Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4NeutronHPVector.cc File Reference

Go to the source code of this file.

Functions

G4NeutronHPVectoroperator+ (G4NeutronHPVector &left, G4NeutronHPVector &right)
 

Function Documentation

◆ operator+()

G4NeutronHPVector & operator+ ( G4NeutronHPVector left,
G4NeutronHPVector right 
)

Definition at line 37 of file G4NeutronHPVector.cc.

38 {
40 G4int j=0;
41 G4double x;
42 G4double y;
43 G4int running = 0;
44 for(G4int i=0; i<left.GetVectorLength(); i++)
45 {
46 while(j<right.GetVectorLength())
47 {
48 if(right.GetX(j)<left.GetX(i)*1.001)
49 {
50 x = right.GetX(j);
51 y = right.GetY(j)+left.GetY(x);
52 result->SetData(running++, x, y);
53 j++;
54 }
55 //else if(std::abs((right.GetX(j)-left.GetX(i))/(left.GetX(i)+right.GetX(j)))>0.001)
56 else if( left.GetX(i)+right.GetX(j) == 0
57 || std::abs((right.GetX(j)-left.GetX(i))/(left.GetX(i)+right.GetX(j))) > 0.001 )
58 {
59 x = left.GetX(i);
60 y = left.GetY(i)+right.GetY(x);
61 result->SetData(running++, x, y);
62 break;
63 }
64 else
65 {
66 break;
67 }
68 }
69 if(j==right.GetVectorLength())
70 {
71 x = left.GetX(i);
72 y = left.GetY(i)+right.GetY(x);
73 result->SetData(running++, x, y);
74 }
75 }
76 result->ThinOut(0.02);
77 return *result;
78 }
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
G4int GetVectorLength() const
G4double GetX(G4int i) const
G4double GetY(G4double x)
void SetData(G4int i, G4double x, G4double y)
void ThinOut(G4double precision)