CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
FSRWeightProducer Class Reference
Inheritance diagram for FSRWeightProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 FSRWeightProducer (const edm::ParameterSet &)
 
 ~FSRWeightProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

double alphaRatio (double)
 
void beginJob () override
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::EDGetTokenT< reco::GenParticleCollectiongenToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 20 of file FSRWeightProducer.cc.

Constructor & Destructor Documentation

FSRWeightProducer::FSRWeightProducer ( const edm::ParameterSet pset)
explicit

Definition at line 36 of file FSRWeightProducer.cc.

References genToken_, and edm::ParameterSet::getUntrackedParameter().

36  {
37  genToken_ = consumes<reco::GenParticleCollection>(pset.getUntrackedParameter<edm::InputTag> ("GenTag", edm::InputTag("genParticles")));
38 
39  produces<double>();
40 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::GenParticleCollection > genToken_
FSRWeightProducer::~FSRWeightProducer ( )
override

Definition at line 43 of file FSRWeightProducer.cc.

43 {}

Member Function Documentation

double FSRWeightProducer::alphaRatio ( double  pt)
private

Definition at line 125 of file FSRWeightProducer.cc.

References patCaloMETCorrections_cff::A, TtFullHadDaughter::B, patCaloMETCorrections_cff::C, DEFINE_FWK_MODULE, cmsBatch::log, and M_PI.

Referenced by produce().

125  {
126 
127  double pigaga = 0.;
128 
129  // Leptonic contribution (just one loop, precise at < 0.3% level)
130  const double alphapi = 1/137.036/M_PI;
131  const double mass_e = 0.0005;
132  const double mass_mu = 0.106;
133  const double mass_tau = 1.777;
134  const double mass_Z = 91.2;
135  if (pt>mass_e) pigaga += alphapi * (2*log(pt/mass_e)/3.-5./9.);
136  if (pt>mass_mu) pigaga += alphapi * (2*log(pt/mass_mu)/3.-5./9.);
137  if (pt>mass_tau) pigaga += alphapi * (2*log(pt/mass_tau)/3.-5./9.);
138 
139  // Hadronic vaccum contribution
140  // Using simple effective parametrization from Physics Letters B 513 (2001) 46.
141  // Top contribution neglected
142  double A = 0.;
143  double B = 0.;
144  double C = 0.;
145  if (pt<0.7) {
146  A = 0.0; B = 0.0023092; C = 3.9925370;
147  } else if (pt<2.0) {
148  A = 0.0; B = 0.0022333; C = 4.2191779;
149  } else if (pt<4.0) {
150  A = 0.0; B = 0.0024402; C = 3.2496684;
151  } else if (pt<10.0) {
152  A = 0.0; B = 0.0027340; C = 2.0995092;
153  } else if (pt<mass_Z) {
154  A = 0.0010485; B = 0.0029431; C = 1.0;
155  } else if (pt<10000.) {
156  A = 0.0012234; B = 0.0029237; C = 1.0;
157  } else {
158  A = 0.0016894; B = 0.0028984; C = 1.0;
159  }
160  pigaga += A + B*log(1.+C*pt*pt);
161 
162  // Done
163  return 1./(1.-pigaga);
164 }
static const std::string B
#define M_PI
void FSRWeightProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 46 of file FSRWeightProducer.cc.

46 {}
void FSRWeightProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 49 of file FSRWeightProducer.cc.

49 {}
void FSRWeightProducer::produce ( edm::Event iEvent,
const edm::EventSetup  
)
overrideprivate

Definition at line 52 of file FSRWeightProducer.cc.

References funct::abs(), alphaRatio(), funct::cos(), reco::CompositeRefCandidateT< D >::daughter(), reco::CompositeRefCandidateT< D >::daughterRef(), delta, reco::Candidate::energy(), reco::LeafCandidate::energy(), GenHFHadronMatcher_cfi::genParticles, genToken_, edm::Event::getByToken(), mps_fire::i, edm::EventBase::isRealData(), softMuonTagInfos_cfi::leptonId, reco::Candidate::mass(), reco::LeafCandidate::mass(), reco::CompositeRefCandidateT< D >::mother(), eostools::move(), reco::CompositeRefCandidateT< D >::numberOfDaughters(), reco::CompositeRefCandidateT< D >::numberOfMothers(), reco::Candidate::pdgId(), reco::LeafCandidate::pdgId(), reco::Candidate::phi(), reco::LeafCandidate::phi(), muons2muons_cfi::photon, funct::pow(), edm::Event::put(), funct::sin(), mathSSE::sqrt(), reco::LeafCandidate::status(), reco::Candidate::theta(), reco::LeafCandidate::theta(), and mps_merge::weight.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

52  {
53 
54  if (iEvent.isRealData()) return;
55 
57  iEvent.getByToken(genToken_, genParticles);
58 
59  std::unique_ptr<double> weight (new double);
60 
61  // Set a default weight to start with
62  (*weight) = 1.;
63 
64  unsigned int gensize = genParticles->size();
65  for (unsigned int i = 0; i<gensize; ++i) {
66  const reco::GenParticle& lepton = (*genParticles)[i];
67  if (lepton.status()!=3) continue;
68  int leptonId = lepton.pdgId();
69  if (abs(leptonId)!=11 && abs(leptonId)!=13 && abs(leptonId)!=15) continue;
70  if (lepton.numberOfMothers()!=1) continue;
71  const reco::Candidate * boson = lepton.mother();
72  int bosonId = abs(boson->pdgId());
73  if (bosonId!=23 && bosonId!=24) continue;
74  double bosonMass = boson->mass();
75  double leptonMass = lepton.mass();
76  double leptonEnergy = lepton.energy();
77  double cosLeptonTheta = cos(lepton.theta());
78  double sinLeptonTheta = sin(lepton.theta());
79  double leptonPhi = lepton.phi();
80 
81  int trueKey = i;
82  if (lepton.numberOfDaughters()==0) {
83  continue;
84  } else if (lepton.numberOfDaughters()==1) {
85  int otherleptonKey = lepton.daughterRef(0).key();
86  const reco::GenParticle& otherlepton = (*genParticles)[otherleptonKey];
87  if (otherlepton.pdgId()!=leptonId) continue;
88  if (otherlepton.numberOfDaughters()<=1) continue;
89  trueKey = otherleptonKey;
90  }
91 
92  const reco::GenParticle& trueLepton = (*genParticles)[trueKey];
93  unsigned int nDaughters = trueLepton.numberOfDaughters();
94 
95  for (unsigned int j = 0; j<nDaughters; ++j) {
96  const reco::Candidate * photon = trueLepton.daughter(j);
97  if (photon->pdgId()!=22) continue;
98  double photonEnergy = photon->energy();
99  double cosPhotonTheta = cos(photon->theta());
100  double sinPhotonTheta = sin(photon->theta());
101  double photonPhi = photon->phi();
102  double costheta = sinLeptonTheta*sinPhotonTheta*cos(leptonPhi-photonPhi)
103  + cosLeptonTheta*cosPhotonTheta;
104  // Missing O(alpha) terms in soft-collinear approach
105  // Only for W, from hep-ph/0303260
106  if (bosonId==24) {
107  double betaLepton = sqrt(1-pow(leptonMass/leptonEnergy,2));
108  double delta = - 8*photonEnergy *(1-betaLepton*costheta)
109  / pow(bosonMass,3)
110  / (1-pow(leptonMass/bosonMass,2))
111  / (4-pow(leptonMass/bosonMass,2))
112  * leptonEnergy * (pow(leptonMass,2)/bosonMass+2*photonEnergy);
113  (*weight) *= (1 + delta);
114  }
115  // Missing NLO QED orders in QED parton shower approach
116  // Change coupling scale from 0 to kT to estimate this effect
117  (*weight) *= alphaRatio(photonEnergy*sqrt(1-pow(costheta,2)));
118  }
119  }
120 
121 
122  iEvent.put(std::move(weight));
123 }
dbl * delta
Definition: mlp_gen.cc:36
int pdgId() const final
PDG identifier.
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
daughters::value_type daughterRef(size_type i) const
reference to daughter at given position
double theta() const final
momentum polar angle
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
size_t numberOfMothers() const override
number of mothers
Definition: weight.py:1
double alphaRatio(double)
bool isRealData() const
Definition: EventBase.h:64
virtual double energy() const =0
energy
virtual int pdgId() const =0
PDG identifier.
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double energy() const final
energy
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual double theta() const =0
momentum polar angle
virtual double mass() const =0
mass
size_t numberOfDaughters() const override
number of daughters
int status() const final
status word
double phi() const final
momentum azimuthal angle
edm::EDGetTokenT< reco::GenParticleCollection > genToken_
virtual double phi() const =0
momentum azimuthal angle
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
def move(src, dest)
Definition: eostools.py:510
const Candidate * mother(size_type=0) const override
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
double mass() const final
mass

Member Data Documentation

edm::EDGetTokenT<reco::GenParticleCollection> FSRWeightProducer::genToken_
private

Definition at line 31 of file FSRWeightProducer.cc.

Referenced by FSRWeightProducer(), and produce().