source: trunk/examples/advanced/lAr_calorimeter/src/FCALAnalysisManager.cc@ 809

Last change on this file since 809 was 807, checked in by garnier, 17 years ago

update

File size: 5.6 KB
Line 
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// $Id: FCALAnalysisManager.cc
27// Author: Patricia Mendez (patricia.mendez@cern.ch)
28//
29// History:
30// -----------
31// 12 Feb 2003 Patricia Mendez Created
32// -------------------------------------------------------------------
33#include <stdlib.h>
34#include "G4VProcess.hh"
35#include <fstream>
36#include "G4ios.hh"
37#include "G4UnitsTable.hh"
38#ifdef G4ANALYSIS_USE
39#include "AIDA/AIDA.h"
40#include "FCALAnalysisManager.hh"
41#include "FCALAnalysisMessenger.hh"
42
43
44#include "G4Step.hh"
45
46FCALAnalysisManager* FCALAnalysisManager::instance = 0;
47
48//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
49
50FCALAnalysisManager::FCALAnalysisManager()
51 :outputFileName("fcal.his"),analysisFactory(0), tree(0),histogramFactory(0)
52 // OutOfWorld(0), Secondary(0), EmEdep(0), HadEdep(0)
53{
54
55 analisysMessenger = new FCALAnalysisMessenger(this);
56
57 // Hooking an AIDA compliant analysis system.
58 analysisFactory = AIDA_createAnalysisFactory();
59 if(analysisFactory) {
60
61 AIDA::ITreeFactory* treeFactory = analysisFactory->createTreeFactory();
62 if(treeFactory) {
63 // tree = treeFactory->create(); // Tree in memory.
64 //porebbe essere qua il memory leak//
65
66 tree = treeFactory->create(outputFileName,"hbook",false,true);
67
68 delete treeFactory; // Will not delete the ITree.
69 histogramFactory = analysisFactory->createHistogramFactory(*tree);
70 tupleFactory = analysisFactory->createTupleFactory(*tree);
71 }
72 }
73
74 G4cout << "FCALAnalysisManager created" << G4endl;
75
76}
77
78//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
79
80FCALAnalysisManager::~FCALAnalysisManager()
81{
82 delete histogramFactory;
83 histogramFactory=0;
84
85 delete analysisFactory;
86 analysisFactory = 0;
87
88 delete tupleFactory;
89 tupleFactory=0;
90
91 delete instance;
92
93 G4cout << "FCALAnalysisManager delete" << G4endl;
94
95}
96
97//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
98
99FCALAnalysisManager* FCALAnalysisManager::getInstance()
100
101{
102 if (instance == 0) {instance = new FCALAnalysisManager;}
103 return instance;
104}
105
106//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
107
108void FCALAnalysisManager::book()
109{
110 // Book histograms
111
112 histo_1 = histogramFactory->createHistogram1D("1","Number of Out Of World", 100,0.,10.);
113 histo_2 = histogramFactory->createHistogram1D("2","Number of Secondaries", 100,0.,100.);
114 histo_3 = histogramFactory->createHistogram1D("3","Electromagnetic Energy/MeV", 100,0.,100.);
115 histo_4 = histogramFactory->createHistogram1D("4","hadronic Energy/MeV", 100,10.,60.);
116
117 // Create a tuple
118
119 // tuple = tupleFactory->create("FCAL","FCAL","energy counts");
120
121 // ntuple_1 = tupleFactory->create("100","Number Out of World","float OutOfWorld, i, j");
122
123 // ntuple_2 = tupleFactory->create("200","Secondary Info","float Secondary, i, j");
124
125 // ntuple_3 = tupleFactory->create("300","Energy Deposits","float EmEdep, HadEdep");
126}
127
128//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
129
130void FCALAnalysisManager::finish()
131{
132
133 if(tree) {
134 tree->commit(); // Write histos and tuple in file.
135 tree->close();
136 }
137
138}
139
140////....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
141//
142//void FCALAnalysisManager::analyseEnergyDep(G4double Edep)
143//void FCALAnalysisManager::analyseEnergyDep(G4double HadEdep)
144//{
145//
146//
147// histo_1->fill(OutOfWorld);
148// histo_2->fill(Secondary);
149// histo_3->fill(EmEdep);
150// histo_4->fill(HadEdep);
151//
152//
153//
154//
155// if(ntuple_1) {
156// ntuple_1->fill(0,OutOfWorld);
157// ntuple_1->fill(1,1);
158// ntuple_1->addRow();
159// }
160//
161// if(ntuple_2) {
162// ntuple_2->fill(0,Secondary);
163// ntuple_2->fill(1,1);
164// ntuple_2->addRow();
165// }
166//
167// if(ntuple_3) {
168// ntuple_3->fill(0,EmEdep);
169// ntuple_3->fill(1,1);
170// ntuple_3->addRow();
171// }
172//
173//
174//}
175
176//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
177
178void FCALAnalysisManager::SetOutputFileName(G4String newName)
179{
180
181 outputFileName = newName;
182
183}
184
185#endif
186
187
188
189
190
191
192
193
194
195
Note: See TracBrowser for help on using the repository browser.