CMS 3D CMS Logo

ZToMuMuIsoDepositSelector.cc
Go to the documentation of this file.
1 /* \class ZToMuMuIsolationSelector
2  *
3  * \author Luca Lista, INFN
4  *
5  */
6 
8  IsolatedSelector(double cut) : cut_(cut) {}
9  bool operator()(double i1, double i2) const { return i1 < cut_ && i2 < cut_; }
10  double cut() const { return cut_; }
11 
12 private:
13  double cut_;
14 };
15 
17  NonIsolatedSelector(double cut) : isolated_(cut) {}
18  bool operator()(double i1, double i2) const { return !isolated_(i1, i2); }
19  double cut() const { return isolated_.cut(); }
20 
21 private:
23 };
24 
26  OneNonIsolatedSelector(double cut) : cut_(cut) {}
27  bool operator()(double i1, double i2) const { return (i1 < cut_ && i2 >= cut_) || (i1 >= cut_ && i2 < cut_); }
28  double cut() const { return cut_; }
29 
30 private:
31  double cut_;
32 };
33 
35  TwoNonIsolatedSelector(double cut) : cut_(cut) {}
36  bool operator()(double i1, double i2) const { return i1 >= cut_ && i2 >= cut_; }
37  double cut() const { return cut_; }
38 
39 private:
40  double cut_;
41 };
42 
53 
54 using namespace reco;
55 using namespace isodeposit;
56 
57 template <typename Isolator>
59 public:
61  : isolator_(cfg.template getParameter<double>("isoCut")),
62  ptThreshold(cfg.getUntrackedParameter<double>("ptThreshold")),
63  etEcalThreshold(cfg.getUntrackedParameter<double>("etEcalThreshold")),
64  etHcalThreshold(cfg.getUntrackedParameter<double>("etHcalThreshold")),
65  dRVetoTrk(cfg.getUntrackedParameter<double>("deltaRVetoTrk")),
66  dRTrk(cfg.getUntrackedParameter<double>("deltaRTrk")),
67  dREcal(cfg.getUntrackedParameter<double>("deltaREcal")),
68  dRHcal(cfg.getUntrackedParameter<double>("deltaRHcal")),
69  alpha(cfg.getUntrackedParameter<double>("alpha")),
70  beta(cfg.getUntrackedParameter<double>("beta")),
71  relativeIsolation(cfg.template getParameter<bool>("relativeIsolation")) {}
72 
73  template <typename T>
74  double isolation(const T* t) const {
75  const pat::IsoDeposit* trkIso = t->isoDeposit(pat::TrackIso);
76  const pat::IsoDeposit* ecalIso = t->isoDeposit(pat::EcalIso);
77  const pat::IsoDeposit* hcalIso = t->isoDeposit(pat::HcalIso);
78 
79  Direction dir = Direction(t->eta(), t->phi());
80 
81  IsoDeposit::AbsVetos vetosTrk;
82  vetosTrk.push_back(new ConeVeto(dir, dRVetoTrk));
83  vetosTrk.push_back(new ThresholdVeto(ptThreshold));
84 
85  IsoDeposit::AbsVetos vetosEcal;
86  vetosEcal.push_back(new ConeVeto(dir, 0.));
87  vetosEcal.push_back(new ThresholdVeto(etEcalThreshold));
88 
89  IsoDeposit::AbsVetos vetosHcal;
90  vetosHcal.push_back(new ConeVeto(dir, 0.));
91  vetosHcal.push_back(new ThresholdVeto(etHcalThreshold));
92 
93  double isovalueTrk = (trkIso->sumWithin(dRTrk, vetosTrk));
94  double isovalueEcal = (ecalIso->sumWithin(dREcal, vetosEcal));
95  double isovalueHcal = (hcalIso->sumWithin(dRHcal, vetosHcal));
96 
97  double iso =
98  alpha * (((1 + beta) / 2 * isovalueEcal) + ((1 - beta) / 2 * isovalueHcal)) + ((1 - alpha) * isovalueTrk);
100  iso /= t->pt();
101  return iso;
102  }
103 
104  double candIsolation(const reco::Candidate* c) const {
105  const pat::Muon* mu = dynamic_cast<const pat::Muon*>(c);
106  if (mu != nullptr)
107  return isolation(mu);
108  const pat::GenericParticle* trk = dynamic_cast<const pat::GenericParticle*>(c);
109  if (trk != nullptr)
110  return isolation(trk);
112  << "Candidate daughter #0 is neither pat::Muons nor pat::GenericParticle\n";
113  return -1;
114  }
115  bool operator()(const reco::Candidate& z) const {
116  if (z.numberOfDaughters() != 2)
118  << "Candidate has " << z.numberOfDaughters() << " daughters, 2 expected\n";
119  const reco::Candidate* dau0 = z.daughter(0);
120  const reco::Candidate* dau1 = z.daughter(1);
121  if (!(dau0->hasMasterClone() && dau1->hasMasterClone()))
122  throw edm::Exception(edm::errors::InvalidReference) << "Candidate daughters have no master clone\n";
123  const reco::Candidate *m0 = &*dau0->masterClone(), *m1 = &*dau1->masterClone();
124  return isolator_(candIsolation(m0), candIsolation(m1));
125  }
126 
127 private:
128  Isolator isolator_;
131 };
132 
136 
137 typedef SingleObjectSelector<
141 
142 typedef SingleObjectSelector<
146 
147 typedef SingleObjectSelector<
151 
152 typedef SingleObjectSelector<
156 
158 
ZToMuMuIsoDepositSelector(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsoDepositSelector< IsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuIsolatedIDSelector
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
double candIsolation(const reco::Candidate *c) const
bool operator()(double i1, double i2) const
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:137
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsoDepositSelector< OneNonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuOneNonIsolatedIDSelector
bool operator()(const reco::Candidate &z) const
bool operator()(double i1, double i2) const
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
double candIsolation(const reco::Candidate *c, double ptThreshold, double etEcalThreshold, double etHcalThreshold, double dRVetoTrk, double dRTrk, double dREcal, double dRHcal, double alpha, double beta, bool relativeIsolation)
bool operator()(double i1, double i2) const
virtual const CandidateBaseRef & masterClone() const =0
double isolation(const T *t) const
fixed size matrix
std::vector< AbsVeto * > AbsVetos
Definition: IsoDeposit.h:43
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsoDepositSelector< TwoNonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuTwoNonIsolatedIDSelector
alpha
zGenParticlesMatch = cms.InputTag(""),
virtual size_type numberOfDaughters() const =0
number of daughters
long double T
Analysis-level muon class.
Definition: Muon.h:51
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition: CandidateFwd.h:23
bool operator()(double i1, double i2) const
virtual bool hasMasterClone() const =0
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsoDepositSelector< NonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuNonIsolatedIDSelector