LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ISCalculationSeparate.cc
Go to the documentation of this file.
1 
13 #include "fhiclcpp/ParameterSet.h"
15 
24 
26 
27 #include <cmath>
28 #include <ostream>
29 
30 namespace {
31  constexpr double scint_yield_factor{1.};
32 }
33 
34 namespace detsim {
35 
36  //----------------------------------------------------------------------------
38  : fRecombA{pset.get<double>("RecombA")}
39  , fRecombk{pset.get<double>("Recombk")}
40  , fModBoxA{pset.get<double>("ModBoxA")}
41  , fModBoxB{pset.get<double>("ModBoxB")}
42  , fUseModBoxRecomb{pset.get<bool>("UseModBoxRecomb")}
43  , fGeVToElectrons{pset.get<double>("GeVToElectrons")}
44  {
45  fLArProp = lar::providerFrom<detinfo::LArPropertiesService>();
46  fSCE = lar::providerFrom<spacecharge::SpaceChargeService>();
47 
48  // the recombination coefficient is in g/(MeVcm^2), but
49  // we report energy depositions in MeV/cm, need to divide
50  // Recombk from the LArG4Parameters service by the density
51  // of the argon we got above. FIXME: is this being done?
52 
53  std::cout << "fLArG4Prop->GeVToElectrons(): " << fGeVToElectrons << std::endl;
54  }
55 
56  //----------------------------------------------------------------------------
57  // fNumIonElectrons returns a value that is not corrected for life time effects
59  sim::SimEnergyDeposit const& edep) const
60  {
61  float e = edep.Energy();
62  float ds = edep.StepLength();
63  float x = edep.MidPointX();
64  float y = edep.MidPointY();
65  float z = edep.MidPointZ();
66  double recomb = 0.;
67  double dEdx = (ds <= 0.0) ? 0.0 : e / ds;
68  double EFieldStep = EFieldAtStep(detProp.Efield(), x, y, z);
69 
70  // Guard against spurious values of dE/dx. Note: assumes density of LAr
71  if (dEdx < 1.) dEdx = 1.;
72 
73  if (fUseModBoxRecomb) {
74  if (ds > 0) {
75  double Xi = fModBoxB * dEdx / EFieldStep;
76  recomb = log(fModBoxA + Xi) / Xi;
77  }
78  else
79  recomb = 0;
80  }
81  else {
82  recomb = fRecombA / (1. + dEdx * fRecombk / EFieldStep);
83  }
84 
85  // 1.e-3 converts fEnergyDeposit to GeV
86  double const numIonElectrons = fGeVToElectrons * 1.e-3 * e * recomb;
87 
88  MF_LOG_DEBUG("ISCalculationSeparate")
89  << " Electrons produced for " << edep.Energy() << " MeV deposited with " << recomb
90  << " recombination: " << numIonElectrons << std::endl;
91 
92  return numIonElectrons;
93  }
94 
95  //----------------------------------------------------------------------------
97  {
98  float const e = edep.Energy();
99  int const pdg = edep.PdgCode();
100  double scintYield = fLArProp->ScintYield(true);
101  if (fLArProp->ScintByParticleType()) {
102 
103  MF_LOG_DEBUG("ISCalculationSeparate") << "scintillating by particle type";
104 
105  switch (pdg) {
106 
107  case 2212: scintYield = fLArProp->ProtonScintYield(true); break;
108  case 13:
109  case -13: scintYield = fLArProp->MuonScintYield(true); break;
110  case 211:
111  case -211: scintYield = fLArProp->PionScintYield(true); break;
112  case 321:
113  case -321: scintYield = fLArProp->KaonScintYield(true); break;
114  case 1000020040: scintYield = fLArProp->AlphaScintYield(true); break;
115  case 11:
116  case -11:
117  case 22: scintYield = fLArProp->ElectronScintYield(true); break;
118  default: scintYield = fLArProp->ElectronScintYield(true);
119  }
120 
121  return scintYield * e;
122  }
123 
124  return scint_yield_factor * scintYield * e;
125  }
126  //----------------------------------------------------------------------------
128  detinfo::DetectorPropertiesData const& detProp,
129  sim::SimEnergyDeposit const& edep) const
130  {
131  return {edep.Energy(), CalculateIonization(detProp, edep), CalculateScintillation(edep)};
132  }
133 
134  double ISCalculationSeparate::EFieldAtStep(double const efield,
135  sim::SimEnergyDeposit const& edep) const
136  {
137  return EFieldAtStep(efield, edep.MidPointX(), edep.MidPointY(), edep.MidPointZ());
138  }
139 
140  double ISCalculationSeparate::EFieldAtStep(double const efield,
141  float const x,
142  float const y,
143  float const z) const
144  {
145  if (not fSCE->EnableSimEfieldSCE()) { return efield; }
146 
147  auto const offsets = fSCE->GetEfieldOffsets(geo::Point_t{x, y, z});
148  return std::hypot(efield + efield * offsets.X(), efield * offsets.Y(), efield * offsets.Z());
149  }
150 
151 } // namespace
Float_t x
Definition: compare.C:6
virtual bool EnableSimEfieldSCE() const =0
virtual double AlphaScintYield(bool prescale=false) const =0
geo::Length_t StepLength() const
Utilities related to art service access.
const detinfo::LArProperties * fLArProp
double fGeVToElectrons
from LArG4Parameters service
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
Detector simulation of raw signals on wires.
double CalculateIonization(detinfo::DetectorPropertiesData const &detProp, sim::SimEnergyDeposit const &edep) const
ISCalculationSeparate(fhicl::ParameterSet const &pset)
const spacecharge::SpaceCharge * fSCE
double Efield(unsigned int planegap=0) const
kV/cm
virtual double ProtonScintYield(bool prescale=false) const =0
double EFieldAtStep(double efield, sim::SimEnergyDeposit const &edep) const
T get(std::string const &key) const
Definition: ParameterSet.h:314
virtual double ElectronScintYield(bool prescale=false) const =0
Data CalculateIonizationAndScintillation(detinfo::DetectorPropertiesData const &detProp, sim::SimEnergyDeposit const &edep) const
virtual double PionScintYield(bool prescale=false) const =0
Double_t edep
Definition: macro.C:13
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2675
geo::Length_t MidPointX() const
geo::Length_t MidPointY() const
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
virtual geo::Vector_t GetEfieldOffsets(geo::Point_t const &point) const =0
virtual double MuonScintYield(bool prescale=false) const =0
virtual double KaonScintYield(bool prescale=false) const =0
contains information for a single step in the detector simulation
geo::Length_t MidPointZ() const
virtual double ScintYield(bool prescale=false) const =0
Energy deposition in the active material.
#define MF_LOG_DEBUG(id)
double Energy() const
Float_t e
Definition: plot.C:35
virtual bool ScintByParticleType() const =0
double CalculateScintillation(sim::SimEnergyDeposit const &edep) const