Skip to content

Commit 0d2e4d8

Browse files
authored
Merge pull request #752 from kochebina/CleanSpReso
add flag for output for spatialRes2DStdDev
2 parents 6c6fe22 + 2055df5 commit 0d2e4d8

6 files changed

Lines changed: 85 additions & 37 deletions

File tree

source/digits_hits/include/GateToRoot.hh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,11 @@ public:
157157
//--------------------------------------------------------------------------
158158
class VOutputChannel {
159159
public:
160-
inline VOutputChannel(const G4String &aCollectionName, G4bool outputFlag, G4bool CCFlag)
160+
inline VOutputChannel(const G4String &aCollectionName, G4bool outputFlag, G4bool CCFlag, G4bool SpatialRes2DStdDevFlag )
161161
: nVerboseLevel(0),
162162
m_outputFlag(outputFlag),
163163
m_CCFlag(CCFlag),
164+
m_SpatialRes2DStdDevFlag(SpatialRes2DStdDevFlag),
164165
m_collectionName(aCollectionName),
165166
m_collectionID(-1),
166167
m_singlesCommands(0),
@@ -179,6 +180,11 @@ public:
179180
inline void SetCCFlag(G4bool val){m_CCFlag=val;};
180181
inline G4bool GetCCFlag(){return m_CCFlag;};
181182

183+
inline void SetSpatialRes2DStdDevFlag (G4bool val) {m_SpatialRes2DStdDevFlag=val;}
184+
inline G4bool GetSpatialRes2DStdDevFlag () {return m_SpatialRes2DStdDevFlag;}
185+
G4bool m_SpatialRes2DStdDevFlag;
186+
187+
182188

183189
inline void AddSinglesCommand() { m_singlesCommands++; };
184190

@@ -202,7 +208,7 @@ public:
202208
class SingleOutputChannel : public VOutputChannel {
203209
public:
204210
inline SingleOutputChannel(const G4String &aCollectionName, G4bool outputFlag)
205-
: VOutputChannel(aCollectionName, outputFlag, false),
211+
: VOutputChannel(aCollectionName, outputFlag, false, false),
206212
m_tree(0)
207213
{ m_buffer.Clear(); }
208214

@@ -241,6 +247,7 @@ public:
241247
m_tree = new GateSingleTree(treeName);
242248

243249
m_buffer.SetCCFlag(GetCCFlag());
250+
m_buffer.SetSpatialRes2DStdDevFlag(GetSpatialRes2DStdDevFlag());
244251
m_tree->Init(m_buffer);
245252
}
246253
}
@@ -256,7 +263,7 @@ public:
256263
class CoincidenceOutputChannel : public VOutputChannel {
257264
public:
258265
inline CoincidenceOutputChannel(const G4String &aCollectionName, G4bool outputFlag)
259-
: VOutputChannel(aCollectionName, outputFlag, false),
266+
: VOutputChannel(aCollectionName, outputFlag, false, false),
260267
m_tree(0) { m_buffer.Clear(); }
261268

262269
virtual inline ~CoincidenceOutputChannel() {}
@@ -292,6 +299,7 @@ public:
292299
treeName = treeName+"_run"+std::to_string(runID);
293300

294301
m_tree = new GateCoincTree(treeName);
302+
m_buffer.SetSpatialRes2DStdDevFlag(GetSpatialRes2DStdDevFlag());
295303
m_tree->Init(m_buffer);
296304
}
297305
}
@@ -314,6 +322,9 @@ public:
314322

315323
void SetRootHitFlag(G4bool flag) { m_rootHitFlag = flag; };
316324

325+
void SetRootSpRes2DStdDevFlag(G4bool flag) { m_rootSpRes2DStdDevFlag = flag; };
326+
G4bool GetRootSpRes2DStdDevFlag() {return m_rootSpRes2DStdDevFlag; };
327+
317328
void SetRootCCFlag(G4bool flag) { m_rootCCFlag = flag; };
318329
G4bool GetRootCCFlag() {return m_rootCCFlag; };
319330

@@ -422,6 +433,7 @@ private:
422433
// v. cuplov - optical photons
423434

424435
G4bool m_rootHitFlag;
436+
G4bool m_rootSpRes2DStdDevFlag;
425437
G4bool m_rootCCFlag;
426438
G4bool m_rootCCSourceParentIDSpecificationFlag;
427439
G4bool m_rootNtupleFlag;

source/digits_hits/include/GateToRootMessenger.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class GateToRootMessenger: public GateOutputModuleMessenger
5151
GateToRoot* m_gateToRoot;
5252

5353
G4UIcmdWithoutParameter* ResetCmd;
54+
G4UIcmdWithABool* RootSpRes2DStdDevCmd;
5455
G4UIcmdWithABool* RootCCCmd;
5556
G4UIcmdWithABool* RootCCSourceParentIDSpecificationCmd;
5657
G4UIcmdWithABool* RootHitCmd;

source/digits_hits/src/GateToRoot.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ GateToRoot::GateToRoot(const G4String &name, GateOutputMgr *outputMgr, DigiMode
111111
if (digiMode==kofflineMode)
112112
m_fileName="digigate";
113113
*/
114-
m_rootCCFlag=false;
114+
m_rootCCFlag=false;
115+
m_rootSpRes2DStdDevFlag=false;
115116
m_isEnabled = false; // Keep this flag false: all output are disabled by default
116117
nVerboseLevel = 0;
117118

@@ -333,6 +334,7 @@ void GateToRoot::BookBeginOfRun() {
333334
for (size_t i = 0; i < m_outputChannelList.size(); ++i)
334335
{
335336
m_outputChannelList[i]->SetCCFlag(GetRootCCFlag());
337+
m_outputChannelList[i]->SetSpatialRes2DStdDevFlag(GetRootSpRes2DStdDevFlag());
336338
m_outputChannelList[i]->Book();
337339

338340
}

source/digits_hits/src/GateToRootMessenger.cc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ See LICENSE.md for further details
1313

1414

1515
#include "GateToRootMessenger.hh"
16-
1716
#ifdef G4ANALYSIS_USE_ROOT
1817

1918
#include "GateToRoot.hh"
@@ -69,6 +68,10 @@ GateToRootMessenger::GateToRootMessenger(GateToRoot* gateToRoot)
6968
RootCCCmd->SetGuidance("Set the flag for Hits in case of CC ROOT output");
7069
// RootCCCmd->SetGuidance("1. true/false");
7170

71+
72+
cmdName = GetDirectoryName()+"SpRes2DStdDevOutput";
73+
RootSpRes2DStdDevCmd = new G4UIcmdWithABool(cmdName,this);
74+
RootSpRes2DStdDevCmd->SetGuidance("Set the flag for Hits in case of SpRes2DStdDev ROOT output");
7275

7376
cmdName = GetDirectoryName()+"CCoutput/specifysourceParentID";
7477
RootCCSourceParentIDSpecificationCmd = new G4UIcmdWithABool(cmdName,this);
@@ -135,6 +138,8 @@ GateToRootMessenger::~GateToRootMessenger()
135138
delete RootSinglesCmd;
136139
delete RootCoincidencesCmd;
137140

141+
delete RootSpRes2DStdDevCmd;
142+
138143
delete RootCCCmd;
139144
delete RootCCSourceParentIDSpecificationCmd;
140145
delete RootHitCmd;
@@ -164,6 +169,11 @@ void GateToRootMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
164169
} else if (command == RootHitCmd) {
165170
m_gateToRoot->SetRootHitFlag(RootHitCmd->GetNewBoolValue(newValue));
166171
}
172+
173+
else if (command == RootSpRes2DStdDevCmd) {
174+
m_gateToRoot->SetRootSpRes2DStdDevFlag(RootSpRes2DStdDevCmd->GetNewBoolValue(newValue));
175+
}
176+
167177
else if (command == RootCCCmd) {
168178
m_gateToRoot->SetRootCCFlag(RootCCCmd->GetNewBoolValue(newValue));
169179

@@ -230,7 +240,7 @@ void GateToRootMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
230240
}
231241

232242
digitizerMgr->m_recordCoincidences= RootCoincidencesCmd->GetNewBoolValue(newValue);
233-
243+
234244

235245
} else if (command == SaveRndmCmd){
236246
m_gateToRoot->SetSaveRndmFlag(SaveRndmCmd->GetNewBoolValue(newValue));

source/general/include/GateRootDefs.hh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class GateRootHitBuffer
7676
inline void SetCCFlag (G4bool val) {m_CCflag=val;}
7777
inline G4bool GetCCFlag () {return m_CCflag;}
7878

79-
8079
//! Returns the time in G4 units (conversion from seconds)
8180
inline G4double GetTime() const
8281
{ return time * second;}
@@ -239,6 +238,7 @@ class GateRootHitBuffer
239238
Int_t decayType = 0; //Type of positronium decay (check ExtendedVSource)
240239
Int_t gammaType = 0; //Gamma type - single, annhilation, prompt (check ExtendedVSource)
241240

241+
242242
//OK GND for CC
243243
G4bool m_CCflag;
244244
Float_t sourceEnergy;
@@ -303,6 +303,11 @@ class GateRootSingleBuffer
303303
inline G4bool GetCCFlag () {return m_CCflag;}
304304
G4bool m_CCflag;
305305

306+
inline void SetSpatialRes2DStdDevFlag (G4bool val) {m_SpatialRes2DStdDevFlag=val;}
307+
inline G4bool GetSpatialRes2DStdDevFlag () {return m_SpatialRes2DStdDevFlag;}
308+
G4bool m_SpatialRes2DStdDevFlag;
309+
310+
306311
//! \name Data fields
307312
//@{
308313

@@ -395,6 +400,10 @@ class GateRootCoincBuffer
395400
inline G4bool GetCCFlag() {return m_CCflag;}
396401
G4bool m_CCflag;
397402

403+
inline void SetSpatialRes2DStdDevFlag (G4bool val) {m_SpatialRes2DStdDevFlag=val;}
404+
inline G4bool GetSpatialRes2DStdDevFlag () {return m_SpatialRes2DStdDevFlag;}
405+
G4bool m_SpatialRes2DStdDevFlag;
406+
398407
//! \name Data fields
399408
//@{
400409

source/general/src/GateRootDefs.cc

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,12 @@ void GateRootSingleBuffer::Clear()
464464
septalNb = 0;
465465

466466
// initialize spatial resolution stddev fields
467-
spatialRes2DStdDevX = 0.;
468-
spatialRes2DStdDevY = 0.;
469-
spatialRes2DStdDevZ = 0.;
467+
if(GetSpatialRes2DStdDevFlag())
468+
{
469+
spatialRes2DStdDevX = 0.;
470+
spatialRes2DStdDevY = 0.;
471+
spatialRes2DStdDevZ = 0.;
472+
}
470473
for ( d = 0 ; d < ROOT_VOLUMEIDSIZE ; ++d )
471474
volumeID[d] = -1;
472475

@@ -494,10 +497,12 @@ void GateRootSingleBuffer::Clear()
494497
nCrystalConv=0;
495498
nCrystalCompt=0;
496499
nCrystalRayl=0;
497-
498-
spatialRes2DStdDevX = 0.;
499-
spatialRes2DStdDevY = 0.;
500-
spatialRes2DStdDevZ = 0.;
500+
if(GetSpatialRes2DStdDevFlag())
501+
{
502+
spatialRes2DStdDevX = 0.;
503+
spatialRes2DStdDevY = 0.;
504+
spatialRes2DStdDevZ = 0.;
505+
}
501506

502507
}
503508

@@ -559,12 +564,13 @@ void GateRootSingleBuffer::Fill(GateDigi* aDigi)
559564
nCrystalCompt =aDigi->GetNCrystalCompton();
560565

561566
}
562-
563-
// spatial resolution stddevs stored by digitizer (in internal units), convert to mm for output
564-
spatialRes2DStdDevX = static_cast<Float_t>(aDigi->GetSpatialRes2DStdDevX()/mm);
565-
spatialRes2DStdDevY = static_cast<Float_t>(aDigi->GetSpatialRes2DStdDevY()/mm);
566-
spatialRes2DStdDevZ = static_cast<Float_t>(aDigi->GetSpatialRes2DStdDevZ()/mm);
567-
567+
if(GetSpatialRes2DStdDevFlag())
568+
{
569+
// spatial resolution stddevs stored by digitizer (in internal units), convert to mm for output
570+
spatialRes2DStdDevX = static_cast<Float_t>(aDigi->GetSpatialRes2DStdDevX()/mm);
571+
spatialRes2DStdDevY = static_cast<Float_t>(aDigi->GetSpatialRes2DStdDevY()/mm);
572+
spatialRes2DStdDevZ = static_cast<Float_t>(aDigi->GetSpatialRes2DStdDevZ()/mm);
573+
}
568574

569575
aDigi->GetVolumeID().StoreDaughterIDs(volumeID,ROOT_VOLUMEIDSIZE);
570576
}
@@ -643,12 +649,13 @@ void GateSingleTree::Init(GateRootSingleBuffer& buffer)
643649
Branch("energyIni", &buffer.energyIni,"energyIni/F");
644650

645651
}
646-
647-
// spatial resolution stddevs (2D distribution) - in mm
648-
Branch("spatialRes2DStdDevX", &buffer.spatialRes2DStdDevX, "spatialRes2DStdDevX/F");
649-
Branch("spatialRes2DStdDevY", &buffer.spatialRes2DStdDevY, "spatialRes2DStdDevY/F");
650-
Branch("spatialRes2DStdDevZ", &buffer.spatialRes2DStdDevZ, "spatialRes2DStdDevZ/F");
651-
652+
if(buffer.GetSpatialRes2DStdDevFlag())
653+
{
654+
// spatial resolution stddevs (2D distribution) - in mm
655+
Branch("spatialRes2DStdDevX", &buffer.spatialRes2DStdDevX, "spatialRes2DStdDevX/F");
656+
Branch("spatialRes2DStdDevY", &buffer.spatialRes2DStdDevY, "spatialRes2DStdDevY/F");
657+
Branch("spatialRes2DStdDevZ", &buffer.spatialRes2DStdDevZ, "spatialRes2DStdDevZ/F");
658+
}
652659
//Initialized by default.TO DO: Mask option should be included or a flag
653660
Branch("volumeID", (void *)buffer.volumeID,"volumeID[10]/I");
654661
}
@@ -701,11 +708,14 @@ void GateRootCoincBuffer::Clear()
701708
RayleighCrystal2 = -1;
702709
strcpy (comptonVolumeName2," ");
703710
strcpy (RayleighVolumeName2," ");
704-
705-
// initialize spatial resolution stddev fields for coincidences
706-
spatialRes2DStdDevX = 0.;
707-
spatialRes2DStdDevY = 0.;
708-
spatialRes2DStdDevZ = 0.;
711+
712+
if(GetSpatialRes2DStdDevFlag())
713+
{
714+
// initialize spatial resolution stddev fields for coincidences
715+
spatialRes2DStdDevX = 0.;
716+
spatialRes2DStdDevY = 0.;
717+
spatialRes2DStdDevZ = 0.;
718+
}
709719
}
710720

711721

@@ -760,6 +770,8 @@ void GateRootCoincBuffer::Fill(GateCoincidenceDigi* aDigi)
760770
strcpy (comptonVolumeName2,((aDigi->GetDigi(1))->GetComptonVolumeName()).c_str());
761771
strcpy (RayleighVolumeName2,((aDigi->GetDigi(1))->GetRayleighVolumeName()).c_str());
762772

773+
774+
if(GetSpatialRes2DStdDevFlag())
763775
// spatial resolution stddevs: average the two constituent digis and convert to mm for output
764776
{
765777
G4double sX1 = (aDigi->GetDigi(0))->GetSpatialRes2DStdDevX();
@@ -902,12 +914,14 @@ void GateCoincTree::Init(GateRootCoincBuffer& buffer)
902914
Branch("sinogramTheta", &buffer.sinogramTheta,"sinogramTheta/F");
903915
if ( GateCoincidenceDigi::GetCoincidenceASCIIMask(19) )
904916
Branch("sinogramS", &buffer.sinogramS,"sinogramS/F");
905-
906-
// spatial resolution stddevs (averaged per coincidence) - in mm
907-
Branch("spatialRes2DStdDevX", &buffer.spatialRes2DStdDevX, "spatialRes2DStdDevX/F");
908-
Branch("spatialRes2DStdDevY", &buffer.spatialRes2DStdDevY, "spatialRes2DStdDevY/F");
909-
Branch("spatialRes2DStdDevZ", &buffer.spatialRes2DStdDevZ, "spatialRes2DStdDevZ/F");
910-
917+
918+
if(buffer.GetSpatialRes2DStdDevFlag())
919+
{
920+
// spatial resolution stddevs (averaged per coincidence) - in mm
921+
Branch("spatialRes2DStdDevX", &buffer.spatialRes2DStdDevX, "spatialRes2DStdDevX/F");
922+
Branch("spatialRes2DStdDevY", &buffer.spatialRes2DStdDevY, "spatialRes2DStdDevY/F");
923+
Branch("spatialRes2DStdDevZ", &buffer.spatialRes2DStdDevZ, "spatialRes2DStdDevZ/F");
924+
}
911925
if ( GateCoincidenceDigi::GetCoincidenceASCIIMask(20) )
912926
Branch("comptVolName1", (void *)buffer.comptonVolumeName1,"comptVolName1/C");
913927
if ( GateCoincidenceDigi::GetCoincidenceASCIIMask(20) )

0 commit comments

Comments
 (0)