diff --git a/source/digits_hits/include/GateToRoot.hh b/source/digits_hits/include/GateToRoot.hh index d26384c43..18f85be23 100644 --- a/source/digits_hits/include/GateToRoot.hh +++ b/source/digits_hits/include/GateToRoot.hh @@ -157,10 +157,11 @@ public: //-------------------------------------------------------------------------- class VOutputChannel { public: - inline VOutputChannel(const G4String &aCollectionName, G4bool outputFlag, G4bool CCFlag) + inline VOutputChannel(const G4String &aCollectionName, G4bool outputFlag, G4bool CCFlag, G4bool SpatialRes2DStdDevFlag ) : nVerboseLevel(0), m_outputFlag(outputFlag), m_CCFlag(CCFlag), + m_SpatialRes2DStdDevFlag(SpatialRes2DStdDevFlag), m_collectionName(aCollectionName), m_collectionID(-1), m_singlesCommands(0), @@ -179,6 +180,11 @@ public: inline void SetCCFlag(G4bool val){m_CCFlag=val;}; inline G4bool GetCCFlag(){return m_CCFlag;}; + inline void SetSpatialRes2DStdDevFlag (G4bool val) {m_SpatialRes2DStdDevFlag=val;} + inline G4bool GetSpatialRes2DStdDevFlag () {return m_SpatialRes2DStdDevFlag;} + G4bool m_SpatialRes2DStdDevFlag; + + inline void AddSinglesCommand() { m_singlesCommands++; }; @@ -202,7 +208,7 @@ public: class SingleOutputChannel : public VOutputChannel { public: inline SingleOutputChannel(const G4String &aCollectionName, G4bool outputFlag) - : VOutputChannel(aCollectionName, outputFlag, false), + : VOutputChannel(aCollectionName, outputFlag, false, false), m_tree(0) { m_buffer.Clear(); } @@ -241,6 +247,7 @@ public: m_tree = new GateSingleTree(treeName); m_buffer.SetCCFlag(GetCCFlag()); + m_buffer.SetSpatialRes2DStdDevFlag(GetSpatialRes2DStdDevFlag()); m_tree->Init(m_buffer); } } @@ -256,7 +263,7 @@ public: class CoincidenceOutputChannel : public VOutputChannel { public: inline CoincidenceOutputChannel(const G4String &aCollectionName, G4bool outputFlag) - : VOutputChannel(aCollectionName, outputFlag, false), + : VOutputChannel(aCollectionName, outputFlag, false, false), m_tree(0) { m_buffer.Clear(); } virtual inline ~CoincidenceOutputChannel() {} @@ -292,6 +299,7 @@ public: treeName = treeName+"_run"+std::to_string(runID); m_tree = new GateCoincTree(treeName); + m_buffer.SetSpatialRes2DStdDevFlag(GetSpatialRes2DStdDevFlag()); m_tree->Init(m_buffer); } } @@ -314,6 +322,9 @@ public: void SetRootHitFlag(G4bool flag) { m_rootHitFlag = flag; }; + void SetRootSpRes2DStdDevFlag(G4bool flag) { m_rootSpRes2DStdDevFlag = flag; }; + G4bool GetRootSpRes2DStdDevFlag() {return m_rootSpRes2DStdDevFlag; }; + void SetRootCCFlag(G4bool flag) { m_rootCCFlag = flag; }; G4bool GetRootCCFlag() {return m_rootCCFlag; }; @@ -422,6 +433,7 @@ private: // v. cuplov - optical photons G4bool m_rootHitFlag; + G4bool m_rootSpRes2DStdDevFlag; G4bool m_rootCCFlag; G4bool m_rootCCSourceParentIDSpecificationFlag; G4bool m_rootNtupleFlag; diff --git a/source/digits_hits/include/GateToRootMessenger.hh b/source/digits_hits/include/GateToRootMessenger.hh index ee6bcdbb3..4dc62a12b 100644 --- a/source/digits_hits/include/GateToRootMessenger.hh +++ b/source/digits_hits/include/GateToRootMessenger.hh @@ -51,6 +51,7 @@ class GateToRootMessenger: public GateOutputModuleMessenger GateToRoot* m_gateToRoot; G4UIcmdWithoutParameter* ResetCmd; + G4UIcmdWithABool* RootSpRes2DStdDevCmd; G4UIcmdWithABool* RootCCCmd; G4UIcmdWithABool* RootCCSourceParentIDSpecificationCmd; G4UIcmdWithABool* RootHitCmd; diff --git a/source/digits_hits/src/GateToRoot.cc b/source/digits_hits/src/GateToRoot.cc index 9a1758991..2626daf8d 100644 --- a/source/digits_hits/src/GateToRoot.cc +++ b/source/digits_hits/src/GateToRoot.cc @@ -111,7 +111,8 @@ GateToRoot::GateToRoot(const G4String &name, GateOutputMgr *outputMgr, DigiMode if (digiMode==kofflineMode) m_fileName="digigate"; */ - m_rootCCFlag=false; + m_rootCCFlag=false; + m_rootSpRes2DStdDevFlag=false; m_isEnabled = false; // Keep this flag false: all output are disabled by default nVerboseLevel = 0; @@ -333,6 +334,7 @@ void GateToRoot::BookBeginOfRun() { for (size_t i = 0; i < m_outputChannelList.size(); ++i) { m_outputChannelList[i]->SetCCFlag(GetRootCCFlag()); + m_outputChannelList[i]->SetSpatialRes2DStdDevFlag(GetRootSpRes2DStdDevFlag()); m_outputChannelList[i]->Book(); } diff --git a/source/digits_hits/src/GateToRootMessenger.cc b/source/digits_hits/src/GateToRootMessenger.cc index 39fd07ca4..fafa44894 100644 --- a/source/digits_hits/src/GateToRootMessenger.cc +++ b/source/digits_hits/src/GateToRootMessenger.cc @@ -13,7 +13,6 @@ See LICENSE.md for further details #include "GateToRootMessenger.hh" - #ifdef G4ANALYSIS_USE_ROOT #include "GateToRoot.hh" @@ -69,6 +68,10 @@ GateToRootMessenger::GateToRootMessenger(GateToRoot* gateToRoot) RootCCCmd->SetGuidance("Set the flag for Hits in case of CC ROOT output"); // RootCCCmd->SetGuidance("1. true/false"); + + cmdName = GetDirectoryName()+"SpRes2DStdDevOutput"; + RootSpRes2DStdDevCmd = new G4UIcmdWithABool(cmdName,this); + RootSpRes2DStdDevCmd->SetGuidance("Set the flag for Hits in case of SpRes2DStdDev ROOT output"); cmdName = GetDirectoryName()+"CCoutput/specifysourceParentID"; RootCCSourceParentIDSpecificationCmd = new G4UIcmdWithABool(cmdName,this); @@ -135,6 +138,8 @@ GateToRootMessenger::~GateToRootMessenger() delete RootSinglesCmd; delete RootCoincidencesCmd; + delete RootSpRes2DStdDevCmd; + delete RootCCCmd; delete RootCCSourceParentIDSpecificationCmd; delete RootHitCmd; @@ -164,6 +169,11 @@ void GateToRootMessenger::SetNewValue(G4UIcommand* command, G4String newValue) } else if (command == RootHitCmd) { m_gateToRoot->SetRootHitFlag(RootHitCmd->GetNewBoolValue(newValue)); } + + else if (command == RootSpRes2DStdDevCmd) { + m_gateToRoot->SetRootSpRes2DStdDevFlag(RootSpRes2DStdDevCmd->GetNewBoolValue(newValue)); + } + else if (command == RootCCCmd) { m_gateToRoot->SetRootCCFlag(RootCCCmd->GetNewBoolValue(newValue)); @@ -230,7 +240,7 @@ void GateToRootMessenger::SetNewValue(G4UIcommand* command, G4String newValue) } digitizerMgr->m_recordCoincidences= RootCoincidencesCmd->GetNewBoolValue(newValue); - + } else if (command == SaveRndmCmd){ m_gateToRoot->SetSaveRndmFlag(SaveRndmCmd->GetNewBoolValue(newValue)); diff --git a/source/general/include/GateRootDefs.hh b/source/general/include/GateRootDefs.hh index 14727a544..cc199af8f 100644 --- a/source/general/include/GateRootDefs.hh +++ b/source/general/include/GateRootDefs.hh @@ -76,7 +76,6 @@ class GateRootHitBuffer inline void SetCCFlag (G4bool val) {m_CCflag=val;} inline G4bool GetCCFlag () {return m_CCflag;} - //! Returns the time in G4 units (conversion from seconds) inline G4double GetTime() const { return time * second;} @@ -239,6 +238,7 @@ class GateRootHitBuffer Int_t decayType = 0; //Type of positronium decay (check ExtendedVSource) Int_t gammaType = 0; //Gamma type - single, annhilation, prompt (check ExtendedVSource) + //OK GND for CC G4bool m_CCflag; Float_t sourceEnergy; @@ -303,6 +303,11 @@ class GateRootSingleBuffer inline G4bool GetCCFlag () {return m_CCflag;} G4bool m_CCflag; + inline void SetSpatialRes2DStdDevFlag (G4bool val) {m_SpatialRes2DStdDevFlag=val;} + inline G4bool GetSpatialRes2DStdDevFlag () {return m_SpatialRes2DStdDevFlag;} + G4bool m_SpatialRes2DStdDevFlag; + + //! \name Data fields //@{ @@ -395,6 +400,10 @@ class GateRootCoincBuffer inline G4bool GetCCFlag() {return m_CCflag;} G4bool m_CCflag; + inline void SetSpatialRes2DStdDevFlag (G4bool val) {m_SpatialRes2DStdDevFlag=val;} + inline G4bool GetSpatialRes2DStdDevFlag () {return m_SpatialRes2DStdDevFlag;} + G4bool m_SpatialRes2DStdDevFlag; + //! \name Data fields //@{ diff --git a/source/general/src/GateRootDefs.cc b/source/general/src/GateRootDefs.cc index bfc90339d..b5840963b 100644 --- a/source/general/src/GateRootDefs.cc +++ b/source/general/src/GateRootDefs.cc @@ -464,9 +464,12 @@ void GateRootSingleBuffer::Clear() septalNb = 0; // initialize spatial resolution stddev fields - spatialRes2DStdDevX = 0.; - spatialRes2DStdDevY = 0.; - spatialRes2DStdDevZ = 0.; + if(GetSpatialRes2DStdDevFlag()) + { + spatialRes2DStdDevX = 0.; + spatialRes2DStdDevY = 0.; + spatialRes2DStdDevZ = 0.; + } for ( d = 0 ; d < ROOT_VOLUMEIDSIZE ; ++d ) volumeID[d] = -1; @@ -494,10 +497,12 @@ void GateRootSingleBuffer::Clear() nCrystalConv=0; nCrystalCompt=0; nCrystalRayl=0; - - spatialRes2DStdDevX = 0.; - spatialRes2DStdDevY = 0.; - spatialRes2DStdDevZ = 0.; + if(GetSpatialRes2DStdDevFlag()) + { + spatialRes2DStdDevX = 0.; + spatialRes2DStdDevY = 0.; + spatialRes2DStdDevZ = 0.; + } } @@ -559,12 +564,13 @@ void GateRootSingleBuffer::Fill(GateDigi* aDigi) nCrystalCompt =aDigi->GetNCrystalCompton(); } - - // spatial resolution stddevs stored by digitizer (in internal units), convert to mm for output - spatialRes2DStdDevX = static_cast(aDigi->GetSpatialRes2DStdDevX()/mm); - spatialRes2DStdDevY = static_cast(aDigi->GetSpatialRes2DStdDevY()/mm); - spatialRes2DStdDevZ = static_cast(aDigi->GetSpatialRes2DStdDevZ()/mm); - + if(GetSpatialRes2DStdDevFlag()) + { + // spatial resolution stddevs stored by digitizer (in internal units), convert to mm for output + spatialRes2DStdDevX = static_cast(aDigi->GetSpatialRes2DStdDevX()/mm); + spatialRes2DStdDevY = static_cast(aDigi->GetSpatialRes2DStdDevY()/mm); + spatialRes2DStdDevZ = static_cast(aDigi->GetSpatialRes2DStdDevZ()/mm); + } aDigi->GetVolumeID().StoreDaughterIDs(volumeID,ROOT_VOLUMEIDSIZE); } @@ -643,12 +649,13 @@ void GateSingleTree::Init(GateRootSingleBuffer& buffer) Branch("energyIni", &buffer.energyIni,"energyIni/F"); } - - // spatial resolution stddevs (2D distribution) - in mm - Branch("spatialRes2DStdDevX", &buffer.spatialRes2DStdDevX, "spatialRes2DStdDevX/F"); - Branch("spatialRes2DStdDevY", &buffer.spatialRes2DStdDevY, "spatialRes2DStdDevY/F"); - Branch("spatialRes2DStdDevZ", &buffer.spatialRes2DStdDevZ, "spatialRes2DStdDevZ/F"); - + if(buffer.GetSpatialRes2DStdDevFlag()) + { + // spatial resolution stddevs (2D distribution) - in mm + Branch("spatialRes2DStdDevX", &buffer.spatialRes2DStdDevX, "spatialRes2DStdDevX/F"); + Branch("spatialRes2DStdDevY", &buffer.spatialRes2DStdDevY, "spatialRes2DStdDevY/F"); + Branch("spatialRes2DStdDevZ", &buffer.spatialRes2DStdDevZ, "spatialRes2DStdDevZ/F"); + } //Initialized by default.TO DO: Mask option should be included or a flag Branch("volumeID", (void *)buffer.volumeID,"volumeID[10]/I"); } @@ -701,11 +708,14 @@ void GateRootCoincBuffer::Clear() RayleighCrystal2 = -1; strcpy (comptonVolumeName2," "); strcpy (RayleighVolumeName2," "); - - // initialize spatial resolution stddev fields for coincidences - spatialRes2DStdDevX = 0.; - spatialRes2DStdDevY = 0.; - spatialRes2DStdDevZ = 0.; + + if(GetSpatialRes2DStdDevFlag()) + { + // initialize spatial resolution stddev fields for coincidences + spatialRes2DStdDevX = 0.; + spatialRes2DStdDevY = 0.; + spatialRes2DStdDevZ = 0.; + } } @@ -760,6 +770,8 @@ void GateRootCoincBuffer::Fill(GateCoincidenceDigi* aDigi) strcpy (comptonVolumeName2,((aDigi->GetDigi(1))->GetComptonVolumeName()).c_str()); strcpy (RayleighVolumeName2,((aDigi->GetDigi(1))->GetRayleighVolumeName()).c_str()); + + if(GetSpatialRes2DStdDevFlag()) // spatial resolution stddevs: average the two constituent digis and convert to mm for output { G4double sX1 = (aDigi->GetDigi(0))->GetSpatialRes2DStdDevX(); @@ -902,12 +914,14 @@ void GateCoincTree::Init(GateRootCoincBuffer& buffer) Branch("sinogramTheta", &buffer.sinogramTheta,"sinogramTheta/F"); if ( GateCoincidenceDigi::GetCoincidenceASCIIMask(19) ) Branch("sinogramS", &buffer.sinogramS,"sinogramS/F"); - - // spatial resolution stddevs (averaged per coincidence) - in mm - Branch("spatialRes2DStdDevX", &buffer.spatialRes2DStdDevX, "spatialRes2DStdDevX/F"); - Branch("spatialRes2DStdDevY", &buffer.spatialRes2DStdDevY, "spatialRes2DStdDevY/F"); - Branch("spatialRes2DStdDevZ", &buffer.spatialRes2DStdDevZ, "spatialRes2DStdDevZ/F"); - + + if(buffer.GetSpatialRes2DStdDevFlag()) + { + // spatial resolution stddevs (averaged per coincidence) - in mm + Branch("spatialRes2DStdDevX", &buffer.spatialRes2DStdDevX, "spatialRes2DStdDevX/F"); + Branch("spatialRes2DStdDevY", &buffer.spatialRes2DStdDevY, "spatialRes2DStdDevY/F"); + Branch("spatialRes2DStdDevZ", &buffer.spatialRes2DStdDevZ, "spatialRes2DStdDevZ/F"); + } if ( GateCoincidenceDigi::GetCoincidenceASCIIMask(20) ) Branch("comptVolName1", (void *)buffer.comptonVolumeName1,"comptVolName1/C"); if ( GateCoincidenceDigi::GetCoincidenceASCIIMask(20) )