Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions
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 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 electromagnetic/TestEm8/include/Histo.hh.

Constructor & Destructor Documentation

Histo::Histo ( )

Definition at line 51 of file electromagnetic/TestEm8/src/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 electromagnetic/TestEm8/src/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 ( )
Histo::Histo ( )
Histo::~Histo ( )

Member Function Documentation

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

Definition at line 198 of file electromagnetic/TestEm8/src/Histo.cc.

References G4cout, and G4endl.

199 {
200  if(fVerbose > 1) {
201  G4cout << "Histo::Activate: Histogram: #" << i << " "
202  << val << G4endl;
203  }
204  if(i>=0 && i<fNHisto) {
205  fActive[i] = val;
206  if(val) { fHistoActive = true; }
207  }
208 }
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::Activate ( G4int  ,
G4bool   
)
void Histo::Add1D ( const G4String ,
const G4String ,
G4int  nb,
G4double  x1,
G4double  x2,
G4double  u = 1. 
)
void Histo::Add1D ( const G4String id,
const G4String name,
G4int  nb,
G4double  x1,
G4double  x2,
G4double  u = 1. 
)

Definition at line 154 of file electromagnetic/TestEm8/src/Histo.cc.

References G4cout, and G4endl.

156 {
157  if(fVerbose > 0) {
158  G4cout << "Histo::Add1D: New histogram will be booked: #" << id << " <" << name
159  << " " << nb << " " << x1 << " " << x2 << " " << u
160  << G4endl;
161  }
162  ++fNHisto;
163  x1 /= u;
164  x2 /= u;
165  fActive.push_back(fDefaultAct);
166  fBins.push_back(nb);
167  fXmin.push_back(x1);
168  fXmax.push_back(x2);
169  fUnit.push_back(u);
170  fIds.push_back(id);
171  fTitles.push_back(name);
172  fHisto.push_back(-1);
173 }
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 398 of file medical/GammaTherapy/src/Histo.cc.

References plottest35::bin, G4VAnalysisManager::FillH1(), and python.hepunit::MeV.

399 {
400  e /= MeV;
401  fSumR += e;
402  G4int bin = (G4int)(e/fStepE);
403  if(bin >= fNBinsE) { bin = fNBinsE-1; }
404  fGammaE[bin] += e;
405  G4int bin1 = (G4int)(r/fStepR);
406  if(bin1 >= fNBinsR) { bin1 = fNBinsR-1; }
407  if(fAnalysisManager) {
408  fAnalysisManager->FillH1(fHisto[6],e,1.0);
409  fAnalysisManager->FillH1(fHisto[9],r,e*fVolumeR[bin1]);
410  }
411 }
tuple bin
Definition: plottest35.py:22
int G4int
Definition: G4Types.hh:78
G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
void Histo::AddPhantomStep ( G4double  e,
G4double  r1,
G4double  z1,
G4double  r2,
G4double  z2,
G4double  r0,
G4double  z0 
)

Definition at line 415 of file medical/GammaTherapy/src/Histo.cc.

References plottest35::bin, G4VAnalysisManager::FillH1(), G4cout, G4endl, python.hepunit::MeV, G4INCL::Math::min(), and z.

Referenced by PhantomSD::ProcessHits().

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

Definition at line 329 of file electromagnetic/TestEm8/src/Histo.cc.

References G4VAnalysisManager::AddNtupleRow().

330 {
331  if(!fNtupleActive) { return; }
332  fManager->AddNtupleRow();
333 }
void Histo::AddRow ( )
void Histo::AddStepInTarget ( )
inline

Definition at line 91 of file medical/GammaTherapy/include/Histo.hh.

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

Definition at line 244 of file electromagnetic/TestEm8/src/Histo.cc.

245 {
246  fTupleTitle = w1;
247 }
void Histo::AddTuple ( const G4String )
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 )
void Histo::AddTupleD ( const G4String w1)

Definition at line 269 of file electromagnetic/TestEm8/src/Histo.cc.

270 {
271  fNtupleActive = true;
272  fNtupleD.push_back(w1);
273  fTupleD.push_back(-1);
274 }
void Histo::AddTupleD ( const G4String )
void Histo::AddTupleD ( const G4String )
void Histo::AddTupleF ( const G4String )
void Histo::AddTupleF ( const G4String )
void Histo::AddTupleF ( const G4String w1)

Definition at line 260 of file electromagnetic/TestEm8/src/Histo.cc.

261 {
262  fNtupleActive = true;
263  fNtupleF.push_back(w1);
264  fTupleF.push_back(-1);
265 }
void Histo::AddTupleF ( const G4String )
void Histo::AddTupleF ( const G4String )
void Histo::AddTupleI ( const G4String )
void Histo::AddTupleI ( const G4String w1)

Definition at line 251 of file electromagnetic/TestEm8/src/Histo.cc.

252 {
253  fNtupleActive = true;
254  fNtupleI.push_back(w1);
255  fTupleI.push_back(-1);
256 }
void Histo::AddTupleI ( const G4String )
void Histo::AddTupleI ( const G4String )
void Histo::AddTupleI ( const G4String )
void Histo::BeginOfHisto ( )

Definition at line 107 of file medical/GammaTherapy/src/Histo.cc.

References python.hepunit::cm, G4cout, G4endl, G4RootAnalysisManager::Instance(), python.hepunit::MeV, python.hepunit::mm, python.hepunit::pi, and SetNumberDivR().

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)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
static G4RootAnalysisManager * Instance()
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void Histo::Book ( )
void Histo::Book ( )
void Histo::Book ( )
void Histo::Book ( )

Definition at line 78 of file electromagnetic/TestEm8/src/Histo.cc.

References G4VAnalysisManager::CreateH1(), G4VAnalysisManager::CreateNtuple(), G4VAnalysisManager::CreateNtupleDColumn(), G4VAnalysisManager::CreateNtupleFColumn(), G4VAnalysisManager::CreateNtupleIColumn(), G4cout, G4endl, G4RootAnalysisManager::Instance(), n, and G4VAnalysisManager::OpenFile().

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] = fManager->CreateH1(ss, fTitles[i], fBins[i], fXmin[i], fXmax[i]);
103  if(fVerbose > 0) {
104  G4cout << "Created histogram #" << i << " id= " << fHisto[i]
105  << " " << ss << " " << fTitles[i] << G4endl;
106  }
107  }
108  }
109  // Creating a tuple factory, whose tuples will be handled by the tree
110  if(fNtupleActive) {
111  fManager->CreateNtuple(fTupleName,fTupleTitle);
112  G4int i;
113  G4int n = fNtupleI.size();
114  for(i=0; i<n; ++i) {
115  if(fTupleI[i] == -1) { fTupleI[i] = fManager->CreateNtupleIColumn(fNtupleI[i]); }
116  }
117  n = fNtupleF.size();
118  for(i=0; i<n; ++i) {
119  if(fTupleF[i] == -1) { fTupleF[i] = fManager->CreateNtupleFColumn(fNtupleF[i]); }
120  }
121  n = fNtupleD.size();
122  for(i=0; i<n; ++i) {
123  if(fTupleD[i] == -1) { fTupleD[i] = fManager->CreateNtupleDColumn(fNtupleD[i]); }
124  }
125  }
126 }
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
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)
void Histo::Book ( )
void Histo::EndOfHisto ( )

Definition at line 159 of file medical/GammaTherapy/src/Histo.cc.

References G4VAnalysisManager::CloseFile(), python.hepunit::cm3, G4cout, G4endl, G4RootAnalysisManager::GetH1(), python.hepunit::MeV, python.hepunit::pi, G4VAnalysisManager::Write(), and test::x.

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  G4cout << "Histo::Save: FATAL ERROR writing ROOT file" << G4endl;
243  exit(1);
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 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
tools::histo::h1d * GetH1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
void Histo::Fill ( G4int  ,
G4double  ,
G4double   
)
void Histo::Fill ( G4int  ,
G4double  ,
G4double   
)
void Histo::Fill ( G4int  i,
G4double  x,
G4double  w 
)

Definition at line 212 of file electromagnetic/TestEm8/src/Histo.cc.

References G4VAnalysisManager::FillH1(), G4cout, and G4endl.

Referenced by RunAction::FillHisto().

213 {
214  if(!fHistoActive) { return; }
215  if(fVerbose > 1) {
216  G4cout << "Histo::Fill: Histogram: #" << i << " at x= " << x
217  << " weight= " << w
218  << G4endl;
219  }
220  if(i>=0 && i<fNHisto) {
221  if(fActive[i]) { fManager->FillH1(fHisto[i], x/fUnit[i], w); }
222  } else {
223  G4cout << "Histo::Fill: WARNING! wrong histogram index " << i << G4endl;
224  }
225 }
G4GLOB_DLL std::ostream G4cout
G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
#define G4endl
Definition: G4ios.hh:61
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  ,
G4double   
)
void Histo::FillTupleD ( G4int  i,
G4double  x 
)

Definition at line 312 of file electromagnetic/TestEm8/src/Histo.cc.

References G4VAnalysisManager::FillNtupleDColumn(), G4cout, G4endl, and n.

313 {
314  if(!fNtupleActive) { return; }
315  G4int n = fNtupleD.size();
316  if(i >= 0 && i < n) {
317  if(fVerbose > 1) {
318  G4cout << "Histo::FillTupleD: i= " << i << " id= " << fTupleD[i]
319  << " <" << fNtupleD[i] << "> = " << x << G4endl;
320  }
321  fManager->FillNtupleDColumn(fTupleD[i], x);
322  } else {
323  G4cout << "Histo::FillTupleD: WARNING! wrong ntuple index " << i << G4endl;
324  }
325 }
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
void Histo::FillTupleF ( G4int  ,
G4float   
)
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 295 of file electromagnetic/TestEm8/src/Histo.cc.

References G4VAnalysisManager::FillNtupleFColumn(), G4cout, G4endl, and n.

296 {
297  if(!fNtupleActive) { return; }
298  G4int n = fNtupleF.size();
299  if(i >= 0 && i < n) {
300  if(fVerbose > 1) {
301  G4cout << "Histo::FillTupleF: i= " << i << " id= " << fTupleF[i]
302  << " <" << fNtupleF[i] << "> = " << x << G4endl;
303  }
304  fManager->FillNtupleFColumn(fTupleF[i], x);
305  } else {
306  G4cout << "Histo::FillTupleF: WARNING! wrong ntuple index " << i << G4endl;
307  }
308 }
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
void Histo::FillTupleI ( G4int  ,
G4int   
)
void Histo::FillTupleI ( G4int  ,
G4int   
)
void Histo::FillTupleI ( G4int  i,
G4int  x 
)

Definition at line 278 of file electromagnetic/TestEm8/src/Histo.cc.

References G4VAnalysisManager::FillNtupleIColumn(), G4cout, G4endl, and n.

279 {
280  if(!fNtupleActive) { return; }
281  G4int n = fNtupleI.size();
282  if(i >= 0 && i < n) {
283  if(fVerbose > 1) {
284  G4cout << "Histo::FillTupleI: i= " << i << " id= " << fTupleI[i]
285  << " <" << fNtupleI[i] << "> = " << x << G4endl;
286  }
287  fManager->FillNtupleIColumn(fTupleI[i], x);
288  } else {
289  G4cout << "Histo::FillTupleI: WARNING! wrong ntuple index " << i << G4endl;
290  }
291 }
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
void Histo::FillTupleI ( G4int  ,
G4int   
)
void Histo::FillTupleI ( G4int  ,
G4int   
)
G4double Histo::GetMaxEnergy ( ) const
inline

Definition at line 109 of file medical/GammaTherapy/include/Histo.hh.

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

Definition at line 100 of file medical/GammaTherapy/include/Histo.hh.

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

Definition at line 97 of file medical/GammaTherapy/include/Histo.hh.

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

Definition at line 59 of file medical/GammaTherapy/src/Histo.cc.

Referenced by PrimaryGeneratorAction::SetBeamEnergy().

60 {
61  if(!fManager) {
62  static Histo manager;
63  fManager = &manager;
64  }
65  return fManager;
66 }
G4int Histo::GetVerbose ( ) const
inline

Definition at line 94 of file medical/GammaTherapy/include/Histo.hh.

Referenced by PhantomSD::Initialize(), and PhantomSD::ProcessHits().

94 { return fVerbose;};
G4bool Histo::IsActive ( ) const
inline

Definition at line 108 of file hadronic/Hadr01/include/Histo.hh.

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

Definition at line 108 of file electromagnetic/TestEm9/include/Histo.hh.

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

Definition at line 108 of file electromagnetic/TestEm8/include/Histo.hh.

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

Definition at line 108 of file hadronic/Hadr02/include/Histo.hh.

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

Definition at line 108 of file exoticphysics/monopole/include/Histo.hh.

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

Definition at line 130 of file electromagnetic/TestEm8/src/Histo.cc.

References G4VAnalysisManager::CloseFile(), G4cout, G4endl, G4RootAnalysisManager::Instance(), and G4VAnalysisManager::Write().

131 {
132  if(!(fHistoActive || fNtupleActive)) { return; }
133 
134  // Creating a tree mapped to a new hbook file.
135  G4String nam = fHistName + "." + fHistType;
136 
137  // Write histogram file
138  if(!fManager->Write()) {
139  G4cout << "Histo::Save: FATAL ERROR writing ROOT file" << G4endl;
140  exit(1);
141  }
142  if(fVerbose > 0) {
143  G4cout << "### Histo::Save: Histograms and Ntuples are saved" << G4endl;
144  }
145  if(fManager->CloseFile() && fVerbose > 0) {
146  G4cout << " File is closed" << G4endl;
147  }
149  fManager = 0;
150 }
G4GLOB_DLL std::ostream G4cout
static G4RootAnalysisManager * Instance()
#define G4endl
Definition: G4ios.hh:61
void Histo::Save ( )
void Histo::Save ( )
void Histo::Save ( )
void Histo::ScaleH1 ( G4int  ,
G4double   
)
void Histo::ScaleH1 ( G4int  i,
G4double  x 
)

Definition at line 229 of file electromagnetic/TestEm8/src/Histo.cc.

References G4cout, G4endl, and G4RootAnalysisManager::GetH1().

230 {
231  if(!fHistoActive) { return; }
232  if(fVerbose > 0) {
233  G4cout << "Histo::Scale: Histogram: #" << i << " by factor " << x << G4endl;
234  }
235  if(i>=0 && i<fNHisto) {
236  if(fActive[i]) { fManager->GetH1(fHisto[i])->scale(x); }
237  } else {
238  G4cout << "Histo::Scale: WARNING! wrong histogram index " << i << G4endl;
239  }
240 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
tools::histo::h1d * GetH1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
void Histo::ScaleH1 ( G4int  ,
G4double   
)
void Histo::ScaleH1 ( G4int  ,
G4double   
)
void Histo::ScaleH1 ( G4int  ,
G4double   
)
void Histo::ScoreNewTrack ( const G4Track aTrack)

Definition at line 345 of file medical/GammaTherapy/src/Histo.cc.

References G4cout, G4endl, G4Track::GetDynamicParticle(), G4Track::GetKineticEnergy(), G4Track::GetMomentumDirection(), G4Track::GetParentID(), G4Track::GetParticleDefinition(), G4ParticleDefinition::GetParticleName(), G4Track::GetVertexPosition(), G4Track::GetVolume(), and python.hepunit::MeV.

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

Definition at line 105 of file medical/GammaTherapy/include/Histo.hh.

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

Definition at line 104 of file medical/GammaTherapy/include/Histo.hh.

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

Definition at line 111 of file medical/GammaTherapy/include/Histo.hh.

References test::v.

111 { fCheckVolume = v;};
void Histo::SetFileName ( const G4String nam)

Definition at line 337 of file electromagnetic/TestEm8/src/Histo.cc.

338 {
339  fHistName = nam;
340  fHistoActive = true;
341 }
void Histo::SetFileName ( const G4String )
void Histo::SetFileName ( const G4String )
void Histo::SetFileName ( const G4String )
void Histo::SetFileName ( const G4String )
void Histo::SetFileType ( const G4String nam)

Definition at line 345 of file electromagnetic/TestEm8/src/Histo.cc.

346 {
347  if(nam == "root" || nam == "ROOT" ) { fHistType = "root"; }
348  else if(nam == "xml" || nam == "XML") { fHistType = "xml"; }
349  else if(nam == "ascii" || nam == "ASCII" ||
350  nam == "Csv" || nam == "csv" || nam == "CSV") { fHistType = "ascii"; }
351 }
void Histo::SetFileType ( const G4String )
void Histo::SetFileType ( const G4String )
void Histo::SetFileType ( const G4String )
void Histo::SetFileType ( const G4String )
void Histo::SetGasVolume ( G4VPhysicalVolume v)
inline

Definition at line 112 of file medical/GammaTherapy/include/Histo.hh.

References test::v.

112 { fGasVolume = v;};
void Histo::SetHisto1D ( G4int  i,
G4int  nb,
G4double  x1,
G4double  x2,
G4double  u 
)

Definition at line 177 of file electromagnetic/TestEm8/src/Histo.cc.

References G4cout, and G4endl.

178 {
179  if(i>=0 && i<fNHisto) {
180  if(fVerbose > 0) {
181  G4cout << "Histo::SetHisto1D: #" << i
182  << " " << nb << " " << x1 << " " << x2 << " " << u
183  << G4endl;
184  }
185  fBins[i] = nb;
186  fXmin[i] = x1;
187  fXmax[i] = x2;
188  fUnit[i] = u;
189  fActive[i] = true;
190  fHistoActive = true;
191  } else {
192  G4cout << "Histo::SetHisto1D: WARNING! wrong histogram index " << i << G4endl;
193  }
194 }
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::SetHisto1D ( G4int  ,
G4int  ,
G4double  ,
G4double  ,
G4double   
)
void Histo::SetHistoName ( const G4String name)
inline

Definition at line 90 of file medical/GammaTherapy/include/Histo.hh.

90 { fHistName = name; };
const XML_Char * name
void Histo::SetMaxEnergy ( G4double  val)
inline

Definition at line 108 of file medical/GammaTherapy/include/Histo.hh.

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

Definition at line 102 of file medical/GammaTherapy/include/Histo.hh.

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

Definition at line 99 of file medical/GammaTherapy/include/Histo.hh.

Referenced by BeginOfHisto().

99 { fNBinsR = val; };
void Histo::SetNumberDivZ ( G4int  val)
inline

Definition at line 96 of file medical/GammaTherapy/include/Histo.hh.

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

Definition at line 113 of file medical/GammaTherapy/include/Histo.hh.

References test::v.

113 { fPhantom = v; };
void Histo::SetScoreZ ( G4double  val)
inline

Definition at line 106 of file medical/GammaTherapy/include/Histo.hh.

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

Definition at line 114 of file medical/GammaTherapy/include/Histo.hh.

References test::v.

114 { fTarget1 = v; };
void Histo::SetTarget2 ( G4VPhysicalVolume v)
inline

Definition at line 115 of file medical/GammaTherapy/include/Histo.hh.

References test::v.

115 { fTarget2 = v; };
void Histo::SetVerbose ( G4int  val)
inline

Definition at line 93 of file medical/GammaTherapy/include/Histo.hh.

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

Definition at line 106 of file hadronic/Hadr01/include/Histo.hh.

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

Definition at line 106 of file electromagnetic/TestEm9/include/Histo.hh.

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

Definition at line 106 of file hadronic/Hadr02/include/Histo.hh.

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

Definition at line 106 of file exoticphysics/monopole/include/Histo.hh.

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

Definition at line 106 of file electromagnetic/TestEm8/include/Histo.hh.

106 { fVerbose = val; };

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