00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "TEveTrack.h"
00010 #include "TEveTrackPropagator.h"
00011 #include "TEveStraightLineSet.h"
00012 #include "TEveVSDStructs.h"
00013 #include "TEveGeoNode.h"
00014
00015
00016 #include "Fireworks/Tracks/interface/TrackUtils.h"
00017 #include "Fireworks/Core/interface/FWEventItem.h"
00018 #include "Fireworks/Core/interface/FWGeometry.h"
00019 #include "Fireworks/Core/interface/TEveElementIter.h"
00020 #include "Fireworks/Core/interface/fwLog.h"
00021
00022 #include "DataFormats/TrackReco/interface/Track.h"
00023
00024 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
00025
00026 #include "DataFormats/TrackingRecHit/interface/RecHit2DLocalPos.h"
00027 #include "DataFormats/TrackingRecHit/interface/RecSegment.h"
00028 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
00029 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h"
00030 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
00031 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00032 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
00033 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00034 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00035 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00036 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00037 #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
00038 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
00039 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00040 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
00041
00042 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
00043 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00044 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00045 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00046
00047 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00048 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00049 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00050
00051 #include "DataFormats/CaloTowers/interface/CaloTowerDetId.h"
00052
00053 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00054 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00055
00056 namespace fireworks {
00057
00058 static const double MICRON = 1./1000./10.;
00059 static const double PITCHX = 100*MICRON;
00060 static const double PITCHY = 150*MICRON;
00061 static const int BIG_PIX_PER_ROC_Y = 2;
00062 static const int COLS_PER_ROC = 52;
00063 static const int ROWS_PER_ROC = 80;
00064 static const int BIG_PIX_PER_ROC_X = 1;
00065
00066
00067 static const std::string subdets[7] = { "UNKNOWN", "PXB", "PXF", "TIB", "TID", "TOB", "TEC" };
00068
00069 TEveTrack*
00070 prepareTrack( const reco::Track& track,
00071 TEveTrackPropagator* propagator,
00072 const std::vector<TEveVector>& extraRefPoints )
00073 {
00074
00075
00076
00077 std::vector<State> refStates;
00078 TEveVector trackMomentum(track.px(), track.py(), track.pz());
00079 refStates.push_back(State(TEveVector(track.vx(), track.vy(), track.vz()),
00080 trackMomentum));
00081 if( track.extra().isAvailable() ) {
00082 if (track.innerOk()) {
00083 const reco::TrackBase::Point &v = track.innerPosition();
00084 const reco::TrackBase::Vector &p = track.innerMomentum();
00085 refStates.push_back(State(TEveVector(v.x(), v.y(), v.z()), TEveVector(p.x(), p.y(), p.z())));
00086 }
00087 if (track.outerOk()) {
00088 const reco::TrackBase::Point &v = track.outerPosition();
00089 const reco::TrackBase::Vector &p = track.outerMomentum();
00090 refStates.push_back(State(TEveVector(v.x(), v.y(), v.z()), TEveVector(p.x(), p.y(), p.z())));
00091 }
00092 }
00093 for( std::vector<TEveVector>::const_iterator point = extraRefPoints.begin(), pointEnd = extraRefPoints.end();
00094 point != pointEnd; ++point )
00095 refStates.push_back(State(*point));
00096 if( track.pt()>1 )
00097 std::sort( refStates.begin(), refStates.end(), StateOrdering(trackMomentum) );
00098
00099
00100
00101
00102
00103
00104
00105
00106 TEveRecTrack t;
00107 t.fBeta = 1.;
00108 t.fSign = track.charge();
00109
00110 if( refStates.front().valid ) {
00111 t.fV = refStates.front().position;
00112 t.fP = refStates.front().momentum;
00113 TEveTrack* trk = new TEveTrack( &t, propagator );
00114 for( unsigned int i(1); i<refStates.size()-1; ++i) {
00115 if( refStates[i].valid )
00116 trk->AddPathMark( TEvePathMark( TEvePathMark::kReference, refStates[i].position, refStates[i].momentum ) );
00117 else
00118 trk->AddPathMark( TEvePathMark( TEvePathMark::kDaughter, refStates[i].position ) );
00119 }
00120 if( refStates.size()>1 ) {
00121 trk->AddPathMark( TEvePathMark( TEvePathMark::kDecay, refStates.back().position ) );
00122 }
00123 return trk;
00124 }
00125
00126 if( refStates.back().valid ) {
00127 t.fSign = (-1)*track.charge();
00128 t.fV = refStates.back().position;
00129 t.fP = refStates.back().momentum * (-1.0f);
00130 TEveTrack* trk = new TEveTrack( &t, propagator );
00131 unsigned int i( refStates.size()-1 );
00132 for(; i>0; --i) {
00133 if ( refStates[i].valid )
00134 trk->AddPathMark( TEvePathMark( TEvePathMark::kReference, refStates[i].position, refStates[i].momentum*(-1.0f) ) );
00135 else
00136 trk->AddPathMark( TEvePathMark( TEvePathMark::kDaughter, refStates[i].position ) );
00137 }
00138 if ( refStates.size()>1 ) {
00139 trk->AddPathMark( TEvePathMark( TEvePathMark::kDecay, refStates.front().position ) );
00140 }
00141 return trk;
00142 }
00143
00144 unsigned int i(0);
00145 while( i<refStates.size() && !refStates[i].valid ) ++i;
00146 assert( i < refStates.size() );
00147
00148 t.fV = refStates[i].position;
00149 t.fP = refStates[i].momentum;
00150 TEveTrack* trk = new TEveTrack( &t, propagator );
00151 for( unsigned int j(i+1); j<refStates.size()-1; ++j ) {
00152 if( refStates[i].valid )
00153 trk->AddPathMark( TEvePathMark( TEvePathMark::kReference, refStates[i].position, refStates[i].momentum ) );
00154 else
00155 trk->AddPathMark( TEvePathMark( TEvePathMark::kDaughter, refStates[i].position ) );
00156 }
00157 if ( i < refStates.size() ) {
00158 trk->AddPathMark( TEvePathMark( TEvePathMark::kDecay, refStates.back().position ) );
00159 }
00160 return trk;
00161 }
00162
00163
00164 float
00165 pixelLocalX( const double mpx, const int nrows )
00166 {
00167
00168
00169
00170 const double xoffset = -( nrows + BIG_PIX_PER_ROC_X * nrows / ROWS_PER_ROC ) / 2. * PITCHX;
00171
00172
00173
00174
00175 int binoffx = int(mpx);
00176 double fractionX = mpx - binoffx;
00177 double local_PITCHX = PITCHX;
00178 if( binoffx > 80 ) {
00179 binoffx = binoffx + 2;
00180 } else if( binoffx == 80 ) {
00181 binoffx = binoffx+1;
00182 local_PITCHX = 2 * PITCHX;
00183 } else if( binoffx == 79 ) {
00184 binoffx = binoffx + 0;
00185 local_PITCHX = 2 * PITCHX;
00186 } else if( binoffx >= 0 ) {
00187 binoffx = binoffx + 0;
00188 }
00189
00190
00191 double lpX = double( binoffx * PITCHX ) + fractionX * local_PITCHX + xoffset;
00192
00193 return lpX;
00194 }
00195
00196
00197 float
00198 pixelLocalY( const double mpy, const int ncols )
00199 {
00200
00201
00202
00203 double yoffset = -( ncols + BIG_PIX_PER_ROC_Y * ncols / COLS_PER_ROC ) / 2. * PITCHY;
00204
00205
00206
00207
00208 int binoffy = int( mpy );
00209 double fractionY = mpy - binoffy;
00210 double local_PITCHY = PITCHY;
00211
00212 if( binoffy>416 ) {
00213 binoffy = binoffy+17;
00214 } else if( binoffy == 416 ) {
00215 binoffy = binoffy + 16;
00216 local_PITCHY = 2 * PITCHY;
00217 } else if( binoffy == 415 ) {
00218 binoffy = binoffy + 15;
00219 local_PITCHY = 2 * PITCHY;
00220 } else if( binoffy > 364 ) {
00221 binoffy = binoffy + 15;
00222 } else if( binoffy == 364 ) {
00223 binoffy = binoffy + 14;
00224 local_PITCHY = 2 * PITCHY;
00225 } else if( binoffy == 363 ) {
00226 binoffy = binoffy + 13;
00227 local_PITCHY = 2 * PITCHY;
00228 } else if( binoffy > 312 ) {
00229 binoffy = binoffy + 13;
00230 } else if( binoffy == 312 ) {
00231 binoffy = binoffy + 12;
00232 local_PITCHY = 2 * PITCHY;
00233 } else if( binoffy == 311 ) {
00234 binoffy = binoffy + 11;
00235 local_PITCHY = 2 * PITCHY;
00236 } else if( binoffy > 260 ) {
00237 binoffy = binoffy + 11;
00238 } else if( binoffy == 260 ) {
00239 binoffy = binoffy + 10;
00240 local_PITCHY = 2 * PITCHY;
00241 } else if( binoffy == 259 ) {
00242 binoffy = binoffy + 9;
00243 local_PITCHY = 2 * PITCHY;
00244 } else if( binoffy > 208 ) {
00245 binoffy = binoffy + 9;
00246 } else if(binoffy == 208 ) {
00247 binoffy = binoffy + 8;
00248 local_PITCHY = 2 * PITCHY;
00249 } else if( binoffy == 207 ) {
00250 binoffy = binoffy + 7;
00251 local_PITCHY = 2 * PITCHY;
00252 } else if( binoffy > 156 ) {
00253 binoffy = binoffy + 7;
00254 } else if( binoffy == 156 ) {
00255 binoffy = binoffy + 6;
00256 local_PITCHY = 2 * PITCHY;
00257 } else if( binoffy == 155 ) {
00258 binoffy = binoffy + 5;
00259 local_PITCHY = 2 * PITCHY;
00260 } else if( binoffy > 104 ) {
00261 binoffy = binoffy + 5;
00262 } else if( binoffy == 104 ) {
00263 binoffy = binoffy + 4;
00264 local_PITCHY = 2 * PITCHY;
00265 } else if( binoffy == 103 ) {
00266 binoffy = binoffy + 3;
00267 local_PITCHY = 2 * PITCHY;
00268 } else if( binoffy > 52 ) {
00269 binoffy = binoffy + 3;
00270 } else if( binoffy == 52 ) {
00271 binoffy = binoffy + 2;
00272 local_PITCHY = 2 * PITCHY;
00273 } else if( binoffy == 51 ) {
00274 binoffy = binoffy + 1;
00275 local_PITCHY = 2 * PITCHY;
00276 } else if( binoffy > 0 ) {
00277 binoffy=binoffy + 1;
00278 } else if( binoffy == 0 ) {
00279 binoffy = binoffy + 0;
00280 local_PITCHY = 2 * PITCHY;
00281 }
00282
00283
00284 double lpY = double( binoffy * PITCHY ) + fractionY * local_PITCHY + yoffset;
00285
00286 return lpY;
00287 }
00288
00289
00290
00291
00292 void localSiStrip( short strip, float* localTop, float* localBottom, const float* pars, unsigned int id )
00293 {
00294 Float_t topology = pars[0];
00295 Float_t halfStripLength = pars[2] * 0.5;
00296
00297 Double_t localCenter[3] = { 0.0, 0.0, 0.0 };
00298 localTop[1] = halfStripLength;
00299 localBottom[1] = -halfStripLength;
00300
00301 if( topology == 1 )
00302 {
00303
00304
00305 Float_t stripAngle = tan( pars[5] + strip * pars[6] );
00306 Float_t delta = halfStripLength * stripAngle;
00307 localCenter[0] = pars[4] * stripAngle;
00308 localTop[0] = localCenter[0] + delta;
00309 localBottom[0] = localCenter[0] - delta;
00310 }
00311 else if( topology == 2 )
00312 {
00313
00314
00315 Float_t offset = -pars[1] * 0.5 * pars[3];
00316 localCenter[0] = strip * pars[3] + offset;
00317 localTop[0] = localCenter[0];
00318 localBottom[0] = localCenter[0];
00319 }
00320 else if( topology == 3 )
00321 {
00322 fwLog( fwlog::kError )
00323 << "did not expect TrapezoidalStripTopology of "
00324 << id << std::endl;
00325 }
00326 else if( pars[0] == 0 )
00327 {
00328 fwLog( fwlog::kError )
00329 << "did not find StripTopology of "
00330 << id << std::endl;
00331 }
00332 }
00333
00334
00335
00336 void
00337 setupAddElement(TEveElement* el, TEveElement* parent, const FWEventItem* item, bool master, bool color)
00338 {
00339 if (master)
00340 {
00341 el->CSCTakeAnyParentAsMaster();
00342 el->SetPickable(true);
00343 }
00344
00345 if (color)
00346 {
00347 el->CSCApplyMainColorToMatchingChildren();
00348 el->CSCApplyMainTransparencyToMatchingChildren();
00349 el->SetMainColor(item->defaultDisplayProperties().color());
00350 assert((item->defaultDisplayProperties().transparency() >= 0)
00351 && (item->defaultDisplayProperties().transparency() <= 100));
00352 el->SetMainTransparency(item->defaultDisplayProperties().transparency());
00353 }
00354 parent->AddElement(el);
00355 }
00356
00357
00358
00359 const SiStripCluster* extractClusterFromTrackingRecHit( const TrackingRecHit* rechit )
00360 {
00361 const SiStripCluster* cluster = 0;
00362
00363 if( const SiStripRecHit2D* hit2D = dynamic_cast<const SiStripRecHit2D*>( rechit ))
00364 {
00365 fwLog( fwlog::kDebug ) << "hit 2D ";
00366
00367 if( hit2D->cluster().isNonnull())
00368 {
00369 cluster = hit2D->cluster().get();
00370 }
00371 else if( hit2D->cluster_regional().isNonnull())
00372 {
00373 cluster = hit2D->cluster_regional().get();
00374 }
00375 else
00376 {
00377 fwLog( fwlog::kDebug ) << "no cluster found!\n";
00378 }
00379 }
00380 if( cluster == 0 )
00381 {
00382 if( const SiStripRecHit1D* hit1D = dynamic_cast<const SiStripRecHit1D*>( rechit ))
00383 {
00384 fwLog( fwlog::kDebug ) << "hit 1D ";
00385
00386 if( hit1D->cluster().isNonnull())
00387 {
00388 cluster = hit1D->cluster().get();
00389 }
00390 else if( hit1D->cluster_regional().isNonnull())
00391 {
00392 cluster = hit1D->cluster_regional().get();
00393 }
00394 else
00395 {
00396 fwLog( fwlog::kDebug ) << "no cluster found!\n";
00397 }
00398 }
00399 }
00400 return cluster;
00401 }
00402
00403 void
00404 addSiStripClusters( const FWEventItem* iItem, const reco::Track &t, class TEveElement *tList, bool addNearbyClusters, bool master )
00405 {
00406
00407 const FWGeometry *geom = iItem->getGeom();
00408
00409 const edmNew::DetSetVector<SiStripCluster> * allClusters = 0;
00410 if( addNearbyClusters )
00411 {
00412 for( trackingRecHit_iterator it = t.recHitsBegin(), itEnd = t.recHitsEnd(); it != itEnd; ++it )
00413 {
00414 if( typeid( **it ) == typeid( SiStripRecHit2D ))
00415 {
00416 const SiStripRecHit2D &hit = static_cast<const SiStripRecHit2D &>( **it );
00417 if( hit.cluster().isNonnull() && hit.cluster().isAvailable())
00418 {
00419 allClusters = hit.cluster().product();
00420 break;
00421 }
00422 }
00423 else if( typeid( **it ) == typeid( SiStripRecHit1D ))
00424 {
00425 const SiStripRecHit1D &hit = static_cast<const SiStripRecHit1D &>( **it );
00426 if( hit.cluster().isNonnull() && hit.cluster().isAvailable())
00427 {
00428 allClusters = hit.cluster().product();
00429 break;
00430 }
00431 }
00432 }
00433 }
00434
00435 for( trackingRecHit_iterator it = t.recHitsBegin(), itEnd = t.recHitsEnd(); it != itEnd; ++it )
00436 {
00437 unsigned int rawid = (*it)->geographicalId();
00438 if( ! geom->contains( rawid ))
00439 {
00440 fwLog( fwlog::kError )
00441 << "failed to get geometry of SiStripCluster with detid: "
00442 << rawid << std::endl;
00443
00444 continue;
00445 }
00446
00447 const float* pars = geom->getParameters( rawid );
00448
00449
00450 TrackingRecHitRef rechitRef = *it;
00451 const TrackingRecHit *rechit = &( *rechitRef );
00452 const SiStripCluster *cluster = extractClusterFromTrackingRecHit( rechit );
00453
00454 if( cluster )
00455 {
00456 if( allClusters != 0 )
00457 {
00458 const edmNew::DetSet<SiStripCluster> & clustersOnThisDet = (*allClusters)[rechit->geographicalId().rawId()];
00459
00460 for( edmNew::DetSet<SiStripCluster>::const_iterator itc = clustersOnThisDet.begin(), edc = clustersOnThisDet.end(); itc != edc; ++itc )
00461 {
00462
00463 TEveStraightLineSet *scposition = new TEveStraightLineSet;
00464 scposition->SetDepthTest( false );
00465 scposition->SetPickable( kTRUE );
00466
00467 short firststrip = itc->firstStrip();
00468
00469 if( &*itc == cluster )
00470 {
00471 scposition->SetTitle( Form( "Exact SiStripCluster from TrackingRecHit, first strip %d", firststrip ));
00472 scposition->SetLineColor( kGreen );
00473 }
00474 else
00475 {
00476 scposition->SetTitle( Form( "SiStripCluster, first strip %d", firststrip ));
00477 scposition->SetLineColor( kRed );
00478 }
00479
00480 float localTop[3] = { 0.0, 0.0, 0.0 };
00481 float localBottom[3] = { 0.0, 0.0, 0.0 };
00482
00483 fireworks::localSiStrip( firststrip, localTop, localBottom, pars, rawid );
00484
00485 float globalTop[3];
00486 float globalBottom[3];
00487 geom->localToGlobal( rawid, localTop, globalTop, localBottom, globalBottom );
00488
00489 scposition->AddLine( globalTop[0], globalTop[1], globalTop[2],
00490 globalBottom[0], globalBottom[1], globalBottom[2] );
00491
00492 setupAddElement( scposition, tList, iItem, master, false );
00493 }
00494 }
00495 else
00496 {
00497 short firststrip = cluster->firstStrip();
00498 TEveStraightLineSet *scposition = new TEveStraightLineSet;
00499 scposition->SetDepthTest( false );
00500 scposition->SetPickable( kTRUE );
00501 scposition->SetTitle( Form( "SiStripCluster, first strip %d", firststrip ));
00502
00503 float localTop[3] = { 0.0, 0.0, 0.0 };
00504 float localBottom[3] = { 0.0, 0.0, 0.0 };
00505
00506 fireworks::localSiStrip( firststrip, localTop, localBottom, pars, rawid );
00507
00508 float globalTop[3];
00509 float globalBottom[3];
00510 geom->localToGlobal( rawid, localTop, globalTop, localBottom, globalBottom );
00511
00512 scposition->AddLine( globalTop[0], globalTop[1], globalTop[2],
00513 globalBottom[0], globalBottom[1], globalBottom[2] );
00514
00515 setupAddElement( scposition, tList, iItem, master, true );
00516 }
00517 }
00518 else if( !rechit->isValid() && ( rawid != 0 ))
00519 {
00520 if( allClusters != 0 )
00521 {
00522 edmNew::DetSetVector<SiStripCluster>::const_iterator itds = allClusters->find( rawid );
00523 if( itds != allClusters->end())
00524 {
00525 const edmNew::DetSet<SiStripCluster> & clustersOnThisDet = *itds;
00526 for( edmNew::DetSet<SiStripCluster>::const_iterator itc = clustersOnThisDet.begin(), edc = clustersOnThisDet.end(); itc != edc; ++itc )
00527 {
00528 short firststrip = itc->firstStrip();
00529
00530 TEveStraightLineSet *scposition = new TEveStraightLineSet;
00531 scposition->SetDepthTest( false );
00532 scposition->SetPickable( kTRUE );
00533 scposition->SetTitle( Form( "Lost SiStripCluster, first strip %d", firststrip ));
00534
00535 float localTop[3] = { 0.0, 0.0, 0.0 };
00536 float localBottom[3] = { 0.0, 0.0, 0.0 };
00537
00538 fireworks::localSiStrip( firststrip, localTop, localBottom, pars, rawid );
00539
00540 float globalTop[3];
00541 float globalBottom[3];
00542 geom->localToGlobal( rawid, localTop, globalTop, localBottom, globalBottom );
00543
00544 scposition->AddLine( globalTop[0], globalTop[1], globalTop[2],
00545 globalBottom[0], globalBottom[1], globalBottom[2] );
00546
00547
00548 setupAddElement( scposition, tList, iItem, master, false );
00549 scposition->SetLineColor( kRed );
00550 }
00551 }
00552 }
00553 }
00554 else
00555 {
00556 fwLog( fwlog::kDebug )
00557 << "*ANOTHER* option possible: valid=" << rechit->isValid()
00558 << ", rawid=" << rawid << std::endl;
00559 }
00560 }
00561 }
00562
00563
00564
00565 void
00566 pushNearbyPixelHits( std::vector<TVector3> &pixelPoints, const FWEventItem &iItem, const reco::Track &t )
00567 {
00568 const edmNew::DetSetVector<SiPixelCluster> * allClusters = 0;
00569 for( trackingRecHit_iterator it = t.recHitsBegin(), itEnd = t.recHitsEnd(); it != itEnd; ++it)
00570 {
00571 if( typeid(**it) == typeid( SiPixelRecHit ))
00572 {
00573 const SiPixelRecHit &hit = static_cast<const SiPixelRecHit &>(**it);
00574 if( hit.cluster().isNonnull() && hit.cluster().isAvailable())
00575 {
00576 allClusters = hit.cluster().product();
00577 break;
00578 }
00579 }
00580 }
00581 if( allClusters == 0 ) return;
00582
00583 const FWGeometry *geom = iItem.getGeom();
00584
00585 for( trackingRecHit_iterator it = t.recHitsBegin(), itEnd = t.recHitsEnd(); it != itEnd; ++it )
00586 {
00587 const TrackingRecHit* rh = &(**it);
00588
00589 DetId id = (*it)->geographicalId();
00590 if( ! geom->contains( id ))
00591 {
00592 fwLog( fwlog::kError )
00593 << "failed to get geometry of Tracker Det with raw id: "
00594 << id.rawId() << std::endl;
00595
00596 continue;
00597 }
00598
00599
00600 unsigned int subdet = (unsigned int)id.subdetId();
00601 if(( subdet != PixelSubdetector::PixelBarrel ) && ( subdet != PixelSubdetector::PixelEndcap )) continue;
00602
00603 const SiPixelCluster* hitCluster = 0;
00604 if( const SiPixelRecHit* pixel = dynamic_cast<const SiPixelRecHit*>( rh ))
00605 hitCluster = pixel->cluster().get();
00606 edmNew::DetSetVector<SiPixelCluster>::const_iterator itds = allClusters->find(id.rawId());
00607 if( itds != allClusters->end())
00608 {
00609 const edmNew::DetSet<SiPixelCluster> & clustersOnThisDet = *itds;
00610 for( edmNew::DetSet<SiPixelCluster>::const_iterator itc = clustersOnThisDet.begin(), edc = clustersOnThisDet.end(); itc != edc; ++itc )
00611 {
00612 if( &*itc != hitCluster )
00613 pushPixelCluster( pixelPoints, *geom, id, *itc, geom->getParameters( id ));
00614 }
00615 }
00616 }
00617 }
00618
00619
00620
00621 void
00622 pushPixelHits( std::vector<TVector3> &pixelPoints, const FWEventItem &iItem, const reco::Track &t )
00623 {
00624
00625
00626
00627 const FWGeometry *geom = iItem.getGeom();
00628
00629 double dz = t.dz();
00630 double vz = t.vz();
00631 double etaT = t.eta();
00632
00633 fwLog( fwlog::kDebug ) << "Track eta: " << etaT << ", vz: " << vz << ", dz: " << dz
00634 << std::endl;
00635
00636 int cnt = 0;
00637 for( trackingRecHit_iterator it = t.recHitsBegin(), itEnd = t.recHitsEnd(); it != itEnd; ++it )
00638 {
00639 const TrackingRecHit* rh = &(**it);
00640
00641 DetId id = (*it)->geographicalId();
00642 if( ! geom->contains( id ))
00643 {
00644 fwLog( fwlog::kError )
00645 << "failed to get geometry of Tracker Det with raw id: "
00646 << id.rawId() << std::endl;
00647
00648 continue;
00649 }
00650
00651
00652 unsigned int subdet = (unsigned int)id.subdetId();
00653
00654 if(( subdet == PixelSubdetector::PixelBarrel ) || ( subdet == PixelSubdetector::PixelEndcap ))
00655 {
00656 fwLog( fwlog::kDebug ) << cnt++ << " -- "
00657 << subdets[subdet];
00658
00659 if( const SiPixelRecHit* pixel = dynamic_cast<const SiPixelRecHit*>( rh ))
00660 {
00661 const SiPixelCluster& c = *( pixel->cluster());
00662 pushPixelCluster( pixelPoints, *geom, id, c, geom->getParameters( id ));
00663 }
00664 }
00665 }
00666 }
00667
00668 void
00669 pushPixelCluster( std::vector<TVector3> &pixelPoints, const FWGeometry &geom, DetId id, const SiPixelCluster &c, const float* pars )
00670 {
00671 double row = c.minPixelRow();
00672 double col = c.minPixelCol();
00673 float lx = 0.;
00674 float ly = 0.;
00675
00676 int nrows = (int)pars[0];
00677 int ncols = (int)pars[1];
00678 lx = pixelLocalX( row, nrows );
00679 ly = pixelLocalY( col, ncols );
00680
00681 fwLog( fwlog::kDebug )
00682 << ", row: " << row << ", col: " << col
00683 << ", lx: " << lx << ", ly: " << ly ;
00684
00685 float local[3] = { lx, ly, 0. };
00686 float global[3];
00687 geom.localToGlobal( id, local, global );
00688 TVector3 pb( global[0], global[1], global[2] );
00689 pixelPoints.push_back( pb );
00690
00691 fwLog( fwlog::kDebug )
00692 << " x: " << pb.X()
00693 << ", y: " << pb.Y()
00694 << " z: " << pb.Z()
00695 << " eta: " << pb.Eta()
00696 << ", phi: " << pb.Phi()
00697 << " rho: " << pb.Pt() << std::endl;
00698 }
00699
00700
00701
00702 std::string
00703 info(const DetId& id) {
00704 std::ostringstream oss;
00705
00706 oss << "DetId: " << id.rawId() << "\n";
00707
00708 switch ( id.det() ) {
00709
00710 case DetId::Tracker:
00711 switch ( id.subdetId() ) {
00712 case StripSubdetector::TIB:
00713 {
00714 oss <<"TIB "<<TIBDetId(id).layer();
00715 }
00716 break;
00717 case StripSubdetector::TOB:
00718 {
00719 oss <<"TOB "<<TOBDetId(id).layer();
00720 }
00721 break;
00722 case StripSubdetector::TEC:
00723 {
00724 oss <<"TEC "<<TECDetId(id).wheel();
00725 }
00726 break;
00727 case StripSubdetector::TID:
00728 {
00729 oss <<"TID "<<TIDDetId(id).wheel();
00730 }
00731 break;
00732 case (int) PixelSubdetector::PixelBarrel:
00733 {
00734 oss <<"PixBarrel "<< PXBDetId(id).layer();
00735 }
00736 break;
00737 case (int) PixelSubdetector::PixelEndcap:
00738 {
00739 oss <<"PixEndcap "<< PXBDetId(id).layer();
00740 }
00741 break;
00742 }
00743 break;
00744
00745 case DetId::Muon:
00746 switch ( id.subdetId() ) {
00747 case MuonSubdetId::DT:
00748 {
00749 DTChamberId detId(id.rawId());
00750 oss << "DT chamber (wheel, station, sector): "
00751 << detId.wheel() << ", "
00752 << detId.station() << ", "
00753 << detId.sector();
00754 }
00755 break;
00756 case MuonSubdetId::CSC:
00757 {
00758 CSCDetId detId(id.rawId());
00759 oss << "CSC chamber (endcap, station, ring, chamber, layer): "
00760 << detId.endcap() << ", "
00761 << detId.station() << ", "
00762 << detId.ring() << ", "
00763 << detId.chamber() << ", "
00764 << detId.layer();
00765 }
00766 break;
00767 case MuonSubdetId::RPC:
00768 {
00769 RPCDetId detId(id.rawId());
00770 oss << "RPC chamber ";
00771 switch ( detId.region() ) {
00772 case 0:
00773 oss << "/ barrel / (wheel, station, sector, layer, subsector, roll): "
00774 << detId.ring() << ", "
00775 << detId.station() << ", "
00776 << detId.sector() << ", "
00777 << detId.layer() << ", "
00778 << detId.subsector() << ", "
00779 << detId.roll();
00780 break;
00781 case 1:
00782 oss << "/ forward endcap / (wheel, station, sector, layer, subsector, roll): "
00783 << detId.ring() << ", "
00784 << detId.station() << ", "
00785 << detId.sector() << ", "
00786 << detId.layer() << ", "
00787 << detId.subsector() << ", "
00788 << detId.roll();
00789 break;
00790 case -1:
00791 oss << "/ backward endcap / (wheel, station, sector, layer, subsector, roll): "
00792 << detId.ring() << ", "
00793 << detId.station() << ", "
00794 << detId.sector() << ", "
00795 << detId.layer() << ", "
00796 << detId.subsector() << ", "
00797 << detId.roll();
00798 break;
00799 }
00800 }
00801 break;
00802 }
00803 break;
00804
00805 case DetId::Calo:
00806 {
00807 CaloTowerDetId detId( id.rawId() );
00808 oss << "CaloTower (ieta, iphi): "
00809 << detId.ieta() << ", "
00810 << detId.iphi();
00811 }
00812 break;
00813
00814 case DetId::Ecal:
00815 switch ( id.subdetId() ) {
00816 case EcalBarrel:
00817 {
00818 EBDetId detId(id);
00819 oss << "EcalBarrel (ieta, iphi, tower_ieta, tower_iphi): "
00820 << detId.ieta() << ", "
00821 << detId.iphi() << ", "
00822 << detId.tower_ieta() << ", "
00823 << detId.tower_iphi();
00824 }
00825 break;
00826 case EcalEndcap:
00827 {
00828 EEDetId detId(id);
00829 oss << "EcalEndcap (ix, iy, SuperCrystal, crystal, quadrant): "
00830 << detId.ix() << ", "
00831 << detId.iy() << ", "
00832 << detId.isc() << ", "
00833 << detId.ic() << ", "
00834 << detId.iquadrant();
00835 }
00836 break;
00837 case EcalPreshower:
00838 oss << "EcalPreshower";
00839 break;
00840 case EcalTriggerTower:
00841 oss << "EcalTriggerTower";
00842 break;
00843 case EcalLaserPnDiode:
00844 oss << "EcalLaserPnDiode";
00845 break;
00846 }
00847 break;
00848
00849 case DetId::Hcal:
00850 {
00851 HcalDetId detId(id);
00852 switch ( detId.subdet() ) {
00853 case HcalEmpty:
00854 oss << "HcalEmpty ";
00855 break;
00856 case HcalBarrel:
00857 oss << "HcalBarrel ";
00858 break;
00859 case HcalEndcap:
00860 oss << "HcalEndcap ";
00861 break;
00862 case HcalOuter:
00863 oss << "HcalOuter ";
00864 break;
00865 case HcalForward:
00866 oss << "HcalForward ";
00867 break;
00868 case HcalTriggerTower:
00869 oss << "HcalTriggerTower ";
00870 break;
00871 case HcalOther:
00872 oss << "HcalOther ";
00873 break;
00874 }
00875 oss << "(ieta, iphi, depth):"
00876 << detId.ieta() << ", "
00877 << detId.iphi() << ", "
00878 << detId.depth();
00879 }
00880 break;
00881 default :;
00882 }
00883 return oss.str();
00884 }
00885
00886 std::string
00887 info(const std::set<DetId>& idSet) {
00888 std::string text;
00889 for(std::set<DetId>::const_iterator id = idSet.begin(), idEnd = idSet.end(); id != idEnd; ++id)
00890 {
00891 text += info(*id);
00892 text += "\n";
00893 }
00894 return text;
00895 }
00896
00897 std::string
00898 info(const std::vector<DetId>& idSet) {
00899 std::string text;
00900 for(std::vector<DetId>::const_iterator id = idSet.begin(), idEnd = idSet.end(); id != idEnd; ++id)
00901 {
00902 text += info(*id);
00903 text += "\n";
00904 }
00905 return text;
00906 }
00907 }