Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-17 01:47:57

0001 /*
0002  * =============================================================================
0003  *       Filename:  RecoTauImpactParameterSignificancePlugin.cc
0004  *
0005  *    Description:  Add the IP significance of the lead track w.r.t to the PV.
0006  *                  to a PFTau.
0007  *        Created:  10/31/2010 13:32:14
0008  *
0009  *         Authors:  Evan K. Friis (UC Davis), evan.klose.friis@cern.ch,
0010  *                   Simone Gennai, Ludovic Houchu
0011  *
0012  * =============================================================================
0013  */
0014 
0015 #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h"
0016 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0017 #include "DataFormats/PatCandidates/interface/PackedCandidate.h"
0018 #include "DataFormats/VertexReco/interface/Vertex.h"
0019 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0020 
0021 #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
0022 
0023 #include "TrackingTools/IPTools/interface/IPTools.h"
0024 #include "TrackingTools/Records/interface/TransientTrackRecord.h"
0025 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
0026 
0027 namespace reco {
0028   namespace tau {
0029 
0030     class RecoTauImpactParameterSignificancePlugin : public RecoTauModifierPlugin {
0031     public:
0032       explicit RecoTauImpactParameterSignificancePlugin(const edm::ParameterSet& pset, edm::ConsumesCollector&& iC);
0033       ~RecoTauImpactParameterSignificancePlugin() override {}
0034       void operator()(PFTau& tau) const override;
0035       void beginEvent() override;
0036 
0037     private:
0038       const edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> transTrackBuilderToken_;
0039       RecoTauVertexAssociator vertexAssociator_;
0040       const TransientTrackBuilder* builder_;
0041     };
0042 
0043     RecoTauImpactParameterSignificancePlugin ::RecoTauImpactParameterSignificancePlugin(const edm::ParameterSet& pset,
0044                                                                                         edm::ConsumesCollector&& iC)
0045         : RecoTauModifierPlugin(pset, std::move(iC)),
0046           transTrackBuilderToken_(iC.esConsumes(edm::ESInputTag{"", "TransientTrackBuilder"})),
0047           vertexAssociator_(pset.getParameter<edm::ParameterSet>("qualityCuts"), std::move(iC)) {}
0048 
0049     void RecoTauImpactParameterSignificancePlugin::beginEvent() {
0050       vertexAssociator_.setEvent(*evt());
0051       // Get tranisent track builder.
0052       builder_ = &evtSetup()->getData(transTrackBuilderToken_);
0053     }
0054 
0055     namespace {
0056       inline const reco::Track* getTrack(const Candidate& cand) {
0057         const PFCandidate* pfCandPtr = dynamic_cast<const PFCandidate*>(&cand);
0058         if (pfCandPtr) {
0059           if (pfCandPtr->trackRef().isNonnull())
0060             return pfCandPtr->trackRef().get();
0061           else
0062             return nullptr;
0063         }
0064 
0065         const pat::PackedCandidate* packedCand = dynamic_cast<const pat::PackedCandidate*>(&cand);
0066         if (packedCand && packedCand->hasTrackDetails())
0067           return &packedCand->pseudoTrack();
0068 
0069         return nullptr;
0070       }
0071     }  // namespace
0072 
0073     void RecoTauImpactParameterSignificancePlugin::operator()(PFTau& tau) const {
0074       // Get the transient lead track
0075       if (tau.leadChargedHadrCand().isNonnull()) {
0076         const reco::Track* leadTrack = getTrack(*tau.leadChargedHadrCand());
0077         if (leadTrack != nullptr) {
0078           const TransientTrack track = builder_->build(leadTrack);
0079           GlobalVector direction(tau.jetRef()->px(), tau.jetRef()->py(), tau.jetRef()->pz());
0080           VertexRef pv = vertexAssociator_.associatedVertex(tau);
0081           // Compute the significance
0082           std::pair<bool, Measurement1D> ipsig = IPTools::signedImpactParameter3D(track, direction, *pv);
0083           if (ipsig.first)
0084             tau.setleadPFChargedHadrCandsignedSipt(ipsig.second.significance());
0085         }
0086       }
0087     }
0088 
0089   }  // namespace tau
0090 }  // namespace reco
0091 #include "FWCore/Framework/interface/MakerMacros.h"
0092 DEFINE_EDM_PLUGIN(RecoTauModifierPluginFactory,
0093                   reco::tau::RecoTauImpactParameterSignificancePlugin,
0094                   "RecoTauImpactParameterSignificancePlugin");