CMS 3D CMS Logo

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  {
19  mLC_P[0] = conf.existsAs<double>("mLC_P0") ? conf.getParameter<double>("mLC_P0") : -.326;
20  mLC_P[1] = conf.existsAs<double>("mLC_P1") ? conf.getParameter<double>("mLC_P1") : .618;
21  mLC_P[2] = conf.existsAs<double>("mLC_P2") ? conf.getParameter<double>("mLC_P2") : .300;
22 
23  mHC_P[SiStripDetId::TIB - 3][0] = conf.existsAs<double>("mTIB_P0") ? conf.getParameter<double>("mTIB_P0") : -.742 ;
24  mHC_P[SiStripDetId::TIB - 3][1] = conf.existsAs<double>("mTIB_P1") ? conf.getParameter<double>("mTIB_P1") : .202 ;
25  mHC_P[SiStripDetId::TID - 3][0] = conf.existsAs<double>("mTID_P0") ? conf.getParameter<double>("mTID_P0") : -1.026 ;
26  mHC_P[SiStripDetId::TID - 3][1] = conf.existsAs<double>("mTID_P1") ? conf.getParameter<double>("mTID_P1") : .253 ;
27  mHC_P[SiStripDetId::TOB - 3][0] = conf.existsAs<double>("mTOB_P0") ? conf.getParameter<double>("mTOB_P0") : -1.427 ;
28  mHC_P[SiStripDetId::TOB - 3][1] = conf.existsAs<double>("mTOB_P1") ? conf.getParameter<double>("mTOB_P1") : .433 ;
29  mHC_P[SiStripDetId::TEC - 3][0] = conf.existsAs<double>("mTEC_P0") ? conf.getParameter<double>("mTEC_P0") : -1.885 ;
30  mHC_P[SiStripDetId::TEC - 3][1] = conf.existsAs<double>("mTEC_P1") ? conf.getParameter<double>("mTEC_P1") : .471 ;
31  }
32 
33 float StripCPEfromTrackAngle::stripErrorSquared(const unsigned N, const float uProj, const SiStripDetId::SubDetector loc ) const {
34  auto fun = [&] (float x) -> float { return mLC_P[0]*x*vdt::fast_expf(-x*mLC_P[1])+mLC_P[2];};
35  auto uerr = (N <= 4) ? fun(uProj) : mHC_P[loc-3][0]+float(N)*mHC_P[loc-3][1];
36  return uerr*uerr;
37 }
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 
52 
53 
55 
56 
57  auto const & par = getAlgoParam(det,ltp);
58  auto const & p = par.p;
59  auto loc = par.loc;
60  auto corr = par.corr;
61  auto afp = par.afullProjection;
62 
63  auto fill = [&](unsigned int i, float uerr2) {
64  const float strip = clusters[i]->barycenter() + corr;
65  retValues[i].first = p.topology->localPosition(strip, ltp.vector());
66  retValues[i].second = p.topology->localError(strip, uerr2, ltp.vector());
67  };
68 
69 
70  switch (m_algo) {
71  case Algo::chargeCK :
72  for (auto i=0U; i< clusters.size(); ++i) {
73  auto dQdx = siStripClusterTools::chargePerCM(*clusters[i], ltp, p.invThickness);
74  auto N = clusters[i]->amplitudes().size();
75  auto uerr2 = dQdx > maxChgOneMIP ? legacyStripErrorSquared(N,afp) : stripErrorSquared( N, afp,loc );
76  fill(i, uerr2);
77  }
78  break;
79  case Algo::legacy :
80  for (auto i=0U; i< clusters.size(); ++i) {
81  auto N = clusters[i]->amplitudes().size();
82  auto uerr2 = legacyStripErrorSquared(N,afp);
83  fill(i, uerr2);
84  }
85  break;
86  case Algo::mergeCK :
87  for (auto i=0U; i< clusters.size(); ++i) {
88  auto N = clusters[i]->amplitudes().size();
89  auto uerr2 = clusters[i]->isMerged() ? legacyStripErrorSquared(N,afp) : stripErrorSquared( N,afp,loc );
90  fill(i, uerr2);
91  }
92  break;
93  }
94 
95 
96 }
97 
100  auto const & p = par.p;
101  auto const & ltp = par.ltp;
102  auto loc = par.loc;
103  auto corr = par.corr;
104  auto afp = par.afullProjection;
105 
106  float uerr2=0;
107 
108  auto N = cluster.amplitudes().size();
109 
110  switch (m_algo) {
111  case Algo::chargeCK :
112  {
113  auto dQdx = siStripClusterTools::chargePerCM(cluster, ltp, p.invThickness);
114  uerr2 = dQdx > maxChgOneMIP ? legacyStripErrorSquared(N,afp) : stripErrorSquared( N, afp,loc );
115  }
116  break;
117  case Algo::legacy :
118  uerr2 = legacyStripErrorSquared(N,afp);
119  break;
120  case Algo::mergeCK :
121  uerr2 = cluster.isMerged() ? legacyStripErrorSquared(N,afp) : stripErrorSquared( N, afp,loc );
122  break;
123  }
124 
125  const float strip = cluster.barycenter() + corr;
126 
127  return std::make_pair( p.topology->localPosition(strip, ltp.vector()),
128  p.topology->localError(strip, uerr2, ltp.vector()) );
129 }
130 
131 
132 
135 
136  auto const & par = getAlgoParam(det,ltp);
137  return localParameters(cluster,par);
138 }
139 
float legacyStripErrorSquared(const unsigned N, const float uProj) const
T getParameter(std::string const &) const
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:161
bool isMerged() const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
float chargePerCM(DetId detid, Iter a, Iter b)
SiStripDetId::SubDetector loc
Definition: StripCPE.h:47
std::pair< LocalPoint, LocalError > LocalValues
AlgebraicVector5 vector() const
float barycenter() const
double f[11][100]
AlgoParam getAlgoParam(const GeomDetUnit &det, const LocalTrajectoryParameters &ltp) const
Definition: StripCPE.h:56
float afullProjection
Definition: StripCPE.h:47
JetCorrectorParameters corr
Definition: classes.h:5
const LocalTrajectoryParameters & ltp
Definition: StripCPE.h:46
#define N
Definition: blowfish.cc:9
void localParameters(AClusters const &clusters, ALocalValues &retValues, const GeomDetUnit &gd, const LocalTrajectoryParameters &ltp) const override
float fast_expf(float x)
#define UNLIKELY(x)
Definition: Likely.h:21
unsigned int size() const
Definition: DynArray.h:44
latency
hardware algo
const std::vector< uint8_t > & amplitudes() const
Definition: fakeMenu.h:6
#define constexpr
float stripErrorSquared(const unsigned N, const float uProj, const SiStripDetId::SubDetector loc) const
Param const & p
Definition: StripCPE.h:46