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3 ] [ 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/gammaray_telescope/src/GammaRayTelAnalysis.cc (Version 11.3.0) and /examples/advanced/gammaray_telescope/src/GammaRayTelAnalysis.cc (Version 5.0)


  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 // -------------------------------------------    
 28 //      GEANT 4 class implementation file         
 29 //      CERN Geneva Switzerland                   
 30 //                                                
 31 //                                                
 32 //      ------------ GammaRayAnalysisManager      
 33 //           by R.Giannitrapani, F.Longo & G.S    
 34 //                                                
 35 // 03.04.2013 F.Longo/L.Pandola                   
 36 // - migrated to G4tools                          
 37 //                                                
 38 // 29.05.2003 F.Longo                             
 39 // - Anaphe 5.0.5 compliant                       
 40 //                                                
 41 // 18.06.2002 R.Giannitrapani, F.Longo & G.San    
 42 // - new release for Anaphe 4.0.3                 
 43 //                                                
 44 // 07.12.2001 A.Pfeiffer                          
 45 // - integrated Guy's addition of the ntuple      
 46 //                                                
 47 // 06.12.2001 A.Pfeiffer                          
 48 // - updating to new design (singleton)           
 49 //                                                
 50 // 22.11.2001 G.Barrand                           
 51 // - Adaptation to AIDA                           
 52 //                                                
 53 // *******************************************    
 54                                                   
 55 #include <fstream>                                
 56 #include <iomanip>                                
 57                                                   
 58 #include "GammaRayTelAnalysis.hh"                 
 59 #include "GammaRayTelAnalysisMessenger.hh"        
 60 #include "GammaRayTelDetectorConstruction.hh"     
 61                                                   
 62 #include "G4RunManager.hh"                        
 63                                                   
 64 //....oooOO0OOooo........oooOO0OOooo........oo    
 65                                                   
 66 GammaRayTelAnalysis *GammaRayTelAnalysis::inst    
 67                                                   
 68 //....oooOO0OOooo........oooOO0OOooo........oo    
 69                                                   
 70 GammaRayTelAnalysis::GammaRayTelAnalysis() : d    
 71     detector = static_cast<const GammaRayTelDe    
 72                                                   
 73     // Define the messenger and the analysis s    
 74     analysisMessenger = new GammaRayTelAnalysi    
 75     histogramFileName = "gammaraytel";            
 76 }                                                 
 77                                                   
 78 //....oooOO0OOooo........oooOO0OOooo........oo    
 79                                                   
 80 GammaRayTelAnalysis::~GammaRayTelAnalysis() {     
 81     Finish();                                     
 82 }                                                 
 83                                                   
 84 //....oooOO0OOooo........oooOO0OOooo........oo    
 85                                                   
 86 void GammaRayTelAnalysis::Init() {                
 87 }                                                 
 88                                                   
 89 //....oooOO0OOooo........oooOO0OOooo........oo    
 90                                                   
 91 void GammaRayTelAnalysis::Finish() {              
 92     delete analysisMessenger;                     
 93     analysisMessenger = nullptr;                  
 94 }                                                 
 95                                                   
 96 //....oooOO0OOooo........oooOO0OOooo........oo    
 97                                                   
 98 auto GammaRayTelAnalysis::getInstance() -> Gam    
 99   if (instance == nullptr) {                      
100     instance = new GammaRayTelAnalysis();         
101   }                                               
102   return instance;                                
103 }                                                 
104                                                   
105 //....oooOO0OOooo........oooOO0OOooo........oo    
106                                                   
107 // This function fill the 2d histogram of the     
108 void GammaRayTelAnalysis::InsertPositionXZ(G4d    
109   auto *manager = G4AnalysisManager::Instance(    
110   manager->FillH2(1, x, z);                       
111 }                                                 
112                                                   
113 //....oooOO0OOooo........oooOO0OOooo........oo    
114                                                   
115 // This function fill the 2d histogram of the     
116 void GammaRayTelAnalysis::InsertPositionYZ(G4d    
117   auto *manager = G4AnalysisManager::Instance(    
118   manager->FillH2(2, y, z);                       
119 }                                                 
120                                                   
121 //....oooOO0OOooo........oooOO0OOooo........oo    
122                                                   
123 // This function fill the 1d histogram of the     
124 void GammaRayTelAnalysis::InsertEnergy(G4doubl    
125   auto *manager = G4AnalysisManager::Instance(    
126   manager->FillH1(1, energy);                     
127 }                                                 
128                                                   
129 //....oooOO0OOooo........oooOO0OOooo........oo    
130                                                   
131 // This function fill the 1d histogram of the     
132 void GammaRayTelAnalysis::InsertHits(G4int pla    
133   auto *manager = G4AnalysisManager::Instance(    
134   manager->FillH1(2, planeNumber);                
135 }                                                 
136                                                   
137 //....oooOO0OOooo........oooOO0OOooo........oo    
138                                                   
139 void GammaRayTelAnalysis::setNtuple(G4double e    
140   auto *manager = G4AnalysisManager::Instance(    
141   manager->FillNtupleDColumn(0, energy);          
142   manager->FillNtupleDColumn(1, planeNumber);     
143   manager->FillNtupleDColumn(2, x);               
144   manager->FillNtupleDColumn(3, y);               
145   manager->FillNtupleDColumn(4, z);               
146   manager->AddNtupleRow();                        
147 }                                                 
148                                                   
149 //....oooOO0OOooo........oooOO0OOooo........oo    
150                                                   
151 /*                                                
152  This member reset the histograms and it is ca    
153  here we put the inizialization so that the hi    
154  always the right dimensions depending from th    
155  */                                               
156 void GammaRayTelAnalysis::BeginOfRun() {          
157   auto *manager = G4AnalysisManager::Instance(    
158   manager->SetDefaultFileType("root");            
159                                                   
160   // Open an output file                          
161                                                   
162   G4cout << "Opening output file " << histogra    
163   manager->OpenFile(histogramFileName);           
164   manager->SetFirstHistoId(1);                    
165   G4cout << " done" << G4endl;                    
166                                                   
167   auto Nplane = detector->GetNbOfTKRLayers();     
168   auto numberOfStrips = detector->GetNbOfTKRSt    
169   auto numberOfTiles = detector->GetNbOfTKRTil    
170   auto sizeXY = detector->GetTKRSizeXY();         
171   auto sizeZ = detector->GetTKRSizeZ();           
172   auto N = numberOfStrips * numberOfTiles;        
173                                                   
174   // Book 1D histograms                           
175   //-------------------                           
176                                                   
177   constexpr auto NUMBER_OF_BINS{100};             
178   constexpr auto LOWER_BOUND{50};                 
179   constexpr auto UPPER_BOUND{200};                
180                                                   
181   // 1D histogram that store the energy deposi    
182   manager->CreateH1("1", "Deposited energy in     
183                                                   
184   // 1D histogram that store the hits distribu    
185   manager->CreateH1("2", "Hits distribution in    
186                                                   
187   // Book 2D histograms                           
188   //-------------------                           
189                                                   
190   // 2D histogram that store the position (mm)    
191                                                   
192     if (histo2DMode == "strip") {                 
193         manager->CreateH2("1", "Tracker hits X    
194     } else {                                      
195         manager->CreateH2("1", "Tracker hits X    
196     }                                             
197                                                   
198     // 2D histogram that store the position (m    
199     if (histo2DMode == "strip") {                 
200         manager->CreateH2("2", "Tracker hits Y    
201     } else {                                      
202         manager->CreateH2("2", "Tracker hits Y    
203     }                                             
204                                                   
205   // Book n-tuple (energy, plane, x, y, z)        
206   //------------------------------------------    
207   manager->CreateNtuple("1", "Track n-tuple");    
208   manager->CreateNtupleDColumn("energy");         
209   manager->CreateNtupleDColumn("plane");          
210   manager->CreateNtupleDColumn("x");              
211   manager->CreateNtupleDColumn("y");              
212   manager->CreateNtupleDColumn("z");              
213   manager->FinishNtuple();                        
214 }                                                 
215                                                   
216 /*                                                
217  This member is called at the end of each run     
218  */                                               
219 void GammaRayTelAnalysis::EndOfRun() {            
220   // Save histograms                              
221   auto *manager = G4AnalysisManager::Instance(    
222   manager->Write();                               
223   manager->CloseFile();                           
224 }                                                 
225                                                   
226 //....oooOO0OOooo........oooOO0OOooo........oo    
227                                                   
228 // This member is called at the end of every e    
229 void GammaRayTelAnalysis::EndOfEvent(G4int /*     
230 }                                                 
231