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"
39 std::vector<std::string> volList = m_Anal.
getParameter< std::vector<std::string> >(
"SelectedVolumes");
40 std::vector<std::string>::const_iterator ite;
41 std::cout <<
"TestGeometry: List of the selected volumes: " << std::endl;
42 for( ite = volList.begin(); ite != volList.end(); ite++ ){
43 if( (*ite) !=
"None" ) {
49 if(theHistoList ==
"Tracker" ) {
50 std::cout <<
"TestGeometry: MaterialBudgetAction running in Tracker Mode" << std::endl;
52 else if(theHistoList ==
"ECAL" ) {
53 std::cout <<
"TestGeometry: MaterialBudgetAction running in Ecal Mode" << std::endl;
56 std::cout <<
"TestGeometry: MaterialBudgetAction running in General Mode" << std::endl;
66 if( saveToHistosFile !=
"None" ) {
68 std::cout <<
"TestGeometry: saving histograms to " << saveToHistosFile << std::endl;
72 if(theHistoList ==
"Tracker" ) {
75 else if (theHistoList ==
"ECAL") {
88 if( saveToTxtFile !=
"None" ) {
90 std::cout <<
"TestGeometry: saving text info to " << saveToTxtFile << std::endl;
97 bool allSteps = m_Anal.
getParameter<
bool>(
"AllStepsToTree");
98 std::cout <<
"TestGeometry: all steps are computed " << allSteps << std::endl;
104 if( saveToTreeFile !=
"None" ) {
110 std::cout <<
"TestGeometry: saving ROOT TREE to " << saveToTreeFile << std::endl;
117 if(storeDecay)
std::cout <<
" if their kinetic energy is greater than " << Ekin <<
" MeV";
137 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
138 std::vector<G4LogicalVolume*>::const_iterator lvcite;
139 std::vector<G4String>::const_iterator volcite;
142 bool volFound =
false;
143 for( lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++ ) {
144 if( (*lvcite)->GetName() == *volcite ) {
150 std::cerr <<
" @@@@@@@ WARNING at MaterialBudgetAction: selected volume not found in geometry " << *volcite << std::endl;
156 bool procFound =
false;
160 G4ParticleTable * partTable = G4ParticleTable::GetParticleTable();
161 int siz = partTable->size();
162 for (
int ii= 0;
ii < siz;
ii++) {
163 G4ParticleDefinition * particle = partTable->GetParticle(
ii);
164 std::string particleName = particle->GetParticleName();
167 G4ProcessManager * pmanager = particle->GetProcessManager();
168 G4ProcessVector * pvect = pmanager->GetProcessList();
169 int sizproc = pvect->size();
170 for (
int jj = 0;
jj < sizproc;
jj++) {
180 std::cerr <<
" @@@@@@@ WARNING at MaterialBudgetAction: selected process to stop tracking not found " <<
theProcessToStop << std::endl;
189 const G4Track * aTrack = (*trk)();
194 std::cout <<
"Track ID " << aTrack->GetTrackID() <<
" Track parent ID " << aTrack->GetParentID()
195 <<
" PDG Id. = " << aTrack->GetDefinition()->GetPDGEncoding()
196 <<
" Ekin = " << aTrack->GetKineticEnergy() <<
" MeV" << std::endl;
197 if( aTrack->GetCreatorProcess() )
std::cout <<
" produced through " << aTrack->GetCreatorProcess()->GetProcessType() << std::endl;
199 if(aTrack->GetTrackID() == 1) {
206 if( aTrack->GetCreatorProcess() ) {
208 aTrack->GetParentID() == 1
212 aTrack->GetKineticEnergy() >
Ekin
216 G4Track * aTracknc =
const_cast<G4Track*
>(aTrack);
217 aTracknc->SetTrackStatus(fStopAndKill);
222 if( aTrack->GetParentID() != 0) {
223 G4Track * aTracknc =
const_cast<G4Track*
>(aTrack);
224 aTracknc->SetTrackStatus(fStopAndKill);
259 G4Track* track = aStep->GetTrack();
260 track->SetTrackStatus( fStopAndKill );
271 G4TouchableHistory* theTouchable
272 = (G4TouchableHistory*)(aStepPoint->GetTouchable());
273 G4int num_levels = theTouchable->GetHistoryDepth();
275 if( theTouchable->GetVolume() ) {
276 return theTouchable->GetVolume(num_levels-1)->GetName();
286 G4TouchableHistory* theTouchable
287 = (G4TouchableHistory*)(aStepPoint->GetTouchable());
288 G4int num_levels = theTouchable->GetHistoryDepth();
291 if( theTouchable->GetVolume() ) {
292 return theTouchable->GetVolume(num_levels-3)->GetName();
301 const G4Track * aTrack = (*trk)();
317 std::vector<G4String>::const_iterator ite;
318 size_t volh = touch->GetHistoryDepth();
321 for(
int ii = volh;
ii >= 0;
ii-- ){
323 if( touch->GetVolume(
ii)->GetName() == *ite )
return true;
335 if(aStep->GetPostStepPoint()->GetProcessDefinedStep() ==
NULL)
return false;
336 if( aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() ==
theProcessToStop ) {
337 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()
MaterialBudgetTree * theTree