Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions source/digits_hits/include/GateToRoot.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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++; };

Expand All @@ -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(); }

Expand Down Expand Up @@ -241,6 +247,7 @@ public:
m_tree = new GateSingleTree(treeName);

m_buffer.SetCCFlag(GetCCFlag());
m_buffer.SetSpatialRes2DStdDevFlag(GetSpatialRes2DStdDevFlag());
m_tree->Init(m_buffer);
}
}
Expand All @@ -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() {}
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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; };

Expand Down Expand Up @@ -422,6 +433,7 @@ private:
// v. cuplov - optical photons

G4bool m_rootHitFlag;
G4bool m_rootSpRes2DStdDevFlag;
G4bool m_rootCCFlag;
G4bool m_rootCCSourceParentIDSpecificationFlag;
G4bool m_rootNtupleFlag;
Expand Down
1 change: 1 addition & 0 deletions source/digits_hits/include/GateToRootMessenger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class GateToRootMessenger: public GateOutputModuleMessenger
GateToRoot* m_gateToRoot;

G4UIcmdWithoutParameter* ResetCmd;
G4UIcmdWithABool* RootSpRes2DStdDevCmd;
G4UIcmdWithABool* RootCCCmd;
G4UIcmdWithABool* RootCCSourceParentIDSpecificationCmd;
G4UIcmdWithABool* RootHitCmd;
Expand Down
4 changes: 3 additions & 1 deletion source/digits_hits/src/GateToRoot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();

}
Expand Down
14 changes: 12 additions & 2 deletions source/digits_hits/src/GateToRootMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ See LICENSE.md for further details


#include "GateToRootMessenger.hh"

#ifdef G4ANALYSIS_USE_ROOT

#include "GateToRoot.hh"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -135,6 +138,8 @@ GateToRootMessenger::~GateToRootMessenger()
delete RootSinglesCmd;
delete RootCoincidencesCmd;

delete RootSpRes2DStdDevCmd;

delete RootCCCmd;
delete RootCCSourceParentIDSpecificationCmd;
delete RootHitCmd;
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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));
Expand Down
11 changes: 10 additions & 1 deletion source/general/include/GateRootDefs.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
//@{

Expand Down Expand Up @@ -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
//@{

Expand Down
74 changes: 44 additions & 30 deletions source/general/src/GateRootDefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.;
}

}

Expand Down Expand Up @@ -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<Float_t>(aDigi->GetSpatialRes2DStdDevX()/mm);
spatialRes2DStdDevY = static_cast<Float_t>(aDigi->GetSpatialRes2DStdDevY()/mm);
spatialRes2DStdDevZ = static_cast<Float_t>(aDigi->GetSpatialRes2DStdDevZ()/mm);

if(GetSpatialRes2DStdDevFlag())
{
// spatial resolution stddevs stored by digitizer (in internal units), convert to mm for output
spatialRes2DStdDevX = static_cast<Float_t>(aDigi->GetSpatialRes2DStdDevX()/mm);
spatialRes2DStdDevY = static_cast<Float_t>(aDigi->GetSpatialRes2DStdDevY()/mm);
spatialRes2DStdDevZ = static_cast<Float_t>(aDigi->GetSpatialRes2DStdDevZ()/mm);
}

aDigi->GetVolumeID().StoreDaughterIDs(volumeID,ROOT_VOLUMEIDSIZE);
}
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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.;
}
}


Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) )
Expand Down
Loading