ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RunAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RunAction.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 //
28 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "RunAction.hh"
34 
35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "RunActionMessenger.hh"
38 #include "Run.hh"
39 #include "EmAcceptance.hh"
40 
41 #include "G4Run.hh"
42 #include "G4RunManager.hh"
43 #include "G4SystemOfUnits.hh"
44 
45 #include "Randomize.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50  :G4UserRunAction(),
51  fDet(det),fKin(kin),fAnalysisManager(nullptr),fRun(nullptr),
52  fVerbose(0), fEdeptrue(1.), fRmstrue(1.), fLimittrue(DBL_MAX)
53 {
55  fHistoName[0] = "testem2";
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62  delete fRunMessenger;
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 {
69  // Create analysis manager
70  // The choice of analysis technology is done via selection of a namespace
71  //
72 
74 
75  // Open an output file
76  //
78 
80 
82  G4String extension = fAnalysisManager->GetFileType();
83  fHistoName[1] = fHistoName[0] + "." + extension;
84 
85  // Creating histograms
86  //
88  G4int nLbin = fDet->GetnLtot();
89  G4int nRbin = fDet->GetnRtot();
90  G4double dLradl = fDet->GetdLradl();
91  G4double dRradl = fDet->GetdRradl();
92 
94  fAnalysisManager->CreateH1( "h1","total energy deposit(percent of Einc)",
95  110,0.,110.);
96 
97  fAnalysisManager->CreateH1( "h2","total charged tracklength (radl)",
98  110,0.,110.*Ekin/GeV);
99 
100  fAnalysisManager->CreateH1( "h3","total neutral tracklength (radl)",
101  110,0.,1100.*Ekin/GeV);
102 
103  fAnalysisManager->CreateH1( "h4","longit energy profile (% of E inc)",
104  nLbin,0.,nLbin*dLradl);
105 
106  fAnalysisManager->CreateP1( "p4","longit energy profile (% of E inc)",
107  nLbin,0.,nLbin*dLradl, 0., 1000.);
108 
109  fAnalysisManager->CreateH1( "h5","rms on longit Edep (% of E inc)",
110  nLbin,0.,nLbin*dLradl);
111 
112  G4double Zmin=0.5*dLradl, Zmax=Zmin+nLbin*dLradl;
113  fAnalysisManager->CreateH1( "h6","cumul longit energy dep (% of E inc)",
114  nLbin,Zmin,Zmax);
115 
116  fAnalysisManager->CreateH1( "h7","rms on cumul longit Edep (% of E inc)",
117  nLbin,Zmin,Zmax);
118 
119  fAnalysisManager->CreateH1( "h8","radial energy profile (% of E inc)",
120  nRbin,0.,nRbin*dRradl);
121 
122  fAnalysisManager->CreateP1( "p8","radial energy profile (% of E inc)",
123  nRbin,0.,nRbin*dRradl, 0., 1000.);
124 
125  fAnalysisManager->CreateH1( "h9","rms on radial Edep (% of E inc)",
126  nRbin,0.,nRbin*dRradl);
127 
128  G4double Rmin=0.5*dRradl, Rmax=Rmin+nRbin*dRradl;
129  fAnalysisManager->CreateH1("h10","cumul radial energy dep (% of E inc)",
130  nRbin,Rmin,Rmax);
131 
132  fAnalysisManager->CreateH1("h11","rms on cumul radial Edep (% of E inc)",
133  nRbin,Rmin,Rmax);
134 
135  G4cout << "\n----> Histogram file is opened in " << fHistoName[1] << G4endl;
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139 
141 {
142  fHistoName[0] = val;
143 }
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146 
148 {
149  fRun = new Run(fDet, fKin);
151  return fRun;
152 }
153 
154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
155 
157 {
158  // show Rndm status
159  if (isMaster) G4Random::showEngineStatus();
160 
161  //histograms
162  //
163  BookHisto();
164 }
165 
166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
167 
168 void RunAction::EndOfRunAction(const G4Run*)
169 {
170  //compute and print statistic
171  //
173 
174  // show Rndm status
175  if (isMaster) G4Random::showEngineStatus();
176 
177  // save histos and close analysis
180 }
181 
182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
183 
185 {
186  fEdeptrue = Value(0);
187  fRmstrue = Value(1);
188  fLimittrue= Value(2);
189 }
190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
191 
193 {
194  fVerbose = val;
195  if (fRun) fRun->SetVerbose(val);
196 }
197 
198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......