Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Histo Class Reference

#include <Histo.hh>

Public Member Functions

 Histo ()
 
 ~Histo ()
 
void Book ()
 
void Save ()
 
void Add1D (const G4String &, const G4String &, G4int nb, G4double x1, G4double x2, G4double u=1.)
 
void SetHisto1D (G4int, G4int, G4double, G4double, G4double)
 
void Activate (G4int, G4bool)
 
void Fill (G4int, G4double, G4double)
 
void ScaleH1 (G4int, G4double)
 
void AddTuple (const G4String &)
 
void AddTupleI (const G4String &)
 
void AddTupleF (const G4String &)
 
void AddTupleD (const G4String &)
 
void FillTupleI (G4int, G4int)
 
void FillTupleF (G4int, G4float)
 
void FillTupleD (G4int, G4double)
 
void AddRow ()
 
void SetFileName (const G4String &)
 
void SetFileType (const G4String &)
 
void SetVerbose (G4int val)
 
G4bool IsActive () const
 
 Histo ()
 
 ~Histo ()
 
void Book ()
 
void Save ()
 
void Add1D (const G4String &, const G4String &, G4int nb, G4double x1, G4double x2, G4double u=1.)
 
void SetHisto1D (G4int, G4int, G4double, G4double, G4double)
 
void Activate (G4int, G4bool)
 
void Fill (G4int, G4double, G4double)
 
void ScaleH1 (G4int, G4double)
 
void AddTuple (const G4String &)
 
void AddTupleI (const G4String &)
 
void AddTupleF (const G4String &)
 
void AddTupleD (const G4String &)
 
void FillTupleI (G4int, G4int)
 
void FillTupleF (G4int, G4float)
 
void FillTupleD (G4int, G4double)
 
void AddRow ()
 
void SetFileName (const G4String &)
 
void SetFileType (const G4String &)
 
void SetVerbose (G4int val)
 
G4bool IsActive () const
 
 Histo ()
 
 ~Histo ()
 
void Book ()
 
void Save ()
 
void Add1D (const G4String &, const G4String &, G4int nb, G4double x1, G4double x2, G4double u=1.)
 
void SetHisto1D (G4int, G4int, G4double, G4double, G4double)
 
void Activate (G4int, G4bool)
 
void Fill (G4int, G4double, G4double)
 
void ScaleH1 (G4int, G4double)
 
void AddTuple (const G4String &)
 
void AddTupleI (const G4String &)
 
void AddTupleF (const G4String &)
 
void AddTupleD (const G4String &)
 
void FillTupleI (G4int, G4int)
 
void FillTupleF (G4int, G4float)
 
void FillTupleD (G4int, G4double)
 
void AddRow ()
 
void SetFileName (const G4String &)
 
void SetFileType (const G4String &)
 
void SetVerbose (G4int val)
 
G4bool IsActive () const
 
 Histo ()
 
 ~Histo ()
 
void Book ()
 
void Save ()
 
void Add1D (const G4String &, const G4String &, G4int nb, G4double x1, G4double x2, G4double u=1.)
 
void SetHisto1D (G4int, G4int, G4double, G4double, G4double)
 
void Activate (G4int, G4bool)
 
void Fill (G4int, G4double, G4double)
 
void ScaleH1 (G4int, G4double)
 
void AddTuple (const G4String &)
 
void AddTupleI (const G4String &)
 
void AddTupleF (const G4String &)
 
void AddTupleD (const G4String &)
 
void FillTupleI (G4int, G4int)
 
void FillTupleF (G4int, G4float)
 
void FillTupleD (G4int, G4double)
 
void AddRow ()
 
void SetFileName (const G4String &)
 
void SetFileType (const G4String &)
 
void SetVerbose (G4int val)
 
G4bool IsActive () const
 
 Histo ()
 
 ~Histo ()
 
void BeginOfHisto ()
 
void EndOfHisto ()
 
void ScoreNewTrack (const G4Track *aTrack)
 
void AddPhantomStep (G4double e, G4double r1, G4double z1, G4double r2, G4double z2, G4double r0, G4double z0)
 
void AddPhantomGamma (G4double e, G4double r)
 
void SetHistoName (const G4String &name)
 
void AddStepInTarget ()
 
void SetVerbose (G4int val)
 
G4int GetVerbose () const
 
void SetNumberDivZ (G4int val)
 
G4int GetNumberDivZ () const
 
void SetNumberDivR (G4int val)
 
G4int GetNumberDivR () const
 
void SetNumberDivE (G4int val)
 
void SetAbsorberZ (G4double val)
 
void SetAbsorberR (G4double val)
 
void SetScoreZ (G4double val)
 
void SetMaxEnergy (G4double val)
 
G4double GetMaxEnergy () const
 
void SetCheckVolume (G4VPhysicalVolume *v)
 
void SetGasVolume (G4VPhysicalVolume *v)
 
void SetPhantom (G4VPhysicalVolume *v)
 
void SetTarget1 (G4VPhysicalVolume *v)
 
void SetTarget2 (G4VPhysicalVolume *v)
 

Static Public Member Functions

static HistoGetPointer ()
 

Detailed Description

Definition at line 56 of file Histo.hh.

Constructor & Destructor Documentation

Histo::Histo ( )

Definition at line 51 of file Histo.cc.

52  : fManager(0),
53  fMessenger(0)
54 {
55  fMessenger = new HistoMessenger(this);
56 
57  fHistName = "test";
58  fHistType = "root";
59  fTupleName = "tuple";
60  fTupleTitle = "test";
61  fNHisto = 0;
62  fVerbose = 0;
63  fDefaultAct = true;
64  fHistoActive= false;
65  fNtupleActive= false;
66 }
Histo::~Histo ( )

Definition at line 70 of file Histo.cc.

71 {
72  delete fMessenger;
73  delete fManager;
74 }
Histo::Histo ( )
Histo::~Histo ( )
Histo::Histo ( )
Histo::~Histo ( )
Histo::Histo ( )
Histo::~Histo ( )
Histo::Histo ( )
Histo::~Histo ( )

Member Function Documentation

void Histo::Activate ( G4int  i,
G4bool  val 
)

Definition at line 207 of file Histo.cc.

208 {
209  if(fVerbose > 1) {
210  G4cout << "Histo::Activate: Histogram: #" << i << " "
211  << val << G4endl;
212  }
213  if(i>=0 && i<fNHisto) {
214  fActive[i] = val;
215  if(val) { fHistoActive = true; }
216  }
217 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void Histo::Activate ( G4int  ,
G4bool   
)
void Histo::Activate ( G4int  ,
G4bool   
)
void Histo::Activate ( G4int  ,
G4bool   
)
void Histo::Add1D ( const G4String id,
const G4String name,
G4int  nb,
G4double  x1,
G4double  x2,
G4double  u = 1. 
)

Definition at line 161 of file Histo.cc.

163 {
164  if(fVerbose > 0) {
165  G4cout << "Histo::Add1D: New histogram will be booked: #" << id
166  << " <" << name
167  << " " << nb << " " << x1 << " " << x2 << " " << u
168  << G4endl;
169  }
170  ++fNHisto;
171  x1 /= u;
172  x2 /= u;
173  fActive.push_back(fDefaultAct);
174  fBins.push_back(nb);
175  fXmin.push_back(x1);
176  fXmax.push_back(x2);
177  fUnit.push_back(u);
178  fIds.push_back(id);
179  fTitles.push_back(name);
180  fHisto.push_back(-1);
181 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void Histo::Add1D ( const G4String ,
const G4String ,
G4int  nb,
G4double  x1,
G4double  x2,
G4double  u = 1. 
)
void Histo::Add1D ( const G4String ,
const G4String ,
G4int  nb,
G4double  x1,
G4double  x2,
G4double  u = 1. 
)
void Histo::Add1D ( const G4String ,
const G4String ,
G4int  nb,
G4double  x1,
G4double  x2,
G4double  u = 1. 
)
void Histo::AddPhantomGamma ( G4double  e,
G4double  r 
)

Definition at line 399 of file Histo.cc.

400 {
401  e /= MeV;
402  fSumR += e;
403  G4int bin = (G4int)(e/fStepE);
404  if(bin >= fNBinsE) { bin = fNBinsE-1; }
405  fGammaE[bin] += e;
406  G4int bin1 = (G4int)(r/fStepR);
407  if(bin1 >= fNBinsR) { bin1 = fNBinsR-1; }
408  if(fAnalysisManager) {
409  fAnalysisManager->FillH1(fHisto[6],e,1.0);
410  fAnalysisManager->FillH1(fHisto[9],r,e*fVolumeR[bin1]);
411  }
412 }
tuple bin
Definition: plottest35.py:22
int G4int
Definition: G4Types.hh:78
G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
static constexpr double MeV
Definition: G4SIunits.hh:214

Here is the call graph for this function:

void Histo::AddPhantomStep ( G4double  e,
G4double  r1,
G4double  z1,
G4double  r2,
G4double  z2,
G4double  r0,
G4double  z0 
)

Definition at line 416 of file Histo.cc.

419 {
420  ++fNstep;
421  G4int nzbin = (G4int)(z0/fStepZ);
422  if(fVerbose > 1) {
423  G4cout << "Histo: edep(MeV)= " << edep/MeV << " at binz= " << nzbin
424  << " r1= " << r1 << " z1= " << z1
425  << " r2= " << r2 << " z2= " << z2
426  << " r0= " << r0 << " z0= " << z0
427  << G4endl;
428  }
429  if(nzbin == fScoreBin) {
430  G4int bin = (G4int)(r0/fStepR);
431  if(bin >= fNBinsR) { bin = fNBinsR-1; }
432  double w = edep*fVolumeR[bin];
433  fEdep[bin] += w;
434  if(fAnalysisManager) {
435  fAnalysisManager->FillH1(fHisto[0],r0,w);
436  fAnalysisManager->FillH1(fHisto[1],r0,w);
437  fAnalysisManager->FillH1(fHisto[2],r0,w);
438  }
439  }
440  G4int bin1 = (G4int)(z1/fStepZ);
441  if(bin1 >= fNBinsZ) { bin1 = fNBinsZ-1; }
442  G4int bin2 = (G4int)(z2/fStepZ);
443  if(bin2 >= fNBinsZ) { bin2 = fNBinsZ-1; }
444  if(bin1 == bin2) {
445  if(fAnalysisManager) {
446  fAnalysisManager->FillH1(fHisto[3],z0,edep);
447  if(r1 < fStepR) {
448  G4double w = edep;
449  if(r2 > fStepR) { w *= (fStepR - r1)/(r2 - r1); }
450  fAnalysisManager->FillH1(fHisto[4],z0,w);
451  }
452  }
453  } else {
454  G4int bin;
455 
456  if(bin2 < bin1) {
457  bin = bin2;
458  G4double z = z2;
459  bin2 = bin1;
460  z2 = z1;
461  bin1 = bin;
462  z1 = z;
463  }
464  G4double zz1 = z1;
465  G4double zz2 = (bin1+1)*fStepZ;
466  G4double rr1 = r1;
467  G4double dz = z2 - z1;
468  G4double dr = r2 - r1;
469  G4double rr2 = r1 + dr*(zz2-zz1)/dz;
470  for(bin=bin1; bin<=bin2; bin++) {
471  if(fAnalysisManager) {
472  G4double de = edep*(zz2 - zz1)/dz;
473  G4double zf = (zz1+zz2)*0.5;
474  { fAnalysisManager->FillH1(fHisto[3],zf,de); }
475  if(rr1 < fStepR) {
476  G4double w = de;
477  if(rr2 > fStepR) w *= (fStepR - rr1)/(rr2 - rr1);
478  { fAnalysisManager->FillH1(fHisto[4],zf,w); }
479  }
480  }
481  zz1 = zz2;
482  zz2 = std::min(z2, zz1+fStepZ);
483  rr1 = rr2;
484  rr2 = rr1 + dr*(zz2 - zz1)/dz;
485  }
486  }
487 }
tuple bin
Definition: plottest35.py:22
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

void Histo::AddRow ( )
void Histo::AddRow ( )
void Histo::AddRow ( )

Definition at line 342 of file Histo.cc.

343 {
344  if(!fNtupleActive) { return; }
345  fManager->AddNtupleRow();
346 }

Here is the call graph for this function:

void Histo::AddRow ( )
void Histo::AddStepInTarget ( )
inline

Definition at line 91 of file Histo.hh.

91 { ++fNstepTarget;};
void Histo::AddTuple ( const G4String w1)

Definition at line 254 of file Histo.cc.

255 {
256  fTupleTitle = w1;
257 }
void Histo::AddTuple ( const G4String )
void Histo::AddTuple ( const G4String )
void Histo::AddTuple ( const G4String )
void Histo::AddTupleD ( const G4String )
void Histo::AddTupleD ( const G4String w1)

Definition at line 279 of file Histo.cc.

280 {
281  fNtupleActive = true;
282  fNtupleD.push_back(w1);
283  fTupleD.push_back(-1);
284 }
void Histo::AddTupleD ( const G4String )
void Histo::AddTupleD ( const G4String )
void Histo::AddTupleF ( const G4String )
void Histo::AddTupleF ( const G4String w1)

Definition at line 270 of file Histo.cc.

271 {
272  fNtupleActive = true;
273  fNtupleF.push_back(w1);
274  fTupleF.push_back(-1);
275 }
void Histo::AddTupleF ( const G4String )
void Histo::AddTupleF ( const G4String )
void Histo::AddTupleI ( const G4String )
void Histo::AddTupleI ( const G4String w1)

Definition at line 261 of file Histo.cc.

262 {
263  fNtupleActive = true;
264  fNtupleI.push_back(w1);
265  fTupleI.push_back(-1);
266 }
void Histo::AddTupleI ( const G4String )
void Histo::AddTupleI ( const G4String )
void Histo::BeginOfHisto ( )

Definition at line 107 of file Histo.cc.

108 {
109  G4cout << "### Histo start initialisation nHisto= " << fNHisto << G4endl;
110 
111  fNevt = fNelec = fNposit= fNgam = fNstep = fNgamPh = fNgamTar =
112  fNeTar = fNePh = fNstepTarget = 0;
113  fSumR = 0.0;
114  if(fNBinsR>1000) { SetNumberDivR(40); }
115 
116  fStepZ = fAbsorberZ/(G4double)fNBinsZ;
117  fStepR = fAbsorberR/(G4double)fNBinsR;
118  fStepE = fMaxEnergy/(G4double)fNBinsE;
119  fScoreBin = (G4int)(fScoreZ/fStepZ + 0.5);
120 
121  G4cout << " "<< fNBinsR << " bins R stepR= " << fStepR/mm << " mm "
122  << G4endl;
123  G4cout << " "<< fNBinsZ << " bins Z stepZ= " << fStepZ/mm << " mm "
124  << G4endl;
125  G4cout << " "<< fNBinsE << " bins E stepE= " << fStepE/MeV << " MeV "
126  << G4endl;
127  G4cout << " "<< fScoreBin << "-th bin in Z is used for R distribution"
128  << G4endl;
129 
130  fVolumeR.resize(fNBinsR);
131  fEdep.resize(fNBinsR, 0.0);
132  fGammaE.resize(fNBinsE, 0.0);
133 
134  G4double r1 = 0.0;
135  G4double r2 = fStepR;
136  for(G4int i=0; i<fNBinsR; ++i) {
137  fVolumeR[i] = cm*cm/(pi*(r2*r2 - r1*r1));
138  r1 = r2;
139  r2 += fStepR;
140  }
141 
142  if(fHistName != "") {
143  if(!fAnalysisManager) {
144  fAnalysisManager = G4RootAnalysisManager::Instance();
145  BookHisto();
146  }
147  if(fVerbose > 0) {
148  G4cout << "Histo: Histograms are booked and run has been started"
149  << G4endl;
150  }
151  } else if(fVerbose > 0) {
152  G4cout << "Histo: Histograms are not booked because file name is not set"
153  << G4endl;
154  }
155 }
void SetNumberDivR(G4int val)
Definition: Histo.hh:99
static constexpr double mm
Definition: G4SIunits.hh:115
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
static G4RootAnalysisManager * Instance()
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
static constexpr double pi
Definition: G4SIunits.hh:75
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

void Histo::Book ( )
void Histo::Book ( )
void Histo::Book ( )

Definition at line 78 of file Histo.cc.

79 {
80  if(!(fHistoActive || fNtupleActive)) { return; }
81 
82  // Always creating analysis manager
83  fManager = G4RootAnalysisManager::Instance();
84 
85  // Creating a tree mapped to a new hbook file.
86  G4String nam = fHistName + "." + fHistType;
87 
88  // Open file histogram file
89  if(!fManager->OpenFile(nam)) {
90  G4cout << "Histo::Book: ERROR open file <" << nam << ">" << G4endl;
91  fHistoActive = false;
92  fNtupleActive = false;
93  return;
94  }
95  G4cout << "### Histo::Save: Opended file <" << nam << "> for "
96  << fNHisto << " histograms " << G4endl;
97 
98  // Creating an 1-dimensional histograms in the root directory of the tree
99  for(G4int i=0; i<fNHisto; ++i) {
100  if(fActive[i]) {
101  G4String ss = "h" + fIds[i];
102  fHisto[i] =
103  fManager->CreateH1(ss, fTitles[i], fBins[i], fXmin[i], fXmax[i]);
104  if(fVerbose > 0) {
105  G4cout << "Created histogram #" << i << " id= " << fHisto[i]
106  << " " << ss << " " << fTitles[i] << G4endl;
107  }
108  }
109  }
110  // Creating a tuple factory, whose tuples will be handled by the tree
111  if(fNtupleActive) {
112  fManager->CreateNtuple(fTupleName,fTupleTitle);
113  G4int i;
114  G4int n = fNtupleI.size();
115  for(i=0; i<n; ++i) {
116  if(fTupleI[i] == -1) {
117  fTupleI[i] = fManager->CreateNtupleIColumn(fNtupleI[i]);
118  }
119  }
120  n = fNtupleF.size();
121  for(i=0; i<n; ++i) {
122  if(fTupleF[i] == -1) {
123  fTupleF[i] = fManager->CreateNtupleFColumn(fNtupleF[i]);
124  }
125  }
126  n = fNtupleD.size();
127  for(i=0; i<n; ++i) {
128  if(fTupleD[i] == -1) {
129  fTupleD[i] = fManager->CreateNtupleDColumn(fNtupleD[i]);
130  }
131  }
132  }
133 }
G4int CreateNtupleIColumn(const G4String &name)
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
G4int CreateNtuple(const G4String &name, const G4String &title)
int G4int
Definition: G4Types.hh:78
G4bool OpenFile(const G4String &fileName="")
G4GLOB_DLL std::ostream G4cout
const G4int n
G4int CreateNtupleFColumn(const G4String &name)
static G4RootAnalysisManager * Instance()
#define G4endl
Definition: G4ios.hh:61
G4int CreateNtupleDColumn(const G4String &name)

Here is the call graph for this function:

void Histo::Book ( )
void Histo::EndOfHisto ( )

Definition at line 159 of file Histo.cc.

160 {
161 
162  G4cout << "Histo: End of run actions are started" << G4endl;
163 
164  // average
165 
166  G4cout<<"========================================================"<<G4endl;
167  G4double x = (G4double)fNevt;
168  if(fNevt > 0) { x = 1.0/x; }
169  G4double xe = x*(G4double)fNelec;
170  G4double xg = x*(G4double)fNgam;
171  G4double xp = x*(G4double)fNposit;
172  G4double xs = x*(G4double)fNstep;
173  G4double xph= x*(G4double)fNgamPh;
174  G4double xes= x*(G4double)fNstepTarget;
175  G4double xgt= x*(G4double)fNgamTar;
176  G4double xet= x*(G4double)fNeTar;
177  G4double xphe= x*(G4double)fNePh;
178 
179  G4cout << "Number of events "
180  << std::setprecision(8) << fNevt <<G4endl;
181  G4cout
182  << std::setprecision(4) << "Average number of e- "
183  << xe << G4endl;
184  G4cout
185  << std::setprecision(4) << "Average number of gamma "
186  << xg << G4endl;
187  G4cout
188  << std::setprecision(4) << "Average number of e+ "
189  << xp << G4endl;
190  G4cout
191  << std::setprecision(4) << "Average number of steps in the phantom "
192  << xs << G4endl;
193  G4cout
194  << std::setprecision(4) << "Average number of e- steps in the target "
195  << xes << G4endl;
196  G4cout
197  << std::setprecision(4) << "Average number of g produced in the target "
198  << xgt << G4endl;
199  G4cout
200  << std::setprecision(4) << "Average number of e- produced in the target "
201  << xet << G4endl;
202  G4cout
203  << std::setprecision(4) << "Average number of g produced in the phantom "
204  << xph << G4endl;
205  G4cout
206  << std::setprecision(4) << "Average number of e- produced in the phantom "
207  << xphe << G4endl;
208  G4cout
209  << std::setprecision(4) << "Total fGamma fluence in front of the phantom "
210  << x*fSumR/MeV << " MeV " << G4endl;
211  G4cout<<"========================================================"<<G4endl;
212  G4cout<<G4endl;
213  G4cout<<G4endl;
214 
215  G4double sum = 0.0;
216  for(G4int i=0; i<fNBinsR; i++) {
217  fEdep[i] *= x;
218  sum += fEdep[i];
219  }
220 
221  if(fAnalysisManager) {
222 
223  // normalise histograms
224  for(G4int i=0; i<fNHisto; i++) {
225  fAnalysisManager->GetH1(fHisto[i])->scale(x);
226  }
227  G4double nr = fEdep[0];
228  if(nr > 0.0) { nr = 1./nr; }
229  fAnalysisManager->GetH1(fHisto[0])->scale(nr);
230 
231  nr = sum*fStepR;
232  if(nr > 0.0) { nr = 1./nr; }
233  fAnalysisManager->GetH1(fHisto[1])->scale(nr);
234 
235  fAnalysisManager->GetH1(fHisto[3])
236  ->scale(1000.0*cm3/(pi*fAbsorberR*fAbsorberR*fStepZ));
237  fAnalysisManager->GetH1(fHisto[4])
238  ->scale(1000.0*cm3*fVolumeR[0]/fStepZ);
239 
240  // Write histogram file
241  if(!fAnalysisManager->Write()) {
242  G4Exception ("Histo::Save()", "hist01", FatalException,
243  "Cannot write ROOT file.");
244  }
245  G4cout << "### Histo::Save: Histograms are saved" << G4endl;
246  if(fAnalysisManager->CloseFile() && fVerbose > 0) {
247  G4cout << " File is closed" << G4endl;
248  }
249  delete fAnalysisManager;
250  fAnalysisManager = 0;
251  }
252 }
tuple x
Definition: test.py:50
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
static constexpr double cm3
Definition: G4SIunits.hh:121
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
static constexpr double pi
Definition: G4SIunits.hh:75
double G4double
Definition: G4Types.hh:76
tools::histo::h1d * GetH1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const

Here is the call graph for this function:

void Histo::Fill ( G4int  ,
G4double  ,
G4double   
)
void Histo::Fill ( G4int  i,
G4double  x,
G4double  w 
)

Definition at line 221 of file Histo.cc.

222 {
223  if(!fHistoActive) { return; }
224  if(fVerbose > 1) {
225  G4cout << "Histo::Fill: Histogram: #" << i << " at x= " << x
226  << " weight= " << w
227  << G4endl;
228  }
229  if(i>=0 && i<fNHisto) {
230  if(fActive[i]) { fManager->FillH1(fHisto[i], x/fUnit[i], w); }
231  } else {
232  G4cout << "Histo::Fill: WARNING! wrong histogram index " << i << G4endl;
233  }
234 }
tuple x
Definition: test.py:50
G4GLOB_DLL std::ostream G4cout
G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

void Histo::Fill ( G4int  ,
G4double  ,
G4double   
)
void Histo::Fill ( G4int  ,
G4double  ,
G4double   
)
void Histo::FillTupleD ( G4int  ,
G4double   
)
void Histo::FillTupleD ( G4int  ,
G4double   
)
void Histo::FillTupleD ( G4int  ,
G4double   
)
void Histo::FillTupleD ( G4int  i,
G4double  x 
)

Definition at line 324 of file Histo.cc.

325 {
326  if(!fNtupleActive) { return; }
327  G4int n = fNtupleD.size();
328  if(i >= 0 && i < n) {
329  if(fVerbose > 1) {
330  G4cout << "Histo::FillTupleD: i= " << i << " id= " << fTupleD[i]
331  << " <" << fNtupleD[i] << "> = " << x << G4endl;
332  }
333  fManager->FillNtupleDColumn(fTupleD[i], x);
334  } else {
335  G4cout << "Histo::FillTupleD: WARNING! wrong ntuple index "
336  << i << G4endl;
337  }
338 }
tuple x
Definition: test.py:50
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4bool FillNtupleDColumn(G4int id, G4double value)
const G4int n
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void Histo::FillTupleF ( G4int  ,
G4float   
)
void Histo::FillTupleF ( G4int  ,
G4float   
)
void Histo::FillTupleF ( G4int  ,
G4float   
)
void Histo::FillTupleF ( G4int  i,
G4float  x 
)

Definition at line 306 of file Histo.cc.

307 {
308  if(!fNtupleActive) { return; }
309  G4int n = fNtupleF.size();
310  if(i >= 0 && i < n) {
311  if(fVerbose > 1) {
312  G4cout << "Histo::FillTupleF: i= " << i << " id= " << fTupleF[i]
313  << " <" << fNtupleF[i] << "> = " << x << G4endl;
314  }
315  fManager->FillNtupleFColumn(fTupleF[i], x);
316  } else {
317  G4cout << "Histo::FillTupleF: WARNING! wrong ntuple index "
318  << i << G4endl;
319  }
320 }
tuple x
Definition: test.py:50
int G4int
Definition: G4Types.hh:78
G4bool FillNtupleFColumn(G4int id, G4float value)
G4GLOB_DLL std::ostream G4cout
const G4int n
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void Histo::FillTupleI ( G4int  ,
G4int   
)
void Histo::FillTupleI ( G4int  i,
G4int  x 
)

Definition at line 288 of file Histo.cc.

289 {
290  if(!fNtupleActive) { return; }
291  G4int n = fNtupleI.size();
292  if(i >= 0 && i < n) {
293  if(fVerbose > 1) {
294  G4cout << "Histo::FillTupleI: i= " << i << " id= " << fTupleI[i]
295  << " <" << fNtupleI[i] << "> = " << x << G4endl;
296  }
297  fManager->FillNtupleIColumn(fTupleI[i], x);
298  } else {
299  G4cout << "Histo::FillTupleI: WARNING! wrong ntuple index "
300  << i << G4endl;
301  }
302 }
tuple x
Definition: test.py:50
int G4int
Definition: G4Types.hh:78
G4bool FillNtupleIColumn(G4int id, G4int value)
G4GLOB_DLL std::ostream G4cout
const G4int n
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void Histo::FillTupleI ( G4int  ,
G4int   
)
void Histo::FillTupleI ( G4int  ,
G4int   
)
G4double Histo::GetMaxEnergy ( ) const
inline

Definition at line 109 of file Histo.hh.

109 { return fMaxEnergy;};
G4int Histo::GetNumberDivR ( ) const
inline

Definition at line 100 of file Histo.hh.

100 { return fNBinsR; };
G4int Histo::GetNumberDivZ ( ) const
inline

Definition at line 97 of file Histo.hh.

97 { return fNBinsZ; };
Histo * Histo::GetPointer ( )
static

Definition at line 59 of file Histo.cc.

60 {
61  if(!fManager) {
62  static Histo manager;
63  fManager = &manager;
64  }
65  return fManager;
66 }
Definition: Histo.hh:56

Here is the caller graph for this function:

G4int Histo::GetVerbose ( ) const
inline

Definition at line 94 of file Histo.hh.

94 { return fVerbose;};

Here is the caller graph for this function:

G4bool Histo::IsActive ( ) const
inline

Definition at line 108 of file Histo.hh.

108 { return fHistoActive; };
G4bool Histo::IsActive ( ) const
inline

Definition at line 108 of file Histo.hh.

108 { return fHistoActive; };
G4bool Histo::IsActive ( ) const
inline

Definition at line 108 of file Histo.hh.

108 { return fHistoActive; };
G4bool Histo::IsActive ( ) const
inline

Definition at line 108 of file Histo.hh.

108 { return fHistoActive; };
void Histo::Save ( )
void Histo::Save ( )

Definition at line 137 of file Histo.cc.

138 {
139  if(!(fHistoActive || fNtupleActive)) { return; }
140 
141  // Creating a tree mapped to a new hbook file.
142  G4String nam = fHistName + "." + fHistType;
143 
144  // Write histogram file
145  if(!fManager->Write()) {
146  G4Exception ("Histo::Save()", "hist01", FatalException,
147  "Cannot write ROOT file.");
148  }
149  if(fVerbose > 0) {
150  G4cout << "### Histo::Save: Histograms and Ntuples are saved" << G4endl;
151  }
152  if(fManager->CloseFile() && fVerbose > 0) {
153  G4cout << " File is closed" << G4endl;
154  }
156  fManager = 0;
157 }
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4RootAnalysisManager * Instance()
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void Histo::Save ( )
void Histo::Save ( )
void Histo::ScaleH1 ( G4int  ,
G4double   
)
void Histo::ScaleH1 ( G4int  ,
G4double   
)
void Histo::ScaleH1 ( G4int  ,
G4double   
)
void Histo::ScaleH1 ( G4int  i,
G4double  x 
)

Definition at line 238 of file Histo.cc.

239 {
240  if(!fHistoActive) { return; }
241  if(fVerbose > 0) {
242  G4cout << "Histo::Scale: Histogram: #"
243  << i << " by factor " << x << G4endl;
244  }
245  if(i>=0 && i<fNHisto) {
246  if(fActive[i]) { fManager->GetH1(fHisto[i])->scale(x); }
247  } else {
248  G4cout << "Histo::Scale: WARNING! wrong histogram index " << i << G4endl;
249  }
250 }
tuple x
Definition: test.py:50
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
tools::histo::h1d * GetH1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const

Here is the call graph for this function:

void Histo::ScoreNewTrack ( const G4Track aTrack)

Definition at line 346 of file Histo.cc.

347 {
348  //Save primary parameters
349  const G4ParticleDefinition* particle = aTrack->GetParticleDefinition();
350  G4int pid = aTrack->GetParentID();
351  G4VPhysicalVolume* pv = aTrack->GetVolume();
352  const G4DynamicParticle* dp = aTrack->GetDynamicParticle();
353 
354  //primary particle
355  if(0 == pid) {
356 
357  ++fNevt;
358  if(1 < fVerbose) {
359  G4ThreeVector pos = aTrack->GetVertexPosition();
360  G4ThreeVector dir = aTrack->GetMomentumDirection();
361  G4cout << "TrackingAction: Primary "
362  << particle->GetParticleName()
363  << " Ekin(MeV)= "
364  << aTrack->GetKineticEnergy()/MeV
365  << "; pos= " << pos << "; dir= " << dir << G4endl;
366  }
367 
368  // secondary electron
369  } else if (0 < pid && particle == fElectron) {
370  if(1 < fVerbose) {
371  G4cout << "TrackingAction: Secondary electron " << G4endl;
372  }
373  AddElectron(dp);
374  if(pv == fPhantom) { AddPhantomElectron(dp); }
375  else if(pv == fTarget1 || pv == fTarget2) { AddTargetElectron(dp); }
376 
377  // secondary positron
378  } else if (0 < pid && particle == fPositron) {
379  if(1 < fVerbose) {
380  G4cout << "TrackingAction: Secondary positron " << G4endl;
381  }
382  AddPositron(dp);
383 
384  // secondary gamma
385  } else if (0 < pid && particle == fGamma) {
386  if(1 < fVerbose) {
387  G4cout << "TrackingAction: Secondary gamma; parentID= " << pid
388  << " E= " << aTrack->GetKineticEnergy() << G4endl;
389  }
390  AddPhoton(dp);
391  if(pv == fPhantom) { AddPhantomPhoton(dp); }
392  else if(pv == fTarget1 || pv == fTarget2) { AddTargetPhoton(dp); }
393 
394  }
395 }
G4int GetParentID() const
const G4DynamicParticle * GetDynamicParticle() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4double GetKineticEnergy() const
G4GLOB_DLL std::ostream G4cout
const G4ParticleDefinition * GetParticleDefinition() const
const G4ThreeVector & GetVertexPosition() const
const G4ThreeVector & GetMomentumDirection() const
G4VPhysicalVolume * GetVolume() const
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
static const G4double pos

Here is the call graph for this function:

void Histo::SetAbsorberR ( G4double  val)
inline

Definition at line 105 of file Histo.hh.

105 { fAbsorberR = val; };
void Histo::SetAbsorberZ ( G4double  val)
inline

Definition at line 104 of file Histo.hh.

104 { fAbsorberZ = val; };
void Histo::SetCheckVolume ( G4VPhysicalVolume v)
inline

Definition at line 111 of file Histo.hh.

111 { fCheckVolume = v;};
tuple v
Definition: test.py:18
void Histo::SetFileName ( const G4String nam)

Definition at line 350 of file Histo.cc.

351 {
352  fHistName = nam;
353  fHistoActive = true;
354 }
void Histo::SetFileName ( const G4String )
void Histo::SetFileName ( const G4String )
void Histo::SetFileName ( const G4String )
void Histo::SetFileType ( const G4String )
void Histo::SetFileType ( const G4String )
void Histo::SetFileType ( const G4String )
void Histo::SetFileType ( const G4String nam)

Definition at line 358 of file Histo.cc.

359 {
360  // format other than ROOT is not tested
361  if(nam == "root" || nam == "ROOT" ) { fHistType = "root"; }
362  else if(nam == "xml" || nam == "XML") { fHistType = "xml"; }
363  else if(nam == "ascii" || nam == "ASCII" ||
364  nam == "Csv" || nam == "csv" || nam == "CSV")
365  { fHistType = "ascii"; }
366 }
void Histo::SetGasVolume ( G4VPhysicalVolume v)
inline

Definition at line 112 of file Histo.hh.

112 { fGasVolume = v;};
tuple v
Definition: test.py:18
void Histo::SetHisto1D ( G4int  i,
G4int  nb,
G4double  x1,
G4double  x2,
G4double  u 
)

Definition at line 185 of file Histo.cc.

186 {
187  if(i>=0 && i<fNHisto) {
188  if(fVerbose > 0) {
189  G4cout << "Histo::SetHisto1D: #" << i
190  << " " << nb << " " << x1 << " " << x2 << " " << u
191  << G4endl;
192  }
193  fBins[i] = nb;
194  fXmin[i] = x1;
195  fXmax[i] = x2;
196  fUnit[i] = u;
197  fActive[i] = true;
198  fHistoActive = true;
199  } else {
200  G4cout << "Histo::SetHisto1D: WARNING! wrong histogram index "
201  << i << G4endl;
202  }
203 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void Histo::SetHisto1D ( G4int  ,
G4int  ,
G4double  ,
G4double  ,
G4double   
)
void Histo::SetHisto1D ( G4int  ,
G4int  ,
G4double  ,
G4double  ,
G4double   
)
void Histo::SetHisto1D ( G4int  ,
G4int  ,
G4double  ,
G4double  ,
G4double   
)
void Histo::SetHistoName ( const G4String name)
inline

Definition at line 90 of file Histo.hh.

90 { fHistName = name; };
const XML_Char * name
Definition: expat.h:151
void Histo::SetMaxEnergy ( G4double  val)
inline

Definition at line 108 of file Histo.hh.

108 { fMaxEnergy = val; };
void Histo::SetNumberDivE ( G4int  val)
inline

Definition at line 102 of file Histo.hh.

102 { fNBinsE = val; };
void Histo::SetNumberDivR ( G4int  val)
inline

Definition at line 99 of file Histo.hh.

99 { fNBinsR = val; };

Here is the caller graph for this function:

void Histo::SetNumberDivZ ( G4int  val)
inline

Definition at line 96 of file Histo.hh.

96 { fNBinsZ = val; };
void Histo::SetPhantom ( G4VPhysicalVolume v)
inline

Definition at line 113 of file Histo.hh.

113 { fPhantom = v; };
tuple v
Definition: test.py:18
void Histo::SetScoreZ ( G4double  val)
inline

Definition at line 106 of file Histo.hh.

106 { fScoreZ = val; };
void Histo::SetTarget1 ( G4VPhysicalVolume v)
inline

Definition at line 114 of file Histo.hh.

114 { fTarget1 = v; };
tuple v
Definition: test.py:18
void Histo::SetTarget2 ( G4VPhysicalVolume v)
inline

Definition at line 115 of file Histo.hh.

115 { fTarget2 = v; };
tuple v
Definition: test.py:18
void Histo::SetVerbose ( G4int  val)
inline

Definition at line 93 of file Histo.hh.

93 { fVerbose = val;};
void Histo::SetVerbose ( G4int  val)
inline

Definition at line 106 of file Histo.hh.

106 { fVerbose = val; };
void Histo::SetVerbose ( G4int  val)
inline

Definition at line 106 of file Histo.hh.

106 { fVerbose = val; };
void Histo::SetVerbose ( G4int  val)
inline

Definition at line 106 of file Histo.hh.

106 { fVerbose = val; };
void Histo::SetVerbose ( G4int  val)
inline

Definition at line 106 of file Histo.hh.

106 { fVerbose = val; };

The documentation for this class was generated from the following files: