Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParticleHPVector.cc File Reference
#include "G4ParticleHPVector.hh"
#include "G4SystemOfUnits.hh"
#include "G4Threading.hh"

Go to the source code of this file.

Functions

G4ParticleHPVectoroperator+ (G4ParticleHPVector &left, G4ParticleHPVector &right)
 

Function Documentation

◆ operator+()

G4ParticleHPVector & operator+ ( G4ParticleHPVector & left,
G4ParticleHPVector & right )

Definition at line 41 of file G4ParticleHPVector.cc.

42{
43 auto result = new G4ParticleHPVector;
44 G4int j = 0;
45 G4double x;
46 G4double y;
47 G4int running = 0;
48 for (G4int i = 0; i < left.GetVectorLength(); i++) {
49 while (j < right.GetVectorLength()) // Loop checking, 11.05.2015, T. Koi
50 {
51 if (right.GetX(j) < left.GetX(i) * 1.001) {
52 x = right.GetX(j);
53 y = right.GetY(j) + left.GetY(x);
54 result->SetData(running++, x, y);
55 j++;
56 }
57 // else if(std::abs((right.GetX(j)-left.GetX(i))/(left.GetX(i)+right.GetX(j)))>0.001)
58 else if (left.GetX(i) + right.GetX(j) == 0
59 || std::abs((right.GetX(j) - left.GetX(i)) / (left.GetX(i) + right.GetX(j))) > 0.001)
60 {
61 x = left.GetX(i);
62 y = left.GetY(i) + right.GetY(x);
63 result->SetData(running++, x, y);
64 break;
65 }
66 else {
67 break;
68 }
69 }
70 if (j == right.GetVectorLength()) {
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:83
int G4int
Definition G4Types.hh:85
void ThinOut(G4double precision)
G4double GetY(G4double x)
G4double GetX(G4int i) const
G4int GetVectorLength() const