Import Geant4 4.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:39:52 +02:00
parent 921d3b1cda
commit 330b82b769
4524 changed files with 178689 additions and 43575 deletions
@@ -33,15 +33,27 @@
// by A. Howard and H. Araujo
// (27th November 2001)
//
// History/Additions:
// 16 Jan 2002 Added analysis
//
//
// EventAction program
// --------------------------------------------------------------
#include "DMXEventAction.hh"
// pass parameters for messengers:
#include "DMXRunAction.hh"
#include "DMXPrimaryGeneratorAction.hh"
// note DMXPmtHit.hh and DMXScintHit.hh are included in DMXEventAction.hh
#include "DMXEventActionMessenger.hh"
#ifdef G4ANALYSIS_USE
#include "DMXAnalysisManager.hh"
#endif
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4HCofThisEvent.hh"
@@ -58,7 +70,10 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
DMXEventAction::DMXEventAction() {
DMXEventAction::DMXEventAction(DMXRunAction* DMXRun,
DMXPrimaryGeneratorAction* DMXGenerator)
: runAct(DMXRun),genAction(DMXGenerator)
{
// create messenger
eventMessenger = new DMXEventActionMessenger(this);
@@ -76,6 +91,9 @@ DMXEventAction::DMXEventAction() {
scintillatorCollID = -1;
pmtCollID = -1;
energy_pri=0;
seeds=NULL;
}
@@ -89,11 +107,24 @@ DMXEventAction::~DMXEventAction() {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DMXEventAction::BeginOfEventAction(const G4Event* evt) {
// grab seeds
seeds = genAction->GetEventSeeds();
// grab energy of primary
energy_pri = genAction->GetEnergyPrimary();
event_id = evt->GetEventID();
// print this information event by event (modulo n)
if (event_id%printModulo == 0)
G4cout << "\n---> Begin of event: " << event_id << G4endl;
{
G4cout << "\n---> Begin of event: " << event_id << G4endl;
G4cout << " Primary Energy: " << G4BestUnit(energy_pri,"Energy")
<< G4endl;
// HepRandom::showEngineStatus();
}
// get ID for scintillator hits collection
if (scintillatorCollID==-1) {
@@ -129,6 +160,7 @@ void DMXEventAction::EndOfEventAction(const G4Event* evt) {
totEnergy = 0.;
totEnergyGammas = 0.;
totEnergyNeutrons = 0.;
firstParticleE = 0.;
particleEnergy = 0.;
firstLXeHitTime = 0.;
aveTimePmtHits = 0.;
@@ -151,16 +183,20 @@ void DMXEventAction::EndOfEventAction(const G4Event* evt) {
// scintillator hits
if(SHC) {
S_hits = SHC->entries();
for (G4int i=0; i<S_hits; i++) {
if(i==0) {
firstParticleName = (*SHC)[0]->GetParticle();
firstLXeHitTime = (*SHC)[0]->GetTime();
if (event_id%printModulo == 0)
G4cout << " First hit: " << firstParticleName << G4endl;
firstParticleE = (*SHC)[0]->GetParticleEnergy();
if (event_id%printModulo == 0) {
G4cout << " First hit in LXe: " << firstParticleName << G4endl;
G4cout << " Number of hits in LXe: " << S_hits << G4endl;
}
}
hitEnergy = (*SHC)[i]->GetEdep();
totEnergy += hitEnergy;
particleName = (*SHC)[i]->GetParticle();
particleEnergy = (*SHC)[i]->GetParticleEnergy();
@@ -188,36 +224,50 @@ void DMXEventAction::EndOfEventAction(const G4Event* evt) {
if(start_neutron && !start_gamma)
totEnergyNeutrons += hitEnergy;
}
if (event_id%printModulo == 0)
G4cout << " Total energy in LXe: "
<< G4BestUnit(totEnergy,"Energy") << G4endl;
}
// PMT hits
if(PHC) {
P_hits = PHC->entries();
// average time of PMT hits
for (G4int i=0; i<P_hits; i++)
aveTimePmtHits +=
((*PHC)[i]->GetTime() - firstLXeHitTime)
/ (G4double)P_hits;
if (event_id%printModulo == 0)
for (G4int i=0; i<P_hits; i++) {
G4double time = ( (*PHC)[i]->GetTime() - firstLXeHitTime );
aveTimePmtHits += time / (G4double)P_hits;
if (event_id == 0) {
#ifdef G4ANALYSIS_USE
// pass first event for histogram record:
DMXAnalysisManager* analysis = DMXAnalysisManager::getInstance();
analysis->HistFirstTime(time);
#endif
}
}
if (event_id%printModulo == 0) {
G4cout << " Average light collection time: "
<< G4BestUnit(aveTimePmtHits,"Time") << G4endl;
G4cout << " Number of PMT hits (photons): " << P_hits << G4endl;
// #ifdef G4ANALYSIS_USE
// // plot histograms, interactively:
// DMXAnalysisManager* analysis = DMXAnalysisManager::getInstance();
// analysis->PlotHistosInter();
// #endif
}
// write out (x,y,z) of PMT hits
if (savePmtFlag)
writePmtHitsToFile(PHC);
}
// write out event summary
if(saveHitsFlag)
writeScintHitsToFile();
// draw trajectories
if(drawColsFlag=="standard" && drawTrksFlag!="none")
drawTracks(evt);
@@ -230,7 +280,6 @@ void DMXEventAction::EndOfEventAction(const G4Event* evt) {
if (event_id%printModulo == 0)
G4cout << "---> End of event: " << event_id << G4endl;
}
@@ -238,73 +287,99 @@ void DMXEventAction::EndOfEventAction(const G4Event* evt) {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DMXEventAction::writeScintHitsToFile(void) {
G4String filename="hits.out";
// G4String filename="hits.out";
G4String filename=runAct->GetsavehitsFile();
G4std::ofstream hitsfile(filename, G4std::ios::app);
if(!event_id) {
G4std::ofstream hitsfile(filename);
hitsfile <<"Evt Etot LXe LXeTime PMT PmtTime First Flags"
hitsfile <<"Evt E_Prim Etot LXe LXeTime PMT PmtTime First Flags Seed1 Seed2"
<< G4endl;
hitsfile <<"# MeV hits ns hits ns hit" << G4endl
hitsfile <<"# MeV MeV hits ns hits ns hit"
<< G4endl
<< G4endl;
}
if(S_hits) {
if(hitsfile.is_open()) {
if(hitsfile.is_open()) {
hitsfile << G4std::setiosflags(G4std::ios::fixed)
<< G4std::setprecision(4)
<< G4std::setiosflags(G4std::ios::left)
<< G4std::setw(6)
<< event_id << "\t"
<< totEnergy/MeV << "\t"
<< S_hits << "\t"
<< G4std::setiosflags(G4std::ios::scientific)
<< G4std::setprecision(2)
<< firstLXeHitTime/nanosecond << "\t"
<< P_hits << "\t"
<< G4std::setiosflags(G4std::ios::fixed)
<< G4std::setprecision(4)
<< aveTimePmtHits/nanosecond << "\t"
<< firstParticleName << "\t"
<< (gamma_ev ? "gamma " : "")
<< (neutron_ev ? "neutron " : "")
<< (positron_ev ? "positron " : "")
<< (electron_ev ? "electron " : "")
<< (other_ev ? "other " : "")
<< G4endl;
if (event_id%printModulo == 0)
G4cout << " Event summary in file " << filename << G4endl;
hitsfile.close();
hitsfile << G4std::setiosflags(G4std::ios::fixed)
<< G4std::setprecision(4)
<< G4std::setiosflags(G4std::ios::left)
<< G4std::setw(6)
<< event_id << "\t"
<< energy_pri/MeV << "\t"
<< totEnergy/MeV << "\t"
<< S_hits << "\t"
<< G4std::setiosflags(G4std::ios::scientific)
<< G4std::setprecision(2)
<< firstLXeHitTime/nanosecond << "\t"
<< P_hits << "\t"
<< G4std::setiosflags(G4std::ios::fixed)
<< G4std::setprecision(4)
<< aveTimePmtHits/nanosecond << "\t"
<< firstParticleName << "\t"
<< (gamma_ev ? "gamma " : "")
<< (neutron_ev ? "neutron " : "")
<< (positron_ev ? "positron " : "")
<< (electron_ev ? "electron " : "")
<< (other_ev ? "other " : "")
<< *seeds << "\t"
<< *(seeds+1) << "\t"
<< G4endl;
if (event_id%printModulo == 0)
G4cout << " Event summary in file " << filename << G4endl;
hitsfile.close();
}
#ifdef G4ANALYSIS_USE
long seed1 = *seeds;
long seed2 = *(seeds+1);
// pass event summary to analysis manager for booking into histos and ntple
DMXAnalysisManager* analysis = DMXAnalysisManager::getInstance();
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);
#endif
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void DMXEventAction::writePmtHitsToFile(const DMXPmtHitsCollection* hits) {
G4String filename="pmt.out";
G4std::ofstream pmtfile(filename);
// G4String filename="pmt.out";
G4String filename=runAct->GetsavepmtFile();
G4std::ofstream pmtfile(filename, G4std::ios::app);
G4double x; G4double y; G4double z;
if(pmtfile.is_open()) {
pmtfile << "Hit# X, mm Y, mm Z, mm" << G4endl;
pmtfile << G4std::setiosflags(G4std::ios::fixed)
<< G4std::setprecision(3)
<< G4std::setiosflags(G4std::ios::left)
<< G4std::setw(6);
<< G4std::setprecision(3)
<< G4std::setiosflags(G4std::ios::left)
<< G4std::setw(6);
for (G4int i=0; i<P_hits; i++)
pmtfile << i << "\t"
<< ((*hits)[i]->GetPos()).x()/mm << "\t"
<< ((*hits)[i]->GetPos()).y()/mm << "\t"
<< ((*hits)[i]->GetPos()).z()/mm << G4endl;
{
x = ((*hits)[i]->GetPos()).x()/mm;
y = ((*hits)[i]->GetPos()).y()/mm;
z = ((*hits)[i]->GetPos()).z()/mm;
pmtfile << i << "\t"
<< x << "\t"
<< y << "\t"
<< z << G4endl;
#ifdef G4ANALYSIS_USE
// pass pmt hit summary to analysis manager for booking in ntples
DMXAnalysisManager* analysis = DMXAnalysisManager::getInstance();
analysis->analysePMTHits(event_id,i,x,y,z);
#endif
}
if (event_id%printModulo == 0)
G4cout << P_hits << " PMT hits in " << filename << G4endl;
pmtfile.close();
if (event_id%printModulo == 0)
G4cout << " PMT hits in " << filename << G4endl;
}
}