35 #include "HistoManager.hh"
36 #include "HistoMessenger.hh"
46 fileName[0] =
"testem17";
67 delete fHistoMessenger;
75 if (fNbHist == 0)
return;
81 analysisManager->SetVerboseLevel(0);
82 G4String extension = analysisManager->GetFileType();
83 fileName[1] = fileName[0] +
"." + extension;
87 G4bool fileOpen = analysisManager->OpenFile(fileName[0]);
89 G4cout <<
"\n---> HistoManager::book(): cannot open " << fileName[1]
96 analysisManager->SetFirstHistoId(1);
100 fHistId[k] = analysisManager->CreateH1( fLabel[k], fTitle[k],
101 fNbins[k], fVmin[k], fVmax[k]);
102 fHistPt[k] = analysisManager->GetH1(fHistId[k]);
108 G4cout <<
"\n----> Histogram file is opened in " << fileName[1] <<
G4endl;
118 analysisManager->Write();
119 analysisManager->CloseFile();
121 G4cout <<
"\n----> Histograms are saved in " << fileName[1] <<
G4endl;
133 G4cout <<
"---> warning from HistoManager::FillHisto() : histo " << ih
134 <<
"does not fExist; e= " << e <<
" w= " << weight <<
G4endl;
138 if (fHistPt[ih]) fHistPt[ih]->fill(e/fUnit[ih], weight);
147 G4cout <<
"---> warning from HistoManager::SetHisto() : histo " << ih
148 <<
"does not fExist" <<
G4endl;
152 const G4String id[] = {
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
153 "10",
"11",
"12",
"13",
"14",
"15"};
156 "log10(Etransfert/Emu) muIonization",
157 "log10(Etransfert/Emu) muPair",
158 "log10(Etransfert/Emu) muBrems",
159 "log10(Etransfert/Emu) muNuclear",
160 "log10(Etransfert/Emu) hIonization",
161 "log10(Etransfert/Emu) hPair",
162 "log10(Etransfert/Emu) hBrems",
166 "log10(Etransfert/Emu) muIonization",
167 "log10(Etransfert/Emu) muPair",
168 "log10(Etransfert/Emu) muBrems",
169 "log10(Etransfert/Emu) muNuclear"
175 if (unit !=
"none") {
176 titl = title[ih] +
" (" + unit +
")";
186 fWidth[ih] = fUnit[ih]*(vmax-vmin)/nbins;
190 G4cout <<
"----> SetHisto " << ih <<
": " << titl <<
"; "
191 << nbins <<
" bins from "
192 << vmin <<
" " << unit <<
" to " << vmax <<
" " << unit <<
G4endl;
200 if (ih >= MaxHisto) {
201 G4cout <<
"---> warning from HistoManager::Normalize() : histo " << ih
202 <<
" fac= " << fac <<
G4endl;
206 if (fHistPt[ih]) fHistPt[ih]->scale(fac);
213 if (ih < MaxHisto) { fAscii[ih] =
true; fAscii[0] =
true; }
215 G4cout <<
"---> warning from HistoManager::PrintHisto() : histo " << ih
216 <<
"does not exist" <<
G4endl;
223 void HistoManager::saveAscii()
225 if (!fAscii[0])
return;
228 std::ofstream File(name, std::ios::out);
231 <<
"\n---> HistoManager::saveAscii(): cannot open " << name <<
G4endl;
235 File.setf( std::ios::scientific, std::ios::floatfield );
239 if (fHistPt[ih] && fAscii[ih]) {
241 File <<
"\n 1D histogram " << ih <<
": " << fTitle[ih]
242 <<
"\n \n \t X \t\t Y" <<
G4endl;
244 for (
G4int iBin=0; iBin<fNbins[ih]; iBin++) {
245 File <<
" " << iBin <<
"\t"
246 << fHistPt[ih]->axis().bin_center(iBin) <<
"\t"
247 << fHistPt[ih]->bin_height(iBin)
void FillHisto(G4int id, G4double bin, G4double weight=1.0)
void Normalize(G4int id, G4double fac)
static G4double GetValueOf(const G4String &)
G4GLOB_DLL std::ostream G4cout
ExG4HbookAnalysisManager G4AnalysisManager
void SetHisto(G4int, G4int, G4double, G4double, const G4String &unit="none")
subroutine title(NA, NB, NCA, NCB)