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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 4.0.p1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 /// \file optical/LXe/src/LXeEventAction.cc       
 28 /// \brief Implementation of the LXeEventActio    
 29 //                                                
 30 //                                                
 31 #include "LXeEventAction.hh"                      
 32                                                   
 33 #include "LXeDetectorConstruction.hh"             
 34 #include "LXeHistoManager.hh"                     
 35 #include "LXePMTHit.hh"                           
 36 #include "LXeRun.hh"                              
 37 #include "LXeScintHit.hh"                         
 38 #include "LXeTrajectory.hh"                       
 39                                                   
 40 #include "G4Event.hh"                             
 41 #include "G4EventManager.hh"                      
 42 #include "G4RunManager.hh"                        
 43 #include "G4SDManager.hh"                         
 44 #include "G4SystemOfUnits.hh"                     
 45 #include "G4Trajectory.hh"                        
 46 #include "G4TrajectoryContainer.hh"               
 47 #include "G4UImanager.hh"                         
 48 #include "G4VVisManager.hh"                       
 49 #include "G4ios.hh"                               
 50                                                   
 51 //....oooOO0OOooo........oooOO0OOooo........oo    
 52                                                   
 53 LXeEventAction::LXeEventAction(const LXeDetect    
 54 {                                                 
 55   fEventMessenger = new LXeEventMessenger(this    
 56 }                                                 
 57                                                   
 58 //....oooOO0OOooo........oooOO0OOooo........oo    
 59                                                   
 60 LXeEventAction::~LXeEventAction()                 
 61 {                                                 
 62   delete fEventMessenger;                         
 63 }                                                 
 64                                                   
 65 //....oooOO0OOooo........oooOO0OOooo........oo    
 66                                                   
 67 void LXeEventAction::BeginOfEventAction(const     
 68 {                                                 
 69   fHitCount = 0;                                  
 70   fPhotonCount_Scint = 0;                         
 71   fPhotonCount_Ceren = 0;                         
 72   fAbsorptionCount = 0;                           
 73   fBoundaryAbsorptionCount = 0;                   
 74   fTotE = 0.0;                                    
 75                                                   
 76   fConvPosSet = false;                            
 77   fEdepMax = 0.0;                                 
 78                                                   
 79   fPMTsAboveThreshold = 0;                        
 80                                                   
 81   G4SDManager* SDman = G4SDManager::GetSDMpoin    
 82   if (fScintCollID < 0) fScintCollID = SDman->    
 83   if (fPMTCollID < 0) fPMTCollID = SDman->GetC    
 84 }                                                 
 85                                                   
 86 //....oooOO0OOooo........oooOO0OOooo........oo    
 87                                                   
 88 void LXeEventAction::EndOfEventAction(const G4    
 89 {                                                 
 90   G4TrajectoryContainer* trajectoryContainer =    
 91                                                   
 92   G4int n_trajectories = 0;                       
 93   if (trajectoryContainer) n_trajectories = tr    
 94                                                   
 95   // extract the trajectories and draw them       
 96   if (G4VVisManager::GetConcreteInstance()) {     
 97     for (G4int i = 0; i < n_trajectories; ++i)    
 98       auto trj = (LXeTrajectory*)((*(anEvent->    
 99       if (trj->GetParticleName() == "opticalph    
100         trj->SetForceDrawTrajectory(fForcedraw    
101         trj->SetForceNoDrawTrajectory(fForceno    
102       }                                           
103       trj->DrawTrajectory();                      
104     }                                             
105   }                                               
106                                                   
107   LXeScintHitsCollection* scintHC = nullptr;      
108   LXePMTHitsCollection* pmtHC = nullptr;          
109   G4HCofThisEvent* hitsCE = anEvent->GetHCofTh    
110                                                   
111   // Get the hit collections                      
112   if (hitsCE) {                                   
113     if (fScintCollID >= 0) {                      
114       scintHC = (LXeScintHitsCollection*)(hits    
115     }                                             
116     if (fPMTCollID >= 0) {                        
117       pmtHC = (LXePMTHitsCollection*)(hitsCE->    
118     }                                             
119   }                                               
120                                                   
121   // Hits in scintillator                         
122   if (scintHC) {                                  
123     size_t n_hit = scintHC->entries();            
124     G4ThreeVector eWeightPos(0.);                 
125     G4double edep;                                
126     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                                                   
140     G4AnalysisManager::Instance()->FillH1(7, f    
141                                                   
142     if (fTotE == 0.) {                            
143       if (fVerbose > 0) G4cout << "No hits in     
144     }                                             
145     else {                                        
146       // Finish calculation of energy weighted    
147       eWeightPos /= fTotE;                        
148       fEWeightPos = eWeightPos;                   
149       if (fVerbose > 0) {                         
150         G4cout << "\tEnergy weighted position     
151       }                                           
152     }                                             
153     if (fVerbose > 0) {                           
154       G4cout << "\tTotal energy deposition in     
155     }                                             
156   }                                               
157                                                   
158   if (pmtHC) {                                    
159     G4ThreeVector reconPos(0., 0., 0.);           
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                                                   
186   G4AnalysisManager::Instance()->FillH1(3, fPh    
187   G4AnalysisManager::Instance()->FillH1(4, fPh    
188   G4AnalysisManager::Instance()->FillH1(5, fAb    
189   G4AnalysisManager::Instance()->FillH1(6, fBo    
190                                                   
191   if (fVerbose > 0) {                             
192     // End of event output. later to be contro    
193     G4cout << "\tNumber of photons that hit PM    
194     G4cout << "\tNumber of PMTs above threshol    
195            << G4endl;                             
196     G4cout << "\tNumber of photons produced by    
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                                                   
210   // update the run statistics                    
211   auto run = static_cast<LXeRun*>(G4RunManager    
212                                                   
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                                                   
221   // If we have set the flag to save 'special'    
222   if (fPhotonCount_Scint + fPhotonCount_Ceren     
223     G4RunManager::GetRunManager()->rndmSaveThi    
224   }                                               
225 }                                                 
226                                                   
227 //....oooOO0OOooo........oooOO0OOooo........oo    
228