Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-03 04:09:57

0001 // -*- C++ -*-
0002 //
0003 // Package:     Candidates
0004 // Class  :     FWCandidateProxyBuilder
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Fri Dec  5 09:56:09 EST 2008
0011 //
0012 
0013 #include "TEveTrack.h"
0014 
0015 // user include files
0016 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0017 #include "Fireworks/Core/interface/Context.h"
0018 
0019 #include "Fireworks/Candidates/interface/CandidateUtils.h"
0020 
0021 #include "DataFormats/Candidate/interface/Candidate.h"
0022 #include "Fireworks/Core/interface/FWEventItem.h"
0023 #include "Fireworks/Core/interface/FWProxyBuilderConfiguration.h"
0024 
0025 class FWCandidateProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Candidate> {
0026 public:
0027   FWCandidateProxyBuilder() {}
0028   ~FWCandidateProxyBuilder() override {}
0029 
0030   void setItem(const FWEventItem* iItem) override {
0031     FWProxyBuilderBase::setItem(iItem);
0032     if (iItem) {
0033       iItem->getConfig()->assertParam("Draw backward extrapolation", false);
0034     }
0035   }
0036 
0037   REGISTER_PROXYBUILDER_METHODS();
0038 
0039   FWCandidateProxyBuilder(const FWCandidateProxyBuilder&) = delete;                   // stop default
0040   const FWCandidateProxyBuilder& operator=(const FWCandidateProxyBuilder&) = delete;  // stop default
0041 
0042 private:
0043   using FWSimpleProxyBuilderTemplate<reco::Candidate>::build;
0044   void build(const reco::Candidate& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
0045 };
0046 
0047 void FWCandidateProxyBuilder::build(const reco::Candidate& iData,
0048                                     unsigned int iIndex,
0049                                     TEveElement& oItemHolder,
0050                                     const FWViewContext*) {
0051   TEveTrack* trk = fireworks::prepareCandidate(iData, context().getTrackPropagator());
0052 
0053   trk->MakeTrack();
0054   setupAddElement(trk, &oItemHolder);
0055 
0056   if (item()->getConfig()->value<bool>("Draw backward extrapolation")) {
0057     TEveRecTrack t;
0058     t.fBeta = 1.;
0059     t.fV = TEveVector(iData.vx(), iData.vy(), iData.vz());
0060     t.fP = TEveVector(-iData.p4().px(), -iData.p4().py(), -iData.p4().pz());
0061     t.fSign = iData.charge();
0062     TEveTrack* trk2 = new TEveTrack(&t, context().getTrackPropagator());
0063     trk2->SetLineStyle(7);
0064     trk2->MakeTrack();
0065     setupAddElement(trk2, &oItemHolder);
0066   }
0067 }
0068 
0069 //
0070 // static member functions
0071 //
0072 REGISTER_FWPROXYBUILDER(FWCandidateProxyBuilder,
0073                         reco::Candidate,
0074                         "Candidates",
0075                         FWViewType::kAll3DBits | FWViewType::kAllRPZBits);