Geant4  10.02.p02
LXeEventAction.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 //
26 // $Id: LXeEventAction.cc 68752 2013-04-05 10:23:47Z gcosmo $
27 //
30 //
31 //
32 #include "LXeEventAction.hh"
33 #include "LXeScintHit.hh"
34 #include "LXePMTHit.hh"
36 #include "LXeTrajectory.hh"
37 #include "LXeRecorderBase.hh"
38 
39 #include "G4EventManager.hh"
40 #include "G4SDManager.hh"
41 #include "G4RunManager.hh"
42 #include "G4Event.hh"
43 #include "G4EventManager.hh"
44 #include "G4TrajectoryContainer.hh"
45 #include "G4Trajectory.hh"
46 #include "G4VVisManager.hh"
47 #include "G4ios.hh"
48 #include "G4UImanager.hh"
49 #include "G4SystemOfUnits.hh"
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54  : fRecorder(r),fSaveThreshold(0),fScintCollID(-1),fPMTCollID(-1),fVerbose(0),
55  fPMTThreshold(1),fForcedrawphotons(false),fForcenophotons(false)
56 {
58 }
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
67 
68  //New event, add the user information object
71 
73  if(fScintCollID<0)
74  fScintCollID=SDman->GetCollectionID("scintCollection");
75  if(fPMTCollID<0)
76  fPMTCollID=SDman->GetCollectionID("pmtHitCollection");
77 
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 
85  LXeUserEventInformation* eventInformation
87 
88  G4TrajectoryContainer* trajectoryContainer=anEvent->GetTrajectoryContainer();
89 
90  G4int n_trajectories = 0;
91  if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
92 
93  // extract the trajectories and draw them
95  for (G4int i=0; i<n_trajectories; i++){
97  ((*(anEvent->GetTrajectoryContainer()))[i]);
98  if(trj->GetParticleName()=="opticalphoton"){
101  }
102  trj->DrawTrajectory();
103  }
104  }
105 
106  LXeScintHitsCollection* scintHC = 0;
107  LXePMTHitsCollection* pmtHC = 0;
108  G4HCofThisEvent* hitsCE = anEvent->GetHCofThisEvent();
109 
110  //Get the hit collections
111  if(hitsCE){
112  if(fScintCollID>=0)scintHC = (LXeScintHitsCollection*)(hitsCE->GetHC(fScintCollID));
113  if(fPMTCollID>=0)pmtHC = (LXePMTHitsCollection*)(hitsCE->GetHC(fPMTCollID));
114  }
115 
116  //Hits in scintillator
117  if(scintHC){
118  int n_hit = scintHC->entries();
119  G4ThreeVector eWeightPos(0.);
120  G4double edep;
121  G4double edepMax=0;
122 
123  for(int i=0;i<n_hit;i++){ //gather info on hits in scintillator
124  edep=(*scintHC)[i]->GetEdep();
125  eventInformation->IncEDep(edep); //sum up the edep
126  eWeightPos += (*scintHC)[i]->GetPos()*edep;//calculate energy weighted pos
127  if(edep>edepMax){
128  edepMax=edep;//store max energy deposit
129  G4ThreeVector posMax=(*scintHC)[i]->GetPos();
130  eventInformation->SetPosMax(posMax,edep);
131  }
132  }
133  if(eventInformation->GetEDep()==0.){
134  if(fVerbose>0)G4cout<<"No hits in the scintillator this event."<<G4endl;
135  }
136  else{
137  //Finish calculation of energy weighted position
138  eWeightPos/=eventInformation->GetEDep();
139  eventInformation->SetEWeightPos(eWeightPos);
140  if(fVerbose>0){
141  G4cout << "\tEnergy weighted position of hits in LXe : "
142  << eWeightPos/mm << G4endl;
143  }
144  }
145  if(fVerbose>0){
146  G4cout << "\tTotal energy deposition in scintillator : "
147  << eventInformation->GetEDep() / keV << " (keV)" << G4endl;
148  }
149  }
150 
151  if(pmtHC){
152  G4ThreeVector reconPos(0.,0.,0.);
153  G4int pmts=pmtHC->entries();
154  //Gather info from all PMTs
155  for(G4int i=0;i<pmts;i++){
156  eventInformation->IncHitCount((*pmtHC)[i]->GetPhotonCount());
157  reconPos+=(*pmtHC)[i]->GetPMTPos()*(*pmtHC)[i]->GetPhotonCount();
158  if((*pmtHC)[i]->GetPhotonCount()>=fPMTThreshold){
159  eventInformation->IncPMTSAboveThreshold();
160  }
161  else{//wasnt above the threshold, turn it back off
162  (*pmtHC)[i]->SetDrawit(false);
163  }
164  }
165 
166  if(eventInformation->GetHitCount()>0){//dont bother unless there were hits
167  reconPos/=eventInformation->GetHitCount();
168  if(fVerbose>0){
169  G4cout << "\tReconstructed position of hits in LXe : "
170  << reconPos/mm << G4endl;
171  }
172  eventInformation->SetReconPos(reconPos);
173  }
174  pmtHC->DrawAllHits();
175  }
176 
177  if(fVerbose>0){
178  //End of event output. later to be controlled by a verbose level
179  G4cout << "\tNumber of photons that hit PMTs in this event : "
180  << eventInformation->GetHitCount() << G4endl;
181  G4cout << "\tNumber of PMTs above threshold("<<fPMTThreshold<<") : "
182  << eventInformation->GetPMTSAboveThreshold() << G4endl;
183  G4cout << "\tNumber of photons produced by scintillation in this event : "
184  << eventInformation->GetPhotonCount_Scint() << G4endl;
185  G4cout << "\tNumber of photons produced by cerenkov in this event : "
186  << eventInformation->GetPhotonCount_Ceren() << G4endl;
187  G4cout << "\tNumber of photons absorbed (OpAbsorption) in this event : "
188  << eventInformation->GetAbsorptionCount() << G4endl;
189  G4cout << "\tNumber of photons absorbed at boundaries (OpBoundary) in "
190  << "this event : " << eventInformation->GetBoundaryAbsorptionCount()
191  << G4endl;
192  G4cout << "Unacounted for photons in this event : "
193  << (eventInformation->GetPhotonCount_Scint() +
194  eventInformation->GetPhotonCount_Ceren() -
195  eventInformation->GetAbsorptionCount() -
196  eventInformation->GetHitCount() -
197  eventInformation->GetBoundaryAbsorptionCount())
198  << G4endl;
199  }
200  //If we have set the flag to save 'special' events, save here
201  if(fSaveThreshold&&eventInformation->GetPhotonCount() <= fSaveThreshold)
203 
204  if(fRecorder)fRecorder->RecordEndOfEvent(anEvent);
205 }
206 
207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
208 
210 /*Sets the save threshold for the random number seed. If the number of photons
211 generated in an event is lower than this, then save the seed for this event
212 in a file called run###evt###.rndm
213 */
214  fSaveThreshold=save;
217  // G4UImanager::GetUIpointer()->ApplyCommand("/random/setSavingFlag 1");
218 }
G4VUserEventInformation * GetUserInformation() const
Definition: G4Event.hh:199
LXeRecorderBase * fRecorder
G4VHitsCollection * GetHC(G4int i)
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
Definition of the LXeRecorderBase class.
CLHEP::Hep3Vector G4ThreeVector
static G4VVisManager * GetConcreteInstance()
G4int entries() const
Definition of the LXeUserEventInformation class.
LXeEventMessenger * fEventMessenger
void SetRandomNumberStore(G4bool flag)
int G4int
Definition: G4Types.hh:78
G4TrajectoryContainer * GetTrajectoryContainer() const
Definition: G4Event.hh:189
virtual ~LXeEventAction()
G4GLOB_DLL std::ostream G4cout
void SetSaveThreshold(G4int)
virtual void EndOfEventAction(const G4Event *)
Definition of the LXeEventAction class.
void SetUserInformation(G4VUserEventInformation *anInfo)
Definition of the LXeTrajectory class.
Definition of the LXePMTHit class.
virtual void rndmSaveThisEvent()
LXeEventAction(LXeRecorderBase *)
virtual void RecordBeginOfEvent(const G4Event *)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
void SetReconPos(const G4ThreeVector &p)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
static G4EventManager * GetEventManager()
virtual void DrawAllHits()
virtual void DrawTrajectory() const
#define G4endl
Definition: G4ios.hh:61
G4bool fForcedrawphotons
G4bool fForcenophotons
static const double keV
Definition: G4SIunits.hh:213
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
double G4double
Definition: G4Types.hh:76
void SetRandomNumberStoreDir(const G4String &dir)
virtual void BeginOfEventAction(const G4Event *)
void SetForceNoDrawTrajectory(G4bool b)
Definition of the LXeScintHit class.
static const double mm
Definition: G4SIunits.hh:114
virtual void RecordEndOfEvent(const G4Event *)
G4String GetParticleName() const
Definition: G4Trajectory.hh:99
void SetEWeightPos(const G4ThreeVector &p)
void SetForceDrawTrajectory(G4bool b)
void SetPosMax(const G4ThreeVector &p, G4double edep)