CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusterShapeHitFilter.cc
Go to the documentation of this file.
2 
7 
11 
14 
17 
19 
24 
27 
29 
31 
33 
35 
36 #include <fstream>
37 #include<cassert>
38 
39 using namespace std;
40 
41 
42 /*****************************************************************************/
44  (const TrackerGeometry * theTracker_,
45  const MagneticField * theMagneticField_,
46  const SiPixelLorentzAngle * theSiPixelLorentzAngle_,
47  const SiStripLorentzAngle * theSiStripLorentzAngle_)
48  : theTracker(theTracker_),
49  theMagneticField(theMagneticField_),
50  theSiPixelLorentzAngle(theSiPixelLorentzAngle_),
51  theSiStripLorentzAngle(theSiStripLorentzAngle_)
52 
53 {
54  // Load pixel limits
55  loadPixelLimits();
56  fillPixelData();
57 
58  // Load strip limits
59  loadStripLimits();
60 }
61 
62 /*****************************************************************************/
64 {
65 }
66 
67 /*****************************************************************************/
69 {
71  fileInPath("RecoPixelVertexing/PixelLowPtUtilities/data/pixelShape.par");
72  ifstream inFile(fileInPath.fullPath().c_str());
73 
74 
75  while(inFile.eof() == false)
76  {
77  int part,dx,dy;
78 
79  inFile >> part; // 0or 1
80  inFile >> dx; // 0 to 10
81  inFile >> dy; // 0 to 15 ...
82 
83  const PixelKeys key(part,dx,dy);
84  auto & pl = pixelLimits[key];
85 
86  for(int b = 0; b<2 ; b++) // branch
87  for(int d = 0; d<2 ; d++) // direction
88  for(int k = 0; k<2 ; k++) // lower and upper
89  inFile >> pl.data[b][d][k];
90 
91 
92  double f;
93  int d;
94 
95  inFile >> f; // density
96  inFile >> d; // points
97  inFile >> f; // density
98  inFile >> d; // points
99  }
100 
101  inFile.close();
102 
103  LogTrace("MinBiasTracking|ClusterShapeHitFilter")
104  << " [ClusterShapeHitFilter] pixel-cluster-shape filter loaded";
105  }
106 
107 /*****************************************************************************/
109 {
110  // Load strip
112  fileInPath("RecoPixelVertexing/PixelLowPtUtilities/data/stripShape.par");
113  ifstream inFile(fileInPath.fullPath().c_str());
114 
115 
116  while(inFile.eof() == false)
117  {
118  int dx;
119  inFile >> dx;
120 
121  StripKeys key(dx);
122  auto & sl = stripLimits[key];
123 
124  for(int b = 0; b<2 ; b++) // branch
125  for(int k = 0; k<2 ; k++) // lower and upper
126  inFile >> sl.data[b][k];
127 
128  }
129 
130  inFile.close();
131 
132  LogTrace("MinBiasTracking|ClusterShapeHitFilter")
133  << " [ClusterShapeHitFilter] strip-cluster-width filter loaded";
134 }
135 
136 
137 
139 
140  //barrel
141  for (auto det : theTracker->detsPXB()) {
142  // better not to fail..
143  const PixelGeomDetUnit * pixelDet =
144  dynamic_cast<const PixelGeomDetUnit*>(det);
145  assert(pixelDet);
146  PixelData & pd = pixelData[pixelDet->geographicalId()];
147  pd.det = pixelDet;
148  pd.part=0;
149  pd.cotangent=getCotangent(pixelDet);
150  pd.drift=getDrift(pixelDet);
151  }
152 
153  //endcap
154  for (auto det : theTracker->detsPXF()) {
155  // better not to fail..
156  const PixelGeomDetUnit * pixelDet =
157  dynamic_cast<const PixelGeomDetUnit*>(det);
158  assert(pixelDet);
159  PixelData & pd = pixelData[pixelDet->geographicalId()];
160  pd.det = pixelDet;
161  pd.part=1;
162  pd.cotangent=getCotangent(pixelDet);
163  pd.drift=getDrift(pixelDet);
164  }
165 
166 }
167 
168 
169 /*****************************************************************************/
170 pair<float,float> ClusterShapeHitFilter::getCotangent
171  (const PixelGeomDetUnit * pixelDet) const
172 {
173  pair<float,float> cotangent;
174 
175  cotangent.first = pixelDet->surface().bounds().thickness() /
176  pixelDet->specificTopology().pitch().first;
177  cotangent.second = pixelDet->surface().bounds().thickness() /
178  pixelDet->specificTopology().pitch().second;
179 
180  return cotangent;
181 }
182 
183 /*****************************************************************************/
185  (const StripGeomDetUnit * stripDet) const
186 {
187  // FIXME may be problematic in case of RadialStriptolopgy
188  return stripDet->surface().bounds().thickness() /
189  stripDet->specificTopology().localPitch(LocalPoint(0,0,0));
190 }
191 
192 /*****************************************************************************/
193 pair<float,float> ClusterShapeHitFilter::getDrift
194  (const PixelGeomDetUnit * pixelDet) const
195 {
196  LocalVector lBfield =
197  (pixelDet->surface()).toLocal(
198  theMagneticField->inTesla(
199  pixelDet->surface().position()));
200 
201  double theTanLorentzAnglePerTesla =
202  theSiPixelLorentzAngle->getLorentzAngle(
203  pixelDet->geographicalId().rawId());
204 
205  pair<float,float> dir;
206  dir.first = - theTanLorentzAnglePerTesla * lBfield.y();
207  dir.second = theTanLorentzAnglePerTesla * lBfield.x();
208 
209  return dir;
210 }
211 
212 /*****************************************************************************/
214 const
215 {
216  LocalVector lBfield =
217  (stripDet->surface()).toLocal(
218  theMagneticField->inTesla(
219  stripDet->surface().position()));
220 
221  double theTanLorentzAnglePerTesla =
222  theSiStripLorentzAngle->getLorentzAngle(
223  stripDet->geographicalId().rawId());
224 
225  float dir = theTanLorentzAnglePerTesla * lBfield.y();
226 
227  return dir;
228 }
229 
230 /*****************************************************************************/
232  (const GeomDetUnit * geomDet) const
233 {
234  if(geomDet->type().isBarrel())
235  { // barrel
236  float perp0 = geomDet->toGlobal( Local3DPoint(0.,0.,0.) ).perp();
237  float perp1 = geomDet->toGlobal( Local3DPoint(0.,0.,1.) ).perp();
238  return (perp1 > perp0);
239  }
240  else
241  { // endcap
242  float rot = geomDet->toGlobal( LocalVector (0.,0.,1.) ).z();
243  float pos = geomDet->toGlobal( Local3DPoint(0.,0.,0.) ).z();
244  return (rot * pos > 0);
245  }
246 }
247 
248 /*****************************************************************************/
249 /*****************************************************************************/
250 
252  (const SiPixelRecHit & recHit, const LocalVector & ldir,
253  int & part, vector<pair<int,int> > & meas, pair<float,float> & pred,
254  PixelData const * ipd) const
255 {
256  // Get detector
257  const PixelData & pd = getpd(recHit,ipd);
258 
259  // Get shape information
261  ClusterShape theClusterShape;
262  theClusterShape.determineShape(*pd.det, recHit, data);
263  bool usable = (data.isStraight && data.isComplete);
264 
265  // Usable?
266  //if(usable)
267  {
268  part = pd.part;
269 
270  // Predicted size
271  pred.first = ldir.x() / ldir.z();
272  pred.second = ldir.y() / ldir.z();
273 
274  if(data.size.front().second < 0)
275  pred.second = - pred.second;
276 
277  meas.reserve(data.size.size());
278  for(vector<pair<int,int> >::const_iterator s = data.size.begin();
279  s!= data.size.end(); s++)
280  {
281  meas.push_back(*s);
282 
283  if(data.size.front().second < 0)
284  meas.back().second = - meas.back().second;
285  }
286 
287  // Take out drift
288  std::pair<float,float> const & drift = pd.drift;
289  pred.first += drift.first;
290  pred.second += drift.second;
291 
292  // Apply cotangent
293  std::pair<float,float> const & cotangent = pd.cotangent;
294  pred.first *= cotangent.first;
295  pred.second *= cotangent.second;
296  }
297 
298  // Usable?
299  return usable;
300 }
301 
303  (const SiPixelRecHit & recHit, const LocalVector & ldir,
304  PixelData const * ipd) const
305 {
306  // Get detector
307  const PixelData & pd = getpd(recHit,ipd);
308 
309  int part;
310  vector<pair<int,int> > meas;
311  pair<float,float> pred;
312 
313  if(getSizes(recHit, ldir, part,meas, pred,&pd))
314  {
315  for(vector<pair<int,int> >::const_iterator m = meas.begin();
316  m!= meas.end(); m++)
317  {
318  PixelKeys key(part, (*m).first, (*m).second);
319  if (!key.isValid()) return true; // FIXME original logic
320  if (pixelLimits[key].isInside(pred)) return true;
321  }
322  // none of the choices worked
323  return false;
324  }
325  // not usable
326  return true;
327 }
328 
330  (const SiPixelRecHit & recHit, const GlobalVector & gdir,
331  PixelData const * ipd) const
332 {
333  // Get detector
334  const PixelData & pd = getpd(recHit,ipd);
335 
336  LocalVector ldir =pd.det->toLocal(gdir);
337 
338  return isCompatible(recHit, ldir,&pd);
339 }
340 
341 
342 /*****************************************************************************/
343 /*****************************************************************************/
345  (DetId id, const SiStripCluster & cluster, const LocalVector & ldir,
346  int & meas, float & pred) const
347 {
348  // Get detector
349  const StripGeomDetUnit* stripDet =
350  dynamic_cast<const StripGeomDetUnit*> (theTracker->idToDet(id));
351 
352  // Measured width
353  meas = cluster.amplitudes().size();
354 
355  // Usable?
356  int fs = cluster.firstStrip();
357  int ns = stripDet->specificTopology().nstrips();
358  // bool usable = (fs > 1 && fs + meas - 1 < ns);
359  bool usable = (fs >= 1 && fs + meas - 1 <= ns);
360 
361  // Usable?
362  //if(usable)
363  {
364  // Predicted width
365  pred = ldir.x() / ldir.z();
366 
367  // Take out drift
368  float drift = getDrift(stripDet);
369  pred += drift;
370 
371  // Apply cotangent
372  pred *= getCotangent(stripDet);
373  }
374 
375  return usable;
376 }
377 
378 
379 /*****************************************************************************/
381  (DetId detId, const SiStripCluster & cluster, const LocalVector & ldir) const
382 {
383  int meas;
384  float pred;
385 
386  if(getSizes(detId, cluster, ldir, meas, pred))
387  {
388  StripKeys key(meas);
389  if (key.isValid())
390  return stripLimits[key].isInside(pred);
391  }
392 
393  // Not usable or no limits
394  return true;
395 }
396 
397 
398 /*****************************************************************************/
400  (DetId detId, const SiStripCluster & cluster, const GlobalVector & gdir) const
401 {
402  LocalVector ldir = theTracker->idToDet(detId)->toLocal(gdir);
403  return isCompatible(detId, cluster, ldir);
404 }
405 
406 
409 
412 
std::vector< std::pair< int, int > > size
Definition: ClusterData.h:11
virtual int nstrips() const =0
bool isBarrel() const
Definition: GeomDetType.cc:13
T perp() const
Definition: PV3DBase.h:71
std::pair< float, float > cotangent
bool isCompatible(const SiPixelRecHit &recHit, const LocalVector &ldir, PixelData const *pd=0) const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
bool isValid() const
LocalVector drift(const StripGeomDetUnit *, const MagneticField &, const SiStripLorentzAngle &)
Definition: ShallowTools.cc:39
T y() const
Definition: PV3DBase.h:62
void determineShape(const PixelGeomDetUnit &pixelDet, const SiPixelRecHit &recHit, ClusterData &data)
Definition: ClusterShape.cc:97
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
uint16_t firstStrip() const
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
virtual const StripTopology & specificTopology() const
Returns a reference to the strip proxy topology.
bool isComplete
Definition: ClusterData.h:10
bool isValid() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
virtual float thickness() const =0
virtual float localPitch(const LocalPoint &) const =0
std::pair< float, float > getCotangent(const PixelGeomDetUnit *pixelDet) const
T z() const
Definition: PV3DBase.h:63
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
double f[11][100]
virtual const GeomDetType & type() const =0
#define LogTrace(id)
bool isNormalOriented(const GeomDetUnit *geomDet) const
int k[5][pyjets_maxn]
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:97
virtual std::pair< float, float > pitch() const =0
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
Definition: DetId.h:20
const Bounds & bounds() const
Definition: BoundSurface.h:89
std::pair< float, float > getDrift(const PixelGeomDetUnit *pixelDet) const
part
Definition: HCALResponse.h:21
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
double b
Definition: hdecay.h:120
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
list key
Definition: combine.py:13
bool getSizes(const SiPixelRecHit &recHit, const LocalVector &ldir, int &part, std::vector< std::pair< int, int > > &meas, std::pair< float, float > &predr, PixelData const *pd=0) const
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
dbl *** dir
Definition: mlp_gen.cc:35
std::string fullPath() const
Definition: FileInPath.cc:171
T x() const
Definition: PV3DBase.h:61
const PositionType & position() const
bool isStraight
Definition: ClusterData.h:10
const std::vector< uint8_t > & amplitudes() const
Our base class.
Definition: SiPixelRecHit.h:22