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
 
- 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
 
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)
 

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)
 
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 22 of file PDFWeightsTest.cc.

Constructor & Destructor Documentation

PDFWeightsTest::PDFWeightsTest ( const ParameterSet cfg)
inlineexplicit

Definition at line 39 of file PDFWeightsTest.cc.

References edm::ParameterSet::getParameter(), PDFWeightsHelper::Init(), and TFileService::make().

40  : srcToken_(consumes<LHEEventProduct>(edm::InputTag("externalLHEProducer"))),
41  srcTokenAlt_(consumes<LHEEventProduct>(edm::InputTag("source"))),
42  srcTokenGen_(consumes<GenEventInfoProduct>(edm::InputTag("generator"))),
43  pdfWeightOffset_(cfg.getParameter<unsigned int>("pdfWeightOffset")),
44  nPdfWeights_(cfg.getParameter<unsigned int>("nPdfWeights")),
45  nPdfEigWeights_(cfg.getParameter<unsigned int>("nPdfEigWeights")),
49  tree_ = fs->make<TTree>("tree", "");
50 
51  tree_->Branch("pdfrep", &pdfweights_);
52  tree_->Branch("pdfeig", &pdfeigweights_);
53  tree_->Branch("weight", &weight_);
54 
55  edm::FileInPath mc2hessianCSV = cfg.getParameter<edm::FileInPath>("mc2hessianCSV");
57  }
unsigned int nPdfWeights_
T getParameter(std::string const &) const
EDGetTokenT< LHEEventProduct > srcToken_
std::vector< float > pdfeigweights_
void Init(unsigned int nreplicas, unsigned int neigenvectors, const edm::FileInPath &incsv)
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
unsigned int pdfWeightOffset_
EDGetTokenT< GenEventInfoProduct > srcTokenGen_
unsigned int nPdfEigWeights_
PDFWeightsHelper pdfweightshelper_
std::vector< float > pdfweights_
EDGetTokenT< LHEEventProduct > srcTokenAlt_

Member Function Documentation

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

Definition at line 60 of file PDFWeightsTest.cc.

References DEFINE_FWK_MODULE, PDFWeightsHelper::DoMC2Hessian(), edm::Event::getByToken(), edm::HandleBase::isValid(), nano_cff::lheInfo, GenEventInfoProduct::weight(), and LHEEventProduct::weights().

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

Member Data Documentation

unsigned int PDFWeightsTest::nPdfEigWeights_
private

Definition at line 31 of file PDFWeightsTest.cc.

unsigned int PDFWeightsTest::nPdfWeights_
private

Definition at line 30 of file PDFWeightsTest.cc.

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

Definition at line 35 of file PDFWeightsTest.cc.

unsigned int PDFWeightsTest::pdfWeightOffset_
private

Definition at line 29 of file PDFWeightsTest.cc.

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

Definition at line 34 of file PDFWeightsTest.cc.

PDFWeightsHelper PDFWeightsTest::pdfweightshelper_
private

Definition at line 24 of file PDFWeightsTest.cc.

EDGetTokenT<LHEEventProduct> PDFWeightsTest::srcToken_
private

Definition at line 25 of file PDFWeightsTest.cc.

EDGetTokenT<LHEEventProduct> PDFWeightsTest::srcTokenAlt_
private

Definition at line 26 of file PDFWeightsTest.cc.

EDGetTokenT<GenEventInfoProduct> PDFWeightsTest::srcTokenGen_
private

Definition at line 27 of file PDFWeightsTest.cc.

TTree* PDFWeightsTest::tree_
private

Definition at line 33 of file PDFWeightsTest.cc.

float PDFWeightsTest::weight_
private

Definition at line 36 of file PDFWeightsTest.cc.