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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 7.1)


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