CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StripCPEfromTrackAngle.cc
Go to the documentation of this file.
4 
5 #include "vdt/vdtMath.h"
6 
8  const MagneticField& mag,
9  const TrackerGeometry& geom,
10  const SiStripLorentzAngle& lorentz,
11  const SiStripBackPlaneCorrection& backPlaneCorrection,
12  const SiStripConfObject& confObj,
13  const SiStripLatency& latency)
14  : StripCPE(conf, mag, geom, lorentz, backPlaneCorrection, confObj, latency),
15  useLegacyError(conf.existsAs<bool>("useLegacyError") ? conf.getParameter<bool>("useLegacyError") : true),
16  maxChgOneMIP(conf.existsAs<float>("maxChgOneMIP") ? conf.getParameter<double>("maxChgOneMIP") : -6000.),
17  m_algo(useLegacyError ? Algo::legacy : (maxChgOneMIP < 0 ? Algo::mergeCK : Algo::chargeCK)) {
18  mLC_P[0] = conf.existsAs<double>("mLC_P0") ? conf.getParameter<double>("mLC_P0") : -.326;
19  mLC_P[1] = conf.existsAs<double>("mLC_P1") ? conf.getParameter<double>("mLC_P1") : .618;
20  mLC_P[2] = conf.existsAs<double>("mLC_P2") ? conf.getParameter<double>("mLC_P2") : .300;
21 
22  mHC_P[SiStripDetId::TIB - 3][0] = conf.existsAs<double>("mTIB_P0") ? conf.getParameter<double>("mTIB_P0") : -.742;
23  mHC_P[SiStripDetId::TIB - 3][1] = conf.existsAs<double>("mTIB_P1") ? conf.getParameter<double>("mTIB_P1") : .202;
24  mHC_P[SiStripDetId::TID - 3][0] = conf.existsAs<double>("mTID_P0") ? conf.getParameter<double>("mTID_P0") : -1.026;
25  mHC_P[SiStripDetId::TID - 3][1] = conf.existsAs<double>("mTID_P1") ? conf.getParameter<double>("mTID_P1") : .253;
26  mHC_P[SiStripDetId::TOB - 3][0] = conf.existsAs<double>("mTOB_P0") ? conf.getParameter<double>("mTOB_P0") : -1.427;
27  mHC_P[SiStripDetId::TOB - 3][1] = conf.existsAs<double>("mTOB_P1") ? conf.getParameter<double>("mTOB_P1") : .433;
28  mHC_P[SiStripDetId::TEC - 3][0] = conf.existsAs<double>("mTEC_P0") ? conf.getParameter<double>("mTEC_P0") : -1.885;
29  mHC_P[SiStripDetId::TEC - 3][1] = conf.existsAs<double>("mTEC_P1") ? conf.getParameter<double>("mTEC_P1") : .471;
30 }
31 
33  const float uProj,
34  const SiStripDetId::SubDetector loc) const {
35  auto fun = [&](float x) -> float { return mLC_P[0] * x * vdt::fast_expf(-x * mLC_P[1]) + mLC_P[2]; };
36  auto uerr = (N <= 4) ? fun(uProj) : mHC_P[loc - 3][0] + float(N) * mHC_P[loc - 3][1];
37  return uerr * uerr;
38 }
39 
40 float StripCPEfromTrackAngle::legacyStripErrorSquared(const unsigned N, const float uProj) const {
41  if UNLIKELY ((float(N) - uProj) > 3.5f)
42  return float(N * N) / 12.f;
43  else {
44  static constexpr float P1 = -0.339;
45  static constexpr float P2 = 0.90;
46  static constexpr float P3 = 0.279;
47  const float uerr = P1 * uProj * vdt::fast_expf(-uProj * P2) + P3;
48  return uerr * uerr;
49  }
50 }
51 
53  ALocalValues& retValues,
54  const GeomDetUnit& det,
55  const LocalTrajectoryParameters& ltp) const {
56  auto const& par = getAlgoParam(det, ltp);
57  auto const& p = par.p;
58  auto loc = par.loc;
59  auto corr = par.corr;
60  auto afp = par.afullProjection;
61 
62  auto fill = [&](unsigned int i, float uerr2) {
63  const float strip = clusters[i]->barycenter() + corr;
64  retValues[i].first = p.topology->localPosition(strip, ltp.vector());
65  retValues[i].second = p.topology->localError(strip, uerr2, ltp.vector());
66  };
67 
68  switch (m_algo) {
69  case Algo::chargeCK:
70  for (auto i = 0U; i < clusters.size(); ++i) {
71  auto dQdx = siStripClusterTools::chargePerCM(*clusters[i], ltp, p.invThickness);
72  auto N = clusters[i]->amplitudes().size();
73  auto uerr2 = dQdx > maxChgOneMIP ? legacyStripErrorSquared(N, afp) : stripErrorSquared(N, afp, loc);
74  fill(i, uerr2);
75  }
76  break;
77  case Algo::legacy:
78  for (auto i = 0U; i < clusters.size(); ++i) {
79  auto N = clusters[i]->amplitudes().size();
80  auto uerr2 = legacyStripErrorSquared(N, afp);
81  fill(i, uerr2);
82  }
83  break;
84  case Algo::mergeCK:
85  for (auto i = 0U; i < clusters.size(); ++i) {
86  auto N = clusters[i]->amplitudes().size();
87  auto uerr2 = clusters[i]->isMerged() ? legacyStripErrorSquared(N, afp) : stripErrorSquared(N, afp, loc);
88  fill(i, uerr2);
89  }
90  break;
91  }
92 }
93 
95  AlgoParam const& par) const {
96  auto const& p = par.p;
97  auto const& ltp = par.ltp;
98  auto loc = par.loc;
99  auto corr = par.corr;
100  auto afp = par.afullProjection;
101 
102  float uerr2 = 0;
103 
104  auto N = cluster.amplitudes().size();
105 
106  switch (m_algo) {
107  case Algo::chargeCK: {
108  auto dQdx = siStripClusterTools::chargePerCM(cluster, ltp, p.invThickness);
109  uerr2 = dQdx > maxChgOneMIP ? legacyStripErrorSquared(N, afp) : stripErrorSquared(N, afp, loc);
110  } break;
111  case Algo::legacy:
112  uerr2 = legacyStripErrorSquared(N, afp);
113  break;
114  case Algo::mergeCK:
115  uerr2 = cluster.isMerged() ? legacyStripErrorSquared(N, afp) : stripErrorSquared(N, afp, loc);
116  break;
117  }
118 
119  const float strip = cluster.barycenter() + corr;
120 
121  return std::make_pair(p.topology->localPosition(strip, ltp.vector()),
122  p.topology->localError(strip, uerr2, ltp.vector()));
123 }
124 
126  const SiStripCluster& cluster, const GeomDetUnit& det, const LocalTrajectoryParameters& ltp) const {
127  auto const& par = getAlgoParam(det, ltp);
128  return localParameters(cluster, par);
129 }
float legacyStripErrorSquared(const unsigned N, const float uProj) const
std::pair< LocalPoint, LocalError > LocalValues
StripCPEfromTrackAngle(edm::ParameterSet &conf, const MagneticField &mag, const TrackerGeometry &geom, const SiStripLorentzAngle &lorentz, const SiStripBackPlaneCorrection &backPlaneCorrection, const SiStripConfObject &confObj, const SiStripLatency &latency)
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
bool isMerged() const
static constexpr auto TID
Definition: SiStripDetId.h:38
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
SiStripCluster const & amplitudes() const
void localParameters(AClusters const &clusters, ALocalValues &retValues, const GeomDetUnit &gd, const LocalTrajectoryParameters &ltp) const override
float chargePerCM(DetId detid, Iter a, Iter b)
SiStripDetId::SubDetector loc
Definition: StripCPE.h:47
AlgebraicVector5 vector() const
auto size() const
float barycenter() const
AlgoParam getAlgoParam(const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const
Definition: StripCPE.h:57
static constexpr auto TOB
Definition: SiStripDetId.h:39
float afullProjection
Definition: StripCPE.h:48
const LocalTrajectoryParameters & ltp
Definition: StripCPE.h:46
#define N
Definition: blowfish.cc:9
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static constexpr auto TIB
Definition: SiStripDetId.h:37
float fast_expf(float x)
#define UNLIKELY(x)
Definition: Likely.h:21
unsigned int size() const
Definition: DynArray.h:60
Definition: fakeMenu.h:6
static constexpr auto TEC
Definition: SiStripDetId.h:40
float stripErrorSquared(const unsigned N, const float uProj, const SiStripDetId::SubDetector loc) const
Param const & p
Definition: StripCPE.h:45