Skip to content

Commit

Permalink
Common Output in GAteToTree
Browse files Browse the repository at this point in the history
  • Loading branch information
kochebina authored and tbaudier committed Jul 24, 2024
1 parent 1a763eb commit c61303a
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 7 deletions.
5 changes: 5 additions & 0 deletions source/digits_hits/include/GateToTree.hh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public:
static void SetOutputIDName(G4int id_system, const char * anOutputIDName, size_t depth);
G4bool getHitsEnabled() const;
void setHitsEnabled(G4bool mHitsEnabled);

G4bool getHitsCommonOutputEnabled() const;
void setHitsCommonOutputEnabled(G4bool mHitsCommonOutputEnabled);

void addCollection(const std::string &str); //called by messenger
//OK GND 2022
void setCCenabled(G4bool mCCenabled){m_cc_enabled=mCCenabled;};
Expand Down Expand Up @@ -135,6 +139,7 @@ private:
std::vector<std::string> m_listOfSinglesCollection;
std::vector<std::string> m_listOfCoincidencesCollection;
G4bool m_hits_enabled;
G4bool m_hitsCommonOutput_enabled;
G4String m_uselessFileName; //only for GiveNameOfFile which return a reference..

G4bool m_opticalData_enabled = false;
Expand Down
4 changes: 4 additions & 0 deletions source/digits_hits/include/GateToTreeMessenger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ private:
G4UIcmdWithoutParameter *m_enableHitsOutput;
G4UIcmdWithoutParameter *m_disableHitsOutput;

G4UIcmdWithoutParameter *m_enableHitsCommonOutput;
G4UIcmdWithoutParameter *m_disableHitsCommonOutput;


G4UIcmdWithoutParameter *m_enableOpticalDataOutput;
G4UIcmdWithoutParameter *m_disableOpticalDataOutput;

Expand Down
47 changes: 40 additions & 7 deletions source/digits_hits/src/GateToTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,30 @@ GateToTree::GateToTree(const G4String &name, GateOutputMgr *outputMgr, DigiMode

m_messenger = new GateToTreeMessenger(this);
m_hits_enabled = false;
m_hitsCommonOutput_enabled = false;




}

void GateToTree::RecordBeginOfAcquisition() {
if (m_hits_enabled && m_hitsCommonOutput_enabled)
GateError("Commands /hits/ and /hitsCommonOutput/ cannot be enabled at the same time");

if (!this->IsEnabled())
return;

/* if (m_hits_enabled) {
if (m_hitsCommonOutput_enabled) {
for (auto &&fileName: m_listOfFileName) {
auto extension = getExtension(fileName);
auto name = removeExtension(fileName);

G4String hits_filename = name + ".hits." + extension;
m_manager_hits.add_file(hits_filename, extension);
}
*/
}

//OK GND 2022
for (auto &&m: m_mmanager_hits)
{
Expand Down Expand Up @@ -691,9 +700,15 @@ void GateToTree::RecordEndOfAcquisition() {
//m_manager_optical.close();

//OK GND 2022

if(m_hitsCommonOutput_enabled)
{
m_manager_hits.close();
}
else
{
for (auto &&m: m_mmanager_hits)
m.second.close();
}

for (auto &&m: m_mmanager_optical)
m.second.close();
Expand All @@ -719,9 +734,10 @@ void GateToTree::RecordBeginOfEvent(const G4Event *event) {
}

void GateToTree::RecordEndOfEvent(const G4Event *event) {
auto fDM = G4DigiManager::GetDMpointer();

//OK GND 2022
auto fDM = G4DigiManager::GetDMpointer();


if (!m_hits_to_collectionID.size()) {
for (auto &&m: m_mmanager_hits) {
Expand Down Expand Up @@ -829,12 +845,19 @@ void GateToTree::RecordEndOfEvent(const G4Event *event) {
m_energyIniT=hit->GetEnergyIniTrack();
}

if(m_hitsCommonOutput_enabled)
{
m_manager_hits.fill();
}
else
{
m.second.fill();
//m_manager_hits.fill();
}

}
}
}
//auto fDM = G4DigiManager::GetDMpointer();

//}
if (!m_singles_to_collectionID.size()) {
for (auto &&m: m_mmanager_singles) {
// auto collectionID = fDM->GetDigiCollectionID(m.first);
Expand Down Expand Up @@ -1083,6 +1106,15 @@ void GateToTree::setHitsEnabled(G4bool mHitsEnabled) {

}

G4bool GateToTree::getHitsCommonOutputEnabled() const {
return m_hitsCommonOutput_enabled;
}

void GateToTree::setHitsCommonOutputEnabled(G4bool mHitsCommonOutputEnabled) {
m_hitsCommonOutput_enabled = mHitsCommonOutputEnabled;
}


//OK GND 2022
void GateToTree::addHitsCollection(const std::string &str) {
GateDigitizerMgr* digitizerMgr = GateDigitizerMgr::GetInstance();
Expand All @@ -1104,6 +1136,7 @@ void GateToTree::addHitsCollection(const std::string &str) {
n_fileName = name + ".hits." + extension;
else
n_fileName = name + ".hits_" + str + "." + extension;
if(!m_hitsCommonOutput_enabled)
m.add_file(n_fileName, extension);

}
Expand Down
11 changes: 11 additions & 0 deletions source/digits_hits/src/GateToTreeMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ GateToTreeMessenger::GateToTreeMessenger(GateToTree *m) :
m_enableHitsOutput = new G4UIcmdWithoutParameter("/gate/output/tree/hits/enable", this);
m_disableHitsOutput = new G4UIcmdWithoutParameter("/gate/output/tree/hits/disable", this);

m_enableHitsCommonOutput = new G4UIcmdWithoutParameter("/gate/output/tree/hitsCommonOutput/enable", this);
m_disableHitsCommonOutput = new G4UIcmdWithoutParameter("/gate/output/tree/hitsCommonOutput/disable", this);


m_enableOpticalDataOutput = new G4UIcmdWithoutParameter("/gate/output/tree/optical/enable", this);
m_disableOpticalDataOutput = new G4UIcmdWithoutParameter("/gate/output/tree/optical/disable", this);

Expand Down Expand Up @@ -103,6 +107,8 @@ GateToTreeMessenger::~GateToTreeMessenger()
delete m_addOpticalCollectionCmd;
delete m_enableHitsOutput;
delete m_disableHitsOutput;
delete m_enableHitsCommonOutput;
delete m_disableHitsCommonOutput;

}

Expand All @@ -119,6 +125,11 @@ void GateToTreeMessenger::SetNewValue(G4UIcommand *icommand, G4String string)
if(icommand == m_disableHitsOutput)
m_gateToTree->setHitsEnabled(false);

if(icommand == m_enableHitsCommonOutput)
m_gateToTree->setHitsCommonOutputEnabled(true);
if(icommand == m_disableHitsCommonOutput)
m_gateToTree->setHitsCommonOutputEnabled(false);

if(icommand == m_enableOpticalDataOutput)
m_gateToTree->setOpticalDataEnabled(true);
if(icommand == m_disableOpticalDataOutput)
Expand Down

0 comments on commit c61303a

Please sign in to comment.