35 #include "DetectorConstruction.hh"
36 #include "PrimaryGeneratorAction.hh"
37 #include "HistoManager.hh"
53 fDetector(det),fParticle(0),
78 const Run* localRun =
static_cast<const Run*
>(run);
81 fParticle = localRun->fParticle;
82 fEnergy = localRun->fEnergy;
85 fNbBins = localRun->fNbBins ;
90 for (
unsigned int i = 0; i < localRun->fluence.size(); i++)
92 try { fluence[i]+=localRun->fluence[i]; }
93 catch(
const std::out_of_range& oor)
94 { fluence.push_back(localRun->fluence[i]); }
97 for (
unsigned int i = 0; i < localRun->fluence1.size(); i++)
99 try { fluence1[i]+=localRun->fluence1[i]; }
100 catch(
const std::out_of_range& oor)
101 { fluence1.push_back(localRun->fluence1[i]); }
104 for (
unsigned int i = 0; i < localRun->fluence2.size(); i++)
106 try { fluence2[i]+=localRun->fluence2[i]; }
107 catch(
const std::out_of_range& oor)
108 { fluence2.push_back(localRun->fluence2[i]); }
111 for (
unsigned int i = 0; i < localRun->fNbEntries.size(); i++)
113 try { fNbEntries[i]+=localRun->fNbEntries[i]; }
114 catch(
const std::out_of_range& oor)
115 { fNbEntries.push_back(localRun->fNbEntries[i]); }
137 G4cout <<
"\n ======================== run summary ======================\n";
142 <<
G4BestUnit(fEnergy,
"Energy") <<
" through "
144 << material->
GetName() <<
" (density: "
153 analysisManager->ScaleH1(1,fac);
154 analysisManager->ScaleH1(2,fac);
155 analysisManager->ScaleH1(3,fac);
156 analysisManager->ScaleH1(5,fac);
157 analysisManager->ScaleH1(6,fac);
159 ComputeFluenceError();
166 void Run::InitFluence()
172 analysisManager->SetH1(ih, 120, 0*
mm, 240*
mm,
"mm");
176 fNbBins = analysisManager->GetH1Nbins(ih);
177 fDr = analysisManager->GetH1Width(ih);
178 fluence.resize(fNbBins, 0.);
179 fluence1.resize(fNbBins, 0.);
180 fluence2.resize(fNbBins, 0.);
181 fNbEntries.resize(fNbBins, 0);
189 if (ibin >= fNbBins)
return;
192 fluence2[ibin] += fl*fl;
197 void Run::ComputeFluenceError()
206 ds =
twopi*rmean*fDr;
208 fluence2[
bin] /= (ds*ds);
210 if (fNbEntries[
bin] > 0)
211 variance = fluence2[
bin] - (fluence[
bin]*fluence[
bin])/fNbEntries[
bin];
213 if(variance > 0.) rms = std::sqrt(variance);
219 G4double rnorm(4*
mm), radius(0.), fnorm(0.), fnorm2(0.);
222 inorm++; radius += fDr; fnorm += fluence[inorm]; fnorm2 += fluence2[inorm];
223 }
while (radius < rnorm);
229 G4double err0 = fnorm2/fnorm, err1 = 0.;
234 ratio = fluence[
bin]*scale;
237 err1 = fluence2[
bin]/fluence[
bin];
238 error = ratio*std::sqrt(err1*err1 + err0*err0);
240 fluence1[
bin] = ratio;
244 analysisManager->FillH1(4,rmean,ratio);
252 void Run::PrintFluence(
G4int TotEvents)
256 G4String fileName = name +
".ascii";
257 std::ofstream File(fileName, std::ios::out);
259 std::ios::fmtflags mode = File.flags();
260 File.setf( std::ios::scientific, std::ios::floatfield );
261 G4int prec = File.precision(3);
263 File <<
" Fluence density distribution \n "
264 <<
"\n ibin \t radius (mm) \t Nb \t fluence\t norma fl\t rms/nfl (%) \n"
271 if (fluence1[
bin] > 0.) error = 100*fluence2[
bin]/fluence1[
bin];
272 File <<
" " <<
bin <<
"\t " << rmean/
mm <<
"\t " << fNbEntries[
bin]
273 <<
"\t " << fluence[
bin]/double(TotEvents) <<
"\t " << fluence1[
bin]
279 File.setf(mode,std::ios::floatfield);
280 File.precision(prec);
virtual void Merge(const G4Run *)
static constexpr double mm
G4Material * GetMaterialScatter()
const G4String & GetName() const
G4double GetDensity() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
const G4String & GetParticleName() const
static constexpr double twopi
G4GLOB_DLL std::ostream G4cout
G4double GetThicknessScatter()
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
G4double energy(const ThreeVector &p, const G4double m)
static const G4double fac
Detector construction class to define materials and geometry.
static PROLOG_HANDLER error
void SetPrimary(G4ParticleDefinition *particle, G4double energy)
void SumFluence(G4double, G4double)
virtual void Merge(const G4Run *)
G4CsvAnalysisManager G4AnalysisManager