Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*
0002  * =============================================================================
0003  *       Filename:  PFRecoTauMassPlugin.cc
0004  *
0005  *    Description:  Set mass of taus reconstructed in 1prong0pi0 decay mode
0006  *                  to charged pion mass
0007  *
0008  *        Created:  27/10/2015 10:30:00
0009  *
0010  *         Authors:  Christian Veelken (Tallinn)
0011  *
0012  * =============================================================================
0013  */
0014 
0015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0016 
0017 #include "RecoTauTag/RecoTau/interface/RecoTauBuilderPlugins.h"
0018 #include "DataFormats/TauReco/interface/PFTau.h"
0019 
0020 #include <TMath.h>
0021 
0022 namespace reco {
0023   namespace tau {
0024 
0025     class PFRecoTauMassPlugin : public RecoTauModifierPlugin {
0026     public:
0027       explicit PFRecoTauMassPlugin(const edm::ParameterSet&, edm::ConsumesCollector&& iC);
0028       ~PFRecoTauMassPlugin() override;
0029       void operator()(PFTau&) const override;
0030       void beginEvent() override;
0031       void endEvent() override;
0032 
0033     private:
0034       int verbosity_;
0035     };
0036 
0037     PFRecoTauMassPlugin::PFRecoTauMassPlugin(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC)
0038         : RecoTauModifierPlugin(cfg, std::move(iC)) {
0039       verbosity_ = cfg.getParameter<int>("verbosity");
0040     }
0041 
0042     PFRecoTauMassPlugin::~PFRecoTauMassPlugin() {}
0043 
0044     void PFRecoTauMassPlugin::beginEvent() {}
0045 
0046     void PFRecoTauMassPlugin::operator()(PFTau& tau) const {
0047       if (verbosity_) {
0048         std::cout << "<PFRecoTauMassPlugin::operator()>:" << std::endl;
0049         std::cout << "tau: Pt = " << tau.pt() << ", eta = " << tau.eta() << ", phi = " << tau.phi()
0050                   << ", mass = " << tau.mass() << " (decayMode = " << tau.decayMode() << ")" << std::endl;
0051       }
0052 
0053       if (tau.decayMode() == reco::PFTau::kOneProng0PiZero) {
0054         double tauEn = tau.energy();
0055         const double chargedPionMass = 0.13957;  // GeV
0056         if (tauEn < chargedPionMass)
0057           tauEn = chargedPionMass;
0058         double tauP_modified = TMath::Sqrt(tauEn * tauEn - chargedPionMass * chargedPionMass);
0059         double tauPx_modified = TMath::Cos(tau.phi()) * TMath::Sin(tau.theta()) * tauP_modified;
0060         double tauPy_modified = TMath::Sin(tau.phi()) * TMath::Sin(tau.theta()) * tauP_modified;
0061         double tauPz_modified = TMath::Cos(tau.theta()) * tauP_modified;
0062         reco::Candidate::LorentzVector tauP4_modified(tauPx_modified, tauPy_modified, tauPz_modified, tauEn);
0063         if (verbosity_) {
0064           std::cout << "--> setting tauP4: Pt = " << tauP4_modified.pt() << ", eta = " << tauP4_modified.eta()
0065                     << ", phi = " << tauP4_modified.phi() << ", mass = " << tauP4_modified.mass() << std::endl;
0066         }
0067         tau.setP4(tauP4_modified);
0068       }
0069     }
0070 
0071     void PFRecoTauMassPlugin::endEvent() {}
0072 
0073   }  // namespace tau
0074 }  // namespace reco
0075 
0076 #include "FWCore/Framework/interface/MakerMacros.h"
0077 
0078 DEFINE_EDM_PLUGIN(RecoTauModifierPluginFactory, reco::tau::PFRecoTauMassPlugin, "PFRecoTauMassPlugin");