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