15 #include "G4UImanager.hh"
16 #include "G4UIterminal.hh"
17 #include "G4UItcsh.hh"
18 #include "G4LogicalVolumeStore.hh"
19 #include "G4TouchableHistory.hh"
20 #include "G4VPhysicalVolume.hh"
21 #include "G4VProcess.hh"
22 #include "G4ParticleTable.hh"
23 #include "G4ParticleDefinition.hh"
24 #include "G4ProcessManager.hh"
25 #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";
145 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
146 std::vector<G4LogicalVolume*>::const_iterator lvcite;
147 std::vector<G4String>::const_iterator volcite;
151 bool volFound =
false;
152 for( lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++ ) {
153 if( (*lvcite)->GetName() == *volcite ) {
159 std::cerr <<
" @@@@@@@ WARNING at MaterialBudgetAction: selected volume not found in geometry " << *volcite << std::endl;
165 bool procFound =
false;
169 G4ParticleTable * partTable = G4ParticleTable::GetParticleTable();
170 int siz = partTable->size();
171 for (
int ii= 0;
ii < siz;
ii++) {
172 G4ParticleDefinition * particle = partTable->GetParticle(
ii);
173 std::string particleName = particle->GetParticleName();
176 G4ProcessManager * pmanager = particle->GetProcessManager();
177 G4ProcessVector * pvect = pmanager->GetProcessList();
178 int sizproc = pvect->size();
179 for (
int jj = 0;
jj < sizproc;
jj++) {
189 std::cerr <<
" @@@@@@@ WARNING at MaterialBudgetAction: selected process to stop tracking not found " <<
theProcessToStop << std::endl;
198 const G4Track * aTrack = (*trk)();
203 std::cout <<
"Track ID " << aTrack->GetTrackID() <<
" Track parent ID " << aTrack->GetParentID()
204 <<
" PDG Id. = " << aTrack->GetDefinition()->GetPDGEncoding()
205 <<
" Ekin = " << aTrack->GetKineticEnergy() <<
" MeV" << std::endl;
206 if( aTrack->GetCreatorProcess() )
std::cout <<
" produced through " << aTrack->GetCreatorProcess()->GetProcessType() << std::endl;
208 if(aTrack->GetTrackID() == 1) {
215 if( aTrack->GetCreatorProcess() ) {
217 aTrack->GetParentID() == 1
221 aTrack->GetKineticEnergy() >
Ekin
225 G4Track * aTracknc =
const_cast<G4Track*
>(aTrack);
226 aTracknc->SetTrackStatus(fStopAndKill);
231 if( aTrack->GetParentID() != 0) {
232 G4Track * aTracknc =
const_cast<G4Track*
>(aTrack);
233 aTracknc->SetTrackStatus(fStopAndKill);
269 G4Track* track = aStep->GetTrack();
270 track->SetTrackStatus( fStopAndKill );
281 G4TouchableHistory* theTouchable
282 = (G4TouchableHistory*)(aStepPoint->GetTouchable());
283 G4int num_levels = theTouchable->GetHistoryDepth();
285 if( theTouchable->GetVolume() ) {
286 return theTouchable->GetVolume(num_levels-1)->GetName();
296 G4TouchableHistory* theTouchable
297 = (G4TouchableHistory*)(aStepPoint->GetTouchable());
298 G4int num_levels = theTouchable->GetHistoryDepth();
301 if( theTouchable->GetVolume() ) {
302 return theTouchable->GetVolume(num_levels-3)->GetName();
314 const G4Track * aTrack = (*trk)();
339 std::vector<G4String>::const_iterator ite;
340 size_t volh = touch->GetHistoryDepth();
343 for(
int ii = volh;
ii >= 0;
ii-- ){
345 if( touch->GetVolume(
ii)->GetName() == *ite )
return true;
359 if(aStep->GetPostStepPoint()->GetProcessDefinedStep() ==
NULL)
return false;
360 if( aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() ==
theProcessToStop ) {
361 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()
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()
void produce(edm::Event &, const edm::EventSetup &)
MaterialBudgetTree * theTree