32 #include <AIDA/AIDA.h>
35 #ifdef G4ANALYSIS_USE_ROOT
37 #include "TApplication.h"
56 :fHistName(
"exrdm"), fHistType(
"root"),
57 fNHisto(0), fNTuple(0), fVerbose(0),
65 #ifdef G4ANALYSIS_USE_ROOT
82 fTupleListROOT.clear();
95 #ifdef G4ANALYSIS_USE_ROOT
115 #ifdef G4ANALYSIS_USE
116 G4cout <<
"### exrdmHisto books " << fNHisto <<
" histograms " <<
G4endl;
118 fAida = AIDA_createAnalysisFactory();
124 {AIDA::ITreeFactory* tf = fAida->createTreeFactory();
126 G4String fileName = fHistName +
"." + fHistType;
127 if (fHistType ==
"root") fileName = fHistName +
"_aida." + fHistType;
128 fTree = tf->create(fileName,fHistType,
false,
true,
"");
131 G4cout <<
"ERROR: Tree store " << fHistName <<
" is not created!" <<
G4endl;
134 G4cout <<
"Tree store : " << fTree->storeName() <<
G4endl;}
136 {AIDA::IHistogramFactory*
hf = fAida->createHistogramFactory(*fTree);
138 for(
G4int i=0; i<fNHisto; i++) {
141 G4cout<<
"Book: histogram "<< i <<
" id= " << fIds[i] <<
G4endl;
143 if(fHistType ==
"root") tit =
"h" + fIds[i];
144 fHisto[i] = hf->createHistogram1D(tit, fTitles[i], fBins[i], fXmin[i],
152 {AIDA::ITupleFactory* tpf = fAida->createTupleFactory( *fTree );
153 G4cout <<
"AIDA will Book " << fNTuple <<
" ntuples" <<
G4endl;
154 for(
G4int i=0; i<fNTuple; i++) {
155 if(fTupleList[i] !=
"") {
156 G4cout <<
"Creating Ntuple: " << fTupleName[i] <<
":" <<fTupleList[i]
158 fNtup[i] = tpf->create(fTupleId[i], fTupleName[i], fTupleList[i],
"");
165 #ifdef G4ANALYSIS_USE_ROOT
168 fHfileROOT =
new TFile(fileNameROOT.c_str() ,
"RECREATE",
"ROOT file for exRDM");
171 for(
G4int i=0; i<fNHisto; i++) {
173 G4String
id = G4String(
"h")+fIds[i];
174 fROOThisto[i] =
new TH1D(
id, fTitles[i], fBins[i], fXmin[i], fXmax[i]);
175 G4cout <<
"ROOT Histo " << fIds[i] <<
" " << fTitles[i] <<
" booked "
180 for(
G4int i=0; i<fNTuple; i++) {
181 if(fTupleListROOT[i] !=
"") {
182 G4String
id = G4String(
"t")+fTupleId[i];
183 G4cout <<
"Creating Ntuple "<<fTupleId[i] <<
" in ROOT file: "
184 << fTupleName[i] <<
G4endl;
185 fROOTntup[i] =
new TNtuple(
id, fTupleName[i], fTupleListROOT[i]);
186 G4cout <<
"ROOT Ntuple " <<
id <<
" " << fTupleName[i] <<
" "
187 << fTupleListROOT[i]<<
" booked " <<
G4endl;
198 #ifdef G4ANALYSIS_USE
208 {
for(
G4int i=0; i<fNHisto; i++) fHisto[i] = 0;}
209 {
for(
G4int i=0; i<fNTuple; i++) fNtup[i] = 0;}
211 #ifdef G4ANALYSIS_USE_ROOT
230 G4cout <<
"New histogram will be booked: #" <<
id <<
" <" << name
231 <<
" " << nb <<
" " << x1 <<
" " << x2 <<
" " << u
237 fActive.push_back(fDefaultAct);
243 fTitles.push_back(name);
244 #ifdef G4ANALYSIS_USE
247 #ifdef G4ANALYSIS_USE_ROOT
248 fROOThisto.push_back(0);
256 if(i>=0 && i<fNHisto) {
258 G4cout <<
"Update histogram: #" << i
259 <<
" " << nb <<
" " << x1 <<
" " << x2 <<
" " << u
267 G4cout <<
"exrdmHisto::setexrdmHisto1D: WARNING! wrong histogram index "
277 G4cout <<
"fill histogram: #" << i <<
" at x= " << x
281 #ifdef G4ANALYSIS_USE
282 if(i>=0 && i<fNHisto) {
283 fHisto[i]->fill(x/fUnit[i], w);
285 G4cout <<
"exrdmHisto::fill: WARNING! wrong AIDA histogram index "
289 #ifdef G4ANALYSIS_USE_ROOT
290 if(i>=0 && i<fNHisto) {
291 fROOThisto[i]->Fill(x/fUnit[i],w);
293 G4cout <<
"exrdmHisto::fill: WARNING! wrong ROOT histogram index "
304 G4cout <<
"Scale histogram: #" << i <<
" by factor " << x <<
G4endl;
306 #ifdef G4ANALYSIS_USE
307 if(i>=0 && i<fNHisto) {
309 G4cout <<
"exrdmHisto::scale: WARNING! wrong AIDA histogram index "
313 #ifdef G4ANALYSIS_USE_ROOT
314 if(i>=0 && i<fNHisto) {
315 fROOThisto[i]->Scale(x);
317 G4cout <<
"exrdmHisto::scale: WARNING! wrong ROOT histogram index "
325 #ifdef G4ANALYSIS_USE
329 #ifdef G4ANALYSIS_USE_ROOT
341 fTupleId.push_back(w1);
342 fTupleName.push_back(w2) ;
343 #ifdef G4ANALYSIS_USE
344 fTupleList.push_back(w3);
348 #ifdef G4ANALYSIS_USE_ROOT
349 std::vector<float> ar;
351 for (
size_t i = 0; i < 20; i++) ar.push_back(0.);
352 fRarray.push_back(ar);
358 while ( token !=
"") {
360 if (token ==
",") token = next();
362 ROOTList1 = ROOTList1 + token +
G4String(
":");
365 G4String ROOTList = ROOTList1.substr(0,ROOTList1.length()-2);
367 fTupleListROOT.push_back(ROOTList);
368 fROOTntup.push_back(0);
369 fRcol.push_back(col-1);
378 G4cout <<
"fill tuple # " << i
379 <<
" with parameter <" << parname <<
"> = " << x <<
G4endl;
380 #ifdef G4ANALYSIS_USE
381 if(fNtup[i]) fNtup[i]->fill(fNtup[i]->findColumn(parname), x);
390 G4cout <<
"fill tuple # " << i
391 <<
" in column < " << col <<
"> = " << x <<
G4endl;
393 #ifdef G4ANALYSIS_USE
394 if(fNtup[i]) fNtup[i]->fill(col,
double(x));
397 #ifdef G4ANALYSIS_USE_ROOT
398 if(fROOTntup[i]) (fRarray[i])[col] =
float(x);
408 G4cout <<
"fill tuple # " << i
409 <<
" with parameter <" << parname <<
"> = " << x <<
G4endl;
411 #ifdef G4ANALYSIS_USE
412 if(fNtup[i]) fNtup[i]->fill(fNtup[i]->findColumn(parname), x);
421 if(fVerbose > 1)
G4cout <<
"Added a raw #" << i <<
" to tuple" <<
G4endl;
422 #ifdef G4ANALYSIS_USE
423 if(fNtup[i]) fNtup[i]->addRow();
426 #ifdef G4ANALYSIS_USE_ROOT
428 for (
G4int j=0; j < fRcol[i]; j++) {
430 ar[j] = fRarray[i][j];
432 if(fROOTntup[i]) fROOTntup[i]->Fill(ar);
const G4String & GetFileName() const
void FillTuple(G4int, const G4String &, G4double)
G4String & remove(str_size)
Definition of the exrdmHisto class.
const G4String & FileType() const
void SetFileType(const G4String &)
void FillHisto(G4int, G4double, G4double)
Definition of the exrdmHistoMessenger class.
void AddTuple(const G4String &, const G4String &, const G4String &)
void SetHisto1D(G4int, G4int, G4double, G4double, G4double)
void SetFileName(const G4String &)
G4GLOB_DLL std::ostream G4cout
G4bool contains(const std::string &) const
void ScaleHisto(G4int, G4double)
void Add1D(const G4String &, const G4String &, G4int nb=100, G4double x1=0., G4double x2=1., G4double u=1.)