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