Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StackingAction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 // $Id: StackingAction.cc 88674 2015-03-05 08:29:46Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "StackingAction.hh"
35 
36 #include "Run.hh"
37 #include "EventAction.hh"
38 #include "HistoManager.hh"
39 #include "StackingMessenger.hh"
40 
41 #include "G4RunManager.hh"
42 #include "G4Track.hh"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47  : G4UserStackingAction(), fEventAction(EA),
48  fKillSecondary(0),fStackMessenger(0),fPhotoGamma(-1),fComptGamma(-1),
49  fPhotoAuger(-1),fComptAuger(-1),fPixeGamma(-1),fPixeAuger(-1),
50  fIDdefined(false)
51 {
52  fStackMessenger = new StackingMessenger(this);
53 }
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 {
59  delete fStackMessenger;
60 }
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
66 {
67  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
68 
69  //keep primary particle
70  if (aTrack->GetParentID() == 0) { return fUrgent; }
71 
72  if(!fIDdefined) {
73  fIDdefined = true;
74  fPhotoGamma = G4PhysicsModelCatalog::GetIndex("phot_fluo");
75  fComptGamma = G4PhysicsModelCatalog::GetIndex("compt_fluo");
76  fPhotoAuger = G4PhysicsModelCatalog::GetIndex("phot_auger");
77  fComptAuger = G4PhysicsModelCatalog::GetIndex("compt_auger");
78  fPixeGamma = G4PhysicsModelCatalog::GetIndex("gammaPIXE");
79  fPixeAuger = G4PhysicsModelCatalog::GetIndex("e-PIXE");
80  }
81  G4int idx = aTrack->GetCreatorModelID();
82 
83  //count secondary particles
84 
85  Run* run = static_cast<Run*>(
87  run->CountParticles(aTrack->GetDefinition());
88  /*
89  G4cout << "###StackingAction: new "
90  << aTrack->GetDefinition()->GetParticleName()
91  << " E(MeV)= " << aTrack->GetKineticEnergy()
92  << " " << aTrack->GetMomentumDirection() << G4endl;
93  */
94  //
95  //energy spectrum of secondaries
96  //
97  G4double energy = aTrack->GetKineticEnergy();
98  G4double charge = aTrack->GetDefinition()->GetPDGCharge();
99 
100  if (charge != 0.) {
101  analysisManager->FillH1(2,energy);
102  analysisManager->FillH1(4,energy);
103  if(idx == fPhotoAuger || idx == fComptAuger) {
104  analysisManager->FillH1(16,energy);
105  analysisManager->FillH1(18,energy);
106  } else if(idx == fPixeAuger) {
107  analysisManager->FillH1(44,energy);
108  analysisManager->FillH1(46,energy);
109  }
110  }
111 
112  if (aTrack->GetDefinition() == G4Gamma::Gamma()) {
113  analysisManager->FillH1(3,energy);
114  analysisManager->FillH1(5,energy);
115  if(idx == fPhotoGamma || idx == fComptGamma) {
116  analysisManager->FillH1(17,energy);
117  analysisManager->FillH1(19,energy);
118  } else if(idx == fPixeGamma) {
119  analysisManager->FillH1(45,energy);
120  analysisManager->FillH1(47,energy);
121  }
122  }
123 
124  //stack or delete secondaries
126  if (fKillSecondary) {
127  if (fKillSecondary == 1) {
128  fEventAction->AddEnergy(energy);
129  status = fKill;
130  }
131  if (aTrack->GetDefinition() == G4Gamma::Gamma()) {
132  status = fKill;
133  }
134  }
135 
136  return status;
137 }
138 
139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int GetCreatorModelID() const
G4ParticleDefinition * GetDefinition() const
G4int GetParentID() const
Event action class.
Definition: EventAction.hh:45
int G4int
Definition: G4Types.hh:78
void AddEnergy(G4double edep)
Definition: EventAction.hh:52
G4double GetKineticEnergy() const
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *)
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
void CountParticles(G4ParticleDefinition *part)
Definition: Run.hh:80
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
G4double energy(const ThreeVector &p, const G4double m)
double G4double
Definition: G4Types.hh:76
Definition: Run.hh:46
G4double GetPDGCharge() const
static G4int GetIndex(const G4String &)
G4CsvAnalysisManager G4AnalysisManager
Definition: g4csv_defs.hh:77
G4Run * GetNonConstCurrentRun() const