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 | // * * |
---|
28 | // * cosmicray_charging advanced example for Geant4 * |
---|
29 | // * (adapted simulation of test-mass charging in the LISA mission) * |
---|
30 | // * * |
---|
31 | // * Henrique Araujo (h.araujo@imperial.ac.uk) & Peter Wass * |
---|
32 | // * Imperial College London * |
---|
33 | // * * |
---|
34 | // * LISAAnalysisManager class * |
---|
35 | // * * |
---|
36 | // ******************************************************************** |
---|
37 | // |
---|
38 | // HISTORY |
---|
39 | // 22/02/2004: migrated from LISA-V04 |
---|
40 | // |
---|
41 | // ******************************************************************** |
---|
42 | |
---|
43 | |
---|
44 | #ifdef G4ANALYSIS_USE |
---|
45 | |
---|
46 | #include "LISAAnalysisManager.hh" |
---|
47 | #include "globals.hh" |
---|
48 | |
---|
49 | LISAAnalysisManager* LISAAnalysisManager::instance = 0; |
---|
50 | |
---|
51 | |
---|
52 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
53 | |
---|
54 | LISAAnalysisManager::LISAAnalysisManager() : |
---|
55 | af(0), |
---|
56 | tf(0), |
---|
57 | run_tree(0), |
---|
58 | run_tpf(0), |
---|
59 | run_tuple(0) |
---|
60 | {;} |
---|
61 | |
---|
62 | |
---|
63 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
64 | |
---|
65 | LISAAnalysisManager::~LISAAnalysisManager() { |
---|
66 | |
---|
67 | if(af) { |
---|
68 | delete tf; |
---|
69 | G4cout << " LISAAnalysis -- deleted tree factory" << G4endl; |
---|
70 | delete af; |
---|
71 | G4cout << " LISAAnalysis -- deleted analysis factory" << G4endl; |
---|
72 | } |
---|
73 | |
---|
74 | } |
---|
75 | |
---|
76 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
77 | LISAAnalysisManager* LISAAnalysisManager::getInstance() { |
---|
78 | |
---|
79 | if (!instance) instance = new LISAAnalysisManager(); |
---|
80 | return instance; |
---|
81 | |
---|
82 | } |
---|
83 | |
---|
84 | |
---|
85 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
86 | void LISAAnalysisManager::Dispose() { |
---|
87 | |
---|
88 | if(instance) { |
---|
89 | delete instance; |
---|
90 | instance = 0; |
---|
91 | } |
---|
92 | } |
---|
93 | |
---|
94 | |
---|
95 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
96 | void LISAAnalysisManager::Init() { |
---|
97 | |
---|
98 | G4cout << G4endl << "******* Analysis with AIDA 3.0 *********" << G4endl; |
---|
99 | |
---|
100 | // create analysis factory |
---|
101 | if( (af = AIDA_createAnalysisFactory()) ) |
---|
102 | G4cout << " LISAAnalysis -- created analysis factory" << G4endl; |
---|
103 | |
---|
104 | // create tree factory |
---|
105 | if( (tf = af->createTreeFactory()) ) |
---|
106 | G4cout << " LISAAnalysis -- created tree factory" << G4endl; |
---|
107 | |
---|
108 | } |
---|
109 | |
---|
110 | |
---|
111 | |
---|
112 | |
---|
113 | // |
---|
114 | // RUN ANALYSIS ************************************************************** |
---|
115 | // |
---|
116 | |
---|
117 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
118 | void LISAAnalysisManager::bookRun(G4String hbookfile) { |
---|
119 | |
---|
120 | |
---|
121 | // create RunTree |
---|
122 | G4bool fileExists = false; |
---|
123 | G4bool readOnly = false; |
---|
124 | run_tree = tf->create(hbookfile, "hbook", readOnly, fileExists); |
---|
125 | G4cout << " LISAAnalysis -- tree store: " << run_tree->storeName()<<G4endl; |
---|
126 | |
---|
127 | // create TupleFactory |
---|
128 | run_tpf = af->createTupleFactory(*run_tree ); |
---|
129 | G4cout << " LISAAnalysis -- created NTuple factory" << G4endl; |
---|
130 | |
---|
131 | // Run Information |
---|
132 | run_tuple = run_tpf->create( "1", "Run Tuple", |
---|
133 | "float evt,tm,energy,charge,in,out,seed1,seed2"); |
---|
134 | assert(run_tuple); |
---|
135 | G4cout << " LISAAnalysis -- created Run NTuple" << G4endl; |
---|
136 | |
---|
137 | |
---|
138 | } |
---|
139 | |
---|
140 | |
---|
141 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
142 | void LISAAnalysisManager::FinishRun() { |
---|
143 | |
---|
144 | // Committing transaction with the tree |
---|
145 | G4cout << " LISAAnalysis -- committing run_tree..." << G4endl; |
---|
146 | run_tree->commit(); |
---|
147 | run_tree->close(); |
---|
148 | |
---|
149 | delete run_tpf; |
---|
150 | delete run_tree; |
---|
151 | } |
---|
152 | |
---|
153 | |
---|
154 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
155 | void LISAAnalysisManager::analyseRun(G4int evt, G4int tm, G4double energy, |
---|
156 | G4int charge, G4int in, G4int out, long seed1, long seed2) { |
---|
157 | |
---|
158 | AIDA::ITuple* ntuple = dynamic_cast<AIDA::ITuple *> ( run_tree->find("1") ); |
---|
159 | |
---|
160 | // Fill the ntuple |
---|
161 | ntuple->fill( ntuple->findColumn( "evt" ), (float) evt ); |
---|
162 | ntuple->fill( ntuple->findColumn( "tm" ), (float) tm ); |
---|
163 | ntuple->fill( ntuple->findColumn( "energy" ), (float) energy ); |
---|
164 | ntuple->fill( ntuple->findColumn( "charge" ), (float) charge ); |
---|
165 | ntuple->fill( ntuple->findColumn( "in" ), (float) in ); |
---|
166 | ntuple->fill( ntuple->findColumn( "out" ), (float) out ); |
---|
167 | ntuple->fill( ntuple->findColumn( "seed1" ), (float) seed1 ); |
---|
168 | ntuple->fill( ntuple->findColumn( "seed2" ), (float) seed2 ); |
---|
169 | |
---|
170 | // Values of attributes are prepared; store them to the nTuple: |
---|
171 | ntuple->addRow(); |
---|
172 | |
---|
173 | } |
---|
174 | |
---|
175 | |
---|
176 | #endif |
---|