31 #include "HistoManager.hh"
32 #include "HistoMessenger.hh"
36 #include "AIDA/AIDA.h"
43 : factoryOn(
false),af(0),
tree(0)
48 af = AIDA_createAnalysisFactory();
50 G4cout <<
" HistoManager::HistoManager :"
51 <<
" problem creating the AIDA analysis factory."
58 fileOption =
"export=root";
82 delete histoMessenger;
97 fileName[1] = fileName[0] +
"." + fileType;
100 AIDA::ITreeFactory* tf = af->createTreeFactory();
101 tree = tf->create(fileName[1], fileType, readOnly, createNew, fileOption);
104 G4cout <<
" HistoManager::book :"
105 <<
" problem creating the AIDA tree with "
106 <<
" storeName = " << fileName[1]
107 <<
" storeType = " << fileType
108 <<
" readOnly = " << readOnly
109 <<
" createNew = " << createNew
110 <<
" options = " << fileOption
116 AIDA::IHistogramFactory*
hf = af->createHistogramFactory(*
tree);
121 histo[k] = hf->createHistogram1D( Label[k], Title[k],
122 Nbins[k], Vmin[k], Vmax[k]);
129 AIDA::ITupleFactory* ntf = af->createTupleFactory(*
tree);
134 ntupl[k] = ntf->create( LabelNt[k], TitleNt[k], ColumnNt[k]);
142 G4cout <<
"\n----> Histogram Tree is opened in " << fileName[1] <<
G4endl;
150 #ifdef G4ANALYSIS_USE
155 G4cout <<
"\n----> Histogram Tree is saved in " << fileName[1] <<
G4endl;
169 G4cout <<
"---> warning from HistoManager::FillHisto() : histo " << ih
170 <<
" xbin= " << xbin <<
" weight= " << weight <<
G4endl;
173 #ifdef G4ANALYSIS_USE
174 if(exist[ih]) histo[ih]->fill(xbin/Unit[ih], weight);
184 G4cout <<
"---> warning from HistoManager::SetHisto() : histo " << ih
185 <<
"does not exist" <<
G4endl;
189 const G4String id[] = {
"0",
"1",
"2",
"3",
"4",
"5" };
192 "total Evis in Ecal",
193 "total Edep in Ecal",
196 "Nb of Radiation Length"
200 G4double vmin = valmin, vmax = valmax;
203 if (unit !=
"none") {
204 titl = title[ih] +
" (" + unit +
")";
206 vmin = valmin/Unit[ih]; vmax = valmax/Unit[ih];
215 Width[ih] = (valmax-valmin)/nbins;
217 G4cout <<
"----> SetHisto " << ih <<
": " << titl <<
"; "
218 << nbins <<
" bins from "
219 << vmin <<
" " << unit <<
" to " << vmax <<
" " << unit <<
G4endl;
228 G4cout <<
"---> warning from HistoManager::Normalize() : histo " << ih
229 <<
" fac= " << fac <<
G4endl;
232 #ifdef G4ANALYSIS_USE
233 if(exist[ih]) histo[ih]->scale(fac);
242 G4cout <<
"---> warning from HistoManager::RemoveHisto() : histo " << ih
243 <<
"does not exist" <<
G4endl;
247 histo[ih] = 0; exist[ih] =
false;
254 if (ih <
MaxHisto) { ascii[ih] =
true; ascii[0] =
true; }
256 G4cout <<
"---> warning from HistoManager::PrintHisto() : histo " << ih
257 <<
"does not exist" <<
G4endl;
264 void HistoManager::saveAscii()
266 #ifdef G4ANALYSIS_USE
268 if (!ascii[0])
return;
271 std::ofstream File(name, std::ios::out);
272 File.setf( std::ios::scientific, std::ios::floatfield );
276 if (exist[ih] && ascii[ih]) {
277 File <<
"\n 1D histogram " << ih <<
": " << Title[ih]
278 <<
"\n \n \t X \t\t Y" <<
G4endl;
280 for (
G4int iBin=0; iBin<Nbins[ih]; iBin++) {
281 File <<
" " << iBin <<
"\t"
282 << 0.5*(histo[ih]->axis().binLowerEdge(iBin) +
283 histo[ih]->axis().binUpperEdge(iBin)) <<
"\t"
284 << histo[ih]->binHeight(iBin)
297 G4cout <<
"---> warning from HistoManager::SetNtuple() : Ntuple " << nt
298 <<
"does not exist" <<
G4endl;
302 const G4String id[] = {
"100",
"101" };
305 "Energy deposit in subModule"
310 column[0] =
" int dum=0 ";
313 "double Evis0, Evis1, Evis2, Evis3, Evis4, Evis5, Evis6, Evis7, Evis8, Evis9";
315 ", Evis10, Evis11, Evis12, Evis13, Evis14, Evis15, Evis16, Evis17";
317 ", Edep0, Edep1, Edep2, Edep3, Edep4, Edep5, Edep6, Edep7, Edep8, Edep9";
319 ", Edep10, Edep11, Edep12, Edep13, Edep14, Edep15, Edep16, Edep17";
324 LabelNt[
nt] =
id[
nt];
326 ColumnNt[
nt] = column[
nt];
328 G4cout <<
"----> SetNtuple " << nt <<
": " << titl <<
"; " <<
G4endl;
337 G4cout <<
"---> warning from HistoManager::FillNtuple() : Ntuple " << nt
338 <<
" does not exist " << column << value <<
G4endl;
341 #ifdef G4ANALYSIS_USE
342 if(existNt[nt]) ntupl[
nt]->fill(column, value);
351 G4cout <<
"---> warning from HistoManager::AddRowNtuple() : Ntuple " << nt
352 <<
" do not exist" <<
G4endl;
355 #ifdef G4ANALYSIS_USE
356 if(existNt[nt]) ntupl[
nt]->addRow();
void FillNtuple(G4int id, G4int column, G4double value)
void AddRowNtuple(G4int id)
void FillHisto(G4int id, G4double bin, G4double weight=1.0)
void Normalize(G4int id, G4double fac)
static G4double GetValueOf(const G4String &)
G4GLOB_DLL std::ostream G4cout
void SetHisto(G4int, G4int, G4double, G4double, const G4String &unit="none")
subroutine title(NA, NB, NCA, NCB)
const XML_Char int const XML_Char * value