35 #include "HistoManager.hh"
36 #include "HistoMessenger.hh"
43 fileName[0] =
"testem12";
67 delete fHistoMessenger;
75 if (fNbHist == 0)
return;
81 analysisManager->SetVerboseLevel(1);
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;
117 analysisManager->Write();
118 analysisManager->CloseFile();
120 G4cout <<
"\n----> Histograms are saved in " << fileName[1] <<
G4endl;
122 delete G4AnalysisManager::Instance();
132 G4cout <<
"---> warning from HistoManager::FillHisto() : histo " << ih
133 <<
"does not fExist; e= " << e <<
" w= " << weight <<
G4endl;
137 if (fHistPt[ih]) fHistPt[ih]->fill(e/fUnit[ih], weight);
146 G4cout <<
"---> warning from HistoManager::SetHisto() : histo " << ih
147 <<
"does not fExist" <<
G4endl;
151 const G4String id[] = {
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8" };
154 "dE/dr (MeV/mm) along radius",
155 "total Energy deposited in absorber",
156 "true track length of the primary particle",
157 "true step size of the primary particle",
158 "projected range of the primary particle",
159 "true track length of charged secondaries",
160 "true step size of charged secondaries",
161 "d(E/E0)/d(r/r0) along r/r0"
167 if (unit !=
"none") {
168 titl = title[ih] +
" (" + unit +
")";
178 fWidth[ih] = fUnit[ih]*(vmax-vmin)/nbins;
182 G4cout <<
"----> SetHisto " << ih <<
": " << titl <<
"; "
183 << nbins <<
" bins from "
184 << vmin <<
" " << unit <<
" to " << vmax <<
" " << unit <<
G4endl;
192 if (ih >= MaxHisto) {
193 G4cout <<
"---> warning from HistoManager::Normalize() : histo " << ih
194 <<
" fac= " << fac <<
G4endl;
198 if (fHistPt[ih]) fHistPt[ih]->scale(fac);
205 if (ih < MaxHisto) { fAscii[ih] =
true; fAscii[0] =
true; }
207 G4cout <<
"---> warning from HistoManager::PrintHisto() : histo " << ih
208 <<
"does not exist" <<
G4endl;
215 void HistoManager::saveAscii()
217 if (!fAscii[0])
return;
220 std::ofstream File(name, std::ios::out);
223 <<
"\n---> HistoManager::saveAscii(): cannot open " << name <<
G4endl;
227 File.setf( std::ios::scientific, std::ios::floatfield );
231 if (fHistPt[ih] && fAscii[ih]) {
233 File <<
"\n 1D histogram " << ih <<
": " << fTitle[ih]
234 <<
"\n \n \t X \t\t Y" <<
G4endl;
236 for (
G4int iBin=0; iBin<fNbins[ih]; iBin++) {
237 File <<
" " << iBin <<
"\t"
238 << fHistPt[ih]->axis().bin_center(iBin) <<
"\t"
239 << fHistPt[ih]->bin_height(iBin)
257 stepMax = frac*fWidth[ih];
262 if (!fRangeFlag) fCsdaRange = range;
263 if (fCsdaRange > 0.) stepMax = std::min(stepMax,frac*fWidth[ih]*fCsdaRange);
266 G4cout <<
"\n---> stepMax from HistoManager = "