Classes | Public Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
calo::LinearEnergyAlg Class Reference

Calibrates the energy of the clusters. More...

#include <LinearEnergyAlg.h>

Classes

struct  BirksParameters
 
struct  Config
 Algorithm configuration. More...
 
struct  ConstantRecombParameters
 
struct  ModBoxParameters
 
struct  ModelName
 
struct  RecombinationConfig
 Configuration of parameters of the box model. More...
 

Public Types

enum  RecombinationModel_t { kModBox, kBirks, kConstant, nRecombinationModel }
 

Public Member Functions

Construction and configuration
 LinearEnergyAlg (Config const &config)
 Constructor with configuration validation. More...
 
 LinearEnergyAlg (fhicl::ParameterSet const &pset)
 Constructor with configuration validation. More...
 
Set up
void setup (detinfo::DetectorProperties const &detproperty, detinfo::DetectorClocks const &detclock, geo::GeometryCore const &geometry)
 Sets up the algorithm. More...
 
template<typename Stream >
void DumpConfiguration (Stream &&out, std::string indent, std::string firstIndent) const
 Prints the current algorithm configuration. More...
 
template<typename Stream >
void DumpConfiguration (Stream &&out, std::string indent="") const
 Prints the current algorithm configuration. More...
 
Operations
template<typename BeginHitIter , typename EndHitIter >
double CalculateClusterEnergy (recob::Cluster const &cluster, BeginHitIter beginHit, EndHitIter endHit) const
 Calculates the energy of a single cluster. More...
 
template<typename Hits >
double CalculateClusterEnergy (recob::Cluster const &cluster, Hits &&hits) const
 Calculates the energy of a single cluster. More...
 
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. More...
 

Private Member Functions

void initialize ()
 
double CalculateHitEnergy (recob::Hit const &hit) const
 Returns the corrected energy from the hit. More...
 
double RecombinationCorrection (double dEdx) const
 TODO: make it more flexible. More...
 
double ModBoxInverse (double dEdx) const
 
double BirksInverse (double dEdx) const
 

Private Attributes

geo::GeometryCore const * geom = nullptr
 Pointer to the geometry to be used. More...
 
detinfo::DetectorProperties const * detp = nullptr
 Pointer to the detector property. More...
 
detinfo::DetectorClocks const * detc = nullptr
 Pointer to the detector clock. More...
 
bool fUseArea
 
int fRecombModel
 
ModBoxParameters recombModBoxParams
 Parameters for recombination box model; filled only when this model is selected. More...
 
BirksParameters recombBirksParams
 Parameters for recombination Birks model; filled only when this model is selected. More...
 
ConstantRecombParameters recombConstParams
 Parameters for constant recombination factor; filled only when this model is selected. More...
 
double fElectronLifetime
 
double fDeconNorm
 

Static Private Attributes

static constexpr double kWion = 23.6e-9
 ionization potenial in LAr, 23.6 eV = 1e, Wion in GeV/e More...
 
static constexpr double kRecombFactor = 0.62
 constant correction used in the current MicroBooNE shower reconstruction More...
 

Detailed Description

Calibrates the energy of the clusters.

Configuration

Example of configuration:

EnergyAlgo: {
UseArea: true
Recombination: {
Model: Birks
A3t: 0.8
k3t: 0.0486
}
}

Parameters:

Definition at line 79 of file LinearEnergyAlg.h.

Member Enumeration Documentation

Enumerator
kModBox 
kBirks 
kConstant 
nRecombinationModel 

Definition at line 89 of file LinearEnergyAlg.h.

Constructor & Destructor Documentation

calo::LinearEnergyAlg::LinearEnergyAlg ( Config const &  config)

Constructor with configuration validation.

Parameters
configconfiguration parameter structure

For the configuration, see LinearEnergyAlg documentation.

Definition at line 82 of file LinearEnergyAlg.cxx.

83  : fUseArea( config.UseArea() )
84 // , fRecombFactor( 1. )
85  , fElectronLifetime( 1e10 ) // needs to be read from service
86  , fDeconNorm( 200 )
87 {
88  auto const& recombParams = config.Recombination();
89  if ( recombParams.modelIsModBox()) {
91  recombModBoxParams.A = recombParams.A();
92  recombModBoxParams.B = recombParams.B();
93  }
94  else if ( recombParams.modelIsBirks()) {
96  recombBirksParams.A = recombParams.A3t();
97  recombBirksParams.k = recombParams.k3t();
98  }
99  else if ( recombParams.modelIsConstant()) {
101  recombConstParams.factor = recombParams.factor();
102  }
103  else {
104  throw std::runtime_error
105  ( "Unsupported recombination mode: '" + recombParams.Model() + "'" );
106  }
107 
108  if (!fUseArea) {
109  throw std::runtime_error("Energy correction based on hit peak amplitude not implemented yet.");
110  }
111 
112 }
fhicl::Table< RecombinationConfig > Recombination
static Config * config
Definition: config.cpp:1054
ModBoxParameters recombModBoxParams
Parameters for recombination box model; filled only when this model is selected.
ConstantRecombParameters recombConstParams
Parameters for constant recombination factor; filled only when this model is selected.
BirksParameters recombBirksParams
Parameters for recombination Birks model; filled only when this model is selected.
calo::LinearEnergyAlg::LinearEnergyAlg ( fhicl::ParameterSet const &  pset)
inline

Constructor with configuration validation.

Parameters
psetFHiCL configuration parameter set
See also
SpacePointIsolationAlg(Config const&)

Translates the parameter set into a configuration object and uses the validating constructor to initialise the object.

For the configuration, see LinearEnergyAlg documentation.

Definition at line 198 of file LinearEnergyAlg.h.

200  {}
LinearEnergyAlg(Config const &config)
Constructor with configuration validation.

Member Function Documentation

double calo::LinearEnergyAlg::BirksInverse ( double  dEdx) const
private

Definition at line 229 of file LinearEnergyAlg.cxx.

229  {
230  // Correction for charge quenching using parameterization from
231  // S.Amoruso et al., NIM A 523 (2004) 275
232 
233  double A3t = recombBirksParams.A;
234  double K3t = recombBirksParams.k; // in KV/cm*(g/cm^2)/MeV
235  double rho = detp->Density(); // LAr density in g/cm^3
236  double Efield = detp->Efield(); // Electric Field in the drift region in KV/cm
237  K3t /= rho; // KV/MeV
238 
239  double dQdx = ( A3t/kWion ) / ( K3t / Efield * dEdx + 1);
240 
241  return dQdx;
242 }
double dEdx(float dqdx, float Efield)
Definition: doAna.cpp:21
static constexpr double kWion
ionization potenial in LAr, 23.6 eV = 1e, Wion in GeV/e
virtual double Density(double temperature) const =0
Returns argon density at a given temperature.
detinfo::DetectorProperties const * detp
Pointer to the detector property.
BirksParameters recombBirksParams
Parameters for recombination Birks model; filled only when this model is selected.
virtual double Efield(unsigned int planegap=0) const =0
Returns the nominal electric field in the specified volume.
template<typename BeginHitIter , typename EndHitIter >
double calo::LinearEnergyAlg::CalculateClusterEnergy ( recob::Cluster const &  cluster,
BeginHitIter  beginHit,
EndHitIter  endHit 
) const

Calculates the energy of a single cluster.

Template Parameters
BeginHitItertype of iterator to the first associated hit
EndHitItertype of iterator to the past-the-last associated hit
Parameters
clusterlist of clusters we want the energy of
hitspointers to all hits associated to the cluster
beginHititerator to the first hit associated to the cluster
endHititerator to past-the-last hit associated to the cluster
Returns
the calibrated energy of the specified cluster [GeV]
Todo:
Describe the algorithm

The hits are stored as (constant) pointers.

Definition at line 393 of file LinearEnergyAlg.h.

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()
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
E
Definition: 018_def.c:13
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
double CalculateHitEnergy(recob::Hit const &hit) const
Returns the corrected energy from the hit.
template<typename Hits >
double calo::LinearEnergyAlg::CalculateClusterEnergy ( recob::Cluster const &  cluster,
Hits &&  hits 
) const
inline

Calculates the energy of a single cluster.

Template Parameters
Hitsa range of hits associated with the cluster
Parameters
clusterlist of clusters we want the energy of
hitspointers to all hits associated to the cluster
Returns
the calibrated energy of the specified cluster [GeV]
See also
CalculateClusterEnergy(recob::Cluster const&. BeginHitIter, EndHitIter)

The hits are stored as (constant) pointers into a "range", that is any object (e.g. a STL vector) supporting begin() and end() iterators.

Definition at line 290 of file LinearEnergyAlg.h.

291  {
292  using std::begin; using std::end;
293  return CalculateClusterEnergy(cluster, begin(hits), end(hits));
294  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Cluster finding and building.
double CalculateClusterEnergy(recob::Cluster const &cluster, BeginHitIter beginHit, EndHitIter endHit) const
Calculates the energy of a single cluster.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
std::vector< double > calo::LinearEnergyAlg::CalculateEnergy ( std::vector< art::Ptr< recob::Cluster >> const &  clusters,
art::Assns< recob::Cluster, recob::Hit > const &  hitsPerCluster 
) const

Calculates the energy of the shower.

Parameters
clusterslist of clusters we want the energy of
hitsPerClusterassociations of all clusters to all hits
Returns
a vector with one energy per input cluster [GeV]
See also
CalculateClusterEnergy()

A vector is returned with a entry per plane in the TPC of the clusters. The energy has a very negative value (std::numeric_limits<double>::lowest()) for the planes with no cluster. See CalculateClusterEnergy() for the algorithm details.

Definition at line 147 of file LinearEnergyAlg.cxx.

151 { // input clusters and hits, shower direction?
152 
153  if (clusters.empty()) return {}; // no clusters!!
154 
155  // prepare the energies vector with one entry per plane
156  // (we get the total number of planes of the TPC the cluster is in from geometry)
157  // and initialize them to a ridiculously negative number to start with
158 
159  std::vector<double> clusterEnergies;
160  geo::TPCID refTPC = clusters[0]->Plane();
161  clusterEnergies.resize
162  (geom->TPC(refTPC).Nplanes(), std::numeric_limits<double>::lowest());
163 
164  if ( clusters.size() > clusterEnergies.size() ) {
165  mf::LogError("LinearEnergyAlg") << clusters.size() << " clusters for "
166  << clusterEnergies.size() << " wire planes!";
167  }
168 
169  for (art::Ptr<recob::Cluster> const& cluster: clusters) {
170 
171  auto const plane = cluster->Plane();
172  if (plane != refTPC) {
173  throw std::runtime_error(
174  "Cluster ID=" + std::to_string(cluster->ID())
175  + " is expected on TPC " + std::string(refTPC)
176  + " but is found on plane " + std::string(plane)
177  );
178  }
179 
180  // hitsAssociatedWith() searches for the right association links
181  // to the cluster we are processing
182  double const E = CalculateClusterEnergy
183  (*cluster, hitsAssociatedWith(cluster, hitsPerCluster));
184 
185  auto const planeNo = plane.Plane;
186  if (clusterEnergies[planeNo] >= 0.) {
187  mf::LogWarning("LinearEnergyAlg")
188  << "Warning! two or more clusters share plane "
189  << plane << "! (the last with energy " << E
190  << ", the previous " << clusterEnergies[planeNo] << " GeV)";
191  }
192  clusterEnergies[planeNo] = E;
193 
194  } // for all clusters
195 
196  return clusterEnergies;
197 
198 } // calo::LinearEnergyAlg::CalculateEnergy()
geo::GeometryCore const * geom
Pointer to the geometry to be used.
std::string string
Definition: nybbler.cc:12
unsigned int Nplanes() const
Number of planes in this tpc.
Definition: TPCGeo.h:165
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Cluster finding and building.
double CalculateClusterEnergy(recob::Cluster const &cluster, BeginHitIter beginHit, EndHitIter endHit) const
Calculates the energy of a single cluster.
The data type to uniquely identify a TPC.
Definition: geo_types.h:382
E
Definition: 018_def.c:13
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
double calo::LinearEnergyAlg::CalculateHitEnergy ( recob::Hit const &  hit) const
private

Returns the corrected energy from the hit.

Parameters
hitthe hit to be corrected
Returns
the corrected hit energy [GeV]
Todo:
document the algorithm here

Definition at line 123 of file LinearEnergyAlg.cxx.

124 {
125 
126  double const t = detc->TPCTick2TrigTime( hit.PeakTime() );
127  double const LifetimeCorr = std::exp( t / fElectronLifetime );
128 
129  // hit charge (ADC) -> Coulomb -> Number of electrons -> eV
130  // TODO: implement the non-UseArea option
131  double dE = hit.Integral() * kWion * fDeconNorm;
132 
133  // dE * lifetime correction
134  dE *= LifetimeCorr;
135 
136  // dE / recombination factor
137  double const dEdx = 2.3;
138  double const RecombCorr = RecombinationCorrection( dEdx ) * kWion / dEdx;
139  dE /= RecombCorr;
140 
141  return dE;
142 
143 } // calo::LinearEnergyAlg::CalculateHitEnergy()
double RecombinationCorrection(double dEdx) const
TODO: make it more flexible.
double dEdx(float dqdx, float Efield)
Definition: doAna.cpp:21
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
Detector simulation of raw signals on wires.
virtual double TPCTick2TrigTime(double tick) const =0
Converts a TPC time (in ticks) into a trigger time [µs].
template<typename Stream >
void calo::LinearEnergyAlg::DumpConfiguration ( Stream &&  out,
std::string  indent,
std::string  firstIndent 
) const

Prints the current algorithm configuration.

Template Parameters
Streamtype of output stream
Parameters
outoutput stream where to write the information
indentindentation for all lines
firstIndentspecial indentation for the first line

The configuration parameters are printed in human-readable form. The output starts at the current line of the stream, and it terminates with a new line.

This method does not require the algorithm to have been set up (via Setup()), since it just prints user configuration as given at construction time.

Definition at line 417 of file LinearEnergyAlg.h.

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()
static const std::string Constant
static const std::string Birks
ModBoxParameters recombModBoxParams
Parameters for recombination box model; filled only when this model is selected.
ConstantRecombParameters recombConstParams
Parameters for constant recombination factor; filled only when this model is selected.
BirksParameters recombBirksParams
Parameters for recombination Birks model; filled only when this model is selected.
static const std::string ModBox
template<typename Stream >
void calo::LinearEnergyAlg::DumpConfiguration ( Stream &&  out,
std::string  indent = "" 
) const
inline

Prints the current algorithm configuration.

Template Parameters
Streamtype of output stream
Parameters
outoutput stream where to write the information
indent(default: none) indentation for all lines (including the first one)

The configuration parameters are printed in human-readable form. The output starts at the current line of the stream, and it terminates with a new line.

Definition at line 248 of file LinearEnergyAlg.h.

249  { DumpConfiguration(std::forward<Stream>(out), indent, indent); }
void DumpConfiguration(Stream &&out, std::string indent, std::string firstIndent) const
Prints the current algorithm configuration.
void calo::LinearEnergyAlg::initialize ( )
private

Definition at line 115 of file LinearEnergyAlg.cxx.

115  {
116 
118 
119 }
detinfo::DetectorProperties const * detp
Pointer to the detector property.
virtual double ElectronLifetime() const =0
Returns the attenuation constant for ionization electrons.
double calo::LinearEnergyAlg::ModBoxInverse ( double  dEdx) const
private

Definition at line 216 of file LinearEnergyAlg.cxx.

216  {
217  // Modified Box model correction has better behavior than the Birks
218  // correction at high values of dQ/dx.
219  double rho = detp->Density(); // LAr density in g/cm^3
220  double Efield = detp->Efield(); // Electric Field in the drift region in KV/cm
221  double Beta = recombModBoxParams.B / (rho * Efield);
222  double Alpha = recombModBoxParams.A;
223 
224  double dQdx = std::log ( Alpha + Beta * dEdx ) / ( Beta * kWion );
225 
226  return dQdx;
227 }
double dEdx(float dqdx, float Efield)
Definition: doAna.cpp:21
static constexpr double kWion
ionization potenial in LAr, 23.6 eV = 1e, Wion in GeV/e
ModBoxParameters recombModBoxParams
Parameters for recombination box model; filled only when this model is selected.
virtual double Density(double temperature) const =0
Returns argon density at a given temperature.
detinfo::DetectorProperties const * detp
Pointer to the detector property.
virtual double Efield(unsigned int planegap=0) const =0
Returns the nominal electric field in the specified volume.
double calo::LinearEnergyAlg::RecombinationCorrection ( double  dEdx) const
private

TODO: make it more flexible.

Definition at line 200 of file LinearEnergyAlg.cxx.

200  {
201 
202  switch ( fRecombModel ) {
203  case kModBox:
204  return this->ModBoxInverse( dEdx );
205  case kBirks:
206  return this->BirksInverse( dEdx );
207  case kConstant:
208  return recombConstParams.factor;
209  default:
210  throw std::logic_error
211  ("Unexpected! recombination model in RecombinationCorrection()");
212  }
213 }
double BirksInverse(double dEdx) const
double dEdx(float dqdx, float Efield)
Definition: doAna.cpp:21
double ModBoxInverse(double dEdx) const
ConstantRecombParameters recombConstParams
Parameters for constant recombination factor; filled only when this model is selected.
void calo::LinearEnergyAlg::setup ( detinfo::DetectorProperties const &  detproperty,
detinfo::DetectorClocks const &  detclock,
geo::GeometryCore const &  geometry 
)
inline

Sets up the algorithm.

Parameters
geometrythe geometry service provider

Acquires the geometry description. This method must be called every time the geometry is changed.

Definition at line 214 of file LinearEnergyAlg.h.

215  { detp = &detproperty; detc = &detclock; geom = &geometry; initialize(); }
geo::GeometryCore const * geom
Pointer to the geometry to be used.
detinfo::DetectorClocks const * detc
Pointer to the detector clock.
detinfo::DetectorProperties const * detp
Pointer to the detector property.

Member Data Documentation

detinfo::DetectorClocks const* calo::LinearEnergyAlg::detc = nullptr
private

Pointer to the detector clock.

Definition at line 339 of file LinearEnergyAlg.h.

detinfo::DetectorProperties const* calo::LinearEnergyAlg::detp = nullptr
private

Pointer to the detector property.

Definition at line 336 of file LinearEnergyAlg.h.

double calo::LinearEnergyAlg::fDeconNorm
private

Definition at line 358 of file LinearEnergyAlg.h.

double calo::LinearEnergyAlg::fElectronLifetime
private

Definition at line 357 of file LinearEnergyAlg.h.

int calo::LinearEnergyAlg::fRecombModel
private

Definition at line 342 of file LinearEnergyAlg.h.

bool calo::LinearEnergyAlg::fUseArea
private

Definition at line 341 of file LinearEnergyAlg.h.

geo::GeometryCore const* calo::LinearEnergyAlg::geom = nullptr
private

Pointer to the geometry to be used.

Definition at line 333 of file LinearEnergyAlg.h.

constexpr double calo::LinearEnergyAlg::kRecombFactor = 0.62
staticprivate

constant correction used in the current MicroBooNE shower reconstruction

Definition at line 362 of file LinearEnergyAlg.h.

constexpr double calo::LinearEnergyAlg::kWion = 23.6e-9
staticprivate

ionization potenial in LAr, 23.6 eV = 1e, Wion in GeV/e

Definition at line 360 of file LinearEnergyAlg.h.

BirksParameters calo::LinearEnergyAlg::recombBirksParams
private

Parameters for recombination Birks model; filled only when this model is selected.

Definition at line 347 of file LinearEnergyAlg.h.

ConstantRecombParameters calo::LinearEnergyAlg::recombConstParams
private

Parameters for constant recombination factor; filled only when this model is selected.

Definition at line 349 of file LinearEnergyAlg.h.

ModBoxParameters calo::LinearEnergyAlg::recombModBoxParams
private

Parameters for recombination box model; filled only when this model is selected.

Definition at line 345 of file LinearEnergyAlg.h.


The documentation for this class was generated from the following files: