ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
MuonCalib::TrRelationLookUp Class Reference

#include <TrRelationLookUp.h>

Inheritance diagram for MuonCalib::TrRelationLookUp:
Collaboration diagram for MuonCalib::TrRelationLookUp:

Public Types

using IRtRelationPtr = GeoModel::TransientConstSharedPtr< IRtRelation >
 
using ParVec = std::vector< double >
 

Public Member Functions

 TrRelationLookUp (const IRtRelationPtr &rtRelation, const ParVec &vec={})
 
virtual std::string name () const override final
 
virtual std::optional< double > driftTime (const double r) const override final
 Interface method for fetching the drift-time from the radius Returns a nullopt if the time is out of the boundaries. More...
 
virtual std::optional< double > driftTimePrime (const double r) const override final
 
virtual std::optional< double > driftTime2Prime (const double r) const override final
 
virtual double minRadius () const override final
 Returns the minimum drift-radius. More...
 
virtual double maxRadius () const override final
 Returns the maximum drift-radius. More...
 
virtual std::string typeName () const override final
 
unsigned int nPar () const
 
const ParVecparameters () const
 
double par (unsigned int index) const
 

Private Member Functions

double getTFromR (const double radius, const IRtRelationPtr &rtRelation) const
 

Private Attributes

std::vector< double > m_times {}
 
std::vector< double > m_radii {}
 
double m_minRadius {}
 
double m_maxRadius {}
 
IRtRelationPtr m_rt {}
 
ParVec m_parameters {}
 

Detailed Description

Definition at line 13 of file TrRelationLookUp.h.

Member Typedef Documentation

◆ IRtRelationPtr

Definition at line 15 of file ITrRelation.h.

◆ ParVec

using MuonCalib::CalibFunc::ParVec = std::vector<double>
inherited

Definition at line 35 of file CalibFunc.h.

Constructor & Destructor Documentation

◆ TrRelationLookUp()

MuonCalib::TrRelationLookUp::TrRelationLookUp ( const IRtRelationPtr rtRelation,
const ParVec vec = {} 
)

Definition at line 12 of file TrRelationLookUp.cxx.

12  : ITrRelation{rtRelation, vec} {
13 
14  std::size_t numPoints(100);
15  double stepSize{rtRelation->radius(rtRelation->tUpper()) / (numPoints - 1)};
16  m_times = std::vector<double>(numPoints);
17  m_radii = std::vector<double>(numPoints);
18 
19  for(std::size_t i = 0; i < numPoints; ++i){
20  m_radii[i] = i * stepSize;
21  m_times[i] = getTFromR(m_radii[i], rtRelation);
22  }
23  m_minRadius = m_radii.front();
24  m_maxRadius = m_radii.back();
25  }

Member Function Documentation

◆ driftTime()

std::optional< double > MuonCalib::TrRelationLookUp::driftTime ( const double  r) const
finaloverridevirtual

Interface method for fetching the drift-time from the radius Returns a nullopt if the time is out of the boundaries.

Implements MuonCalib::ITrRelation.

Definition at line 29 of file TrRelationLookUp.cxx.

29  {
30  if(r < minRadius()) return m_times.front();
31  if(r > maxRadius()) return m_times.back();
32  //Find the first element that is not less than r
33  auto it = std::lower_bound(m_radii.begin(), m_radii.end(), r);
34  //Find the distance to the element right before this one, since r lies between idx and idx+1
35  std::size_t idx = std::distance(m_radii.begin(), it) - 1;
36  double radius1 = m_radii[idx];
37  double radius2 = m_radii[idx + 1];
38  if (radius1 == radius2) return m_times[idx];
39  double time1 = m_times[idx];
40  double time2 = m_times[idx + 1];
41  return time1 + (time2 - time1) * (r - radius1) / (radius2 - radius1);
42  }

◆ driftTime2Prime()

std::optional< double > MuonCalib::TrRelationLookUp::driftTime2Prime ( const double  r) const
finaloverridevirtual

Implements MuonCalib::ITrRelation.

Definition at line 57 of file TrRelationLookUp.cxx.

57  {
58  if(r < minRadius() || r > maxRadius()) return std::nullopt;
59  return 0.0;
60  }

◆ driftTimePrime()

std::optional< double > MuonCalib::TrRelationLookUp::driftTimePrime ( const double  r) const
finaloverridevirtual

Implements MuonCalib::ITrRelation.

Definition at line 44 of file TrRelationLookUp.cxx.

44  {
45  if(r < minRadius() || r > maxRadius()) return 0.;
46  //do the same thing as above but return dt/dr
47  auto it = std::lower_bound(m_radii.begin(), m_radii.end(), r);
48  std::size_t idx = std::distance(m_radii.begin(), it) - 1;
49  double radius1 = m_radii[idx];
50  double radius2 = m_radii[idx + 1];
51  if (radius1 == radius2) return std::nullopt;
52  double time1 = m_times[idx];
53  double time2 = m_times[idx + 1];
54  return (time2 - time1) / (radius2 - radius1);
55  }

◆ getTFromR()

double MuonCalib::TrRelationLookUp::getTFromR ( const double  radius,
const IRtRelationPtr rtRelation 
) const
private

Definition at line 65 of file TrRelationLookUp.cxx.

65  {
66  double precision{0.001};
67  double tMax{rtRelation->tUpper()};
68  double tMin{rtRelation->tLower()};
69 
70  //Search for the drift time
71  while (tMax - tMin > 0.1 and std::abs(rtRelation->radius(0.5 * (tMin + tMax)) - radius) > precision) {
72  double midPoint = 0.5 * (tMin + tMax);
73  if (rtRelation->radius(midPoint) > radius) {
74  tMax = midPoint;
75  } else {
76  tMin = midPoint;
77  }
78  }
79  return 0.5 * (tMin + tMax);
80  }

◆ maxRadius()

double MuonCalib::TrRelationLookUp::maxRadius ( ) const
finaloverridevirtual

Returns the maximum drift-radius.

Implements MuonCalib::ITrRelation.

Definition at line 63 of file TrRelationLookUp.cxx.

63 { return m_maxRadius; }

◆ minRadius()

double MuonCalib::TrRelationLookUp::minRadius ( ) const
finaloverridevirtual

Returns the minimum drift-radius.

Implements MuonCalib::ITrRelation.

Definition at line 62 of file TrRelationLookUp.cxx.

62 { return m_minRadius; }

◆ name()

std::string MuonCalib::TrRelationLookUp::name ( ) const
finaloverridevirtual

Implements MuonCalib::CalibFunc.

Definition at line 27 of file TrRelationLookUp.cxx.

27 { return "TrRelationLookUp"; }

◆ nPar()

unsigned int MuonCalib::CalibFunc::nPar ( ) const
inlineinherited

Definition at line 39 of file CalibFunc.h.

39 { return m_parameters.size(); }

◆ par()

double MuonCalib::CalibFunc::par ( unsigned int  index) const
inlineinherited

Definition at line 41 of file CalibFunc.h.

41  {
42  if (index < nPar())
43  return m_parameters[index];
44  else
45  return 0.;
46  }

◆ parameters()

const ParVec& MuonCalib::CalibFunc::parameters ( ) const
inlineinherited

Definition at line 40 of file CalibFunc.h.

40 { return m_parameters; }

◆ typeName()

virtual std::string MuonCalib::ITrRelation::typeName ( ) const
inlinefinaloverridevirtualinherited

Implements MuonCalib::CalibFunc.

Definition at line 21 of file ITrRelation.h.

21 { return "ITrRelation"; }

Member Data Documentation

◆ m_maxRadius

double MuonCalib::TrRelationLookUp::m_maxRadius {}
private

Definition at line 26 of file TrRelationLookUp.h.

◆ m_minRadius

double MuonCalib::TrRelationLookUp::m_minRadius {}
private

Definition at line 25 of file TrRelationLookUp.h.

◆ m_parameters

ParVec MuonCalib::CalibFunc::m_parameters {}
privateinherited

Definition at line 51 of file CalibFunc.h.

◆ m_radii

std::vector<double> MuonCalib::TrRelationLookUp::m_radii {}
private

Definition at line 24 of file TrRelationLookUp.h.

◆ m_rt

IRtRelationPtr MuonCalib::ITrRelation::m_rt {}
privateinherited

Definition at line 36 of file ITrRelation.h.

◆ m_times

std::vector<double> MuonCalib::TrRelationLookUp::m_times {}
private

Definition at line 23 of file TrRelationLookUp.h.


The documentation for this class was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:676
MuonCalib::TrRelationLookUp::getTFromR
double getTFromR(const double radius, const IRtRelationPtr &rtRelation) const
Definition: TrRelationLookUp.cxx:65
index
Definition: index.py:1
skel.it
it
Definition: skel.GENtoEVGEN.py:396
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
MuonCalib::TrRelationLookUp::m_radii
std::vector< double > m_radii
Definition: TrRelationLookUp.h:24
MuonCalib::TrRelationLookUp::minRadius
virtual double minRadius() const override final
Returns the minimum drift-radius.
Definition: TrRelationLookUp.cxx:62
MuonCalib::TrRelationLookUp::m_times
std::vector< double > m_times
Definition: TrRelationLookUp.h:23
lumiFormat.i
int i
Definition: lumiFormat.py:85
MuonCalib::TrRelationLookUp::m_maxRadius
double m_maxRadius
Definition: TrRelationLookUp.h:26
MuonCalib::TrRelationLookUp::maxRadius
virtual double maxRadius() const override final
Returns the maximum drift-radius.
Definition: TrRelationLookUp.cxx:63
MuonCalib::TrRelationLookUp::m_minRadius
double m_minRadius
Definition: TrRelationLookUp.h:25
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
DeMoScan.index
string index
Definition: DeMoScan.py:364
MuonCalib::ITrRelation::ITrRelation
ITrRelation(const IRtRelationPtr &rtRelation, const ParVec &parameters)
Constructor taking the input r-t relation & the vector of parameters.
Definition: ITrRelation.h:17
MuonCalib::CalibFunc::m_parameters
ParVec m_parameters
Definition: CalibFunc.h:51
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
MuonCalib::CalibFunc::nPar
unsigned int nPar() const
Definition: CalibFunc.h:39
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54