45 #include "HistoMessenger.hh"
80 if(!(fHistoActive || fNtupleActive)) {
return; }
86 G4String nam = fHistName +
"." + fHistType;
90 G4cout <<
"Histo::Book: ERROR open file <" << nam <<
">" <<
G4endl;
92 fNtupleActive =
false;
95 G4cout <<
"### Histo::Save: Opended file <" << nam <<
"> for "
96 << fNHisto <<
" histograms " <<
G4endl;
99 for(
G4int i=0; i<fNHisto; ++i) {
103 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()) {
147 "Cannot write ROOT file.");
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: #" <<
id
167 <<
" " << nb <<
" " << x1 <<
" " << x2 <<
" " << u
173 fActive.push_back(fDefaultAct);
179 fTitles.push_back(name);
180 fHisto.push_back(-1);
187 if(i>=0 && i<fNHisto) {
189 G4cout <<
"Histo::SetHisto1D: #" << i
190 <<
" " << nb <<
" " << x1 <<
" " << x2 <<
" " << u
200 G4cout <<
"Histo::SetHisto1D: WARNING! wrong histogram index "
210 G4cout <<
"Histo::Activate: Histogram: #" << i <<
" "
213 if(i>=0 && i<fNHisto) {
215 if(val) { fHistoActive =
true; }
223 if(!fHistoActive) {
return; }
225 G4cout <<
"Histo::Fill: Histogram: #" << i <<
" at x= " << x
229 if(i>=0 && i<fNHisto) {
230 if(fActive[i]) { fManager->
FillH1(fHisto[i], x/fUnit[i], w); }
232 G4cout <<
"Histo::Fill: WARNING! wrong histogram index " << i <<
G4endl;
240 if(!fHistoActive) {
return; }
242 G4cout <<
"Histo::Scale: Histogram: #"
243 << i <<
" by factor " << x <<
G4endl;
245 if(i>=0 && i<fNHisto) {
246 if(fActive[i]) { fManager->
GetH1(fHisto[i])->scale(x); }
248 G4cout <<
"Histo::Scale: WARNING! wrong histogram index " << i <<
G4endl;
263 fNtupleActive =
true;
264 fNtupleI.push_back(w1);
265 fTupleI.push_back(-1);
272 fNtupleActive =
true;
273 fNtupleF.push_back(w1);
274 fTupleF.push_back(-1);
281 fNtupleActive =
true;
282 fNtupleD.push_back(w1);
283 fTupleD.push_back(-1);
290 if(!fNtupleActive) {
return; }
291 G4int n = fNtupleI.size();
292 if(i >= 0 && i < n) {
294 G4cout <<
"Histo::FillTupleI: i= " << i <<
" id= " << fTupleI[i]
295 <<
" <" << fNtupleI[i] <<
"> = " << x <<
G4endl;
299 G4cout <<
"Histo::FillTupleI: WARNING! wrong ntuple index "
308 if(!fNtupleActive) {
return; }
309 G4int n = fNtupleF.size();
310 if(i >= 0 && i < n) {
312 G4cout <<
"Histo::FillTupleF: i= " << i <<
" id= " << fTupleF[i]
313 <<
" <" << fNtupleF[i] <<
"> = " << x <<
G4endl;
317 G4cout <<
"Histo::FillTupleF: WARNING! wrong ntuple index "
326 if(!fNtupleActive) {
return; }
327 G4int n = fNtupleD.size();
328 if(i >= 0 && i < n) {
330 G4cout <<
"Histo::FillTupleD: i= " << i <<
" id= " << fTupleD[i]
331 <<
" <" << fNtupleD[i] <<
"> = " << x <<
G4endl;
335 G4cout <<
"Histo::FillTupleD: WARNING! wrong ntuple index "
344 if(!fNtupleActive) {
return; }
361 if(nam ==
"root" || nam ==
"ROOT" ) { fHistType =
"root"; }
362 else if(nam ==
"xml" || nam ==
"XML") { fHistType =
"xml"; }
363 else if(nam ==
"ascii" || nam ==
"ASCII" ||
364 nam ==
"Csv" || nam ==
"csv" || nam ==
"CSV")
365 { 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 OpenFile(const G4String &fileName="")
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 G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
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)
void SetFileName(const G4String &)