Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*
0002  * Original author: Alexander Nehrkorn (RWTH Aachen)
0003  *
0004  * Description:
0005  * This module rejects tau candidates that do not have unit charge.
0006  * It takes the fact into account that taus do not necessarily need
0007  * to be created from PF charged hadrons only but can be created
0008  * from a combination of PF charged hadrons and tracks.
0009  *
0010  */
0011 
0012 #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h"
0013 #include "DataFormats/TauReco/interface/PFTau.h"
0014 #include "DataFormats/TauReco/interface/PFTauFwd.h"
0015 
0016 namespace reco {
0017   namespace tau {
0018 
0019     class RecoTauChargeCleanerPlugin : public RecoTauCleanerPlugin {
0020     public:
0021       explicit RecoTauChargeCleanerPlugin(const edm::ParameterSet&, edm::ConsumesCollector&& iC);
0022       ~RecoTauChargeCleanerPlugin() override {}
0023       double operator()(const PFTauRef& tau) const override;
0024 
0025     private:
0026       std::vector<unsigned> nprongs_;
0027       double failResult_;
0028       int charge_;
0029     };
0030 
0031     RecoTauChargeCleanerPlugin::RecoTauChargeCleanerPlugin(const edm::ParameterSet& pset, edm::ConsumesCollector&& iC)
0032         : RecoTauCleanerPlugin(pset, std::move(iC)),
0033           nprongs_(pset.getParameter<std::vector<unsigned> >("nprongs")),
0034           failResult_(pset.getParameter<double>("selectionFailValue")),
0035           charge_(pset.getParameter<int>("passForCharge")) {}
0036 
0037     double RecoTauChargeCleanerPlugin::operator()(const PFTauRef& cand) const {
0038       int charge = 0;
0039       unsigned nChargedPFCandidate(0), nTrack(0);
0040       for (auto const& tauCand : cand->signalTauChargedHadronCandidates()) {
0041         charge += tauCand.charge();
0042         if (tauCand.algoIs(reco::PFRecoTauChargedHadron::kChargedPFCandidate))
0043           nChargedPFCandidate++;
0044         else if (tauCand.algoIs(reco::PFRecoTauChargedHadron::kTrack))
0045           nTrack++;
0046       }
0047 
0048       for (auto nprong : nprongs_) {
0049         if (nChargedPFCandidate + nTrack == nprong)
0050           return abs(charge) - charge_;
0051       }
0052 
0053       return failResult_;
0054     }
0055 
0056   }  // namespace tau
0057 }  // namespace reco
0058 
0059 #include "FWCore/Framework/interface/MakerMacros.h"
0060 
0061 DEFINE_EDM_PLUGIN(RecoTauCleanerPluginFactory, reco::tau::RecoTauChargeCleanerPlugin, "RecoTauChargeCleanerPlugin");