63 #include "G4HCofThisEvent.hh"
64 #include "G4VHitsCollection.hh"
79 : runAct(DMXRun),genAction(DMXGenerator)
86 drawColsFlag =
"standard";
95 scintillatorCollID = -1;
107 delete eventMessenger;
124 if (event_id%printModulo == 0)
126 G4cout <<
"\n---> Begin of event: " << event_id <<
G4endl;
134 if (scintillatorCollID==-1) {
152 if(scintillatorCollID<0||pmtCollID<0)
return;
165 totEnergyGammas = 0.;
166 totEnergyNeutrons = 0.;
169 firstLXeHitTime = 0.;
172 firstParticleName =
"";
184 start_neutron =
false;
191 for (
G4int i=0; i<S_hits; i++) {
193 firstParticleName = (*SHC)[0]->GetParticle();
194 firstLXeHitTime = (*SHC)[0]->GetTime();
195 firstParticleE = (*SHC)[0]->GetParticleEnergy();
196 if (event_id%printModulo == 0 && S_hits > 0) {
197 G4cout <<
" First hit in LXe: " << firstParticleName <<
G4endl;
198 G4cout <<
" Number of hits in LXe: " << S_hits <<
G4endl;
201 hitEnergy = (*SHC)[i]->GetEdep();
202 totEnergy += hitEnergy;
204 particleName = (*SHC)[i]->GetParticle();
205 particleEnergy = (*SHC)[i]->GetParticleEnergy();
207 if(particleName ==
"gamma") {
210 start_neutron =
false;
212 else if(particleName ==
"neutron")
214 else if(particleName ==
"e+")
216 else if(particleName ==
"e-")
218 else if(particleName ==
"proton")
223 start_neutron =
true;
226 if(start_gamma && !start_neutron)
227 totEnergyGammas += hitEnergy;
228 if(start_neutron && !start_gamma)
229 totEnergyNeutrons += hitEnergy;
232 if (event_id%printModulo == 0)
233 G4cout <<
" Total energy in LXe: "
244 for (
G4int i=0; i<P_hits; i++) {
245 G4double time = ( (*PHC)[i]->GetTime() - firstLXeHitTime );
246 aveTimePmtHits += time / (
G4double)P_hits;
249 #ifdef G4ANALYSIS_USE
251 DMXAnalysisManager* analysis = DMXAnalysisManager::getInstance();
252 analysis->HistTime(time);
257 if (event_id%printModulo == 0 && P_hits > 0) {
258 G4cout <<
" Average light collection time: "
260 G4cout <<
" Number of PMT hits (photoelectron equivalent): "
273 writePmtHitsToFile(PHC);
279 writeScintHitsToFile();
282 if(drawColsFlag==
"standard" && drawTrksFlag!=
"none")
286 if(drawHitsFlag && PHC)
290 if (event_id%printModulo == 0)
298 void DMXEventAction::writeScintHitsToFile(
void) {
304 std::ofstream hitsfile(filename);
305 hitsfile <<
"Evt Eprim Etot LXe LXeTime PMT PMTTime Seed1 Seed2 First Flags"
307 hitsfile <<
"# MeV MeV hits ns hits ns hit"
314 if(hitsfile.is_open()) {
317 hitsfile << std::setiosflags(std::ios::fixed)
318 << std::setprecision(4)
322 << energy_pri/
MeV <<
"\t"
323 << totEnergy/
MeV <<
"\t"
325 << std::setiosflags(std::ios::scientific)
326 << std::setprecision(2)
329 << std::setiosflags(std::ios::fixed)
330 << std::setprecision(4)
333 << *(seeds+1) <<
"\t"
334 << firstParticleName <<
"\t"
335 << (gamma_ev ?
"gamma " :
"")
336 << (neutron_ev ?
"neutron " :
"")
337 << (positron_ev ?
"positron " :
"")
338 << (electron_ev ?
"electron " :
"")
339 << (other_ev ?
"other " :
"")
342 if (event_id%printModulo == 0)
343 G4cout <<
" Event summary in file " << filename <<
G4endl;
347 #ifdef G4ANALYSIS_USE
349 long seed2 = *(seeds+1);
351 DMXAnalysisManager* analysis = DMXAnalysisManager::getInstance();
352 analysis->analyseScintHits(event_id,energy_pri,totEnergy,S_hits,firstLXeHitTime,P_hits,aveTimePmtHits,firstParticleName,firstParticleE,gamma_ev,neutron_ev,positron_ev,electron_ev,other_ev,seed1,seed2);
367 if(pmtfile.is_open()) {
368 pmtfile <<
"Hit# X, mm Y, mm Z, mm" <<
G4endl;
369 pmtfile << std::setiosflags(std::ios::fixed)
370 << std::setprecision(3)
373 for (
G4int i=0; i<P_hits; i++)
375 x = ((*hits)[i]->GetPos()).
x()/
mm;
376 y = ((*hits)[i]->GetPos()).
y()/
mm;
377 z = ((*hits)[i]->GetPos()).
z()/
mm;
382 #ifdef G4ANALYSIS_USE
384 DMXAnalysisManager* analysis = DMXAnalysisManager::getInstance();
385 analysis->analysePMTHits(event_id,i,x,y,z);
388 if (event_id%printModulo == 0 && P_hits > 0)
389 G4cout <<
" " << P_hits <<
" PMT hits in " << filename <<
G4endl;
398 void DMXEventAction::drawTracks(
const G4Event* evt) {
403 G4int n_trajectories = 0;
405 if(trajContainer) n_trajectories = trajContainer->
entries();
406 for (
G4int i=0; i<n_trajectories; i++) {
408 if (drawTrksFlag ==
"all")
410 else if ((drawTrksFlag ==
"charged") && (trj->
GetCharge() != 0.))
412 else if ((drawTrksFlag ==
"noscint")