CMS 3D CMS Logo

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

#include <ttHFGenFilter/ttHFGenFilter/plugins/ttHFGenFilter.cc>

Inheritance diagram for ttHFGenFilter:
edm::stream::EDFilter<> edm::stream::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ttHFGenFilter (const edm::ParameterSet &)
 
 ~ttHFGenFilter () override
 
- Public Member Functions inherited from edm::stream::EDFilter<>
 EDFilter ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilterBase () 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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

virtual bool analyzeMothersRecursive (const reco::Candidate *, std::vector< const reco::Candidate * > &AllTopMothers)
 
void beginStream (edm::StreamID) override
 
void endStream () override
 
bool filter (edm::Event &, const edm::EventSetup &) override
 
virtual void FindAllTopMothers (const reco::Candidate *particle, std::vector< const reco::Candidate * > &)
 
virtual std::vector< const reco::Candidate * > GetTops (const std::vector< reco::GenParticle > &, std::vector< const reco::Candidate * > &AllTopMothers)
 
virtual bool HasAdditionalBHadron (const std::vector< int > &, const std::vector< int > &, const std::vector< reco::GenParticle > &, std::vector< const reco::Candidate * > &)
 

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< std::vector< int > > > genBHadPlusMothersIndicesToken_
 
const edm::EDGetTokenT< std::vector< reco::GenParticle > > genBHadPlusMothersToken_
 
const edm::EDGetTokenT< reco::GenParticleCollectiongenParticlesToken_
 
bool OnlyHardProcessBHadrons_
 
bool taggingMode_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDFilter<>
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::EDFilterBase
typedef EDFilterAdaptorBase 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
 
- 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

Description: Filters ttbar events, where additional b-hadrons come from ISR or hard process

Implementation: The ttHFGenFilter is a edm::Filter, that returns true, if a tt+jets event contains a b-hadron, that does not come from top decay or when the b-hadron comes from ISR. The filter uses the GenHFHadronMatcher to classify, whether the b-hadron is an "additional b-hadron". This is done in the ttHFGenFilter::HasAdditionalBHadron() function. To classify, whether the b-hadron comes from ISR: first all mothers of the top-topbar pair are found then the mother-chain of all b-hadrons is checked if it contains at least one mother, that is also in the mother-chain of the top-topbar pair

Definition at line 46 of file ttHFGenFilter.cc.

Constructor & Destructor Documentation

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

Definition at line 85 of file ttHFGenFilter.cc.

References edm::ParameterSet::getParameter(), OnlyHardProcessBHadrons_, and taggingMode_.

85  :
86 genParticlesToken_(consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("genParticles"))),
87 genBHadFlavourToken_(consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genBHadFlavour"))),
88 genBHadFromTopWeakDecayToken_(consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genBHadFromTopWeakDecay"))),
89 genBHadPlusMothersToken_(consumes<std::vector<reco::GenParticle> >(iConfig.getParameter<edm::InputTag>("genBHadPlusMothers"))),
90 genBHadPlusMothersIndicesToken_(consumes<std::vector<std::vector<int> > >(iConfig.getParameter<edm::InputTag>("genBHadPlusMothersIndices"))),
91 genBHadIndexToken_(consumes<std::vector<int> >(iConfig.getParameter<edm::InputTag>("genBHadIndex")))
92 {
93  //now do what ever initialization is needed
94  OnlyHardProcessBHadrons_ = iConfig.getParameter<bool> ( "OnlyHardProcessBHadrons" );
95  taggingMode_ = iConfig.getParameter<bool>("taggingMode");
96 
97  produces<bool>();
98 }
const edm::EDGetTokenT< std::vector< reco::GenParticle > > genBHadPlusMothersToken_
T getParameter(std::string const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< std::vector< int > > genBHadFlavourToken_
const edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken_
const edm::EDGetTokenT< std::vector< std::vector< int > > > genBHadPlusMothersIndicesToken_
const edm::EDGetTokenT< std::vector< int > > genBHadFromTopWeakDecayToken_
const edm::EDGetTokenT< std::vector< int > > genBHadIndexToken_
bool OnlyHardProcessBHadrons_
ttHFGenFilter::~ttHFGenFilter ( )
override

Definition at line 101 of file ttHFGenFilter.cc.

102 {
103 
104  // do anything here that needs to be done at destruction time
105  // (e.g. close files, deallocate resources etc.)
106 
107 }

Member Function Documentation

bool ttHFGenFilter::analyzeMothersRecursive ( const reco::Candidate particle,
std::vector< const reco::Candidate * > &  AllTopMothers 
)
privatevirtual

Definition at line 190 of file ttHFGenFilter.cc.

References mps_fire::i, gen::k, reco::Candidate::mother(), reco::Candidate::numberOfMothers(), and reco::Candidate::status().

Referenced by HasAdditionalBHadron().

190  {
191  if(particle->status()>20&&particle->status()<30){ //particle comes from hardest process in event
192  return true;
193  }
194  for(unsigned int k=0; k<AllTopMothers.size();k++){
195  if(particle==AllTopMothers[k]){ //particle comes from ISR
196  return true;
197  }
198  }
199  bool isFromHardProcess=false;
200  for(unsigned int i=0;i<particle->numberOfMothers();i++){
201  const reco::Candidate* mother = particle->mother(i);
202  isFromHardProcess=analyzeMothersRecursive(mother,AllTopMothers);
203  if(isFromHardProcess){
204  return true;
205  }
206  }
207  return isFromHardProcess;
208 }
virtual bool analyzeMothersRecursive(const reco::Candidate *, std::vector< const reco::Candidate * > &AllTopMothers)
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
virtual int status() const =0
status word
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
int k[5][pyjets_maxn]
void ttHFGenFilter::beginStream ( edm::StreamID  )
overrideprivatevirtual

Reimplemented from edm::stream::EDFilterBase.

Definition at line 267 of file ttHFGenFilter.cc.

268 {
269 }
void ttHFGenFilter::endStream ( )
overrideprivatevirtual

Reimplemented from edm::stream::EDFilterBase.

Definition at line 273 of file ttHFGenFilter.cc.

273  {
274 }
void ttHFGenFilter::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 310 of file ttHFGenFilter.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

310  {
311  //The following says we do not know what parameters are allowed so do no validation
312  // Please change this to state exactly what you do use, even if it is no parameters
314  desc.setUnknown();
315  descriptions.addDefault(desc);
316 }
void addDefault(ParameterSetDescription const &psetDescription)
bool ttHFGenFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 116 of file ttHFGenFilter.cc.

References ttHFGenFilter_cfi::genBHadFlavour, genBHadFlavourToken_, ttHFGenFilter_cfi::genBHadFromTopWeakDecay, genBHadFromTopWeakDecayToken_, ttHFGenFilter_cfi::genBHadIndex, genBHadIndexToken_, ttHFGenFilter_cfi::genBHadPlusMothers, ttHFGenFilter_cfi::genBHadPlusMothersIndices, genBHadPlusMothersIndicesToken_, genBHadPlusMothersToken_, GenHFHadronMatcher_cfi::genParticles, genParticlesToken_, edm::Event::getByToken(), GetTops(), HasAdditionalBHadron(), edm::Event::put(), and taggingMode_.

117 {
118  using namespace std;
119 
120  //get GenParticleCollection
122  iEvent.getByToken(genParticlesToken_, genParticles);
123 
124  //get Information on B-Hadrons
125  // the information is calculated in GenHFHadronMatcher
126 
128  iEvent.getByToken(genBHadFlavourToken_, genBHadFlavour);
129 
131  iEvent.getByToken(genBHadFromTopWeakDecayToken_, genBHadFromTopWeakDecay);
132 
134  iEvent.getByToken(genBHadPlusMothersToken_, genBHadPlusMothers);
135 
137  iEvent.getByToken(genBHadPlusMothersIndicesToken_, genBHadPlusMothersIndices);
138 
140  iEvent.getByToken(genBHadIndexToken_, genBHadIndex);
141 
142 
143  //check whether the event has additional b-hadrons not coming from top/topbar decay
144 
145  std::vector<const reco::Candidate*> AllTopMothers;
146  std::vector<const reco::Candidate*> Tops = GetTops(*genParticles,AllTopMothers);
147 
148  bool pass = HasAdditionalBHadron(*genBHadIndex,*genBHadFlavour,*genBHadPlusMothers,AllTopMothers);
149 
150  iEvent.put(std::make_unique<bool>(pass));
151 
152  return taggingMode_ || pass;
153 
154 }
const edm::EDGetTokenT< std::vector< reco::GenParticle > > genBHadPlusMothersToken_
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
const edm::EDGetTokenT< std::vector< int > > genBHadFlavourToken_
const edm::EDGetTokenT< reco::GenParticleCollection > genParticlesToken_
const edm::EDGetTokenT< std::vector< std::vector< int > > > genBHadPlusMothersIndicesToken_
const edm::EDGetTokenT< std::vector< int > > genBHadFromTopWeakDecayToken_
const edm::EDGetTokenT< std::vector< int > > genBHadIndexToken_
virtual bool HasAdditionalBHadron(const std::vector< int > &, const std::vector< int > &, const std::vector< reco::GenParticle > &, std::vector< const reco::Candidate * > &)
virtual std::vector< const reco::Candidate * > GetTops(const std::vector< reco::GenParticle > &, std::vector< const reco::Candidate * > &AllTopMothers)
void ttHFGenFilter::FindAllTopMothers ( const reco::Candidate particle,
std::vector< const reco::Candidate * > &  AllTopMothers 
)
privatevirtual

Definition at line 250 of file ttHFGenFilter.cc.

References funct::abs(), mps_fire::i, reco::Candidate::mother(), reco::Candidate::numberOfMothers(), and reco::Candidate::pdgId().

Referenced by GetTops().

250  {
251  // std::cout << "particle mother: " << particle->mother(0) << std::endl;
252  for(unsigned int i=0;i<particle->numberOfMothers();i++){
253  if(abs(particle->mother(i)->pdgId())!=6 && particle->mother(i)->pdgId()!=2212){
254  AllTopMothers.push_back(particle->mother(i));
255  if(particle->mother(i)->pdgId()!=2212 || particle->mother(i)->numberOfMothers()>1){
256  //std::cout << "Size of vector in loop = " << AllTopMothers.size() << std::endl;
257  FindAllTopMothers(particle->mother(i),AllTopMothers);
258  }
259  }
260  }
261 
262 }
virtual void FindAllTopMothers(const reco::Candidate *particle, std::vector< const reco::Candidate * > &)
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
virtual int pdgId() const =0
PDG identifier.
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< const reco::Candidate * > ttHFGenFilter::GetTops ( const std::vector< reco::GenParticle > &  genParticles,
std::vector< const reco::Candidate * > &  AllTopMothers 
)
privatevirtual

Definition at line 210 of file ttHFGenFilter.cc.

References FindAllTopMothers(), mps_fire::i, reco::CompositeRefCandidateT< D >::mother(), reco::CompositeRefCandidateT< D >::numberOfMothers(), and reco::LeafCandidate::pdgId().

Referenced by filter().

210  {
211  // std::vector<const reco::Candidate*> tops;
212  const reco::GenParticle* firstTop = nullptr;
213  const reco::GenParticle* firstTopBar = nullptr;
214  bool foundTop = false;
215  bool foundTopBar = false;
216  std::vector<const reco::GenParticle*> Tops;
217 
218  //loop over all genParticles and find a Top and AntiTop quark
219  //then find all mothers of the Tops
220  //this is then used to if the b-hadron is an inital state radiation particle
221 
222  for(reco::GenParticleCollection::const_iterator i_particle = genParticles.begin(); i_particle != genParticles.end(); ++i_particle){
223  const reco::GenParticle* thisParticle = &*i_particle;
224  if(!foundTop && thisParticle->pdgId()==6){
225  firstTop = thisParticle;
226  for(unsigned int i=0; i<firstTop->numberOfMothers();i++){
227  FindAllTopMothers(thisParticle->mother(i),AllTopMothers);
228  }
229  foundTop = true;
230  }
231  else if(!foundTopBar && thisParticle->pdgId()==-6){
232  firstTopBar = thisParticle;
233  for(unsigned int i=0; i<firstTopBar->numberOfMothers();i++){
234  FindAllTopMothers(firstTopBar->mother(i),AllTopMothers);
235  }
236  foundTopBar = true;
237  }
238  if(foundTopBar&&foundTop){
239  //tops.push_back(firstTop);
240  //tops.push_back(firstTopBar);
241  //return tops;
242  break;
243  }
244  }
245  return AllTopMothers;
246 }
int pdgId() const final
PDG identifier.
virtual void FindAllTopMothers(const reco::Candidate *particle, std::vector< const reco::Candidate * > &)
size_t numberOfMothers() const override
number of mothers
const Candidate * mother(size_type=0) const override
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
bool ttHFGenFilter::HasAdditionalBHadron ( const std::vector< int > &  genBHadIndex,
const std::vector< int > &  genBHadFlavour,
const std::vector< reco::GenParticle > &  genBHadPlusMothers,
std::vector< const reco::Candidate * > &  AllTopMothers 
)
privatevirtual

Definition at line 156 of file ttHFGenFilter.cc.

References funct::abs(), analyzeMothersRecursive(), mps_fire::i, createfilelist::int, and OnlyHardProcessBHadrons_.

Referenced by filter().

156  {
157 
158  for(unsigned int i=0; i<genBHadIndex.size();i++){
159 
161  int motherflav = genBHadFlavour[i];
162  bool from_tth=(abs(motherflav)==6||abs(motherflav)==25); //b-hadron comes from top or higgs decay
163  bool fromhp=false;
164 
166  if(bhadron!=nullptr&&!from_tth){
167  return true;
168  }
169  }
170 
172  if(bhadron!=nullptr&&!from_tth){
173  //std::cout << "PT: " << bhadron->pt() << " , eta: " << bhadron->eta() << std::endl;
174 
175  fromhp=analyzeMothersRecursive(bhadron,AllTopMothers);
176  if(fromhp){
177  return true;
178  }
179  }
180  if(i==genBHadIndex.size()-1){
181  return false;
182  }
183  }
184 }
185 
186  return false;
187 }
#define nullptr
virtual bool analyzeMothersRecursive(const reco::Candidate *, std::vector< const reco::Candidate * > &AllTopMothers)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool OnlyHardProcessBHadrons_

Member Data Documentation

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

Definition at line 64 of file ttHFGenFilter.cc.

Referenced by filter().

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

Definition at line 65 of file ttHFGenFilter.cc.

Referenced by filter().

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

Definition at line 68 of file ttHFGenFilter.cc.

Referenced by filter().

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

Definition at line 67 of file ttHFGenFilter.cc.

Referenced by filter().

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

Definition at line 66 of file ttHFGenFilter.cc.

Referenced by filter().

const edm::EDGetTokenT<reco::GenParticleCollection> ttHFGenFilter::genParticlesToken_
private

Definition at line 63 of file ttHFGenFilter.cc.

Referenced by filter().

bool ttHFGenFilter::OnlyHardProcessBHadrons_
private

Definition at line 69 of file ttHFGenFilter.cc.

Referenced by HasAdditionalBHadron(), and ttHFGenFilter().

bool ttHFGenFilter::taggingMode_
private

Definition at line 70 of file ttHFGenFilter.cc.

Referenced by filter(), and ttHFGenFilter().