CMS 3D CMS Logo

StripCPEfromTemplate.cc
Go to the documentation of this file.
1 
4 
5 // #include <iostream>
6 
7 namespace {
8  inline
9  float stripErrorSquared(const unsigned N, const float uProj) {
10  if( (float(N)-uProj) > 3.5f )
11  return float(N*N)/12.f;
12  else {
13  const float P1=-0.339f;
14  const float P2=0.90f;
15  const float P3=0.279f;
16  const float uerr = P1*uProj*std::exp(-uProj*P2)+P3;
17  return uerr*uerr;
18  }
19  }
20 }
21 
24  const GeomDetUnit& det,
25  const LocalTrajectoryParameters& ltp) const
26 {
28 
29  LocalPoint final_lp;
30  LocalError final_le;
31 
32  // Default reconstruction (needed if template reco fails)
33 
34  StripCPE::Param const& p = param( det );
35 
36  LocalVector track = ltp.momentum();
37  track *=
38  ( track.z()<0 ) ? fabs( p.thickness/track.z() ) :
39  ( track.z()>0 ) ? -fabs( p.thickness/track.z() ) :
40  p.maxLength/track.mag() ;
41 
42  const unsigned N = cluster.amplitudes().size();
43 
44  const float fullProjection = p.coveredStrips( track+p.drift, ltp.position());
45 
46  const float strip = cluster.barycenter() - 0.5f*(1.f-p.backplanecorrection) * fullProjection
47  + 0.5f*p.coveredStrips(track, ltp.position());
48 
49  LocalPoint default_lp = p.topology->localPosition( strip, ltp.vector() );
50 
51 
52 
53 
54 
55  // Get the error of the split cluster.
56  // If the cluster is not split, then the error is -99999.9.
57  // The split cluster error is in microns and it has to be transformed into centimeteres and then in measurement units
58 
59  float uerr2 = -99999.9;
60  float split_cluster_error = cluster.getSplitClusterError();
61 
62  float local_pitch = p.topology->localPitch( default_lp );
63 
64  if ( split_cluster_error > 0.0 && use_strip_split_cluster_errors )
65  {
66  //cout << endl;
67  //cout << "Assign split rechit errors" << endl;
68  // go from microns to cm and then to strip units...
69 
70  uerr2 =
71  (split_cluster_error/10000.0 / local_pitch ) *
72  (split_cluster_error/10000.0 / local_pitch );
73  }
74  else
75  {
76  //cout << endl;
77  //cout << "Assign default rechit errors" << endl;
78  uerr2 = stripErrorSquared( N, fabs(fullProjection) );
79  }
80 
81 
82  LocalError default_le = p.topology->localError( strip, uerr2, ltp.vector() );
83 
84 
85 
86  // Template reconstruction
87 
88  int ierr = 9999999; // failed template reco ( if ierr = 0, then, template reco was successful )
89  float template_x_pos = -9999999.9;
90  float template_x_err = -9999999.9;
91 
92  // int cluster_size = (int)cluster.amplitudes().size();
93 
94  // do not use template reco for huge clusters
95  if ( use_template_reco )
96  {
97 
98  int id = -9999999;
99 
100  SiStripDetId ssdid = SiStripDetId( det.geographicalId() );
101 
102  int is_stereo = (int)( ssdid.stereo() );
103 
104  if ( p.moduleGeom == 1 ) // IB1
105  {
106  if ( !is_stereo )
107  id = 11;
108  else
109  id = 12;
110  }
111  else if ( p.moduleGeom == 2 ) // IB2
112  {
113  id = 13;
114  }
115  else if ( p.moduleGeom == 3 ) // OB1
116  {
117  id = 16;
118  }
119  else if ( p.moduleGeom == 4 ) // OB2
120  {
121  if ( !is_stereo )
122  id = 14;
123  else
124  id = 15;
125  }
126  //else
127  //cout << "Do not use templates for strip modules other than IB1, IB2, OB1 and OB2" << endl;
128 
129  const StripGeomDetUnit* stripdet = (const StripGeomDetUnit*)(&det);
130 
131  if ( (id > -9999999) && !(stripdet == nullptr) )
132  {
133  // Variables needed by template reco
134  float cotalpha = -9999999.9;
135  float cotbeta = -9999999.9;
136  float locBy = -9999999.9;
137  std::vector<float> vec_cluster_charge;
138 
139  // Variables returned by template reco
140  float xrec = -9999999.9;
141  float sigmax = -9999999.9;
142  float probx = -9999999.9;
143  int qbin = -9999999 ;
144  int speed = template_reco_speed ;
145  float probQ = -9999999.9;
146 
147 
148  LocalVector lbfield = ( stripdet->surface() ).toLocal( magfield_.inTesla( stripdet->surface().position() ) );
149  locBy = lbfield.y();
150 
151 
152  LocalVector localDir = ltp.momentum()/ltp.momentum().mag();
153  float locx = localDir.x();
154  float locy = localDir.y();
155  float locz = localDir.z();
156  cotalpha = locx/locz;
157  cotbeta = locy/locz;
158 
159 
160  int cluster_size = (int)( (cluster.amplitudes()).size() );
161  for (int i=0; i<cluster_size; ++i)
162  {
163  vec_cluster_charge.push_back( (float)( (cluster.amplitudes())[i] ) );
164  }
165 
166 
167  float measurement_position_first_strip_center = (float)(cluster.firstStrip()) + 0.5;
168 
169  LocalPoint local_position_first_strip_center
170  = p.topology->localPosition( measurement_position_first_strip_center, ltp.vector() );
171 
172 
175  cotalpha,
176  cotbeta,
177  locBy,
178  vec_cluster_charge,
179  templ,
180  xrec,
181  sigmax,
182  probx,
183  qbin,
184  speed,
185  probQ );
186 
187 
188 
189  // stripCPEtemplateProbability_ = probQ;
190  // stripCPEtemplateQbin_ = qbin;
191 
192 
193  template_x_pos = xrec / 10000.0 + local_position_first_strip_center.x();
194 
195  if ( split_cluster_error > 0.0 && use_strip_split_cluster_errors )
196  {
197  template_x_err = split_cluster_error/10000.0;
198  }
199  else
200  {
201  template_x_err = sigmax/10000.0;
202  }
203 
204 
205  } // if ( id > -9999999 && !stripdet == 0 )
206 
207  } // if ( use_template_reco )
208 
209 
210  if ( use_template_reco && ierr == 0 )
211  {
212  //cout << "Use template reco " << ierr << endl;
213 
214  LocalPoint template_lp( template_x_pos , default_lp.y() , default_lp.z() );
215  LocalError template_le( template_x_err*template_x_err, default_le.xy(), default_le.yy() );
216 
217 
218  final_lv = std::make_pair( template_lp, template_le );
219 
220  }
221  else
222  {
223  //cout << "Use default reco " << ierr << endl;
224 
225  final_lv = std::make_pair( default_lp, default_le );
226  }
227 
228  return final_lv;
229 
230 
231 }
232 
233 
234 
size
Write out results.
StripClusterParameterEstimator::LocalValues localParameters(const SiStripCluster &, const GeomDetUnit &, const LocalTrajectoryParameters &) const override
uint32_t stereo() const
Definition: SiStripDetId.h:160
LocalPoint position() const
Local x and y position coordinates.
float thickness
Definition: StripCPE.h:37
virtual LocalError localError(float strip, float stripErr2) const =0
StripTopology const * topology
Definition: StripCPE.h:35
T y() const
Definition: PV3DBase.h:63
std::pair< LocalPoint, LocalError > LocalValues
uint16_t firstStrip() const
std::vector< SiStripTemplateStore > theStripTemp_
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
float backplanecorrection
Definition: StripCPE.h:39
float getSplitClusterError() const
AlgebraicVector5 vector() const
float xy() const
Definition: LocalError.h:25
T mag() const
Definition: PV3DBase.h:67
SiStripDetId::ModuleGeometry moduleGeom
Definition: StripCPE.h:40
float yy() const
Definition: LocalError.h:26
virtual LocalPoint localPosition(float strip) const =0
T z() const
Definition: PV3DBase.h:64
int StripTempReco1D(int id, float cotalpha, float cotbeta, float locBy, std::vector< float > &cluster, SiStripTemplate &templ, float &xrec, float &sigmax, float &probx, int &qbin, int speed, float &probQ)
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:79
float barycenter() const
double f[11][100]
const MagneticField & magfield_
Definition: StripCPE.h:76
LocalVector momentum() const
Momentum vector in the local frame.
float coveredStrips(const LocalVector &, const LocalPoint &) const
Definition: StripCPE.cc:76
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
#define N
Definition: blowfish.cc:9
virtual float localPitch(const LocalPoint &) const =0
float maxLength
Definition: StripCPE.h:37
Param const & param(const GeomDetUnit &det) const
Definition: StripCPE.h:82
LocalVector drift
Definition: StripCPE.h:36
T x() const
Definition: PV3DBase.h:62
const PositionType & position() const
const std::vector< uint8_t > & amplitudes() const