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
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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)
 

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
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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.

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  }

References looper::cfg, PDFWeightsHelper::Init(), and TFileService::make().

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.

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  }

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

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.

PDFWeightsTest::srcToken_
EDGetTokenT< LHEEventProduct > srcToken_
Definition: PDFWeightsTest.cc:24
PDFWeightsTest::weight_
float weight_
Definition: PDFWeightsTest.cc:35
PDFWeightsTest::nPdfEigWeights_
unsigned int nPdfEigWeights_
Definition: PDFWeightsTest.cc:30
PDFWeightsTest::srcTokenAlt_
EDGetTokenT< LHEEventProduct > srcTokenAlt_
Definition: PDFWeightsTest.cc:25
edm::Handle
Definition: AssociativeIterator.h:50
PDFWeightsHelper::Init
void Init(unsigned int nreplicas, unsigned int neigenvectors, const edm::FileInPath &incsv)
Definition: PDFWeightsHelper.cc:7
PDFWeightsHelper::DoMC2Hessian
void DoMC2Hessian(double nomweight, const double *inweights, double *outweights) const
Definition: PDFWeightsHelper.cc:28
edm::FileInPath
Definition: FileInPath.h:64
genWeightsTable_cfi.lheInfo
lheInfo
Definition: genWeightsTable_cfi.py:6
PDFWeightsTest::srcTokenGen_
EDGetTokenT< GenEventInfoProduct > srcTokenGen_
Definition: PDFWeightsTest.cc:26
PDFWeightsTest::pdfeigweights_
std::vector< float > pdfeigweights_
Definition: PDFWeightsTest.cc:34
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
PDFWeightsTest::pdfWeightOffset_
unsigned int pdfWeightOffset_
Definition: PDFWeightsTest.cc:28
edm::Service< TFileService >
PDFWeightsTest::pdfweightshelper_
PDFWeightsHelper pdfweightshelper_
Definition: PDFWeightsTest.cc:23
looper.cfg
cfg
Definition: looper.py:297
PDFWeightsTest::pdfweights_
std::vector< float > pdfweights_
Definition: PDFWeightsTest.cc:33
PDFWeightsTest::tree_
TTree * tree_
Definition: PDFWeightsTest.cc:32
PDFWeightsTest::nPdfWeights_
unsigned int nPdfWeights_
Definition: PDFWeightsTest.cc:29
edm::InputTag
Definition: InputTag.h:15
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
GenEventInfoProduct::weight
double weight() const
Definition: GenEventInfoProduct.h:35