Skip to content

Commit

Permalink
Move example weight test producer
Browse files Browse the repository at this point in the history
  • Loading branch information
kdlong committed Oct 7, 2019
1 parent 2b1b520 commit d307670
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 37 deletions.
9 changes: 7 additions & 2 deletions GeneratorInterface/Core/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
<use name="GeneratorInterface/Core"/>

<library name="GeneratorInterfaceCore_plugins" file="*.cc" >
<use name="DataFormats/HepMCCandidate"/>
<use name="DataFormats/Candidate"/>
<use name="DataFormats/METReco"/>
<use name="DataFormats/JetReco"/>
<use name="PhysicsTools/UtilAlgos"/>
<use name="SimDataFormats/GeneratorProducts"/>
<use name="lhapdf"/>
<flags EDM_PLUGIN="1"/>
</library>


Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// -*- C++ -*-
//
// Package: GenAnalysis/LHEWeightsTest
// Class: LHEWeightsTest
// Package: GenAnalysis/GenWeightsTestAnalyzer
// Class: GenWeightsTestAnalyzer
//
/**\class LHEWeightsTest LHEWeightsTest.cc GenAnalysis/LHEWeightsTest/plugins/LHEWeightsTest.cc
/**\class GenWeightsTestAnalyzer GenWeightsTestAnalyzer.cc GenAnalysis/GenWeightsTestAnalyzer/plugins/GenWeightsTestAnalyzer.cc
Description: [one line class summary]
Expand Down Expand Up @@ -66,10 +66,10 @@
// constructor "usesResource("TFileService");"
// This will improve performance in multithreaded jobs.

class LHEWeightsTest : public edm::one::EDAnalyzer<edm::one::WatchLuminosityBlocks> {
class GenWeightsTestAnalyzer : public edm::one::EDAnalyzer<edm::one::WatchLuminosityBlocks> {
public:
explicit LHEWeightsTest(const edm::ParameterSet&);
~LHEWeightsTest();
explicit GenWeightsTestAnalyzer(const edm::ParameterSet&);
~GenWeightsTestAnalyzer();

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

Expand Down Expand Up @@ -125,7 +125,7 @@ class LHEWeightsTest : public edm::one::EDAnalyzer<edm::one::WatchLuminosityBloc
//
// constructors and destructor
//
LHEWeightsTest::LHEWeightsTest(const edm::ParameterSet& iConfig) :
GenWeightsTestAnalyzer::GenWeightsTestAnalyzer(const edm::ParameterSet& iConfig) :
tag_(iConfig.getParameter<std::string>("tag")),
isMiniaod_(iConfig.getParameter<bool>("miniaod")),
genParticleToken_(consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("genParticleSrc"))),
Expand Down Expand Up @@ -160,7 +160,7 @@ LHEWeightsTest::LHEWeightsTest(const edm::ParameterSet& iConfig) :
}


LHEWeightsTest::~LHEWeightsTest()
GenWeightsTestAnalyzer::~GenWeightsTestAnalyzer()
{

// do anything here that needs to be done at desctruction time
Expand Down Expand Up @@ -279,7 +279,7 @@ bool has_v_in_history(reco::GenParticle const & part){
}
}

void LHEWeightsTest::setup_variables(const edm::Event& iEvent) {
void GenWeightsTestAnalyzer::setup_variables(const edm::Event& iEvent) {
using namespace edm;

//// Initialize with dummy values
Expand Down Expand Up @@ -331,7 +331,7 @@ void LHEWeightsTest::setup_variables(const edm::Event& iEvent) {
variables["ht"] = ht;

}
std::vector<double> LHEWeightsTest::setup_weights(const edm::Event& iEvent) {
std::vector<double> GenWeightsTestAnalyzer::setup_weights(const edm::Event& iEvent) {
edm::Handle<GenWeightProduct> lheWeightHandle;
iEvent.getByToken(lheWeightToken_, lheWeightHandle);
const GenWeightProduct * lheWeights = lheWeightHandle.product();
Expand All @@ -348,7 +348,7 @@ std::vector<double> LHEWeightsTest::setup_weights(const edm::Event& iEvent) {

// ------------ method called for each event ------------
void
LHEWeightsTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
GenWeightsTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
using namespace edm;

Expand All @@ -371,19 +371,19 @@ LHEWeightsTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)

// ------------ method called once each job just before starting event loop ------------
void
LHEWeightsTest::beginJob()
GenWeightsTestAnalyzer::beginJob()
{
}

// ------------ method called once each job just after ending the event loop ------------
void
LHEWeightsTest::endJob()
GenWeightsTestAnalyzer::endJob()
{
}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void
LHEWeightsTest::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
GenWeightsTestAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
Expand All @@ -392,7 +392,7 @@ LHEWeightsTest::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
}

void
LHEWeightsTest::beginLuminosityBlock(edm::LuminosityBlock const& iLumi, edm::EventSetup const& es) {
GenWeightsTestAnalyzer::beginLuminosityBlock(edm::LuminosityBlock const& iLumi, edm::EventSetup const& es) {
//edm::Handle<GenWeightInfoProduct> lheWeightsInfoHandle;
//edm::Handle<GenRunInfoProduct> lheWeightsInfoHandle;
//run.getByLabel("generator", lheWeightsInfoHandle);
Expand Down Expand Up @@ -424,5 +424,5 @@ LHEWeightsTest::beginLuminosityBlock(edm::LuminosityBlock const& iLumi, edm::Eve
}

//define this as a plug-in
DEFINE_FWK_MODULE(LHEWeightsTest);
DEFINE_FWK_MODULE(GenWeightsTestAnalyzer);

2 changes: 1 addition & 1 deletion GeneratorInterface/Core/src/LHEWeightHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace gen {
auto rawLabel = boost::algorithm::to_lower_copy(entry.first);
std::string label = nameConversionMap_[rawLabel];
if (nameConversionMap_.find(label) != nameConversionMap_.end())
attributeMap.at(nameConversionMap_[label]) = entry.second;
attributeMap[nameConversionMap_[label]] = entry.second;
else
attributeMap[label] = entry.second;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def commandline():

process.testWeights = cms.EDProducer("LHEWeightProductProducer")

process.demo = cms.EDAnalyzer('LHEWeightsTest',
process.demo = cms.EDAnalyzer('GenWeightsTestAnalyzer',
tag = cms.string(options.tag),
miniaod = cms.bool(options.isMiniAOD),
genParticleSrc = cms.InputTag("prunedGenParticles" if options.isMiniAOD else "genParticles"),
Expand Down
17 changes: 0 additions & 17 deletions GeneratorInterface/LHEInterface/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,3 @@
<use name="mcdb"/>
<flags EDM_PLUGIN="1"/>
</library>
<library name="GeneratorInterfaceLHECOMWeightProducer" file="LHECOMWeightProducer.cc">
<use name="FWCore/Framework"/>
<use name="SimDataFormats/GeneratorProducts"/>
<use name="lhapdf"/>
<flags EDM_PLUGIN="1"/>
</library>
<library name="GeneratorInterfaceLHEWeightsTest" file="LHEWeightsTest.cc">
<use name="DataFormats/HepMCCandidate"/>
<use name="DataFormats/Candidate"/>
<use name="DataFormats/METReco"/>
<use name="DataFormats/JetReco"/>
<use name="PhysicsTools/UtilAlgos"/>
<use name="SimDataFormats/GeneratorProducts"/>
<use name="FWCore/Framework"/>
<use name="SimDataFormats/GeneratorProducts"/>
<flags EDM_PLUGIN="1"/>
</library>

0 comments on commit d307670

Please sign in to comment.