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 //
26 // This example is provided by the Geant4-DNA collaboration
27 // Any report or published results obtained using the Geant4-DNA software
28 // shall cite the following Geant4-DNA collaboration publications:
29 // Med. Phys. 45 (2018) e722-e739
30 // Phys. Med. 31 (2015) 861-874
31 // Med. Phys. 37 (2010) 4692-4708
32 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157\u2013178
33 //
34 // The Geant4-DNA web site is available at http://geant4-dna.org
35 //
38 
39 #include "RunAction.hh"
40 
41 #include "G4RunManager.hh"
42 #include "G4SystemOfUnits.hh"
43 
44 #include "Analysis.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
50 {
51  // book histograms, ntuple
52 
53  // create analysis manager
54  // the choice of analysis technology is done via selection of a namespace
55  // in Analysis.hh
56 
57  G4cout << "##### Create analysis manager " << " " << this << G4endl;
59 
60  analysisManager->SetNtupleMerging(true);
61 
62  G4cout << "Using " << analysisManager->GetType()
63  << " analysis manager"
64  << G4endl;
65 
66  // create directories
67 
68  analysisManager->SetVerboseLevel(1);
69 
70  // create ntuple
71 
72  analysisManager->CreateNtuple("t", "t-distribution");
73  analysisManager->CreateNtupleDColumn("radius1");
74  analysisManager->CreateNtupleIColumn("noRadius");
75  analysisManager->CreateNtupleDColumn("nbHits");
76  analysisManager->CreateNtupleDColumn("nbScoredHits");
77  analysisManager->CreateNtupleDColumn("edep");
78  analysisManager->CreateNtupleDColumn("radius2");
79  analysisManager->CreateNtupleDColumn("Einc");
80 
81  analysisManager->FinishNtuple();
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87 {
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 
94 {
95  // inform the runManager to save random number seed
97 
98  // open an output file
99  auto analysisManager = G4AnalysisManager::Instance();
100  G4String fileName = "t";
101  analysisManager->OpenFile(fileName);
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105 
106 void RunAction::EndOfRunAction(const G4Run* )
107 {
108  // print histogram statistics
109 
110  auto analysisManager = G4AnalysisManager::Instance();
111 
112  // save histograms
113 
114  analysisManager->Write();
115  analysisManager->CloseFile();
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......