60 #include "G4HCofThisEvent.hh"
61 #include "G4VHitsCollection.hh"
76 : runAct(DMXRun),genAction(DMXGenerator)
83 drawColsFlag =
"standard";
92 scintillatorCollID = -1;
104 delete eventMessenger;
121 if (event_id%printModulo == 0)
123 G4cout <<
"\n---> Begin of event: " << event_id <<
G4endl;
131 if (scintillatorCollID==-1) {
149 if(scintillatorCollID<0||pmtCollID<0)
return;
164 totEnergyGammas = 0.;
165 totEnergyNeutrons = 0.;
168 firstLXeHitTime = 0.;
171 firstParticleName =
"";
183 start_neutron =
false;
190 for (
G4int i=0; i<S_hits; i++) {
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;
200 hitEnergy = (*SHC)[i]->GetEdep();
201 totEnergy += hitEnergy;
203 particleName = (*SHC)[i]->GetParticle();
204 particleEnergy = (*SHC)[i]->GetParticleEnergy();
206 if(particleName ==
"gamma") {
209 start_neutron =
false;
211 else if(particleName ==
"neutron")
213 else if(particleName ==
"e+")
215 else if(particleName ==
"e-")
217 else if(particleName ==
"proton")
222 start_neutron =
true;
225 if(start_gamma && !start_neutron)
226 totEnergyGammas += hitEnergy;
227 if(start_neutron && !start_gamma)
228 totEnergyNeutrons += hitEnergy;
231 if (event_id%printModulo == 0)
232 G4cout <<
" Total energy in LXe: "
243 for (
G4int i=0; i<P_hits; i++) {
244 G4double time = ( (*PHC)[i]->GetTime() - firstLXeHitTime );
245 aveTimePmtHits += time / (
G4double)P_hits;
252 if (event_id%printModulo == 0 && P_hits > 0) {
253 G4cout <<
" Average light collection time: "
255 G4cout <<
" Number of PMT hits (photoelectron equivalent): "
260 writePmtHitsToFile(PHC);
266 writeScintHitsToFile();
269 if(drawColsFlag==
"standard" && drawTrksFlag!=
"none")
273 if(drawHitsFlag && PHC)
277 if (event_id%printModulo == 0)
285 void DMXEventAction::writeScintHitsToFile(
void) {
291 std::ofstream hitsfileInit(filename);
292 hitsfileInit <<
"Evt Eprim Etot LXe LXeTime PMT PMTTime Seed1 Seed2 First Flags"
294 hitsfileInit <<
"# MeV MeV hits ns hits ns hit"
301 if(hitsfile.is_open()) {
304 hitsfile << std::setiosflags(std::ios::fixed)
305 << std::setprecision(4)
309 << energy_pri/
MeV <<
"\t"
310 << totEnergy/
MeV <<
"\t"
312 << std::setiosflags(std::ios::scientific)
313 << std::setprecision(2)
316 << std::setiosflags(std::ios::fixed)
317 << std::setprecision(4)
320 << *(seeds+1) <<
"\t"
321 << firstParticleName <<
"\t"
322 << (gamma_ev ?
"gamma " :
"")
323 << (neutron_ev ?
"neutron " :
"")
324 << (positron_ev ?
"positron " :
"")
325 << (electron_ev ?
"electron " :
"")
326 << (other_ev ?
"other " :
"")
329 if (event_id%printModulo == 0)
330 G4cout <<
" Event summary in file " << filename <<
G4endl;
335 G4int firstparticleIndex = 0;
336 if(firstParticleName ==
"gamma") firstparticleIndex = 1;
337 else if (firstParticleName ==
"neutron") firstparticleIndex = 2;
338 else if(firstParticleName ==
"electron") firstparticleIndex = 3;
339 else if(firstParticleName ==
"positron") firstparticleIndex = 4;
341 firstparticleIndex = 5;
353 long seed2 = *(seeds+1);
388 if(pmtfile.is_open()) {
389 pmtfile <<
"Hit# X, mm Y, mm Z, mm" <<
G4endl;
390 pmtfile << std::setiosflags(std::ios::fixed)
391 << std::setprecision(3)
394 for (
G4int i=0; i<P_hits; i++)
396 x = ((*hits)[i]->GetPos()).
x()/
mm;
397 y = ((*hits)[i]->GetPos()).
y()/
mm;
398 z = ((*hits)[i]->GetPos()).
z()/
mm;
405 if (event_id == 0 ) {
418 if (event_id%printModulo == 0 && P_hits > 0)
419 G4cout <<
" " << P_hits <<
" PMT hits in " << filename <<
G4endl;
428 void DMXEventAction::drawTracks(
const G4Event* evt) {
433 G4int n_trajectories = 0;
435 if(trajContainer) n_trajectories = trajContainer->
entries();
436 for (
G4int i=0; i<n_trajectories; i++) {
438 if (drawTrksFlag ==
"all")
440 else if ((drawTrksFlag ==
"charged") && (trj->
GetCharge() != 0.))
442 else if ((drawTrksFlag ==
"noscint")
virtual void BeginOfEventAction(const G4Event *)
G4VHitsCollection * GetHC(G4int i)
G4int GetCollectionID(G4String colName)
static G4VVisManager * GetConcreteInstance()
G4double GetCharge() const
virtual ~DMXEventAction()
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4TrajectoryContainer * GetTrajectoryContainer() const
static G4UImanager * GetUIpointer()
G4GLOB_DLL std::ostream G4cout
G4bool FillNtupleDColumn(G4int id, G4double value)
virtual void EndOfEventAction(const G4Event *)
G4String GetsavehitsFile()
const long * GetEventSeeds()
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()
DMXEventAction(DMXRunAction *, DMXPrimaryGeneratorAction *)
G4HCofThisEvent * GetHCofThisEvent() const
G4String GetsavepmtFile()
G4double GetEnergyPrimary()
G4String GetParticleName() const
G4int ApplyCommand(const char *aCommand)