CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
GenTtbarCategorizer Class Reference

#include <TopQuarkAnalysis/TopTools/plugins/GenTtbarCategorizer.cc>

Inheritance diagram for GenTtbarCategorizer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 GenTtbarCategorizer (const edm::ParameterSet &)
 
- 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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept 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 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)
 

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)
 

Private Member Functions

std::vector< int > nHadronsOrderedJetIndices (const std::map< int, int > &m_jetIndex) const
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 

Private Attributes

const edm::EDGetTokenT< std::vector< int > > genBHadFlavourToken_
 
const edm::EDGetTokenT< std::vector< int > > genBHadFromTopWeakDecayToken_
 
const edm::EDGetTokenT< std::vector< int > > genBHadIndexToken_
 
const edm::EDGetTokenT< std::vector< int > > genBHadJetIndexToken_
 
const edm::EDGetTokenT< std::vector< int > > genBHadLeptonHadronIndexToken_
 
const edm::EDGetTokenT< std::vector< int > > genBHadLeptonViaTauToken_
 
const edm::EDGetTokenT< std::vector< std::vector< int > > > genBHadPlusMothersIndicesToken_
 
const edm::EDGetTokenT< std::vector< reco::GenParticle > > genBHadPlusMothersToken_
 
const edm::EDGetTokenT< std::vector< int > > genCHadBHadronIdToken_
 
const edm::EDGetTokenT< std::vector< int > > genCHadFlavourToken_
 
const edm::EDGetTokenT< std::vector< int > > genCHadFromTopWeakDecayToken_
 
const edm::EDGetTokenT< std::vector< int > > genCHadJetIndexToken_
 
const double genJetAbsEtaMax_
 
const double genJetPtMin_
 
const edm::EDGetTokenT< reco::GenJetCollectiongenJetsToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::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
 
- 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

Description: Categorization of different tt+xx processes, returning unique ID for each process as e.g. tt+bb, tt+b, tt+2b, tt+cc, ...

Implementation:

The classification scheme returns an ID per event, and works as follows:

All jets in the following need to be in the acceptance as given by the config parameters |eta|, pt.
A c jet must contain at least one c hadron and should contain no b hadrons

First, b jets from top are identified, i.e. jets containing a b hadron from t->b decay
They are encoded in the ID as numberOfBjetsFromTop*100, i.e.
0xx: no b jets from top in acceptance
1xx: 1 b jet from top in acceptance
2xx: both b jets from top in acceptance

Then, b jets from W are identified, i.e. jets containing a b hadron from W->b decay
They are encoded in the ID as numberOfBjetsFromW*1000, i.e.
0xxx: no b jets from W in acceptance
1xxx: 1 b jet from W in acceptance
2xxx: 2 b jets from W in acceptance

Then, c jets from W are identified, i.e. jets containing a c hadron from W->c decay, but no b hadrons
They are encoded in the ID as numberOfCjetsFromW*10000, i.e.
0xxxx: no c jets from W in acceptance
1xxxx: 1 c jet from W in acceptance
2xxxx: 2 c jets from W in acceptance

From the remaining jets, the ID is formed based on the additional b jets (IDs x5x) and c jets (IDs x4x) in the following order:
x55: at least 2 additional b jets with at least two of them having >= 2 b hadrons in each
x54: at least 2 additional b jets with one of them having >= 2 b hadrons, the others having =1 b hadron
x53: at least 2 additional b jets with all having =1 b hadron
x52: exactly 1 additional b jet having >=2 b hadrons
x51: exactly 1 additional b jet having =1 b hadron
x45: at least 2 additional c jets with at least two of them having >= 2 c hadrons in each
x44: at least 2 additional c jets with one of them having >= 2 c hadrons, the others having =1 c hadron
x43: at least 2 additional c jets with all having =1 c hadron
x42: exactly 1 additional c jet having >=2 c hadrons
x41: exactly 1 additional c jet having =1 c hadron
x00: No additional b or c jet, i.e. only light flavour jets or no additional jets

Definition at line 73 of file GenTtbarCategorizer.cc.

Constructor & Destructor Documentation

◆ GenTtbarCategorizer()

GenTtbarCategorizer::GenTtbarCategorizer ( const edm::ParameterSet iConfig)
explicit

Definition at line 119 of file GenTtbarCategorizer.cc.

120  : genJetPtMin_(iConfig.getParameter<double>("genJetPtMin")),
121  genJetAbsEtaMax_(iConfig.getParameter<double>("genJetAbsEtaMax")),
122  genJetsToken_(consumes<reco::GenJetCollection>(iConfig.getParameter<edm::InputTag>("genJets"))),
123  genBHadJetIndexToken_(consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genBHadJetIndex"))),
124  genBHadFlavourToken_(consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genBHadFlavour"))),
126  consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genBHadFromTopWeakDecay"))),
128  consumes<std::vector<reco::GenParticle> >(iConfig.getParameter<edm::InputTag>("genBHadPlusMothers"))),
130  consumes<std::vector<std::vector<int> > >(iConfig.getParameter<edm::InputTag>("genBHadPlusMothersIndices"))),
131  genBHadIndexToken_(consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genBHadIndex"))),
133  consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genBHadLeptonHadronIndex"))),
135  consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genBHadLeptonViaTau"))),
136  genCHadJetIndexToken_(consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genCHadJetIndex"))),
137  genCHadFlavourToken_(consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genCHadFlavour"))),
139  consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genCHadFromTopWeakDecay"))),
140  genCHadBHadronIdToken_(consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genCHadBHadronId"))) {
141  produces<int>("genTtbarId");
142 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< std::vector< int > > genBHadFromTopWeakDecayToken_
const edm::EDGetTokenT< std::vector< int > > genBHadJetIndexToken_
const edm::EDGetTokenT< std::vector< int > > genCHadFromTopWeakDecayToken_
const edm::EDGetTokenT< std::vector< int > > genCHadFlavourToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< std::vector< int > > genBHadFlavourToken_
const edm::EDGetTokenT< std::vector< std::vector< int > > > genBHadPlusMothersIndicesToken_
const edm::EDGetTokenT< std::vector< int > > genBHadLeptonHadronIndexToken_
const edm::EDGetTokenT< std::vector< int > > genBHadIndexToken_
const edm::EDGetTokenT< std::vector< int > > genBHadLeptonViaTauToken_
const edm::EDGetTokenT< std::vector< reco::GenParticle > > genBHadPlusMothersToken_
const edm::EDGetTokenT< std::vector< int > > genCHadJetIndexToken_
const edm::EDGetTokenT< std::vector< int > > genCHadBHadronIdToken_
const edm::EDGetTokenT< reco::GenJetCollection > genJetsToken_

Member Function Documentation

◆ fillDescriptions()

void GenTtbarCategorizer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 404 of file GenTtbarCategorizer.cc.

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

404  {
405  //The following says we do not know what parameters are allowed so do no validation
406  // Please change this to state exactly what you do use, even if it is no parameters
408 
409  desc.add<double>("genJetPtMin", 20.);
410  desc.add<double>("genJetAbsEtaMax", 2.4);
411  desc.add<edm::InputTag>("genJets", edm::InputTag("ak4GenJets"));
412  desc.add<edm::InputTag>("genBHadJetIndex", edm::InputTag("matchGenBHadron", "genBHadJetIndex"));
413  desc.add<edm::InputTag>("genBHadFlavour", edm::InputTag("matchGenBHadron", "genBHadFlavour"));
414  desc.add<edm::InputTag>("genBHadFromTopWeakDecay", edm::InputTag("matchGenBHadron", "genBHadFromTopWeakDecay"));
415  desc.add<edm::InputTag>("genBHadPlusMothers", edm::InputTag("matchGenBHadron", "genBHadPlusMothers"));
416  desc.add<edm::InputTag>("genBHadPlusMothersIndices", edm::InputTag("matchGenBHadron", "genBHadPlusMothersIndices"));
417  desc.add<edm::InputTag>("genBHadIndex", edm::InputTag("matchGenBHadron", "genBHadIndex"));
418  desc.add<edm::InputTag>("genBHadLeptonHadronIndex", edm::InputTag("matchGenBHadron", "genBHadLeptonHadronIndex"));
419  desc.add<edm::InputTag>("genBHadLeptonViaTau", edm::InputTag("matchGenBHadron", "genBHadLeptonViaTau"));
420 
421  desc.add<edm::InputTag>("genCHadJetIndex", edm::InputTag("matchGenCHadron", "genCHadJetIndex"));
422  desc.add<edm::InputTag>("genCHadFlavour", edm::InputTag("matchGenCHadron", "genCHadFlavour"));
423  desc.add<edm::InputTag>("genCHadFromTopWeakDecay", edm::InputTag("matchGenCHadron", "genCHadFromTopWeakDecay"));
424  desc.add<edm::InputTag>("genCHadBHadronId", edm::InputTag("matchGenCHadron", "genCHadBHadronId"));
425 
426  descriptions.add("categorizeGenTtbar", desc);
427 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ nHadronsOrderedJetIndices()

std::vector< int > GenTtbarCategorizer::nHadronsOrderedJetIndices ( const std::map< int, int > &  m_jetIndex) const
private

Definition at line 380 of file GenTtbarCategorizer.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, jetUpdater_cfi::sort, and trackerHitRTTI::vector.

Referenced by produce().

380  {
381  const int nElements = m_jetIndex.size();
382  std::vector<std::pair<int, int> > v_jetNhadIndexPair;
383  v_jetNhadIndexPair.reserve(nElements);
384  for (std::map<int, int>::const_iterator it = m_jetIndex.begin(); it != m_jetIndex.end(); ++it) {
385  const int jetIndex = it->first;
386  const int nHadrons = it->second;
387  v_jetNhadIndexPair.push_back(std::pair<int, int>(nHadrons, jetIndex));
388  }
389  // Sorting the vector of pairs by their key value
390  std::sort(v_jetNhadIndexPair.begin(), v_jetNhadIndexPair.end(), std::greater<std::pair<int, int> >());
391  // Building the vector of indices in the proper order
392  std::vector<int> v_orderedJetIndices;
393  v_orderedJetIndices.reserve(nElements);
394  for (std::vector<std::pair<int, int> >::const_iterator it = v_jetNhadIndexPair.begin();
395  it != v_jetNhadIndexPair.end();
396  ++it) {
397  v_orderedJetIndices.push_back(it->second);
398  }
399 
400  return v_orderedJetIndices;
401 }

◆ produce()

void GenTtbarCategorizer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 149 of file GenTtbarCategorizer.cc.

References funct::abs(), ttHFGenFilter_cfi::genBHadFlavour, genBHadFlavourToken_, ttHFGenFilter_cfi::genBHadFromTopWeakDecay, genBHadFromTopWeakDecayToken_, ttHFGenFilter_cfi::genBHadIndex, genBHadIndexToken_, genBHadJetIndexToken_, genBHadLeptonHadronIndexToken_, genBHadLeptonViaTauToken_, ttHFGenFilter_cfi::genBHadPlusMothers, ttHFGenFilter_cfi::genBHadPlusMothersIndices, genBHadPlusMothersIndicesToken_, genBHadPlusMothersToken_, genCHadBHadronIdToken_, genCHadFlavourToken_, genCHadFromTopWeakDecayToken_, genCHadJetIndexToken_, genJetAbsEtaMax_, genJetPtMin_, l1tCaloJetHTTProducer_cfi::genJets, genJetsToken_, iEvent, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, SiStripPI::max, SiStripPI::min, eostools::move(), and nHadronsOrderedJetIndices().

149  {
150  // Access gen jets
152  iEvent.getByToken(genJetsToken_, genJets);
153 
154  // Access B hadrons information
157 
158  edm::Handle<std::vector<int> > genBHadJetIndex;
159  iEvent.getByToken(genBHadJetIndexToken_, genBHadJetIndex);
160 
163 
166 
169 
172 
173  edm::Handle<std::vector<int> > genBHadLeptonHadronIndex;
174  iEvent.getByToken(genBHadLeptonHadronIndexToken_, genBHadLeptonHadronIndex);
175 
176  edm::Handle<std::vector<int> > genBHadLeptonViaTau;
177  iEvent.getByToken(genBHadLeptonViaTauToken_, genBHadLeptonViaTau);
178 
179  // Access C hadrons information
180  edm::Handle<std::vector<int> > genCHadFlavour;
181  iEvent.getByToken(genCHadFlavourToken_, genCHadFlavour);
182 
183  edm::Handle<std::vector<int> > genCHadJetIndex;
184  iEvent.getByToken(genCHadJetIndexToken_, genCHadJetIndex);
185 
186  edm::Handle<std::vector<int> > genCHadFromTopWeakDecay;
187  iEvent.getByToken(genCHadFromTopWeakDecayToken_, genCHadFromTopWeakDecay);
188 
189  edm::Handle<std::vector<int> > genCHadBHadronId;
190  iEvent.getByToken(genCHadBHadronIdToken_, genCHadBHadronId);
191 
192  // Map <jet index, number of specific hadrons in jet>
193  // B jets with b hadrons directly from t->b decay
194  std::map<int, int> bJetFromTopIds;
195  // B jets with b hadrons from W->b decay
196  std::map<int, int> bJetFromWIds;
197  // C jets with c hadrons from W->c decay
198  std::map<int, int> cJetFromWIds;
199  // B jets with b hadrons before top quark decay chain
200  std::map<int, int> bJetAdditionalIds;
201  // C jets with c hadrons before top quark decay chain
202  std::map<int, int> cJetAdditionalIds;
203 
204  // Count number of specific b hadrons in each jet
205  for (size_t hadronId = 0; hadronId < genBHadIndex->size(); ++hadronId) {
206  // Index of jet associated to the hadron
207  const int jetIndex = genBHadJetIndex->at(hadronId);
208  // Skip hadrons which have no associated jet
209  if (jetIndex < 0)
210  continue;
211  // Skip if jet is not in acceptance
212  if (genJets->at(jetIndex).pt() < genJetPtMin_)
213  continue;
214  if (std::fabs(genJets->at(jetIndex).eta()) > genJetAbsEtaMax_)
215  continue;
216  // Flavour of the hadron's origin
217  const int flavour = genBHadFlavour->at(hadronId);
218  // Jet from t->b decay [pdgId(top)=6]
219  if (std::abs(flavour) == 6) {
220  if (bJetFromTopIds.count(jetIndex) < 1)
221  bJetFromTopIds[jetIndex] = 1;
222  else
223  bJetFromTopIds[jetIndex]++;
224  continue;
225  }
226  // Jet from W->b decay [pdgId(W)=24]
227  if (std::abs(flavour) == 24) {
228  if (bJetFromWIds.count(jetIndex) < 1)
229  bJetFromWIds[jetIndex] = 1;
230  else
231  bJetFromWIds[jetIndex]++;
232  continue;
233  }
234  // Identify jets with b hadrons not from top-quark or W-boson decay
235  if (bJetAdditionalIds.count(jetIndex) < 1)
236  bJetAdditionalIds[jetIndex] = 1;
237  else
238  bJetAdditionalIds[jetIndex]++;
239  }
240 
241  // Cleaning up b jets from W->b decays
242  for (std::map<int, int>::iterator it = bJetFromWIds.begin(); it != bJetFromWIds.end();) {
243  // Cannot be a b jet from t->b decay
244  if (bJetFromTopIds.count(it->first) > 0)
245  bJetFromWIds.erase(it++);
246  else
247  ++it;
248  }
249 
250  // Cleaning up additional b jets
251  for (std::map<int, int>::iterator it = bJetAdditionalIds.begin(); it != bJetAdditionalIds.end();) {
252  // Cannot be a b jet from t->b decay
253  if (bJetFromTopIds.count(it->first) > 0)
254  bJetAdditionalIds.erase(it++);
255  // Cannot be a b jet from W->b decay
256  else if (bJetFromWIds.count(it->first) > 0)
257  bJetAdditionalIds.erase(it++);
258  else
259  ++it;
260  }
261 
262  // Count number of specific c hadrons in each c jet
263  for (size_t hadronId = 0; hadronId < genCHadJetIndex->size(); ++hadronId) {
264  // Index of jet associated to the hadron
265  const int jetIndex = genCHadJetIndex->at(hadronId);
266  // Skip hadrons which have no associated jet
267  if (jetIndex < 0)
268  continue;
269  // Skip c hadrons that are coming from b hadrons
270  if (genCHadBHadronId->at(hadronId) >= 0)
271  continue;
272  // Skip if jet is not in acceptance
273  if (genJets->at(jetIndex).pt() < genJetPtMin_)
274  continue;
275  if (std::fabs(genJets->at(jetIndex).eta()) > genJetAbsEtaMax_)
276  continue;
277  // Skip if jet contains a b hadron
278  if (bJetFromTopIds.count(jetIndex) > 0)
279  continue;
280  if (bJetFromWIds.count(jetIndex) > 0)
281  continue;
282  if (bJetAdditionalIds.count(jetIndex) > 0)
283  continue;
284  // Flavour of the hadron's origin
285  const int flavour = genCHadFlavour->at(hadronId);
286  // Jet from W->c decay [pdgId(W)=24]
287  if (std::abs(flavour) == 24) {
288  if (cJetFromWIds.count(jetIndex) < 1)
289  cJetFromWIds[jetIndex] = 1;
290  else
291  cJetFromWIds[jetIndex]++;
292  continue;
293  }
294  // Identify jets with c hadrons not from W-boson decay
295  if (cJetAdditionalIds.count(jetIndex) < 1)
296  cJetAdditionalIds[jetIndex] = 1;
297  else
298  cJetAdditionalIds[jetIndex]++;
299  }
300 
301  // Cleaning up additional c jets
302  for (std::map<int, int>::iterator it = cJetAdditionalIds.begin(); it != cJetAdditionalIds.end();) {
303  // Cannot be a c jet from W->c decay
304  if (cJetFromWIds.count(it->first) > 0)
305  cJetAdditionalIds.erase(it++);
306  else
307  ++it;
308  }
309 
310  // Categorize event based on number of additional b/c jets
311  // and number of corresponding hadrons in each of them
312  int additionalJetEventId = bJetFromTopIds.size() * 100 + bJetFromWIds.size() * 1000 + cJetFromWIds.size() * 10000;
313  // tt + 1 additional b jet
314  if (bJetAdditionalIds.size() == 1) {
315  const int nHadronsInJet = bJetAdditionalIds.begin()->second;
316  // tt + 1 additional b jet from 1 additional b hadron
317  if (nHadronsInJet == 1)
318  additionalJetEventId += 51;
319  // tt + 1 additional b jet from >=2 additional b hadrons
320  else
321  additionalJetEventId += 52;
322  }
323  // tt + >=2 additional b jets
324  else if (bJetAdditionalIds.size() > 1) {
325  // Check first two additional b jets (rare cases could have more)
326  const std::vector<int> orderedJetIndices = nHadronsOrderedJetIndices(bJetAdditionalIds);
327  int nHadronsInJet1 = bJetAdditionalIds.at(orderedJetIndices.at(0));
328  int nHadronsInJet2 = bJetAdditionalIds.at(orderedJetIndices.at(1));
329  // tt + >=2 additional b jets each from 1 additional b hadron
330  if (std::max(nHadronsInJet1, nHadronsInJet2) == 1)
331  additionalJetEventId += 53;
332  // tt + >=2 additional b jets one of which from >=2 additional b hadrons
333  else if (std::min(nHadronsInJet1, nHadronsInJet2) == 1 && std::max(nHadronsInJet1, nHadronsInJet2) > 1)
334  additionalJetEventId += 54;
335  // tt + >=2 additional b jets each from >=2 additional b hadrons
336  else if (std::min(nHadronsInJet1, nHadronsInJet2) > 1)
337  additionalJetEventId += 55;
338  }
339  // tt + no additional b jets
340  else {
341  // tt + 1 additional c jet
342  if (cJetAdditionalIds.size() == 1) {
343  const int nHadronsInJet = cJetAdditionalIds.begin()->second;
344  // tt + 1 additional c jet from 1 additional c hadron
345  if (nHadronsInJet == 1)
346  additionalJetEventId += 41;
347  // tt + 1 additional c jet from >=2 additional c hadrons
348  else
349  additionalJetEventId += 42;
350  }
351  // tt + >=2 additional c jets
352  else if (cJetAdditionalIds.size() > 1) {
353  // Check first two additional c jets (rare cases could have more)
354  const std::vector<int> orderedJetIndices = nHadronsOrderedJetIndices(cJetAdditionalIds);
355  int nHadronsInJet1 = cJetAdditionalIds.at(orderedJetIndices.at(0));
356  int nHadronsInJet2 = cJetAdditionalIds.at(orderedJetIndices.at(1));
357  // tt + >=2 additional c jets each from 1 additional c hadron
358  if (std::max(nHadronsInJet1, nHadronsInJet2) == 1)
359  additionalJetEventId += 43;
360  // tt + >=2 additional c jets one of which from >=2 additional c hadrons
361  else if (std::min(nHadronsInJet1, nHadronsInJet2) == 1 && std::max(nHadronsInJet1, nHadronsInJet2) > 1)
362  additionalJetEventId += 44;
363  // tt + >=2 additional c jets each from >=2 additional c hadrons
364  else if (std::min(nHadronsInJet1, nHadronsInJet2) > 1)
365  additionalJetEventId += 45;
366  }
367  // tt + no additional c jets
368  else {
369  // tt + light jets
370  additionalJetEventId += 0;
371  }
372  }
373 
374  std::unique_ptr<int> ttbarId(new int);
375  *ttbarId = additionalJetEventId;
376  iEvent.put(std::move(ttbarId), "genTtbarId");
377 }
const edm::EDGetTokenT< std::vector< int > > genBHadFromTopWeakDecayToken_
const edm::EDGetTokenT< std::vector< int > > genBHadJetIndexToken_
const edm::EDGetTokenT< std::vector< int > > genCHadFromTopWeakDecayToken_
std::vector< int > nHadronsOrderedJetIndices(const std::map< int, int > &m_jetIndex) const
const edm::EDGetTokenT< std::vector< int > > genCHadFlavourToken_
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< std::vector< int > > genBHadFlavourToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const edm::EDGetTokenT< std::vector< std::vector< int > > > genBHadPlusMothersIndicesToken_
const edm::EDGetTokenT< std::vector< int > > genBHadLeptonHadronIndexToken_
const edm::EDGetTokenT< std::vector< int > > genBHadIndexToken_
const edm::EDGetTokenT< std::vector< int > > genBHadLeptonViaTauToken_
const edm::EDGetTokenT< std::vector< reco::GenParticle > > genBHadPlusMothersToken_
const edm::EDGetTokenT< std::vector< int > > genCHadJetIndexToken_
const edm::EDGetTokenT< std::vector< int > > genCHadBHadronIdToken_
const edm::EDGetTokenT< reco::GenJetCollection > genJetsToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ genBHadFlavourToken_

const edm::EDGetTokenT<std::vector<int> > GenTtbarCategorizer::genBHadFlavourToken_
private

Definition at line 94 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genBHadFromTopWeakDecayToken_

const edm::EDGetTokenT<std::vector<int> > GenTtbarCategorizer::genBHadFromTopWeakDecayToken_
private

Definition at line 95 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genBHadIndexToken_

const edm::EDGetTokenT<std::vector<int> > GenTtbarCategorizer::genBHadIndexToken_
private

Definition at line 98 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genBHadJetIndexToken_

const edm::EDGetTokenT<std::vector<int> > GenTtbarCategorizer::genBHadJetIndexToken_
private

Definition at line 93 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genBHadLeptonHadronIndexToken_

const edm::EDGetTokenT<std::vector<int> > GenTtbarCategorizer::genBHadLeptonHadronIndexToken_
private

Definition at line 99 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genBHadLeptonViaTauToken_

const edm::EDGetTokenT<std::vector<int> > GenTtbarCategorizer::genBHadLeptonViaTauToken_
private

Definition at line 100 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genBHadPlusMothersIndicesToken_

const edm::EDGetTokenT<std::vector<std::vector<int> > > GenTtbarCategorizer::genBHadPlusMothersIndicesToken_
private

Definition at line 97 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genBHadPlusMothersToken_

const edm::EDGetTokenT<std::vector<reco::GenParticle> > GenTtbarCategorizer::genBHadPlusMothersToken_
private

Definition at line 96 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genCHadBHadronIdToken_

const edm::EDGetTokenT<std::vector<int> > GenTtbarCategorizer::genCHadBHadronIdToken_
private

Definition at line 105 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genCHadFlavourToken_

const edm::EDGetTokenT<std::vector<int> > GenTtbarCategorizer::genCHadFlavourToken_
private

Definition at line 103 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genCHadFromTopWeakDecayToken_

const edm::EDGetTokenT<std::vector<int> > GenTtbarCategorizer::genCHadFromTopWeakDecayToken_
private

Definition at line 104 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genCHadJetIndexToken_

const edm::EDGetTokenT<std::vector<int> > GenTtbarCategorizer::genCHadJetIndexToken_
private

Definition at line 102 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genJetAbsEtaMax_

const double GenTtbarCategorizer::genJetAbsEtaMax_
private

Definition at line 88 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genJetPtMin_

const double GenTtbarCategorizer::genJetPtMin_
private

Definition at line 87 of file GenTtbarCategorizer.cc.

Referenced by produce().

◆ genJetsToken_

const edm::EDGetTokenT<reco::GenJetCollection> GenTtbarCategorizer::genJetsToken_
private

Definition at line 91 of file GenTtbarCategorizer.cc.

Referenced by produce().