Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 // $Id: FWTracksModulesProxyBuilder.cc,v 1.1 2009/01/16 10:37:00 Tom Danielson
0003 //
0004 
0005 // user include files
0006 #include "TEveGeoShape.h"
0007 
0008 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0009 #include "Fireworks/Core/interface/FWGeometry.h"
0010 #include "Fireworks/Core/interface/FWEventItem.h"
0011 #include "Fireworks/Tracks/interface/TrackUtils.h"
0012 
0013 #include "DataFormats/TrackReco/interface/Track.h"
0014 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
0015 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0016 
0017 #include "Fireworks/Core/interface/fwLog.h"
0018 
0019 class FWTracksModulesProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Track> {
0020 public:
0021   FWTracksModulesProxyBuilder(void) {}
0022   ~FWTracksModulesProxyBuilder(void) override {}
0023 
0024   REGISTER_PROXYBUILDER_METHODS();
0025 
0026   static bool representsSubPart(void);
0027 
0028 private:
0029   using FWSimpleProxyBuilderTemplate<reco::Track>::build;
0030   void build(const reco::Track& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
0031 
0032 public:
0033   FWTracksModulesProxyBuilder(const FWTracksModulesProxyBuilder&) = delete;                   // stop default
0034   const FWTracksModulesProxyBuilder& operator=(const FWTracksModulesProxyBuilder&) = delete;  // stop default
0035 };
0036 
0037 void FWTracksModulesProxyBuilder::build(const reco::Track& track,
0038                                         unsigned int iIndex,
0039                                         TEveElement& oItemHolder,
0040                                         const FWViewContext*) {
0041   if (track.extra().isAvailable()) {
0042     const FWGeometry* geom = item()->getGeom();
0043 
0044     for (trackingRecHit_iterator recIt = track.recHitsBegin(), recItEnd = track.recHitsEnd(); recIt != recItEnd;
0045          ++recIt) {
0046       DetId detid = (*recIt)->geographicalId();
0047       if ((*recIt)->isValid()) {
0048         if (detid.det() == DetId::Muon) {
0049           if (detid.subdetId() == MuonSubdetId::DT)
0050             detid = DetId(DTChamberId(detid));  // get rid of layer bits
0051         }
0052 
0053         TEveGeoShape* shape = geom->getEveShape(detid);
0054         if (shape) {
0055           setupAddElement(shape, &oItemHolder);
0056         } else {
0057           fwLog(fwlog::kDebug) << "Failed to get shape extract for track-id " << iIndex << ", tracking rec hit: "
0058                                << "\n"
0059                                << fireworks::info(detid) << std::endl;
0060         }
0061       }
0062     }
0063   }
0064 }
0065 
0066 bool FWTracksModulesProxyBuilder::representsSubPart(void) { return true; }
0067 
0068 REGISTER_FWPROXYBUILDER(FWTracksModulesProxyBuilder,
0069                         reco::Track,
0070                         "TrackDets",
0071                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);