CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StripCPEgeometric.cc
Go to the documentation of this file.
4 #include <numeric>
5 
7  const SiStripCluster& cluster, const GeomDetUnit& det, const LocalTrajectoryParameters& ltp) const {
8  StripCPE::Param const& p = param(det);
9 
10  const LocalPoint& pos = ltp.position();
11  LocalVector track = ltp.momentum();
12  track *= (track.z() < 0) ? fabs(p.thickness / track.z())
13  : (track.z() > 0) ? -fabs(p.thickness / track.z())
14  : p.maxLength / track.mag();
15 
16  const float fullProjection = p.coveredStrips(track + p.drift, pos);
17  stats_t<float> projection;
18  {
19  const float absProj = fabs(fullProjection);
20  const float minProj = 2 * p.thickness * tan_diffusion_angle / p.topology->localPitch(pos);
21  const float projection_rel_err2 = thickness_rel_err2 + p.pitch_rel_err2;
22  projection = stats_t<float>::from_relative_uncertainty2(std::max(absProj, minProj), projection_rel_err2);
23  }
24 
25  const std::vector<stats_t<float> > Q =
26  reco::InverseCrosstalkMatrix::unfold(cluster, xtalk1[static_cast<int>(p.moduleGeom)]);
27  const stats_t<float> strip = cluster.firstStrip() + offset_from_firstStrip(Q, projection);
28 
29  const float corrected =
30  strip() - 0.5 * (1 - p.backplanecorrection) * fullProjection + 0.5 * p.coveredStrips(track, ltp.position());
31  const float error2 = std::max(strip.error2(), minimum_uncertainty_squared);
32 
33  return std::make_pair(p.topology->localPosition(corrected, ltp.vector()),
34  p.topology->localError(corrected, error2, ltp.vector()));
35 }
36 
38  const stats_t<float>& proj) const {
39  WrappedCluster wc(Q);
40  if (useNPlusOne(wc, proj))
42  else
43  while (useNMinusOne(wc, proj))
45 
46  if (proj() < wc.N - 2)
47  return stats_t<float>(wc.middle(), pow(wc.N - proj(), 2) / 12.);
48  if (wc.deformed())
49  return stats_t<float>(wc.centroid()(), 1 / 12.);
50  if (proj > wc.maxProjection())
51  return stats_t<float>(wc.centroid()(), 1 / 12.);
52 
53  if (ambiguousSize(wc, proj)) {
54  const stats_t<float> probably = geometric_position(wc, proj);
56  const stats_t<float> maybe = geometric_position(wc, proj);
57  return stats_t<float>(probably(),
58  std::max(probably.error2(), float(maybe.error2() + pow(probably() - maybe(), 2) / 12)));
59  }
60  return geometric_position(wc, proj);
61 }
62 
64  const stats_t<float>& proj) const {
65  const stats_t<float> x = wc.middle() + 0.5 * proj * wc.eta();
66  return wc.N == 1 ? stats_t<float>(x(), pow(1 - 0.82 * proj(), 2) / 12)
68 }
69 
70 inline bool StripCPEgeometric::useNPlusOne(const WrappedCluster& wc, const stats_t<float>& proj) const {
71  return wc.maxProjection() < proj && proj() < wc.N + 1;
72 }
73 
74 inline bool StripCPEgeometric::useNMinusOne(const WrappedCluster& wc, const stats_t<float>& proj) const {
75  if (proj() > wc.N - 1)
76  return false;
77  if (wc.smallerEdgeStrip() < 0)
78  return true;
79  if (proj() < wc.N - 3)
80  return false;
81  if (proj() < wc.N - 2)
82  return true;
83  if (wc.eta().sigmaFrom(0) < 3)
84  return false;
85 
86  WrappedCluster wcTest(wc);
87  wcTest.dropSmallerEdgeStrip();
88  if (proj >= wcTest.maxProjection())
89  return false;
90  if (wc.sign() * wc.eta()() > 1. / (wc.N - 1))
91  return true;
92 
93  return wc.smallerEdgeStrip().sigmaFrom(0) < noise_threshold;
94 }
95 
96 inline bool StripCPEgeometric::ambiguousSize(const WrappedCluster& wc, const stats_t<float>& proj) const {
97  return proj() < wc.N - 1 && wc.smallerEdgeStrip()() > 0 && wc.smallerEdgeStrip().sigmaFrom(0) < maybe_noise_threshold;
98 }
99 
101  : N(Q.size() - 2), clusterFirst(Q.begin() + 1), first(clusterFirst) {}
102 
104  if (eta().sigmaFrom(0) < 1) {
105  first--;
106  N += 2;
107  } else if (*first > last()) {
108  first--;
109  N += 1;
110  } else {
111  N += 1;
112  }
113 }
114 
116  if (*first < last()) {
117  first++;
118  N -= 1;
119  } else if (last() < *first) {
120  N -= 1;
121  } else {
122  first++;
123  N -= 2;
124  }
125 }
126 
127 inline float StripCPEgeometric::WrappedCluster::middle() const { return (first - clusterFirst) + N / 2.; }
128 
130  stats_t<float> sumXQ(0);
131  for (std::vector<stats_t<float> >::const_iterator i = first; i < first + N; i++)
132  sumXQ += (i - clusterFirst) * (*i);
133  return sumXQ / sumQ() + 0.5;
134 }
135 
137  return accumulate(first, first + N, stats_t<float>(0));
138 }
139 
141 
143  return N > 2 && std::max((*first)(), last()()) > accumulate(first + 1, first + N - 1, stats_t<float>(0))() / (N - 2);
144 }
145 
147  return N * (1 + sign() * eta()).inverse();
148 }
149 
151 
152 inline int StripCPEgeometric::WrappedCluster::sign() const { return (*first < last()) ? 1 : -1; }
std::pair< LocalPoint, LocalError > LocalValues
WrappedCluster(const std::vector< stats_t< float > > &)
float pitch_rel_err2
Definition: StripCPE.h:37
LocalPoint position() const
Local x and y position coordinates.
float thickness
Definition: StripCPE.h:37
double sign(double x)
StripTopology const * topology
Definition: StripCPE.h:35
stats_t< float > smallerEdgeStrip() const
const float scaling_squared
T error2() const
uint16_t firstStrip() const
float backplanecorrection
Definition: StripCPE.h:39
stats_t< float > centroid() const
AlgebraicVector5 vector() const
virtual float localPitch(const LocalPoint &) const =0
stats_t< float > geometric_position(const WrappedCluster &, const stats_t< float > &) const
std::vector< float > xtalk1
Definition: StripCPE.h:78
T mag() const
Definition: PV3DBase.h:64
static stats_t from_relative_uncertainty2(T q, T re2)
T z() const
Definition: PV3DBase.h:61
stats_t< float > sumQ() const
stats_t< float > offset_from_firstStrip(const std::vector< stats_t< float > > &, const stats_t< float > &) const
static std::vector< stats_t< float > > unfold(const SiStripCluster &q, const float x)
LocalVector momentum() const
Momentum vector in the local frame.
T min(T a, T b)
Definition: MathUtil.h:58
float coveredStrips(const LocalVector &, const LocalPoint &) const
Definition: StripCPE.cc:73
StripClusterParameterEstimator::LocalValues localParameters(const SiStripCluster &, const GeomDetUnit &, const LocalTrajectoryParameters &) const override
const float maybe_noise_threshold
#define N
Definition: blowfish.cc:9
bool useNPlusOne(const WrappedCluster &, const stats_t< float > &) const
const float minimum_uncertainty_squared
bool ambiguousSize(const WrappedCluster &, const stats_t< float > &) const
const float tan_diffusion_angle
virtual LocalError localError(float strip, float stripErr2) const =0
float maxLength
Definition: StripCPE.h:37
Param const & param(const GeomDetUnit &det) const
Definition: StripCPE.h:81
LocalVector drift
Definition: StripCPE.h:36
virtual LocalPoint localPosition(float strip) const =0
SiStripModuleGeometry moduleGeom
Definition: StripCPE.h:40
const float thickness_rel_err2
tuple last
Definition: dqmdumpme.py:56
const float noise_threshold
stats_t< float > maxProjection() const
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
bool useNMinusOne(const WrappedCluster &, const stats_t< float > &) const
double sumQ(DIGI const &digi, double ped, int i=0, int j=3)
Definition: Utilities.h:127