CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackUtils.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Tracks
4 // Class : TrackUtils
5 //
6 
7 // system include files
8 #include "TEveTrack.h"
9 #include "TEveTrackPropagator.h"
10 #include "TEveStraightLineSet.h"
11 #include "TEveVSDStructs.h"
12 #include "TEveGeoNode.h"
13 
14 // user include files
20 
22 
24 
26 
42 
49 
53 
55 
58 
60 
61 namespace fireworks {
62 
63 static const double MICRON = 1./1000./10.;
64 static const double PITCHX = 100*MICRON;
65 static const double PITCHY = 150*MICRON;
66 static const int BIG_PIX_PER_ROC_Y = 2; // in y direction, cols
67 static const int COLS_PER_ROC = 52; // Num of Rows per ROC
68 static const int ROWS_PER_ROC = 80; // Num of cols per ROC
69 static const int BIG_PIX_PER_ROC_X = 1; // in x direction, rows
70 
71 // -- Si module names for printout
72 static const std::string subdets[7] = { "UNKNOWN", "PXB", "PXF", "TIB", "TID", "TOB", "TEC" };
73 
74 TEveTrack*
75 prepareTrack( const reco::Track& track,
76  TEveTrackPropagator* propagator,
77  const std::vector<TEveVector>& extraRefPoints )
78 {
79  // To make use of all available information, we have to order states
80  // properly first. Propagator should take care of y=0 transition.
81 
82  std::vector<State> refStates;
83  TEveVector trackMomentum(track.px(), track.py(), track.pz());
84  refStates.push_back(State(TEveVector(track.vx(), track.vy(), track.vz()),
85  trackMomentum));
86  if( track.extra().isAvailable() ) {
87  if (track.innerOk()) {
88  const reco::TrackBase::Point &v = track.innerPosition();
89  const reco::TrackBase::Vector &p = track.innerMomentum();
90  refStates.push_back(State(TEveVector(v.x(), v.y(), v.z()), TEveVector(p.x(), p.y(), p.z())));
91  }
92  if (track.outerOk()) {
93  const reco::TrackBase::Point &v = track.outerPosition();
94  const reco::TrackBase::Vector &p = track.outerMomentum();
95  refStates.push_back(State(TEveVector(v.x(), v.y(), v.z()), TEveVector(p.x(), p.y(), p.z())));
96  }
97  }
98  for( std::vector<TEveVector>::const_iterator point = extraRefPoints.begin(), pointEnd = extraRefPoints.end();
99  point != pointEnd; ++point )
100  refStates.push_back(State(*point));
101  if( track.pt()>1 )
102  std::sort( refStates.begin(), refStates.end(), StateOrdering(trackMomentum) );
103 
104  // * if the first state has non-zero momentum use it as a starting point
105  // and all other points as PathMarks to follow
106  // * if the first state has only position, try the last state. If it has
107  // momentum we propagate backword, if not, we look for the first one
108  // on left that has momentum and ignore all earlier.
109  //
110 
111  TEveRecTrack t;
112  t.fBeta = 1.;
113  t.fSign = track.charge();
114 
115  if( refStates.front().valid ) {
116  t.fV = refStates.front().position;
117  t.fP = refStates.front().momentum;
118  TEveTrack* trk = new TEveTrack( &t, propagator );
119  for( unsigned int i(1); i<refStates.size()-1; ++i) {
120  if( refStates[i].valid )
121  trk->AddPathMark( TEvePathMark( TEvePathMark::kReference, refStates[i].position, refStates[i].momentum ) );
122  else
123  trk->AddPathMark( TEvePathMark( TEvePathMark::kDaughter, refStates[i].position ) );
124  }
125  if( refStates.size()>1 ) {
126  trk->AddPathMark( TEvePathMark( TEvePathMark::kDecay, refStates.back().position ) );
127  }
128  return trk;
129  }
130 
131  if( refStates.back().valid ) {
132  t.fSign = (-1)*track.charge();
133  t.fV = refStates.back().position;
134  t.fP = refStates.back().momentum * (-1.0f);
135  TEveTrack* trk = new TEveTrack( &t, propagator );
136  unsigned int i( refStates.size()-1 );
137  for(; i>0; --i) {
138  if ( refStates[i].valid )
139  trk->AddPathMark( TEvePathMark( TEvePathMark::kReference, refStates[i].position, refStates[i].momentum*(-1.0f) ) );
140  else
141  trk->AddPathMark( TEvePathMark( TEvePathMark::kDaughter, refStates[i].position ) );
142  }
143  if ( refStates.size()>1 ) {
144  trk->AddPathMark( TEvePathMark( TEvePathMark::kDecay, refStates.front().position ) );
145  }
146  return trk;
147  }
148 
149  unsigned int i(0);
150  while( i<refStates.size() && !refStates[i].valid ) ++i;
151  assert( i < refStates.size() );
152 
153  t.fV = refStates[i].position;
154  t.fP = refStates[i].momentum;
155  TEveTrack* trk = new TEveTrack( &t, propagator );
156  for( unsigned int j(i+1); j<refStates.size()-1; ++j ) {
157  if( refStates[i].valid )
158  trk->AddPathMark( TEvePathMark( TEvePathMark::kReference, refStates[i].position, refStates[i].momentum ) );
159  else
160  trk->AddPathMark( TEvePathMark( TEvePathMark::kDaughter, refStates[i].position ) );
161  }
162  if ( i < refStates.size() ) {
163  trk->AddPathMark( TEvePathMark( TEvePathMark::kDecay, refStates.back().position ) );
164  }
165  return trk;
166 }
167 
168 // Transform measurement to local coordinates in X dimension
169 float
170 pixelLocalX( const double mpx, const int nrows )
171 {
172  // Calculate the edge of the active sensor with respect to the center,
173  // that is simply the half-size.
174  // Take into account large pixels
175  const double xoffset = -( nrows + BIG_PIX_PER_ROC_X * nrows / ROWS_PER_ROC ) / 2. * PITCHX;
176 
177  // Measurement to local transformation for X coordinate
178  // X coordinate is in the ROC row number direction
179  // Copy from RectangularPixelTopology::localX implementation
180  int binoffx = int(mpx); // truncate to int
181  double fractionX = mpx - binoffx; // find the fraction
182  double local_PITCHX = PITCHX; // defaultpitch
183  if( binoffx > 80 ) { // ROC 1 - handles x on edge cluster
184  binoffx = binoffx + 2;
185  } else if( binoffx == 80 ) { // ROC 1
186  binoffx = binoffx+1;
187  local_PITCHX = 2 * PITCHX;
188  } else if( binoffx == 79 ) { // ROC 0
189  binoffx = binoffx + 0;
190  local_PITCHX = 2 * PITCHX;
191  } else if( binoffx >= 0 ) { // ROC 0
192  binoffx = binoffx + 0;
193  }
194 
195  // The final position in local coordinates
196  double lpX = double( binoffx * PITCHX ) + fractionX * local_PITCHX + xoffset;
197 
198  return lpX;
199 }
200 
201 // Transform measurement to local coordinates in Y dimension
202 float
203 pixelLocalY( const double mpy, const int ncols )
204 {
205  // Calculate the edge of the active sensor with respect to the center,
206  // that is simply the half-size.
207  // Take into account large pixels
208  double yoffset = -( ncols + BIG_PIX_PER_ROC_Y * ncols / COLS_PER_ROC ) / 2. * PITCHY;
209 
210  // Measurement to local transformation for Y coordinate
211  // Y is in the ROC column number direction
212  // Copy from RectangularPixelTopology::localY implementation
213  int binoffy = int( mpy ); // truncate to int
214  double fractionY = mpy - binoffy; // find the fraction
215  double local_PITCHY = PITCHY; // defaultpitch
216 
217  if( binoffy>416 ) { // ROC 8, not real ROC
218  binoffy = binoffy+17;
219  } else if( binoffy == 416 ) { // ROC 8
220  binoffy = binoffy + 16;
221  local_PITCHY = 2 * PITCHY;
222  } else if( binoffy == 415 ) { // ROC 7, last big pixel
223  binoffy = binoffy + 15;
224  local_PITCHY = 2 * PITCHY;
225  } else if( binoffy > 364 ) { // ROC 7
226  binoffy = binoffy + 15;
227  } else if( binoffy == 364 ) { // ROC 7
228  binoffy = binoffy + 14;
229  local_PITCHY = 2 * PITCHY;
230  } else if( binoffy == 363 ) { // ROC 6
231  binoffy = binoffy + 13;
232  local_PITCHY = 2 * PITCHY;
233  } else if( binoffy > 312 ) { // ROC 6
234  binoffy = binoffy + 13;
235  } else if( binoffy == 312 ) { // ROC 6
236  binoffy = binoffy + 12;
237  local_PITCHY = 2 * PITCHY;
238  } else if( binoffy == 311 ) { // ROC 5
239  binoffy = binoffy + 11;
240  local_PITCHY = 2 * PITCHY;
241  } else if( binoffy > 260 ) { // ROC 5
242  binoffy = binoffy + 11;
243  } else if( binoffy == 260 ) { // ROC 5
244  binoffy = binoffy + 10;
245  local_PITCHY = 2 * PITCHY;
246  } else if( binoffy == 259 ) { // ROC 4
247  binoffy = binoffy + 9;
248  local_PITCHY = 2 * PITCHY;
249  } else if( binoffy > 208 ) { // ROC 4
250  binoffy = binoffy + 9;
251  } else if(binoffy == 208 ) { // ROC 4
252  binoffy = binoffy + 8;
253  local_PITCHY = 2 * PITCHY;
254  } else if( binoffy == 207 ) { // ROC 3
255  binoffy = binoffy + 7;
256  local_PITCHY = 2 * PITCHY;
257  } else if( binoffy > 156 ) { // ROC 3
258  binoffy = binoffy + 7;
259  } else if( binoffy == 156 ) { // ROC 3
260  binoffy = binoffy + 6;
261  local_PITCHY = 2 * PITCHY;
262  } else if( binoffy == 155 ) { // ROC 2
263  binoffy = binoffy + 5;
264  local_PITCHY = 2 * PITCHY;
265  } else if( binoffy > 104 ) { // ROC 2
266  binoffy = binoffy + 5;
267  } else if( binoffy == 104 ) { // ROC 2
268  binoffy = binoffy + 4;
269  local_PITCHY = 2 * PITCHY;
270  } else if( binoffy == 103 ) { // ROC 1
271  binoffy = binoffy + 3;
272  local_PITCHY = 2 * PITCHY;
273  } else if( binoffy > 52 ) { // ROC 1
274  binoffy = binoffy + 3;
275  } else if( binoffy == 52 ) { // ROC 1
276  binoffy = binoffy + 2;
277  local_PITCHY = 2 * PITCHY;
278  } else if( binoffy == 51 ) { // ROC 0
279  binoffy = binoffy + 1;
280  local_PITCHY = 2 * PITCHY;
281  } else if( binoffy > 0 ) { // ROC 0
282  binoffy=binoffy + 1;
283  } else if( binoffy == 0 ) { // ROC 0
284  binoffy = binoffy + 0;
285  local_PITCHY = 2 * PITCHY;
286  }
287 
288  // The final position in local coordinates
289  double lpY = double( binoffy * PITCHY ) + fractionY * local_PITCHY + yoffset;
290 
291  return lpY;
292 }
293 
294 //
295 // Returns strip geometry in local coordinates of a detunit.
296 // The strip is a line from a localTop to a localBottom point.
297 void localSiStrip( short strip, float* localTop, float* localBottom, const float* pars, unsigned int id )
298 {
299  Float_t topology = pars[0];
300  Float_t halfStripLength = pars[2] * 0.5;
301 
302  Double_t localCenter[3] = { 0.0, 0.0, 0.0 };
303  localTop[1] = halfStripLength;
304  localBottom[1] = -halfStripLength;
305 
306  if( topology == 1 ) // RadialStripTopology
307  {
308  // stripAngle = phiOfOneEdge + strip * angularWidth
309  // localY = originToIntersection * tan( stripAngle )
310  Float_t stripAngle = tan( pars[5] + strip * pars[6] );
311  Float_t delta = halfStripLength * stripAngle;
312  localCenter[0] = pars[4] * stripAngle;
313  localTop[0] = localCenter[0] + delta;
314  localBottom[0] = localCenter[0] - delta;
315  }
316  else if( topology == 2 ) // RectangularStripTopology
317  {
318  // offset = -numberOfStrips/2. * pitch
319  // localY = strip * pitch + offset
320  Float_t offset = -pars[1] * 0.5 * pars[3];
321  localCenter[0] = strip * pars[3] + offset;
322  localTop[0] = localCenter[0];
323  localBottom[0] = localCenter[0];
324  }
325  else if( topology == 3 ) // TrapezoidalStripTopology
326  {
328  << "did not expect TrapezoidalStripTopology of "
329  << id << std::endl;
330  }
331  else if( pars[0] == 0 ) // StripTopology
332  {
334  << "did not find StripTopology of "
335  << id << std::endl;
336  }
337 }
338 
339 //______________________________________________________________________________
340 
341 void
342 setupAddElement(TEveElement* el, TEveElement* parent, const FWEventItem* item, bool master, bool color)
343 {
344  if (master)
345  {
346  el->CSCTakeAnyParentAsMaster();
347  el->SetPickable(true);
348  }
349 
350  if (color)
351  {
352  el->CSCApplyMainColorToMatchingChildren();
353  el->CSCApplyMainTransparencyToMatchingChildren();
354  el->SetMainColor(item->defaultDisplayProperties().color());
356  && (item->defaultDisplayProperties().transparency() <= 100));
357  el->SetMainTransparency(item->defaultDisplayProperties().transparency());
358  }
359  parent->AddElement(el);
360 }
361 
362 //______________________________________________________________________________
363 
365 {
366  const SiStripCluster* cluster = 0;
367 
368  if( const SiStripRecHit2D* hit2D = dynamic_cast<const SiStripRecHit2D*>( rechit ))
369  {
370  fwLog( fwlog::kDebug ) << "hit 2D ";
371 
372  cluster = hit2D->cluster().get();
373  }
374  if( cluster == 0 )
375  {
376  if( const SiStripRecHit1D* hit1D = dynamic_cast<const SiStripRecHit1D*>( rechit ))
377  {
378  fwLog( fwlog::kDebug ) << "hit 1D ";
379 
380  cluster = hit1D->cluster().get();
381  }
382  }
383  return cluster;
384 }
385 
386 void
387 addSiStripClusters( const FWEventItem* iItem, const reco::Track &t, class TEveElement *tList, bool addNearbyClusters, bool master )
388 {
389  // master is true if the product is for proxy builder
390  const FWGeometry *geom = iItem->getGeom();
391 
392  const edmNew::DetSetVector<SiStripCluster> * allClusters = 0;
393  if( addNearbyClusters )
394  {
395  for( trackingRecHit_iterator it = t.recHitsBegin(), itEnd = t.recHitsEnd(); it != itEnd; ++it )
396  {
397  if( typeid( **it ) == typeid( SiStripRecHit2D ))
398  {
399  const SiStripRecHit2D &hit = static_cast<const SiStripRecHit2D &>( **it );
400  if( hit.cluster().isNonnull() && hit.cluster().isAvailable())
401  {
403  iItem->getEvent()->get(hit.cluster().id(), allClustersHandle);
404  allClusters = allClustersHandle.product();
405  break;
406  }
407  }
408  else if( typeid( **it ) == typeid( SiStripRecHit1D ))
409  {
410  const SiStripRecHit1D &hit = static_cast<const SiStripRecHit1D &>( **it );
411  if( hit.cluster().isNonnull() && hit.cluster().isAvailable())
412  {
414  iItem->getEvent()->get(hit.cluster().id(), allClustersHandle);
415  allClusters = allClustersHandle.product();
416  break;
417  }
418  }
419  }
420  }
421 
422  for( trackingRecHit_iterator it = t.recHitsBegin(), itEnd = t.recHitsEnd(); it != itEnd; ++it )
423  {
424  unsigned int rawid = (*it)->geographicalId();
425  if( ! geom->contains( rawid ))
426  {
428  << "failed to get geometry of SiStripCluster with detid: "
429  << rawid << std::endl;
430 
431  continue;
432  }
433 
434  const float* pars = geom->getParameters( rawid );
435 
436  // -- get phi from SiStripHit
437  auto rechitRef = *it;
438  const TrackingRecHit *rechit = &( *rechitRef );
439  const SiStripCluster *cluster = extractClusterFromTrackingRecHit( rechit );
440 
441  if( cluster )
442  {
443  if( allClusters != 0 )
444  {
445  const edmNew::DetSet<SiStripCluster> & clustersOnThisDet = (*allClusters)[rechit->geographicalId().rawId()];
446 
447  for( edmNew::DetSet<SiStripCluster>::const_iterator itc = clustersOnThisDet.begin(), edc = clustersOnThisDet.end(); itc != edc; ++itc )
448  {
449 
450  TEveStraightLineSet *scposition = new TEveStraightLineSet;
451  scposition->SetDepthTest( false );
452  scposition->SetPickable( kTRUE );
453 
454  short firststrip = itc->firstStrip();
455 
456  if( &*itc == cluster )
457  {
458  scposition->SetTitle( Form( "Exact SiStripCluster from TrackingRecHit, first strip %d", firststrip ));
459  scposition->SetLineColor( kGreen );
460  }
461  else
462  {
463  scposition->SetTitle( Form( "SiStripCluster, first strip %d", firststrip ));
464  scposition->SetLineColor( kRed );
465  }
466 
467  float localTop[3] = { 0.0, 0.0, 0.0 };
468  float localBottom[3] = { 0.0, 0.0, 0.0 };
469 
470  fireworks::localSiStrip( firststrip, localTop, localBottom, pars, rawid );
471 
472  float globalTop[3];
473  float globalBottom[3];
474  geom->localToGlobal( rawid, localTop, globalTop, localBottom, globalBottom );
475 
476  scposition->AddLine( globalTop[0], globalTop[1], globalTop[2],
477  globalBottom[0], globalBottom[1], globalBottom[2] );
478 
479  setupAddElement( scposition, tList, iItem, master, false );
480  }
481  }
482  else
483  {
484  short firststrip = cluster->firstStrip();
485  TEveStraightLineSet *scposition = new TEveStraightLineSet;
486  scposition->SetDepthTest( false );
487  scposition->SetPickable( kTRUE );
488  scposition->SetTitle( Form( "SiStripCluster, first strip %d", firststrip ));
489 
490  float localTop[3] = { 0.0, 0.0, 0.0 };
491  float localBottom[3] = { 0.0, 0.0, 0.0 };
492 
493  fireworks::localSiStrip( firststrip, localTop, localBottom, pars, rawid );
494 
495  float globalTop[3];
496  float globalBottom[3];
497  geom->localToGlobal( rawid, localTop, globalTop, localBottom, globalBottom );
498 
499  scposition->AddLine( globalTop[0], globalTop[1], globalTop[2],
500  globalBottom[0], globalBottom[1], globalBottom[2] );
501 
502  setupAddElement( scposition, tList, iItem, master, true );
503  }
504  }
505  else if( !rechit->isValid() && ( rawid != 0 )) // lost hit
506  {
507  if( allClusters != 0 )
508  {
509  edmNew::DetSetVector<SiStripCluster>::const_iterator itds = allClusters->find( rawid );
510  if( itds != allClusters->end())
511  {
512  const edmNew::DetSet<SiStripCluster> & clustersOnThisDet = *itds;
513  for( edmNew::DetSet<SiStripCluster>::const_iterator itc = clustersOnThisDet.begin(), edc = clustersOnThisDet.end(); itc != edc; ++itc )
514  {
515  short firststrip = itc->firstStrip();
516 
517  TEveStraightLineSet *scposition = new TEveStraightLineSet;
518  scposition->SetDepthTest( false );
519  scposition->SetPickable( kTRUE );
520  scposition->SetTitle( Form( "Lost SiStripCluster, first strip %d", firststrip ));
521 
522  float localTop[3] = { 0.0, 0.0, 0.0 };
523  float localBottom[3] = { 0.0, 0.0, 0.0 };
524 
525  fireworks::localSiStrip( firststrip, localTop, localBottom, pars, rawid );
526 
527  float globalTop[3];
528  float globalBottom[3];
529  geom->localToGlobal( rawid, localTop, globalTop, localBottom, globalBottom );
530 
531  scposition->AddLine( globalTop[0], globalTop[1], globalTop[2],
532  globalBottom[0], globalBottom[1], globalBottom[2] );
533 
534 
535  setupAddElement( scposition, tList, iItem, master, false );
536  scposition->SetLineColor( kRed );
537  }
538  }
539  }
540  }
541  else
542  {
544  << "*ANOTHER* option possible: valid=" << rechit->isValid()
545  << ", rawid=" << rawid << std::endl;
546  }
547  }
548 }
549 
550 //______________________________________________________________________________
551 
552 void
553 pushNearbyPixelHits( std::vector<TVector3> &pixelPoints, const FWEventItem &iItem, const reco::Track &t )
554 {
555  const edmNew::DetSetVector<SiPixelCluster> * allClusters = 0;
556  for( trackingRecHit_iterator it = t.recHitsBegin(), itEnd = t.recHitsEnd(); it != itEnd; ++it)
557  {
558  if( typeid(**it) == typeid( SiPixelRecHit ))
559  {
560  const SiPixelRecHit &hit = static_cast<const SiPixelRecHit &>(**it);
561  if( hit.cluster().isNonnull() && hit.cluster().isAvailable())
562  {
564  iItem.getEvent()->get(hit.cluster().id(), allClustersHandle);
565  allClusters = allClustersHandle.product();
566  break;
567  }
568  }
569  }
570  if( allClusters == 0 ) return;
571 
572  const FWGeometry *geom = iItem.getGeom();
573 
574  for( trackingRecHit_iterator it = t.recHitsBegin(), itEnd = t.recHitsEnd(); it != itEnd; ++it )
575  {
576  const TrackingRecHit* rh = &(**it);
577 
578  DetId id = (*it)->geographicalId();
579  if( ! geom->contains( id ))
580  {
582  << "failed to get geometry of Tracker Det with raw id: "
583  << id.rawId() << std::endl;
584 
585  continue;
586  }
587 
588  // -- in which detector are we?
589  unsigned int subdet = (unsigned int)id.subdetId();
590  if(( subdet != PixelSubdetector::PixelBarrel ) && ( subdet != PixelSubdetector::PixelEndcap )) continue;
591 
592  const SiPixelCluster* hitCluster = 0;
593  if( const SiPixelRecHit* pixel = dynamic_cast<const SiPixelRecHit*>( rh ))
594  hitCluster = pixel->cluster().get();
595  edmNew::DetSetVector<SiPixelCluster>::const_iterator itds = allClusters->find(id.rawId());
596  if( itds != allClusters->end())
597  {
598  const edmNew::DetSet<SiPixelCluster> & clustersOnThisDet = *itds;
599  for( edmNew::DetSet<SiPixelCluster>::const_iterator itc = clustersOnThisDet.begin(), edc = clustersOnThisDet.end(); itc != edc; ++itc )
600  {
601  if( &*itc != hitCluster )
602  pushPixelCluster( pixelPoints, *geom, id, *itc, geom->getParameters( id ));
603  }
604  }
605  }
606 }
607 
608 //______________________________________________________________________________
609 
610 void
611 pushPixelHits( std::vector<TVector3> &pixelPoints, const FWEventItem &iItem, const reco::Track &t )
612 {
613  /*
614  * -- return for each Pixel Hit a 3D point
615  */
616  const FWGeometry *geom = iItem.getGeom();
617 
618  double dz = t.dz();
619  double vz = t.vz();
620  double etaT = t.eta();
621 
622  fwLog( fwlog::kDebug ) << "Track eta: " << etaT << ", vz: " << vz << ", dz: " << dz
623  << std::endl;
624 
625  int cnt = 0;
626  for( trackingRecHit_iterator it = t.recHitsBegin(), itEnd = t.recHitsEnd(); it != itEnd; ++it )
627  {
628  const TrackingRecHit* rh = &(**it);
629  // -- get position of center of wafer, assuming (0,0,0) is the center
630  DetId id = (*it)->geographicalId();
631  if( ! geom->contains( id ))
632  {
634  << "failed to get geometry of Tracker Det with raw id: "
635  << id.rawId() << std::endl;
636 
637  continue;
638  }
639 
640  // -- in which detector are we?
641  unsigned int subdet = (unsigned int)id.subdetId();
642 
643  if(( subdet == PixelSubdetector::PixelBarrel ) || ( subdet == PixelSubdetector::PixelEndcap ))
644  {
645  fwLog( fwlog::kDebug ) << cnt++ << " -- "
646  << subdets[subdet];
647 
648  if( const SiPixelRecHit* pixel = dynamic_cast<const SiPixelRecHit*>( rh ))
649  {
650  const SiPixelCluster& c = *( pixel->cluster());
651  pushPixelCluster( pixelPoints, *geom, id, c, geom->getParameters( id ));
652  }
653  }
654  }
655 }
656 
657 void
658 pushPixelCluster( std::vector<TVector3> &pixelPoints, const FWGeometry &geom, DetId id, const SiPixelCluster &c, const float* pars )
659 {
660  double row = c.minPixelRow();
661  double col = c.minPixelCol();
662  float lx = 0.;
663  float ly = 0.;
664 
665  int nrows = (int)pars[0];
666  int ncols = (int)pars[1];
667  lx = pixelLocalX( row, nrows );
668  ly = pixelLocalY( col, ncols );
669 
671  << ", row: " << row << ", col: " << col
672  << ", lx: " << lx << ", ly: " << ly ;
673 
674  float local[3] = { lx, ly, 0. };
675  float global[3];
676  geom.localToGlobal( id, local, global );
677  TVector3 pb( global[0], global[1], global[2] );
678  pixelPoints.push_back( pb );
679 
681  << " x: " << pb.X()
682  << ", y: " << pb.Y()
683  << " z: " << pb.Z()
684  << " eta: " << pb.Eta()
685  << ", phi: " << pb.Phi()
686  << " rho: " << pb.Pt() << std::endl;
687 }
688 
689 //______________________________________________________________________________
690 
692 info(const DetId& id) {
693  std::ostringstream oss;
694 
695  oss << "DetId: " << id.rawId() << "\n";
696 
697  switch ( id.det() ) {
698 
699  case DetId::Tracker:
700  switch ( id.subdetId() ) {
702  {
703  oss <<"TIB "<<TIBDetId(id).layer();
704  }
705  break;
707  {
708  oss <<"TOB "<<TOBDetId(id).layer();
709  }
710  break;
712  {
713  oss <<"TEC "<<TECDetId(id).wheel();
714  }
715  break;
717  {
718  oss <<"TID "<<TIDDetId(id).wheel();
719  }
720  break;
722  {
723  oss <<"PixBarrel "<< PXBDetId(id).layer();
724  }
725  break;
727  {
728  oss <<"PixEndcap "<< PXBDetId(id).layer();
729  }
730  break;
731  }
732  break;
733 
734  case DetId::Muon:
735  switch ( id.subdetId() ) {
736  case MuonSubdetId::DT:
737  {
738  DTChamberId detId(id.rawId());
739  oss << "DT chamber (wheel, station, sector): "
740  << detId.wheel() << ", "
741  << detId.station() << ", "
742  << detId.sector();
743  }
744  break;
745  case MuonSubdetId::CSC:
746  {
747  CSCDetId detId(id.rawId());
748  oss << "CSC chamber (endcap, station, ring, chamber, layer): "
749  << detId.endcap() << ", "
750  << detId.station() << ", "
751  << detId.ring() << ", "
752  << detId.chamber() << ", "
753  << detId.layer();
754  }
755  break;
756  case MuonSubdetId::RPC:
757  {
758  RPCDetId detId(id.rawId());
759  oss << "RPC chamber ";
760  switch ( detId.region() ) {
761  case 0:
762  oss << "/ barrel / (wheel, station, sector, layer, subsector, roll): "
763  << detId.ring() << ", "
764  << detId.station() << ", "
765  << detId.sector() << ", "
766  << detId.layer() << ", "
767  << detId.subsector() << ", "
768  << detId.roll();
769  break;
770  case 1:
771  oss << "/ forward endcap / (wheel, station, sector, layer, subsector, roll): "
772  << detId.ring() << ", "
773  << detId.station() << ", "
774  << detId.sector() << ", "
775  << detId.layer() << ", "
776  << detId.subsector() << ", "
777  << detId.roll();
778  break;
779  case -1:
780  oss << "/ backward endcap / (wheel, station, sector, layer, subsector, roll): "
781  << detId.ring() << ", "
782  << detId.station() << ", "
783  << detId.sector() << ", "
784  << detId.layer() << ", "
785  << detId.subsector() << ", "
786  << detId.roll();
787  break;
788  }
789  }
790  break;
791  case MuonSubdetId::GEM:
792  {
793  GEMDetId detId(id.rawId());
794  oss << "GEM chamber (region, station, ring, chamber, layer): "
795  << detId.region() << ", "
796  << detId.station() << ", "
797  << detId.ring() << ", "
798  << detId.chamber() << ", "
799  << detId.layer();
800  }
801  break;
802  case MuonSubdetId::ME0:
803  {
804  ME0DetId detId(id.rawId());
805  oss << "ME0 chamber (region, chamber, layer): "
806  << detId.region() << ", "
807  << detId.chamber() << ", "
808  << detId.layer();
809  }
810  break;
811  }
812  break;
813 
814  case DetId::Calo:
815  {
816  CaloTowerDetId detId( id.rawId() );
817  oss << "CaloTower (ieta, iphi): "
818  << detId.ieta() << ", "
819  << detId.iphi();
820  }
821  break;
822 
823  case DetId::Ecal:
824  switch ( id.subdetId() ) {
825  case EcalBarrel:
826  {
827  EBDetId detId(id);
828  oss << "EcalBarrel (ieta, iphi, tower_ieta, tower_iphi): "
829  << detId.ieta() << ", "
830  << detId.iphi() << ", "
831  << detId.tower_ieta() << ", "
832  << detId.tower_iphi();
833  }
834  break;
835  case EcalEndcap:
836  {
837  EEDetId detId(id);
838  oss << "EcalEndcap (ix, iy, SuperCrystal, crystal, quadrant): "
839  << detId.ix() << ", "
840  << detId.iy() << ", "
841  << detId.isc() << ", "
842  << detId.ic() << ", "
843  << detId.iquadrant();
844  }
845  break;
846  case EcalPreshower:
847  oss << "EcalPreshower";
848  break;
849  case EcalTriggerTower:
850  oss << "EcalTriggerTower";
851  break;
852  case EcalLaserPnDiode:
853  oss << "EcalLaserPnDiode";
854  break;
855  }
856  break;
857 
858  case DetId::Hcal:
859  {
860  HcalDetId detId(id);
861  switch ( detId.subdet() ) {
862  case HcalEmpty:
863  oss << "HcalEmpty ";
864  break;
865  case HcalBarrel:
866  oss << "HcalBarrel ";
867  break;
868  case HcalEndcap:
869  oss << "HcalEndcap ";
870  break;
871  case HcalOuter:
872  oss << "HcalOuter ";
873  break;
874  case HcalForward:
875  oss << "HcalForward ";
876  break;
877  case HcalTriggerTower:
878  oss << "HcalTriggerTower ";
879  break;
880  case HcalOther:
881  oss << "HcalOther ";
882  break;
883  }
884  oss << "(ieta, iphi, depth):"
885  << detId.ieta() << ", "
886  << detId.iphi() << ", "
887  << detId.depth();
888  }
889  break;
890  default :;
891  }
892  return oss.str();
893 }
894 
896 info(const std::set<DetId>& idSet) {
898  for(std::set<DetId>::const_iterator id = idSet.begin(), idEnd = idSet.end(); id != idEnd; ++id)
899  {
900  text += info(*id);
901  text += "\n";
902  }
903  return text;
904 }
905 
907 info(const std::vector<DetId>& idSet) {
909  for(std::vector<DetId>::const_iterator id = idSet.begin(), idEnd = idSet.end(); id != idEnd; ++id)
910  {
911  text += info(*id);
912  text += "\n";
913  }
914  return text;
915 }
916 }
ClusterRef cluster() const
dbl * delta
Definition: mlp_gen.cc:36
bool isAvailable() const
Definition: Ref.h:576
int chamber() const
Definition: CSCDetId.h:68
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:453
int minPixelCol() const
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
int ix() const
Definition: EEDetId.h:76
int ic() const
Definition: EEDetId.cc:324
unsigned int layer() const
layer id
Definition: TOBDetId.h:39
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:189
CaloTopology const * topology(0)
TEveTrack * prepareTrack(const reco::Track &track, TEveTrackPropagator *propagator, const std::vector< TEveVector > &extraRefPoints=std::vector< TEveVector >())
Definition: TrackUtils.cc:75
float pixelLocalY(const double mpy, const int m_ncols)
Definition: TrackUtils.cc:203
static const int COLS_PER_ROC
Definition: TrackUtils.cc:67
int tower_ieta() const
get the HCAL/trigger ieta of this crystal
Definition: EBDetId.h:55
const float * getParameters(unsigned int id) const
Definition: FWGeometry.cc:296
bool get(ProductID const &, Handle< T > &) const
Definition: EventBase.h:102
int tower_iphi() const
get the HCAL/trigger iphi of this crystal
Definition: EBDetId.cc:114
int isc() const
Definition: EEDetId.cc:285
assert(m_qm.get())
static const int GEM
Definition: MuonSubdetId.h:15
static const int BIG_PIX_PER_ROC_Y
Definition: TrackUtils.cc:66
int ring() const
Definition: GEMDetId.h:59
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:50
int iquadrant() const
Definition: EEDetId.cc:264
uint16_t firstStrip() const
data_type const * const_iterator
Definition: DetSetNew.h:30
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Definition: GEMDetId.h:74
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:622
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:65
int layer() const
Definition: CSCDetId.h:61
ProductID id() const
Accessor for product ID.
Definition: Ref.h:258
unsigned int layer() const
layer id
Definition: PXBDetId.h:35
Color_t color() const
static const int ROWS_PER_ROC
Definition: TrackUtils.cc:68
void localSiStrip(short strip, float *localTop, float *localBottom, const float *pars, unsigned int id)
Definition: TrackUtils.cc:297
int iphi() const
get the crystal iphi
Definition: EBDetId.h:53
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:55
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int endcap() const
Definition: CSCDetId.h:93
static const int ME0
Definition: MuonSubdetId.h:16
static const double PITCHX
Definition: TrackUtils.cc:64
static const int BIG_PIX_PER_ROC_X
Definition: TrackUtils.cc:69
int depth() const
get the tower depth
Definition: HcalDetId.cc:106
Char_t transparency() const
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Definition: ME0DetId.h:51
static const int CSC
Definition: MuonSubdetId.h:13
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
int roll() const
Definition: RPCDetId.h:120
int minPixelRow() const
int ring() const
Definition: RPCDetId.h:72
double pt() const
track transverse momentum
Definition: TrackBase.h:616
const SiStripCluster * extractClusterFromTrackingRecHit(const TrackingRecHit *rh)
Definition: TrackUtils.cc:364
static const double MICRON
Definition: TrackUtils.cc:63
int layer() const
Layer id: each station have two layers of chambers: layer 1 is the inner chamber and layer 2 is the o...
Definition: GEMDetId.h:69
int ieta() const
get the cell ieta
Definition: HcalDetId.h:56
void localToGlobal(unsigned int id, const float *local, float *global, bool translatep=true) const
Definition: FWGeometry.cc:328
int iphi() const
get the tower iphi
int station() const
Station id : the station is the pair of chambers at same disk.
Definition: GEMDetId.h:64
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
int j
Definition: DBlmapReader.cc:9
double f[11][100]
static const double PITCHY
Definition: TrackUtils.cc:65
ClusterRef cluster() const
tuple text
Definition: runonSM.py:42
int iy() const
Definition: EEDetId.h:82
bool contains(unsigned int id) const
Definition: FWGeometry.h:109
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
math::XYZPoint Point
point in the space
Definition: TrackBase.h:83
void pushPixelHits(std::vector< TVector3 > &pixelPoints, const FWEventItem &iItem, const reco::Track &t)
Definition: TrackUtils.cc:611
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:104
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
Definition: GEMDetId.h:53
void addSiStripClusters(const FWEventItem *iItem, const reco::Track &t, class TEveElement *tList, bool addNearbyClusters, bool master)
Definition: TrackUtils.cc:387
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:634
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:604
int iphi() const
get the cell iphi
Definition: HcalDetId.cc:101
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:664
int ring() const
Definition: CSCDetId.h:75
const edm::EventBase * getEvent() const
Definition: FWEventItem.h:148
int layer() const
Definition: RPCDetId.h:108
Definition: DetId.h:18
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:70
T const * product() const
Definition: Handle.h:81
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:45
#define fwLog(_level_)
Definition: fwLog.h:50
ClusterRef cluster() const
Definition: SiPixelRecHit.h:49
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
Definition: ME0DetId.h:46
bool isValid() const
unsigned int wheel() const
wheel id
Definition: TECDetId.h:52
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
const_iterator find(id_type i, bool update=false) const
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
Definition: RPCDetId.h:114
Pixel cluster – collection of neighboring pixels above threshold.
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:658
iterator end()
Definition: DetSetNew.h:70
static const int RPC
Definition: MuonSubdetId.h:14
int sector() const
Definition: DTChamberId.h:61
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:60
static int position[264][3]
Definition: ReadPGInfo.cc:509
std::string info(const DetId &)
Definition: TrackUtils.cc:692
State
Definition: hltDiff.cc:319
int station() const
Definition: CSCDetId.h:86
int charge() const
track electric charge
Definition: TrackBase.h:562
static const int DT
Definition: MuonSubdetId.h:12
int layer() const
Layer id: each chamber has six layers of chambers: layer 1 is the inner layer and layer 6 is the oute...
Definition: ME0DetId.h:56
DetId geographicalId() const
int ieta() const
get the tower ieta
int station() const
Return the station number.
Definition: DTChamberId.h:51
int col
Definition: cuy.py:1008
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
static const std::string subdets[7]
Definition: TrackUtils.cc:72
void pushNearbyPixelHits(std::vector< TVector3 > &pixelPoints, const FWEventItem &iItem, const reco::Track &t)
Definition: TrackUtils.cc:553
math::XYZVector Vector
spatial vector
Definition: TrackBase.h:80
void pushPixelCluster(std::vector< TVector3 > &pixelPoints, const FWGeometry &geom, DetId id, const SiPixelCluster &c, const float *pars)
Definition: TrackUtils.cc:658
void setupAddElement(TEveElement *el, TEveElement *parent, const FWEventItem *item, bool master, bool color)
Definition: TrackUtils.cc:342
float pixelLocalX(const double mpx, const int m_nrows)
Definition: TrackUtils.cc:170
const FWGeometry * getGeom() const
Definition: FWEventItem.cc:683
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:628
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:652
unsigned int wheel() const
wheel id
Definition: TIDDetId.h:50
Our base class.
Definition: SiPixelRecHit.h:23
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:109
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96
iterator begin()
Definition: DetSetNew.h:67