60 #include "G4HCofThisEvent.hh"
61 #include "G4VHitsCollection.hh"
77 : runAct(0),genAction(0),hitsfile(0),pmtfile(0)
84 drawColsFlag =
"standard";
93 scintillatorCollID = -1;
115 delete eventMessenger;
143 if (event_id%printModulo == 0)
145 G4cout <<
"\n---> Begin of event: " << event_id <<
G4endl;
153 if (scintillatorCollID==-1) {
171 if(scintillatorCollID<0||pmtCollID<0)
return;
186 totEnergyGammas = 0.;
187 totEnergyNeutrons = 0.;
190 firstLXeHitTime = 0.;
193 firstParticleName =
"";
205 start_neutron =
false;
212 for (
G4int i=0; i<S_hits; i++) {
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;
222 hitEnergy = (*SHC)[i]->GetEdep();
223 totEnergy += hitEnergy;
225 particleName = (*SHC)[i]->GetParticle();
226 particleEnergy = (*SHC)[i]->GetParticleEnergy();
228 if(particleName ==
"gamma") {
231 start_neutron =
false;
233 else if(particleName ==
"neutron")
235 else if(particleName ==
"e+")
237 else if(particleName ==
"e-")
239 else if(particleName ==
"proton")
244 start_neutron =
true;
247 if(start_gamma && !start_neutron)
248 totEnergyGammas += hitEnergy;
249 if(start_neutron && !start_gamma)
250 totEnergyNeutrons += hitEnergy;
253 if (event_id%printModulo == 0)
254 G4cout <<
" Total energy in LXe: "
265 for (
G4int i=0; i<P_hits; i++) {
266 G4double time = ( (*PHC)[i]->GetTime() - firstLXeHitTime );
267 aveTimePmtHits += time / (
G4double)P_hits;
274 if (event_id%printModulo == 0 && P_hits > 0) {
275 G4cout <<
" Average light collection time: "
277 G4cout <<
" Number of PMT hits (photoelectron equivalent): "
282 writePmtHitsToFile(PHC);
288 writeScintHitsToFile();
291 if(drawColsFlag==
"standard" && drawTrksFlag!=
"none")
295 if(drawHitsFlag && PHC)
299 if (event_id%printModulo == 0)
307 void DMXEventAction::writeScintHitsToFile()
323 std::stringstream
sss;
325 filename = sss.str();
329 hitsfile =
new std::ofstream;
330 hitsfile->open(filename);
331 (*hitsfile) <<
"Evt Eprim Etot LXe LXeTime PMT PMTTime Seed1 Seed2 First Flags"
333 (*hitsfile) <<
"# MeV MeV hits ns hits ns hit"
340 if(hitsfile->is_open()) {
343 (*hitsfile) << std::setiosflags(std::ios::fixed)
344 << std::setprecision(4)
348 << energy_pri/
MeV <<
"\t"
349 << totEnergy/
MeV <<
"\t"
351 << std::setiosflags(std::ios::scientific)
352 << std::setprecision(2)
355 << std::setiosflags(std::ios::fixed)
356 << std::setprecision(4)
359 << *(seeds+1) <<
"\t"
360 << firstParticleName <<
"\t"
361 << (gamma_ev ?
"gamma " :
"")
362 << (neutron_ev ?
"neutron " :
"")
363 << (positron_ev ?
"positron " :
"")
364 << (electron_ev ?
"electron " :
"")
365 << (other_ev ?
"other " :
"")
368 if (event_id%printModulo == 0)
369 G4cout <<
" Event summary in file " << filename <<
G4endl;
373 G4int firstparticleIndex = 0;
374 if(firstParticleName ==
"gamma") firstparticleIndex = 1;
375 else if (firstParticleName ==
"neutron") firstparticleIndex = 2;
376 else if(firstParticleName ==
"electron") firstparticleIndex = 3;
377 else if(firstParticleName ==
"positron") firstparticleIndex = 4;
379 firstparticleIndex = 5;
391 long seed2 = *(seeds+1);
432 std::stringstream
sss;
434 filename = sss.str();
437 pmtfile =
new std::ofstream;
438 pmtfile->open(filename);
445 if(pmtfile->is_open()) {
446 (*pmtfile) <<
"Hit# X, mm Y, mm Z, mm" <<
G4endl;
447 (*pmtfile) << std::setiosflags(std::ios::fixed)
448 << std::setprecision(3)
451 for (
G4int i=0; i<P_hits; i++)
453 x = ((*hits)[i]->GetPos()).
x()/
mm;
454 y = ((*hits)[i]->GetPos()).y()/
mm;
455 z = ((*hits)[i]->GetPos()).
z()/
mm;
456 (*pmtfile) << i <<
"\t"
462 if (event_id == 0 ) {
475 if (event_id%printModulo == 0 && P_hits > 0)
476 G4cout <<
" " << P_hits <<
" PMT hits in " << filename <<
G4endl;
484 void DMXEventAction::drawTracks(
const G4Event* evt) {
489 G4int n_trajectories = 0;
491 if(trajContainer) n_trajectories = trajContainer->
entries();
492 for (
G4int i=0; i<n_trajectories; i++) {
494 if (drawTrksFlag ==
"all")
496 else if ((drawTrksFlag ==
"charged") && (trj->
GetCharge() != 0.))
498 else if ((drawTrksFlag ==
"noscint")
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
G4String GetsavehitsFile() const
static constexpr double mm
virtual void BeginOfEventAction(const G4Event *)
G4VHitsCollection * GetHC(G4int i)
G4int GetCollectionID(G4String colName)
G4String GetsavepmtFile() const
static G4VVisManager * GetConcreteInstance()
G4double GetCharge() const
virtual ~DMXEventAction()
const long * GetEventSeeds() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4TrajectoryContainer * GetTrajectoryContainer() const
G4double GetEnergyPrimary() const
static constexpr double nanosecond
static G4UImanager * GetUIpointer()
G4GLOB_DLL std::ostream G4cout
G4bool FillNtupleDColumn(G4int id, G4double value)
virtual void EndOfEventAction(const G4Event *)
static G4RunManager * GetRunManager()
static const char sss[MAX_N_PAR+2]
virtual void DrawTrajectory() const
G4bool FillH2(G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0)
G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
static G4SDManager * GetSDMpointer()
virtual void DrawAllHits()
static constexpr double MeV
G4HCofThisEvent * GetHCofThisEvent() const
const G4UserRunAction * GetUserRunAction() const
static constexpr double keV
G4String GetParticleName() const
G4int ApplyCommand(const char *aCommand)