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 #include "RunActionMessenger.hh"
35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "Run.hh"
38 
39 #include "G4UnitsTable.hh"
40 #include "G4SystemOfUnits.hh"
41 #include "G4ios.hh"
42 #include "Randomize.hh"
43 #include "G4ProductionCutsTable.hh"
44 
45 #include "G4EmCalculator.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50  :fDetector(det),fKinematic(kin)
51 {
52  fMessenger = new RunActionMessenger(this);
53  fBinLength = 5 * CLHEP::mm;
54  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
55  analysisManager->SetFileName("monopole");
56  analysisManager->SetVerboseLevel(1);
57  analysisManager->SetActivation(true);
58 }
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
61 
63 {
65 
66  delete fMessenger;
67 }
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
72 {
74  return fRun;
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
79 void RunAction::BeginOfRunAction(const G4Run* aRun)
80 {
81  // Dump production cuts
83 
84  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
85  //histograms
86  //
87  Book();
88 }
89 
90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
91 
93 {
94  // print Run summary
95  //
97 
98  // save histograms
99  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
100  if ( analysisManager->IsActive() ) {
101  analysisManager->Write();
102  analysisManager->CloseFile();
103  }
104 }
105 
106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
107 
109 {
110  fBinLength = size;
113  }
114 }
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117 
118 void RunAction::Book()
119 {
120  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
121  analysisManager->SetFirstHistoId(1);
122 
124  G4int nbBins = G4lrint(length / fBinLength);
125 
126  // Create histograms
127  analysisManager->CreateH1("h1","Edep (MeV/mm) along absorber (mm)",
128  nbBins, 0, length);
129  analysisManager->CreateH1("h2","Total DEDX (MeV/mm) of proton",100,-3.,7.);
130  analysisManager->CreateH1("h3","Total DEDX (MeV/mm) of monopole",100,-3., 7.);
131  analysisManager->CreateH1("h4","Range(mm) of proton", 100, -3., 7., "mm");
132  analysisManager->CreateH1("h5","Range(mm) of monopole", 100, -3., 7., "mm");
133  analysisManager->CreateH1("h6","Restricted DEDX (MeV/mm) of proton",
134  100,-3.,7.);
135  analysisManager->CreateH1("h7","Restricted DEDX (MeV/mm) of monopole",
136  100,-3., 7.);
137  analysisManager->CreateH1("h8","Delta-electron x-section (1/mm) of proton",
138  100, -3., 7., "mm");
139  analysisManager->CreateH1("h9","Delta-electron x-section (1/mm) of monopole",
140  100, -3., 7., "mm");
141  analysisManager->OpenFile();
142 }
143 
144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......