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

39  :
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")),
48  {
49 
51  tree_ = fs->make<TTree>("tree", "");
52 
53  tree_->Branch("pdfrep",&pdfweights_);
54  tree_->Branch("pdfeig",&pdfeigweights_);
55  tree_->Branch("weight",&weight_);
56 
57  edm::FileInPath mc2hessianCSV = cfg.getParameter<edm::FileInPath>("mc2hessianCSV");
59 
60  }
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 63 of file PDFWeightsTest.cc.

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

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