DetectorPropertiesStandard.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // \file DetectorProperties.cxx
4 //
5 // Separation of service from Detector info class:
6 // jpaley@fnal.gov
7 //
8 ////////////////////////////////////////////////////////////////////////
9 // Framework includes
10 
11 #include <cassert>
12 
13 // GArSoft includes
14 #include "DetectorInfo/DetectorPropertiesStandard.h"
15 #include "CoreUtils/ProviderUtil.h" // gar::IgnorableProviderConfigKeys()
16 #include "CoreUtils/DebugUtils.h" // gar::IgnorableProviderConfigKeys()
17 #include "Geometry/GeometryGAr.h"
18 
20 
21 // Art includes
23 
24 namespace {
25 
26  template <typename T>
27  inline T sqr(T v) { return v*v; }
28 
29 } // local namespace
30 
31 namespace gar {
32  namespace detinfo{
33 
34  //--------------------------------------------------------------------
36  : fGP(0)
37  , fECALP(0)
38  , fClocks(0)
39  , fGeo(0)
40  {
41 
42  }
43 
44  //--------------------------------------------------------------------
46  const geo::GeometryCore* geo,
48  const detinfo::ECALProperties* ecalp,
50  std::set<std::string> const& ignore_params /* = {} */)
51  : fGP(gp)
52  , fECALP(ecalp)
53  , fClocks(c)
54  , fGeo(geo)
55  {
56  {
57  mf::LogInfo debug("setupProvider<DetectorPropertiesStandard>");
58 
59  debug << "Asked to ignore " << ignore_params.size() << " keys:";
60  for (auto const& key: ignore_params) debug << " '" << key << "'";
61  }
62 
63  ValidateAndConfigure(pset, ignore_params);
64 
66 
67  MF_LOG_WARNING("DetectorPropertiesStandard")
68  << "DetectorPropertiesStandard Warning!"
69  << "\t The following functions need to be verified for gaseous argon:"
70  << "\t\t BirksCorrection"
71  << "\t\t Density"
72  << "\t\t DriftVelocity"
73  << "\t\t EField";
74 
75 
76  }
77 
78  //--------------------------------------------------------------------
80  providers_type providers,
81  std::set<std::string> const& ignore_params /* = {} */)
83  providers.get<geo::GeometryCore>(),
84  providers.get<detinfo::GArProperties>(),
85  providers.get<detinfo::ECALProperties>(),
86  providers.get<detinfo::DetectorClocks>(),
87  ignore_params)
88  {}
89 
90  //--------------------------------------------------------------------
92  {
93 
95  return true;
96  }
97 
98  //--------------------------------------------------------------------
100  {
101  fClocks = clks;
102 
105  return true;
106  }
107 
108  //------------------------------------------------------------
110  {
111  return fClocks->TPCTDC2Tick(tdc);
112  }
113 
114  //--------------------------------------------------------------
116  {
117  return fClocks->TPCTick2TDC(ticks);
118  }
119 
120 
121  //--------------------------------------------------------------------
123 
124  fEfield = config.Efield();
126  fTemperature = config.Temperature();
127  fDriftVelocity = config.DriftVelocity();
128  fElectronsToADC = config.ElectronsToADC();
130 
136 
138 
139  } // DetectorPropertiesStandard::Configure()
140 
141  //--------------------------------------------------------------------
144  std::set<std::string> const& ignore_params /* = {} */)
145  {
146  std::set<std::string> ignorable_keys = gar::IgnorableProviderConfigKeys();
147  ignorable_keys.insert(ignore_params.begin(), ignore_params.end());
148 
149  gar::debug::printBacktrace(mf::LogDebug("DetectorPropertiesStandard"), 15);
150 
151  // parses and validates the parameter set:
152  fhicl::Table<Configuration_t> config_table { p, ignorable_keys };
153 
154  return std::move(config_table());
155 
156  } // DetectorPropertiesStandard::ValidateConfiguration()
157 
158  //--------------------------------------------------------------------
160  std::set<std::string> const& ignore_params /* = {} */)
161  {
162  Configure(ValidateConfiguration(p, ignore_params));
163  } // ValidateAndConfigure()
164 
165 
166  //------------------------------------------------------------------------------------//
168 
169  SetGeometry(providers.get<geo::GeometryCore>());
173 
174  } // DetectorPropertiesStandard::Setup()
175 
176 
177  //------------------------------------------------------------------------------------//
178  double DetectorPropertiesStandard::Efield(unsigned int planegap) const
179  {
180  if(planegap >= fEfield.size())
181  throw cet::exception("DetectorPropertiesStandard")
182  << "requesting Electric field in a plane gap that is not defined\n";
183 
184  return fEfield[planegap];
185  }
186 
187 
188  //------------------------------------------------
189  double DetectorPropertiesStandard::Density(double temperature) const
190  {
191  // Default temperature use internal value.
192  if(temperature == 0.)
193  temperature = Temperature();
194 
195  double density = -0.00615*temperature + 1.928;
196 
197  return density;
198  } // DetectorPropertiesStandard::Density()
199 
200 
201  //----------------------------------------------------------------------------------
202  // Restricted mean energy loss (dE/dx) in units of MeV/cm.
203  //
204  // For unrestricted mean energy loss, set tcut = 0, or tcut large.
205  //
206  // Arguments:
207  //
208  // mom - Momentum of incident particle in GeV/c.
209  // mass - Mass of incident particle in GeV/c^2.
210  // tcut - Maximum kinetic energy of delta rays (MeV).
211  //
212  // Returned value is positive.
213  //
214  // Based on Bethe-Bloch formula as contained in particle data book.
215  // Material parameters (stored in GArProperties.fcl) are taken from
216  // pdg web site http://pdg.lbl.gov/AtomicNuclearProperties/
217  //
219  double mass,
220  double tcut) const
221  {
222  // Some constants.
223 
224  double K = 0.307075; // 4 pi N_A r_e^2 m_e c^2 (MeV cm^2/mol).
225  double me = 0.510998918; // Electron mass (MeV/c^2).
226 
227  // Calculate kinematic quantities.
228 
229  double bg = mom / mass; // beta*gamma.
230  double gamma = sqrt(1. + bg*bg); // gamma.
231  double beta = bg / gamma; // beta (velocity).
232  double mer = 0.001 * me / mass; // electron mass / mass of incident particle.
233  double tmax = 2.*me* bg*bg / (1. + 2.*gamma*mer + mer*mer); // Maximum delta ray energy (MeV).
234 
235  // Make sure tcut does not exceed tmax.
236 
237  if(tcut == 0. || tcut > tmax)
238  tcut = tmax;
239 
240  // Calculate density effect correction (delta).
241 
242  double x = std::log10(bg);
243  double delta = 0.;
244  if(x >= fSternheimerParameters.x0) {
245  delta = 2. * std::log(10.) * x - fSternheimerParameters.cbar;
246  if(x < fSternheimerParameters.x1)
248  }
249 
250  // Calculate stopping number.
251 
252  double B = 0.5 * std::log(2.*me*bg*bg*tcut / (1.e-12 * sqr(fGP->ExcitationEnergy())))
253  - 0.5 * beta*beta * (1. + tcut / tmax) - 0.5 * delta;
254 
255  // Don't let the stopping number become negative.
256 
257  if(B < 1.)
258  B = 1.;
259 
260  // Calculate dE/dx.
261 
262  double dedx = Density() * K*fGP->AtomicNumber()*B / (fGP->AtomicMass() * beta*beta);
263 
264  // Done.
265 
266  return dedx;
267  } // DetectorPropertiesStandard::Eloss()
268 
269  //----------------------------------------------------------------------------------
271  double mass) const
272  {
273  // Some constants.
274 
275  double K = 0.307075; // 4 pi N_A r_e^2 m_e c^2 (MeV cm^2/mol).
276  double me = 0.510998918; // Electron mass (MeV/c^2).
277 
278  // Calculate kinematic quantities.
279 
280  double bg = mom / mass; // beta*gamma.
281  double gamma2 = 1. + bg*bg; // gamma^2.
282  double beta2 = bg*bg / gamma2; // beta^2.
283 
284  // Calculate final result.
285 
286  double result = gamma2 * (1. - 0.5 * beta2) * me * (fGP->AtomicNumber() / fGP->AtomicMass()) * K * Density();
287  return result;
288  } // DetectorPropertiesStandard::ElossVar()
289 
290 
291  //------------------------------------------------------------------------------------//
293  double temperature,
294  bool cmPerns) const
295  {
296 
297  // Efield should have units of kV/cm
298  // Temperature should have units of Kelvin
299 
300  // Default Efield, use internal value.
301  if(efield == 0.)
302  efield = Efield();
303 
304  //
305  //if(efield > 4.0)
306  // MF_LOG_WARNING("DetectorPropertiesStandard")
307  // << "DriftVelocity Warning! : E-field value of "
308  // << efield
309  // << " kV/cm is outside of range covered by drift"
310  // << " velocity parameterization. Returned value"
311  //<< " may not be correct";
312 
313  // Default temperature use internal value.
314  if(temperature == 0.)
315  temperature = Temperature();
316 
317  // read in from fcl parameter
318 
319  double vd = fDriftVelocity; // cm/us. For now just take it out of a fcl parameter. Calcualted with magboltz and it's a strong function of gas composition
320 
321  if(cmPerns) return vd * 1.e-3; // cm/ns
322 
323  return vd; // in cm/us
324  }
325 
326  //------------------------------------------------------------------------------------//
328  {
329  return fTPCClock.Ticks(fClocks->TriggerOffsetTPC() * -1.);
330  }
331 
332 
333  //--------------------------------------------------------------------
334  // Take an X coordinate, and convert to a number of ticks, the
335  // charge deposit occured at t=0
337  {
338  return (X / fXTicksCoefficient);
339  }
340 
341  //-------------------------------------------------------------------
342  // Take a cooridnate in ticks, and convert to an x position
343  // assuming event deposit occured at t=0
345  {
346  return ticks * fXTicksCoefficient;
347  }
348 
349 
350  //--------------------------------------------------------------------
352  {
353  if (!fGeo) throw cet::exception(__FUNCTION__) << "Geometry is uninitialized!";
354  if (!fGP) throw cet::exception(__FUNCTION__) << "GArPropertiesStandard is uninitialized!";
355  if (!fECALP) throw cet::exception(__FUNCTION__) << "ECALPropertiesStandard is uninitialized!";
356  if (!fClocks) throw cet::exception(__FUNCTION__) << "DetectorClocks is uninitialized!";
357  }
358 
359  //--------------------------------------------------------------------
360  // Recalculte x<-->ticks conversion parameters from detector constants
362  {
364 
365  double samplingRate = SamplingRate();
366  double efield = Efield();
367  double temperature = Temperature();
368  double driftVelocity = DriftVelocity(efield, temperature);
369 
370  fXTicksCoefficient = 0.001 * driftVelocity * samplingRate;
371 
372  return;
373  }
374 
375  } // namespace
376 } // gar
bool UpdateClocks(const detinfo::DetectorClocks *clks)
void Setup(providers_type providers)
Sets all the providers at once.
SternheimerParameters_t fSternheimerParameters
Sternheimer parameters.
virtual double TPCTDC2Tick(double tdc) const =0
Given electronics clock count [tdc] returns TPC time-tick.
double beta(double KE, const simb::MCParticle *part)
static QCString result
Provider const * get() const
Returns the provider with the specified type.
Definition: ProviderPack.h:141
void SetDetectorClocks(const detinfo::DetectorClocks *clks)
virtual double ExcitationEnergy() const =0
Mean excitation energy of the gas (eV)
constexpr T pow(T x)
Definition: pow.h:72
virtual double ConvertTDCToTicks(double tdc) const override
virtual double DriftVelocity(double efield=0., double temperature=0., bool cmPerns=true) const override
cm/ns if true, otherwise cm/us
Description of geometry of one entire detector.
Definition: GeometryCore.h:436
virtual double Temperature() const override
In kelvin.
virtual double AtomicNumber() const =0
Atomic number of the gas.
void ValidateAndConfigure(fhicl::ParameterSet const &p, std::set< std::string > const &ignore_params={})
Configures the provider, first validating the configuration.
virtual double AtomicMass() const =0
Atomic mass of the gas (g/mol)
tick ticks
Alias for common language habits.
Definition: electronics.h:78
double fXTicksCoefficient
Parameters for x<–>ticks.
T sqr(T v)
virtual double ConvertXToTicks(double X) const override
Container for a list of pointers to providers.
Definition: ProviderPack.h:90
virtual double ElossVar(double mom, double mass) const override
Energy loss fluctuation ( )
const double e
def key(type, name=None)
Definition: graph.py:13
static Config * config
Definition: config.cpp:1054
virtual double ConvertTicksToX(double ticks) const override
def move(depos, offset)
Definition: depos.py:107
virtual double Density() const override
Returns argon density at the temperature from Temperature()
std::set< std::string > const & IgnorableProviderConfigKeys()
Returns a list of configuration keys that providers should ignore.
Definition: ProviderUtil.h:35
p
Definition: test.py:223
void printBacktrace(Stream &&out, unsigned int maxLines=5, std::string indent=" ", CallInfoPrinter::opt const *options=nullptr)
Prints the full backtrace into a stream.
Definition: DebugUtils.h:249
void SetGArProperties(const detinfo::GArProperties *gp)
General LArSoft Utilities.
double gamma(double KE, const simb::MCParticle *part)
virtual double ConvertTicksToTDC(double ticks) const override
General GArSoft Utilities.
double fElectronsToADC
conversion factor for # of ionization electrons to 1 ADC count
virtual double Efield(unsigned int planegap=0) const override
kV/cm
virtual double TriggerOffsetTPC() const =0
int Ticks() const
of Ticks
Definition: ElecClock.h:95
Configuration_t ValidateConfiguration(fhicl::ParameterSet const &p, std::set< std::string > const &ignore_params={})
Validates the specified configuration.
virtual const ElecClock & TPCClock() const =0
Borrow a const TPC clock with time set to Trigger time [ns].
list x
Definition: train.py:276
void SetECALProperties(const detinfo::ECALProperties *ecalp)
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
#define MF_LOG_WARNING(category)
std::vector< double > fEfield
kV/cm (per inter-plane volume)
LArSoft geometry interface.
Definition: ChannelGeo.h:16
art framework interface to geometry description
unsigned int fNumberTimeSamples
number of clock ticks per event (= readout window)
virtual double TPCTick2TDC(double tick) const =0
Given TPC time-tick (waveform index), returns electronics clock count [tdc].
void Configure(Configuration_t const &config)
Extracts the relevant configuration from the specified object.
double fDriftVelocity
centimeters / microsecond
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
detinfo::ElecClock fTPCClock
TPC electronics clock.
virtual double Eloss(double mom, double mass, double tcut) const override
Restricted mean energy loss (dE/dx)