LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
CalorimetryAlg.cxx
Go to the documentation of this file.
1 // \file CalorimetryAlg.cxx
3 //
4 // \brief Functions to calculate dE/dx. Based on code in Calorimetry.cxx
5 //
6 // andrzej.szelc@yale.edu
7 //
9 
10 
11 
13 //
14 
15 #include "TMath.h"
16 
17 // LArSoft includes
20 #include "larevt/CalibrationDBI/Interface/ElectronLifetimeService.h"
21 #include "larevt/CalibrationDBI/Interface/ElectronLifetimeProvider.h"
22 
23 namespace calo{
24 
25  //--------------------------------------------------------------------
27  {
28  this->reconfigure(config);
29 
31  }
32 
33  //--------------------------------------------------------------------
35  {
36 
37  }
38 
39  //--------------------------------------------------------------------
40  void CalorimetryAlg::reconfigure(const Config& config)
41  {
42 
45  fUseModBox = config.CaloUseModBox();
48 
49  return;
50  }
51 
52  //------------------------------------------------------------------------------------//
53  // Functions to calculate the dEdX based on the AMPLITUDE of the pulse
54  // ----------------------------------------------------------------------------------//
55  double CalorimetryAlg::dEdx_AMP(art::Ptr< recob::Hit > hit, double pitch, double T0) const
56  {
57  return dEdx_AMP(hit->PeakAmplitude()/pitch, hit->PeakTime(), hit->WireID().Plane, T0);
58  }
59 
60  // ----------------------------------------------------------------------------------//
61  double CalorimetryAlg::dEdx_AMP(recob::Hit const& hit, double pitch, double T0) const
62  {
63  return dEdx_AMP(hit.PeakAmplitude()/pitch, hit.PeakTime(), hit.WireID().Plane, T0);
64  }
65 
67  // ----------------------------------------------------------------------------------//
68  double CalorimetryAlg::dEdx_AMP(double dQ, double time, double pitch, unsigned int plane, double T0) const
69  {
70  double dQdx = dQ/pitch; // in ADC/cm
71  return dEdx_AMP(dQdx, time, plane, T0);
72  }
73 
74  // ----------------------------------------------------------------------------------//
75  double CalorimetryAlg::dEdx_AMP(double dQdx,double time, unsigned int plane, double T0) const
76  {
77  double fADCtoEl=1.;
78 
79  fADCtoEl = fCalAmpConstants[plane];
80 
81  double dQdx_e = dQdx/fADCtoEl; // Conversion from ADC/cm to e/cm
82  return dEdx_from_dQdx_e(dQdx_e,time, T0);
83  }
84 
85  //------------------------------------------------------------------------------------//
86  // Functions to calculate the dEdX based on the AREA of the pulse
87  // ----------------------------------------------------------------------------------//
88  double CalorimetryAlg::dEdx_AREA(art::Ptr< recob::Hit > hit, double pitch, double T0) const
89  {
90  return dEdx_AREA(hit->Integral()/pitch, hit->PeakTime(), hit->WireID().Plane, T0);
91  }
92 
93  // ----------------------------------------------------------------------------------//
94  double CalorimetryAlg::dEdx_AREA(recob::Hit const& hit, double pitch, double T0) const
95  {
96  return dEdx_AREA(hit.Integral()/pitch, hit.PeakTime(), hit.WireID().Plane, T0);
97  }
98 
99  // ----------------------------------------------------------------------------------//
100  double CalorimetryAlg::dEdx_AREA(double dQ,double time, double pitch, unsigned int plane, double T0) const
101  {
102  double dQdx = dQ/pitch; // in ADC/cm
103  return dEdx_AREA(dQdx, time, plane, T0);
104  }
105 
106  // ----------------------------------------------------------------------------------//
107  double CalorimetryAlg::dEdx_AREA(double dQdx,double time, unsigned int plane, double T0) const
108  {
109  double fADCtoEl=1.;
110 
111  fADCtoEl = fCalAreaConstants[plane];
112 
113  double dQdx_e = dQdx/fADCtoEl; // Conversion from ADC/cm to e/cm
114  return dEdx_from_dQdx_e(dQdx_e, time, T0);
115  }
116 
117  // ----------------- apply Lifetime and recombination correction. -----------------//
118  double CalorimetryAlg::dEdx_from_dQdx_e(double dQdx_e, double time, double T0) const
119  {
121  dQdx_e *= LifetimeCorrection(time, T0); // Lifetime Correction (dQdx_e in e/cm)
122  if(fUseModBox) {
123  return detprop->ModBoxCorrection(dQdx_e);
124  } else {
125  return detprop->BirksCorrection(dQdx_e);
126  }
127  }
128 
129 
130  //------------------------------------------------------------------------------------//
131  // for the time being copying from Calorimetry.cxx - should be decided where to keep it.
132  // ----------------------------------------------------------------------------------//
133  double calo::CalorimetryAlg::LifetimeCorrection(double time, double T0) const
134  {
135  float t = time;
136 
137  double timetick = detprop->SamplingRate()*1.e-3; //time sample in microsec
138  double presamplings = detprop->TriggerOffset();
139 
140  t -= presamplings;
141  time = t * timetick - T0*1e-3; // (in microsec)
142 
143  if (fLifeTimeForm==0){
144  //Exponential form
145  double tau = detprop->ElectronLifetime();
146 
147  double correction = exp(time/tau);
148  return correction;
149  }
150  else if (fLifeTimeForm==1){
151  //Exponential+constant form
152  const lariov::ElectronLifetimeProvider& elifetime_provider = art::ServiceHandle<lariov::ElectronLifetimeService>()->GetProvider();
153  double correction = elifetime_provider.Lifetime(time);
154  //std::cout<<correction<<std::endl;
155  return correction;
156  }
157  else{
158  throw cet::exception("CalorimetryAlg") << "Unknow CaloLifeTimeForm "<<fLifeTimeForm<<std::endl;
159  }
160  }
161 
162 } // namespace
fhicl::Atom< int > CaloLifeTimeForm
virtual int TriggerOffset() const =0
double dEdx_AREA(art::Ptr< recob::Hit > hit, double pitch, double T0=0) const
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
Declaration of signal hit object.
virtual double BirksCorrection(double dQdX) const =0
dQ/dX in electrons/cm, returns dE/dX in MeV/cm.
virtual double ModBoxCorrection(double dQdX) const =0
fhicl::Atom< bool > CaloDoLifeTimeCorrection
virtual double SamplingRate() const =0
Returns the period of the TPC readout electronics clock.
void reconfigure(const Config &config)
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Definition: Hit.h:225
float PeakAmplitude() const
The estimated amplitude of the hit at its peak, in ADC units.
Definition: Hit.h:222
fhicl::Sequence< double > CalAmpConstants
fhicl::Atom< bool > CaloUseModBox
std::vector< double > fCalAmpConstants
const detinfo::DetectorProperties * detprop
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
Detector simulation of raw signals on wires.
CalorimetryAlg(const fhicl::ParameterSet &pset)
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:219
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
Float_t e
Definition: plot.C:34
double dEdx_from_dQdx_e(double dQdx_e, double time, double T0=0) const
double LifetimeCorrection(double time, double T0=0) const
double dEdx_AMP(art::Ptr< recob::Hit > hit, double pitch, double T0=0) const
fhicl::Sequence< double > CalAreaConstants
calorimetry
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
virtual double ElectronLifetime() const =0
Returns the attenuation constant for ionization electrons.
std::vector< double > fCalAreaConstants