ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GammaRayTelAnalysis.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GammaRayTelAnalysis.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // ------------------------------------------------------------
27 // GEANT 4 class implementation file
28 // CERN Geneva Switzerland
29 //
30 //
31 // ------------ GammaRayAnalysisManager ------
32 // by R.Giannitrapani, F.Longo & G.Santin (03 dic 2000)
33 //
34 // 03.04.2013 F.Longo/L.Pandola
35 // - migrated to G4tools
36 //
37 // 29.05.2003 F.Longo
38 // - anaphe 5.0.5 compliant
39 //
40 // 18.06.2002 R.Giannitrapani, F.Longo & G.Santin
41 // - new release for Anaphe 4.0.3
42 //
43 // 07.12.2001 A.Pfeiffer
44 // - integrated Guy's addition of the ntuple
45 //
46 // 06.12.2001 A.Pfeiffer
47 // - updating to new design (singleton)
48 //
49 // 22.11.2001 G.Barrand
50 // - Adaptation to AIDA
51 //
52 // ************************************************************
53 #include <fstream>
54 #include <iomanip>
55 
56 #include "G4RunManager.hh"
57 
58 #include "GammaRayTelAnalysis.hh"
61 
63 
64 //--------------------------------------------------------------------------------
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
66 
68  :GammaRayTelDetector(0),histo2DMode("strip")
69 {
71  static_cast<const GammaRayTelDetectorConstruction*>
73 
74  // Define the messenger and the analysis system
76  histoFileName = "gammaraytel";
77 }
78 
79 
81  Finish();
82  // Complete clean-up
84 }
85 
86 
88 {;}
89 
91 {
92  delete analysisMessenger;
94 }
95 
97 {
98  if (instance == 0) instance = new GammaRayTelAnalysis();
99  return instance;
100 }
101 
102 // This function fill the 2d histogram of the XZ positions
104 {
106  man->FillH2(1,x,z);
107 }
108 
109 // This function fill the 2d histogram of the YZ positions
111 {
113  man->FillH2(2,y,z);
114 }
115 
116 // This function fill the 1d histogram of the energy released in the last Si plane
118 {
120  man->FillH1(1,en);
121 }
122 
123 // This function fill the 1d histogram of the hits distribution along the TKR planes
125 {
127  man->FillH1(2,nplane);
128 }
129 
130 void GammaRayTelAnalysis::setNtuple(float E, float p, float x,
131  float y, float z)
132 {
134  man->FillNtupleDColumn(0,E);
135  man->FillNtupleDColumn(1,p);
136  man->FillNtupleDColumn(2,x);
137  man->FillNtupleDColumn(3,y);
138  man->FillNtupleDColumn(4,z);
139  man->AddNtupleRow();
140 }
141 
142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
143 /*
144  This member reset the histograms and it is called at the begin
145  of each run; here we put the inizialization so that the histograms have
146  always the right dimensions depending from the detector geometry
147 */
148 
150 {
152 
153  // Open an output file
154 
155  G4cout << "Opening output file " << histoFileName << " ... ";
156  man->OpenFile(histoFileName);
157  man->SetFirstHistoId(1);
158  G4cout << " done" << G4endl;
159 
160 
161  int Nplane = GammaRayTelDetector->GetNbOfTKRLayers();
162  int Nstrip = GammaRayTelDetector->GetNbOfTKRStrips();
163  int Ntile = GammaRayTelDetector->GetNbOfTKRTiles();
164  double sizexy = GammaRayTelDetector->GetTKRSizeXY();
165  double sizez = GammaRayTelDetector->GetTKRSizeZ();
166  int N = Nstrip*Ntile;
167 
168  // Book1D histograms
169  //------------------
170 
171  // 1D histogram that store the energy deposition of the
172  // particle in the last (number 0) TKR X-plane
173  man->CreateH1("1","Edep in the last X plane (keV)", 100, 50, 200);
174 
175  // 1D histogram that store the hits distribution along the TKR X-planes
176  man->CreateH1("2","Hits dist in TKR X planes",Nplane, 0, Nplane-1);
177 
178  // Book 2D histograms
179  //-------------------
180 
181  // 2D histogram that store the position (mm) of the hits (XZ projection)
182 
183  if (histo2DMode == "strip")
184  {
185  man->CreateH2("1","Tracker Hits XZ (strip,plane)",
186  N, 0, N-1,
187  2*Nplane, 0, Nplane-1);
188  }
189  else
190  {
191  man->CreateH2("1","Tracker Hits XZ (x,z) in mm",
192  int(sizexy/5), -sizexy/2, sizexy/2,
193  int(sizez/5), -sizez/2, sizez/2);
194  }
195 
196  // 2D histogram that store the position (mm) of the hits (YZ projection)
197  if (histo2DMode == "strip")
198  {
199  man->CreateH2("2","Tracker Hits YZ (strip,plane)",
200  N, 0, N-1,
201  2*Nplane, 0, Nplane-1);
202  }
203  else
204  {
205  man->CreateH2("2","Tracker Hits YZ (x,z) in mm",
206  int(sizexy/5), -sizexy/2, sizexy/2,
207  int(sizez/5), -sizez/2, sizez/2);
208  }
209 
210 
211  // Book Ntuples (energy / plane/ x / y / z)
212  //------------------------------------------
213  man->CreateNtuple("1","Track ntuple");
214  man->CreateNtupleDColumn("energy");
215  man->CreateNtupleDColumn("plane"); // can I use Int values?
216  man->CreateNtupleDColumn("x"); // can I use Int values?
217  man->CreateNtupleDColumn("y"); // can I use Int values?
218  man->CreateNtupleDColumn("z"); // can I use Int values?
219  man->FinishNtuple();
220 
221 }
222 
223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
224 
225 /*
226  This member is called at the end of each run
227 */
229 {
230  //Save histograms
232  man->Write();
233  man->CloseFile();
234 }
235 
236 /* This member is called at the end of every event */
237 
239 {;}
240 
241 
242 
243 
244 
245 
246