16 #include "G4UImanager.hh" 17 #include "G4UIterminal.hh" 18 #include "G4UItcsh.hh" 19 #include "G4LogicalVolumeStore.hh" 20 #include "G4TouchableHistory.hh" 21 #include "G4VPhysicalVolume.hh" 22 #include "G4VProcess.hh" 23 #include "G4ParticleTable.hh" 24 #include "G4ParticleDefinition.hh" 25 #include "G4ProcessManager.hh" 26 #include "G4TransportationManager.hh" 40 std::vector<std::string> volList = m_Anal.
getParameter< std::vector<std::string> >(
"SelectedVolumes");
41 std::vector<std::string>::const_iterator ite;
42 std::cout <<
"TestGeometry: List of the selected volumes: " << std::endl;
43 for( ite = volList.begin(); ite != volList.end(); ite++ ){
44 if( (*ite) !=
"None" ) {
50 if(theHistoList ==
"Tracker" ) {
51 std::cout <<
"TestGeometry: MaterialBudgetAction running in Tracker Mode" << std::endl;
53 else if(theHistoList ==
"ECAL" ) {
54 std::cout <<
"TestGeometry: MaterialBudgetAction running in Ecal Mode" << std::endl;
57 std::cout <<
"TestGeometry: MaterialBudgetAction running in General Mode" << std::endl;
67 if( saveToHistosFile !=
"None" ) {
69 std::cout <<
"TestGeometry: saving histograms to " << saveToHistosFile << std::endl;
73 if(theHistoList ==
"Tracker" ) {
76 else if (theHistoList ==
"ECAL") {
89 if( saveToTxtFile !=
"None" ) {
91 std::cout <<
"TestGeometry: saving text info to " << saveToTxtFile << std::endl;
98 bool allSteps = m_Anal.
getParameter<
bool>(
"AllStepsToTree");
99 std::cout <<
"TestGeometry: all steps are computed " << allSteps << std::endl;
105 if( saveToTreeFile !=
"None" ) {
111 std::cout <<
"TestGeometry: saving ROOT TREE to " << saveToTreeFile << std::endl;
118 if(storeDecay)
std::cout <<
" if their kinetic energy is greater than " << Ekin <<
" MeV";
133 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
134 std::vector<G4LogicalVolume*>::const_iterator lvcite;
135 std::vector<G4String>::const_iterator volcite;
138 bool volFound =
false;
139 for( lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++ ) {
140 if( (*lvcite)->GetName() == *volcite ) {
146 std::cerr <<
" @@@@@@@ WARNING at MaterialBudgetAction: selected volume not found in geometry " << *volcite << std::endl;
152 bool procFound =
false;
156 G4ParticleTable * partTable = G4ParticleTable::GetParticleTable();
157 int siz = partTable->size();
158 for (
int ii= 0;
ii < siz;
ii++) {
159 G4ParticleDefinition * particle = partTable->GetParticle(
ii);
162 G4ProcessManager * pmanager = particle->GetProcessManager();
163 G4ProcessVector * pvect = pmanager->GetProcessList();
164 int sizproc = pvect->size();
165 for (
int jj = 0;
jj < sizproc;
jj++) {
175 std::cerr <<
" @@@@@@@ WARNING at MaterialBudgetAction: selected process to stop tracking not found " <<
theProcessToStop << std::endl;
184 const G4Track * aTrack = (*trk)();
189 std::cout <<
"Track ID " << aTrack->GetTrackID() <<
" Track parent ID " << aTrack->GetParentID()
190 <<
" PDG Id. = " << aTrack->GetDefinition()->GetPDGEncoding()
191 <<
" Ekin = " << aTrack->GetKineticEnergy() <<
" MeV" << std::endl;
192 if( aTrack->GetCreatorProcess() )
std::cout <<
" produced through " << aTrack->GetCreatorProcess()->GetProcessType() << std::endl;
194 if(aTrack->GetTrackID() == 1) {
201 if( aTrack->GetCreatorProcess() ) {
203 aTrack->GetParentID() == 1
207 aTrack->GetKineticEnergy() >
Ekin 211 G4Track * aTracknc =
const_cast<G4Track*
>(aTrack);
212 aTracknc->SetTrackStatus(fStopAndKill);
217 if( aTrack->GetParentID() != 0) {
218 G4Track * aTracknc =
const_cast<G4Track*
>(aTrack);
219 aTracknc->SetTrackStatus(fStopAndKill);
254 G4Track*
track = aStep->GetTrack();
255 track->SetTrackStatus( fStopAndKill );
266 G4TouchableHistory* theTouchable
267 = (G4TouchableHistory*)(aStepPoint->GetTouchable());
268 G4int num_levels = theTouchable->GetHistoryDepth();
270 if( theTouchable->GetVolume() ) {
271 return theTouchable->GetVolume(num_levels-1)->GetName();
281 G4TouchableHistory* theTouchable
282 = (G4TouchableHistory*)(aStepPoint->GetTouchable());
283 G4int num_levels = theTouchable->GetHistoryDepth();
286 if( theTouchable->GetVolume() ) {
287 return theTouchable->GetVolume(num_levels-3)->GetName();
296 const G4Track * aTrack = (*trk)();
323 std::vector<G4String>::const_iterator ite;
324 size_t volh = touch->GetHistoryDepth();
327 for(
int ii = volh;
ii >= 0;
ii-- ){
345 if(aStep->GetPostStepPoint()->GetProcessDefinedStep() ==
nullptr)
return false;
346 if( aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() ==
theProcessToStop ) {
347 std::cout <<
" MaterialBudgetAction::StopAfterProcess " << aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() << std::endl;
bool CheckTouchableInSelectedVolumes(const G4VTouchable *touch)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void fillPerStep() override
void fillEndTrack() override
void fillStartTrack() override
MaterialBudgetAction(const edm::ParameterSet &)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
TestHistoMgr * theHistoMgr
MaterialBudgetTxt * theTxt
G4String theProcessToStop
void fillPerStep() override
void dataEndTrack(const G4Track *aTrack)
MaterialBudgetFormat * theHistos
void dataPerStep(const G4Step *aStep)
void fillStartTrack() override
MaterialBudgetData * theData
bool StopAfterProcess(const G4Step *aStep)
~MaterialBudgetAction() override
void dataStartTrack(const G4Track *aTrack)
void fillEndTrack() override
std::string getPartName(G4StepPoint *aStepPoint)
std::vector< G4String > theVolumeList
std::string getSubDetectorName(G4StepPoint *aStepPoint)
void update(const BeginOfRun *) override
This routine will be called when the appropriate signal arrives.
MaterialBudgetTree * theTree