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
 
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
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () 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::vector< ModuleDescription const * > &modules, 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)
 

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::HepMCProduct_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
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<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 32 of file HTXSRivetProducer.cc.

Constructor & Destructor Documentation

◆ HTXSRivetProducer()

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

Definition at line 34 of file HTXSRivetProducer.cc.

35  : _hepmcCollection(consumes<HepMCProduct>(cfg.getParameter<edm::InputTag>("HepMCCollection"))),
36  _lheRunInfo(consumes<LHERunInfoProduct, edm::InRun>(cfg.getParameter<edm::InputTag>("LHERunInfo"))) {
37  usesResource("Rivet");
38  _prodMode = cfg.getParameter<string>("ProductionMode");
40  _HTXS = nullptr;
41  _analysisHandler = nullptr;
42  produces<HTXS::HiggsClassification>("HiggsClassification").setBranchAlias("HiggsClassification");
43  }

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

Member Function Documentation

◆ beginRun()

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

Definition at line 168 of file HTXSRivetProducer.cc.

168  {
169  if (_prodMode == "AUTO") {
171  bool product_exists = iRun.getByLabel(edm::InputTag("externalLHEProducer"), run);
172  if (product_exists) {
173  typedef std::vector<LHERunInfoProduct::Header>::const_iterator headers_const_iterator;
174  LHERunInfoProduct myLHERunInfoProduct = *(run.product());
175  for (headers_const_iterator iter = myLHERunInfoProduct.headers_begin(); iter != myLHERunInfoProduct.headers_end();
176  iter++) {
177  std::vector<std::string> lines = iter->lines();
178  for (unsigned int iLine = 0; iLine < lines.size(); iLine++) {
179  std::string line = lines.at(iLine);
180  // POWHEG
181  if (line.find("gg_H_quark-mass-effects") != std::string::npos) {
182  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
184  break;
185  }
186  if (line.find("Process: HJ") != std::string::npos) {
187  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
189  break;
190  }
191  if (line.find("Process: HJJ") != std::string::npos) {
192  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
194  break;
195  }
196  if (line.find("VBF_H") != std::string::npos) {
197  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
199  break;
200  }
201  if (line.find("HZJ") != std::string::npos) {
202  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
204  break;
205  }
206  if (line.find("ggHZ") != std::string::npos) {
207  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
209  break;
210  }
211  // MC@NLO
212  if (line.find("ggh012j") != std::string::npos) {
213  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
215  break;
216  }
217  if (line.find("vbfh") != std::string::npos) {
218  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
220  break;
221  }
222  if (line.find("zh012j") != std::string::npos) {
223  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
225  break;
226  }
227  if (line.find("ggzh01j") != std::string::npos) {
228  edm::LogInfo("HTXSRivetProducer") << iLine << " " << line << std::endl;
230  break;
231  }
232  }
233 
235  break;
236  }
237  }
238  }
239 }

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.

◆ endRun()

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

Definition at line 166 of file HTXSRivetProducer.cc.

◆ produce()

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

Implements edm::one::EDProducerBase.

Definition at line 63 of file HTXSRivetProducer.cc.

63  {
64  //get the hepmc product from the event
66 
67  bool product_exists = iEvent.getByToken(_hepmcCollection, evt);
68  if (product_exists) {
69  // get HepMC GenEvent
70  const HepMC::GenEvent* myGenEvent = evt->GetEvent();
71 
72  if (_prodMode == "AUTO") {
73  // for these prod modes, don't change what is set in BeginRun
75  unsigned nWs = 0;
76  unsigned nZs = 0;
77  unsigned nTs = 0;
78  unsigned nBs = 0;
79  unsigned nHs = 0;
80 
81  HepMC::GenVertex* HSvtx = myGenEvent->signal_process_vertex();
82 
83  if (HSvtx) {
84  for (auto ptcl : HepMCUtils::particles(HSvtx, HepMC::children)) {
85  if (std::abs(ptcl->pdg_id()) == 24)
86  ++nWs;
87  if (ptcl->pdg_id() == 23)
88  ++nZs;
89  if (abs(ptcl->pdg_id()) == 6)
90  ++nTs;
91  if (abs(ptcl->pdg_id()) == 5)
92  ++nBs;
93  if (ptcl->pdg_id() == 25)
94  ++nHs;
95  }
96  }
97 
98  if (nZs == 1 && nHs == 1 && (nWs + nTs) == 0) {
100  } else if (nWs == 1 && nHs == 1 && (nZs + nTs) == 0) {
102  } else if (nTs == 2 && nHs == 1 && nZs == 0) {
104  } else if (nTs == 1 && nHs == 1 && nZs == 0) {
106  } else if (nBs == 2 && nHs == 1 && nZs == 0) {
108  }
109  }
110  }
111 
112  if (!_HTXS || !_HTXS->hasProjection("FS")) {
113  _analysisHandler = std::make_unique<Rivet::AnalysisHandler>();
115  _analysisHandler->addAnalysis(_HTXS);
116 
117  // set the production mode if not done already
118  if (_prodMode == "GGF")
120  else if (_prodMode == "VBF")
122  else if (_prodMode == "WH")
124  else if (_prodMode == "ZH")
126  else if (_prodMode == "QQ2ZH")
128  else if (_prodMode == "GG2ZH")
130  else if (_prodMode == "TTH")
132  else if (_prodMode == "BBH")
134  else if (_prodMode == "TH")
136  else if (_prodMode == "AUTO") {
137  edm::LogInfo("HTXSRivetProducer")
138  << "Using AUTO for HiggsProdMode, found it to be: " << m_HiggsProdMode << "\n";
139  edm::LogInfo("HTXSRivetProducer")
140  << "(UNKNOWN=0, GGF=1, VBF=2, WH=3, QQ2ZH=4, GG2ZH=5, TTH=6, BBH=7, TH=8)" << endl;
141  } else {
142  throw cms::Exception("HTXSRivetProducer")
143  << "ProductionMode must be one of: GGF,VBF,WH,ZH,QQ2ZH,GG2ZH,TTH,BBH,TH,AUTO ";
144  }
146 
147  // at this point the production mode must be known
149  edm::LogInfo("HTXSRivetProducer") << "HTXSRivetProducer WARNING: HiggsProduction mode is UNKNOWN" << endl;
150  }
151 
152  // initialize rivet analysis
153  _analysisHandler->init(*myGenEvent);
154  }
155 
156  // classify the event
157  Rivet::HiggsClassification rivet_cat = _HTXS->classifyEvent(*myGenEvent, m_HiggsProdMode);
158  cat_ = HTXS::Rivet2Root(rivet_cat);
159 
160  unique_ptr<HTXS::HiggsClassification> cat(new HTXS::HiggsClassification(cat_));
161 
162  iEvent.put(std::move(cat), "HiggsClassification");
163  }
164 }

References funct::abs(), HTXS::BBH, eostools::cat(), class-composition::children, Exception, edm::HepMCProduct::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.

Member Data Documentation

◆ _analysisHandler

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

Definition at line 54 of file HTXSRivetProducer.cc.

◆ _hepmcCollection

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

Definition at line 51 of file HTXSRivetProducer.cc.

◆ _HTXS

Rivet::HiggsTemplateCrossSections* HTXSRivetProducer::_HTXS
private

Definition at line 55 of file HTXSRivetProducer.cc.

◆ _lheRunInfo

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

Definition at line 52 of file HTXSRivetProducer.cc.

◆ _prodMode

std::string HTXSRivetProducer::_prodMode
private

Definition at line 57 of file HTXSRivetProducer.cc.

◆ cat_

HTXS::HiggsClassification HTXSRivetProducer::cat_
private

Definition at line 60 of file HTXSRivetProducer.cc.

◆ m_HiggsProdMode

HTXS::HiggsProdMode HTXSRivetProducer::m_HiggsProdMode
private

Definition at line 58 of file HTXSRivetProducer.cc.

Rivet::HiggsTemplateCrossSections::printClassificationSummary
void printClassificationSummary()
Definition: HiggsTemplateCrossSections.cc:1044
HTXS::GG2ZH
Definition: HiggsTemplateCrossSections.h:25
HTXS::UNKNOWN
Definition: HiggsTemplateCrossSections.h:25
HTXS::TTH
Definition: HiggsTemplateCrossSections.h:25
HTXSRivetProducer::_lheRunInfo
edm::EDGetTokenT< LHERunInfoProduct > _lheRunInfo
Definition: HTXSRivetProducer.cc:52
class-composition.children
children
Definition: class-composition.py:88
eostools.cat
def cat(path)
Definition: eostools.py:401
HTXS::GGF
Definition: HiggsTemplateCrossSections.h:25
Rivet::HiggsTemplateCrossSections
Rivet routine for classifying MC events according to the Higgs template cross section categories.
Definition: HiggsTemplateCrossSections.cc:21
LHERunInfoProduct::headers_end
headers_const_iterator headers_end() const
Definition: LHERunInfoProduct.h:59
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
HTXSRivetProducer::m_HiggsProdMode
HTXS::HiggsProdMode m_HiggsProdMode
Definition: HTXSRivetProducer.cc:58
HTXSRivetProducer::_analysisHandler
std::unique_ptr< Rivet::AnalysisHandler > _analysisHandler
Definition: HTXSRivetProducer.cc:54
LHERunInfoProduct::headers_begin
headers_const_iterator headers_begin() const
Definition: LHERunInfoProduct.h:58
LHERunInfoProduct
Definition: LHERunInfoProduct.h:13
HTXS::Rivet2Root
HTXS::HiggsClassification Rivet2Root(category const &htxs_cat_rivet)
Definition: HiggsTemplateCrossSections.h:548
HTXSRivetProducer::_HTXS
Rivet::HiggsTemplateCrossSections * _HTXS
Definition: HTXSRivetProducer.cc:55
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
groupFilesInBlocks.lines
lines
Definition: groupFilesInBlocks.py:95
HTXSRivetProducer::_hepmcCollection
edm::EDGetTokenT< edm::HepMCProduct > _hepmcCollection
Definition: HTXSRivetProducer.cc:51
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
looper.cfg
cfg
Definition: looper.py:297
HTXSRivetProducer::cat_
HTXS::HiggsClassification cat_
Definition: HTXSRivetProducer.cc:60
eostools.move
def move(src, dest)
Definition: eostools.py:511
HTXS::HiggsClassification
Definition: HiggsTemplateCrossSections.h:514
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Exception
Definition: hltDiff.cc:246
Rivet::HiggsTemplateCrossSections::setHiggsProdMode
void setHiggsProdMode(HTXS::HiggsProdMode prodMode)
Sets the Higgs production mode.
Definition: HiggsTemplateCrossSections.cc:943
HTXSRivetProducer::_prodMode
std::string _prodMode
Definition: HTXSRivetProducer.cc:57
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HTXS::TH
Definition: HiggsTemplateCrossSections.h:25
mps_splice.line
line
Definition: mps_splice.py:76
edm::InputTag
Definition: InputTag.h:15
HTXS::WH
Definition: HiggsTemplateCrossSections.h:25
Rivet::HiggsTemplateCrossSections::classifyEvent
HiggsClassification classifyEvent(const Event &event, const HTXS::HiggsProdMode prodMode)
Main classificaion method.
Definition: HiggsTemplateCrossSections.cc:122
HTXS::VBF
Definition: HiggsTemplateCrossSections.h:25
HTXS::BBH
Definition: HiggsTemplateCrossSections.h:25
HTXS::QQ2ZH
Definition: HiggsTemplateCrossSections.h:25