31 #include "HistoManager.hh"
32 #include "HistoMessenger.hh"
36 #include "AIDA/AIDA.h"
42 :factoryOn(false),af(0),
tree(0)
46 af = AIDA_createAnalysisFactory();
48 G4cout <<
" HistoManager::HistoManager :"
49 <<
" problem creating the AIDA analysis factory."
56 fileOption =
"export=root";
80 delete histoMessenger;
95 fileName[1] = fileName[0] +
"." + fileType;
98 AIDA::ITreeFactory* tf = af->createTreeFactory();
99 tree = tf->create(fileName[1], fileType, readOnly, createNew, fileOption);
102 G4cout <<
" HistoManager::book :"
103 <<
" problem creating the AIDA tree with "
104 <<
" storeName = " << fileName[1]
105 <<
" storeType = " << fileType
106 <<
" readOnly = " << readOnly
107 <<
" createNew = " << createNew
108 <<
" options = " << fileOption
114 AIDA::IHistogramFactory*
hf = af->createHistogramFactory(*tree);
119 histo[k] = hf->createHistogram1D( Label[k], Title[k],
120 Nbins[k], Vmin[k], Vmax[k]);
127 AIDA::ITupleFactory* ntf = af->createTupleFactory(*tree);
132 ntupl[k] = ntf->create( LabelNt[k], TitleNt[k], ColumnNt[k]);
140 G4cout <<
"\n----> Histogram Tree is opened in " << fileName[1] <<
G4endl;
148 #ifdef G4ANALYSIS_USE
153 G4cout <<
"\n----> Histogram Tree is saved in " << fileName[1] <<
G4endl;
167 G4cout <<
"---> warning from HistoManager::FillHisto() : histo " << ih
168 <<
" xbin= " << xbin <<
" weight= " << weight <<
G4endl;
171 #ifdef G4ANALYSIS_USE
172 if(exist[ih]) histo[ih]->fill(xbin/Unit[ih], weight);
182 G4cout <<
"---> warning from HistoManager::SetHisto() : histo " << ih
183 <<
"does not exist" <<
G4endl;
187 const G4String id[] = {
"0",
"1",
"2",
"3",
"4",
"5" };
190 "total Evis in Ecal",
191 "total Edep in Ecal",
194 "Nb of Radiation Length"
198 G4double vmin = valmin, vmax = valmax;
201 if (unit !=
"none") {
202 titl = title[ih] +
" (" + unit +
")";
204 vmin = valmin/Unit[ih]; vmax = valmax/Unit[ih];
213 Width[ih] = (valmax-valmin)/nbins;
215 G4cout <<
"----> SetHisto " << ih <<
": " << titl <<
"; "
216 << nbins <<
" bins from "
217 << vmin <<
" " << unit <<
" to " << vmax <<
" " << unit <<
G4endl;
226 G4cout <<
"---> warning from HistoManager::Normalize() : histo " << ih
227 <<
" fac= " << fac <<
G4endl;
230 #ifdef G4ANALYSIS_USE
231 if(exist[ih]) histo[ih]->scale(fac);
240 G4cout <<
"---> warning from HistoManager::RemoveHisto() : histo " << ih
241 <<
"does not exist" <<
G4endl;
245 histo[ih] = 0; exist[ih] =
false;
252 if (ih <
MaxHisto) { ascii[ih] =
true; ascii[0] =
true; }
254 G4cout <<
"---> warning from HistoManager::PrintHisto() : histo " << ih
255 <<
"does not exist" <<
G4endl;
262 void HistoManager::saveAscii()
264 #ifdef G4ANALYSIS_USE
266 if (!ascii[0])
return;
269 std::ofstream File(name, std::ios::out);
270 File.setf( std::ios::scientific, std::ios::floatfield );
274 if (exist[ih] && ascii[ih]) {
275 File <<
"\n 1D histogram " << ih <<
": " << Title[ih]
276 <<
"\n \n \t X \t\t Y" <<
G4endl;
278 for (
G4int iBin=0; iBin<Nbins[ih]; iBin++) {
279 File <<
" " << iBin <<
"\t"
280 << 0.5*(histo[ih]->axis().binLowerEdge(iBin) +
281 histo[ih]->axis().binUpperEdge(iBin)) <<
"\t"
282 << histo[ih]->binHeight(iBin)
295 G4cout <<
"---> warning from HistoManager::SetNtuple() : Ntuple " << nt
296 <<
"does not exist" <<
G4endl;
300 const G4String id[] = {
"100",
"101" };
303 "Energy deposit in subModule"
308 column[0] =
" int dum=0 ";
311 "double Evis0, Evis1, Evis2, Evis3, Evis4, Evis5, Evis6, Evis7, Evis8, Evis9";
313 ", Evis10, Evis11, Evis12, Evis13, Evis14, Evis15, Evis16, Evis17";
315 ", Edep0, Edep1, Edep2, Edep3, Edep4, Edep5, Edep6, Edep7, Edep8, Edep9";
317 ", Edep10, Edep11, Edep12, Edep13, Edep14, Edep15, Edep16, Edep17";
322 LabelNt[
nt] =
id[
nt];
324 ColumnNt[
nt] = column[
nt];
326 G4cout <<
"----> SetNtuple " << nt <<
": " << titl <<
"; " <<
G4endl;
335 G4cout <<
"---> warning from HistoManager::FillNtuple() : Ntuple " << nt
336 <<
" does not exist " << column << value <<
G4endl;
339 #ifdef G4ANALYSIS_USE
340 if(existNt[nt]) ntupl[
nt]->fill(column, value);
349 G4cout <<
"---> warning from HistoManager::AddRowNtuple() : Ntuple " << nt
350 <<
" do not exist" <<
G4endl;
353 #ifdef G4ANALYSIS_USE
354 if(existNt[nt]) ntupl[
nt]->addRow();