Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
208a4a3
Adding first outlines of weight products
kdlong May 28, 2019
0a8810e
Close to an outline, not working for LHESource
kdlong May 29, 2019
7cfc2fe
Working skeleton of LHEWeightInfoProduct
kdlong May 29, 2019
444dbc3
About a working outline with weights in the event
kdlong May 30, 2019
49c25ba
Working rough implementation of Weight/WeightInfo prods
kdlong May 30, 2019
bb431b7
Fix bug in insert to containedIds for WeightGroup
kdlong May 31, 2019
df84164
Add test scripts
kdlong May 31, 2019
23bee66
Store pointers to WeightGroupInfo
kdlong Aug 5, 2019
0ba28e0
Compiles with OwnVector, but need a proper copy constructor
kdlong Aug 6, 2019
9ba9510
Working with edm::OwnVector
kdlong Aug 6, 2019
338a979
Separate WeightGroupInfo into .h and .cc files
kdlong Aug 7, 2019
8397fca
Separate out PDF weights
kdlong Aug 7, 2019
9e06271
Add scale-specific weightgroupinfo class
kdlong Aug 15, 2019
071c069
First tests with parsing of lhe file. Need to incorp EDM lhe reader
dteague Aug 15, 2019
f44363c
Merge pull request #2 from dteague/Gen_parsing
kdlong Aug 15, 2019
6bfea57
fixing readerhelper problems
dteague Aug 15, 2019
9696885
Merge pull request #3 from dteague/Gen_parsing
kdlong Aug 15, 2019
f62468c
Working on parsing integration with scale/pdf weights
kdlong Aug 15, 2019
28f0ba2
Fixing little bit of readerhelper to change things to non-ptrs
dteague Aug 16, 2019
db06b18
Random commit before merge: only spacing diffs -_-
dteague Aug 16, 2019
71629cd
Read header info from headers in externalLHEProducer
kdlong Aug 28, 2019
cf10a6b
Merge branch 'GenWeightRefactor' of https://github.com/kdlong/cmssw i…
dteague Aug 28, 2019
fbf495c
Merge branch 'GenWeightRefactor' of https://github.com/kdlong/cmssw i…
dteague Aug 28, 2019
c98a078
added Regex helper class and put under (kinda silly) namespace
dteague Sep 2, 2019
de0ad7a
Fix problem with instantiating Scale/PdfWeightInfo to file
kdlong Sep 2, 2019
59691bc
Add an alternative sample for testing
kdlong Sep 3, 2019
1c1da76
Slight cleanup to naming and weightgroup type
kdlong Sep 3, 2019
057cb83
Merge remote-tracking branch 'dylan/Gen_parsing' into dteague-Gen_par…
kdlong Sep 3, 2019
80cde77
Fixed small error in names of RegexCreater, should run on new gridp
dteague Sep 4, 2019
41f2e17
Merge remote-tracking branch 'dylan/Gen_parsing' into dteague-Gen_par…
kdlong Sep 4, 2019
33e2466
Remove bloated comments
kdlong Sep 4, 2019
f1bcab0
Merge branch 'dteague-Gen_parsing' into GenWeightRefactor
kdlong Sep 4, 2019
9baeee2
overhaul of code: now works with tinyxml2 instead of regex
dteague Sep 6, 2019
1038e0d
testing helper stuff as comments
dteague Sep 6, 2019
b4b08c9
Merge branch 'GenWeightRefactor' of https://github.com/kdlong/cmssw i…
dteague Sep 6, 2019
f1a3ae4
A bit of cleanup
kdlong Sep 11, 2019
1bb40ac
Merge pull request #5 from dteague/Gen_parsing
kdlong Sep 18, 2019
1e81c15
Merge branch 'GenWeightRefactor' of https://github.com/kdlong/cmssw i…
kdlong Sep 18, 2019
79efbe6
Adding a dummy analyzer for weights, need to clean up organization
kdlong Sep 18, 2019
07eb97a
Use dynamic cast, but then it segfaults
kdlong Sep 18, 2019
5668f0d
Incorporate changes to make OwnVector work
kdlong Sep 20, 2019
8c0c98e
Fix setting of ScaleWeight indices
kdlong Sep 20, 2019
8744839
Add unknown weightgroup
kdlong Sep 20, 2019
682ac14
Start to move parsing tools to GeneratorInterface/Core
kdlong Sep 20, 2019
037f6f9
Move LHE reader to .h and .cc files, rename
kdlong Sep 21, 2019
a78163b
Separate WeightHelper into base and daughter classes
kdlong Sep 21, 2019
b6e3285
Producer or MiniAOD is finally working
kdlong Sep 23, 2019
c82792f
Add outline of Zplotter (from Andreas) with weights implemented
kdlong Sep 24, 2019
ffd0503
Working example of plotting code reading weight products
kdlong Sep 24, 2019
c535b55
Rename LHEWeight-->GenWeight to have same product for LHE and GEN
kdlong Oct 3, 2019
3e48617
Add parton shower weights class
kdlong Oct 3, 2019
176adbf
Simple version of GEN producer working
kdlong Oct 3, 2019
acc3817
Fix nasty bug searching for weights by index
kdlong Oct 3, 2019
27a9239
Clean up test script for LHE weights a bit
kdlong Oct 4, 2019
7402487
Start to implement useful functions for PdfGroupInfo
kdlong Oct 4, 2019
b744a77
Put product in lumi instead of run
kdlong Oct 4, 2019
a30dacf
Some cleanup + nasty bug fix in lhapdfIds
kdlong Oct 6, 2019
2b1b520
Remove dummy analyzer
kdlong Oct 7, 2019
d307670
Move example weight test producer
kdlong Oct 7, 2019
bbdd462
Add PDF and PS weights in example
kdlong Oct 7, 2019
916af26
Make the test script more general
kdlong Oct 8, 2019
70cdb97
New LHEWeightsTableProducer
guitargeek Dec 19, 2019
205de35
Variable number of produced flat tables
guitargeek Dec 19, 2019
d663d2f
select specific weight groups
guitargeek Dec 19, 2019
45be54a
give a bit more structure to weight counter class
guitargeek Dec 20, 2019
c4cd203
Merged NanoGen_11_0_0_pre11 from repository guitargeek with cms-merge…
kdlong Dec 24, 2019
dd34a14
Merged GenWeightRefactor from repository kdlong with cms-merge-topic
kdlong Dec 24, 2019
c545dec
Remove some customization to make it compile
kdlong Dec 25, 2019
d6c2452
Remove duplicate text from merge
kdlong Dec 26, 2019
a4e2b7a
Fix mistake in getting weightMetaInfo by index
kdlong Dec 28, 2019
9f6b791
Add outline of ME reweight weightinfo class
kdlong Dec 29, 2019
afe662a
Add MEParams class, nanogen example config
kdlong Dec 29, 2019
6c5900c
Roughly working with Run, need to move to lumi
kdlong Jan 4, 2020
fb19c05
Produce in beginLumi, working with scale and NanoGen
kdlong Jan 5, 2020
ae40865
Example with both scale and ME weights
kdlong Jan 5, 2020
e542eaa
Improve organization of adding different weight types
kdlong Jan 6, 2020
ca22fc5
Close to working, but segfaulting
kdlong Jan 10, 2020
8fcc230
Update weighttype, read storage info from config
kdlong Jan 11, 2020
3dbdd4c
Correct name of shower weights so they're stored
kdlong Jan 11, 2020
265e6a0
Store normalized weights from the start, cleanup
kdlong Jan 16, 2020
6aaef39
Make pdfIds untracked
kdlong Jan 17, 2020
6ccee5d
Working implementation producing new prod if needed
kdlong Jan 17, 2020
884dc84
Remove test analyzers
kdlong Jan 17, 2020
9bd87c7
Remove dummy weights function
kdlong Jan 18, 2020
7daba24
Significant restructure of parsing
kdlong Jan 19, 2020
419a1cd
Update lheWeights config
kdlong Jan 20, 2020
a2912ec
First stab at cmsDriver NanoGEN
kdlong Jan 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Configuration/Applications/python/ConfigBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ def define_Configs(self):
self.RECOSIMDefaultCFF="Configuration/StandardSequences/RecoSim_cff"
self.PATDefaultCFF="Configuration/StandardSequences/PAT_cff"
self.NANODefaultCFF="PhysicsTools/NanoAOD/nano_cff"
self.NANOGENDefaultCFF="PhysicsTools/NanoAOD/nanogen_cff"
self.EIDefaultCFF=None
self.SKIMDefaultCFF="Configuration/StandardSequences/Skims_cff"
self.POSTRECODefaultCFF="Configuration/StandardSequences/PostRecoGenerator_cff"
Expand Down Expand Up @@ -987,6 +988,7 @@ def define_Configs(self):
self.REPACKDefaultSeq='DigiToRawRepack'
self.PATDefaultSeq='miniAOD'
self.PATGENDefaultSeq='miniGEN'
self.NANOGENDefaultSeq='nanogenSequence'
self.NANODefaultSeq='nanoSequence'

self.EVTCONTDefaultCFF="Configuration/EventContent/EventContent_cff"
Expand Down Expand Up @@ -1690,6 +1692,15 @@ def prepare_NANO(self, sequence = "nanoAOD"):
self._options.customise_commands = self._options.customise_commands + " \n"
self._options.customise_commands = self._options.customise_commands + "process.unpackedPatTrigger.triggerResults= cms.InputTag( 'TriggerResults::"+self._options.hltProcess+"' )\n"

def prepare_NANOGEN(self, sequence = "nanoAOD"):
''' Enrich the schedule with NANO '''
self.loadDefaultOrSpecifiedCFF(sequence,self.NANOGENDefaultCFF)
self.scheduleSequence(sequence.split('.')[-1],'nanoAOD_step')
custom = "customizeNanoGEN"
if self._options.runUnscheduled:
self._options.customisation_file_unsch.insert(0, '.'.join([self.NANOGENDefaultCFF, custom]))
else:
self._options.customisation_file.insert(0, '.'.join([self.NANOGENDefaultCFF, custom]))

def prepare_EI(self, sequence = None):
''' Enrich the schedule with event interpretation '''
Expand Down
3 changes: 3 additions & 0 deletions DataFormats/NanoAOD/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<class name="nanoaod::FlatTable::RowView" transient="true" />
<class name="edm::Wrapper<nanoaod::FlatTable>" />

<class name="edm::Wrapper<std::vector<nanoaod::FlatTable>>" />
<class name="std::vector<nanoaod::FlatTable>" />

<class name="nanoaod::MergeableCounterTable::FloatColumn" ClassVersion="3">
<version ClassVersion="3" checksum="828208870"/>
</class>
Expand Down
1 change: 1 addition & 0 deletions GeneratorInterface/Core/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<use name="lhapdf"/>
<use name="f77compiler"/>
<use name="root"/>
<use name="tinyxml2"/>
<export>
<lib name="1"/>
</export>
30 changes: 30 additions & 0 deletions GeneratorInterface/Core/interface/GenWeightHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef GeneratorInterface_Core_GenWeightHelper_h
#define GeneratorInterface_Core_GenWeightHelper_h

#include <string>
#include <vector>
#include <map>
#include <regex>
#include <fstream>

#include "SimDataFormats/GeneratorProducts/interface/PdfWeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/ScaleWeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/PartonShowerWeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/GenLumiInfoProduct.h"
#include "GeneratorInterface/Core/interface/WeightHelper.h"

#include <tinyxml2.h>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be in "" not <>


namespace gen {
class GenWeightHelper : public WeightHelper {
public:
GenWeightHelper();

void parseWeightGroupsFromNames(std::vector<std::string> weightNames);
private:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove private if unused

};
}

#endif


33 changes: 33 additions & 0 deletions GeneratorInterface/Core/interface/LHEWeightHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef GeneratorInterface_Core_LHEWeightHelper_h
#define GeneratorInterface_Core_LHEWeightHelper_h

#include <string>
#include <vector>
#include <map>
#include <regex>
#include <fstream>

#include "SimDataFormats/GeneratorProducts/interface/UnknownWeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/MEParamWeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/PdfWeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/ScaleWeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/LHERunInfoProduct.h"
#include "GeneratorInterface/Core/interface/WeightHelper.h"

#include <tinyxml2.h>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"" not <>


namespace gen {
class LHEWeightHelper : public WeightHelper {
public:
LHEWeightHelper() : WeightHelper() {};
void setHeaderLines(std::vector<std::string> headerLines);
void parseWeights();
void buildGroups();
std::unique_ptr<WeightGroupInfo> buildGroup(const ParsedWeight& weight);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function could be const. Can you check the other member functions of the Helper classes to see if any of them should also be const?

private:
std::vector<std::string> headerLines_;
};
}

#endif

65 changes: 65 additions & 0 deletions GeneratorInterface/Core/interface/WeightHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef GeneratorInterface_LHEInterface_WeightHelper_h
#define GeneratorInterface_LHEInterface_WeightHelper_h

#include "DataFormats/Common/interface/OwnVector.h"
#include "SimDataFormats/GeneratorProducts/interface/GenWeightProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/WeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/PdfWeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/WeightsInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/UnknownWeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/PdfWeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/ScaleWeightGroupInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/MEParamWeightGroupInfo.h"
#include <boost/algorithm/string.hpp>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this include needed?


namespace gen {
struct PdfSetInfo {
std::string name;
int lhapdfId;
PdfUncertaintyType uncertaintyType;
};

struct ParsedWeight {
std::string id;
size_t index;
std::string groupname;
std::string content;
std::unordered_map<std::string, std::string> attributes;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add #include <unordered_map>

};

class WeightHelper {
public:
WeightHelper();
edm::OwnVector<gen::WeightGroupInfo> weightGroups() {
return weightGroups_;
}
std::unique_ptr<GenWeightProduct> weightProduct(std::vector<gen::WeightsInfo>, float w0);
std::unique_ptr<GenWeightProduct> weightProduct(std::vector<double>, float w0);
void setModel(std::string model) { model_ = model; }
int addWeightToProduct(std::unique_ptr<GenWeightProduct>& product, double weight, std::string name, int weightNum, int groupIndex);
int findContainingWeightGroup(std::string wgtId, int weightIndex, int previousGroupIndex);
protected:
std::string model_;
std::vector<ParsedWeight> parsedWeights_;
const std::vector<PdfSetInfo> pdfSetsInfo;
std::map<std::string, std::string> currWeightAttributeMap_;
std::map<std::string, std::string> currGroupAttributeMap_;
edm::OwnVector<gen::WeightGroupInfo> weightGroups_;
bool isScaleWeightGroup(const ParsedWeight& weight);
bool isMEParamWeightGroup(const ParsedWeight& weight);
bool isPdfWeightGroup(const ParsedWeight& weight);
void updateScaleInfo(const ParsedWeight& weight);
void updatePdfInfo(const ParsedWeight& weight);
std::string searchAttributes(const std::string& label, const ParsedWeight& weight);

// Possible names for the same thing
const std::unordered_map<std::string, std::vector<std::string>> attributeNames_ = {
{"muf", {"muR", "MUR", "muf","facscfact"}},
{"mur", {"muF", "MUF", "mur","renscfact"}},
{"pdf", {"PDF", "PDF set", "lhapdf", "pdf", "pdf set", "pdfset"}}
};
};
}

#endif

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>


99 changes: 99 additions & 0 deletions GeneratorInterface/Core/plugins/GenWeightProductProducer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#include <cstdio>
#include <memory>
#include <vector>
#include <string>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDProducer.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"

#include "FWCore/Framework/interface/Run.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "SimDataFormats/GeneratorProducts/interface/LHERunInfoProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/GenWeightInfoProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/GenLumiInfoHeader.h"

#include "GeneratorInterface/Core/interface/GenWeightHelper.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include <boost/algorithm/string.hpp>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this include needed?


class GenWeightProductProducer : public edm::one::EDProducer<edm::BeginLuminosityBlockProducer> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be a one producer? What thread-unsafe accesses or operations are used?

public:
explicit GenWeightProductProducer(const edm::ParameterSet& iConfig);
~GenWeightProductProducer() override;

private:
std::vector<std::string> weightNames_;
gen::GenWeightHelper weightHelper_;
edm::EDGetTokenT<GenLumiInfoHeader> genLumiInfoToken_;
edm::EDGetTokenT<GenEventInfoProduct> genEventToken_;
const edm::EDGetTokenT<GenLumiInfoHeader> genLumiInfoHeadTag_;

void produce(edm::Event&, const edm::EventSetup&) override;
void beginLuminosityBlockProduce(edm::LuminosityBlock& lb, edm::EventSetup const& c) override;
};

//
// constructors and destructor
//
GenWeightProductProducer::GenWeightProductProducer(const edm::ParameterSet& iConfig) :
genLumiInfoToken_(consumes<GenLumiInfoHeader, edm::InLumi>(iConfig.getParameter<edm::InputTag>("genInfo"))),
genEventToken_(consumes<GenEventInfoProduct>(iConfig.getParameter<edm::InputTag>("genInfo"))),
genLumiInfoHeadTag_(mayConsume<GenLumiInfoHeader, edm::InLumi>(iConfig.getParameter<edm::InputTag>("genLumiInfoHeader")))
{
produces<GenWeightProduct>();
produces<GenWeightInfoProduct, edm::Transition::BeginLuminosityBlock>();
}


GenWeightProductProducer::~GenWeightProductProducer()
{
}


// ------------ method called to produce the data ------------
void
GenWeightProductProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
edm::Handle<GenEventInfoProduct> genEventInfo;
iEvent.getByToken(genEventToken_, genEventInfo);

float centralWeight = genEventInfo->weights().size() > 0 ? genEventInfo->weights().at(0) : 1.;
auto weightProduct = weightHelper_.weightProduct(genEventInfo->weights(), centralWeight);
iEvent.put(std::move(weightProduct));
}

void
GenWeightProductProducer::beginLuminosityBlockProduce(edm::LuminosityBlock& iLumi, edm::EventSetup const& iSetup) {
edm::Handle<GenLumiInfoHeader> genLumiInfoHead;
iLumi.getByToken(genLumiInfoHeadTag_, genLumiInfoHead);
if (genLumiInfoHead.isValid()) {
std::string label = genLumiInfoHead->configDescription();
boost::replace_all(label,"-","_");
weightHelper_.setModel(label);
}

if (weightNames_.size() == 0) {
edm::Handle<GenLumiInfoHeader> genLumiInfoHandle;
iLumi.getByToken(genLumiInfoToken_, genLumiInfoHandle);

weightNames_ = genLumiInfoHandle->weightNames();
weightHelper_.parseWeightGroupsFromNames(weightNames_);
}
auto weightInfoProduct = std::make_unique<GenWeightInfoProduct>();
for (auto& weightGroup : weightHelper_.weightGroups()) {
weightInfoProduct->addWeightGroupInfo(weightGroup.clone());
}
iLumi.put(std::move(weightInfoProduct));
}

DEFINE_FWK_MODULE(GenWeightProductProducer);


Loading