35 #include "DetectorConstruction.hh"
36 #include "HistoManager.hh"
49 fParticle(0), fEkin(0.),
50 nbOfModules(0), nbOfLayers(0), kLayerMax(0),
51 EtotCalor(0.), Etot2Calor(0.), EvisCalor(0.), Evis2Calor(0.),
56 kLayerMax = nbOfModules*nbOfLayers + 1;
60 EtotLayer.resize(kLayerMax); Etot2Layer.resize(kLayerMax);
61 EvisLayer.resize(kLayerMax); Evis2Layer.resize(kLayerMax);
62 for (
G4int k=0; k<kLayerMax; k++) {
63 EtotLayer[k] = Etot2Layer[k] = EvisLayer[k] = Evis2Layer[k] = 0.0;
66 EtotCalor = Etot2Calor = EvisCalor = Evis2Calor = Eleak = Eleak2 = 0.;
67 EdLeak[0] = EdLeak[1] = EdLeak[2] = 0.;
89 EtotLayer[layer] += Etot; Etot2Layer[layer] += Etot*Etot;
90 EvisLayer[layer] += Evis; Evis2Layer[layer] += Evis*Evis;
99 EtotCalor += etot; Etot2Calor += etot*etot;
100 EvisCalor += evis; Evis2Calor += evis*evis;
101 Eleak += eleak; Eleak2 += eleak*eleak;
117 const Run* localRun =
static_cast<const Run*
>(run);
120 fParticle = localRun->fParticle;
121 fEkin = localRun->fEkin;
125 for (
G4int k=0; k<kLayerMax; k++) {
126 EtotLayer[k] += localRun->EtotLayer[k];
127 Etot2Layer[k] += localRun->Etot2Layer[k];
128 EvisLayer[k] += localRun->EvisLayer[k];
129 Evis2Layer[k] += localRun->Evis2Layer[k];
132 EtotCalor += localRun->EtotCalor;
133 Etot2Calor += localRun->Etot2Calor;
134 EvisCalor += localRun->EvisCalor;
135 Evis2Calor += localRun->Evis2Calor;
136 Eleak += localRun->Eleak;
137 Eleak2 += localRun->Eleak2;
138 EdLeak[0] += localRun->EdLeak[0];
139 EdLeak[1] += localRun->EdLeak[1];
140 EdLeak[2] += localRun->EdLeak[2];
160 G4cout <<
" The run was " << nbEvents <<
" " << partName <<
" of "
163 G4cout <<
"------------------------------------------------------------"
168 if (nbEvents == 0)
return;
172 std::ios::fmtflags mode =
G4cout.flags();
178 <<
"total Energy (rms/mean) "
179 <<
"visible Energy (rms/mean)" <<
G4endl;
183 G4double meanEtot,meanEtot2,varianceEtot,rmsEtot,resEtot;
184 G4double meanEvis,meanEvis2,varianceEvis,rmsEvis,resEvis;
186 for (
G4int i1=1; i1<kLayerMax; i1++) {
188 meanEtot = EtotLayer[i1] /nbEvents;
189 meanEtot2 = Etot2Layer[i1]/nbEvents;
190 varianceEtot = meanEtot2 - meanEtot*meanEtot;
191 resEtot = rmsEtot = 0.;
192 if (varianceEtot > 0.) rmsEtot = std::sqrt(varianceEtot);
193 if (meanEtot > 0.) resEtot = 100*rmsEtot/meanEtot;
194 analysisManager->FillH1(3, i1+0.5, meanEtot);
197 meanEvis = EvisLayer[i1] /nbEvents;
198 meanEvis2 = Evis2Layer[i1]/nbEvents;
199 varianceEvis = meanEvis2 - meanEvis*meanEvis;
200 resEvis = rmsEvis = 0.;
201 if (varianceEvis > 0.) rmsEvis = std::sqrt(varianceEvis);
202 if (meanEvis > 0.) resEvis = 100*rmsEvis/meanEvis;
203 analysisManager->FillH1(4, i1+0.5, meanEvis);
208 <<
"\n layer " << i1 <<
": "
209 << std::setprecision(5)
210 << std::setw(6) <<
G4BestUnit(meanEtot,
"Energy") <<
" +- "
211 << std::setprecision(4)
212 << std::setw(5) <<
G4BestUnit( rmsEtot,
"Energy") <<
" ("
213 << std::setprecision(2)
214 << std::setw(3) << resEtot <<
" %)"
216 << std::setprecision(5)
217 << std::setw(6) <<
G4BestUnit(meanEvis,
"Energy") <<
" +- "
218 << std::setprecision(4)
219 << std::setw(5) <<
G4BestUnit( rmsEvis,
"Energy") <<
" ("
220 << std::setprecision(2)
221 << std::setw(3) << resEvis <<
" %)";
226 meanEtot = EtotCalor /nbEvents;
227 meanEtot2 = Etot2Calor/nbEvents;
228 varianceEtot = meanEtot2 - meanEtot*meanEtot;
229 resEtot = rmsEtot = 0.;
230 if (varianceEtot > 0.) rmsEtot = std::sqrt(varianceEtot);
231 if (meanEtot > 0.) resEtot = 100*rmsEtot/meanEtot;
234 meanEvis = EvisCalor /nbEvents;
235 meanEvis2 = Evis2Calor/nbEvents;
236 varianceEvis = meanEvis2 - meanEvis*meanEvis;
237 resEvis = rmsEvis = 0.;
238 if (varianceEvis > 0.) rmsEvis = std::sqrt(varianceEvis);
239 if (meanEvis > 0.) resEvis = 100*rmsEvis/meanEvis;
244 <<
"\n total calor : "
245 << std::setprecision(5)
246 << std::setw(6) <<
G4BestUnit(meanEtot,
"Energy") <<
" +- "
247 << std::setprecision(4)
248 << std::setw(5) <<
G4BestUnit( rmsEtot,
"Energy") <<
" ("
249 << std::setprecision(2)
250 << std::setw(3) << resEtot <<
" %)"
252 << std::setprecision(5)
253 << std::setw(6) <<
G4BestUnit(meanEvis,
"Energy") <<
" +- "
254 << std::setprecision(4)
255 << std::setw(5) <<
G4BestUnit( rmsEvis,
"Energy") <<
" ("
256 << std::setprecision(2)
257 << std::setw(3) << resEvis <<
" %)";
259 G4cout <<
"\n------------------------------------------------------------"
263 G4double meanEleak,meanEleak2,varianceEleak,rmsEleak,ratio;
264 meanEleak = Eleak /nbEvents;
265 meanEleak2 = Eleak2/nbEvents;
266 varianceEleak = meanEleak2 - meanEleak*meanEleak;
268 if (varianceEleak > 0.) rmsEleak = std::sqrt(varianceEleak);
269 ratio = 100*meanEleak/fEkin;
271 G4double forward = 100*EdLeak[0]/(nbEvents*fEkin);
272 G4double bakward = 100*EdLeak[1]/(nbEvents*fEkin);
273 G4double lateral = 100*EdLeak[2]/(nbEvents*fEkin);
279 << std::setprecision(5)
280 << std::setw(6) <<
G4BestUnit(meanEleak,
"Energy") <<
" +- "
281 << std::setprecision(4)
282 << std::setw(5) <<
G4BestUnit( rmsEleak,
"Energy")
283 <<
"\n Eleak/Ebeam ="
284 << std::setprecision(3)
285 << std::setw(4) << ratio <<
" % ( forward ="
286 << std::setw(4) << forward <<
" %; backward ="
287 << std::setw(4) << bakward <<
" %; lateral ="
288 << std::setw(4) << lateral <<
" %)"
291 G4cout.setf(mode,std::ios::floatfield);
296 analysisManager->ScaleH1(5,factor);
virtual void Merge(const G4Run *)
void SumEvents_2(G4double, G4double, G4double)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
void DetailedLeakage(G4int, G4double)
void SumEvents_1(G4int, G4double, G4double)
G4double energy(const ThreeVector &p, const G4double m)
Detector construction class to define materials and geometry.
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
void PrintCalorParameters()
virtual void Merge(const G4Run *)
G4CsvAnalysisManager G4AnalysisManager