CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Attributes
LHETablesProducer Class Reference
Inheritance diagram for LHETablesProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

std::unique_ptr< nanoaod::FlatTablefillLHEObjectTable (const LHEEventProduct &lheProd, nanoaod::FlatTable &out) const
 
 LHETablesProducer (edm::ParameterSet const &params)
 
void produce (edm::StreamID id, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
 
 ~LHETablesProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Attributes

const std::vector< edm::EDGetTokenT< LHEEventProduct > > lheTag_
 
const unsigned int precision_
 
const bool storeLHEParticles_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- 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 14 of file LHETablesProducer.cc.

Constructor & Destructor Documentation

◆ LHETablesProducer()

LHETablesProducer::LHETablesProducer ( edm::ParameterSet const &  params)
inline

Definition at line 16 of file LHETablesProducer.cc.

17  : lheTag_(edm::vector_transform(params.getParameter<std::vector<edm::InputTag>>("lheInfo"),
18  [this](const edm::InputTag& tag) { return mayConsume<LHEEventProduct>(tag); })),
19  precision_(params.getParameter<int>("precision")),
20  storeLHEParticles_(params.getParameter<bool>("storeLHEParticles")) {
21  produces<nanoaod::FlatTable>("LHE");
23  produces<nanoaod::FlatTable>("LHEPart");
24  }

References GlobalPosition_Frontier_DevDB_cff::tag.

◆ ~LHETablesProducer()

LHETablesProducer::~LHETablesProducer ( )
inlineoverride

Definition at line 26 of file LHETablesProducer.cc.

26 {}

Member Function Documentation

◆ fillDescriptions()

static void LHETablesProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 160 of file LHETablesProducer.cc.

160  {
162  desc.add<std::vector<edm::InputTag>>("lheInfo", std::vector<edm::InputTag>{{"externalLHEProducer"}, {"source"}})
163  ->setComment("tag(s) for the LHE information (LHEEventProduct)");
164  desc.add<int>("precision", -1)->setComment("precision on the 4-momenta of the LHE particles");
165  desc.add<bool>("storeLHEParticles", false)
166  ->setComment("Whether we want to store the 4-momenta of the status 1 particles at LHE level");
167  descriptions.add("lheInfoTable", desc);
168  }

References edm::ConfigurationDescriptions::add(), and submitPVResolutionJobs::desc.

◆ fillLHEObjectTable()

std::unique_ptr<nanoaod::FlatTable> LHETablesProducer::fillLHEObjectTable ( const LHEEventProduct lheProd,
nanoaod::FlatTable out 
) const
inline

Definition at line 51 of file LHETablesProducer.cc.

52  {
53  double lheHT = 0, lheHTIncoming = 0;
54  unsigned int lheNj = 0, lheNb = 0, lheNc = 0, lheNuds = 0, lheNglu = 0;
55  double lheVpt = 0;
56  double alphaS = 0;
57 
58  const auto& hepeup = lheProd.hepeup();
59  const auto& pup = hepeup.PUP;
60  int lep = -1, lepBar = -1, nu = -1, nuBar = -1;
61  std::vector<float> vals_pt;
62  std::vector<float> vals_eta;
63  std::vector<float> vals_phi;
64  std::vector<float> vals_mass;
65  std::vector<float> vals_pz;
66  std::vector<int> vals_pid;
67  std::vector<int> vals_status;
68  std::vector<int> vals_spin;
69  alphaS = hepeup.AQCDUP;
70  for (unsigned int i = 0, n = pup.size(); i < n; ++i) {
71  int status = hepeup.ISTUP[i];
72  int idabs = std::abs(hepeup.IDUP[i]);
73  if (status == 1 || status == -1) {
74  TLorentzVector p4(pup[i][0], pup[i][1], pup[i][2], pup[i][3]); // x,y,z,t
75  vals_pid.push_back(hepeup.IDUP[i]);
76  vals_spin.push_back(hepeup.SPINUP[i]);
77  vals_status.push_back(status);
78  if (status == -1) {
79  vals_pt.push_back(0);
80  vals_eta.push_back(0);
81  vals_phi.push_back(0);
82  vals_mass.push_back(0);
83  vals_pz.push_back(p4.Pz());
84  } else {
85  vals_pt.push_back(p4.Pt());
86  vals_eta.push_back(p4.Eta());
87  vals_phi.push_back(p4.Phi());
88  vals_mass.push_back(p4.M());
89  vals_pz.push_back(0);
90  }
91  }
92  if ((status == 1) && ((idabs == 21) || (idabs > 0 && idabs < 7))) { //# gluons and quarks
93  // object counters
94  lheNj++;
95  if (idabs == 5)
96  lheNb++;
97  else if (idabs == 4)
98  lheNc++;
99  else if (idabs <= 3)
100  lheNuds++;
101  else if (idabs == 21)
102  lheNglu++;
103  // HT
104  double pt = std::hypot(pup[i][0], pup[i][1]); // first entry is px, second py
105  lheHT += pt;
106  int mothIdx = std::max(
107  hepeup.MOTHUP[i].first - 1,
108  0); //first and last mother as pair; first entry has index 1 in LHE; incoming particles return motherindex 0
109  int mothIdxTwo = std::max(hepeup.MOTHUP[i].second - 1, 0);
110  int mothStatus = hepeup.ISTUP[mothIdx];
111  int mothStatusTwo = hepeup.ISTUP[mothIdxTwo];
112  bool hasIncomingAsMother = mothStatus < 0 || mothStatusTwo < 0;
113  if (hasIncomingAsMother)
114  lheHTIncoming += pt;
115  } else if (idabs == 12 || idabs == 14 || idabs == 16) {
116  (hepeup.IDUP[i] > 0 ? nu : nuBar) = i;
117  } else if (idabs == 11 || idabs == 13 || idabs == 15) {
118  (hepeup.IDUP[i] > 0 ? lep : lepBar) = i;
119  }
120  }
121  std::pair<int, int> v(0, 0);
122  if (lep != -1 && lepBar != -1)
123  v = std::make_pair(lep, lepBar);
124  else if (lep != -1 && nuBar != -1)
125  v = std::make_pair(lep, nuBar);
126  else if (nu != -1 && lepBar != -1)
127  v = std::make_pair(nu, lepBar);
128  else if (nu != -1 && nuBar != -1)
129  v = std::make_pair(nu, nuBar);
130  if (v.first != -1 && v.second != -1) {
131  lheVpt = std::hypot(pup[v.first][0] + pup[v.second][0], pup[v.first][1] + pup[v.second][1]);
132  }
133 
134  out.addColumnValue<uint8_t>("Njets", lheNj, "Number of jets (partons) at LHE step");
135  out.addColumnValue<uint8_t>("Nb", lheNb, "Number of b partons at LHE step");
136  out.addColumnValue<uint8_t>("Nc", lheNc, "Number of c partons at LHE step");
137  out.addColumnValue<uint8_t>("Nuds", lheNuds, "Number of u,d,s partons at LHE step");
138  out.addColumnValue<uint8_t>("Nglu", lheNglu, "Number of gluon partons at LHE step");
139  out.addColumnValue<float>("HT", lheHT, "HT, scalar sum of parton pTs at LHE step");
140  out.addColumnValue<float>(
141  "HTIncoming", lheHTIncoming, "HT, scalar sum of parton pTs at LHE step, restricted to partons");
142  out.addColumnValue<float>("Vpt", lheVpt, "pT of the W or Z boson at LHE step");
143  out.addColumnValue<uint8_t>("NpNLO", lheProd.npNLO(), "number of partons at NLO");
144  out.addColumnValue<uint8_t>("NpLO", lheProd.npLO(), "number of partons at LO");
145  out.addColumnValue<float>("AlphaS", alphaS, "Per-event alphaS");
146 
147  auto outPart = std::make_unique<nanoaod::FlatTable>(vals_pt.size(), "LHEPart", false);
148  outPart->addColumn<float>("pt", vals_pt, "Pt of LHE particles", this->precision_);
149  outPart->addColumn<float>("eta", vals_eta, "Pseodorapidity of LHE particles", this->precision_);
150  outPart->addColumn<float>("phi", vals_phi, "Phi of LHE particles", this->precision_);
151  outPart->addColumn<float>("mass", vals_mass, "Mass of LHE particles", this->precision_);
152  outPart->addColumn<float>("incomingpz", vals_pz, "Pz of incoming LHE particles", this->precision_);
153  outPart->addColumn<int>("pdgId", vals_pid, "PDG ID of LHE particles");
154  outPart->addColumn<int>("status", vals_status, "LHE particle status; -1:incoming, 1:outgoing");
155  outPart->addColumn<int>("spin", vals_spin, "Spin of LHE particles");
156 
157  return outPart;
158  }

References funct::abs(), LHEEventProduct::hepeup(), mps_fire::i, SiStripPI::max, dqmiodumpmetadata::n, LHEEventProduct::npLO(), LHEEventProduct::npNLO(), MillePedeFileConverter_cfg::out, p4, precision_, DiDispStaMuonMonitor_cfi::pt, lhef::HEPEUP::PUP, mps_update::status, and findQualityFiles::v.

Referenced by produce().

◆ produce()

void LHETablesProducer::produce ( edm::StreamID  id,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
inlineoverridevirtual

Implements edm::global::EDProducerBase.

Definition at line 28 of file LHETablesProducer.cc.

28  {
29  auto lheTab = std::make_unique<nanoaod::FlatTable>(1, "LHE", true);
30 
32  for (const auto& lheTag : lheTag_) {
33  iEvent.getByToken(lheTag, lheInfo);
34  if (lheInfo.isValid()) {
35  break;
36  }
37  }
38  if (lheInfo.isValid()) {
39  auto lhePartTab = fillLHEObjectTable(*lheInfo, *lheTab);
41  iEvent.put(std::move(lhePartTab), "LHEPart");
42  } else {
43  if (storeLHEParticles_) { // need to store a dummy table anyway to make the framework happy
44  auto lhePartTab = std::make_unique<nanoaod::FlatTable>(1, "LHEPart", true);
45  iEvent.put(std::move(lhePartTab), "LHEPart");
46  }
47  }
48  iEvent.put(std::move(lheTab), "LHE");
49  }

References fillLHEObjectTable(), iEvent, genWeightsTable_cfi::lheInfo, lheTag_, eostools::move(), and storeLHEParticles_.

Member Data Documentation

◆ lheTag_

const std::vector<edm::EDGetTokenT<LHEEventProduct> > LHETablesProducer::lheTag_
protected

Definition at line 171 of file LHETablesProducer.cc.

Referenced by produce().

◆ precision_

const unsigned int LHETablesProducer::precision_
protected

Definition at line 172 of file LHETablesProducer.cc.

Referenced by fillLHEObjectTable().

◆ storeLHEParticles_

const bool LHETablesProducer::storeLHEParticles_
protected

Definition at line 173 of file LHETablesProducer.cc.

Referenced by produce().

mps_fire.i
i
Definition: mps_fire.py:428
LHETablesProducer::precision_
const unsigned int precision_
Definition: LHETablesProducer.cc:172
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
mps_update.status
status
Definition: mps_update.py:69
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
findQualityFiles.v
v
Definition: findQualityFiles.py:179
LHETablesProducer::lheTag_
const std::vector< edm::EDGetTokenT< LHEEventProduct > > lheTag_
Definition: LHETablesProducer.cc:171
edm::Handle
Definition: AssociativeIterator.h:50
LHEEventProduct::npNLO
int npNLO() const
Definition: LHEEventProduct.h:41
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
genWeightsTable_cfi.lheInfo
lheInfo
Definition: genWeightsTable_cfi.py:6
LHETablesProducer::storeLHEParticles_
const bool storeLHEParticles_
Definition: LHETablesProducer.cc:173
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
iEvent
int iEvent
Definition: GenABIO.cc:224
p4
double p4[4]
Definition: TauolaWrapper.h:92
LHEEventProduct::hepeup
const lhef::HEPEUP & hepeup() const
Definition: LHEEventProduct.h:46
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
LHETablesProducer::fillLHEObjectTable
std::unique_ptr< nanoaod::FlatTable > fillLHEObjectTable(const LHEEventProduct &lheProd, nanoaod::FlatTable &out) const
Definition: LHETablesProducer.cc:51
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
lhef::HEPEUP::PUP
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
edm::InputTag
Definition: InputTag.h:15
LHEEventProduct::npLO
int npLO() const
Definition: LHEEventProduct.h:40