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10.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/advanced/HGCal_testbeam/src/EventAction.cc (Version 11.3.0) and /examples/advanced/HGCal_testbeam/src/EventAction.cc (Version 10.1)


  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 #include "EventAction.hh"                         
 27                                                   
 28 #include "SiPMHit.hh"                             
 29 #include "SiliconPixelHit.hh"                     
 30                                                   
 31 #include "G4Event.hh"                             
 32 #include "G4SDManager.hh"                         
 33 #include "G4GenericMessenger.hh"                  
 34 #include "G4AnalysisManager.hh"                   
 35                                                   
 36 //....oooOO0OOooo........oooOO0OOooo........oo    
 37                                                   
 38 EventAction::EventAction() : G4UserEventAction    
 39                                                   
 40 //....oooOO0OOooo........oooOO0OOooo........oo    
 41                                                   
 42 EventAction::~EventAction() {}                    
 43                                                   
 44 //....oooOO0OOooo........oooOO0OOooo........oo    
 45                                                   
 46 void EventAction::BeginOfEventAction(const G4E    
 47   fPrimariesPDG.clear();                          
 48   fPrimariesEnergy.clear();                       
 49   fPrimariesX.clear();                            
 50   fPrimariesY.clear();                            
 51   fPrimariesZ.clear();                            
 52                                                   
 53   fSiHitsID.clear();                              
 54   fSiHitsX.clear();                               
 55   fSiHitsY.clear();                               
 56   fSiHitsZ.clear();                               
 57   fSiHitsEdep.clear();                            
 58   fSiHitsEdepNonIonising.clear();                 
 59   fSiHitsTOA.clear();                             
 60   fSiHitsTOAlast.clear();                         
 61   fSiHitsType.clear();                            
 62                                                   
 63   fSiPMhitsID.clear();                            
 64   fSiPMhitsX.clear();                             
 65   fSiPMhitsY.clear();                             
 66   fSiPMhitsZ.clear();                             
 67   fSiPMhitsEdep.clear();                          
 68   fSiPMhitsEdepNonIonising.clear();               
 69   fSiPMhitsTOA.clear();                           
 70   fSiPMhitsType.clear();                          
 71 }                                                 
 72                                                   
 73 //....oooOO0OOooo........oooOO0OOooo........oo    
 74                                                   
 75 void EventAction::EndOfEventAction(const G4Eve    
 76   // sanity check                                 
 77   if (event->GetNumberOfPrimaryVertex() == 0)     
 78     return;                                       
 79                                                   
 80   auto analysisManager = G4AnalysisManager::In    
 81   analysisManager->FillNtupleIColumn(0, event-    
 82   // fill for all primary input particles         
 83   for (G4int iVertex = 0; iVertex < event->Get    
 84        iVertex++) {                               
 85     auto vertex = event->GetPrimaryVertex(iVer    
 86     fPrimariesX.push_back(vertex->GetX0() / CL    
 87     fPrimariesY.push_back(vertex->GetY0() / CL    
 88     fPrimariesZ.push_back(vertex->GetZ0() / CL    
 89     for (G4int iParticle = 0; iParticle < vert    
 90          iParticle++) {                           
 91       auto particle = vertex->GetPrimary(iPart    
 92       fPrimariesPDG.push_back(particle->GetPDG    
 93       fPrimariesEnergy.push_back(particle->Get    
 94     }                                             
 95   }                                               
 96                                                   
 97   auto hce = event->GetHCofThisEvent();           
 98   auto sdManager = G4SDManager::GetSDMpointer(    
 99   G4int collId;                                   
100                                                   
101   // HGCAL EE + FH                                
102   collId = sdManager->GetCollectionID("Silicon    
103   auto hc = hce->GetHC(collId);                   
104   if (!hc)                                        
105     return;                                       
106   double esumHGCAL = 0;                           
107   double cogzHGCAL = 0;                           
108   int NhitsHGCAL = 0;                             
109   for (unsigned int i = 0; i < hc->GetSize();     
110     auto hit = static_cast<SiliconPixelHit *>(    
111     hit->Digitise(fHitTimeCut / CLHEP::ns, fTo    
112                                                   
113     if (hit->isValidHit()) {                      
114       fSiHitsID.push_back(hit->ID());             
115       fSiHitsX.push_back(hit->GetX());            
116       fSiHitsY.push_back(hit->GetY());            
117       fSiHitsZ.push_back(hit->GetZ());            
118       fSiHitsEdep.push_back(hit->GetEdep());      
119       fSiHitsEdepNonIonising.push_back(hit->Ge    
120       fSiHitsTOA.push_back(hit->GetTOA());        
121       fSiHitsTOAlast.push_back(hit->GetLastTOA    
122       fSiHitsType.push_back(0);                   
123                                                   
124       NhitsHGCAL++;                               
125       esumHGCAL += hit->GetEdep() * CLHEP::keV    
126       cogzHGCAL += hit->GetZ() * hit->GetEdep(    
127     }                                             
128   }                                               
129   if (esumHGCAL > 0)                              
130     cogzHGCAL /= esumHGCAL;                       
131                                                   
132   analysisManager->FillNtupleDColumn(23, esumH    
133   analysisManager->FillNtupleDColumn(24, cogzH    
134   analysisManager->FillNtupleIColumn(25, Nhits    
135                                                   
136   // AHCAL                                        
137   collId = sdManager->GetCollectionID("SiPMHit    
138   hc = hce->GetHC(collId);                        
139   if (!hc)                                        
140     return;                                       
141   double esumAHCAL = 0;                           
142   double cogzAHCAL = 0;                           
143   int NhitsAHCAL = 0;                             
144   for (unsigned int i = 0; i < hc->GetSize();     
145     auto hit = static_cast<SiPMHit *>(hc->GetH    
146     hit->Digitise(-1, 0);                         
147                                                   
148     if (hit->isValidHit()) {                      
149       fSiPMhitsID.push_back(hit->ID());           
150       fSiPMhitsX.push_back(hit->GetX());          
151       fSiPMhitsY.push_back(hit->GetY());          
152       fSiPMhitsZ.push_back(hit->GetZ());          
153       fSiPMhitsEdep.push_back(hit->GetEdep());    
154       fSiPMhitsEdepNonIonising.push_back(hit->    
155       fSiPMhitsTOA.push_back(hit->GetTOA());      
156       fSiPMhitsType.push_back(1);                 
157                                                   
158       NhitsAHCAL++;                               
159       esumAHCAL += hit->GetEdep() * CLHEP::keV    
160       cogzAHCAL += hit->GetZ() * hit->GetEdep(    
161     }                                             
162   }                                               
163   if (esumAHCAL > 0)                              
164     cogzAHCAL /= esumAHCAL;                       
165                                                   
166   analysisManager->FillNtupleDColumn(26, esumA    
167   analysisManager->FillNtupleDColumn(27, cogzA    
168   analysisManager->FillNtupleIColumn(28, Nhits    
169                                                   
170   analysisManager->AddNtupleRow();                
171 }                                                 
172                                                   
173 //....oooOO0OOooo........oooOO0OOooo........oo    
174                                                   
175 void EventAction::DefineCommands() {              
176                                                   
177   fMessenger = new G4GenericMessenger(this, "/    
178                                       "Primary    
179                                                   
180   // time cut command                             
181   auto &timeCutCmd = fMessenger->DeclareProper    
182       "timeCut", "ns", fHitTimeCut,               
183       "Size of time window for hit digitalisat    
184   timeCutCmd.SetParameterName("timeCut", true)    
185   timeCutCmd.SetRange("timeCut>=-1");             
186   timeCutCmd.SetDefaultValue("-1");               
187                                                   
188   // toa threshold command                        
189   auto &toaThresholdCmd = fMessenger->DeclareP    
190       "toaThreshold", "keV", fToaThreshold, "T    
191   toaThresholdCmd.SetParameterName("toaThresho    
192   toaThresholdCmd.SetRange("toaThreshold>=0");    
193   toaThresholdCmd.SetDefaultValue("0");           
194 }                                                 
195                                                   
196 //....oooOO0OOooo........oooOO0OOooo........oo    
197