LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
LinearEnergyAlg.h
Go to the documentation of this file.
1 
9 #ifndef LARRECO_CALORIMETRY_LINEARENERGYALG_H
10 #define LARRECO_CALORIMETRY_LINEARENERGYALG_H
11 
12 
13 // LArSoft libraries
19 #include "larcoreobj/SimpleTypesAndConstants/PhysicalConstants.h" // util::kModBoxA ...
20 
21 // infrastructure and utilities
22 // #include "cetlib/exception.h"
25 #include "fhiclcpp/types/Comment.h"
26 #include "fhiclcpp/types/Name.h"
27 #include "fhiclcpp/types/Atom.h"
28 #include "fhiclcpp/types/Table.h"
29 #include "fhiclcpp/ParameterSet.h"
30 
31 // C/C++ standard libraries
32 #include <vector>
33 #include <utility> // std::forward()
34 #include <type_traits> // std::is_same, std::decay_t
35 
36 namespace calo {
37 
80 
81  public:
82 
83  struct ModelName {
84  static const std::string ModBox;
85  static const std::string Birks;
86  static const std::string Constant;
87  };
88 
94  };
95 
96 
99 
100  using Name = fhicl::Name;
102 
103  bool modelIsBirks() const
104  { return Model() == ModelName::Birks; }
105  bool modelIsModBox() const
106  { return Model() == ModelName::ModBox; }
107  bool modelIsConstant() const
108  { return Model() == ModelName::Constant; }
109 
110 
112  Name("Model"),
113  Comment(std::string("Which recombination model to use: "
114  + ModelName::ModBox + ", "
115  + ModelName::Birks + ", "
116  + ModelName::Constant + ".").c_str()
117  )
118  };
119 
121  Name("A"),
122  Comment("Parameter \"A\" of box model."),
125  };
126 
128  Name("B"),
129  Comment("Parameter \"B\" of box model [kV/cm*(g/cm^2)/MeV]."),
132  };
133 
135  Name("A3t"),
136  Comment("Recombination parameter \"A\" of Birks model."),
139  };
140 
142  Name("k3t"),
143  Comment("Recombination parameter \"k\" of Birks model [kV/cm*(g/cm^2)/MeV]."),
146  };
147 
149  Name("factor"),
150  Comment("Constant recombination factor for \"constant\" model."),
152  };
153 
154  }; // RecombinationConfig
155 
156 
158  struct Config {
159 
160  using Name = fhicl::Name;
162 
164  Name("UseArea"),
165  Comment("Whether to use the area of hit to count the deposited charges.")
166  };
167 
169  Name("Recombination"),
170  Comment("Parameters of the recombination model")
171  };
172 
173  }; // Config
174 
175 
178 
185  LinearEnergyAlg(Config const& config);
186 
187 
199  : LinearEnergyAlg(fhicl::Table<Config>(pset, {})())
200  {}
201 
203 
206 
214  void setup( detinfo::DetectorProperties const& detproperty, detinfo::DetectorClocks const& detclock, geo::GeometryCore const& geometry )
215  { detp = &detproperty; detc = &detclock; geom = &geometry; initialize(); }
216 
232  template <typename Stream>
233  void DumpConfiguration
234  (Stream&& out, std::string indent, std::string firstIndent) const;
235 
247  template <typename Stream>
248  void DumpConfiguration(Stream&& out, std::string indent = "") const
249  { DumpConfiguration(std::forward<Stream>(out), indent, indent); }
250 
252 
255 
271  template <typename BeginHitIter, typename EndHitIter>
273  (recob::Cluster const& cluster, BeginHitIter beginHit, EndHitIter endHit)
274  const;
275 
288  template <typename Hits>
290  (recob::Cluster const& cluster, Hits&& hits) const
291  {
292  using std::begin; using std::end;
293  return CalculateClusterEnergy(cluster, begin(hits), end(hits));
294  }
295 
296 
309  std::vector<double> CalculateEnergy(
310  std::vector<art::Ptr<recob::Cluster>> const& clusters,
311  art::Assns<recob::Cluster, recob::Hit> const& hitsPerCluster
312  ) const;
313 
315 
316  private:
317 
319  double A = util::kModBoxA;
320  double B = util::kModBoxB;
321  };
322 
324  double A = util::kRecombA;
325  double k = util::kRecombk;
326  };
327 
329  double factor = 1.0; // no sensible default value here
330  };
331 
333  geo::GeometryCore const* geom = nullptr;
334 
337 
339  detinfo::DetectorClocks const* detc = nullptr;
340 
341  bool fUseArea;
343 
350 
351  // TODO
352  // double fRecombA;
353  // double fRecombk;
354  // double fModBoxA;
355  // double fModBoxB;
356  // double fRecombFactor;
358  double fDeconNorm;
359 
360  static constexpr double kWion = 23.6e-9;
361  // Conversion for energy deposited in GeV to number of ionization electrons produced
362  static constexpr double kRecombFactor = 0.62;
363 
364  void initialize();
365 
374  double CalculateHitEnergy(recob::Hit const& hit) const;
375 
376  double RecombinationCorrection( double dEdx ) const;
377 
378  double ModBoxInverse( double dEdx ) const;
379 
380  double BirksInverse( double dEdx ) const;
381 
382  }; // class LinearEnergyAlg
383 
384 } // namespace calo
385 
386 
387 
388 //------------------------------------------------------------------------------
389 //--- template implementation
390 //---
391 template <typename BeginHitIter, typename EndHitIter>
393  (recob::Cluster const& cluster, BeginHitIter beginHit, EndHitIter endHit)
394  const
395 {
396  static_assert( // check the hits type
397  std::is_same<std::decay_t<decltype(**beginHit)>, recob::Hit>::value,
398  "The hits must be stored as recob::Hit pointers!" // any pointer will do
399  );
400 
401  double E = 0.0; // total cluster energy
402 
403  for (auto hitIter = beginHit; hitIter != endHit; ++hitIter) {
404 
405  E += CalculateHitEnergy(**hitIter);
406 
407  } // for
408 
409  return E;
410 
411 } // calo::LinearEnergyAlg::CalculateEnergy()
412 
413 
414 //------------------------------------------------------------------------------
415 template <typename Stream>
417  (Stream&& out, std::string indent, std::string firstIndent) const
418 {
419 
420  out << firstIndent << "LinearEnergyAlg configuration:"
421  << "\n" << indent << " use hit " << (fUseArea? "area": "peak amplitude")
422  << " for charge estimation"
423  << "\n" << indent << " recombination model: ";
424  switch ( fRecombModel ) {
425  case kModBox:
426  out << ModelName::ModBox
427  << "\n" << indent << " A = " << recombModBoxParams.A
428  << "\n" << indent << " B = " << recombModBoxParams.B;
429  break;
430  case kBirks:
431  out << ModelName::Birks
432  << "\n" << indent << " A = " << recombBirksParams.A
433  << "\n" << indent << " k = " << recombBirksParams.k;
434  break;
435  case kConstant:
436  out << ModelName::Constant
437  << "\n" << indent << " k = " << recombConstParams.factor;
438  break;
439  default:
440  out << "invalid (" << ((int) fRecombModel) << ")!!!";
441  } // switch
442  out << "\n";
443 
444 } // calo::LinearEnergyAlg::DumpConfiguration()
445 
446 
447 //------------------------------------------------------------------------------
448 
449 
450 
451 
452 
453 #endif // LARRECO_CALORIMETRY_LINEARENERGYALG_H
Calibrates the energy of the clusters.
static const std::string Constant
geo::GeometryCore const * geom
Pointer to the geometry to be used.
LinearEnergyAlg(fhicl::ParameterSet const &pset)
Constructor with configuration validation.
Float_t E
Definition: plot.C:23
std::function< bool()> use_if(T *p, NullaryConfigPredicate_t< T > f)
Declaration of signal hit object.
Int_t B
Definition: plot.C:25
std::vector< double > CalculateEnergy(std::vector< art::Ptr< recob::Cluster >> const &clusters, art::Assns< recob::Cluster, recob::Hit > const &hitsPerCluster) const
Calculates the energy of the shower.
double RecombinationCorrection(double dEdx) const
TODO: make it more flexible.
Set of hits with a 2D structure.
Definition: Cluster.h:71
Cluster finding and building.
pure virtual base interface for detector clocks
double BirksInverse(double dEdx) const
Algorithm configuration.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
Access the description of detector geometry.
static const std::string Birks
void hits()
Definition: readHits.C:15
void setup(detinfo::DetectorProperties const &detproperty, detinfo::DetectorClocks const &detclock, geo::GeometryCore const &geometry)
Sets up the algorithm.
static constexpr double kRecombFactor
constant correction used in the current MicroBooNE shower reconstruction
constexpr double kModBoxB
Modified Box Beta in g/(MeV cm²)*kV/cm.
double CalculateClusterEnergy(recob::Cluster const &cluster, BeginHitIter beginHit, EndHitIter endHit) const
Calculates the energy of a single cluster.
parameter set interface
double ModBoxInverse(double dEdx) const
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::string indent(std::size_t const i)
detinfo::DetectorClocks const * detc
Pointer to the detector clock.
static constexpr double kWion
ionization potenial in LAr, 23.6 eV = 1e, Wion in GeV/e
void DumpConfiguration(Stream &&out, std::string indent="") const
Prints the current algorithm configuration.
Description of geometry of one entire detector.
Declaration of cluster object.
ModBoxParameters recombModBoxParams
Parameters for recombination box model; filled only when this model is selected.
detinfo::DetectorProperties const * detp
Pointer to the detector property.
Detector simulation of raw signals on wires.
Conversion of times between different formats and references.
void DumpConfiguration(Stream &&out, std::string indent, std::string firstIndent) const
Prints the current algorithm configuration.
art::PtrVector< recob::Hit > Hits
std::string value(boost::any const &)
ConstantRecombParameters recombConstParams
Parameters for constant recombination factor; filled only when this model is selected.
LinearEnergyAlg(Config const &config)
Constructor with configuration validation.
constexpr double kRecombk
BirksParameters recombBirksParams
Parameters for recombination Birks model; filled only when this model is selected.
Configuration of parameters of the box model.
static const std::string ModBox
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
constexpr double kRecombA
A constant.
constexpr double kModBoxA
Modified Box Alpha.
calorimetry
double CalculateHitEnergy(recob::Hit const &hit) const
Returns the corrected energy from the hit.