Skip to content

Commit

Permalink
Merge pull request #205 from dsarrut/float-double-time-PSF
Browse files Browse the repository at this point in the history
PSF time now double (was float). Both write (Actor) and read (Source)
  • Loading branch information
dsarrut authored Feb 13, 2019
2 parents 29c73ca + 90f696b commit e5cf543
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion source/digits_hits/include/GatePhaseSpaceActor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected:
float ekPost;
float ekPre;
float w;
float t;//t is either time or local time.
double t;//t is either time or local time.
G4int m;
Char_t vol[256];

Expand Down
2 changes: 1 addition & 1 deletion source/digits_hits/src/GatePhaseSpaceActor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void GatePhaseSpaceActor::Construct()
if (EnableElectronicDEDX) pListeVar->Branch("Ekpost", &ekPost, "Ekpost/F");
if (EnableElectronicDEDX) pListeVar->Branch("Ekpre", &ekPre, "Ekpre/F");
if (EnableWeight) pListeVar->Branch("Weight", &w, "Weight/F");
if (EnableTime || EnableLocalTime) pListeVar->Branch("Time", &t, "Time/F");
if (EnableTime || EnableLocalTime) pListeVar->Branch("Time", &t, "Time/D");
if (EnableMass) pListeVar->Branch("Mass", &m, "Mass/I"); // in MeV/c2
if (EnableXPosition) pListeVar->Branch("X", &x, "X/F");
if (EnableYPosition) pListeVar->Branch("Y", &y, "Y/F");
Expand Down
8 changes: 6 additions & 2 deletions source/physics/include/GateSourcePhaseSpace.hh
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,16 @@ protected:

float energy;
float x, y, z;
float dx, dy, dz, t;
float dx, dy, dz;
float ftime;
double dtime;
EDataType time_type;
float weight;

// char volumeName;
char particleName[64];
G4String mParticleTypeNameGivenByUser;
float mParticleTime ;//m_source->GetTime();
double mParticleTime ;//m_source->GetTime();
G4double mMomentum;

bool mAlreadyLoad;
Expand Down
19 changes: 14 additions & 5 deletions source/physics/src/GateSourcePhaseSpace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ GateSourcePhaseSpace::GateSourcePhaseSpace(G4String name ):GateVSource( name )
pIAEARecordType = 0;
pIAEAheader = 0;


pParticleDefinition = 0;
pParticle = 0;
pVertex = 0;
Expand All @@ -76,7 +75,9 @@ GateSourcePhaseSpace::GateSourcePhaseSpace(G4String name ):GateVSource( name )
mParticleMomentum2 = G4ThreeVector();

x = y = z = dx = dy = dz = px = py = pz = energy = 0.;
t= -1.;
dtime= -1.;
ftime= -1.;
time_type = EDataType::kOther_t;
weight = 1.;
strcpy(particleName, "");

Expand Down Expand Up @@ -137,8 +138,15 @@ void GateSourcePhaseSpace::Initialize()
if (T->GetListOfBranches()->FindObject("Weight")) {
T->SetBranchAddress("Weight",&weight);
}
if (T->GetListOfBranches()->FindObject("Time")) {
T->SetBranchAddress("Time",&t);
auto tob = T->GetListOfBranches()->FindObject("Time");
if (tob) {
auto tt = dynamic_cast<TBranch*>(tob);
TClass * expectedClass;
tt-> GetExpectedType(expectedClass, time_type);
if (time_type == EDataType::kDouble_t)
T->SetBranchAddress("Time",&dtime);
else
T->SetBranchAddress("Time",&ftime);
}

if (mRmax>0){
Expand Down Expand Up @@ -223,7 +231,8 @@ void GateSourcePhaseSpace::GenerateROOTVertex( G4Event* /*aEvent*/ )

mParticleMomentum = G4ThreeVector(px,py,pz);

if (t>0) mParticleTime = t;
if (time_type == EDataType::kDouble_t and dtime>0) mParticleTime = dtime;
if (time_type == EDataType::kFloat_t and ftime>0) mParticleTime = ftime;
}
// ----------------------------------------------------------------------------------

Expand Down

0 comments on commit e5cf543

Please sign in to comment.