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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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)
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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

Rivet::AnalysisHandler _analysisHandler
 
edm::EDGetTokenT< edm::HepMCProduct_hepmcCollection
 
Rivet::HiggsTemplateCrossSections_HTXS
 
bool _isFirstEvent
 
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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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)
 

Detailed Description

Definition at line 30 of file HTXSRivetProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 32 of file HTXSRivetProducer.cc.

References Ecal2004TBTDCRanges_v1_cff::endRun, edm::ParameterSet::getParameter(), and HTXS::UNKNOWN.

33  : _hepmcCollection(consumes<HepMCProduct>(cfg.getParameter<edm::InputTag>("HepMCCollection"))),
34  _lheRunInfo(consumes<LHERunInfoProduct, edm::InRun>(cfg.getParameter<edm::InputTag>("LHERunInfo"))) {
35  usesResource("Rivet");
36 
38 
39  _isFirstEvent = true;
40  _prodMode = cfg.getParameter<string>("ProductionMode");
42 
43  produces<HTXS::HiggsClassification>("HiggsClassification").setBranchAlias("HiggsClassification");
44  }
T getParameter(std::string const &) const
HTXS::HiggsProdMode m_HiggsProdMode
Rivet::HiggsTemplateCrossSections * _HTXS
Rivet routine for classifying MC events according to the Higgs template cross section categories...
edm::EDGetTokenT< edm::HepMCProduct > _hepmcCollection
edm::EDGetTokenT< LHERunInfoProduct > _lheRunInfo

Member Function Documentation

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

Definition at line 171 of file HTXSRivetProducer.cc.

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

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

Definition at line 169 of file HTXSRivetProducer.cc.

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

Definition at line 65 of file HTXSRivetProducer.cc.

References funct::abs(), HTXS::BBH, eostools::cat(), class-composition::children, Exception, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), HTXS::GG2ZH, HTXS::GGF, eostools::move(), HadronAndPartonSelector_cfi::particles, edm::Event::put(), HTXS::QQ2ZH, HTXS::Rivet2Root(), HTXS::TH, HTXS::TTH, HTXS::UNKNOWN, HTXS::VBF, and HTXS::WH.

65  {
66  //get the hepmc product from the event
68 
69  bool product_exists = iEvent.getByToken(_hepmcCollection, evt);
70  if (product_exists) {
71  // get HepMC GenEvent
72  const HepMC::GenEvent* myGenEvent = evt->GetEvent();
73 
74  if (_prodMode == "AUTO") {
75  // for these prod modes, don't change what is set in BeginRun
77  unsigned nWs = 0;
78  unsigned nZs = 0;
79  unsigned nTs = 0;
80  unsigned nBs = 0;
81  unsigned nHs = 0;
82 
83  HepMC::GenVertex* HSvtx = myGenEvent->signal_process_vertex();
84 
85  if (HSvtx) {
86  for (auto ptcl : particles(HSvtx, HepMC::children)) {
87  if (std::abs(ptcl->pdg_id()) == 24)
88  ++nWs;
89  if (ptcl->pdg_id() == 23)
90  ++nZs;
91  if (abs(ptcl->pdg_id()) == 6)
92  ++nTs;
93  if (abs(ptcl->pdg_id()) == 5)
94  ++nBs;
95  if (ptcl->pdg_id() == 25)
96  ++nHs;
97  }
98  }
99 
100  if (nZs == 1 && nHs == 1 && (nWs + nTs) == 0) {
102  } else if (nWs == 1 && nHs == 1 && (nZs + nTs) == 0) {
104  } else if (nTs == 2 && nHs == 1 && nZs == 0) {
106  } else if (nTs == 1 && nHs == 1 && nZs == 0) {
108  } else if (nBs == 2 && nHs == 1 && nZs == 0) {
110  }
111 
113  }
114  }
115 
116  if (_isFirstEvent) {
117  _analysisHandler.addAnalysis(_HTXS);
118 
119  // set the production mode if not done already
120  if (_prodMode == "GGF")
122  else if (_prodMode == "VBF")
124  else if (_prodMode == "WH")
126  else if (_prodMode == "ZH")
128  else if (_prodMode == "QQ2ZH")
130  else if (_prodMode == "GG2ZH")
132  else if (_prodMode == "TTH")
134  else if (_prodMode == "BBH")
136  else if (_prodMode == "TH")
138  else if (_prodMode == "AUTO") {
139  edm::LogInfo("HTXSRivetProducer")
140  << "Using AUTO for HiggsProdMode, found it to be: " << m_HiggsProdMode << "\n";
141  edm::LogInfo("HTXSRivetProducer")
142  << "(UNKNOWN=0, GGF=1, VBF=2, WH=3, QQ2ZH=4, GG2ZH=5, TTH=6, BBH=7, TH=8)" << endl;
143  } else {
144  throw cms::Exception("HTXSRivetProducer")
145  << "ProductionMode must be one of: GGF,VBF,WH,ZH,QQ2ZH,GG2ZH,TTH,BBH,TH,AUTO ";
146  }
148 
149  // at this point the production mode must be known
151  edm::LogInfo("HTXSRivetProducer") << "HTXSRivetProducer WARNING: HiggsProduction mode is UNKNOWN" << endl;
152  }
153 
154  // initialize rivet analysis
155  _analysisHandler.init(*myGenEvent);
156  _isFirstEvent = false;
157  }
158 
159  // classify the event
160  Rivet::HiggsClassification rivet_cat = _HTXS->classifyEvent(*myGenEvent, m_HiggsProdMode);
161  cat_ = HTXS::Rivet2Root(rivet_cat);
162 
163  unique_ptr<HTXS::HiggsClassification> cat(new HTXS::HiggsClassification(cat_));
164 
165  iEvent.put(std::move(cat), "HiggsClassification");
166  }
167 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
HTXS::HiggsProdMode m_HiggsProdMode
Rivet::AnalysisHandler _analysisHandler
Rivet::HiggsTemplateCrossSections * _HTXS
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.
HiggsClassification classifyEvent(const Event &event, const HTXS::HiggsProdMode prodMode)
Main classificaion method.
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
edm::EDGetTokenT< edm::HepMCProduct > _hepmcCollection
HTXS::HiggsClassification Rivet2Root(category const &htxs_cat_rivet)
HTXS::HiggsClassification cat_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

Rivet::AnalysisHandler HTXSRivetProducer::_analysisHandler
private

Definition at line 55 of file HTXSRivetProducer.cc.

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

Definition at line 52 of file HTXSRivetProducer.cc.

Rivet::HiggsTemplateCrossSections* HTXSRivetProducer::_HTXS
private

Definition at line 56 of file HTXSRivetProducer.cc.

bool HTXSRivetProducer::_isFirstEvent
private

Definition at line 58 of file HTXSRivetProducer.cc.

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

Definition at line 53 of file HTXSRivetProducer.cc.

std::string HTXSRivetProducer::_prodMode
private

Definition at line 59 of file HTXSRivetProducer.cc.

HTXS::HiggsClassification HTXSRivetProducer::cat_
private

Definition at line 62 of file HTXSRivetProducer.cc.

HTXS::HiggsProdMode HTXSRivetProducer::m_HiggsProdMode
private

Definition at line 60 of file HTXSRivetProducer.cc.