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);
163 G4ProcessManager * pmanager = particle->GetProcessManager();
164 G4ProcessVector * pvect = pmanager->GetProcessList();
165 int sizproc = pvect->size();
166 for (
int jj = 0;
jj < sizproc;
jj++) {
176 std::cerr <<
" @@@@@@@ WARNING at MaterialBudgetAction: selected process to stop tracking not found " <<
theProcessToStop << std::endl;
185 const G4Track * aTrack = (*trk)();
190 std::cout <<
"Track ID " << aTrack->GetTrackID() <<
" Track parent ID " << aTrack->GetParentID()
191 <<
" PDG Id. = " << aTrack->GetDefinition()->GetPDGEncoding()
192 <<
" Ekin = " << aTrack->GetKineticEnergy() <<
" MeV" << std::endl;
193 if( aTrack->GetCreatorProcess() )
std::cout <<
" produced through " << aTrack->GetCreatorProcess()->GetProcessType() << std::endl;
195 if(aTrack->GetTrackID() == 1) {
202 if( aTrack->GetCreatorProcess() ) {
204 aTrack->GetParentID() == 1
208 aTrack->GetKineticEnergy() >
Ekin 212 G4Track * aTracknc =
const_cast<G4Track*
>(aTrack);
213 aTracknc->SetTrackStatus(fStopAndKill);
218 if( aTrack->GetParentID() != 0) {
219 G4Track * aTracknc =
const_cast<G4Track*
>(aTrack);
220 aTracknc->SetTrackStatus(fStopAndKill);
255 G4Track*
track = aStep->GetTrack();
256 track->SetTrackStatus( fStopAndKill );
267 G4TouchableHistory* theTouchable
268 = (G4TouchableHistory*)(aStepPoint->GetTouchable());
269 G4int num_levels = theTouchable->GetHistoryDepth();
271 if( theTouchable->GetVolume() ) {
272 return theTouchable->GetVolume(num_levels-1)->GetName();
282 G4TouchableHistory* theTouchable
283 = (G4TouchableHistory*)(aStepPoint->GetTouchable());
284 G4int num_levels = theTouchable->GetHistoryDepth();
287 if( theTouchable->GetVolume() ) {
288 return theTouchable->GetVolume(num_levels-3)->GetName();
297 const G4Track * aTrack = (*trk)();
324 std::vector<G4String>::const_iterator ite;
325 size_t volh = touch->GetHistoryDepth();
328 for(
int ii = volh;
ii >= 0;
ii-- ){
346 if(aStep->GetPostStepPoint()->GetProcessDefinedStep() ==
NULL)
return false;
347 if( aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() ==
theProcessToStop ) {
348 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
virtual void fillPerStep()
MaterialBudgetAction(const edm::ParameterSet &)
void update(const BeginOfRun *)
This routine will be called when the appropriate signal arrives.
virtual void fillEndTrack()
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
TestHistoMgr * theHistoMgr
virtual void fillEndTrack()
MaterialBudgetTxt * theTxt
G4String theProcessToStop
virtual void fillStartTrack()
void dataEndTrack(const G4Track *aTrack)
MaterialBudgetFormat * theHistos
void dataPerStep(const G4Step *aStep)
MaterialBudgetData * theData
bool StopAfterProcess(const G4Step *aStep)
virtual void fillPerStep()
void dataStartTrack(const G4Track *aTrack)
std::string getPartName(G4StepPoint *aStepPoint)
std::vector< G4String > theVolumeList
virtual ~MaterialBudgetAction()
std::string getSubDetectorName(G4StepPoint *aStepPoint)
virtual void fillStartTrack()
MaterialBudgetTree * theTree