40 #include "HistoManager.hh"
47 fNtuple1(0), fNtuple2(0),
48 fEabs(0.), fEgap(0.) ,fLabs(0.), fLgap(0.)
63 if (fRootFile)
delete fRootFile;
68 void HistoManager::Book()
74 fRootFile =
new TFile(fileName,
"RECREATE");
76 G4cout <<
" HistoManager::Book :"
77 <<
" problem creating the ROOT TFile "
83 fHisto[0] =
new TH1D(
"EAbs",
"Edep in absorber (MeV)", 100, 0., 800*
CLHEP::MeV);
85 fHisto[1] =
new TH1D(
"EGap",
"Edep in gap (MeV)", 100, 0., 100*
CLHEP::MeV);
87 fHisto[2] =
new TH1D(
"LAbs",
"trackL in absorber (mm)", 100, 0., 1*
CLHEP::m);
89 fHisto[3] =
new TH1D(
"LGap",
"trackL in gap (mm)", 100, 0., 50*
CLHEP::cm);
92 if (! fHisto[i])
G4cout <<
"\n can't create histo " << i <<
G4endl;
96 fNtuple1 =
new TTree(
"Ntuple1",
"Edep");
97 fNtuple1->Branch(
"Eabs", &fEabs,
"Eabs/D");
98 fNtuple1->Branch(
"Egap", &fEgap,
"Egap/D");
101 fNtuple2 =
new TTree(
"Ntuple2",
"TrackL");
102 fNtuple2->Branch(
"Labs", &fLabs,
"Labs/D");
103 fNtuple2->Branch(
"Lgap", &fLgap,
"Lgap/D");
105 G4cout <<
"\n----> Output file is open in " << fileName <<
G4endl;
112 if (! fRootFile)
return;
117 G4cout <<
"\n----> Histograms and ntuples are saved\n" <<
G4endl;
124 if (ih >= kMaxHisto) {
125 G4cerr <<
"---> warning from HistoManager::FillHisto() : histo " << ih
126 <<
" does not exist. (xbin=" << xbin <<
" weight=" << weight <<
")"
130 if (fHisto[ih]) { fHisto[ih]->Fill(xbin, weight); }
137 if (ih >= kMaxHisto) {
138 G4cout <<
"---> warning from HistoManager::Normalize() : histo " << ih
139 <<
" does not exist. (fac=" << fac <<
")" <<
G4endl;
142 if (fHisto[ih]) fHisto[ih]->Scale(fac);
155 if (fNtuple1) fNtuple1->Fill();
156 if (fNtuple2) fNtuple2->Fill();
163 G4cout <<
"\n ----> print histograms statistic \n" <<
G4endl;
165 TH1D* h1 = fHisto[i];
169 if (name[0] ==
'E' ) unitCategory =
"Energy";
170 if (name[0] ==
'L' ) unitCategory =
"Length";
173 <<
": mean = " <<
G4BestUnit(h1->GetMean(), unitCategory)
174 <<
" rms = " <<
G4BestUnit(h1->GetRMS(), unitCategory )
static constexpr double m
static constexpr double cm
void FillHisto(G4int id, G4double e, G4double weight=1.0)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void Normalize(G4int id, G4double fac)
G4GLOB_DLL std::ostream G4cout
static constexpr double MeV
static const G4double fac
void FillNtuple(G4double EnergyAbs, G4double EnergyGap, G4double TrackLAbs, G4double TrackLGap)
G4GLOB_DLL std::ostream G4cerr