30 #include <AIDA/AIDA.h>
33 #ifdef G4ANALYSIS_USE_ROOT
35 #include "TApplication.h"
54 :fHistName(
"exrdm"), fHistType(
"root"),
55 fNHisto(0), fNTuple(0), fVerbose(0),
63 #ifdef G4ANALYSIS_USE_ROOT
80 fTupleListROOT.clear();
93 #ifdef G4ANALYSIS_USE_ROOT
113 #ifdef G4ANALYSIS_USE
114 G4cout <<
"### exrdmHisto books " << fNHisto <<
" histograms " <<
G4endl;
116 fAida = AIDA_createAnalysisFactory();
122 {AIDA::ITreeFactory* tf = fAida->createTreeFactory();
124 G4String fileName = fHistName +
"." + fHistType;
125 if (fHistType ==
"root") fileName = fHistName +
"_aida." + fHistType;
126 fTree = tf->create(fileName,fHistType,
false,
true,
"");
129 G4cout <<
"ERROR: Tree store " << fHistName <<
" is not created!" <<
G4endl;
132 G4cout <<
"Tree store : " << fTree->storeName() <<
G4endl;}
134 {AIDA::IHistogramFactory*
hf = fAida->createHistogramFactory(*fTree);
136 for(
G4int i=0; i<fNHisto; i++) {
139 G4cout<<
"Book: histogram "<< i <<
" id= " << fIds[i] <<
G4endl;
141 if(fHistType ==
"root") tit =
"h" + fIds[i];
142 fHisto[i] = hf->createHistogram1D(tit, fTitles[i], fBins[i], fXmin[i],
150 {AIDA::ITupleFactory* tpf = fAida->createTupleFactory( *fTree );
151 G4cout <<
"AIDA will Book " << fNTuple <<
" ntuples" <<
G4endl;
152 for(
G4int i=0; i<fNTuple; i++) {
153 if(fTupleList[i] !=
"") {
154 G4cout <<
"Creating Ntuple: " << fTupleName[i] <<
":" <<fTupleList[i]
156 fNtup[i] = tpf->create(fTupleId[i], fTupleName[i], fTupleList[i],
"");
163 #ifdef G4ANALYSIS_USE_ROOT
166 fHfileROOT =
new TFile(fileNameROOT.c_str() ,
"RECREATE",
"ROOT file for exRDM");
169 for(
G4int i=0; i<fNHisto; i++) {
171 G4String
id = G4String(
"h")+fIds[i];
172 fROOThisto[i] =
new TH1D(
id, fTitles[i], fBins[i], fXmin[i], fXmax[i]);
173 G4cout <<
"ROOT Histo " << fIds[i] <<
" " << fTitles[i] <<
" booked "
178 for(
G4int i=0; i<fNTuple; i++) {
179 if(fTupleListROOT[i] !=
"") {
180 G4String
id = G4String(
"t")+fTupleId[i];
181 G4cout <<
"Creating Ntuple "<<fTupleId[i] <<
" in ROOT file: "
182 << fTupleName[i] <<
G4endl;
183 fROOTntup[i] =
new TNtuple(
id, fTupleName[i], fTupleListROOT[i]);
184 G4cout <<
"ROOT Ntuple " <<
id <<
" " << fTupleName[i] <<
" "
185 << fTupleListROOT[i]<<
" booked " <<
G4endl;
196 #ifdef G4ANALYSIS_USE
206 {
for(
G4int i=0; i<fNHisto; i++) fHisto[i] = 0;}
207 {
for(
G4int i=0; i<fNTuple; i++) fNtup[i] = 0;}
209 #ifdef G4ANALYSIS_USE_ROOT
228 G4cout <<
"New histogram will be booked: #" <<
id <<
" <" << name
229 <<
" " << nb <<
" " << x1 <<
" " << x2 <<
" " << u
235 fActive.push_back(fDefaultAct);
241 fTitles.push_back(name);
242 #ifdef G4ANALYSIS_USE
245 #ifdef G4ANALYSIS_USE_ROOT
246 fROOThisto.push_back(0);
254 if(i>=0 && i<fNHisto) {
256 G4cout <<
"Update histogram: #" << i
257 <<
" " << nb <<
" " << x1 <<
" " << x2 <<
" " << u
265 G4cout <<
"exrdmHisto::setexrdmHisto1D: WARNING! wrong histogram index "
275 G4cout <<
"fill histogram: #" << i <<
" at x= " << x
279 #ifdef G4ANALYSIS_USE
280 if(i>=0 && i<fNHisto) {
281 fHisto[i]->fill(x/fUnit[i], w);
283 G4cout <<
"exrdmHisto::fill: WARNING! wrong AIDA histogram index "
287 #ifdef G4ANALYSIS_USE_ROOT
288 if(i>=0 && i<fNHisto) {
289 fROOThisto[i]->Fill(x/fUnit[i],w);
291 G4cout <<
"exrdmHisto::fill: WARNING! wrong ROOT histogram index "
302 G4cout <<
"Scale histogram: #" << i <<
" by factor " << x <<
G4endl;
304 #ifdef G4ANALYSIS_USE
305 if(i>=0 && i<fNHisto) {
307 G4cout <<
"exrdmHisto::scale: WARNING! wrong AIDA histogram index "
311 #ifdef G4ANALYSIS_USE_ROOT
312 if(i>=0 && i<fNHisto) {
313 fROOThisto[i]->Scale(x);
315 G4cout <<
"exrdmHisto::scale: WARNING! wrong ROOT histogram index "
323 #ifdef G4ANALYSIS_USE
327 #ifdef G4ANALYSIS_USE_ROOT
339 fTupleId.push_back(w1);
340 fTupleName.push_back(w2) ;
341 #ifdef G4ANALYSIS_USE
342 fTupleList.push_back(w3);
346 #ifdef G4ANALYSIS_USE_ROOT
347 std::vector<float> ar;
349 for (
size_t i = 0; i < 20; i++) ar.push_back(0.);
350 fRarray.push_back(ar);
356 while ( token !=
"") {
358 if (token ==
",") token = next();
360 ROOTList1 = ROOTList1 + token +
G4String(
":");
363 G4String ROOTList = ROOTList1.substr(0,ROOTList1.length()-2);
365 fTupleListROOT.push_back(ROOTList);
366 fROOTntup.push_back(0);
367 fRcol.push_back(col-1);
376 G4cout <<
"fill tuple # " << i
377 <<
" with parameter <" << parname <<
"> = " << x <<
G4endl;
378 #ifdef G4ANALYSIS_USE
379 if(fNtup[i]) fNtup[i]->fill(fNtup[i]->findColumn(parname), x);
388 G4cout <<
"fill tuple # " << i
389 <<
" in column < " << col <<
"> = " << x <<
G4endl;
391 #ifdef G4ANALYSIS_USE
392 if(fNtup[i]) fNtup[i]->fill(col,
double(x));
395 #ifdef G4ANALYSIS_USE_ROOT
396 if(fROOTntup[i]) (fRarray[i])[col] =
float(x);
406 G4cout <<
"fill tuple # " << i
407 <<
" with parameter <" << parname <<
"> = " << x <<
G4endl;
409 #ifdef G4ANALYSIS_USE
410 if(fNtup[i]) fNtup[i]->fill(fNtup[i]->findColumn(parname), x);
419 if(fVerbose > 1)
G4cout <<
"Added a raw #" << i <<
" to tuple" <<
G4endl;
420 #ifdef G4ANALYSIS_USE
421 if(fNtup[i]) fNtup[i]->addRow();
424 #ifdef G4ANALYSIS_USE_ROOT
426 for (
G4int j=0; j < fRcol[i]; j++) {
428 ar[j] = fRarray[i][j];
430 if(fROOTntup[i]) fROOTntup[i]->Fill(ar);