35 #include "HistoManager.hh"
36 #include "HistoMessenger.hh"
43 fileName[0] =
"fanocavity2";
64 delete fHistoMessenger;
72 if (fNbHist == 0)
return;
78 analysisManager->SetVerboseLevel(1);
79 G4String extension = analysisManager->GetFileType();
80 fileName[1] = fileName[0] +
"." + extension;
84 G4bool fileOpen = analysisManager->OpenFile(fileName[0]);
86 G4cout <<
"\n---> HistoManager::book(): cannot open " << fileName[1]
93 analysisManager->SetFirstHistoId(1);
97 fHistId[k] = analysisManager->CreateH1( fLabel[k], fTitle[k],
98 fNbins[k], fVmin[k], fVmax[k]);
99 fHistPt[k] = analysisManager->GetH1(fHistId[k]);
105 G4cout <<
"\n----> Histogram file is opened in " << fileName[1] <<
G4endl;
114 analysisManager->Write();
115 analysisManager->CloseFile();
117 G4cout <<
"\n----> Histograms are saved in " << fileName[1] <<
G4endl;
119 delete G4AnalysisManager::Instance();
129 G4cout <<
"---> warning from HistoManager::FillHisto() : histo " << ih
130 <<
"does not fExist; e= " << e <<
" w= " << weight <<
G4endl;
134 if (fHistPt[ih]) fHistPt[ih]->fill(e/fUnit[ih], weight);
143 G4cout <<
"---> warning from HistoManager::SetHisto() : histo " << ih
144 <<
"does not fExist" <<
G4endl;
148 const G4String id[] = {
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9" ,
"10",
"11"};
152 "emission point of e-",
153 "energy spectrum of e-",
154 "theta distribution of e-",
155 "emission point of e- hitting cavity",
156 "energy spectrum of e- when entering in cavity",
157 "theta distribution of e- before enter in cavity",
158 "theta distribution of e- at first step in cavity",
159 "track segment of e- in cavity",
160 "step size of e- in wall",
161 "step size of e- in cavity",
162 "energy deposit in cavity per track"
168 if (unit !=
"none") {
169 titl = title[ih] +
" (" + unit +
")";
179 fWidth[ih] = fUnit[ih]*(vmax-vmin)/nbins;
183 G4cout <<
"----> SetHisto " << ih <<
": " << titl <<
"; "
184 << nbins <<
" bins from "
185 << vmin <<
" " << unit <<
" to " << vmax <<
" " << unit <<
G4endl;
193 if (ih >= MaxHisto) {
194 G4cout <<
"---> warning from HistoManager::Normalize() : histo " << ih
195 <<
" fac= " << fac <<
G4endl;
199 if (fHistPt[ih]) fHistPt[ih]->scale(fac);
206 if (ih < MaxHisto) { fAscii[ih] =
true; fAscii[0] =
true; }
208 G4cout <<
"---> warning from HistoManager::PrintHisto() : histo " << ih
209 <<
"does not exist" <<
G4endl;
216 void HistoManager::saveAscii()
218 if (!fAscii[0])
return;
221 std::ofstream File(name, std::ios::out);
224 <<
"\n---> HistoManager::saveAscii(): cannot open " << name <<
G4endl;
228 File.setf( std::ios::scientific, std::ios::floatfield );
232 if (fHistPt[ih] && fAscii[ih]) {
234 File <<
"\n 1D histogram " << ih <<
": " << fTitle[ih]
235 <<
"\n \n \t X \t\t Y" <<
G4endl;
237 for (
G4int iBin=0; iBin<fNbins[ih]; iBin++) {
238 File <<
" " << iBin <<
"\t"
239 << fHistPt[ih]->axis().bin_center(iBin) <<
"\t"
240 << fHistPt[ih]->bin_height(iBin)