CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes
GenWeightsTableProducer Class Reference
Inheritance diagram for GenWeightsTableProducer:
edm::global::EDProducer< edm::StreamCache< CounterMap >, edm::RunCache< DynamicWeightChoice >, edm::RunSummaryCache< CounterMap >, edm::EndRunProducer > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

std::unique_ptr< CounterMap > beginStream (edm::StreamID) const override
 
void fillLHEWeightTables (Counter *counter, const DynamicWeightChoice *weightChoice, double genWeight, const LHEEventProduct &lheProd, const GenEventInfoProduct &genProd, std::unique_ptr< nanoaod::FlatTable > &outScale, std::unique_ptr< nanoaod::FlatTable > &outPdf, std::unique_ptr< nanoaod::FlatTable > &outRwgt, std::unique_ptr< nanoaod::FlatTable > &outNamed, std::unique_ptr< nanoaod::FlatTable > &outPS) const
 
void fillOnlyPSWeightTable (Counter *counter, double genWeight, const GenEventInfoProduct &genProd, std::unique_ptr< nanoaod::FlatTable > &outPS) const
 
 GenWeightsTableProducer (edm::ParameterSet const &params)
 
std::shared_ptr< DynamicWeightChoice > globalBeginRun (edm::Run const &iRun, edm::EventSetup const &) const override
 
std::shared_ptr< CounterMap > globalBeginRunSummary (edm::Run const &, edm::EventSetup const &) const override
 
void globalEndRun (edm::Run const &, edm::EventSetup const &) const override
 
void globalEndRunProduce (edm::Run &iRun, edm::EventSetup const &, CounterMap const *runCounterMap) const override
 
void globalEndRunSummary (edm::Run const &, edm::EventSetup const &, CounterMap *runCounterMap) const override
 
void produce (edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 
void streamBeginLuminosityBlock (edm::StreamID id, edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &eventSetup) const override
 
void streamBeginRun (edm::StreamID id, edm::Run const &, edm::EventSetup const &) const override
 
void streamEndRunSummary (edm::StreamID id, edm::Run const &, edm::EventSetup const &, CounterMap *runCounterMap) const override
 
 ~GenWeightsTableProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer< edm::StreamCache< CounterMap >, edm::RunCache< DynamicWeightChoice >, edm::RunSummaryCache< CounterMap >, edm::EndRunProducer >
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () 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
 
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
 
ESProxyIndex const * esGetTokenIndices (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::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)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Attributes

std::atomic< bool > debug_
 
std::atomic< bool > debugRun_
 
const edm::EDGetTokenT< GenLumiInfoHeadergenLumiInfoHeadTag_
 
const edm::EDGetTokenT< GenEventInfoProductgenTag_
 
std::atomic< bool > hasIssuedWarning_
 
std::unordered_map< std::string, uint32_t > lhaNameToID_
 
const std::vector< edm::InputTaglheLabel_
 
const std::vector< edm::EDGetTokenT< LHERunInfoProduct > > lheRunTag_
 
const std::vector< edm::EDGetTokenT< LHEEventProduct > > lheTag_
 
int lheWeightPrecision_
 
unsigned int maxPdfWeights_
 
std::vector< std::string > namedWeightIDs_
 
std::vector< std::string > namedWeightLabels_
 
std::vector< uint32_t > preferredPDFLHAIDs_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase 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
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 213 of file GenWeightsTableProducer.cc.

Constructor & Destructor Documentation

GenWeightsTableProducer::GenWeightsTableProducer ( edm::ParameterSet const &  params)
inline

Definition at line 218 of file GenWeightsTableProducer.cc.

References Exception, nano_cff::lhaid, Skims_PA_cff::name, CalibrationSummaryClient_cfi::params, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and edm::vector_transform().

219  : genTag_(consumes<GenEventInfoProduct>(params.getParameter<edm::InputTag>("genEvent"))),
220  lheLabel_(params.getParameter<std::vector<edm::InputTag>>("lheInfo")),
222  [this](const edm::InputTag& tag) { return mayConsume<LHEEventProduct>(tag); })),
224  lheLabel_, [this](const edm::InputTag& tag) { return mayConsume<LHERunInfoProduct, edm::InRun>(tag); })),
226  mayConsume<GenLumiInfoHeader, edm::InLumi>(params.getParameter<edm::InputTag>("genLumiInfoHeader"))),
227  namedWeightIDs_(params.getParameter<std::vector<std::string>>("namedWeightIDs")),
228  namedWeightLabels_(params.getParameter<std::vector<std::string>>("namedWeightLabels")),
229  lheWeightPrecision_(params.getParameter<int32_t>("lheWeightPrecision")),
230  maxPdfWeights_(params.getParameter<uint32_t>("maxPdfWeights")),
231  debug_(params.getUntrackedParameter<bool>("debug", false)),
232  debugRun_(debug_.load()),
233  hasIssuedWarning_(false) {
234  produces<nanoaod::FlatTable>();
235  produces<std::string>("genModel");
236  produces<nanoaod::FlatTable>("LHEScale");
237  produces<nanoaod::FlatTable>("LHEPdf");
238  produces<nanoaod::FlatTable>("LHEReweighting");
239  produces<nanoaod::FlatTable>("LHENamed");
240  produces<nanoaod::FlatTable>("PS");
241  produces<nanoaod::MergeableCounterTable, edm::Transition::EndRun>();
242  if (namedWeightIDs_.size() != namedWeightLabels_.size()) {
243  throw cms::Exception("Configuration", "Size mismatch between namedWeightIDs & namedWeightLabels");
244  }
245  for (const edm::ParameterSet& pdfps : params.getParameter<std::vector<edm::ParameterSet>>("preferredPDFs")) {
246  const std::string& name = pdfps.getParameter<std::string>("name");
247  uint32_t lhaid = pdfps.getParameter<uint32_t>("lhaid");
248  preferredPDFLHAIDs_.push_back(lhaid);
250  lhaNameToID_[name + ".LHgrid"] = lhaid;
251  }
252  }
const std::vector< edm::EDGetTokenT< LHERunInfoProduct > > lheRunTag_
const edm::EDGetTokenT< GenEventInfoProduct > genTag_
std::atomic< bool > hasIssuedWarning_
std::unordered_map< std::string, uint32_t > lhaNameToID_
const std::vector< edm::InputTag > lheLabel_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
std::vector< std::string > namedWeightLabels_
const std::vector< edm::EDGetTokenT< LHEEventProduct > > lheTag_
std::vector< uint32_t > preferredPDFLHAIDs_
std::vector< std::string > namedWeightIDs_
const edm::EDGetTokenT< GenLumiInfoHeader > genLumiInfoHeadTag_
GenWeightsTableProducer::~GenWeightsTableProducer ( )
inlineoverride

Definition at line 254 of file GenWeightsTableProducer.cc.

254 {}

Member Function Documentation

std::unique_ptr<CounterMap> GenWeightsTableProducer::beginStream ( edm::StreamID  ) const
inlineoverride

Definition at line 766 of file GenWeightsTableProducer.cc.

766 { return std::make_unique<CounterMap>(); }
static void GenWeightsTableProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 842 of file GenWeightsTableProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptionalUntracked(), edm::ParameterSetDescription::addVPSet(), HLT_2018_cff::InputTag, edm::ParameterDescriptionNode::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

842  {
844  desc.add<edm::InputTag>("genEvent", edm::InputTag("generator"))
845  ->setComment("tag for the GenEventInfoProduct, to get the main weight");
846  desc.add<edm::InputTag>("genLumiInfoHeader", edm::InputTag("generator"))
847  ->setComment("tag for the GenLumiInfoProduct, to get the model string");
848  desc.add<std::vector<edm::InputTag>>("lheInfo", std::vector<edm::InputTag>{{"externalLHEProducer"}, {"source"}})
849  ->setComment("tag(s) for the LHE information (LHEEventProduct and LHERunInfoProduct)");
850 
852  prefpdf.add<std::string>("name");
853  prefpdf.add<uint32_t>("lhaid");
854  desc.addVPSet("preferredPDFs", prefpdf, std::vector<edm::ParameterSet>())
855  ->setComment(
856  "LHA PDF Ids of the preferred PDF sets, in order of preference (the first matching one will be used)");
857  desc.add<std::vector<std::string>>("namedWeightIDs")->setComment("set of LHA weight IDs for named LHE weights");
858  desc.add<std::vector<std::string>>("namedWeightLabels")
859  ->setComment("output names for the namedWeightIDs (in the same order)");
860  desc.add<int32_t>("lheWeightPrecision")->setComment("Number of bits in the mantissa for LHE weights");
861  desc.add<uint32_t>("maxPdfWeights")->setComment("Maximum number of PDF weights to save (to crop NN replicas)");
862  desc.addOptionalUntracked<bool>("debug")->setComment("dump out all LHE information for one event");
863  descriptions.add("genWeightsTable", desc);
864  }
void setComment(std::string const &value)
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
void GenWeightsTableProducer::fillLHEWeightTables ( Counter *  counter,
const DynamicWeightChoice *  weightChoice,
double  genWeight,
const LHEEventProduct lheProd,
const GenEventInfoProduct genProd,
std::unique_ptr< nanoaod::FlatTable > &  outScale,
std::unique_ptr< nanoaod::FlatTable > &  outPdf,
std::unique_ptr< nanoaod::FlatTable > &  outRwgt,
std::unique_ptr< nanoaod::FlatTable > &  outNamed,
std::unique_ptr< nanoaod::FlatTable > &  outPS 
) const
inline

Definition at line 312 of file GenWeightsTableProducer.cc.

References spr::find(), nanoaod::FlatTable::FloatColumn, mps_fire::i, dqmiodumpmetadata::n, LHEEventProduct::originalXWGTUP(), GenEventInfoProduct::weights(), and LHEEventProduct::weights().

321  {
322  bool lheDebug = debug_.exchange(
323  false); // make sure only the first thread dumps out this (even if may still be mixed up with other output, but nevermind)
324 
325  const std::vector<std::string>& scaleWeightIDs = weightChoice->scaleWeightIDs;
326  const std::vector<std::string>& pdfWeightIDs = weightChoice->pdfWeightIDs;
327  const std::vector<std::string>& rwgtWeightIDs = weightChoice->rwgtIDs;
328 
329  double w0 = lheProd.originalXWGTUP();
330 
331  std::vector<double> wScale(scaleWeightIDs.size(), 1), wPDF(pdfWeightIDs.size(), 1), wRwgt(rwgtWeightIDs.size(), 1),
332  wNamed(namedWeightIDs_.size(), 1);
333  for (auto& weight : lheProd.weights()) {
334  if (lheDebug)
335  printf("Weight %+9.5f rel %+9.5f for id %s\n", weight.wgt, weight.wgt / w0, weight.id.c_str());
336  // now we do it slowly, can be optimized
337  auto mScale = std::find(scaleWeightIDs.begin(), scaleWeightIDs.end(), weight.id);
338  if (mScale != scaleWeightIDs.end())
339  wScale[mScale - scaleWeightIDs.begin()] = weight.wgt / w0;
340 
341  auto mPDF = std::find(pdfWeightIDs.begin(), pdfWeightIDs.end(), weight.id);
342  if (mPDF != pdfWeightIDs.end())
343  wPDF[mPDF - pdfWeightIDs.begin()] = weight.wgt / w0;
344 
345  auto mRwgt = std::find(rwgtWeightIDs.begin(), rwgtWeightIDs.end(), weight.id);
346  if (mRwgt != rwgtWeightIDs.end())
347  wRwgt[mRwgt - rwgtWeightIDs.begin()] = weight.wgt / w0;
348 
349  auto mNamed = std::find(namedWeightIDs_.begin(), namedWeightIDs_.end(), weight.id);
350  if (mNamed != namedWeightIDs_.end())
351  wNamed[mNamed - namedWeightIDs_.begin()] = weight.wgt / w0;
352  }
353 
354  int vectorSize = (genProd.weights().size() == 14 || genProd.weights().size() == 46) ? 4 : 1;
355  std::vector<double> wPS(vectorSize, 1);
356  if (vectorSize > 1) {
357  for (unsigned int i = 6; i < 10; i++) {
358  wPS[i - 6] = (genProd.weights()[i]) / w0;
359  }
360  }
361  outPS.reset(new nanoaod::FlatTable(wPS.size(), "PSWeight", false));
362  outPS->addColumn<float>("",
363  wPS,
364  vectorSize > 1 ? "PS weights (w_var / w_nominal); [0] is ISR=0.5 FSR=1; [1] is ISR=1 "
365  "FSR=0.5; [2] is ISR=2 FSR=1; [3] is ISR=1 FSR=2 "
366  : "dummy PS weight (1.0) ",
369 
370  outScale.reset(new nanoaod::FlatTable(wScale.size(), "LHEScaleWeight", false));
371  outScale->addColumn<float>(
372  "", wScale, weightChoice->scaleWeightsDoc, nanoaod::FlatTable::FloatColumn, lheWeightPrecision_);
373 
374  outPdf.reset(new nanoaod::FlatTable(wPDF.size(), "LHEPdfWeight", false));
375  outPdf->addColumn<float>(
376  "", wPDF, weightChoice->pdfWeightsDoc, nanoaod::FlatTable::FloatColumn, lheWeightPrecision_);
377 
378  outRwgt.reset(new nanoaod::FlatTable(wRwgt.size(), "LHEReweightingWeight", false));
379  outRwgt->addColumn<float>(
380  "", wRwgt, weightChoice->rwgtWeightDoc, nanoaod::FlatTable::FloatColumn, lheWeightPrecision_);
381 
382  outNamed.reset(new nanoaod::FlatTable(1, "LHEWeight", true));
383  outNamed->addColumnValue<float>("originalXWGTUP",
384  lheProd.originalXWGTUP(),
385  "Nominal event weight in the LHE file",
387  for (unsigned int i = 0, n = wNamed.size(); i < n; ++i) {
388  outNamed->addColumnValue<float>(namedWeightLabels_[i],
389  wNamed[i],
390  "LHE weight for id " + namedWeightIDs_[i] + ", relative to nominal",
393  }
394 
395  counter->incLHE(genWeight, wScale, wPDF, wRwgt, wNamed, wPS);
396  }
double originalXWGTUP() const
Definition: weight.py:1
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const std::vector< WGT > & weights() const
std::vector< std::string > namedWeightLabels_
std::vector< double > & weights()
std::vector< std::string > namedWeightIDs_
void GenWeightsTableProducer::fillOnlyPSWeightTable ( Counter *  counter,
double  genWeight,
const GenEventInfoProduct genProd,
std::unique_ptr< nanoaod::FlatTable > &  outPS 
) const
inline

Definition at line 398 of file GenWeightsTableProducer.cc.

References nanoaod::FlatTable::FloatColumn, mps_fire::i, and GenEventInfoProduct::weights().

401  {
402  int vectorSize = (genProd.weights().size() == 14 || genProd.weights().size() == 46) ? 4 : 1;
403 
404  std::vector<double> wPS(vectorSize, 1);
405  if (vectorSize > 1) {
406  for (unsigned int i = 6; i < 10; i++) {
407  wPS[i - 6] = (genProd.weights()[i]) / genWeight;
408  }
409  }
410 
411  outPS.reset(new nanoaod::FlatTable(wPS.size(), "PSWeight", false));
412  outPS->addColumn<float>("",
413  wPS,
414  vectorSize > 1 ? "PS weights (w_var / w_nominal); [0] is ISR=0.5 FSR=1; [1] is ISR=1 "
415  "FSR=0.5; [2] is ISR=2 FSR=1; [3] is ISR=1 FSR=2 "
416  : "dummy PS weight (1.0) ",
419 
420  counter->incGenOnly(genWeight);
421  counter->incPSOnly(genWeight, wPS);
422  }
std::vector< double > & weights()
std::shared_ptr<DynamicWeightChoice> GenWeightsTableProducer::globalBeginRun ( edm::Run const &  iRun,
edm::EventSetup const &   
) const
inlineoverride

Definition at line 425 of file GenWeightsTableProducer.cc.

References filterCSVwithJSON::copy, gather_cfg::cout, end, spr::find(), dqmdumpme::first, newFWLiteAna::found, edm::Run::getByLabel(), LHERunInfoProduct::headers_begin(), LHERunInfoProduct::headers_end(), triggerObjects_cff::id, edm::HandleBase::isValid(), nano_cff::lhaid, nano_cff::lheInfo, groupFilesInBlocks::lines, submitDQMOfflineCAF::nLines, and AlCaHLTBitMon_QueryRunRegistry::string.

425  {
427 
428  bool lheDebug = debugRun_.exchange(
429  false); // make sure only the first thread dumps out this (even if may still be mixed up with other output, but nevermind)
430  auto weightChoice = std::make_shared<DynamicWeightChoice>();
431 
432  // getByToken throws since we're not in the endRun (see https://github.com/cms-sw/cmssw/pull/18499)
433  //if (iRun.getByToken(lheRunTag_, lheInfo)) {
434  for (const auto& lheLabel : lheLabel_) {
435  iRun.getByLabel(lheLabel, lheInfo);
436  if (lheInfo.isValid()) {
437  break;
438  }
439  }
440  if (lheInfo.isValid()) {
441  std::vector<ScaleVarWeight> scaleVariationIDs;
442  std::vector<PDFSetWeights> pdfSetWeightIDs;
443  std::vector<std::string> lheReweighingIDs;
444 
445  std::regex weightgroupmg26x("<weightgroup\\s+(?:name|type)=\"(.*)\"\\s+combine=\"(.*)\"\\s*>");
446  std::regex weightgroup("<weightgroup\\s+combine=\"(.*)\"\\s+(?:name|type)=\"(.*)\"\\s*>");
447  std::regex weightgroupRwgt("<weightgroup\\s+(?:name|type)=\"(.*)\"\\s*>");
448  std::regex endweightgroup("</weightgroup>");
449  std::regex scalewmg26x(
450  "<weight\\s+(?:.*\\s+)?id=\"(\\d+)\"\\s*(?:lhapdf=\\d+|dyn=\\s*-?\\d+)?\\s*((?:[mM][uU][rR]|renscfact)=\"("
451  "\\S+)\"\\s+(?:[mM][uU][Ff]|facscfact)=\"(\\S+)\")(\\s+.*)?</weight>");
452  std::regex scalew(
453  "<weight\\s+(?:.*\\s+)?id=\"(\\d+)\">\\s*(?:lhapdf=\\d+|dyn=\\s*-?\\d+)?\\s*((?:mu[rR]|renscfact)=(\\S+)\\s+("
454  "?:mu[Ff]|facscfact)=(\\S+)(\\s+.*)?)</weight>");
455  std::regex pdfw(
456  "<weight\\s+id=\"(\\d+)\">\\s*(?:PDF set|lhapdf|PDF|pdfset)\\s*=\\s*(\\d+)\\s*(?:\\s.*)?</weight>");
457  std::regex pdfwOld("<weight\\s+(?:.*\\s+)?id=\"(\\d+)\">\\s*Member \\s*(\\d+)\\s*(?:.*)</weight>");
458  std::regex pdfwmg26x(
459  "<weight\\s+id=\"(\\d+)\"\\s*MUR=\"(?:\\S+)\"\\s*MUF=\"(?:\\S+)\"\\s*(?:PDF "
460  "set|lhapdf|PDF|pdfset)\\s*=\\s*\"(\\d+)\"\\s*>\\s*(?:PDF=(\\d+)\\s*MemberID=(\\d+))?\\s*(?:\\s.*)?</"
461  "weight>");
462  std::regex rwgt("<weight\\s+id=\"(.+)\">(.+)?(</weight>)?");
463  std::smatch groups;
464  for (auto iter = lheInfo->headers_begin(), end = lheInfo->headers_end(); iter != end; ++iter) {
465  if (iter->tag() != "initrwgt") {
466  if (lheDebug)
467  std::cout << "Skipping LHE header with tag" << iter->tag() << std::endl;
468  continue;
469  }
470  if (lheDebug)
471  std::cout << "Found LHE header with tag" << iter->tag() << std::endl;
472  std::vector<std::string> lines = iter->lines();
473  bool missed_weightgroup =
474  false; //Needed because in some of the samples ( produced with MG26X ) a small part of the header info is ordered incorrectly
475  bool ismg26x = false;
476  for (unsigned int iLine = 0, nLines = lines.size(); iLine < nLines;
477  ++iLine) { //First start looping through the lines to see which weightgroup pattern is matched
478  boost::replace_all(lines[iLine], "&lt;", "<");
479  boost::replace_all(lines[iLine], "&gt;", ">");
480  if (std::regex_search(lines[iLine], groups, weightgroupmg26x)) {
481  ismg26x = true;
482  }
483  }
484  for (unsigned int iLine = 0, nLines = lines.size(); iLine < nLines; ++iLine) {
485  if (lheDebug)
486  std::cout << lines[iLine];
487  if (std::regex_search(lines[iLine], groups, ismg26x ? weightgroupmg26x : weightgroup)) {
488  std::string groupname = groups.str(2);
489  if (ismg26x)
490  groupname = groups.str(1);
491  if (lheDebug)
492  std::cout << ">>> Looks like the beginning of a weight group for '" << groupname << "'" << std::endl;
493  if (groupname.find("scale_variation") == 0 || groupname == "Central scale variation") {
494  if (lheDebug)
495  std::cout << ">>> Looks like scale variation for theory uncertainties" << std::endl;
496  for (++iLine; iLine < nLines; ++iLine) {
497  if (lheDebug)
498  std::cout << " " << lines[iLine];
499  if (std::regex_search(lines[iLine], groups, ismg26x ? scalewmg26x : scalew)) {
500  if (lheDebug)
501  std::cout << " >>> Scale weight " << groups[1].str() << " for " << groups[3].str() << " , "
502  << groups[4].str() << " , " << groups[5].str() << std::endl;
503  scaleVariationIDs.emplace_back(groups.str(1), groups.str(2), groups.str(3), groups.str(4));
504  } else if (std::regex_search(lines[iLine], endweightgroup)) {
505  if (lheDebug)
506  std::cout << ">>> Looks like the end of a weight group" << std::endl;
507  if (!missed_weightgroup) {
508  break;
509  } else
510  missed_weightgroup = false;
511  } else if (std::regex_search(lines[iLine], ismg26x ? weightgroupmg26x : weightgroup)) {
512  if (lheDebug)
513  std::cout << ">>> Looks like the beginning of a new weight group, I will assume I missed the end "
514  "of the group."
515  << std::endl;
516  if (ismg26x)
517  missed_weightgroup = true;
518  --iLine; // rewind by one, and go back to the outer loop
519  break;
520  }
521  }
522  } else if (groupname == "PDF_variation" || groupname.find("PDF_variation ") == 0) {
523  if (lheDebug)
524  std::cout << ">>> Looks like a new-style block of PDF weights for one or more pdfs" << std::endl;
525  for (++iLine; iLine < nLines; ++iLine) {
526  if (lheDebug)
527  std::cout << " " << lines[iLine];
528  if (std::regex_search(lines[iLine], groups, pdfw)) {
529  unsigned int lhaID = std::stoi(groups.str(2));
530  if (lheDebug)
531  std::cout << " >>> PDF weight " << groups.str(1) << " for " << groups.str(2) << " = " << lhaID
532  << std::endl;
533  if (pdfSetWeightIDs.empty() || !pdfSetWeightIDs.back().maybe_add(groups.str(1), lhaID)) {
534  pdfSetWeightIDs.emplace_back(groups.str(1), lhaID);
535  }
536  } else if (std::regex_search(lines[iLine], endweightgroup)) {
537  if (lheDebug)
538  std::cout << ">>> Looks like the end of a weight group" << std::endl;
539  if (!missed_weightgroup) {
540  break;
541  } else
542  missed_weightgroup = false;
543  } else if (std::regex_search(lines[iLine], ismg26x ? weightgroupmg26x : weightgroup)) {
544  if (lheDebug)
545  std::cout << ">>> Looks like the beginning of a new weight group, I will assume I missed the end "
546  "of the group."
547  << std::endl;
548  if (ismg26x)
549  missed_weightgroup = true;
550  --iLine; // rewind by one, and go back to the outer loop
551  break;
552  }
553  }
554  } else if (groupname == "PDF_variation1" || groupname == "PDF_variation2") {
555  if (lheDebug)
556  std::cout << ">>> Looks like a new-style block of PDF weights for multiple pdfs" << std::endl;
557  unsigned int lastid = 0;
558  for (++iLine; iLine < nLines; ++iLine) {
559  if (lheDebug)
560  std::cout << " " << lines[iLine];
561  if (std::regex_search(lines[iLine], groups, pdfw)) {
562  unsigned int id = std::stoi(groups.str(1));
563  unsigned int lhaID = std::stoi(groups.str(2));
564  if (lheDebug)
565  std::cout << " >>> PDF weight " << groups.str(1) << " for " << groups.str(2) << " = " << lhaID
566  << std::endl;
567  if (id != (lastid + 1) || pdfSetWeightIDs.empty()) {
568  pdfSetWeightIDs.emplace_back(groups.str(1), lhaID);
569  } else {
570  pdfSetWeightIDs.back().add(groups.str(1), lhaID);
571  }
572  lastid = id;
573  } else if (std::regex_search(lines[iLine], endweightgroup)) {
574  if (lheDebug)
575  std::cout << ">>> Looks like the end of a weight group" << std::endl;
576  if (!missed_weightgroup) {
577  break;
578  } else
579  missed_weightgroup = false;
580  } else if (std::regex_search(lines[iLine], ismg26x ? weightgroupmg26x : weightgroup)) {
581  if (lheDebug)
582  std::cout << ">>> Looks like the beginning of a new weight group, I will assume I missed the end "
583  "of the group."
584  << std::endl;
585  if (ismg26x)
586  missed_weightgroup = true;
587  --iLine; // rewind by one, and go back to the outer loop
588  break;
589  }
590  }
591  } else if (lhaNameToID_.find(groupname) != lhaNameToID_.end()) {
592  if (lheDebug)
593  std::cout << ">>> Looks like an old-style PDF weight for an individual pdf" << std::endl;
594  unsigned int firstLhaID = lhaNameToID_.find(groupname)->second;
595  bool first = true;
596  for (++iLine; iLine < nLines; ++iLine) {
597  if (lheDebug)
598  std::cout << " " << lines[iLine];
599  if (std::regex_search(lines[iLine], groups, ismg26x ? pdfwmg26x : pdfwOld)) {
600  unsigned int member = 0;
601  if (ismg26x == 0) {
602  member = std::stoi(groups.str(2));
603  } else {
604  if (!groups.str(4).empty()) {
605  member = std::stoi(groups.str(4));
606  }
607  }
608  unsigned int lhaID = member + firstLhaID;
609  if (lheDebug)
610  std::cout << " >>> PDF weight " << groups.str(1) << " for " << member << " = " << lhaID
611  << std::endl;
612  //if (member == 0) continue; // let's keep also the central value for now
613  if (first) {
614  pdfSetWeightIDs.emplace_back(groups.str(1), lhaID);
615  first = false;
616  } else {
617  pdfSetWeightIDs.back().add(groups.str(1), lhaID);
618  }
619  } else if (std::regex_search(lines[iLine], endweightgroup)) {
620  if (lheDebug)
621  std::cout << ">>> Looks like the end of a weight group" << std::endl;
622  if (!missed_weightgroup) {
623  break;
624  } else
625  missed_weightgroup = false;
626  } else if (std::regex_search(lines[iLine], ismg26x ? weightgroupmg26x : weightgroup)) {
627  if (lheDebug)
628  std::cout << ">>> Looks like the beginning of a new weight group, I will assume I missed the end "
629  "of the group."
630  << std::endl;
631  if (ismg26x)
632  missed_weightgroup = true;
633  --iLine; // rewind by one, and go back to the outer loop
634  break;
635  }
636  }
637  } else {
638  for (++iLine; iLine < nLines; ++iLine) {
639  if (lheDebug)
640  std::cout << " " << lines[iLine];
641  if (std::regex_search(lines[iLine], groups, endweightgroup)) {
642  if (lheDebug)
643  std::cout << ">>> Looks like the end of a weight group" << std::endl;
644  if (!missed_weightgroup) {
645  break;
646  } else
647  missed_weightgroup = false;
648  } else if (std::regex_search(lines[iLine], ismg26x ? weightgroupmg26x : weightgroup)) {
649  if (lheDebug)
650  std::cout << ">>> Looks like the beginning of a new weight group, I will assume I missed the end "
651  "of the group."
652  << std::endl;
653  if (ismg26x)
654  missed_weightgroup = true;
655  --iLine; // rewind by one, and go back to the outer loop
656  break;
657  }
658  }
659  }
660  } else if (std::regex_search(lines[iLine], groups, weightgroupRwgt)) {
661  std::string groupname = groups.str(1);
662  if (groupname == "mg_reweighting") {
663  if (lheDebug)
664  std::cout << ">>> Looks like a LHE weights for reweighting" << std::endl;
665  for (++iLine; iLine < nLines; ++iLine) {
666  if (lheDebug)
667  std::cout << " " << lines[iLine];
668  if (std::regex_search(lines[iLine], groups, rwgt)) {
669  std::string rwgtID = groups.str(1);
670  if (lheDebug)
671  std::cout << " >>> LHE reweighting weight: " << rwgtID << std::endl;
672  if (std::find(lheReweighingIDs.begin(), lheReweighingIDs.end(), rwgtID) == lheReweighingIDs.end()) {
673  // we're only interested in the beggining of the block
674  lheReweighingIDs.emplace_back(rwgtID);
675  }
676  } else if (std::regex_search(lines[iLine], endweightgroup)) {
677  if (lheDebug)
678  std::cout << ">>> Looks like the end of a weight group" << std::endl;
679  if (!missed_weightgroup) {
680  break;
681  } else
682  missed_weightgroup = false;
683  } else if (std::regex_search(lines[iLine], ismg26x ? weightgroupmg26x : weightgroup)) {
684  if (lheDebug)
685  std::cout << ">>> Looks like the beginning of a new weight group, I will assume I missed the end "
686  "of the group."
687  << std::endl;
688  if (ismg26x)
689  missed_weightgroup = true;
690  --iLine; // rewind by one, and go back to the outer loop
691  break;
692  }
693  }
694  }
695  }
696  }
697  //std::cout << "============= END [ " << iter->tag() << " ] ============ \n\n" << std::endl;
698 
699  // ----- SCALE VARIATIONS -----
700  std::sort(scaleVariationIDs.begin(), scaleVariationIDs.end());
701  if (lheDebug)
702  std::cout << "Found " << scaleVariationIDs.size() << " scale variations: " << std::endl;
703  std::stringstream scaleDoc;
704  scaleDoc << "LHE scale variation weights (w_var / w_nominal); ";
705  for (unsigned int isw = 0, nsw = scaleVariationIDs.size(); isw < nsw; ++isw) {
706  const auto& sw = scaleVariationIDs[isw];
707  if (isw)
708  scaleDoc << "; ";
709  scaleDoc << "[" << isw << "] is " << sw.label;
710  weightChoice->scaleWeightIDs.push_back(sw.wid);
711  if (lheDebug)
712  printf(" id %s: scales ren = % .2f fact = % .2f text = %s\n",
713  sw.wid.c_str(),
714  sw.scales.first,
715  sw.scales.second,
716  sw.label.c_str());
717  }
718  if (!scaleVariationIDs.empty())
719  weightChoice->scaleWeightsDoc = scaleDoc.str();
720 
721  // ------ PDF VARIATIONS (take the preferred one) -----
722  if (lheDebug) {
723  std::cout << "Found " << pdfSetWeightIDs.size() << " PDF set errors: " << std::endl;
724  for (const auto& pw : pdfSetWeightIDs)
725  printf("lhaIDs %6d - %6d (%3lu weights: %s, ... )\n",
726  pw.lhaIDs.first,
727  pw.lhaIDs.second,
728  pw.wids.size(),
729  pw.wids.front().c_str());
730  }
731 
732  // ------ LHE REWEIGHTING -------
733  if (lheDebug) {
734  std::cout << "Found " << lheReweighingIDs.size() << " reweighting weights" << std::endl;
735  }
736  std::copy(lheReweighingIDs.begin(), lheReweighingIDs.end(), std::back_inserter(weightChoice->rwgtIDs));
737 
738  std::stringstream pdfDoc;
739  pdfDoc << "LHE pdf variation weights (w_var / w_nominal) for LHA IDs ";
740  bool found = false;
741  for (uint32_t lhaid : preferredPDFLHAIDs_) {
742  for (const auto& pw : pdfSetWeightIDs) {
743  if (pw.lhaIDs.first != lhaid && pw.lhaIDs.first != (lhaid + 1))
744  continue; // sometimes the first weight is not saved if that PDF is the nominal one for the sample
745  if (pw.wids.size() == 1)
746  continue; // only consider error sets
747  pdfDoc << pw.lhaIDs.first << " - " << pw.lhaIDs.second;
748  weightChoice->pdfWeightIDs = pw.wids;
749  if (maxPdfWeights_ < pw.wids.size()) {
750  weightChoice->pdfWeightIDs.resize(maxPdfWeights_); // drop some replicas
751  pdfDoc << ", truncated to the first " << maxPdfWeights_ << " replicas";
752  }
753  weightChoice->pdfWeightsDoc = pdfDoc.str();
754  found = true;
755  break;
756  }
757  if (found)
758  break;
759  }
760  }
761  }
762  return weightChoice;
763  }
headers_const_iterator headers_end() const
std::unordered_map< std::string, uint32_t > lhaNameToID_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const std::vector< edm::InputTag > lheLabel_
headers_const_iterator headers_begin() const
#define end
Definition: vmac.h:39
bool isValid() const
Definition: HandleBase.h:70
std::vector< uint32_t > preferredPDFLHAIDs_
std::shared_ptr<CounterMap> GenWeightsTableProducer::globalBeginRunSummary ( edm::Run const &  ,
edm::EventSetup const &   
) const
inlineoverride

Definition at line 783 of file GenWeightsTableProducer.cc.

783  {
784  return std::make_shared<CounterMap>();
785  }
void GenWeightsTableProducer::globalEndRun ( edm::Run const &  ,
edm::EventSetup const &   
) const
inlineoverride

Definition at line 840 of file GenWeightsTableProducer.cc.

840 {}
void GenWeightsTableProducer::globalEndRunProduce ( edm::Run iRun,
edm::EventSetup const &  ,
CounterMap const *  runCounterMap 
) const
inlineoverride

Definition at line 796 of file GenWeightsTableProducer.cc.

References mps_fire::i, eostools::move(), dqmiodumpmetadata::n, MillePedeFileConverter_cfg::out, edm::Run::put(), AlCaHLTBitMon_QueryRunRegistry::string, heppy_batch::val, and x.

796  {
797  auto out = std::make_unique<nanoaod::MergeableCounterTable>();
798 
799  for (auto x : runCounterMap->countermap) {
800  auto runCounter = &(x.second);
801  std::string label = std::string("_") + x.first;
802  std::string doclabel = (!x.first.empty()) ? (std::string(", for model label ") + x.first) : "";
803 
804  out->addInt("genEventCount" + label, "event count" + doclabel, runCounter->num);
805  out->addFloat("genEventSumw" + label, "sum of gen weights" + doclabel, runCounter->sumw);
806  out->addFloat("genEventSumw2" + label, "sum of gen (weight^2)" + doclabel, runCounter->sumw2);
807 
808  double norm = runCounter->sumw ? 1.0 / runCounter->sumw : 1;
809  auto sumScales = runCounter->sumScale;
810  for (auto& val : sumScales)
811  val *= norm;
812  out->addVFloat("LHEScaleSumw" + label,
813  "Sum of genEventWeight * LHEScaleWeight[i], divided by genEventSumw" + doclabel,
814  sumScales);
815  auto sumPDFs = runCounter->sumPDF;
816  for (auto& val : sumPDFs)
817  val *= norm;
818  out->addVFloat(
819  "LHEPdfSumw" + label, "Sum of genEventWeight * LHEPdfWeight[i], divided by genEventSumw" + doclabel, sumPDFs);
820  if (!runCounter->sumRwgt.empty()) {
821  auto sumRwgts = runCounter->sumRwgt;
822  for (auto& val : sumRwgts)
823  val *= norm;
824  out->addVFloat("LHEReweightingSumw" + label,
825  "Sum of genEventWeight * LHEReweightingWeight[i], divided by genEventSumw" + doclabel,
826  sumRwgts);
827  }
828  if (!runCounter->sumNamed.empty()) { // it could be empty if there's no LHE info in the sample
829  for (unsigned int i = 0, n = namedWeightLabels_.size(); i < n; ++i) {
830  out->addFloat(
831  "LHESumw_" + namedWeightLabels_[i] + label,
832  "Sum of genEventWeight * LHEWeight_" + namedWeightLabels_[i] + ", divided by genEventSumw" + doclabel,
833  runCounter->sumNamed[i] * norm);
834  }
835  }
836  }
837  iRun.put(std::move(out));
838  }
char const * label
std::vector< std::string > namedWeightLabels_
void put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Run.h:108
def move(src, dest)
Definition: eostools.py:511
void GenWeightsTableProducer::globalEndRunSummary ( edm::Run const &  ,
edm::EventSetup const &  ,
CounterMap *  runCounterMap 
) const
inlineoverride

Definition at line 794 of file GenWeightsTableProducer.cc.

794 {}
void GenWeightsTableProducer::produce ( edm::StreamID  id,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
inlineoverride

Definition at line 256 of file GenWeightsTableProducer.cc.

References nanoaod::FlatTable::FloatColumn, edm::Event::getByToken(), edm::Event::getRun(), edm::Run::index(), edm::HandleBase::isValid(), nano_cff::lheInfo, eostools::move(), MillePedeFileConverter_cfg::out, edm::Event::put(), AlCaHLTBitMon_QueryRunRegistry::string, GenEventInfoProduct::weight(), and mps_merge::weight.

256  {
257  // get my counter for weights
258  Counter* counter = streamCache(id)->get();
259 
260  // generator information (always available)
262  iEvent.getByToken(genTag_, genInfo);
263  double weight = genInfo->weight();
264 
265  // table for gen info, always available
266  auto out = std::make_unique<nanoaod::FlatTable>(1, "genWeight", true);
267  out->setDoc("generator weight");
268  out->addColumnValue<float>("", weight, "generator weight", nanoaod::FlatTable::FloatColumn);
269  iEvent.put(std::move(out));
270 
271  std::string model_label = streamCache(id)->getLabel();
272  auto outM = std::make_unique<std::string>((!model_label.empty()) ? std::string("GenModel_") + model_label : "");
273  iEvent.put(std::move(outM), "genModel");
274 
275  // tables for LHE weights, may not be filled
276  std::unique_ptr<nanoaod::FlatTable> lheScaleTab, lhePdfTab, lheRwgtTab, lheNamedTab;
277  std::unique_ptr<nanoaod::FlatTable> genPSTab;
278 
280  for (const auto& lheTag : lheTag_) {
281  iEvent.getByToken(lheTag, lheInfo);
282  if (lheInfo.isValid()) {
283  break;
284  }
285  }
286  if (lheInfo.isValid()) {
287  // get the dynamic choice of weights
288  const DynamicWeightChoice* weightChoice = runCache(iEvent.getRun().index());
289  // go fill tables
291  counter, weightChoice, weight, *lheInfo, *genInfo, lheScaleTab, lhePdfTab, lheRwgtTab, lheNamedTab, genPSTab);
292  } else {
293  // Still try to add the PS weights
294  fillOnlyPSWeightTable(counter, weight, *genInfo, genPSTab);
295  // make dummy values
296  lheScaleTab.reset(new nanoaod::FlatTable(1, "LHEScaleWeights", true));
297  lhePdfTab.reset(new nanoaod::FlatTable(1, "LHEPdfWeights", true));
298  lheRwgtTab.reset(new nanoaod::FlatTable(1, "LHEReweightingWeights", true));
299  lheNamedTab.reset(new nanoaod::FlatTable(1, "LHENamedWeights", true));
300  if (!hasIssuedWarning_.exchange(true)) {
301  edm::LogWarning("LHETablesProducer") << "No LHEEventProduct, so there will be no LHE Tables\n";
302  }
303  }
304 
305  iEvent.put(std::move(lheScaleTab), "LHEScale");
306  iEvent.put(std::move(lhePdfTab), "LHEPdf");
307  iEvent.put(std::move(lheRwgtTab), "LHEReweighting");
308  iEvent.put(std::move(lheNamedTab), "LHENamed");
309  iEvent.put(std::move(genPSTab), "PS");
310  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const edm::EDGetTokenT< GenEventInfoProduct > genTag_
Definition: weight.py:1
Run const & getRun() const
Definition: Event.cc:108
double weight() const
std::atomic< bool > hasIssuedWarning_
void fillLHEWeightTables(Counter *counter, const DynamicWeightChoice *weightChoice, double genWeight, const LHEEventProduct &lheProd, const GenEventInfoProduct &genProd, std::unique_ptr< nanoaod::FlatTable > &outScale, std::unique_ptr< nanoaod::FlatTable > &outPdf, std::unique_ptr< nanoaod::FlatTable > &outRwgt, std::unique_ptr< nanoaod::FlatTable > &outNamed, std::unique_ptr< nanoaod::FlatTable > &outPS) const
std::function< unsigned int(align::ID)> Counter
RunIndex index() const
Definition: Run.cc:21
void fillOnlyPSWeightTable(Counter *counter, double genWeight, const GenEventInfoProduct &genProd, std::unique_ptr< nanoaod::FlatTable > &outPS) const
bool isValid() const
Definition: HandleBase.h:70
const std::vector< edm::EDGetTokenT< LHEEventProduct > > lheTag_
def move(src, dest)
Definition: eostools.py:511
void GenWeightsTableProducer::streamBeginLuminosityBlock ( edm::StreamID  id,
edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  eventSetup 
) const
inlineoverride

Definition at line 771 of file GenWeightsTableProducer.cc.

References GenLumiInfoHeader::configDescription(), edm::LuminosityBlock::getByToken(), and edm::HandleBase::isValid().

773  {
774  auto counterMap = streamCache(id);
775  edm::Handle<GenLumiInfoHeader> genLumiInfoHead;
776  lumiBlock.getByToken(genLumiInfoHeadTag_, genLumiInfoHead);
777  if (!genLumiInfoHead.isValid())
778  edm::LogWarning("LHETablesProducer")
779  << "No GenLumiInfoHeader product found, will not fill generator model string.\n";
780  counterMap->setLabel(genLumiInfoHead.isValid() ? genLumiInfoHead->configDescription() : "");
781  }
bool isValid() const
Definition: HandleBase.h:70
const std::string & configDescription() const
const edm::EDGetTokenT< GenLumiInfoHeader > genLumiInfoHeadTag_
void GenWeightsTableProducer::streamBeginRun ( edm::StreamID  id,
edm::Run const &  ,
edm::EventSetup const &   
) const
inlineoverride

Definition at line 768 of file GenWeightsTableProducer.cc.

768  {
769  streamCache(id)->clear();
770  }
void GenWeightsTableProducer::streamEndRunSummary ( edm::StreamID  id,
edm::Run const &  ,
edm::EventSetup const &  ,
CounterMap *  runCounterMap 
) const
inlineoverride

Definition at line 787 of file GenWeightsTableProducer.cc.

790  {
791  runCounterMap->merge(*streamCache(id));
792  }

Member Data Documentation

std::atomic<bool> GenWeightsTableProducer::debug_
mutableprotected

Definition at line 880 of file GenWeightsTableProducer.cc.

std::atomic<bool> GenWeightsTableProducer::debugRun_
mutableprotected

Definition at line 880 of file GenWeightsTableProducer.cc.

const edm::EDGetTokenT<GenLumiInfoHeader> GenWeightsTableProducer::genLumiInfoHeadTag_
protected

Definition at line 871 of file GenWeightsTableProducer.cc.

const edm::EDGetTokenT<GenEventInfoProduct> GenWeightsTableProducer::genTag_
protected

Definition at line 867 of file GenWeightsTableProducer.cc.

std::atomic<bool> GenWeightsTableProducer::hasIssuedWarning_
mutableprotected

Definition at line 880 of file GenWeightsTableProducer.cc.

std::unordered_map<std::string, uint32_t> GenWeightsTableProducer::lhaNameToID_
protected

Definition at line 874 of file GenWeightsTableProducer.cc.

const std::vector<edm::InputTag> GenWeightsTableProducer::lheLabel_
protected

Definition at line 868 of file GenWeightsTableProducer.cc.

const std::vector<edm::EDGetTokenT<LHERunInfoProduct> > GenWeightsTableProducer::lheRunTag_
protected

Definition at line 870 of file GenWeightsTableProducer.cc.

const std::vector<edm::EDGetTokenT<LHEEventProduct> > GenWeightsTableProducer::lheTag_
protected

Definition at line 869 of file GenWeightsTableProducer.cc.

int GenWeightsTableProducer::lheWeightPrecision_
protected

Definition at line 877 of file GenWeightsTableProducer.cc.

unsigned int GenWeightsTableProducer::maxPdfWeights_
protected

Definition at line 878 of file GenWeightsTableProducer.cc.

std::vector<std::string> GenWeightsTableProducer::namedWeightIDs_
protected

Definition at line 875 of file GenWeightsTableProducer.cc.

std::vector<std::string> GenWeightsTableProducer::namedWeightLabels_
protected

Definition at line 876 of file GenWeightsTableProducer.cc.

std::vector<uint32_t> GenWeightsTableProducer::preferredPDFLHAIDs_
protected

Definition at line 873 of file GenWeightsTableProducer.cc.