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 
52 
53 template<typename Isolator>
55 public:
57  isolator_(cfg.template getParameter<double>("isoCut")) {
58  std::string iso = cfg.template getParameter<std::string>("isolationType");
59  if(iso == "track") {
62  }
63  else if(iso == "ecal") {
66  }
67  else if(iso == "hcal") {
70  }
71  else if(iso == "calo") {
74  }
76  << "Invalid isolation type: " << iso << ". Valid types are:"
77  << "'track', 'ecal', 'hcal', 'calo'\n";
78  }
79  bool operator()(const reco::Candidate & z) const {
80  if(z.numberOfDaughters()!=2)
82  << "Candidate has " << z.numberOfDaughters() << " daughters, 2 expected\n";
83  const reco::Candidate * dau0 = z.daughter(0);
84  const reco::Candidate * dau1 = z.daughter(1);
85  if(!(dau0->hasMasterClone()&&dau1->hasMasterClone()))
87  << "Candidate daughters have no master clone\n";
88  const reco::Candidate * m0 = &*dau0->masterClone(), * m1 = &*dau1->masterClone();
89  double iso0 = -1, iso1 = -1;
90  const pat::Muon * mu0 = dynamic_cast<const pat::Muon *>(m0);
91  if(mu0 != 0) {
92  iso0 = ((*mu0).*(leptonIsolation_))();
93  } else {
94  const pat::GenericParticle * trk0 = dynamic_cast<const pat::GenericParticle*>(m0);
95  if(trk0 != 0) {
96  iso0 = ((*trk0).*(trackIsolation_))();
97  } else {
99  << "Candidate daughter #0 is neither pat::Muons nor pat::GenericParticle\n";
100  }
101  }
102  const pat::Muon * mu1 = dynamic_cast<const pat::Muon *>(m1);
103  if(mu1 != 0) {
104  iso1 = ((*mu1).*(leptonIsolation_))();
105  } else {
106  const pat::GenericParticle * trk1 = dynamic_cast<const pat::GenericParticle*>(m1);
107  if(trk1 != 0) {
108  iso1 = ((*trk1).*(trackIsolation_))();
109  } else {
111  << "Candidate daughter #1 is neither pat::Muons nor pat::GenericParticle\n";
112  }
113  }
114  bool pass = isolator_(iso0, iso1);
115  return pass;
116  }
117  private:
118  typedef float (pat::Lepton<reco::Muon>::*LeptonIsolationType)() const;
119  typedef float (pat::GenericParticle::*TrackIsolationType)() const;
122  Isolator isolator_;
123 };
124 
125 namespace dummy {
126  void Isolationdummy() {
128  //ignore return values
129  pat.trackIso(); pat.ecalIso(); pat.hcalIso(); pat.caloIso();
130  }
131 }
132 
136 
140  >
142 
146  >
148 
149 
153  >
155 
159  >
161 
162 
164 
float(pat::Lepton< reco::Muon >::* LeptonIsolationType)() const
float ecalIso() const
Definition: Lepton.h:126
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
float(pat::GenericParticle::* TrackIsolationType)() const
bool operator()(double i1, double i2) const
float trackIso() const
float float float z
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
Analysis-level lepton class.
Definition: Lepton.h:30
bool operator()(double i1, double i2) const
float trackIso() const
Definition: Lepton.h:116
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:121
float hcalIso() const
Definition: Lepton.h:131
float ecalIso() const
Analysis-level muon class.
Definition: Muon.h:49
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
ZToMuMuIsolationSelector(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)