CMS 3D CMS Logo

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

Public Member Functions

 HTXSRivetProducer (const edm::ParameterSet &cfg)
 
 ~HTXSRivetProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::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
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob ()
 
void beginRun (edm::Run const &iRun, edm::EventSetup const &es) override
 
void endJob ()
 
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::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase 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::stream::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 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 31 of file HTXSRivetProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 34 of file HTXSRivetProducer.cc.

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

34  :
35  _hepmcCollection(consumes<HepMCProduct>(cfg.getParameter<edm::InputTag>("HepMCCollection"))),
36  _lheRunInfo(consumes<LHERunInfoProduct,edm::InRun>(cfg.getParameter<edm::InputTag>("LHERunInfo")))
37  {
39 
40  _isFirstEvent = true;
41  _prodMode = cfg.getParameter<string>("ProductionMode");
43 
44  produces<HTXS::HiggsClassification>("HiggsClassification").setBranchAlias("HiggsClassification");
45 
46  }
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
HTXSRivetProducer::~HTXSRivetProducer ( )
override

Definition at line 72 of file HTXSRivetProducer.cc.

72  {
73 }

Member Function Documentation

void HTXSRivetProducer::beginJob ( void  )
private

Definition at line 75 of file HTXSRivetProducer.cc.

75  {
76  _analysisHandler.addAnalysis(_HTXS);
77 }
Rivet::AnalysisHandler _analysisHandler
Rivet::HiggsTemplateCrossSections * _HTXS
void HTXSRivetProducer::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  es 
)
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 180 of file HTXSRivetProducer.cc.

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

180  {
181 
182  if (_prodMode == "AUTO") {
183 
185  bool product_exists = iRun.getByLabel( edm::InputTag("externalLHEProducer"), run );
186  if( product_exists ){
187 
188  typedef std::vector<LHERunInfoProduct::Header>::const_iterator headers_const_iterator;
189  LHERunInfoProduct myLHERunInfoProduct = *(run.product());
190  for (headers_const_iterator iter=myLHERunInfoProduct.headers_begin(); iter!=myLHERunInfoProduct.headers_end(); iter++){
191  std::vector<std::string> lines = iter->lines();
192  for (unsigned int iLine = 0; iLine<lines.size(); iLine++) {
193  std::string line=lines.at(iLine);
194  // POWHEG
195  if (line.find("gg_H_quark-mass-effects") != std::string::npos) {
196  edm::LogInfo ("HTXSRivetProducer") <<iLine<< " "<<line<<std::endl;
198  break;
199  }
200  if (line.find("Process: HJ") != std::string::npos) {
201  edm::LogInfo ("HTXSRivetProducer") <<iLine<< " "<<line<<std::endl;
203  break;
204  }
205  if (line.find("Process: HJJ") != std::string::npos) {
206  edm::LogInfo ("HTXSRivetProducer") <<iLine<< " "<<line<<std::endl;
208  break;
209  }
210  if (line.find("VBF_H") != std::string::npos) {
211  edm::LogInfo ("HTXSRivetProducer") <<iLine<< " "<<line<<std::endl;
213  break;
214  }
215  if (line.find("HZJ") != std::string::npos) {
216  edm::LogInfo ("HTXSRivetProducer") <<iLine<< " "<<line<<std::endl;
218  break;
219  }
220  if (line.find("ggHZ") != std::string::npos) {
221  edm::LogInfo ("HTXSRivetProducer") <<iLine<< " "<<line<<std::endl;
223  break;
224  }
225  // MC@NLO
226  if (line.find("ggh012j") != std::string::npos) {
227  edm::LogInfo ("HTXSRivetProducer") <<iLine<< " "<<line<<std::endl;
229  break;
230  }
231  if (line.find("vbfh") != std::string::npos) {
232  edm::LogInfo ("HTXSRivetProducer") <<iLine<< " "<<line<<std::endl;
234  break;
235  }
236  if (line.find("zh012j") != std::string::npos) {
237  edm::LogInfo ("HTXSRivetProducer") <<iLine<< " "<<line<<std::endl;
239  break;
240  }
241  if (line.find("ggzh01j") != std::string::npos) {
242  edm::LogInfo ("HTXSRivetProducer") <<iLine<< " "<<line<<std::endl;
244  break;
245  }
246  }
247 
248  if ( m_HiggsProdMode != HTXS::UNKNOWN) break;
249  }
250  }
251  }
252 }
headers_const_iterator headers_end() const
HTXS::HiggsProdMode m_HiggsProdMode
headers_const_iterator headers_begin() const
T const * product() const
Definition: Handle.h:81
void HTXSRivetProducer::endJob ( void  )
private

Definition at line 172 of file HTXSRivetProducer.cc.

172  {
174 }
Rivet::HiggsTemplateCrossSections * _HTXS
void HTXSRivetProducer::endRun ( edm::Run const &  iRun,
edm::EventSetup const &  es 
)
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 176 of file HTXSRivetProducer.cc.

177 {
178 }
void HTXSRivetProducer::produce ( edm::Event iEvent,
const edm::EventSetup  
)
overrideprivate

Definition at line 79 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.

79  {
80 
81  //get the hepmc product from the event
83 
84  bool product_exists = iEvent.getByToken(_hepmcCollection, evt);
85  if( product_exists ){
86 
87  // get HepMC GenEvent
88  const HepMC::GenEvent *myGenEvent = evt->GetEvent();
89 
90  if (_prodMode == "AUTO") {
91 
92  // for these prod modes, don't change what is set in BeginRun
94 
95  unsigned nWs = 0;
96  unsigned nZs = 0;
97  unsigned nTs = 0;
98  unsigned nBs = 0;
99  unsigned nHs = 0;
100 
101  HepMC::GenVertex *HSvtx = myGenEvent->signal_process_vertex();
102 
103  if(HSvtx){
104  for (auto ptcl:particles(HSvtx,HepMC::children)) {
105  if (std::abs(ptcl->pdg_id()) == 24) ++nWs;
106  if (ptcl->pdg_id() == 23) ++nZs;
107  if (abs(ptcl->pdg_id()) == 6) ++nTs;
108  if (abs(ptcl->pdg_id()) == 5) ++nBs;
109  if (ptcl->pdg_id() == 25) ++nHs;
110  }
111  }
112 
113  if (nZs==1 && nHs==1 && (nWs+nTs)==0) {
115  } else if (nWs==1 && nHs==1 && (nZs+nTs)==0) {
117  } else if (nTs==2 && nHs==1 && nZs==0) {
119  } else if (nTs==1 && nHs==1 && nZs==0) {
121  } else if (nBs==2 && nHs==1 && nZs==0) {
123  }
124 
126 
127  }
128  }
129 
130 
131  if (_isFirstEvent){
132 
133  // set the production mode if not done already
134  if ( _prodMode == "GGF" ) m_HiggsProdMode = HTXS::GGF;
135  else if ( _prodMode == "VBF" ) m_HiggsProdMode = HTXS::VBF;
136  else if ( _prodMode == "WH" ) m_HiggsProdMode = HTXS::WH;
137  else if ( _prodMode == "ZH" ) m_HiggsProdMode = HTXS::QQ2ZH;
138  else if ( _prodMode == "QQ2ZH" ) m_HiggsProdMode = HTXS::QQ2ZH;
139  else if ( _prodMode == "GG2ZH" ) m_HiggsProdMode = HTXS::GG2ZH;
140  else if ( _prodMode == "TTH" ) m_HiggsProdMode = HTXS::TTH;
141  else if ( _prodMode == "BBH" ) m_HiggsProdMode = HTXS::BBH;
142  else if ( _prodMode == "TH" ) m_HiggsProdMode = HTXS::TH;
143  else if ( _prodMode == "AUTO" ) {
144  edm::LogInfo ("HTXSRivetProducer") <<"Using AUTO for HiggsProdMode, found it to be: "<<m_HiggsProdMode<< "\n";
145  edm::LogInfo ("HTXSRivetProducer") <<"(UNKNOWN=0, GGF=1, VBF=2, WH=3, QQ2ZH=4, GG2ZH=5, TTH=6, BBH=7, TH=8)"<<endl;
146  } else {
147  throw cms::Exception("HTXSRivetProducer") << "ProductionMode must be one of: GGF,VBF,WH,ZH,QQ2ZH,GG2ZH,TTH,BBH,TH,AUTO " ;
148  }
150 
151  // at this point the production mode must be known
153  edm::LogInfo ("HTXSRivetProducer") << "HTXSRivetProducer WARNING: HiggsProduction mode is UNKNOWN" << endl;
154  }
155 
156  // initialize rivet analysis
157  _analysisHandler.init(*myGenEvent);
158  _isFirstEvent = false;
159 
160  }
161 
162  // classify the event
163  Rivet::HiggsClassification rivet_cat = _HTXS->classifyEvent(*myGenEvent,m_HiggsProdMode);
164  cat_ = HTXS::Rivet2Root(rivet_cat);
165 
166  unique_ptr<HTXS::HiggsClassification> cat( new HTXS::HiggsClassification( cat_ ) );
167 
168  iEvent.put(std::move(cat),"HiggsClassification");
169  }
170 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
HTXS::HiggsProdMode m_HiggsProdMode
Rivet::AnalysisHandler _analysisHandler
Rivet::HiggsTemplateCrossSections * _HTXS
def cat(path)
Definition: eostools.py:400
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:510

Member Data Documentation

Rivet::AnalysisHandler HTXSRivetProducer::_analysisHandler
private

Definition at line 61 of file HTXSRivetProducer.cc.

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

Definition at line 58 of file HTXSRivetProducer.cc.

Rivet::HiggsTemplateCrossSections* HTXSRivetProducer::_HTXS
private

Definition at line 62 of file HTXSRivetProducer.cc.

bool HTXSRivetProducer::_isFirstEvent
private

Definition at line 64 of file HTXSRivetProducer.cc.

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

Definition at line 59 of file HTXSRivetProducer.cc.

std::string HTXSRivetProducer::_prodMode
private

Definition at line 65 of file HTXSRivetProducer.cc.

HTXS::HiggsClassification HTXSRivetProducer::cat_
private

Definition at line 68 of file HTXSRivetProducer.cc.

HTXS::HiggsProdMode HTXSRivetProducer::m_HiggsProdMode
private

Definition at line 66 of file HTXSRivetProducer.cc.