35 #include "HistoManager.hh"
43 fFileName[0] =
"AnaEx01";
70 analysisManager->SetVerboseLevel(2);
71 G4String extension = analysisManager->GetFileType();
72 fFileName[1] = fFileName[0] +
"." + extension;
75 analysisManager->SetHistoDirectoryName(
"histo");
76 analysisManager->SetNtupleDirectoryName(
"ntuple");
80 G4bool fileOpen = analysisManager->OpenFile(fFileName[0]);
82 G4cout <<
"\n---> HistoManager::book(): cannot open " << fFileName[1]
89 analysisManager->SetFirstHistoId(1);
90 analysisManager->SetFirstNtupleId(1);
92 fHistId[1] = analysisManager->CreateH1(
"1",
"Edep in absorber (MeV)",
94 fHistPt[1] = analysisManager->GetH1(fHistId[1]);
96 fHistId[2] = analysisManager->CreateH1(
"2",
"Edep in gap (MeV)",
98 fHistPt[2] = analysisManager->GetH1(fHistId[2]);
100 fHistId[3] = analysisManager->CreateH1(
"3",
"trackL in absorber (mm)",
102 fHistPt[3] = analysisManager->GetH1(fHistId[3]);
104 fHistId[4] = analysisManager->CreateH1(
"4",
"trackL in gap (mm)",
106 fHistPt[4] = analysisManager->GetH1(fHistId[4]);
110 analysisManager->CreateNtuple(
"101",
"Edep");
111 fNtColId[0] = analysisManager->CreateNtupleDColumn(
"Eabs");
112 fNtColId[1] = analysisManager->CreateNtupleDColumn(
"Egap");
113 analysisManager->FinishNtuple();
117 analysisManager->CreateNtuple(
"102",
"TrackL");
118 fNtColId[2] = analysisManager->CreateNtupleDColumn(
"Labs");
119 fNtColId[3] = analysisManager->CreateNtupleDColumn(
"Lgap");
120 analysisManager->FinishNtuple();
123 G4cout <<
"\n----> Histogram Tree is opened in " << fFileName[1] <<
G4endl;
132 analysisManager->Write();
133 analysisManager->CloseFile();
134 G4cout <<
"\n----> Histogram Tree is saved in " << fFileName[1] <<
G4endl;
136 delete G4AnalysisManager::Instance();
146 G4cout <<
"---> warning from HistoManager::FillHisto() : histo " << ih
147 <<
"does note xist; xbin= " << xbin <<
" w= " << weight <<
G4endl;
151 if (fHistPt[ih]) fHistPt[ih]->fill(xbin, weight);
158 if (ih >= MaxHisto) {
159 G4cout <<
"---> warning from HistoManager::Normalize() : histo " << ih
160 <<
" fac= " << fac <<
G4endl;
164 if (fHistPt[ih]) fHistPt[ih]->scale(fac);
174 analysisManager->FillNtupleDColumn(1,fNtColId[0], energyAbs);
175 analysisManager->FillNtupleDColumn(1,fNtColId[1], energyGap);
176 analysisManager->AddNtupleRow(1);
178 analysisManager->FillNtupleDColumn(2,fNtColId[2], trackLAbs);
179 analysisManager->FillNtupleDColumn(2,fNtColId[3], trackLGap);
180 analysisManager->AddNtupleRow(2);
188 G4cout <<
"\n ----> print histograms statistic \n" <<
G4endl;
191 <<
" EAbs : mean = " <<
G4BestUnit(fHistPt[1]->mean(),
"Energy")
192 <<
" rms = " <<
G4BestUnit(fHistPt[1]->rms(),
"Energy")
195 <<
" EGap : mean = " <<
G4BestUnit(fHistPt[2]->mean(),
"Energy")
196 <<
" rms = " <<
G4BestUnit(fHistPt[2]->rms(),
"Energy")
199 <<
" LAbs : mean = " <<
G4BestUnit(fHistPt[3]->mean(),
"Length")
200 <<
" rms = " <<
G4BestUnit(fHistPt[3]->rms(),
"Length")
203 <<
" LGap : mean = " <<
G4BestUnit(fHistPt[4]->mean(),
"Length")
204 <<
" rms = " <<
G4BestUnit(fHistPt[4]->rms(),
"Length")
void FillNtuple(G4int id, G4int column, G4double value)
void FillHisto(G4int id, G4double bin, 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
ExG4HbookAnalysisManager G4AnalysisManager