CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HeavyQuarkFromMPIFilterAlgo.cc
Go to the documentation of this file.
5 
6 using namespace edm;
7 using namespace std;
8 
9 
11  HeavyQuarkFlavour=(int)iConfig.getParameter<int>("HQFlavour");
12  genParSource_=iConfig.getParameter<edm::InputTag>("genParSource");
13 }
14 
16 }
17 
18 
19 //look for status==1 e coming from b or c hadron
20 //there is an eT threshold on the electron (configurable)
22  bool Veto=false;
24  iEvent.getByLabel(genParSource_,genParsHandle);
25  reco::GenParticleCollection genPars=*genParsHandle;
26 // std::cout<<" in the filter HQF="<<HeavyQuarkFlavour<<std::endl;
27  bool fromMPI=false;
28  for (uint32_t ig=0;ig<genPars.size();ig++) {
29  reco::GenParticle gp=genPars[ig];
30  if (abs(gp.pdgId())==HeavyQuarkFlavour) {
31  if(gp.status()>=30 && gp.status()<40){
32 // cout<<"Found a B with status of 3X (eta="<<gp.eta()<<")==>fromMPI=true"<<endl;
33  fromMPI=true;
34  }
35  if(gp.status()>=40 && fromMPI==false){
36 // cout<<"Found a B with status >= 4X (eta="<<gp.eta()<<")==>Need to check ancestors!"<<endl;
37  const reco::GenParticleRefVector& mothers = gp.motherRefVector();
38 // cout<<"Note: it has "<<mothers.size()<<" mothers"<<endl;
39  for( reco::GenParticleRefVector::const_iterator im = mothers.begin(); im!=mothers.end(); ++im) {
40  const reco::GenParticle& part = **im;
41 // cout<<"--->Going to a mother, having eta="<<part.eta()<<endl;
42  if( hasMPIAncestor( &part) ){
43 // cout<<"------>Found one ancestor with status of 3X (eta="<<gp.eta()<<")==>fromMPI=true"<<endl;
44  fromMPI=true;
45  }
46  }
47  }
48  if(fromMPI)Veto=true;
49  else Veto=false;
50  }
51  }
52 // cout<<"RETURN "<<Veto<<endl;
53  return Veto;
54 }
55 
57  if( particle->status() >=30 && particle->status()<40 ){
58 // cout<<"------->Mother found with eta="<<particle->eta()<<" and status "<<particle->status()<<"==> returning true!"<<endl;
59  return true;
60  }
61 // cout<<"------->in hasMPIAncestor, current particle has eta="<<particle->eta()<<" and status!=3X ==> checking next mothers"<<endl;
62  const reco::GenParticleRefVector& mothers = particle->motherRefVector();
63 // cout<<"------>Note: it has "<<mothers.size()<<" mothers"<<endl;
64  for( reco::GenParticleRefVector::const_iterator im = mothers.begin(); im!=mothers.end(); ++im) {
65  const reco::GenParticle& part = **im;
66  if( hasMPIAncestor( &part )){
67 // cout<<"--------->Found one ancestor with status of 3X ==>returning true"<<endl;
68  return true;
69  }
70  }
71 // cout<<"------>No 30's ancestor found ==>returning false"<<endl;
72  return false;
73 }
74 
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
T getParameter(std::string const &) const
virtual int pdgId() const
PDG identifier.
virtual int status() const
status word
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:255
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:250
bool filter(const edm::Event &iEvent)
int iEvent
Definition: GenABIO.cc:230
bool hasMPIAncestor(const reco::GenParticle *)
const mothers & motherRefVector() const
references to mothers
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
HeavyQuarkFromMPIFilterAlgo(const edm::ParameterSet &)
part
Definition: HCALResponse.h:20