Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DMXEventAction Class Reference

#include <DMXEventAction.hh>

Inheritance diagram for DMXEventAction:
Collaboration diagram for DMXEventAction:

Public Member Functions

 DMXEventAction ()
 
virtual ~DMXEventAction ()
 
virtual void BeginOfEventAction (const G4Event *)
 
virtual void EndOfEventAction (const G4Event *)
 
void SetDrawTrksFlag (G4String val)
 
G4String GetDrawTrksFlag () const
 
void SetDrawColsFlag (G4String val)
 
G4String GetDrawColsFlag () const
 
void SetDrawHitsFlag (G4int val)
 
void SetSavePmtFlag (G4int val)
 
void SetSaveHitsFlag (G4int val)
 
void SetPrintModulo (G4int val)
 
- Public Member Functions inherited from G4UserEventAction
 G4UserEventAction ()
 
virtual ~G4UserEventAction ()
 
virtual void SetEventManager (G4EventManager *value)
 

Additional Inherited Members

- Protected Attributes inherited from G4UserEventAction
G4EventManagerfpEventManager
 

Detailed Description

Definition at line 58 of file DMXEventAction.hh.

Constructor & Destructor Documentation

DMXEventAction::DMXEventAction ( )

Definition at line 76 of file DMXEventAction.cc.

77  : runAct(0),genAction(0),hitsfile(0),pmtfile(0)
78 {
79 
80  // create messenger
81  eventMessenger = new DMXEventActionMessenger(this);
82 
83  // defaults for messenger
84  drawColsFlag = "standard";
85  drawTrksFlag = "all";
86  drawHitsFlag = 1;
87  savePmtFlag = 0;
88  saveHitsFlag = 1;
89 
90  printModulo = 1;
91 
92  // hits collections
93  scintillatorCollID = -1;
94  pmtCollID = -1;
95 
96  energy_pri=0;
97  seeds=NULL;
98 
99 }
DMXEventAction::~DMXEventAction ( )
virtual

Definition at line 103 of file DMXEventAction.cc.

103  {
104 
105  if (hitsfile)
106  {
107  hitsfile->close();
108  delete hitsfile;
109  }
110  if (pmtfile)
111  {
112  pmtfile->close();
113  delete pmtfile;
114  }
115  delete eventMessenger;
116 }

Member Function Documentation

void DMXEventAction::BeginOfEventAction ( const G4Event evt)
virtual

Reimplemented from G4UserEventAction.

Definition at line 120 of file DMXEventAction.cc.

121 {
122 
123  //thread-local run action
124  if (!runAct)
125  runAct =
126  dynamic_cast<const DMXRunAction*>
128 
129  if (!genAction)
130  genAction = dynamic_cast<const DMXPrimaryGeneratorAction*>
132 
133 
134  // grab seeds
135  seeds = genAction->GetEventSeeds();
136 
137  // grab energy of primary
138  energy_pri = genAction->GetEnergyPrimary();
139 
140  event_id = evt->GetEventID();
141 
142  // print this information event by event (modulo n)
143  if (event_id%printModulo == 0)
144  {
145  G4cout << "\n---> Begin of event: " << event_id << G4endl;
146  G4cout << "\n Primary Energy: " << G4BestUnit(energy_pri,"Energy")
147  << G4endl;
148  // HepRandom::showEngineStatus();
149  }
150 
151 
152  // get ID for scintillator hits collection
153  if (scintillatorCollID==-1) {
155  scintillatorCollID = SDman->GetCollectionID("scintillatorCollection");
156  }
157 
158  // get ID for pmt hits collection
159  if (pmtCollID==-1) {
161  pmtCollID = SDman->GetCollectionID("pmtCollection");
162  }
163 
164 }
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4int GetEventID() const
Definition: G4Event.hh:151
G4GLOB_DLL std::ostream G4cout
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
#define G4endl
Definition: G4ios.hh:61
const G4UserRunAction * GetUserRunAction() const

Here is the call graph for this function:

void DMXEventAction::EndOfEventAction ( const G4Event evt)
virtual

Reimplemented from G4UserEventAction.

Definition at line 168 of file DMXEventAction.cc.

168  {
169 
170  // check that both hits collections have been defined
171  if(scintillatorCollID<0||pmtCollID<0) return;
172 
173  G4AnalysisManager* man = G4AnalysisManager::Instance();
174 
175  // address hits collections
176  DMXScintHitsCollection* SHC = NULL;
177  DMXPmtHitsCollection* PHC = NULL;
178  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
179  if(HCE) {
180  SHC = (DMXScintHitsCollection*)(HCE->GetHC(scintillatorCollID));
181  PHC = (DMXPmtHitsCollection*)(HCE->GetHC(pmtCollID));
182  }
183 
184  // event summary
185  totEnergy = 0.;
186  totEnergyGammas = 0.;
187  totEnergyNeutrons = 0.;
188  firstParticleE = 0.;
189  particleEnergy = 0.;
190  firstLXeHitTime = 0.;
191  aveTimePmtHits = 0.;
192 
193  firstParticleName = "";
194  particleName = "";
195 
196 
197  // particle flags
198  gamma_ev = false;
199  neutron_ev = false;
200  positron_ev = false;
201  electron_ev = false;
202  proton_ev = false;
203  other_ev = false;
204  start_gamma = false;
205  start_neutron = false;
206 
207 
208  // scintillator hits
209  if(SHC) {
210  S_hits = SHC->entries();
211 
212  for (G4int i=0; i<S_hits; i++) {
213  if(i==0) {
214  firstParticleName = (*SHC)[0]->GetParticle();
215  firstLXeHitTime = (*SHC)[0]->GetTime();
216  firstParticleE = (*SHC)[0]->GetParticleEnergy();
217  if (event_id%printModulo == 0 && S_hits > 0) {
218  G4cout << " First hit in LXe: " << firstParticleName << G4endl;
219  G4cout << " Number of hits in LXe: " << S_hits << G4endl;
220  }
221  }
222  hitEnergy = (*SHC)[i]->GetEdep();
223  totEnergy += hitEnergy;
224 
225  particleName = (*SHC)[i]->GetParticle();
226  particleEnergy = (*SHC)[i]->GetParticleEnergy();
227 
228  if(particleName == "gamma") {
229  gamma_ev = true;
230  start_gamma = true;
231  start_neutron = false;
232  }
233  else if(particleName == "neutron")
234  neutron_ev = true;
235  else if(particleName == "e+")
236  positron_ev = true;
237  else if(particleName == "e-")
238  electron_ev = true;
239  else if(particleName == "proton")
240  proton_ev = true;
241  else {
242  other_ev = true;
243  start_gamma = false;
244  start_neutron = true;
245  }
246 
247  if(start_gamma && !start_neutron)
248  totEnergyGammas += hitEnergy;
249  if(start_neutron && !start_gamma)
250  totEnergyNeutrons += hitEnergy;
251  }
252 
253  if (event_id%printModulo == 0)
254  G4cout << " Total energy in LXe: "
255  << G4BestUnit(totEnergy,"Energy") << G4endl;
256 
257  }
258 
259 
260  // PMT hits
261  if(PHC) {
262  P_hits = PHC->entries();
263 
264  // average time of PMT hits
265  for (G4int i=0; i<P_hits; i++) {
266  G4double time = ( (*PHC)[i]->GetTime() - firstLXeHitTime );
267  aveTimePmtHits += time / (G4double)P_hits;
269  if(P_hits >= 0) {
270  man->FillH1(7,time);
271  }
272  }
273 
274  if (event_id%printModulo == 0 && P_hits > 0) {
275  G4cout << " Average light collection time: "
276  << G4BestUnit(aveTimePmtHits,"Time") << G4endl;
277  G4cout << " Number of PMT hits (photoelectron equivalent): "
278  << P_hits << G4endl;
279  }
280  // write out (x,y,z) of PMT hits
281  if (savePmtFlag)
282  writePmtHitsToFile(PHC);
283  }
284 
285 
286  // write out event summary
287  if(saveHitsFlag)
288  writeScintHitsToFile();
289 
290  // draw trajectories
291  if(drawColsFlag=="standard" && drawTrksFlag!="none")
292  drawTracks(evt);
293 
294  // hits in PMT
295  if(drawHitsFlag && PHC)
296  PHC->DrawAllHits();
297 
298  // print this event by event (modulo n)
299  if (event_id%printModulo == 0)
300  G4cout << "\n---> End of event: " << event_id << G4endl << G4endl;
301 
302 }
G4VHitsCollection * GetHC(G4int i)
G4int entries() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
virtual void DrawAllHits()
#define G4endl
Definition: G4ios.hh:61
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

G4String DMXEventAction::GetDrawColsFlag ( ) const
inline

Definition at line 76 of file DMXEventAction.hh.

76 {return drawColsFlag;};

Here is the caller graph for this function:

G4String DMXEventAction::GetDrawTrksFlag ( ) const
inline

Definition at line 73 of file DMXEventAction.hh.

73 {return drawTrksFlag;};

Here is the caller graph for this function:

void DMXEventAction::SetDrawColsFlag ( G4String  val)
inline

Definition at line 75 of file DMXEventAction.hh.

75 {drawColsFlag = val;};
void DMXEventAction::SetDrawHitsFlag ( G4int  val)
inline

Definition at line 78 of file DMXEventAction.hh.

78 {drawHitsFlag = val;};
void DMXEventAction::SetDrawTrksFlag ( G4String  val)
inline

Definition at line 72 of file DMXEventAction.hh.

72 {drawTrksFlag = val;};
void DMXEventAction::SetPrintModulo ( G4int  val)
inline

Definition at line 81 of file DMXEventAction.hh.

81 {printModulo = val;};
void DMXEventAction::SetSaveHitsFlag ( G4int  val)
inline

Definition at line 80 of file DMXEventAction.hh.

80 {saveHitsFlag = val;};
void DMXEventAction::SetSavePmtFlag ( G4int  val)
inline

Definition at line 79 of file DMXEventAction.hh.

79 {savePmtFlag = val;};

The documentation for this class was generated from the following files: