34 #include "HistoManager.hh"
39 #include "AIDA/AIDA.h"
45 :fAF(0),fTree(0), fNtuple1(0), fNtuple2(0)
50 fAF = AIDA_createAnalysisFactory();
52 G4cout <<
" HistoManager::HistoManager :"
53 <<
" problem creating the AIDA analysis factory."
87 fileName = fileName +
"." + fileType;
90 AIDA::ITreeFactory* tf = fAF->createTreeFactory();
91 fTree = tf->create(fileName, fileType, readOnly, createNew, fileOption);
94 G4cout <<
" HistoManager::book :"
95 <<
" problem creating the AIDA tree with "
96 <<
" storeName = " << fileName
97 <<
" storeType = " << fileType
98 <<
" readOnly = " << readOnly
99 <<
" createNew = " << createNew
100 <<
" options = " << fileOption
107 AIDA::IHistogramFactory*
hf = fAF->createHistogramFactory(*fTree);
111 fTree->mkdir(
"histograms");
112 fTree->cd(
"histograms");
114 fHisto[1] = hf->createHistogram1D(
"1",
"Edep in absorber", 100, 0., 800*
MeV);
115 if (!fHisto[1])
G4cout <<
"\n can't create histo 1" <<
G4endl;
116 fHisto[2] = hf->createHistogram1D(
"2",
"Edep in gap", 100, 0., 100*
MeV);
117 if (!fHisto[2])
G4cout <<
"\n can't create histo 2" <<
G4endl;
118 fHisto[3] = hf->createHistogram1D(
"3",
"trackL in absorber", 100, 0., 1*
m);
119 if (!fHisto[3])
G4cout <<
"\n can't create histo 3" <<
G4endl;
120 fHisto[4] = hf->createHistogram1D(
"4",
"trackL in gap", 100, 0., 50*
cm);
121 if (!fHisto[4])
G4cout <<
"\n can't create histo 4" <<
G4endl;
128 AIDA::ITupleFactory* ntf = fAF->createTupleFactory(*fTree);
132 fTree->mkdir(
"tuples");
135 fNtuple1 = ntf->create(
"101",
"Edep",
"double Eabs, Egap");
136 fNtuple2 = ntf->create(
"102",
"TrackL",
"double Labs, Lgap");
141 G4cout <<
"\n----> Histogram Tree is opened in " << fileName <<
G4endl;
149 #ifdef G4ANALYSIS_USE
153 G4cout <<
"\n----> Histogram Tree is saved \n" <<
G4endl;
166 G4cout <<
"---> warning from HistoManager::FillHisto() : histo " << ih
167 <<
" does not exist. (xbin=" << xbin <<
" weight=" << weight <<
")"
171 #ifdef G4ANALYSIS_USE
172 if (fHisto[ih]) fHisto[ih]->fill(xbin, weight);
181 G4cout <<
"---> warning from HistoManager::Normalize() : histo " << ih
182 <<
" does not exist. (fac=" << fac <<
")" <<
G4endl;
185 #ifdef G4ANALYSIS_USE
186 if (fHisto[ih]) fHisto[ih]->scale(fac);
192 #ifdef G4ANALYSIS_USE
197 fNtuple1->fill(0, energyAbs);
198 fNtuple1->fill(1, energyGap);
202 fNtuple2->fill(0, trackLAbs);
203 fNtuple2->fill(1, trackLGap);
216 #ifdef G4ANALYSIS_USE
218 G4cout <<
"\n ----> print histograms statistic \n" <<
G4endl;
221 <<
" EAbs : mean = " <<
G4BestUnit(fHisto[1]->mean(),
"Energy")
224 <<
" EGap : mean = " <<
G4BestUnit(fHisto[2]->mean(),
"Energy")
227 <<
" LAbs : mean = " <<
G4BestUnit(fHisto[3]->mean(),
"Length")
230 <<
" LGap : mean = " <<
G4BestUnit(fHisto[4]->mean(),
"Length")
void FillNtuple(G4int id, G4int column, G4double value)
void FillHisto(G4int id, G4double bin, G4double weight=1.0)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void Normalize(G4int id, G4double fac)
G4GLOB_DLL std::ostream G4cout