CMS 3D CMS Logo

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