LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
RunAction Class Reference

#include "RunAction.hh"

Inheritance diagram for RunAction:

Public Member Functions

 RunAction (DetectorConstruction *, PrimaryGeneratorAction *)
 
 ~RunAction ()
 
void BeginOfRunAction (const G4Run *)
 
void EndOfRunAction (const G4Run *)
 
void GetCuts ()
 
void CriticalEnergy ()
 

Private Attributes

DetectorConstructiondetector
 
PrimaryGeneratorActionprimary
 
G4double rangeCut [3]
 
G4double energyCut [3]
 

Detailed Description

Definition at line 45 of file RunAction.hh.

Constructor & Destructor Documentation

RunAction::RunAction ( DetectorConstruction det,
PrimaryGeneratorAction kin 
)

Definition at line 46 of file RunAction.cc.

47 :detector(det), primary(kin)
48 { }
DetectorConstruction * detector
Definition: RunAction.hh:59
PrimaryGeneratorAction * primary
Definition: RunAction.hh:60
RunAction::~RunAction ( )

Definition at line 52 of file RunAction.cc.

53 { }

Member Function Documentation

void RunAction::BeginOfRunAction ( const G4Run *  )

Definition at line 57 of file RunAction.cc.

References CriticalEnergy(), detector, energy, energyCut, GetCuts(), DetectorConstruction::GetMaterial(), PrimaryGeneratorAction::GetParticleGun(), primary, rangeCut, and Z.

58 {
59  //set precision for printing
60  G4int prec = G4cout.precision(6);
61 
62  // get particle
63  G4ParticleDefinition* particle = primary->GetParticleGun()
64  ->GetParticleDefinition();
65  G4String partName = particle->GetParticleName();
66  G4double charge = particle->GetPDGCharge();
67  G4double energy = primary->GetParticleGun()->GetParticleEnergy();
68 
69  // get material
70  G4Material* material = detector->GetMaterial();
71  G4String matName = material->GetName();
72  G4double density = material->GetDensity();
73  G4double radl = material->GetRadlen();
74 
75  G4cout << "\n " << partName << " ("
76  << G4BestUnit(energy,"Energy") << ") in "
77  << material->GetName() << " (density: "
78  << G4BestUnit(density,"Volumic Mass") << "; radiation length: "
79  << G4BestUnit(radl, "Length") << ")" << G4endl;
80 
81  // get cuts
82  GetCuts();
83  if (charge != 0.) {
84  G4cout << "\n Range cuts : \t gamma "
85  << std::setw(8) << G4BestUnit(rangeCut[0],"Length")
86  << "\t e- " << std::setw(8) << G4BestUnit(rangeCut[1],"Length");
87  G4cout << "\n Energy cuts : \t gamma "
88  << std::setw(8) << G4BestUnit(energyCut[0],"Energy")
89  << "\t e- " << std::setw(8) << G4BestUnit(energyCut[1],"Energy")
90  << G4endl;
91  }
92 
93  // get processList and extract EM processes (but not MultipleScattering)
94  G4ProcessVector* plist = particle->GetProcessManager()->GetProcessList();
95  G4String procName;
96  G4double cut;
97  std::vector<G4String> emName;
98  std::vector<G4double> enerCut;
99  size_t length = plist->size();
100  for (size_t j=0; j<length; j++) {
101  procName = (*plist)[j]->GetProcessName();
102  cut = energyCut[1];
103  if ((procName == "eBrem")||(procName == "muBrems")) cut = energyCut[0];
104  if (((*plist)[j]->GetProcessType() == fElectromagnetic) &&
105  (procName != "msc")) {
106  emName.push_back(procName);
107  enerCut.push_back(cut);
108  }
109  }
110 
111  // print list of processes
112  G4cout << "\n processes : ";
113  for (size_t j=0; j<emName.size();j++)
114  G4cout << "\t" << std::setw(13) << emName[j] << "\t";
115  G4cout << "\t" << std::setw(13) <<"total";
116 
117  //instanciate EmCalculator
118  G4EmCalculator emCal;
119  // emCal.SetVerbose(2);
120 
121  //compute cross section per atom (only for single material)
122  if (material->GetNumberOfElements() == 1) {
123  G4double Z = material->GetZ();
124  G4double A = material->GetA();
125 
126  std::vector<G4double> sigma0;
127  G4double sig, sigtot = 0.;
128 
129  for (size_t j=0; j<emName.size();j++) {
130  sig = emCal.ComputeCrossSectionPerAtom
131  (energy,particle,emName[j],Z,A,enerCut[j]);
132  sigtot += sig;
133  sigma0.push_back(sig);
134  }
135  sigma0.push_back(sigtot);
136 
137  G4cout << "\n \n cross section per atom : ";
138  for (size_t j=0; j<sigma0.size();j++) {
139  G4cout << "\t" << std::setw(13) << G4BestUnit(sigma0[j], "Surface");
140  }
141  G4cout << G4endl;
142  }
143 
144  //get cross section per volume
145  std::vector<G4double> sigma1;
146  std::vector<G4double> sigma2;
147  G4double Sig, Sigtot = 0.;
148 
149  for (size_t j=0; j<emName.size();j++) {
150  Sig = emCal.GetCrossSectionPerVolume(energy,particle,emName[j],material);
151  if (Sig == 0.) Sig = emCal.ComputeCrossSectionPerVolume
152  (energy,particle,emName[j],material,enerCut[j]);
153  Sigtot += Sig;
154  sigma1.push_back(Sig);
155  sigma2.push_back(Sig/density);
156  }
157  sigma1.push_back(Sigtot);
158  sigma2.push_back(Sigtot/density);
159 
160  //print cross sections
161  G4cout << "\n \n cross section per volume : ";
162  for (size_t j=0; j<sigma1.size();j++) {
163  G4cout << "\t" << std::setw(13) << sigma1[j]*cm << " cm^-1";
164  }
165 
166  G4cout << "\n cross section per mass : ";
167  for (size_t j=0; j<sigma2.size();j++) {
168  G4cout << "\t" << std::setw(13) << G4BestUnit(sigma2[j], "Surface/Mass");
169  }
170 
171  //print mean free path
172 
173  G4double lambda;
174 
175  G4cout << "\n \n mean free path : ";
176  for (size_t j=0; j<sigma1.size();j++) {
177  lambda = DBL_MAX;
178  if (sigma1[j] > 0.) lambda = 1/sigma1[j];
179  G4cout << "\t" << std::setw(13) << G4BestUnit( lambda, "Length");
180  }
181 
182  //mean free path (g/cm2)
183  G4cout << "\n (g/cm2) : ";
184  for (size_t j=0; j<sigma2.size();j++) {
185  lambda = DBL_MAX;
186  if (sigma2[j] > 0.) lambda = 1/sigma2[j];
187  G4cout << "\t" << std::setw(13) << G4BestUnit( lambda, "Mass/Surface");
188  }
189  G4cout << G4endl;
190 
191  if (charge == 0.) {
192  G4cout.precision(prec);
193  G4cout << "\n-------------------------------------------------------------\n"
194  << G4endl;
195  return;
196  }
197 
198  //get stopping power
199  std::vector<G4double> dedx1;
200  std::vector<G4double> dedx2;
201  G4double dedx, dedxtot = 0.;
202 
203  for (size_t j=0; j<emName.size();j++) {
204  dedx = emCal.ComputeDEDX(energy,particle,emName[j],material,enerCut[j]);
205  dedx1.push_back(dedx);
206  dedx2.push_back(dedx/density);
207  }
208  dedxtot = emCal.GetDEDX(energy,particle,material);
209  dedx1.push_back(dedxtot);
210  dedx2.push_back(dedxtot/density);
211 
212  //print stopping power
213  G4cout << "\n \n restricted dE/dx : ";
214  for (size_t j=0; j<sigma1.size();j++) {
215  G4cout << "\t" << std::setw(13) << G4BestUnit(dedx1[j],"Energy/Length");
216  }
217 
218  G4cout << "\n (MeV/g/cm2) : ";
219  for (size_t j=0; j<sigma2.size();j++) {
220  G4cout << "\t" << std::setw(13) << G4BestUnit(dedx2[j],"Energy*Surface/Mass");
221  }
222 
223  //get range from restricted dedx
224  G4double range1 = emCal.GetRangeFromRestricteDEDX(energy,particle,material);
225  G4double range2 = range1*density;
226 
227  //get range from full dedx
228  G4double Range1 = emCal.GetCSDARange(energy,particle,material);
229  G4double Range2 = Range1*density;
230 
231  //print range
232  G4cout << "\n \n range from restrict dE/dx: "
233  << "\t" << std::setw(8) << G4BestUnit(range1,"Length")
234  << " (" << std::setw(8) << G4BestUnit(range2,"Mass/Surface") << ")";
235 
236  G4cout << "\n range from full dE/dx : "
237  << "\t" << std::setw(8) << G4BestUnit(Range1,"Length")
238  << " (" << std::setw(8) << G4BestUnit(Range2,"Mass/Surface") << ")";
239 
240  //get transport mean free path (for multiple scattering)
241  G4double MSmfp1 = emCal.GetMeanFreePath(energy,particle,"msc",material);
242  G4double MSmfp2 = MSmfp1*density;
243 
244  //print transport mean free path
245  G4cout << "\n \n transport mean free path : "
246  << "\t" << std::setw(8) << G4BestUnit(MSmfp1,"Length")
247  << " (" << std::setw(8) << G4BestUnit(MSmfp2,"Mass/Surface") << ")";
248 
249  if (particle == G4Electron::Electron()) CriticalEnergy();
250 
251  G4cout << "\n-------------------------------------------------------------\n";
252  G4cout << G4endl;
253 
254  // reset default precision
255  G4cout.precision(prec);
256 }
DetectorConstruction * detector
Definition: RunAction.hh:59
void GetCuts()
Definition: RunAction.cc:269
G4ParticleGun * GetParticleGun()
G4double energyCut[3]
Definition: RunAction.hh:62
Float_t Z
Definition: plot.C:39
double energy
Definition: plottest35.C:25
void CriticalEnergy()
Definition: RunAction.cc:300
G4double rangeCut[3]
Definition: RunAction.hh:61
PrimaryGeneratorAction * primary
Definition: RunAction.hh:60
void RunAction::CriticalEnergy ( )

Definition at line 300 of file RunAction.cc.

References detector, and DetectorConstruction::GetMaterial().

Referenced by BeginOfRunAction().

301 {
302  // compute e- critical energy (Rossi definition) and Moliere radius.
303  // Review of Particle Physics - Eur. Phys. J. C3 (1998) page 147
304  //
305  G4EmCalculator emCal;
306 
307  const G4Material* material = detector->GetMaterial();
308  const G4double radl = material->GetRadlen();
309  G4double ekin = 5*MeV;
310  G4double deioni;
311  G4double err = 1., errmax = 0.001;
312  G4int iter = 0 , itermax = 10;
313  while (err > errmax && iter < itermax) {
314  iter++;
315  deioni = radl*
316  emCal.ComputeDEDX(ekin,G4Electron::Electron(),"eIoni",material);
317  err = std::abs(deioni - ekin)/ekin;
318  ekin = deioni;
319  }
320  G4cout << "\n \n critical energy (Rossi) : "
321  << "\t" << std::setw(8) << G4BestUnit(ekin,"Energy");
322 
323  //Pdg formula (only for single material)
324  G4double pdga[2] = { 610*MeV, 710*MeV };
325  G4double pdgb[2] = { 1.24, 0.92 };
326  G4double EcPdg = 0.;
327 
328  if (material->GetNumberOfElements() == 1) {
329  G4int istat = 0;
330  if (material->GetState() == kStateGas) istat = 1;
331  G4double Zeff = material->GetZ() + pdgb[istat];
332  EcPdg = pdga[istat]/Zeff;
333  G4cout << "\t\t\t (from Pdg formula : "
334  << std::setw(8) << G4BestUnit(EcPdg,"Energy") << ")";
335  }
336 
337  const G4double Es = 21.2052*MeV;
338  G4double rMolier1 = Es/ekin, rMolier2 = rMolier1*radl;
339  G4cout << "\n Moliere radius : "
340  << "\t" << std::setw(8) << rMolier1 << " X0 "
341  << "= " << std::setw(8) << G4BestUnit(rMolier2,"Length");
342 
343  if (material->GetNumberOfElements() == 1) {
344  G4double rMPdg = radl*Es/EcPdg;
345  G4cout << "\t (from Pdg formula : "
346  << std::setw(8) << G4BestUnit(rMPdg,"Length") << ")";
347  }
348 }
DetectorConstruction * detector
Definition: RunAction.hh:59
void RunAction::EndOfRunAction ( const G4Run *  )

Definition at line 260 of file RunAction.cc.

261 { }
void RunAction::GetCuts ( )

Definition at line 269 of file RunAction.cc.

References detector, energyCut, DetectorConstruction::GetMaterial(), and rangeCut.

Referenced by BeginOfRunAction().

270 {
271  G4ProductionCutsTable* theCoupleTable =
272  G4ProductionCutsTable::GetProductionCutsTable();
273 
274  size_t numOfCouples = theCoupleTable->GetTableSize();
275  const G4MaterialCutsCouple* couple = 0;
276  G4int index = 0;
277  for (size_t i=0; i<numOfCouples; i++) {
278  couple = theCoupleTable->GetMaterialCutsCouple(i);
279  if (couple->GetMaterial() == detector->GetMaterial()) {index = i; break;}
280  }
281 
282  rangeCut[0] =
283  (*(theCoupleTable->GetRangeCutsVector(idxG4GammaCut)))[index];
284  rangeCut[1] =
285  (*(theCoupleTable->GetRangeCutsVector(idxG4ElectronCut)))[index];
286  rangeCut[2] =
287  (*(theCoupleTable->GetRangeCutsVector(idxG4PositronCut)))[index];
288 
289  energyCut[0] =
290  (*(theCoupleTable->GetEnergyCutsVector(idxG4GammaCut)))[index];
291  energyCut[1] =
292  (*(theCoupleTable->GetEnergyCutsVector(idxG4ElectronCut)))[index];
293  energyCut[2] =
294  (*(theCoupleTable->GetEnergyCutsVector(idxG4PositronCut)))[index];
295 
296 }
DetectorConstruction * detector
Definition: RunAction.hh:59
G4double energyCut[3]
Definition: RunAction.hh:62
G4double rangeCut[3]
Definition: RunAction.hh:61

Member Data Documentation

DetectorConstruction* RunAction::detector
private

Definition at line 59 of file RunAction.hh.

Referenced by BeginOfRunAction(), CriticalEnergy(), and GetCuts().

G4double RunAction::energyCut[3]
private

Definition at line 62 of file RunAction.hh.

Referenced by BeginOfRunAction(), and GetCuts().

PrimaryGeneratorAction* RunAction::primary
private

Definition at line 60 of file RunAction.hh.

Referenced by BeginOfRunAction().

G4double RunAction::rangeCut[3]
private

Definition at line 61 of file RunAction.hh.

Referenced by BeginOfRunAction(), and GetCuts().


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