CMS 3D CMS Logo

PFRecoTauMassPlugin.cc
Go to the documentation of this file.
1 /*
2  * =============================================================================
3  * Filename: PFRecoTauMassPlugin.cc
4  *
5  * Description: Set mass of taus reconstructed in 1prong0pi0 decay mode
6  * to charged pion mass
7  *
8  * Created: 27/10/2015 10:30:00
9  *
10  * Authors: Christian Veelken (Tallinn)
11  *
12  * =============================================================================
13  */
14 
16 
19 
20 #include <TMath.h>
21 
22 namespace reco { namespace tau {
23 
25 {
26  public:
27 
29  ~PFRecoTauMassPlugin() override;
30  void operator()(PFTau&) const override;
31  void beginEvent() override;
32  void endEvent() override;
33 
34  private:
35 
37 };
38 
40  : RecoTauModifierPlugin(cfg, std::move(iC))
41 {
42  verbosity_ = ( cfg.exists("verbosity") ) ?
43  cfg.getParameter<int>("verbosity") : 0;
44 }
45 
47 {}
48 
50 {}
51 
53 {
54  if ( verbosity_ ) {
55  std::cout << "<PFRecoTauMassPlugin::operator()>:" << std::endl;
56  std::cout << "tau: Pt = " << tau.pt() << ", eta = " << tau.eta() << ", phi = " << tau.phi() << ", mass = " << tau.mass() << " (decayMode = " << tau.decayMode() << ")" << std::endl;
57  }
58 
60  double tauEn = tau.energy();
61  const double chargedPionMass = 0.13957; // GeV
62  if ( tauEn < chargedPionMass ) tauEn = chargedPionMass;
63  double tauP_modified = TMath::Sqrt(tauEn*tauEn - chargedPionMass*chargedPionMass);
64  double tauPx_modified = TMath::Cos(tau.phi())*TMath::Sin(tau.theta())*tauP_modified;
65  double tauPy_modified = TMath::Sin(tau.phi())*TMath::Sin(tau.theta())*tauP_modified;
66  double tauPz_modified = TMath::Cos(tau.theta())*tauP_modified;
67  reco::Candidate::LorentzVector tauP4_modified(tauPx_modified, tauPy_modified, tauPz_modified, tauEn);
68  if ( verbosity_ ) {
69  std::cout << "--> setting tauP4: Pt = " << tauP4_modified.pt() << ", eta = " << tauP4_modified.eta() << ", phi = " << tauP4_modified.phi() << ", mass = " << tauP4_modified.mass() << std::endl;
70  }
71  tau.setP4(tauP4_modified);
72  }
73 }
74 
76 {}
77 
78 }} // end namespace reco::tau
79 
81 
T getParameter(std::string const &) const
double eta() const final
momentum pseudorapidity
double theta() const final
momentum polar angle
bool exists(std::string const &parameterName) const
checks if a parameter exists
double pt() const final
transverse momentum
void operator()(PFTau &) const override
hadronicDecayMode decayMode() const
Definition: PFTau.cc:212
PFRecoTauMassPlugin(const edm::ParameterSet &, edm::ConsumesCollector &&iC)
double energy() const final
energy
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
fixed size matrix
#define DEFINE_EDM_PLUGIN(factory, type, name)
double phi() const final
momentum azimuthal angle
void setP4(const LorentzVector &p4) final
set 4-momentum
def move(src, dest)
Definition: eostools.py:510
double mass() const final
mass