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

#include <TrRelation.h>

Inheritance diagram for MuonCalib::TrRelation:
Collaboration diagram for MuonCalib::TrRelation:

Public Member Functions

 TrRelation (const IRtRelation &input_rt)
 < Constructor. More...
 
 TrRelation (const std::vector< double > &r_values, const std::vector< double > &t_values)
 
double tFromR (const double r, bool &out_of_bound_flag) const
 < Get t(r). out_of_bound_flag is set to true if r is out of bounds. More...
 
double rFromT (const double t, bool &out_of_bound_flag) const
 

Static Private Member Functions

static double getTFromR (const double r, const IRtRelation &input_rt)
 

Private Attributes

std::vector< double > m_r
 
std::vector< double > m_t
 

Detailed Description

Definition at line 39 of file TrRelation.h.

Constructor & Destructor Documentation

◆ TrRelation() [1/2]

TrRelation::TrRelation ( const IRtRelation input_rt)

< Constructor.

The user has to provide the input r-t relationship to be inverted. Constructor. The user has to provide (r, t) pairs stored in the vectors r_values and t_values. The r and t values must be in increasing order.

Definition at line 20 of file TrRelation.cxx.

20  {
22  // VARIABLES //
24  unsigned int nb_points(100); // number of r-t points used internally
25  // step size in r
26  double step_size(input_rt.radius(input_rt.tUpper()) / static_cast<double>(nb_points - 1));
27  m_r = std::vector<double>(nb_points);
28  m_t = std::vector<double>(nb_points);
29 
31  // FILL THE (r, t) PAIRS //
33  for (unsigned int k = 0; k < nb_points; k++) {
34  m_r[k] = k * step_size;
35  m_t[k] = getTFromR(m_r[k], input_rt);
36  }
37 
38 } // end TrRelation::TrRelation

◆ TrRelation() [2/2]

TrRelation::TrRelation ( const std::vector< double > &  r_values,
const std::vector< double > &  t_values 
)

Definition at line 45 of file TrRelation.cxx.

46  : m_r (r_values),
47  m_t (t_values)
48 {
49 }

Member Function Documentation

◆ getTFromR()

double TrRelation::getTFromR ( const double  r,
const IRtRelation input_rt 
)
staticprivate

Definition at line 128 of file TrRelation.cxx.

128  {
130  // VARIABLES //
132  double precision(0.001); // spatial precision of the inversion
133  double t_max(input_rt.tUpper()); // upper time search limit
134  double t_min(input_rt.tLower()); // lower time search limit
135 
137  // SEARCH FOR THE CORRESPONDING DRIFT TIME //
139  while (t_max - t_min > 0.1 && std::abs(input_rt.radius(0.5 * (t_min + t_max)) - r) > precision) {
140  if (input_rt.radius(0.5 * (t_min + t_max)) > r) {
141  t_max = 0.5 * (t_min + t_max);
142  } else {
143  t_min = 0.5 * (t_min + t_max);
144  }
145  }
146 
147  return 0.5 * (t_min + t_max);
148 } // end TrRelation::getTFromR

◆ rFromT()

double TrRelation::rFromT ( const double  t,
bool &  out_of_bound_flag 
) const

Definition at line 92 of file TrRelation.cxx.

92  {
94  // CHECK BOUNDS //
96  if (t < m_t[0]) {
97  out_of_bound_flag = true;
98  return m_r[0];
99  }
100  if (t > m_t[m_r.size() - 1]) {
101  out_of_bound_flag = true;
102  return m_r[m_r.size() - 1];
103  }
104 
106  // INTERPOLATION //
108  for (unsigned int k = 0; k < m_r.size() - 1; k++) {
109  if (t >= m_t[k] && t <= m_t[k + 1]) {
110  if (m_t[k] == m_t[k + 1]) {
111  out_of_bound_flag = false;
112  return m_r[k];
113  }
114  out_of_bound_flag = false;
115  return m_r[k] + (t - m_t[k]) * (m_r[k + 1] - m_r[k]) / (m_t[k + 1] - m_t[k]);
116  }
117  }
118  MsgStream log(Athena::getMessageSvc(), "TrRelation");
119  log << MSG::ERROR << "Class TrRelation, method rFromT: ERROR!" << endmsg;
120  return 0.0;
121 } // end TrRelation::rFromT

◆ tFromR()

double TrRelation::tFromR ( const double  r,
bool &  out_of_bound_flag 
) const

< Get t(r). out_of_bound_flag is set to true if r is out of bounds.

Get r(t). out_of_bound_flag is set to true if t is out of bounds.

Definition at line 56 of file TrRelation.cxx.

56  {
58  // CHECK BOUNDS //
60  if (r < m_r[0]) {
61  out_of_bound_flag = true;
62  return m_t[0];
63  }
64  if (r > m_r[m_r.size() - 1]) {
65  out_of_bound_flag = true;
66  return m_t[m_r.size() - 1];
67  }
68 
70  // INTERPOLATION //
72  for (unsigned int k = 0; k < m_r.size() - 1; k++) {
73  if (r >= m_r[k] && r <= m_r[k + 1]) {
74  if (m_r[k] == m_r[k + 1]) {
75  out_of_bound_flag = false;
76  return m_t[k];
77  }
78  out_of_bound_flag = false;
79  return m_t[k] + (r - m_r[k]) * (m_t[k + 1] - m_t[k]) / (m_r[k + 1] - m_r[k]);
80  }
81  }
82  MsgStream log(Athena::getMessageSvc(), "TrRelation");
83  log << MSG::ERROR << "Class TrRelation, method tFromR: ERROR!" << endmsg;
84  return 0.0;
85 } // end TrRelation::tFromR

Member Data Documentation

◆ m_r

std::vector<double> MuonCalib::TrRelation::m_r
private

Definition at line 58 of file TrRelation.h.

◆ m_t

std::vector<double> MuonCalib::TrRelation::m_t
private

Definition at line 59 of file TrRelation.h.


The documentation for this class was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:676
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MuonCalib::IRtRelation::tUpper
virtual double tUpper() const =0
Returns the upper time covered by the r-t.
MuonCalib::TrRelation::getTFromR
static double getTFromR(const double r, const IRtRelation &input_rt)
Definition: TrRelation.cxx:128
MuonCalib::TrRelation::m_t
std::vector< double > m_t
Definition: TrRelation.h:59
MuonCalib::IRtRelation::radius
virtual double radius(double t) const =0
returns drift radius for a given time
MuonCalib::TrRelation::m_r
std::vector< double > m_r
Definition: TrRelation.h:58
MuonCalib::IRtRelation::tLower
virtual double tLower() const =0
Returns the lower time covered by the r-t.
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
fitman.k
k
Definition: fitman.py:528