Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:10:05

0001 #include "TEvePointSet.h"
0002 
0003 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0004 #include "Fireworks/Core/interface/FWGeometry.h"
0005 #include "Fireworks/Core/interface/FWEventItem.h"
0006 #include "Fireworks/Core/interface/fwLog.h"
0007 
0008 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
0009 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h"
0010 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0011 #include "DataFormats/TrackReco/interface/Track.h"
0012 
0013 class FWTrackTrackingRecHitProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Track> {
0014 public:
0015   FWTrackTrackingRecHitProxyBuilder(void) {}
0016   ~FWTrackTrackingRecHitProxyBuilder(void) override {}
0017 
0018   REGISTER_PROXYBUILDER_METHODS();
0019 
0020 private:
0021   using FWSimpleProxyBuilderTemplate<reco::Track>::build;
0022   void build(const reco::Track& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
0023 
0024 public:
0025   FWTrackTrackingRecHitProxyBuilder(const FWTrackTrackingRecHitProxyBuilder&) = delete;  // stop default
0026   const FWTrackTrackingRecHitProxyBuilder& operator=(const FWTrackTrackingRecHitProxyBuilder&) = delete;  // stop default
0027 };
0028 
0029 void FWTrackTrackingRecHitProxyBuilder::build(const reco::Track& iData,
0030                                               unsigned int iIndex,
0031                                               TEveElement& oItemHolder,
0032                                               const FWViewContext*) {
0033   const FWGeometry* geom = item()->getGeom();
0034 
0035   for (trackingRecHit_iterator it = iData.recHitsBegin(), itEnd = iData.recHitsEnd(); it != itEnd; ++it) {
0036     TEvePointSet* pointSet = new TEvePointSet;
0037     setupAddElement(pointSet, &oItemHolder);
0038 
0039     auto rechitRef = *it;
0040     const TrackingRecHit* rechit = &(*rechitRef);
0041 
0042     if (rechit->isValid()) {
0043       unsigned int rawid = rechit->geographicalId().rawId();
0044 
0045       if (!geom->contains(rawid)) {
0046         fwLog(fwlog::kError) << "failed get geometry for detid: " << rawid << std::endl;
0047       }
0048 
0049       LocalPoint pos(0.0, 0.0, 0.0);
0050       if (const SiStripRecHit2D* hit = dynamic_cast<const SiStripRecHit2D*>(rechit)) {
0051         if (hit->hasPositionAndError()) {
0052           pos = rechit->localPosition();
0053         }
0054       } else if (const SiStripRecHit1D* hit = dynamic_cast<const SiStripRecHit1D*>(rechit)) {
0055         if (hit->hasPositionAndError()) {
0056           pos = rechit->localPosition();
0057         }
0058       }
0059 
0060       float localPos[3] = {pos.x(), pos.y(), pos.z()};
0061       float globalPos[3];
0062       geom->localToGlobal(rawid, localPos, globalPos);
0063       pointSet->SetNextPoint(globalPos[0], globalPos[1], globalPos[2]);
0064     }
0065   }
0066 }
0067 
0068 REGISTER_FWPROXYBUILDER(FWTrackTrackingRecHitProxyBuilder,
0069                         reco::Track,
0070                         "Track Tracking RecHits",
0071                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);