CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HTXSRivetProducer Class Reference
Inheritance diagram for HTXSRivetProducer:
edm::one::EDProducer< edm::one::WatchRuns, edm::one::SharedResources > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HTXSRivetProducer (const edm::ParameterSet &cfg)
 
- Public Member Functions inherited from edm::one::EDProducer< edm::one::WatchRuns, edm::one::SharedResources >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginRun (edm::Run const &iRun, edm::EventSetup const &es) override
 
void endRun (edm::Run const &iRun, edm::EventSetup const &es) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::unique_ptr< Rivet::AnalysisHandler > _analysisHandler
 
edm::EDGetTokenT< edm::HepMC3Product_hepmcCollection
 
Rivet::HiggsTemplateCrossSections_HTXS
 
edm::EDGetTokenT< LHERunInfoProduct_lheRunInfo
 
std::string _prodMode
 
HTXS::HiggsClassification cat_
 
HTXS::HiggsProdMode m_HiggsProdMode
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 33 of file HTXSRivetProducer.cc.

Constructor & Destructor Documentation

◆ HTXSRivetProducer()

HTXSRivetProducer::HTXSRivetProducer ( const edm::ParameterSet cfg)
inlineexplicit

Definition at line 35 of file HTXSRivetProducer.cc.

References looper::cfg, and HTXS::UNKNOWN.

36  : _hepmcCollection(consumes<HepMC3Product>(cfg.getParameter<edm::InputTag>("HepMCCollection"))),
37  _lheRunInfo(consumes<LHERunInfoProduct, edm::InRun>(cfg.getParameter<edm::InputTag>("LHERunInfo"))) {
38  usesResource("Rivet");
39  _prodMode = cfg.getParameter<string>("ProductionMode");
41  _HTXS = nullptr;
42  _analysisHandler = nullptr;
43  produces<HTXS::HiggsClassification>("HiggsClassification").setBranchAlias("HiggsClassification");
44  }
HTXS::HiggsProdMode m_HiggsProdMode
std::unique_ptr< Rivet::AnalysisHandler > _analysisHandler
Rivet::HiggsTemplateCrossSections * _HTXS
edm::EDGetTokenT< edm::HepMC3Product > _hepmcCollection
edm::EDGetTokenT< LHERunInfoProduct > _lheRunInfo

Member Function Documentation

◆ beginRun()

void HTXSRivetProducer::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  es 
)
overrideprivate

Definition at line 176 of file HTXSRivetProducer.cc.

References edm::Run::getByLabel(), HTXS::GG2ZH, HTXS::GGF, LHERunInfoProduct::headers_begin(), LHERunInfoProduct::headers_end(), mps_splice::line, groupFilesInBlocks::lines, HTXS::QQ2ZH, writedatasetfile::run, AlCaHLTBitMon_QueryRunRegistry::string, HTXS::UNKNOWN, and HTXS::VBF.

176  {
177  if (_prodMode == "AUTO") {
179  bool product_exists = iRun.getByLabel(edm::InputTag("externalLHEProducer"), run);
180  if (product_exists) {
181  typedef std::vector<LHERunInfoProduct::Header>::const_iterator headers_const_iterator;
182  LHERunInfoProduct myLHERunInfoProduct = *(run.product());
183  for (headers_const_iterator iter = myLHERunInfoProduct.headers_begin(); iter != myLHERunInfoProduct.headers_end();
184  iter++) {
185  std::vector<std::string> lines = iter->lines();
186  for (unsigned int iLine = 0; iLine < lines.size(); iLine++) {
187  std::string line = lines.at(iLine);
188  // POWHEG
189  if (line.find("gg_H_quark-mass-effects") != std::string::npos) {
190  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
192  break;
193  }
194  if (line.find("Process: HJ") != std::string::npos) {
195  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
197  break;
198  }
199  if (line.find("Process: HJJ") != std::string::npos) {
200  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
202  break;
203  }
204  if (line.find("VBF_H") != std::string::npos) {
205  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
207  break;
208  }
209  if (line.find("HZJ") != std::string::npos) {
210  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
212  break;
213  }
214  if (line.find("ggHZ") != std::string::npos) {
215  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
217  break;
218  }
219  // MC@NLO
220  if (line.find("ggh012j") != std::string::npos) {
221  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
223  break;
224  }
225  if (line.find("vbfh") != std::string::npos) {
226  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
228  break;
229  }
230  if (line.find("zh012j") != std::string::npos) {
231  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
233  break;
234  }
235  if (line.find("ggzh01j") != std::string::npos) {
236  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
238  break;
239  }
240  }
241 
243  break;
244  }
245  }
246  }
247 }
headers_const_iterator headers_begin() const
HTXS::HiggsProdMode m_HiggsProdMode
headers_const_iterator headers_end() const
Log< level::Info, false > LogInfo

◆ endRun()

void HTXSRivetProducer::endRun ( edm::Run const &  iRun,
edm::EventSetup const &  es 
)
overrideprivate

Definition at line 171 of file HTXSRivetProducer.cc.

171  {
172  if (_HTXS)
174 }
Rivet::HiggsTemplateCrossSections * _HTXS

◆ produce()

void HTXSRivetProducer::produce ( edm::Event iEvent,
const edm::EventSetup  
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 64 of file HTXSRivetProducer.cc.

References funct::abs(), HTXS::BBH, eostools::cat(), edmPickEvents::event, Exception, edm::HepMC3Product::GetEvent(), HTXS::GG2ZH, HTXS::GGF, iEvent, eostools::move(), ecalTrigSettings_cff::particles, HTXS::QQ2ZH, HTXS::Rivet2Root(), HTXS::TH, HTXS::TTH, HTXS::UNKNOWN, HTXS::VBF, and HTXS::WH.

64  {
65  //get the hepmc product from the event
67 
68  bool product_exists = iEvent.getByToken(_hepmcCollection, evt);
69  if (product_exists) {
70  // get HepMC GenEvent
71  const HepMC3::GenEventData* genEventData = evt->GetEvent();
72  std::unique_ptr<HepMC3::GenEvent> myGenEvent = std::make_unique<HepMC3::GenEvent>();
73  myGenEvent->read_data(*genEventData);
74 
75  if (_prodMode == "AUTO") {
76  // for these prod modes, don't change what is set in BeginRun
78  unsigned nWs = 0;
79  unsigned nZs = 0;
80  unsigned nTs = 0;
81  unsigned nBs = 0;
82  unsigned nHs = 0;
83 
84  ConstGenVertexPtr HSvtx = myGenEvent->vertices()[0];
85 
86  if (HSvtx) {
87  for (auto ptcl : HepMCUtils::particles(HSvtx, Relatives::CHILDREN)) {
88  if (std::abs(ptcl->pdg_id()) == 24)
89  ++nWs;
90  if (ptcl->pdg_id() == 23)
91  ++nZs;
92  if (abs(ptcl->pdg_id()) == 6)
93  ++nTs;
94  if (abs(ptcl->pdg_id()) == 5)
95  ++nBs;
96  if (ptcl->pdg_id() == 25)
97  ++nHs;
98  }
99  }
100 
101  if (nZs == 1 && nHs == 1 && (nWs + nTs) == 0) {
103  } else if (nWs == 1 && nHs == 1 && (nZs + nTs) == 0) {
105  } else if (nTs == 2 && nHs == 1 && nZs == 0) {
107  } else if (nTs == 1 && nHs == 1 && nZs == 0) {
109  } else if (nBs == 2 && nHs == 1 && nZs == 0) {
111  }
112  }
113  }
114 
115  if (!_HTXS || !_HTXS->hasProjection("FS")) {
116  _analysisHandler = std::make_unique<Rivet::AnalysisHandler>();
118  _analysisHandler->addAnalysis(_HTXS);
119 
120  // set the production mode if not done already
121  if (_prodMode == "GGF")
123  else if (_prodMode == "VBF")
125  else if (_prodMode == "WH")
127  else if (_prodMode == "ZH")
129  else if (_prodMode == "QQ2ZH")
131  else if (_prodMode == "GG2ZH")
133  else if (_prodMode == "TTH")
135  else if (_prodMode == "BBH")
137  else if (_prodMode == "TH")
139  else if (_prodMode == "AUTO") {
140  edm::LogInfo("HTXSRivetProducer")
141  << "Using AUTO for HiggsProdMode, found it to be: " << m_HiggsProdMode << "\n";
142  edm::LogInfo("HTXSRivetProducer")
143  << "(UNKNOWN=0, GGF=1, VBF=2, WH=3, QQ2ZH=4, GG2ZH=5, TTH=6, BBH=7, TH=8)" << endl;
144  } else {
145  throw cms::Exception("HTXSRivetProducer")
146  << "ProductionMode must be one of: GGF,VBF,WH,ZH,QQ2ZH,GG2ZH,TTH,BBH,TH,AUTO ";
147  }
149 
150  // at this point the production mode must be known
152  edm::LogInfo("HTXSRivetProducer") << "HTXSRivetProducer WARNING: HiggsProduction mode is UNKNOWN" << endl;
153  }
154 
155  // initialize rivet analysis
156  _analysisHandler->init(*myGenEvent);
157  }
158 
159  // Create the Rivet event wrapper
160  const Rivet::Event event(const_cast<GenEvent&>(*myGenEvent));
161  // classify the event
162  Rivet::HiggsClassification rivet_cat = _HTXS->classifyEvent(event, m_HiggsProdMode);
163  cat_ = HTXS::Rivet2Root(rivet_cat);
164 
165  unique_ptr<HTXS::HiggsClassification> cat(new HTXS::HiggsClassification(cat_));
166 
167  iEvent.put(std::move(cat), "HiggsClassification");
168  }
169 }
HTXS::HiggsProdMode m_HiggsProdMode
std::unique_ptr< Rivet::AnalysisHandler > _analysisHandler
Rivet::HiggsTemplateCrossSections * _HTXS
int iEvent
Definition: GenABIO.cc:224
def cat(path)
Definition: eostools.py:401
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setHiggsProdMode(HTXS::HiggsProdMode prodMode)
Sets the Higgs production mode.
edm::EDGetTokenT< edm::HepMC3Product > _hepmcCollection
HiggsClassification classifyEvent(const Event &event, const HTXS::HiggsProdMode prodMode)
Main classificaion method.
Log< level::Info, false > LogInfo
Rivet routine for classifying MC events according to the Higgs template cross section categories...
HTXS::HiggsClassification Rivet2Root(category const &htxs_cat_rivet)
HTXS::HiggsClassification cat_
def move(src, dest)
Definition: eostools.py:511
const HepMC3::GenEventData * GetEvent() const
Definition: HepMC3Product.h:36
Definition: event.py:1

Member Data Documentation

◆ _analysisHandler

std::unique_ptr<Rivet::AnalysisHandler> HTXSRivetProducer::_analysisHandler
private

Definition at line 55 of file HTXSRivetProducer.cc.

◆ _hepmcCollection

edm::EDGetTokenT<edm::HepMC3Product> HTXSRivetProducer::_hepmcCollection
private

Definition at line 52 of file HTXSRivetProducer.cc.

◆ _HTXS

Rivet::HiggsTemplateCrossSections* HTXSRivetProducer::_HTXS
private

Definition at line 56 of file HTXSRivetProducer.cc.

◆ _lheRunInfo

edm::EDGetTokenT<LHERunInfoProduct> HTXSRivetProducer::_lheRunInfo
private

Definition at line 53 of file HTXSRivetProducer.cc.

◆ _prodMode

std::string HTXSRivetProducer::_prodMode
private

Definition at line 58 of file HTXSRivetProducer.cc.

◆ cat_

HTXS::HiggsClassification HTXSRivetProducer::cat_
private

Definition at line 61 of file HTXSRivetProducer.cc.

◆ m_HiggsProdMode

HTXS::HiggsProdMode HTXSRivetProducer::m_HiggsProdMode
private

Definition at line 59 of file HTXSRivetProducer.cc.