Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:     Tracks
0004 // Class  :     FWTrackProxyBuilder
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Tue Nov 25 14:42:13 EST 2008
0011 //
0012 
0013 // system include files
0014 #include "TEveTrack.h"
0015 
0016 // user include files
0017 #include "Fireworks/Core/interface/FWSimpleProxyBuilderTemplate.h"
0018 #include "Fireworks/Core/interface/FWEventItem.h"
0019 #include "Fireworks/Core/interface/FWProxyBuilderConfiguration.h"
0020 #include "Fireworks/Core/interface/FWMagField.h"
0021 #include "Fireworks/Tracks/interface/TrackUtils.h"
0022 #include "Fireworks/Tracks/interface/estimate_field.h"
0023 
0024 #include "DataFormats/TrackReco/interface/Track.h"
0025 
0026 class FWTrackProxyBuilder : public FWSimpleProxyBuilderTemplate<reco::Track> {
0027 public:
0028   FWTrackProxyBuilder();
0029   ~FWTrackProxyBuilder() override;
0030 
0031   REGISTER_PROXYBUILDER_METHODS();
0032 
0033   void setItem(const FWEventItem* iItem) override;
0034 
0035   FWTrackProxyBuilder(const FWTrackProxyBuilder&) = delete;  // stop default
0036 
0037   const FWTrackProxyBuilder& operator=(const FWTrackProxyBuilder&) = delete;  // stop default
0038 
0039 private:
0040   using FWSimpleProxyBuilderTemplate<reco::Track>::build;
0041   void build(const reco::Track& iData, unsigned int iIndex, TEveElement& oItemHolder, const FWViewContext*) override;
0042 };
0043 
0044 FWTrackProxyBuilder::FWTrackProxyBuilder() {}
0045 
0046 FWTrackProxyBuilder::~FWTrackProxyBuilder() {}
0047 
0048 void FWTrackProxyBuilder::setItem(const FWEventItem* iItem) {
0049   FWProxyBuilderBase::setItem(iItem);
0050 
0051   if (iItem) {
0052     iItem->getConfig()->assertParam("LineWidth", long(1), long(1), long(4));
0053   }
0054 }
0055 
0056 void FWTrackProxyBuilder::build(const reco::Track& iData,
0057                                 unsigned int iIndex,
0058                                 TEveElement& oItemHolder,
0059                                 const FWViewContext*) {
0060   if (context().getField()->getSource() == FWMagField::kNone) {
0061     if (fabs(iData.eta()) < 2.0 && iData.pt() > 0.5 && iData.pt() < 30) {
0062       double estimate = fw::estimate_field(iData, true);
0063       if (estimate >= 0)
0064         context().getField()->guessField(estimate);
0065     }
0066   }
0067 
0068   TEveTrackPropagator* propagator =
0069       (!iData.extra().isAvailable()) ? context().getTrackerTrackPropagator() : context().getTrackPropagator();
0070 
0071   TEveTrack* trk = fireworks::prepareTrack(iData, propagator);
0072   trk->MakeTrack();
0073 
0074   // Line width can be cached as a member. Set in virtual builder::itemChanged()
0075   int width = item()->getConfig()->value<long>("LineWidth");
0076   trk->SetLineWidth(width);
0077 
0078   setupAddElement(trk, &oItemHolder);
0079 }
0080 
0081 //
0082 // static member functions
0083 //
0084 REGISTER_FWPROXYBUILDER(FWTrackProxyBuilder, reco::Track, "Tracks", FWViewType::kAll3DBits | FWViewType::kAllRPZBits);