45 #include "HistoMessenger.hh"
83 if(!(fHistoActive || fNtupleActive)) {
return; }
86 if ( fHistType ==
"root" ) {
97 G4cout <<
"Histo::Book: ERROR open file <" << nam <<
">" <<
G4endl;
99 fNtupleActive =
false;
102 G4cout <<
"### Histo::Save: Opended file <" << nam <<
"> for "
103 << fNHisto <<
" histograms " <<
G4endl;
106 for(
G4int i=0; i<fNHisto; ++i) {
109 fHisto[i] = fManager->
CreateH1(ss, fTitles[i], fBins[i], fXmin[i], fXmax[i]);
111 G4cout <<
"Created histogram #" << i <<
" id= " << fHisto[i]
112 <<
" " << ss <<
" " << fTitles[i] <<
G4endl;
120 G4int n = fNtupleI.size();
122 if(fTupleI[i] == -1) {
128 if(fTupleF[i] == -1) {
134 if(fTupleD[i] == -1) {
145 if(!(fHistoActive || fNtupleActive)) {
return; }
148 G4String nam = fHistName +
"." + fHistType;
151 if(!fManager->
Write()) {
153 message <<
"Histo::Save: FATAL ERROR writing ROOT file.";
158 G4cout <<
"### Histo::Save: Histograms and Ntuples are saved" <<
G4endl;
160 if(fManager->
CloseFile() && fVerbose > 0) {
173 G4cout <<
"Histo::Add1D: New histogram will be booked: #"
174 <<
id <<
" <" << name
175 <<
" " << nb <<
" " << x1 <<
" " << x2 <<
" " << u
181 fActive.push_back(fDefaultAct);
187 fTitles.push_back(name);
188 fHisto.push_back(-1);
196 if(i>=0 && i<fNHisto) {
198 G4cout <<
"Histo::SetHisto1D: #" << i
199 <<
" " << nb <<
" " << x1 <<
" " << x2 <<
" " << u
209 G4cout <<
"Histo::SetHisto1D: WARNING! wrong histogram index "
219 G4cout <<
"Histo::Activate: Histogram: #" << i <<
" "
222 if(i>=0 && i<fNHisto) {
224 if(val) { fHistoActive =
true; }
232 if(!fHistoActive) {
return; }
234 G4cout <<
"Histo::Fill: Histogram: #" << i <<
" at x= " << x
238 if(i>=0 && i<fNHisto) {
239 if(fActive[i]) { fManager->
FillH1(fHisto[i], x/fUnit[i], w); }
241 G4cout <<
"Histo::Fill: WARNING! wrong histogram index "
250 if(!fHistoActive) {
return; }
252 G4cout <<
"Histo::Scale: Histogram: #" << i <<
" by factor "
255 if(i>=0 && i<fNHisto) {
257 if ( fHistType ==
"root" )
259 if ( fHistType ==
"xml" )
263 G4cout <<
"Histo::Scale: WARNING! wrong histogram index "
279 fNtupleActive =
true;
280 fNtupleI.push_back(w1);
281 fTupleI.push_back(-1);
288 fNtupleActive =
true;
289 fNtupleF.push_back(w1);
290 fTupleF.push_back(-1);
297 fNtupleActive =
true;
298 fNtupleD.push_back(w1);
299 fTupleD.push_back(-1);
306 if(!fNtupleActive) {
return; }
307 G4int n = fNtupleI.size();
308 if(i >= 0 && i < n) {
310 G4cout <<
"Histo::FillTupleI: i= " << i <<
" id= " << fTupleI[i]
311 <<
" <" << fNtupleI[i] <<
"> = " << x <<
G4endl;
315 G4cout <<
"Histo::FillTupleI: WARNING! wrong ntuple index "
324 if(!fNtupleActive) {
return; }
325 G4int n = fNtupleF.size();
326 if(i >= 0 && i < n) {
328 G4cout <<
"Histo::FillTupleF: i= " << i <<
" id= " << fTupleF[i]
329 <<
" <" << fNtupleF[i] <<
"> = " << x <<
G4endl;
333 G4cout <<
"Histo::FillTupleF: WARNING! wrong ntuple index "
342 if(!fNtupleActive) {
return; }
343 G4int n = fNtupleD.size();
344 if(i >= 0 && i < n) {
346 G4cout <<
"Histo::FillTupleD: i= " << i <<
" id= " << fTupleD[i]
347 <<
" <" << fNtupleD[i] <<
"> = " << x <<
G4endl;
351 G4cout <<
"Histo::FillTupleD: WARNING! wrong ntuple index "
360 if(!fNtupleActive) {
return; }
376 if(nam ==
"root" || nam ==
"ROOT" ) { fHistType =
"root"; }
377 else if(nam ==
"xml" || nam ==
"XML") { fHistType =
"xml"; }
379 G4cout<<
"Histo::SetFileType: Sorry, format for output file: "<<nam
380 <<
" not supported. Use \"root\" or \"xml\"" <<
G4endl;
void AddTupleD(const G4String &)
void AddTuple(const G4String &)
G4int CreateNtupleIColumn(const G4String &name)
std::ostringstream G4ExceptionDescription
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)
static G4XmlAnalysisManager * Instance()
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 &)