Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
DMXEventAction Class Reference

#include <DMXEventAction.hh>

Inheritance diagram for DMXEventAction:
G4UserEventAction

Public Member Functions

 DMXEventAction (DMXRunAction *, DMXPrimaryGeneratorAction *)
 
virtual ~DMXEventAction ()
 
virtual void BeginOfEventAction (const G4Event *)
 
virtual void EndOfEventAction (const G4Event *)
 
void SetDrawTrksFlag (G4String val)
 
G4String GetDrawTrksFlag ()
 
void SetDrawColsFlag (G4String val)
 
G4String GetDrawColsFlag ()
 
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 ()
 
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 ( DMXRunAction DMXRun,
DMXPrimaryGeneratorAction DMXGenerator 
)

Definition at line 74 of file DMXEventAction.cc.

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

Definition at line 102 of file DMXEventAction.cc.

102  {
103 
104  delete eventMessenger;
105 }

Member Function Documentation

void DMXEventAction::BeginOfEventAction ( const G4Event evt)
virtual

Reimplemented from G4UserEventAction.

Definition at line 109 of file DMXEventAction.cc.

References G4BestUnit, G4cout, G4endl, G4SDManager::GetCollectionID(), DMXPrimaryGeneratorAction::GetEnergyPrimary(), G4Event::GetEventID(), DMXPrimaryGeneratorAction::GetEventSeeds(), and G4SDManager::GetSDMpointer().

109  {
110 
111 
112  // grab seeds
113  seeds = genAction->GetEventSeeds();
114 
115  // grab energy of primary
116  energy_pri = genAction->GetEnergyPrimary();
117 
118  event_id = evt->GetEventID();
119 
120  // print this information event by event (modulo n)
121  if (event_id%printModulo == 0)
122  {
123  G4cout << "\n---> Begin of event: " << event_id << G4endl;
124  G4cout << "\n Primary Energy: " << G4BestUnit(energy_pri,"Energy")
125  << G4endl;
126  // HepRandom::showEngineStatus();
127  }
128 
129 
130  // get ID for scintillator hits collection
131  if (scintillatorCollID==-1) {
133  scintillatorCollID = SDman->GetCollectionID("scintillatorCollection");
134  }
135 
136  // get ID for pmt hits collection
137  if (pmtCollID==-1) {
139  pmtCollID = SDman->GetCollectionID("pmtCollection");
140  }
141 
142 }
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4int GetEventID() const
Definition: G4Event.hh:140
G4GLOB_DLL std::ostream G4cout
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
#define G4endl
Definition: G4ios.hh:61
void DMXEventAction::EndOfEventAction ( const G4Event evt)
virtual

Reimplemented from G4UserEventAction.

Definition at line 146 of file DMXEventAction.cc.

References G4THitsCollection< T >::DrawAllHits(), G4THitsCollection< T >::entries(), G4VAnalysisManager::FillH1(), G4BestUnit, G4cout, G4endl, G4HCofThisEvent::GetHC(), and G4Event::GetHCofThisEvent().

146  {
147 
148  // check that both hits collections have been defined
149  if(scintillatorCollID<0||pmtCollID<0) return;
150 
151  G4AnalysisManager* man = G4AnalysisManager::Instance();
152 
153  // address hits collections
154  DMXScintHitsCollection* SHC = NULL;
155  DMXPmtHitsCollection* PHC = NULL;
156  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
157  if(HCE) {
158  SHC = (DMXScintHitsCollection*)(HCE->GetHC(scintillatorCollID));
159  PHC = (DMXPmtHitsCollection*)(HCE->GetHC(pmtCollID));
160  }
161 
162  // event summary
163  totEnergy = 0.;
164  totEnergyGammas = 0.;
165  totEnergyNeutrons = 0.;
166  firstParticleE = 0.;
167  particleEnergy = 0.;
168  firstLXeHitTime = 0.;
169  aveTimePmtHits = 0.;
170 
171  firstParticleName = "";
172  particleName = "";
173 
174 
175  // particle flags
176  gamma_ev = false;
177  neutron_ev = false;
178  positron_ev = false;
179  electron_ev = false;
180  proton_ev = false;
181  other_ev = false;
182  start_gamma = false;
183  start_neutron = false;
184 
185 
186  // scintillator hits
187  if(SHC) {
188  S_hits = SHC->entries();
189 
190  for (G4int i=0; i<S_hits; i++) {
191  if(i==0) {
192  firstParticleName = (*SHC)[0]->GetParticle();
193  firstLXeHitTime = (*SHC)[0]->GetTime();
194  firstParticleE = (*SHC)[0]->GetParticleEnergy();
195  if (event_id%printModulo == 0 && S_hits > 0) {
196  G4cout << " First hit in LXe: " << firstParticleName << G4endl;
197  G4cout << " Number of hits in LXe: " << S_hits << G4endl;
198  }
199  }
200  hitEnergy = (*SHC)[i]->GetEdep();
201  totEnergy += hitEnergy;
202 
203  particleName = (*SHC)[i]->GetParticle();
204  particleEnergy = (*SHC)[i]->GetParticleEnergy();
205 
206  if(particleName == "gamma") {
207  gamma_ev = true;
208  start_gamma = true;
209  start_neutron = false;
210  }
211  else if(particleName == "neutron")
212  neutron_ev = true;
213  else if(particleName == "e+")
214  positron_ev = true;
215  else if(particleName == "e-")
216  electron_ev = true;
217  else if(particleName == "proton")
218  proton_ev = true;
219  else {
220  other_ev = true;
221  start_gamma = false;
222  start_neutron = true;
223  }
224 
225  if(start_gamma && !start_neutron)
226  totEnergyGammas += hitEnergy;
227  if(start_neutron && !start_gamma)
228  totEnergyNeutrons += hitEnergy;
229  }
230 
231  if (event_id%printModulo == 0)
232  G4cout << " Total energy in LXe: "
233  << G4BestUnit(totEnergy,"Energy") << G4endl;
234 
235  }
236 
237 
238  // PMT hits
239  if(PHC) {
240  P_hits = PHC->entries();
241 
242  // average time of PMT hits
243  for (G4int i=0; i<P_hits; i++) {
244  G4double time = ( (*PHC)[i]->GetTime() - firstLXeHitTime );
245  aveTimePmtHits += time / (G4double)P_hits;
246  //// if (event_id == 0) {
247  if(P_hits >= 0) {
248  man->FillH1(7,time);
249  }
250  }
251 
252  if (event_id%printModulo == 0 && P_hits > 0) {
253  G4cout << " Average light collection time: "
254  << G4BestUnit(aveTimePmtHits,"Time") << G4endl;
255  G4cout << " Number of PMT hits (photoelectron equivalent): "
256  << P_hits << G4endl;
257  }
258  // write out (x,y,z) of PMT hits
259  if (savePmtFlag)
260  writePmtHitsToFile(PHC);
261  }
262 
263 
264  // write out event summary
265  if(saveHitsFlag)
266  writeScintHitsToFile();
267 
268  // draw trajectories
269  if(drawColsFlag=="standard" && drawTrksFlag!="none")
270  drawTracks(evt);
271 
272  // hits in PMT
273  if(drawHitsFlag && PHC)
274  PHC->DrawAllHits();
275 
276  // print this event by event (modulo n)
277  if (event_id%printModulo == 0)
278  G4cout << "\n---> End of event: " << event_id << G4endl << G4endl;
279 
280 }
#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)
#define G4endl
Definition: G4ios.hh:61
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:174
double G4double
Definition: G4Types.hh:76
G4String DMXEventAction::GetDrawColsFlag ( )
inline

Definition at line 76 of file DMXEventAction.hh.

Referenced by DMXSteppingAction::UserSteppingAction().

76 {return drawColsFlag;};
G4String DMXEventAction::GetDrawTrksFlag ( )
inline

Definition at line 73 of file DMXEventAction.hh.

Referenced by DMXSteppingAction::UserSteppingAction().

73 {return drawTrksFlag;};
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: