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.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/optical/LXe/src/LXeEventAction.cc (Version 11.3.0) and /examples/extended/optical/LXe/src/LXeEventAction.cc (Version 9.5)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                             << 
 27 /// \file optical/LXe/src/LXeEventAction.cc    << 
 28 /// \brief Implementation of the LXeEventActio << 
 29 //                                             << 
 30 //                                             << 
 31 #include "LXeEventAction.hh"                       26 #include "LXeEventAction.hh"
 32                                                << 
 33 #include "LXeDetectorConstruction.hh"          << 
 34 #include "LXeHistoManager.hh"                  << 
 35 #include "LXePMTHit.hh"                        << 
 36 #include "LXeRun.hh"                           << 
 37 #include "LXeScintHit.hh"                          27 #include "LXeScintHit.hh"
                                                   >>  28 #include "LXePMTHit.hh"
                                                   >>  29 #include "LXeUserEventInformation.hh"
 38 #include "LXeTrajectory.hh"                        30 #include "LXeTrajectory.hh"
                                                   >>  31 #include "RecorderBase.hh"
 39                                                    32 
 40 #include "G4Event.hh"                          << 
 41 #include "G4EventManager.hh"                       33 #include "G4EventManager.hh"
 42 #include "G4RunManager.hh"                     << 
 43 #include "G4SDManager.hh"                          34 #include "G4SDManager.hh"
 44 #include "G4SystemOfUnits.hh"                  <<  35 #include "G4RunManager.hh"
 45 #include "G4Trajectory.hh"                     <<  36 #include "G4Event.hh"
                                                   >>  37 #include "G4EventManager.hh"
 46 #include "G4TrajectoryContainer.hh"                38 #include "G4TrajectoryContainer.hh"
 47 #include "G4UImanager.hh"                      <<  39 #include "G4Trajectory.hh"
 48 #include "G4VVisManager.hh"                        40 #include "G4VVisManager.hh"
 49 #include "G4ios.hh"                                41 #include "G4ios.hh"
                                                   >>  42 #include "G4UImanager.hh"
 50                                                    43 
 51 //....oooOO0OOooo........oooOO0OOooo........oo <<  44 //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 52                                                <<  45 LXeEventAction::LXeEventAction(RecorderBase* r)
 53 LXeEventAction::LXeEventAction(const LXeDetect <<  46   :recorder(r),saveThreshold(0),scintCollID(-1),pmtCollID(-1),verbose(0),
 54 {                                              <<  47    pmtThreshold(1),forcedrawphotons(false),forcenophotons(false)
 55   fEventMessenger = new LXeEventMessenger(this << 
 56 }                                              << 
 57                                                << 
 58 //....oooOO0OOooo........oooOO0OOooo........oo << 
 59                                                << 
 60 LXeEventAction::~LXeEventAction()              << 
 61 {                                                  48 {
 62   delete fEventMessenger;                      <<  49   eventMessenger=new LXeEventMessenger(this);
 63 }                                                  50 }
 64                                                <<  51  
 65 //....oooOO0OOooo........oooOO0OOooo........oo <<  52 //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 66                                                <<  53 LXeEventAction::~LXeEventAction(){}
 67 void LXeEventAction::BeginOfEventAction(const  <<  54 
 68 {                                              <<  55 //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 69   fHitCount = 0;                               <<  56 void LXeEventAction::BeginOfEventAction(const G4Event* anEvent){
 70   fPhotonCount_Scint = 0;                      <<  57   
 71   fPhotonCount_Ceren = 0;                      <<  58   //New event, add the user information object
 72   fAbsorptionCount = 0;                        <<  59   G4EventManager::
 73   fBoundaryAbsorptionCount = 0;                <<  60     GetEventManager()->SetUserInformation(new LXeUserEventInformation);
 74   fTotE = 0.0;                                 <<  61   
 75                                                << 
 76   fConvPosSet = false;                         << 
 77   fEdepMax = 0.0;                              << 
 78                                                << 
 79   fPMTsAboveThreshold = 0;                     << 
 80                                                << 
 81   G4SDManager* SDman = G4SDManager::GetSDMpoin     62   G4SDManager* SDman = G4SDManager::GetSDMpointer();
 82   if (fScintCollID < 0) fScintCollID = SDman-> <<  63   if(scintCollID<0)
 83   if (fPMTCollID < 0) fPMTCollID = SDman->GetC <<  64     scintCollID=SDman->GetCollectionID("scintCollection");
 84 }                                              <<  65   if(pmtCollID<0)
 85                                                <<  66     pmtCollID=SDman->GetCollectionID("pmtHitCollection");
 86 //....oooOO0OOooo........oooOO0OOooo........oo << 
 87                                                << 
 88 void LXeEventAction::EndOfEventAction(const G4 << 
 89 {                                              << 
 90   G4TrajectoryContainer* trajectoryContainer = << 
 91                                                    67 
                                                   >>  68   if(recorder)recorder->RecordBeginOfEvent(anEvent);
                                                   >>  69 }
                                                   >>  70  
                                                   >>  71 //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
                                                   >>  72 void LXeEventAction::EndOfEventAction(const G4Event* anEvent){
                                                   >>  73   
                                                   >>  74   LXeUserEventInformation* eventInformation
                                                   >>  75     =(LXeUserEventInformation*)anEvent->GetUserInformation();
                                                   >>  76   
                                                   >>  77   G4TrajectoryContainer* trajectoryContainer=anEvent->GetTrajectoryContainer();
                                                   >>  78   
 92   G4int n_trajectories = 0;                        79   G4int n_trajectories = 0;
 93   if (trajectoryContainer) n_trajectories = tr     80   if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
 94                                                    81 
 95   // extract the trajectories and draw them        82   // extract the trajectories and draw them
 96   if (G4VVisManager::GetConcreteInstance()) {  <<  83   if (G4VVisManager::GetConcreteInstance()){
 97     for (G4int i = 0; i < n_trajectories; ++i) <<  84     for (G4int i=0; i<n_trajectories; i++){ 
 98       auto trj = (LXeTrajectory*)((*(anEvent-> <<  85       LXeTrajectory* trj = (LXeTrajectory*)
 99       if (trj->GetParticleName() == "opticalph <<  86   ((*(anEvent->GetTrajectoryContainer()))[i]);
100         trj->SetForceDrawTrajectory(fForcedraw <<  87       if(trj->GetParticleName()=="opticalphoton"){
101         trj->SetForceNoDrawTrajectory(fForceno <<  88   trj->SetForceDrawTrajectory(forcedrawphotons);
102       }                                        <<  89   trj->SetForceNoDrawTrajectory(forcenophotons);
103       trj->DrawTrajectory();                   <<  90       }
104     }                                          <<  91       trj->DrawTrajectory(50);
105   }                                            <<  92     }
106                                                <<  93   }
107   LXeScintHitsCollection* scintHC = nullptr;   <<  94   
108   LXePMTHitsCollection* pmtHC = nullptr;       <<  95   LXeScintHitsCollection* SHC = 0;
109   G4HCofThisEvent* hitsCE = anEvent->GetHCofTh <<  96   LXePMTHitsCollection* PHC = 0;
110                                                <<  97   G4HCofThisEvent* HCE = anEvent->GetHCofThisEvent();
111   // Get the hit collections                   <<  98   
112   if (hitsCE) {                                <<  99   //Get the hit collections
113     if (fScintCollID >= 0) {                   << 100   if(HCE){
114       scintHC = (LXeScintHitsCollection*)(hits << 101     if(scintCollID>=0)SHC = (LXeScintHitsCollection*)(HCE->GetHC(scintCollID));
115     }                                          << 102     if(pmtCollID>=0)PHC = (LXePMTHitsCollection*)(HCE->GetHC(pmtCollID));
116     if (fPMTCollID >= 0) {                     << 103   }
117       pmtHC = (LXePMTHitsCollection*)(hitsCE-> << 104 
118     }                                          << 105   //Hits in scintillator
119   }                                            << 106   if(SHC){
120                                                << 107     int n_hit = SHC->entries();
121   // Hits in scintillator                      << 108     G4ThreeVector  eWeightPos(0.);     
122   if (scintHC) {                               << 
123     size_t n_hit = scintHC->entries();         << 
124     G4ThreeVector eWeightPos(0.);              << 
125     G4double edep;                                109     G4double edep;
126     G4double edepMax = 0;                      << 110     G4double edepMax=0;
127                                                << 
128     for (size_t i = 0; i < n_hit; ++i) {  // g << 
129       edep = (*scintHC)[i]->GetEdep();         << 
130       fTotE += edep;                           << 
131       eWeightPos += (*scintHC)[i]->GetPos() *  << 
132       if (edep > edepMax) {                    << 
133         edepMax = edep;  // store max energy d << 
134         G4ThreeVector posMax = (*scintHC)[i]-> << 
135         fPosMax = posMax;                      << 
136         fEdepMax = edep;                       << 
137       }                                        << 
138     }                                          << 
139                                                   111 
140     G4AnalysisManager::Instance()->FillH1(7, f << 112     for(int i=0;i<n_hit;i++){ //gather info on hits in scintillator
141                                                << 113       edep=(*SHC)[i]->GetEdep();
142     if (fTotE == 0.) {                         << 114       eventInformation->IncEDep(edep); //sum up the edep
143       if (fVerbose > 0) G4cout << "No hits in  << 115       eWeightPos += (*SHC)[i]->GetPos()*edep;//calculate energy weighted pos
144     }                                          << 116       if(edep>edepMax){
145     else {                                     << 117   edepMax=edep;//store max energy deposit
146       // Finish calculation of energy weighted << 118   G4ThreeVector posMax=(*SHC)[i]->GetPos();
147       eWeightPos /= fTotE;                     << 119   eventInformation->SetPosMax(posMax,edep);
148       fEWeightPos = eWeightPos;                << 120       }
149       if (fVerbose > 0) {                      << 121     }
150         G4cout << "\tEnergy weighted position  << 122     if(eventInformation->GetEDep()==0.){
151       }                                        << 123       if(verbose>0)G4cout<<"No hits in the scintillator this event."<<G4endl;
152     }                                          << 124     }    
153     if (fVerbose > 0) {                        << 125     else{
154       G4cout << "\tTotal energy deposition in  << 126       //Finish calculation of energy weighted position
155     }                                          << 127       eWeightPos/=eventInformation->GetEDep();
                                                   >> 128       eventInformation->SetEWeightPos(eWeightPos);
                                                   >> 129       if(verbose>0){
                                                   >> 130   G4cout << "\tEnergy weighted position of hits in LXe : "
                                                   >> 131          << eWeightPos/mm << G4endl;
                                                   >> 132       }
                                                   >> 133     }
                                                   >> 134     if(verbose>0){
                                                   >> 135     G4cout << "\tTotal energy deposition in scintillator : "
                                                   >> 136      << eventInformation->GetEDep() / keV << " (keV)" << G4endl;
                                                   >> 137     }
                                                   >> 138   }
                                                   >> 139   
                                                   >> 140   if(PHC){
                                                   >> 141     G4ThreeVector reconPos(0.,0.,0.);
                                                   >> 142     G4int pmts=PHC->entries();
                                                   >> 143     //Gather info from all PMTs
                                                   >> 144     for(G4int i=0;i<pmts;i++){
                                                   >> 145       eventInformation->IncHitCount((*PHC)[i]->GetPhotonCount());
                                                   >> 146       reconPos+=(*PHC)[i]->GetPMTPos()*(*PHC)[i]->GetPhotonCount();
                                                   >> 147       if((*PHC)[i]->GetPhotonCount()>=pmtThreshold){
                                                   >> 148   eventInformation->IncPMTSAboveThreshold();
                                                   >> 149       }
                                                   >> 150       else{//wasnt above the threshold, turn it back off
                                                   >> 151   (*PHC)[i]->SetDrawit(false);
                                                   >> 152       }
                                                   >> 153     }
                                                   >> 154     
                                                   >> 155     if(eventInformation->GetHitCount()>0){//dont bother unless there were hits
                                                   >> 156       reconPos/=eventInformation->GetHitCount();
                                                   >> 157       if(verbose>0){
                                                   >> 158   G4cout << "\tReconstructed position of hits in LXe : "
                                                   >> 159          << reconPos/mm << G4endl;
                                                   >> 160       }
                                                   >> 161       eventInformation->SetReconPos(reconPos);
                                                   >> 162     }
                                                   >> 163     PHC->DrawAllHits();
                                                   >> 164   }
                                                   >> 165 
                                                   >> 166   if(verbose>0){
                                                   >> 167     //End of event output. later to be controlled by a verbose level
                                                   >> 168     G4cout << "\tNumber of photons that hit PMTs in this event : "
                                                   >> 169      << eventInformation->GetHitCount() << G4endl;
                                                   >> 170     G4cout << "\tNumber of PMTs above threshold("<<pmtThreshold<<") : "
                                                   >> 171      << eventInformation->GetPMTSAboveThreshold() << G4endl;
                                                   >> 172     G4cout << "\tNumber of photons produced by scintillation in this event : "
                                                   >> 173      << eventInformation->GetPhotonCount_Scint() << G4endl;
                                                   >> 174     G4cout << "\tNumber of photons produced by cerenkov in this event : "
                                                   >> 175      << eventInformation->GetPhotonCount_Ceren() << G4endl;
                                                   >> 176     G4cout << "\tNumber of photons absorbed (OpAbsorption) in this event : "
                                                   >> 177      << eventInformation->GetAbsorptionCount() << G4endl;
                                                   >> 178     G4cout << "\tNumber of photons absorbed at boundaries (OpBoundary) in "
                                                   >> 179      << "this event : " << eventInformation->GetBoundaryAbsorptionCount() 
                                                   >> 180      << G4endl;
                                                   >> 181     G4cout << "Unacounted for photons in this event : " 
                                                   >> 182      << (eventInformation->GetPhotonCount_Scint() + 
                                                   >> 183          eventInformation->GetPhotonCount_Ceren() - 
                                                   >> 184          eventInformation->GetAbsorptionCount() -
                                                   >> 185          eventInformation->GetHitCount() - 
                                                   >> 186          eventInformation->GetBoundaryAbsorptionCount())
                                                   >> 187      << G4endl;
156   }                                               188   }
                                                   >> 189   //If we have set the flag to save 'special' events, save here
                                                   >> 190   if(saveThreshold&&eventInformation->GetPhotonCount() <= saveThreshold)
                                                   >> 191     G4RunManager::GetRunManager()->rndmSaveThisEvent();
157                                                   192 
158   if (pmtHC) {                                 << 193   if(recorder)recorder->RecordEndOfEvent(anEvent);
159     G4ThreeVector reconPos(0., 0., 0.);        << 194 }
160     size_t pmts = pmtHC->entries();            << 
161     // Gather info from all PMTs               << 
162     for (size_t i = 0; i < pmts; ++i) {        << 
163       fHitCount += (*pmtHC)[i]->GetPhotonCount << 
164       reconPos += (*pmtHC)[i]->GetPMTPos() * ( << 
165       if ((*pmtHC)[i]->GetPhotonCount() >= fPM << 
166         ++fPMTsAboveThreshold;                 << 
167       }                                        << 
168       else {  // wasn't above the threshold, t << 
169         (*pmtHC)[i]->SetDrawit(false);         << 
170       }                                        << 
171     }                                          << 
172                                                << 
173     G4AnalysisManager::Instance()->FillH1(1, f << 
174     G4AnalysisManager::Instance()->FillH1(2, f << 
175                                                << 
176     if (fHitCount > 0) {  // don't bother unle << 
177       reconPos /= fHitCount;                   << 
178       if (fVerbose > 0) {                      << 
179         G4cout << "\tReconstructed position of << 
180       }                                        << 
181       fReconPos = reconPos;                    << 
182     }                                          << 
183     pmtHC->DrawAllHits();                      << 
184   }                                            << 
185                                                   195 
186   G4AnalysisManager::Instance()->FillH1(3, fPh << 196 //_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
187   G4AnalysisManager::Instance()->FillH1(4, fPh << 197 void LXeEventAction::SetSaveThreshold(G4int save){
188   G4AnalysisManager::Instance()->FillH1(5, fAb << 198 /*Sets the save threshold for the random number seed. If the number of photons
189   G4AnalysisManager::Instance()->FillH1(6, fBo << 199 generated in an event is lower than this, then save the seed for this event
190                                                << 200 in a file called run###evt###.rndm
191   if (fVerbose > 0) {                          << 201 */
192     // End of event output. later to be contro << 202   saveThreshold=save;
193     G4cout << "\tNumber of photons that hit PM << 203   G4RunManager::GetRunManager()->SetRandomNumberStore(true);
194     G4cout << "\tNumber of PMTs above threshol << 204   G4RunManager::GetRunManager()->SetRandomNumberStoreDir("random/");
195            << G4endl;                          << 205   //  G4UImanager::GetUIpointer()->ApplyCommand("/random/setSavingFlag 1");
196     G4cout << "\tNumber of photons produced by << 206 }
197            << G4endl;                          << 
198     G4cout << "\tNumber of photons produced by << 
199            << G4endl;                          << 
200     G4cout << "\tNumber of photons absorbed (O << 
201            << G4endl;                          << 
202     G4cout << "\tNumber of photons absorbed at << 
203            << "this event : " << fBoundaryAbso << 
204     G4cout << "Unaccounted for photons in this << 
205            << (fPhotonCount_Scint + fPhotonCou << 
206                - fBoundaryAbsorptionCount)     << 
207            << G4endl;                          << 
208   }                                            << 
209                                                   207 
210   // update the run statistics                 << 
211   auto run = static_cast<LXeRun*>(G4RunManager << 
212                                                   208 
213   run->IncHitCount(fHitCount);                 << 
214   run->IncPhotonCount_Scint(fPhotonCount_Scint << 
215   run->IncPhotonCount_Ceren(fPhotonCount_Ceren << 
216   run->IncEDep(fTotE);                         << 
217   run->IncAbsorption(fAbsorptionCount);        << 
218   run->IncBoundaryAbsorption(fBoundaryAbsorpti << 
219   run->IncHitsAboveThreshold(fPMTsAboveThresho << 
220                                                   209 
221   // If we have set the flag to save 'special' << 
222   if (fPhotonCount_Scint + fPhotonCount_Ceren  << 
223     G4RunManager::GetRunManager()->rndmSaveThi << 
224   }                                            << 
225 }                                              << 
226                                                   210 
227 //....oooOO0OOooo........oooOO0OOooo........oo << 
228                                                   211