DetectorPropertiesStandard.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file DetectorProperties.h
3 //
4 // \brief service to contain information about detector electronics, etc
5 //
6 // \author brebel@fnal.gov
7 //
8 // Separation of service from Detector info class:
9 // jpaley@fnal.gov
10 ////////////////////////////////////////////////////////////////////////
11 #ifndef DETINFO_DETECTORPROPERTIESSTD_H
12 #define DETINFO_DETECTORPROPERTIESSTD_H
13 
14 // GArSoft libraries
15 #include "Geometry/GeometryCore.h"
16 #include "CoreUtils/ProviderPack.h"
19 #include "DetectorInfo/DetectorClocks.h"
20 #include "DetectorInfo/DetectorProperties.h"
21 
22 // framework libraries
23 #include "fhiclcpp/ParameterSet.h"
25 #include "fhiclcpp/types/Table.h"
26 #include "fhiclcpp/types/Atom.h"
27 
28 // C/C++ standard libraries
29 #include <set>
30 
31 ///General GArSoft Utilities
32 namespace gar {
33  namespace detinfo{
34 
36  public:
37  /// List of service providers we depend on
42 
43  /// Structure for configuration parameters
44  struct Configuration_t {
45  using Name = fhicl::Name;
47 
49  Name ("Efield"),
50  Comment("electric field in front of each wire plane (the last one is the big one!) [kV/cm]")
51  };
52 
54  Name ("Electronlifetime"),
55  Comment("electron lifetime in gaseous argon [us]")
56  };
58  Name ("Temperature"),
59  Comment("argon temperature [K]")
60  };
62  Name ("DriftVelocity"),
63  Comment("electron drift velocity in cm/us")
64  };
66  Name ("ElectronsToADC"),
67  Comment("conversion factor: (ADC counts)/(ionization electrons)")
68  };
70  Name ("NumberTimeSamples"),
71  Comment("number of TPC readout TDC clock ticks per event (= readout window)")
72  };
73 
75  Name ("SternheimerA"),
76  Comment("parameter a of Sternheimer correction delta = 2log(10) x - cbar + { a (x1-x)^k } theta(x1-x), x = log10(p/m)")
77  };
79  Name ("SternheimerK"),
80  Comment("parameter k of Sternheimer correction delta = 2log(10) x - cbar + { a (x_1-x)^k } theta(x1-x), x = log10(p/m)")
81  };
83  Name ("SternheimerX0"),
84  Comment("minimum x = log10(p/m) for the application of Sternheimer correction")
85  };
87  Name ("SternheimerX1"),
88  Comment("parameter x_1 of Sternheimer correction delta = 2log(10) x - cbar + { a (x_1-x)^k } theta(x1-x), x = log10(p/m)")
89  };
91  Name ("SternheimerCbar"),
92  Comment("parameter cbar of Sternheimer correction delta = 2log(10) x - cbar + { a (x_1-x)^k } theta(x1-x), x = log10(p/m)")
93  };
94 
95  }; // Configuration_t
96 
99  const geo::GeometryCore * geo,
100  const detinfo::GArProperties* gp,
101  const detinfo::ECALProperties* ecalp,
102  const detinfo::DetectorClocks* c,
103  std::set<std::string> const& ignore_params = {});
104 
105  /**
106  * @brief Constructs the provider and sets up the dependencies
107  * @param pset FHiCL parameter set for provider configuration
108  * @param providers pack of providers DetectorPropertiesStandard depends on
109  * @see Setup()
110  */
112  providers_type providers,
113  std::set<std::string> const& ignore_params = {});
115  virtual ~DetectorPropertiesStandard() = default;
116 
117  /**
118  * @brief Configures the provider, first validating the configuration
119  * @param p configuration parameter set
120  * @param ignore_params parameters to be ignored (optional)
121  *
122  * This method will validate the parameter set (except for the parameters
123  * it's explicitly told to ignore) and extract the useful information out
124  * of it.
125  */
127  std::set<std::string> const& ignore_params = {});
128 
129 
130  /// Extracts the relevant configuration from the specified object
131  void Configure(Configuration_t const& config);
132 
133  /**
134  * @brief Validates the specified configuration
135  * @param p configuration parameter set
136  * @param ignore_params parameters to be ignored (optional)
137  * @return a parsed configuration object
138  * @see ValidateAndConfigure(), Configure()
139  *
140  * This method will validate the parameter set (except for the parameters
141  * it's explicitly told to ignore) and it returns an object ready to
142  * be used with Configure().
143  */
145  std::set<std::string> const& ignore_params = {});
146 
147  bool Update(uint64_t ts);
148  bool UpdateClocks(const detinfo::DetectorClocks* clks);
149 
150  /**
151  * @brief Sets all the providers at once
152  * @param providers the pack of service providers we depend on
153  *
154  * Example:
155  *
156  * gar::DetectorPropertiesStandard::providers_type providers;
157  * providers.set(gar::providerFrom<geo::GeometryGAr>());
158  * providers.set(gar::providerFrom<detinfo::GArPropertiesService>());
159  * providers.set(gar::providerFrom<detinfo::DetectorClocksService>());
160  * detprop->Setup(providers);
161  *
162  */
163  void Setup(providers_type providers);
164 
165  void SetGeometry (const geo::GeometryCore* g) { fGeo = g; }
166  void SetGArProperties (const detinfo::GArProperties* gp) { fGP = gp; }
167  void SetECALProperties (const detinfo::ECALProperties* ecalp) { fECALP = ecalp; }
168  void SetDetectorClocks(const detinfo::DetectorClocks* clks) { fClocks = clks; }
169 
170  void SetNumberTimeSamples(unsigned int nsamp) { fNumberTimeSamples=nsamp;}
171  // Accessors.
172 
173  virtual double Efield(unsigned int planegap=0) const override; ///< kV/cm
174 
175  virtual double DriftVelocity(double efield=0.,
176  double temperature=0.,
177  bool cmPerns=true) const override; ///< cm/ns if true, otherwise cm/us
178 
179  /// dQ/dX in electrons/cm, returns dE/dX in MeV/cm.
180 
181  virtual double ElectronLifetime() const override { return fElectronlifetime; } //< microseconds
182 
183  /**
184  * @brief Returns argon density at a given temperature
185  * @param temperature the temperature in kelvin
186  * @return argon density in g/cm^3
187  *
188  * Density is nearly a linear function of temperature.
189  * See the NIST tables for details
190  * Slope is between -6.2 and -6.1, intercept is 1928 kg/m^3.
191  * This parameterization will be good to better than 0.5%.
192  */
193  virtual double Density(double temperature) const override; ///< g/cm^3
194 
195  // need to provide a definition, since the override above hides the inherited one
196  virtual double Density() const override { return Density(Temperature()); }
197 
198  /// In kelvin.
199  virtual double Temperature() const override { return fTemperature; }
200 
201  /**
202  * @brief Restricted mean energy loss (dE/dx)
203  * @param mom momentum of incident particle [GeV/c]
204  * @param mass mass of incident particle [GeV/c^2]
205  * @param tcut maximum kinetic energy of delta rays [MeV]; 0 for unlimited
206  * @return the restricted mean energy loss (dE/dx) in units of MeV/cm
207  *
208  * Returned value is always positive.
209  * For unrestricted mean energy loss, set tcut = 0 (special case),
210  * or tcut large.
211  *
212  * Based on Bethe-Bloch formula as contained in particle data book.
213  * Material parameters are from the configuration.
214  */
215  virtual double Eloss(double mom, double mass, double tcut) const override;
216 
217  /**
218  * @brief Energy loss fluctuation (@f$ \sigma_{E}^2 / x @f$)
219  * @param mom momentum of incident particle in [GeV/c]
220  * @return energy loss fluctuation in MeV^2/cm
221  *
222  * Based on Bichsel formula referred to but not given in pdg.
223  */
224  virtual double ElossVar(double mom, double mass) const override;
225 
226  virtual double SamplingRate() const override { return fTPCClock.TickPeriod() * 1.e3; }
227  virtual double ElectronsToADC() const override { return fElectronsToADC; }
228  virtual unsigned int NumberTimeSamples() const override { return fNumberTimeSamples; }
229  virtual int TriggerOffset() const override;
230 
231  virtual double ConvertXToTicks(double X) const override;
232  virtual double ConvertTicksToX(double ticks) const override;
233 
234  // The following methods convert between TDC counts (SimChannel time) and
235  // ticks (RawDigit/Wire time).
236  virtual double ConvertTDCToTicks(double tdc) const override;
237  virtual double ConvertTicksToTDC(double ticks) const override;
238 
239  //ECAL Properties
240  virtual double EffectivePixel() const override { return fECALP->EffectivePixel(); }
241  virtual double LightYield() const override { return fECALP->LightYield(); }
242  virtual double SiPMGain() const override { return fECALP->SiPMGain(); }
243  virtual double IntercalibrationFactor() const override { return fECALP->IntercalibrationFactor(); }
244  virtual double ADCSaturation() const override { return fECALP->ADCSaturation(); }
245  virtual double TimeResolution() const override { return fECALP->TimeResolution(); }
246  virtual double MeVtoMIP() const override { return fECALP->MeVtoMIP(); }
247  virtual double NoisePx() const override { return fECALP->NoisePx(); }
248 
249  /// Verifies that the provider is in a fully configured status
250  /// @throw cet::exception (category DetectorPropertiesStandard) if not ok
251  void CheckIfConfigured() const;
252 
253  protected:
254 
255 
256  /// Parameters for Sternheimer density effect corrections
258  double a; ///< parameter a
259  double k; ///< parameter k
260  double x0; ///< parameter x0
261  double x1; ///< parameter x1
262  double cbar; ///< parameter Cbar
263  }; // SternheimerParameters_t
264 
265  void CalculateXTicksParams();
266 
267  // service providers we depend on;
268  // in principle could be replaced by a single providerpacl_type.
269  const detinfo::GArProperties* fGP;
270  const detinfo::ECALProperties* fECALP;
272  const geo::GeometryCore* fGeo;
273 
274  std::vector< double > fEfield; ///< kV/cm (per inter-plane volume)
275  double fElectronlifetime; ///< microseconds
276  double fTemperature; ///< kelvin
277  double fDriftVelocity; ///< centimeters / microsecond
278  double fSamplingRate; ///< in ns
279  double fElectronsToADC; ///< conversion factor for # of ionization electrons to 1 ADC count
280  unsigned int fNumberTimeSamples; ///< number of clock ticks per event (= readout window)
281 
282  SternheimerParameters_t fSternheimerParameters; ///< Sternheimer parameters
283 
284  double fXTicksCoefficient; ///< Parameters for x<-->ticks
285 
286  detinfo::ElecClock fTPCClock; ///< TPC electronics clock
287  }; // class DetectorPropertiesStandard
288  } //namespace detinfo
289 } // gar
290 
291 #endif // DETINFO_DETECTOR_PROPERTIES_H
bool UpdateClocks(const detinfo::DetectorClocks *clks)
void Setup(providers_type providers)
Sets all the providers at once.
virtual unsigned int NumberTimeSamples() const override
SternheimerParameters_t fSternheimerParameters
Sternheimer parameters.
static constexpr double g
Definition: Units.h:144
virtual double IntercalibrationFactor() const override
void SetDetectorClocks(const detinfo::DetectorClocks *clks)
virtual double ADCSaturation() const =0
virtual double ConvertTDCToTicks(double tdc) const override
ChannelGroupService::Name Name
Description of geometry of one entire detector.
Definition: GeometryCore.h:436
virtual double MeVtoMIP() const =0
virtual double Temperature() const override
In kelvin.
void ValidateAndConfigure(fhicl::ParameterSet const &p, std::set< std::string > const &ignore_params={})
Configures the provider, first validating the configuration.
tick ticks
Alias for common language habits.
Definition: electronics.h:78
double fXTicksCoefficient
Parameters for x<–>ticks.
virtual double SiPMGain() const =0
virtual double TimeResolution() const =0
Parameters for Sternheimer density effect corrections.
virtual double ConvertXToTicks(double X) const override
double TickPeriod() const
A single tick period in nano-second, frequency is in MHz.
Definition: ElecClock.h:125
Container for a list of pointers to providers.
Definition: ProviderPack.h:90
virtual double ElossVar(double mom, double mass) const override
Energy loss fluctuation ( )
static Config * config
Definition: config.cpp:1054
virtual double ConvertTicksToX(double ticks) const override
virtual double Density() const override
Returns argon density at the temperature from Temperature()
p
Definition: test.py:223
void SetGArProperties(const detinfo::GArProperties *gp)
General LArSoft Utilities.
virtual double LightYield() const =0
virtual double ElectronLifetime() const override
dQ/dX in electrons/cm, returns dE/dX in MeV/cm.
virtual double NoisePx() const =0
virtual double ConvertTicksToTDC(double ticks) const override
General GArSoft Utilities.
#define Comment
virtual double EffectivePixel() const =0
double fElectronsToADC
conversion factor for # of ionization electrons to 1 ADC count
Configuration_t ValidateConfiguration(fhicl::ParameterSet const &p, std::set< std::string > const &ignore_params={})
Validates the specified configuration.
void SetECALProperties(const detinfo::ECALProperties *ecalp)
virtual double IntercalibrationFactor() const =0
std::vector< double > fEfield
kV/cm (per inter-plane volume)
LArSoft geometry interface.
Definition: ChannelGeo.h:16
unsigned int fNumberTimeSamples
number of clock ticks per event (= readout window)
void Configure(Configuration_t const &config)
Extracts the relevant configuration from the specified object.
double fDriftVelocity
centimeters / microsecond
detinfo::ElecClock fTPCClock
TPC electronics clock.
virtual double Eloss(double mom, double mass, double tcut) const override
Restricted mean energy loss (dE/dx)