45 #include "HistoMessenger.hh"
81 if(!(fHistoActive || fNtupleActive)) {
return; }
87 G4String nam = fHistName +
"." + fHistType;
91 G4cout <<
"Histo::Book: ERROR open file <" << nam <<
">" <<
G4endl;
93 fNtupleActive =
false;
96 G4cout <<
"### Histo::Save: Opended file <" << nam <<
"> for "
97 << fNHisto <<
" histograms " <<
G4endl;
100 for(
G4int i=0; i<fNHisto; ++i) {
103 fHisto[i] = fManager->
CreateH1(ss, fTitles[i], fBins[i], fXmin[i], fXmax[i]);
105 G4cout <<
"Created histogram #" << i <<
" id= " << fHisto[i]
106 <<
" " << ss <<
" " << fTitles[i] <<
G4endl;
114 G4int n = fNtupleI.size();
116 if(fTupleI[i] == -1) {
122 if(fTupleF[i] == -1) {
128 if(fTupleD[i] == -1) {
139 if(!(fHistoActive || fNtupleActive)) {
return; }
142 G4String nam = fHistName +
"." + fHistType;
145 if(!fManager->
Write()) {
146 G4cout <<
"Histo::Save: FATAL ERROR writing ROOT file" <<
G4endl;
150 G4cout <<
"### Histo::Save: Histograms and Ntuples are saved" <<
G4endl;
152 if(fManager->
CloseFile() && fVerbose > 0) {
165 G4cout <<
"Histo::Add1D: New histogram will be booked: #"
166 <<
id <<
" <" << name
167 <<
" " << nb <<
" " << x1 <<
" " << x2 <<
" " << u
173 fActive.push_back(fDefaultAct);
179 fTitles.push_back(name);
180 fHisto.push_back(-1);
188 if(i>=0 && i<fNHisto) {
190 G4cout <<
"Histo::SetHisto1D: #" << i
191 <<
" " << nb <<
" " << x1 <<
" " << x2 <<
" " << u
201 G4cout <<
"Histo::SetHisto1D: WARNING! wrong histogram index "
211 G4cout <<
"Histo::Activate: Histogram: #" << i <<
" "
214 if(i>=0 && i<fNHisto) {
216 if(val) { fHistoActive =
true; }
224 if(!fHistoActive) {
return; }
226 G4cout <<
"Histo::Fill: Histogram: #" << i <<
" at x= " << x
230 if(i>=0 && i<fNHisto) {
231 if(fActive[i]) { fManager->
FillH1(fHisto[i], x/fUnit[i], w); }
233 G4cout <<
"Histo::Fill: WARNING! wrong histogram index "
242 if(!fHistoActive) {
return; }
244 G4cout <<
"Histo::Scale: Histogram: #" << i <<
" by factor "
247 if(i>=0 && i<fNHisto) {
248 if(fActive[i]) { fManager->
GetH1(fHisto[i])->scale(x); }
250 G4cout <<
"Histo::Scale: WARNING! wrong histogram index "
266 fNtupleActive =
true;
267 fNtupleI.push_back(w1);
268 fTupleI.push_back(-1);
275 fNtupleActive =
true;
276 fNtupleF.push_back(w1);
277 fTupleF.push_back(-1);
284 fNtupleActive =
true;
285 fNtupleD.push_back(w1);
286 fTupleD.push_back(-1);
293 if(!fNtupleActive) {
return; }
294 G4int n = fNtupleI.size();
295 if(i >= 0 && i < n) {
297 G4cout <<
"Histo::FillTupleI: i= " << i <<
" id= " << fTupleI[i]
298 <<
" <" << fNtupleI[i] <<
"> = " << x <<
G4endl;
302 G4cout <<
"Histo::FillTupleI: WARNING! wrong ntuple index "
311 if(!fNtupleActive) {
return; }
312 G4int n = fNtupleF.size();
313 if(i >= 0 && i < n) {
315 G4cout <<
"Histo::FillTupleF: i= " << i <<
" id= " << fTupleF[i]
316 <<
" <" << fNtupleF[i] <<
"> = " << x <<
G4endl;
320 G4cout <<
"Histo::FillTupleF: WARNING! wrong ntuple index "
329 if(!fNtupleActive) {
return; }
330 G4int n = fNtupleD.size();
331 if(i >= 0 && i < n) {
333 G4cout <<
"Histo::FillTupleD: i= " << i <<
" id= " << fTupleD[i]
334 <<
" <" << fNtupleD[i] <<
"> = " << x <<
G4endl;
338 G4cout <<
"Histo::FillTupleD: WARNING! wrong ntuple index "
347 if(!fNtupleActive) {
return; }
363 if(nam ==
"root" || nam ==
"ROOT" ) { fHistType =
"root"; }
364 else if(nam ==
"xml" || nam ==
"XML") { fHistType =
"xml"; }
365 else if(nam ==
"ascii" || nam ==
"ASCII" ||
366 nam ==
"Csv" || nam ==
"csv" || nam ==
"CSV")
367 { fHistType =
"ascii"; }
void AddTupleD(const G4String &)
void AddTuple(const G4String &)
G4int CreateNtupleIColumn(const G4String &name)
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
void AddTupleI(const G4String &)
G4int CreateNtuple(const G4String &name, const G4String &title)
void Activate(G4int, G4bool)
G4bool FillNtupleFColumn(G4int id, G4float value)
void Fill(G4int, G4double, G4double)
void FillTupleF(G4int, G4float)
G4bool FillNtupleIColumn(G4int id, G4int value)
G4GLOB_DLL std::ostream G4cout
G4bool FillNtupleDColumn(G4int id, G4double value)
void ScaleH1(G4int, G4double)
void Add1D(const G4String &, const G4String &, G4int nb, G4double x1, G4double x2, G4double u=1.)
void AddTupleF(const G4String &)
G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
void SetHisto1D(G4int, G4int, G4double, G4double, G4double)
void FillTupleD(G4int, G4double)
G4int CreateNtupleFColumn(const G4String &name)
static G4RootAnalysisManager * Instance()
G4int CreateNtupleDColumn(const G4String &name)
void SetFileType(const G4String &)
void FillTupleI(G4int, G4int)
tools::histo::h1d * GetH1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
void SetFileName(const G4String &)