Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:49

0001 // -*- C++ -*-
0002 //
0003 // Package:     Muons
0004 // Class  :     FWMuonLegoProxyBuilder
0005 //
0006 //
0007 
0008 #include "TEvePointSet.h"
0009 
0010 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0011 #include "DataFormats/MuonReco/interface/Muon.h"
0012 #include "DataFormats/TrackReco/interface/Track.h"
0013 
0014 class FWMuonLegoProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Muon> {
0015 public:
0016   FWMuonLegoProxyBuilder(void) {}
0017   ~FWMuonLegoProxyBuilder(void) override {}
0018 
0019   REGISTER_PROXYBUILDER_METHODS();
0020 
0021   // Disable default copy constructor
0022   FWMuonLegoProxyBuilder(const FWMuonLegoProxyBuilder&) = delete;
0023   // Disable default assignment operator
0024   const FWMuonLegoProxyBuilder& operator=(const FWMuonLegoProxyBuilder&) = delete;
0025 
0026 private:
0027   using FWSimpleProxyBuilderTemplate<reco::Muon>::build;
0028   void build(const reco::Muon& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
0029 };
0030 
0031 void FWMuonLegoProxyBuilder::build(const reco::Muon& iData,
0032                                    unsigned int iIndex,
0033                                    TEveElement& oItemHolder,
0034                                    const FWViewContext*) {
0035   TEvePointSet* points = new TEvePointSet;
0036   setupAddElement(points, &oItemHolder);
0037 
0038   points->SetMarkerStyle(2);
0039   points->SetMarkerSize(0.2);
0040 
0041   // get ECAL position of the propagated trajectory if available
0042   if (iData.isEnergyValid() && iData.calEnergy().ecal_position.r() > 100) {
0043     points->SetNextPoint(iData.calEnergy().ecal_position.eta(), iData.calEnergy().ecal_position.phi(), 0.1);
0044     return;
0045   }
0046 
0047   // get position of the muon at surface of the tracker
0048   if (iData.track().isAvailable() && iData.track()->extra().isAvailable()) {
0049     points->SetNextPoint(iData.track()->outerPosition().eta(), iData.track()->outerPosition().phi(), 0.1);
0050     return;
0051   }
0052 
0053   // get position of the inner state of the stand alone muon
0054   if (iData.standAloneMuon().isAvailable() && iData.standAloneMuon()->extra().isAvailable()) {
0055     if (iData.standAloneMuon()->innerPosition().R() < iData.standAloneMuon()->outerPosition().R())
0056       points->SetNextPoint(
0057           iData.standAloneMuon()->innerPosition().eta(), iData.standAloneMuon()->innerPosition().phi(), 0.1);
0058     else
0059       points->SetNextPoint(
0060           iData.standAloneMuon()->outerPosition().eta(), iData.standAloneMuon()->outerPosition().phi(), 0.1);
0061     return;
0062   }
0063 
0064   // WARNING: use direction at POCA as the last option
0065   points->SetNextPoint(iData.eta(), iData.phi(), 0.1);
0066 }
0067 
0068 REGISTER_FWPROXYBUILDER(FWMuonLegoProxyBuilder, reco::Muon, "Muons", FWViewType::kAllLegoBits);