LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ISCalculationSeparate.cxx
Go to the documentation of this file.
1 
9 #include "Geant4/G4EmSaturation.hh"
10 #include "Geant4/G4LossTableManager.hh"
11 #include "Geant4/G4ParticleTypes.hh"
12 
19 
20 #include "cetlib_except/exception.h"
22 
23 namespace larg4 {
24 
25  //----------------------------------------------------------------------------
27  {
29  const detinfo::LArProperties* larp = lar::providerFrom<detinfo::LArPropertiesService>();
30  auto const detProp =
32 
33  double density = detProp.Density(detProp.Temperature());
34  fEfield = detProp.Efield();
36  fGeVToElectrons = lgpHandle->GeVToElectrons();
37 
38  // \todo get scintillation yield from LArG4Parameters or LArProperties
39  fScintYieldFactor = 1.;
40 
41  // the recombination coefficient is in g/(MeVcm^2), but
42  // we report energy depositions in MeV/cm, need to divide
43  // Recombk from the LArG4Parameters service by the density
44  // of the argon we got above.
45  fRecombA = lgpHandle->RecombA();
46  fRecombk = lgpHandle->Recombk() / density;
47  fModBoxA = lgpHandle->ModBoxA();
48  fModBoxB = lgpHandle->ModBoxB() / density;
49  fUseModBoxRecomb = lgpHandle->UseModBoxRecomb();
50 
51  // Use Birks Correction in the Scintillation process
52  fEMSaturation = G4LossTableManager::Instance()->EmSaturation();
53 
54  // determine the step size using the voxel sizes
56  double maxsize =
57  std::max(lvc->VoxelSizeX(), std::max(lvc->VoxelSizeY(), lvc->VoxelSizeZ())) * CLHEP::cm;
58 
59  fStepSize = 0.1 * maxsize;
60  }
61 
62  //----------------------------------------------------------------------------
63  // fNumIonElectrons returns a value that is not corrected for life time effects
65  {
66  fEnergyDeposit = 0.;
67  fNumScintPhotons = 0.;
68  fNumIonElectrons = 0.;
69  }
70 
71  //----------------------------------------------------------------------------
72  // fNumIonElectrons returns a value that is not corrected for life time effects
74  {
75  fEnergyDeposit = step->GetTotalEnergyDeposit() / CLHEP::MeV;
76 
77  // Get the recombination factor for this voxel - Nucl.Instrum.Meth.A523:275-286,2004
78  // R = A/(1 + (dE/dx)*k)
79  // dE/dx is given by the voxel energy deposition, but have to convert it to MeV/cm
80  // from GeV/voxel width
81  // A = 0.800 +/- 0.003
82  // k = (0.097+/-0.001) g/(MeVcm^2)
83  // the dx depends on the trajectory of the step
84  // k should be divided by the density as our dE/dx is in MeV/cm,
85  // the division is handled in the constructor when we set fRecombk
86  // B.Baller: Add Modified Box recombination - ArgoNeuT result submitted to JINST
87 
88  G4ThreeVector totstep = step->GetPostStepPoint()->GetPosition();
89  totstep -= step->GetPreStepPoint()->GetPosition();
90 
91  double dx = totstep.mag() / CLHEP::cm;
92  double recomb = 0.;
93  double dEdx = (dx == 0.0) ? 0.0 : fEnergyDeposit / dx;
94  double EFieldStep = EFieldAtStep(fEfield, step);
95 
96  // Guard against spurious values of dE/dx. Note: assumes density of LAr
97  if (dEdx < 1.) dEdx = 1.;
98 
99  if (fUseModBoxRecomb) {
100  if (dx) {
101  double Xi = fModBoxB * dEdx / EFieldStep;
102  recomb = log(fModBoxA + Xi) / Xi;
103  }
104  else
105  recomb = 0;
106  }
107  else {
108  recomb = fRecombA / (1. + dEdx * fRecombk / EFieldStep);
109  }
110 
111  // 1.e-3 converts fEnergyDeposit to GeV
112  fNumIonElectrons = fGeVToElectrons * 1.e-3 * fEnergyDeposit * recomb;
113 
114  MF_LOG_DEBUG("ISCalculationSeparate")
115  << " Electrons produced for " << fEnergyDeposit << " MeV deposited with " << recomb
116  << " recombination: " << fNumIonElectrons;
117 
118  // Now do the scintillation
119  G4MaterialPropertiesTable* mpt = step->GetTrack()->GetMaterial()->GetMaterialPropertiesTable();
120  if (!mpt)
121  throw cet::exception("ISCalculationSeparate")
122  << "Cannot find materials property table"
123  << " for this step! " << step->GetTrack()->GetMaterial() << "\n";
124 
125  // if not doing the scintillation by particle type, use the saturation
126  double scintYield = mpt->GetConstProperty("SCINTILLATIONYIELD");
127 
128  if (fScintByParticleType) {
129 
130  MF_LOG_DEBUG("ISCalculationSeparate") << "scintillating by particle type";
131 
132  // Get the definition of the current particle
133  G4ParticleDefinition* pDef = step->GetTrack()->GetDynamicParticle()->GetDefinition();
134 
135  // Obtain the G4MaterialPropertyVectory containing the
136  // scintillation light yield as a function of the deposited
137  // energy for the current particle type
138 
139  // Protons
140  if (pDef == G4Proton::ProtonDefinition()) {
141  scintYield = mpt->GetConstProperty("PROTONSCINTILLATIONYIELD");
142  }
143  // Muons
144  else if (pDef == G4MuonPlus::MuonPlusDefinition() ||
145  pDef == G4MuonMinus::MuonMinusDefinition()) {
146  scintYield = mpt->GetConstProperty("MUONSCINTILLATIONYIELD");
147  }
148  // Pions
149  else if (pDef == G4PionPlus::PionPlusDefinition() ||
150  pDef == G4PionMinus::PionMinusDefinition()) {
151  scintYield = mpt->GetConstProperty("PIONSCINTILLATIONYIELD");
152  }
153  // Kaons
154  else if (pDef == G4KaonPlus::KaonPlusDefinition() ||
155  pDef == G4KaonMinus::KaonMinusDefinition()) {
156  scintYield = mpt->GetConstProperty("KAONSCINTILLATIONYIELD");
157  }
158  // Alphas
159  else if (pDef == G4Alpha::AlphaDefinition()) {
160  scintYield = mpt->GetConstProperty("ALPHASCINTILLATIONYIELD");
161  }
162  // Electrons (must also account for shell-binding energy
163  // attributed to gamma from standard PhotoElectricEffect)
164  else if (pDef == G4Electron::ElectronDefinition() || pDef == G4Gamma::GammaDefinition()) {
165  scintYield = mpt->GetConstProperty("ELECTRONSCINTILLATIONYIELD");
166  }
167  // Default for particles not enumerated/listed above
168  else {
169  scintYield = mpt->GetConstProperty("ELECTRONSCINTILLATIONYIELD");
170  }
171 
172  // If the user has not specified yields for (p,d,t,a,carbon)
173  // then these unspecified particles will default to the
174  // electron's scintillation yield
175 
176  // Throw an exception if no scintillation yield is found
177  if (!scintYield)
178  throw cet::exception("ISCalculationSeparate")
179  << "Request for scintillation yield for energy "
180  << "deposit and particle type without correct "
181  << "entry in MaterialPropertiesTable\n"
182  << "ScintillationByParticleType requires at "
183  << "minimum that ELECTRONSCINTILLATIONYIELD is "
184  << "set by the user\n";
185 
186  fNumScintPhotons = scintYield * fEnergyDeposit;
187  }
188  else if (fEMSaturation) {
189  // The default linear scintillation process
190  fVisibleEnergyDeposition = fEMSaturation->VisibleEnergyDepositionAtAStep(step);
192  }
193  else {
195  }
196 
197  MF_LOG_DEBUG("ISCalculationSeparate")
198  << "number photons: " << fNumScintPhotons << " energy: " << fEnergyDeposit / CLHEP::MeV
199  << " saturation: " << fEMSaturation->VisibleEnergyDepositionAtAStep(step)
200  << " step length: " << step->GetStepLength() / CLHEP::cm;
201  }
202 
203 } // namespace
Store parameters for running LArG4.
double VoxelSizeX() const
Access to voxel dimensions and offsets.
double ModBoxA() const
Utilities related to art service access.
bool fUseModBoxRecomb
from LArG4Parameters service
G4EmSaturation * fEMSaturation
pointer to EM saturation
double fScintYieldFactor
scintillation yield factor
Encapsulates calculation of LArVoxelID and LArVoxel parameters.
double EFieldAtStep(double fEfield, const G4Step *step) const
void CalculateIonizationAndScintillation(const G4Step *step) override
double fGeVToElectrons
conversion factor from LArProperties service
bool UseModBoxRecomb() const
Geant4 interface.
double fRecombA
from LArG4Parameters service
double fEfield
value of electric field from LArProperties service
double fNumIonElectrons
number of ionization electrons for this step
Definition: ISCalculation.h:33
double fModBoxB
from LArG4Parameters service
bool fScintByParticleType
from LArProperties service
double RecombA() const
double fStepSize
maximum step to take
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2675
double fRecombk
from LArG4Parameters service
double ModBoxB() const
double Recombk() const
#define MF_LOG_DEBUG(id)
double fNumScintPhotons
number of scintillation photons for this step
Definition: ISCalculation.h:34
double fVisibleEnergyDeposition
Definition: ISCalculation.h:35
double fModBoxA
from LArG4Parameters service
double fEnergyDeposit
total energy deposited in the step
Definition: ISCalculation.h:32
virtual bool ScintByParticleType() const =0
double GeVToElectrons() const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33