Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:21:55

0001 /*
0002  * ===========================================================================
0003  *
0004  *       Filename:  RecoTauTagInfoWorkaroundModifer
0005  *
0006  *    Description:  Add the PFTauTagInfoRef back to PFTaus so things don't
0007  *                  break.
0008  *
0009  *         Author:  Evan K. Friis (UC Davis)
0010  *
0011  * ===========================================================================
0012  */
0013 
0014 #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h"
0015 #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h"
0016 
0017 namespace reco {
0018   namespace tau {
0019 
0020     class RecoTauTagInfoWorkaroundModifer : public RecoTauModifierPlugin {
0021     public:
0022       explicit RecoTauTagInfoWorkaroundModifer(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC);
0023       ~RecoTauTagInfoWorkaroundModifer() override {}
0024       void operator()(PFTau &) const override;
0025       // Called by base class
0026       void beginEvent() override;
0027 
0028     private:
0029       edm::InputTag pfTauTagInfoSrc_;
0030       edm::Handle<PFTauTagInfoCollection> infos_;
0031       edm::EDGetTokenT<PFTauTagInfoCollection> pfTauTagInfo_token;
0032     };
0033 
0034     RecoTauTagInfoWorkaroundModifer::RecoTauTagInfoWorkaroundModifer(const edm::ParameterSet &pset,
0035                                                                      edm::ConsumesCollector &&iC)
0036         : RecoTauModifierPlugin(pset, std::move(iC)) {
0037       pfTauTagInfoSrc_ = pset.getParameter<edm::InputTag>("pfTauTagInfoSrc");
0038       pfTauTagInfo_token = iC.consumes<PFTauTagInfoCollection>(pfTauTagInfoSrc_);
0039     }
0040 
0041     // Load our tau tag infos from the event
0042     void RecoTauTagInfoWorkaroundModifer::beginEvent() { evt()->getByToken(pfTauTagInfo_token, infos_); }
0043 
0044     void RecoTauTagInfoWorkaroundModifer::operator()(PFTau &tau) const {
0045       // Find the PFTauTagInfo that comes from the same PFJet
0046       JetBaseRef tauJetRef = tau.jetRef();
0047       for (size_t iInfo = 0; iInfo < infos_->size(); ++iInfo) {
0048         // Get jet ref from tau tag info
0049         PFTauTagInfoRef infoRef = PFTauTagInfoRef(infos_, iInfo);
0050         JetBaseRef infoJetRef = infoRef->pfjetRef();
0051         // Check if they come from the same jet
0052         if (infoJetRef == tauJetRef) {
0053           // This tau "comes" from this PFJetRef
0054           tau.setpfTauTagInfoRef(infoRef);
0055           break;
0056         }
0057       }
0058     }
0059   }  // namespace tau
0060 }  // namespace reco
0061 #include "FWCore/Framework/interface/MakerMacros.h"
0062 DEFINE_EDM_PLUGIN(RecoTauModifierPluginFactory,
0063                   reco::tau::RecoTauTagInfoWorkaroundModifer,
0064                   "RecoTauTagInfoWorkaroundModifer");