CMS 3D CMS Logo

TkMSParameterization.h
Go to the documentation of this file.
1 #ifndef TkNavigation_TkMSParameterization_H
2 #define TkNavigation_TkMSParameterization_H
3 
5 
6 #include <array>
7 #include <vector>
8 #include <unordered_map>
9 #include <cmath>
10 #include <algorithm>
11 
12 #include <ostream>
13 
16 
17  constexpr unsigned short packLID(unsigned int id, unsigned int od) { return (id << 8) | od; }
18  constexpr std::tuple<unsigned short, unsigned short> unpackLID(unsigned short lid) {
19  return std::make_tuple(lid >> 8, lid & 255);
20  }
21 
22  constexpr unsigned int nLmBins() { return 12 * 10; }
23  constexpr float lmBin() { return 0.1f; }
24  constexpr float lmBinInv() { return 1.f / lmBin(); }
25 
26  struct Elem {
27  float vi;
28  float vo;
29  float uerr;
30  float verr;
31  };
32 
33  // this shall be sorted by "vo"
34  class Elems {
35  public:
36  Elem find(float v) {
37  auto p = find_if(data.begin(), data.end(), [=](Elem const& d) { return d.vo > v; });
38  if (p != data.begin())
39  --p;
40  return *p;
41  }
42  auto const& operator()() const { return data; }
43 
44  private:
45  std::vector<Elem> data;
47  };
48 
49  class FromToData {
50  public:
51  Elems const& get(float tnLambda) const {
52  auto i = std::min(nLmBins() - 1, (unsigned int)(std::abs(tnLambda) * lmBinInv()));
53  return data[i];
54  }
55 
56  auto const& operator()() const { return data; }
57 
58  private:
61  };
62 
63  using AllData = std::unordered_map<unsigned short, FromToData>;
64 
65 } // namespace tkMSParameterization
66 
67 inline std::ostream& operator<<(std::ostream& os, tkMSParameterization::Elem d) {
68  os << d.vi << '/' << d.vo << ':' << d.uerr << '/' << d.verr;
69  return os;
70 }
71 
73 public:
76 
77  FromToData const* fromTo(DetLayer const& in, DetLayer const& out) const { return fromTo(in.seqNum(), out.seqNum()); }
78 
79  FromToData const* fromTo(int in, int out) const {
80  using namespace tkMSParameterization;
81  auto id = packLID(in, out);
82  auto p = data.find(id);
83  if (p != data.end())
84  return &(*p).second;
85  return nullptr;
86  }
87 
88  auto const& operator()() const { return data; }
89 
90 private:
93 };
94 
95 #endif // TkNavigation_TkMSParameterization_H
tkMSParameterization::FromToData::TkMSParameterizationBuilder
friend TkMSParameterizationBuilder
Definition: TkMSParameterization.h:60
mps_fire.i
i
Definition: mps_fire.py:428
tkMSParameterization::Elem::verr
float verr
Definition: TkMSParameterization.h:30
tkMSParameterization::packLID
constexpr unsigned short packLID(unsigned int id, unsigned int od)
Definition: TkMSParameterization.h:17
tkMSParameterization::Elem::vi
float vi
Definition: TkMSParameterization.h:27
DetLayer
Definition: DetLayer.h:21
tkMSParameterization::Elem::uerr
float uerr
Definition: TkMSParameterization.h:29
min
T min(T a, T b)
Definition: MathUtil.h:58
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
tkMSParameterization::lmBinInv
constexpr float lmBinInv()
Definition: TkMSParameterization.h:24
mps_check.array
array
Definition: mps_check.py:216
tkMSParameterization::Elems::operator()
auto const & operator()() const
Definition: TkMSParameterization.h:42
findQualityFiles.v
v
Definition: findQualityFiles.py:179
TkMSParameterization::AllData
tkMSParameterization::AllData AllData
Definition: TkMSParameterization.h:75
tkMSParameterization::Elem::vo
float vo
Definition: TkMSParameterization.h:28
TkMSParameterization::data
AllData data
Definition: TkMSParameterization.h:91
TkMSParameterization
Definition: TkMSParameterization.h:72
tkMSParameterization::Elem
Definition: TkMSParameterization.h:26
TkMSParameterizationBuilder
Definition: TkMSParameterizationBuilder.cc:50
tkMSParameterization::Elems::TkMSParameterizationBuilder
friend TkMSParameterizationBuilder
Definition: TkMSParameterization.h:46
TkMSParameterization::fromTo
FromToData const * fromTo(int in, int out) const
Definition: TkMSParameterization.h:79
tkMSParameterization::Elems::find
Elem find(float v)
Definition: TkMSParameterization.h:36
TkMSParameterization::operator()
auto const & operator()() const
Definition: TkMSParameterization.h:88
recoMuon::in
Definition: RecoMuonEnumerators.h:6
operator<<
std::ostream & operator<<(std::ostream &os, tkMSParameterization::Elem d)
Definition: TkMSParameterization.h:67
tkMSParameterization::FromToData::data
std::array< Elems, nLmBins()> data
Definition: TkMSParameterization.h:59
tkMSParameterization::unpackLID
constexpr std::tuple< unsigned short, unsigned short > unpackLID(unsigned short lid)
Definition: TkMSParameterization.h:18
tkMSParameterization::lmBin
constexpr float lmBin()
Definition: TkMSParameterization.h:23
tkMSParameterization::Elems::data
std::vector< Elem > data
Definition: TkMSParameterization.h:45
tkMSParameterization::FromToData::get
Elems const & get(float tnLambda) const
Definition: TkMSParameterization.h:51
DetLayer.h
tkMSParameterization::AllData
std::unordered_map< unsigned short, FromToData > AllData
Definition: TkMSParameterization.h:63
tkMSParameterization::nLmBins
constexpr unsigned int nLmBins()
Definition: TkMSParameterization.h:22
TkMSParameterization::fromTo
FromToData const * fromTo(DetLayer const &in, DetLayer const &out) const
Definition: TkMSParameterization.h:77
tkMSParameterization::Elems
Definition: TkMSParameterization.h:34
tkMSParameterization::FromToData::operator()
auto const & operator()() const
Definition: TkMSParameterization.h:56
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ztail.d
d
Definition: ztail.py:151
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
submitPVValidationJobs.od
od
Definition: submitPVValidationJobs.py:891
TkMSParameterization::TkMSParameterizationBuilder
friend TkMSParameterizationBuilder
Definition: TkMSParameterization.h:92
tkMSParameterization::FromToData
Definition: TkMSParameterization.h:49
tkMSParameterization
Definition: TkMSParameterization.h:15