CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
XtoFFbarFilter.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace reco;
5 
7  src_(iConfig.getParameter<edm::InputTag>("src")),
8  idMotherX_(iConfig.getParameter<vector<int> >("idMotherX")),
9  idDaughterF_(iConfig.getParameter<vector<int> >("idDaughterF")),
10  idMotherY_(iConfig.getParameter<vector<int> >("idMotherY")),
11  idDaughterG_(iConfig.getParameter<vector<int> >("idDaughterG")),
12  xTotal_(0), xSumPt_(0.), xSumR_(0.), totalEvents_(0),rejectedEvents_(0)
13 {
14  // Note if if not searching for Y --> g-gbar.
15  requireY_ = (idMotherY_.size() > 0 && idDaughterG_.size() > 0);
16 }
17 
18 
20 
21  iEvent.getByLabel(src_, genParticles_);
22 
23  totalEvents_++;
24 
25  unsigned int numX = 0;
26  unsigned int numY = 0;
27  unsigned int numXorY = 0;
28 
29  for (unsigned int j = 0; j < genParticles_->size(); j++) {
31 
32  // Is it X -> f fbar ?
33  bool isXtoFFbar = this->foundXtoFFbar(moth, idMotherX_, idDaughterF_);
34  if (isXtoFFbar) numX++;
35 
36  if (!requireY_) {
37 
38  // Has X been found already ?
39  if (numX >= 1) return true;
40 
41  } else {
42 
43  // Is it Y -> g gbar ?
44  bool isYtoGGbar = this->foundXtoFFbar(moth, idMotherY_, idDaughterG_);
45  if (isYtoGGbar) numY++;
46  if (isXtoFFbar || isYtoGGbar) numXorY++;
47 
48  // Have X and Y been found already ?
49  if (numX >= 1 && numY >= 1 && numXorY >= 2) return true;
50  }
51  }
52 
54  // cout<<"REJECTED "<<totalEvents_<<endl;
55  return false;
56 }
57 
58 
60  const vector<int>& idMother,
61  const vector<int>& idDaughter) {
62  // Check if given particle "moth" is X-->f fbar
63  bool isXtoFFbar = false;
64  int pdgIdMoth = moth->pdgId();
65  double rho = -9.9e9;
66 
67  if (this->found(idMother, pdgIdMoth)) {
68  bool foundF = false;
69  bool foundFbar = false;
70  unsigned int nDau = moth->numberOfDaughters();
71 
72  for (unsigned int i = 0; i < nDau; i++) {
73  GenParticleRef dau = moth->daughterRef(i);
74  int pdgIdDau = dau->pdgId();
75  if (this->found(idDaughter, -pdgIdDau)) foundFbar = true;
76  if (this->found(idDaughter, pdgIdDau)) {foundF = true;
77 
78  // Just for statistics, get transverse decay length.
79  // This is the normal case
80  rho = dau->vertex().Rho();
81  // Unfortunately, duplicate particles can appear in the event record. Handle this as follows:
82  for (unsigned int j = 0; j < dau->numberOfDaughters(); j++) {
83  GenParticleRef granddau = dau->daughterRef(j);
84  if (granddau->pdgId() == pdgIdDau) rho = granddau->vertex().Rho();
85  }
86  }
87  }
88  if (foundF && foundFbar) isXtoFFbar = true;
89  }
90 
91  if (isXtoFFbar) {
92  // Get statistics
93  xTotal_++;
94  xSumPt_ += moth->pt();
95  xSumR_ += rho;
96  }
97 
98  return isXtoFFbar;
99 }
100 
102  cout<<endl;
103  cout<<"=== XtoFFbarFilter statistics of selected X->ffbar or Y->ggbar"<<endl;
104  if (xTotal_ > 0) {
105  cout<<"=== mean X & Y Pt = "<<xSumPt_/xTotal_<<" and transverse decay length = "<<xSumR_/xTotal_<<endl;
106  } else {
107  cout<<"=== WARNING: NONE FOUND !"<<endl;
108  }
109  cout<<"=== events rejected = "<<rejectedEvents_<<"/"<<totalEvents_<<endl;
110 }
int i
Definition: DBlmapReader.cc:9
XtoFFbarFilter(const edm::ParameterSet &)
virtual void endJob()
bool found(const std::vector< int > v, int j)
Definition: DDAxes.h:10
edm::InputTag src_
unsigned int rejectedEvents_
std::vector< int > idMotherX_
int iEvent
Definition: GenABIO.cc:243
std::vector< int > idMotherY_
unsigned int totalEvents_
std::vector< int > idDaughterG_
edm::Handle< reco::GenParticleCollection > genParticles_
int j
Definition: DBlmapReader.cc:9
unsigned int xTotal_
std::vector< int > idDaughterF_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
bool foundXtoFFbar(const reco::GenParticleRef &moth, const std::vector< int > &idMotherX, const std::vector< int > &idDaughterF)
virtual bool filter(edm::Event &iEvent, const edm::EventSetup &iSetup)
tuple cout
Definition: gather_cfg.py:121