CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PDFWeightsTest Class Reference
Inheritance diagram for PDFWeightsTest:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 PDFWeightsTest (const ParameterSet &cfg)
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const Event &evt, const EventSetup &es) override
 

Private Attributes

unsigned int nPdfEigWeights_
 
unsigned int nPdfWeights_
 
std::vector< float > pdfeigweights_
 
unsigned int pdfWeightOffset_
 
std::vector< float > pdfweights_
 
PDFWeightsHelper pdfweightshelper_
 
EDGetTokenT< LHEEventProductsrcToken_
 
EDGetTokenT< LHEEventProductsrcTokenAlt_
 
EDGetTokenT< GenEventInfoProductsrcTokenGen_
 
TTree * tree_
 
float weight_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 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<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 21 of file PDFWeightsTest.cc.

Constructor & Destructor Documentation

◆ PDFWeightsTest()

PDFWeightsTest::PDFWeightsTest ( const ParameterSet cfg)
inlineexplicit

Definition at line 38 of file PDFWeightsTest.cc.

References looper::cfg, compareTotals::fs, and PDFWeightsHelper::Init().

39  : srcToken_(consumes<LHEEventProduct>(edm::InputTag("externalLHEProducer"))),
40  srcTokenAlt_(consumes<LHEEventProduct>(edm::InputTag("source"))),
41  srcTokenGen_(consumes<GenEventInfoProduct>(edm::InputTag("generator"))),
42  pdfWeightOffset_(cfg.getParameter<unsigned int>("pdfWeightOffset")),
43  nPdfWeights_(cfg.getParameter<unsigned int>("nPdfWeights")),
44  nPdfEigWeights_(cfg.getParameter<unsigned int>("nPdfEigWeights")),
48  tree_ = fs->make<TTree>("tree", "");
49 
50  tree_->Branch("pdfrep", &pdfweights_);
51  tree_->Branch("pdfeig", &pdfeigweights_);
52  tree_->Branch("weight", &weight_);
53 
54  edm::FileInPath mc2hessianCSV = cfg.getParameter<edm::FileInPath>("mc2hessianCSV");
56  }
unsigned int nPdfWeights_
EDGetTokenT< LHEEventProduct > srcToken_
std::vector< float > pdfeigweights_
void Init(unsigned int nreplicas, unsigned int neigenvectors, const edm::FileInPath &incsv)
unsigned int pdfWeightOffset_
EDGetTokenT< GenEventInfoProduct > srcTokenGen_
unsigned int nPdfEigWeights_
PDFWeightsHelper pdfweightshelper_
std::vector< float > pdfweights_
EDGetTokenT< LHEEventProduct > srcTokenAlt_

Member Function Documentation

◆ analyze()

void PDFWeightsTest::analyze ( const Event evt,
const EventSetup es 
)
inlineoverrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 59 of file PDFWeightsTest.cc.

References PDFWeightsHelper::DoMC2Hessian(), edm::Event::getByToken(), genWeightsTable_cfi::lheInfo, and GenEventInfoProduct::weight().

59  {
62 
63  if (!lheInfo.isValid()) {
65  }
66 
67  double nomlheweight = lheInfo->weights()[0].wgt;
68 
70  evt.getByToken(srcTokenGen_, genInfo);
71 
72  weight_ = genInfo->weight();
73 
74  //get the original mc replica weights
75  std::vector<double> inpdfweights(nPdfWeights_);
76  for (unsigned int ipdf = 0; ipdf < nPdfWeights_; ++ipdf) {
77  unsigned int iwgt = ipdf + pdfWeightOffset_;
78 
79  //this is the weight to be used for evaluating uncertainties with mc replica weights
80  pdfweights_[ipdf] = lheInfo->weights()[iwgt].wgt * weight_ / nomlheweight;
81 
82  //this is the raw weight to be fed to the mc2hessian convertor
83  inpdfweights[ipdf] = lheInfo->weights()[iwgt].wgt;
84  }
85 
86  std::vector<double> outpdfweights(nPdfEigWeights_);
87  //do the actual conversion, where the nominal lhe weight is needed as the reference point for the linearization
88  pdfweightshelper_.DoMC2Hessian(nomlheweight, inpdfweights.data(), outpdfweights.data());
89 
90  for (unsigned int iwgt = 0; iwgt < nPdfEigWeights_; ++iwgt) {
91  double wgtval = outpdfweights[iwgt];
92 
93  //the is the weight to be used for evaluating uncertainties with hessian weights
94  pdfeigweights_[iwgt] = wgtval * weight_ / nomlheweight;
95  }
96 
97  tree_->Fill();
98  }
unsigned int nPdfWeights_
EDGetTokenT< LHEEventProduct > srcToken_
std::vector< float > pdfeigweights_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
void DoMC2Hessian(double nomweight, const double *inweights, double *outweights) const
unsigned int pdfWeightOffset_
EDGetTokenT< GenEventInfoProduct > srcTokenGen_
unsigned int nPdfEigWeights_
PDFWeightsHelper pdfweightshelper_
std::vector< float > pdfweights_
EDGetTokenT< LHEEventProduct > srcTokenAlt_

Member Data Documentation

◆ nPdfEigWeights_

unsigned int PDFWeightsTest::nPdfEigWeights_
private

Definition at line 30 of file PDFWeightsTest.cc.

◆ nPdfWeights_

unsigned int PDFWeightsTest::nPdfWeights_
private

Definition at line 29 of file PDFWeightsTest.cc.

◆ pdfeigweights_

std::vector<float> PDFWeightsTest::pdfeigweights_
private

Definition at line 34 of file PDFWeightsTest.cc.

◆ pdfWeightOffset_

unsigned int PDFWeightsTest::pdfWeightOffset_
private

Definition at line 28 of file PDFWeightsTest.cc.

◆ pdfweights_

std::vector<float> PDFWeightsTest::pdfweights_
private

Definition at line 33 of file PDFWeightsTest.cc.

◆ pdfweightshelper_

PDFWeightsHelper PDFWeightsTest::pdfweightshelper_
private

Definition at line 23 of file PDFWeightsTest.cc.

◆ srcToken_

EDGetTokenT<LHEEventProduct> PDFWeightsTest::srcToken_
private

Definition at line 24 of file PDFWeightsTest.cc.

◆ srcTokenAlt_

EDGetTokenT<LHEEventProduct> PDFWeightsTest::srcTokenAlt_
private

Definition at line 25 of file PDFWeightsTest.cc.

◆ srcTokenGen_

EDGetTokenT<GenEventInfoProduct> PDFWeightsTest::srcTokenGen_
private

Definition at line 26 of file PDFWeightsTest.cc.

◆ tree_

TTree* PDFWeightsTest::tree_
private

Definition at line 32 of file PDFWeightsTest.cc.

◆ weight_

float PDFWeightsTest::weight_
private

Definition at line 35 of file PDFWeightsTest.cc.