CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
LHECOMWeightProducer Class Reference
Inheritance diagram for LHECOMWeightProducer:
edm::one::EDProducer< edm::one::WatchRuns > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 LHECOMWeightProducer (const edm::ParameterSet &)
 
 ~LHECOMWeightProducer () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< edm::one::WatchRuns >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob () override
 
void beginRun (edm::Run const &run, const edm::EventSetup &es) override
 
void endRun (edm::Run const &run, const edm::EventSetup &es) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::string _label
 
const double _newECMS
 
double _origECMS
 
int _pdfmember
 
int _pdfset
 
const edm::InputTag lheTag_
 
const edm::EDGetTokenT< LHEEventProducttokenLHEEvent_
 
const edm::EDGetTokenT< LHERunInfoProducttokenLHERun_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 24 of file LHECOMWeightProducer.cc.

Constructor & Destructor Documentation

◆ LHECOMWeightProducer()

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

Definition at line 59 of file LHECOMWeightProducer.cc.

References _label, and _newECMS.

60  : lheTag_(pset.getParameter<edm::InputTag>("lheSrc")),
61  _newECMS(pset.getParameter<double>("NewECMS")),
62  tokenLHERun_(consumes<LHERunInfoProduct, edm::InRun>(lheTag_)),
63  tokenLHEEvent_(consumes<LHEEventProduct>(lheTag_)) {
64  std::stringstream labelStr;
65  labelStr << "com"
66  << "To" << _newECMS;
67  _label = labelStr.str();
68  produces<GenEventInfoProduct>(_label);
69 }
const edm::InputTag lheTag_
const edm::EDGetTokenT< LHEEventProduct > tokenLHEEvent_
const edm::EDGetTokenT< LHERunInfoProduct > tokenLHERun_

◆ ~LHECOMWeightProducer()

LHECOMWeightProducer::~LHECOMWeightProducer ( )
overridedefault

Member Function Documentation

◆ beginJob()

void LHECOMWeightProducer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 87 of file LHECOMWeightProducer.cc.

87  {
88  //LHAPDF::initPDFSet(1,pdfSetName_);
89 }

◆ beginRun()

void LHECOMWeightProducer::beginRun ( edm::Run const &  run,
const edm::EventSetup es 
)
overrideprivate

Definition at line 72 of file LHECOMWeightProducer.cc.

References _newECMS, _origECMS, _pdfmember, _pdfset, lhef::HEPRUP::EBMUP, Exception, LHERunInfoProduct::heprup(), LHAPDF::initPDFSet(), lhef::HEPRUP::PDFGUP, lhef::HEPRUP::PDFSUP, writedatasetfile::run, and tokenLHERun_.

72  {
73  using namespace edm;
74  const edm::Handle<LHERunInfoProduct>& lheRun = run.getHandle(tokenLHERun_);
75  //assumes the same pdf is used for both beams
76  _pdfset = lheRun->heprup().PDFSUP.first;
77  _pdfmember = lheRun->heprup().PDFGUP.first;
78  _origECMS = lheRun->heprup().EBMUP.first + lheRun->heprup().EBMUP.second;
79  edm::LogInfo("LHECOMWeightProducer") << "PDFSET: " << _pdfset << "; member: " << _pdfmember
80  << "; COM energy: " << _origECMS;
81  if (_newECMS > _origECMS)
82  throw cms::Exception("LHECOMWeightProducer") << "You cannot reweight COM energy to a higher than original energy ";
84 }
std::pair< double, double > EBMUP
Definition: LesHouches.h:82
std::pair< int, int > PDFGUP
Definition: LesHouches.h:88
const lhef::HEPRUP & heprup() const
Log< level::Info, false > LogInfo
void initPDFSet(int nset, int setid, int member=0)
const edm::EDGetTokenT< LHERunInfoProduct > tokenLHERun_
std::pair< int, int > PDFSUP
Definition: LesHouches.h:94
HLT enums.

◆ endRun()

void LHECOMWeightProducer::endRun ( edm::Run const &  run,
const edm::EventSetup es 
)
inlineoverrideprivate

Definition at line 32 of file LHECOMWeightProducer.cc.

32 {}

◆ produce()

void LHECOMWeightProducer::produce ( edm::Event iEvent,
const edm::EventSetup  
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 92 of file LHECOMWeightProducer.cc.

References _label, _newECMS, _origECMS, _pdfmember, _pdfset, gather_cfg::cout, LHEEventProduct::hepeup(), globals_cff::id1, globals_cff::id2, lhef::HEPEUP::IDUP, iEvent, info(), LogTrace, eostools::move(), lhef::HEPEUP::PUP, lhef::HEPEUP::SCALUP, tokenLHEEvent_, LHAPDF::usePDFMember(), verbose, hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, and LHAPDF::xfx().

92  {
93  using namespace std;
94  bool verbose = false;
95 
96  if (iEvent.isRealData())
97  return;
98 
99  const edm::Handle<LHEEventProduct>& lheevent = iEvent.getHandle(tokenLHEEvent_);
100 
101  float Q = lheevent->hepeup().SCALUP;
102 
103  int id1 = lheevent->hepeup().IDUP[0];
104  double x1 = fabs(lheevent->hepeup().PUP[0][2] / (_origECMS / 2));
105  double x1prime = fabs(lheevent->hepeup().PUP[0][2] / (_newECMS / 2));
106 
107  int id2 = lheevent->hepeup().IDUP[1];
108  double x2 = fabs(lheevent->hepeup().PUP[1][2] / (_origECMS / 2));
109  double x2prime = fabs(lheevent->hepeup().PUP[1][2] / (_newECMS / 2));
110 
111  LogTrace("LHECOMWeightProducer") << "*******LHECOMWeightProducer*******\n"
112  << " Q : " << Q << "\n"
113  << " id1: " << id1 << "\n"
114  << " x1 : " << x1 << "\n"
115  << " x1': " << x1prime << "\n"
116  << " id2: " << id2 << "\n"
117  << " x2 : " << x2 << "\n"
118  << " x2': " << x2prime;
119  //gluon is 0 in the LHAPDF numbering
120  if (id1 == 21)
121  id1 = 0;
122  if (id2 == 21)
123  id2 = 0;
124 
125  // Put PDF weights in the event
126  if (verbose)
127  cout << " Set : " << _pdfset << " member : " << _pdfmember << endl;
128 
130  double oldpdf1 = LHAPDF::xfx(1, x1, Q, id1) / x1;
131  double oldpdf2 = LHAPDF::xfx(1, x2, Q, id2) / x2;
132  double newpdf1 = LHAPDF::xfx(1, x1prime, Q, id1) / x1prime;
133  double newpdf2 = LHAPDF::xfx(1, x2prime, Q, id2) / x2prime;
134  LogTrace("LHECOMWeightProducer") << " xfx1 : " << oldpdf1 << "\n"
135  << " xfx2 : " << oldpdf2 << "\n"
136  << " xfx1': " << newpdf1 << "\n"
137  << " xfx2': " << newpdf2 << "\n"
138  << " weight:" << (newpdf1 / oldpdf1) * (newpdf2 / oldpdf2);
139  double weight = (newpdf1 / oldpdf1) * (newpdf2 / oldpdf2);
140  std::vector<double> weights;
141  weights.push_back(weight);
142  std::unique_ptr<GenEventInfoProduct> info(new GenEventInfoProduct());
143  info->setWeights(weights);
144  iEvent.put(std::move(info), _label);
145 }
static const TGPicture * info(bool iBackgroundIsBlack)
bool verbose
Definition: weight.py:1
#define LogTrace(id)
int iEvent
Definition: GenABIO.cc:224
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
std::vector< int > IDUP
Definition: LesHouches.h:223
const edm::EDGetTokenT< LHEEventProduct > tokenLHEEvent_
double xfx(int nset, double x, double Q, int fl)
def move(src, dest)
Definition: eostools.py:511
void usePDFMember(int nset, int member)
double SCALUP
Definition: LesHouches.h:208
const lhef::HEPEUP & hepeup() const

Member Data Documentation

◆ _label

std::string LHECOMWeightProducer::_label
private

◆ _newECMS

const double LHECOMWeightProducer::_newECMS
private

Definition at line 36 of file LHECOMWeightProducer.cc.

Referenced by beginRun(), LHECOMWeightProducer(), and produce().

◆ _origECMS

double LHECOMWeightProducer::_origECMS
private

Definition at line 41 of file LHECOMWeightProducer.cc.

Referenced by beginRun(), and produce().

◆ _pdfmember

int LHECOMWeightProducer::_pdfmember
private

Definition at line 40 of file LHECOMWeightProducer.cc.

Referenced by beginRun(), and produce().

◆ _pdfset

int LHECOMWeightProducer::_pdfset
private

Definition at line 39 of file LHECOMWeightProducer.cc.

Referenced by beginRun(), and produce().

◆ lheTag_

const edm::InputTag LHECOMWeightProducer::lheTag_
private

Definition at line 35 of file LHECOMWeightProducer.cc.

◆ tokenLHEEvent_

const edm::EDGetTokenT<LHEEventProduct> LHECOMWeightProducer::tokenLHEEvent_
private

Definition at line 38 of file LHECOMWeightProducer.cc.

Referenced by produce().

◆ tokenLHERun_

const edm::EDGetTokenT<LHERunInfoProduct> LHECOMWeightProducer::tokenLHERun_
private

Definition at line 37 of file LHECOMWeightProducer.cc.

Referenced by beginRun().