Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:51

0001 /*
0002  * =============================================================================
0003  *       Filename:  RecoTauEnergyRecoveryPlugin2.cc
0004  *
0005  *    Description:  Set tau energy to sum of **all** PFCandidates
0006  *                 (regardless of PFCandidate type and whether 
0007  *                  PFCandidate passes or fails quality cuts)
0008  * 
0009  *           NOTE:  use for testing only,
0010  *                  this code has **not** yet been commissioned !!
0011  *
0012  *        Created:  02/02/2013 17:09:00
0013  *
0014  *         Authors:  Christian Veelken (LLR)
0015  *
0016  * =============================================================================
0017  */
0018 
0019 #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h"
0020 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0021 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
0022 #include "DataFormats/JetReco/interface/PFJet.h"
0023 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
0024 #include "DataFormats/TrackReco/interface/Track.h"
0025 #include "DataFormats/VertexReco/interface/Vertex.h"
0026 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0027 #include "RecoTauTag/RecoTau/interface/RecoTauQualityCuts.h"
0028 
0029 #include "DataFormats/Math/interface/deltaR.h"
0030 
0031 #include <algorithm>
0032 
0033 namespace reco {
0034   namespace tau {
0035 
0036     class RecoTauEnergyRecoveryPlugin2 : public RecoTauModifierPlugin {
0037     public:
0038       explicit RecoTauEnergyRecoveryPlugin2(const edm::ParameterSet&, edm::ConsumesCollector&& iC);
0039       ~RecoTauEnergyRecoveryPlugin2() override;
0040       void operator()(PFTau&) const override;
0041       void beginEvent() override;
0042 
0043     private:
0044       double dRcone_;
0045     };
0046 
0047     RecoTauEnergyRecoveryPlugin2::RecoTauEnergyRecoveryPlugin2(const edm::ParameterSet& cfg,
0048                                                                edm::ConsumesCollector&& iC)
0049         : RecoTauModifierPlugin(cfg, std::move(iC)), dRcone_(cfg.getParameter<double>("dRcone")) {}
0050 
0051     RecoTauEnergyRecoveryPlugin2::~RecoTauEnergyRecoveryPlugin2() {}
0052 
0053     void RecoTauEnergyRecoveryPlugin2::beginEvent() {}
0054 
0055     void RecoTauEnergyRecoveryPlugin2::operator()(PFTau& tau) const {
0056       reco::Candidate::LorentzVector tauAltP4(0., 0., 0., 0.);
0057 
0058       std::vector<reco::CandidatePtr> pfJetConstituents = tau.jetRef()->getJetConstituents();
0059       for (std::vector<reco::CandidatePtr>::const_iterator pfJetConstituent = pfJetConstituents.begin();
0060            pfJetConstituent != pfJetConstituents.end();
0061            ++pfJetConstituent) {
0062         double dR = deltaR((*pfJetConstituent)->p4(), tau.p4());
0063         if (dR < dRcone_)
0064           tauAltP4 += (*pfJetConstituent)->p4();
0065       }
0066 
0067       tau.setalternatLorentzVect(tauAltP4);
0068     }
0069 
0070   }  // namespace tau
0071 }  // namespace reco
0072 
0073 #include "FWCore/Framework/interface/MakerMacros.h"
0074 DEFINE_EDM_PLUGIN(RecoTauModifierPluginFactory,
0075                   reco::tau::RecoTauEnergyRecoveryPlugin2,
0076                   "RecoTauEnergyRecoveryPlugin2");