CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
ISRGammaWeightProducer Class Reference
Inheritance diagram for ISRGammaWeightProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
 ISRGammaWeightProducer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
 ~ISRGammaWeightProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

edm::InputTag genTag_
 
std::vector< double > isrBinEdges_
 
std::vector< double > ptWeights_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 ISRGammaWeightProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 38 of file ISRGammaWeightProducer.cc.

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

38  {
39  genTag_ = pset.getUntrackedParameter<edm::InputTag> ("GenTag", edm::InputTag("genParticles"));
40 
41  produces<double>();
42 }
T getUntrackedParameter(std::string const &, T const &) const
ISRGammaWeightProducer::~ISRGammaWeightProducer ( )

Definition at line 45 of file ISRGammaWeightProducer.cc.

45 {}

Member Function Documentation

void ISRGammaWeightProducer::beginJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 48 of file ISRGammaWeightProducer.cc.

48 {}
void ISRGammaWeightProducer::endJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 51 of file ISRGammaWeightProducer.cc.

51 {}
void ISRGammaWeightProducer::produce ( edm::Event iEvent,
const edm::EventSetup  
)
overridevirtual

Implements edm::EDProducer.

Definition at line 54 of file ISRGammaWeightProducer.cc.

References abs, reco::CompositeRefCandidateT< D >::daughterRef(), genParticleCandidates2GenParticles_cfi::genParticles, genTag_, edm::Event::getByLabel(), i, edm::EventBase::isRealData(), j, reco::LeafCandidate::mass(), reco::CompositeRefCandidateT< D >::motherRef(), reco::CompositeRefCandidateT< D >::numberOfDaughters(), reco::CompositeRefCandidateT< D >::numberOfMothers(), reco::LeafCandidate::p4(), reco::LeafCandidate::pdgId(), edm::Event::put(), alignCSCRings::s, reco::LeafCandidate::status(), ntuplemaker::status, lumiQTWidget::t, and histoStyle::weight.

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

54  {
55 
56  if (iEvent.isRealData()) return;
57 
59  iEvent.getByLabel(genTag_, genParticles);
60  unsigned int gensize = genParticles->size();
61 
62  std::auto_ptr<double> weight (new double);
63 
64  // Set a default weight to start with
65  (*weight) = 1.;
66 
67  // Find the boson at the hard scattering level
68  const reco::GenParticle* boson = 0;
69  int parton1Key = -1;
70  int parton2Key = -1;
71  for (unsigned int i = 0; i<gensize; ++i) {
72  const reco::GenParticle& part = (*genParticles)[i];
73  int status = abs(part.status());
74  if (status!=3) continue;
75  if (part.numberOfMothers()!=2) continue;
76  int partId = abs(part.pdgId());
77  if (status==3 && (partId==23||abs(partId)==24)) {
78  boson = &(*genParticles)[i];
79  parton1Key = part.motherRef(0).key();
80  parton2Key = part.motherRef(1).key();
81  break;
82  }
83  }
84 
85  // Consider only photons near the hard-scattering process
86  const reco::GenParticle* photon = 0;
87  if (boson) {
88  for (unsigned int i = 0; i<gensize; ++i) {
89  photon = 0;
90  const reco::GenParticle& part = (*genParticles)[i];
91  int status = abs(part.status());
92  if (status!=1) continue;
93  int partId = abs(part.pdgId());
94  if (partId!=22) continue;
95  if (part.numberOfMothers()!=1) continue;
96  int keyM = part.motherRef(0).key();
97  const reco::GenParticle* mother = &(*genParticles)[keyM];
98  if (mother->status()!=3) continue;
99  int mId = mother->pdgId();
100  if (abs(mId)>6 && mId!=2212) continue;
101  for (unsigned int j=0; j<mother->numberOfDaughters(); ++j){
102  int keyD = mother->daughterRef(j).key();
103  if (keyD==parton1Key || keyD==parton2Key) {
104  photon = &part;
105  break;
106  }
107  }
108  if (photon) break;
109  }
110  }
111 
112  if (boson && photon) {
113  math::XYZTLorentzVector smom = boson->p4() + photon->p4();
114  double s = smom.M2();
115  double sqrts = smom.M();
116 
117  // Go to CM using the boost direction of the boson+photon system
118  ROOT::Math::Boost cmboost(smom.BoostToCM());
119  math::XYZTLorentzVector photonCM(cmboost(photon->p4()));
120  double pcostheta = ( smom.x()*photonCM.x()
121  + smom.y()*photonCM.y()
122  + smom.z()*photonCM.z() ) / smom.P();
123 
124  // Determine kinematic invariants
125  double t = - sqrts * (photonCM.t()-pcostheta);
126  double MV = boson->mass();
127  double u = MV*MV - s - t;
128  (*weight) = 1. - 2*t*u/(s*s+MV*MV*MV*MV);
129  //printf(">>>>>>>>> s %f t %f u %f, MV %f, weight = %f\n", s, t, u, MV, (*weight));
130  }
131 
132  iEvent.put(weight);
133 }
int i
Definition: DBlmapReader.cc:9
daughters::value_type daughterRef(size_type i) const
reference to daughter at given position
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
virtual int pdgId() const GCC11_FINAL
PDG identifier.
#define abs(x)
Definition: mlp_lapack.h:159
bool isRealData() const
Definition: EventBase.h:60
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
virtual int status() const GCC11_FINAL
status word
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
virtual size_t numberOfMothers() const
number of mothers
virtual size_t numberOfDaughters() const
number of daughters
int j
Definition: DBlmapReader.cc:9
daughters::value_type motherRef(size_type i=0) const
reference to mother at given position
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
virtual float mass() const GCC11_FINAL
mass
part
Definition: HCALResponse.h:20
int weight
Definition: histoStyle.py:50
tuple status
Definition: ntuplemaker.py:245

Member Data Documentation

edm::InputTag ISRGammaWeightProducer::genTag_
private

Definition at line 30 of file ISRGammaWeightProducer.cc.

Referenced by ISRGammaWeightProducer(), and produce().

std::vector<double> ISRGammaWeightProducer::isrBinEdges_
private

Definition at line 31 of file ISRGammaWeightProducer.cc.

std::vector<double> ISRGammaWeightProducer::ptWeights_
private

Definition at line 32 of file ISRGammaWeightProducer.cc.