CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RawParticleTypeFilter.cc
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 // Prototype for a particle class
3 // -----------------------------------------------------------------------------
4 // $Date: 2007/05/18 09:12:46 $
5 // $Revision: 1.4 $
6 // -----------------------------------------------------------------------------
7 // Author: Stephan Wynhoff - RWTH-Aachen (Email: Stephan.Wynhoff@cern.ch)
8 // -----------------------------------------------------------------------------
14 
15 RawParticleTypeFilter::RawParticleTypeFilter(const std::string& particleName) {
17  RawParticle tmp(particleName,one);
18 // cout << tmp.pid() << endl;
19  myAcceptIDs.push_back(tmp.pid());
20 }
21 
22 RawParticleTypeFilter::RawParticleTypeFilter(const std::string& particleName1,
23  const std::string& particleName2) {
25  RawParticle tmp1(particleName1,one),tmp2(particleName2,one);
26 // cout << tmp1.pid() << endl;
27 // cout << tmp2.pid() << endl;
28  myAcceptIDs.push_back(tmp1.pid());
29  myAcceptIDs.push_back(tmp2.pid());
30 }
31 
33  myAcceptIDs.push_back(pid);
34 }
35 
36 RawParticleTypeFilter::RawParticleTypeFilter(const int pid1, const int pid2) {
37  myAcceptIDs.push_back(pid1);
38  myAcceptIDs.push_back(pid2);
39 }
40 
42  myAcceptIDs.push_back(pid);
43  myRejectIDs.clear();
44 }
45 
46 void RawParticleTypeFilter::addAccept(const std::string& name) {
48  RawParticle tmp(name,one);
49  this->addAccept(tmp.pid());
50 }
51 
53  myRejectIDs.push_back(pid);
54  myAcceptIDs.clear();
55 }
56 
57 void RawParticleTypeFilter::addReject(const std::string& name) {
59  RawParticle tmp(name,one);
60  this->addReject(tmp.pid());
61 }
62 
64 {
65  bool acceptThis = true;
66  if (myAcceptIDs.size() > 0) {
67  acceptThis = this->isAcceptable(p->pid());
68  }
69  if (myRejectIDs.size() > 0) {
70  acceptThis = ! this->isRejectable(p->pid());
71  }
72  return acceptThis;
73 }
74 
75 bool RawParticleTypeFilter::isAcceptable(const int id) const
76 {
77  bool acceptThis = false;
78 
79  std::vector<int>::const_iterator myAcceptIDsItr;
80  for (myAcceptIDsItr = myAcceptIDs.begin(); myAcceptIDsItr != myAcceptIDs.end();
81  myAcceptIDsItr++) {
82  if (id == (*myAcceptIDsItr)) {
83  acceptThis = true;
84  }
85  }
86  return acceptThis;
87 }
88 
89 bool RawParticleTypeFilter::isRejectable(const int id) const
90 {
91  bool acceptThis = false;
92 
93  std::vector<int>::const_iterator myRejectIDsItr;
94  for (myRejectIDsItr = myRejectIDs.begin(); myRejectIDsItr != myRejectIDs.end();
95  myRejectIDsItr++) {
96  if (id == (*myRejectIDsItr)) {
97  acceptThis = true;
98  }
99  }
100  return acceptThis;
101 }
int pid() const
get the HEP particle ID number
Definition: RawParticle.h:264
bool isOKForMe(const RawParticle *p) const
implemented as required by class BaseRawParticleFilter
std::vector< int > myRejectIDs
void addAccept(const int id)
bool isRejectable(const int id) const
is this particle id in the list of rejectable particles?
std::vector< int > myAcceptIDs
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
bool isAcceptable(const int id) const
is this particle id in the list of acceptable particles?
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:15
void addReject(const int id)