CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ZToMuMuIsolationSelector.cc
Go to the documentation of this file.
1 /* \class ZToMuMuIsolationSelector
2  *
3  * \author Luca Lista, INFN
4  *
5  */
6 
7 struct IsolatedSelector {
8  IsolatedSelector(double cut) : cut_(cut) { }
9  bool operator()(double i1, double i2) const {
10  return i1 < cut_ && i2 < cut_;
11  }
12  double cut() const { return cut_; }
13 private:
14  double cut_;
15 };
16 
17 struct NonIsolatedSelector {
18  NonIsolatedSelector(double cut) : isolated_(cut) { }
19  bool operator()(double i1, double i2) const {
20  return !isolated_(i1, i2);
21  }
22  double cut() const { return isolated_.cut(); }
23 private:
25 };
26 
28  OneNonIsolatedSelector(double cut) : cut_(cut) { }
29  bool operator()(double i1, double i2) const {
30  return (i1 < cut_ && i2 >= cut_) || (i1 >= cut_ && i2 < cut_);
31  }
32  double cut() const { return cut_; }
33 private:
34  double cut_;
35 };
36 
38  TwoNonIsolatedSelector(double cut) : cut_(cut) { }
39  bool operator()(double i1, double i2) const {
40  return i1 >= cut_ && i2 >= cut_;
41  }
42  double cut() const { return cut_; }
43 private:
44  double cut_;
45 };
46 
51 
52 template<typename Isolator>
54 public:
56  isolator_(cfg.template getParameter<double>("isoCut")) {
57  std::string iso = cfg.template getParameter<std::string>("isolationType");
58  if(iso == "track") {
61  }
62  else if(iso == "ecal") {
65  }
66  else if(iso == "hcal") {
69  }
70  else if(iso == "calo") {
73  }
75  << "Invalid isolation type: " << iso << ". Valid types are:"
76  << "'track', 'ecal', 'hcal', 'calo'\n";
77  }
78  bool operator()(const reco::Candidate & z) const {
79  if(z.numberOfDaughters()!=2)
81  << "Candidate has " << z.numberOfDaughters() << " daughters, 2 expected\n";
82  const reco::Candidate * dau0 = z.daughter(0);
83  const reco::Candidate * dau1 = z.daughter(1);
84  if(!(dau0->hasMasterClone()&&dau1->hasMasterClone()))
86  << "Candidate daughters have no master clone\n";
87  const reco::Candidate * m0 = &*dau0->masterClone(), * m1 = &*dau1->masterClone();
88  double iso0 = -1, iso1 = -1;
89  const pat::Muon * mu0 = dynamic_cast<const pat::Muon *>(m0);
90  if(mu0 != 0) {
91  iso0 = ((*mu0).*(leptonIsolation_))();
92  } else {
93  const pat::GenericParticle * trk0 = dynamic_cast<const pat::GenericParticle*>(m0);
94  if(trk0 != 0) {
95  iso0 = ((*trk0).*(trackIsolation_))();
96  } else {
98  << "Candidate daughter #0 is neither pat::Muons nor pat::GenericParticle\n";
99  }
100  }
101  const pat::Muon * mu1 = dynamic_cast<const pat::Muon *>(m1);
102  if(mu1 != 0) {
103  iso1 = ((*mu1).*(leptonIsolation_))();
104  } else {
105  const pat::GenericParticle * trk1 = dynamic_cast<const pat::GenericParticle*>(m1);
106  if(trk1 != 0) {
107  iso1 = ((*trk1).*(trackIsolation_))();
108  } else {
110  << "Candidate daughter #1 is neither pat::Muons nor pat::GenericParticle\n";
111  }
112  }
113  bool pass = isolator_(iso0, iso1);
114  return pass;
115  }
116  private:
117  typedef float (pat::Lepton<reco::Muon>::*LeptonIsolationType)() const;
118  typedef float (pat::GenericParticle::*TrackIsolationType)() const;
121  Isolator isolator_;
122 };
123 
124 namespace dummy {
125  void Isolationdummy() {
127  float x;
128  x = pat.trackIso(); x = pat.ecalIso(); x = pat.hcalIso(); x = pat.caloIso();
129  }
130 }
131 
135 
139  >
141 
145  >
147 
148 
152  >
154 
158  >
160 
161 
163 
float(pat::Lepton< reco::Muon >::* LeptonIsolationType)() const
float ecalIso() const
Definition: Lepton.h:127
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsolationSelector< OneNonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuOneNonIsolatedSelector
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
ZToMuMuIsolationSelector(const edm::ParameterSet &cfg)
float(pat::GenericParticle::* TrackIsolationType)() const
bool operator()(double i1, double i2) const
float trackIso() const
float hcalIso() const
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
virtual size_type numberOfDaughters() const =0
number of daughters
virtual bool hasMasterClone() const =0
Definition: DDAxes.h:10
Analysis-level lepton class.
Definition: Lepton.h:32
bool operator()(double i1, double i2) const
float trackIso() const
Definition: Lepton.h:117
float caloIso() const
bool operator()(double i1, double i2) const
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsolationSelector< IsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuIsolatedSelector
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsolationSelector< NonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuNonIsolatedSelector
float caloIso() const
Definition: Lepton.h:122
float hcalIso() const
Definition: Lepton.h:132
float ecalIso() const
Analysis-level muon class.
Definition: Muon.h:47
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsolationSelector< TwoNonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuTwoNonIsolatedSelector
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition: CandidateFwd.h:23
def template
Definition: svgfig.py:520
bool operator()(double i1, double i2) const
bool operator()(const reco::Candidate &z) const
virtual const CandidateBaseRef & masterClone() const =0