Skip to content

Commit

Permalink
Merge pull request #659 from kochebina/Merger
Browse files Browse the repository at this point in the history
Merger simplification
  • Loading branch information
kochebina authored Jan 25, 2024
2 parents a03b407 + bfcb5ef commit 1f56f6b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 7 deletions.
4 changes: 3 additions & 1 deletion source/digits_hits/include/GateDigitizerMerger.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public:
void AddInputCollection(const G4String& );
void DescribeMyself(size_t indent );

void SetInputCollectionID();

protected:
std::vector<G4String> m_names;
std::vector<G4int> m_inputCollectionIDs;
Expand All @@ -54,7 +56,7 @@ private:
GateDigiCollection* m_OutputDigiCollection;

GateSinglesDigitizer *m_digitizer;

G4int m_DigiCollectionID;

};

Expand Down
6 changes: 4 additions & 2 deletions source/digits_hits/include/GateSinglesDigitizer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,23 @@ class GateSinglesDigitizer : public GateModuleListManager
void SetOutputCollectionID();



protected:
GateSinglesDigitizerMessenger* m_messenger;
GateVSystem *m_system; //!< System to which the digitizer is attached
G4String m_outputName;
//G4String m_outputName;
G4String m_inputName;

public:

G4String m_outputName;
G4bool m_recordFlag;

std::vector<GateVDigitizerModule*> m_DMlist; //!< List of DigitizerModules for this digitizer
GateCrystalSD* m_SD;
G4String m_digitizerName;

G4int m_outputDigiCollectionID;
G4int m_digiCollectionID4merger;
};

#endif
59 changes: 56 additions & 3 deletions source/digits_hits/src/GateDigitizerMerger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,31 @@ void GateDigitizerMerger::Digitize()
//Do only in the first event as it is time consuming procedure
if(isFirstEvent)
{
for(G4int i=0; i<m_names.size();i++)
GateDigitizerMgr* mgr=GateDigitizerMgr::GetInstance();

// This block is needed to find the last DM in the inserted SingleDigitizer
for(G4int i=0; i<m_names.size();i++)
{
//G4cout<<m_names[i]<< " "<< fDM->GetDigiCollectionID(m_names[i])<<G4endl;
m_inputCollectionIDs.push_back(fDM->GetDigiCollectionID(m_names[i]));
for(G4int k=0; k<mgr->m_SingleDigitizersList.size();k++)
{

if(mgr->m_SingleDigitizersList[k]->m_outputName != outputCollName)
{
if(mgr->m_SingleDigitizersList[k]->m_outputName == m_names[i])
{
G4int size=mgr->m_SingleDigitizersList[k]->m_DMlist.size();
//G4cout<<"size "<<size<< " of "<< mgr->m_SingleDigitizersList[k]->m_outputName <<G4endl;
G4String inputDMname=mgr->m_SingleDigitizersList[k]->m_DMlist[size-1]->GetName();
//G4cout<< inputDMname <<G4endl;

G4String name=inputDMname+"/"+m_names[i];
//G4cout<< name<<G4endl;
m_inputCollectionIDs.push_back(fDM->GetDigiCollectionID(name));
}

}
}

}

isFirstEvent=false;
Expand Down Expand Up @@ -151,11 +172,43 @@ void GateDigitizerMerger::Digitize()

void GateDigitizerMerger::AddInputCollection(const G4String& name)
{
//adder/Singles_crystal
//name
m_names.push_back(name);
}


void GateDigitizerMerger::SetInputCollectionID()
{

//Save the ID of the last digitizer module for current digitizer
//G4cout<<"GateSinglesDigitizer::SetOuptputCollectionID"<<G4endl;

/* G4DigiManager *fDM = G4DigiManager::GetDMpointer();
G4String name;
if(m_digitizer->m_DMlist.size()>1)
{
GateVDigitizerModule *DM = (GateVDigitizerModule*)(m_digitizer->m_DMlist[m_digitizer->m_DMlist.size()-2]);
name=DM->GetName()+"/"+m_digitizer->GetName()+"_"+m_SD->GetName();
}
else if (m_digitizer->m_DMlist.size()==1)
{
name="DigiInit/"+m_digitizer->GetName()+"_"+m_SD->GetName();
}
else
G4cout<<"error"<<G4endl;
m_DigiCollectionID = fDM->GetDigiCollectionID(name);
G4cout<<"output collecionID "<<m_digitizer->GetName()<<" "<<fDM->GetDigiCollectionID(name)<<G4endl;
*/

}



void GateDigitizerMerger::DescribeMyself(size_t indent )
{
;
Expand Down
2 changes: 1 addition & 1 deletion source/digits_hits/src/GateDigitizerMergerMessenger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ GateDigitizerMergerMessenger::GateDigitizerMergerMessenger (GateDigitizerMerger*

cmdName = GetDirectoryName()+"addInput";
addCollCmd = new G4UIcmdWithAString(cmdName,this);
addCollCmd->SetGuidance("How to generate position");
addCollCmd->SetGuidance("Select input collection");

}

Expand Down
2 changes: 2 additions & 0 deletions source/digits_hits/src/GateSinglesDigitizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ void GateSinglesDigitizer::SetOutputCollectionID()
{
GateVDigitizerModule *DM = (GateVDigitizerModule*)m_DMlist[m_DMlist.size()-1];
name=DM->GetName()+"/"+m_digitizerName+"_"+m_SD->GetName();


}
else
name="DigiInit/"+m_digitizerName+"_"+m_SD->GetName();
Expand Down

0 comments on commit 1f56f6b

Please sign in to comment.