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 {
10  return i1 < cut_ && i2 < cut_;
11  }
12  double cut() const { return cut_; }
13 private:
14  double cut_;
15 };
16 
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 
57 
58 using namespace reco;
59 using namespace isodeposit;
60 
61 template<typename Isolator>
63 public:
65  isolator_(cfg.template getParameter<double>("isoCut")),
66  ptThreshold(cfg.getUntrackedParameter<double>("ptThreshold")),
67  etEcalThreshold(cfg.getUntrackedParameter<double>("etEcalThreshold")),
68  etHcalThreshold(cfg.getUntrackedParameter<double>("etHcalThreshold")),
69  dRVetoTrk(cfg.getUntrackedParameter<double>("deltaRVetoTrk")),
70  dRTrk(cfg.getUntrackedParameter<double>("deltaRTrk")),
71  dREcal(cfg.getUntrackedParameter<double>("deltaREcal")),
72  dRHcal(cfg.getUntrackedParameter<double>("deltaRHcal")),
73  alpha(cfg.getUntrackedParameter<double>("alpha")),
74  beta(cfg.getUntrackedParameter<double>("beta")),
75  relativeIsolation(cfg.template getParameter<bool>("relativeIsolation")) {
76  }
77 
78  template<typename T>
79  double isolation(const T * t) const {
80  const pat::IsoDeposit * trkIso = t->isoDeposit(pat::TrackIso);
81  const pat::IsoDeposit * ecalIso = t->isoDeposit(pat::EcalIso);
82  const pat::IsoDeposit * hcalIso = t->isoDeposit(pat::HcalIso);
83 
84  Direction dir = Direction(t->eta(), t->phi());
85 
86  IsoDeposit::AbsVetos vetosTrk;
87  vetosTrk.push_back(new ConeVeto( dir, dRVetoTrk ));
88  vetosTrk.push_back(new ThresholdVeto( ptThreshold ));
89 
90  IsoDeposit::AbsVetos vetosEcal;
91  vetosEcal.push_back(new ConeVeto( dir, 0.));
92  vetosEcal.push_back(new ThresholdVeto( etEcalThreshold ));
93 
94  IsoDeposit::AbsVetos vetosHcal;
95  vetosHcal.push_back(new ConeVeto( dir, 0. ));
96  vetosHcal.push_back(new ThresholdVeto( etHcalThreshold ));
97 
98  double isovalueTrk = (trkIso->sumWithin(dRTrk,vetosTrk));
99  double isovalueEcal = (ecalIso->sumWithin(dREcal,vetosEcal));
100  double isovalueHcal = (hcalIso->sumWithin(dRHcal,vetosHcal));
101 
102 
103  double iso = alpha*( ((1+beta)/2*isovalueEcal) + ((1-beta)/2*isovalueHcal) ) + ((1-alpha)*isovalueTrk) ;
104  if(relativeIsolation) iso /= t->pt();
105  return iso;
106  }
107 
108  double candIsolation(const reco::Candidate* c) const {
109  const pat::Muon * mu = dynamic_cast<const pat::Muon *>(c);
110  if(mu != nullptr) return isolation(mu);
111  const pat::GenericParticle * trk = dynamic_cast<const pat::GenericParticle*>(c);
112  if(trk != nullptr) return isolation(trk);
114  << "Candidate daughter #0 is neither pat::Muons nor pat::GenericParticle\n";
115  return -1;
116  }
117  bool operator()(const reco::Candidate & z) const {
118  if(z.numberOfDaughters()!=2)
120  << "Candidate has " << z.numberOfDaughters() << " daughters, 2 expected\n";
121  const reco::Candidate * dau0 = z.daughter(0);
122  const reco::Candidate * dau1 = z.daughter(1);
123  if(!(dau0->hasMasterClone()&&dau1->hasMasterClone()))
125  << "Candidate daughters have no master clone\n";
126  const reco::Candidate * m0 = &*dau0->masterClone(), * m1 = &*dau1->masterClone();
127  return isolator_(candIsolation(m0), candIsolation(m1));
128  }
129 private:
130  Isolator isolator_;
131  double ptThreshold,etEcalThreshold,etHcalThreshold, dRVetoTrk, dRTrk, dREcal, dRHcal, alpha, beta;
133 
134 };
135 
139 
143  >
145 
149  >
151 
152 
156  >
158 
162  >
164 
165 
167 
float alpha
Definition: AMPTWrapper.h:95
ZToMuMuIsoDepositSelector(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsoDepositSelector< TwoNonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuTwoNonIsolatedIDSelector
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:138
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< NonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuNonIsolatedIDSelector
bool operator()(const reco::Candidate &z) const
bool operator()(double i1, double i2) const
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
const int mu
Definition: Constants.h:22
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsoDepositSelector< IsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuIsolatedIDSelector
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
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsoDepositSelector< OneNonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuOneNonIsolatedIDSelector
fixed size matrix
std::vector< AbsVeto * > AbsVetos
Definition: IsoDeposit.h:40
dbl *** dir
Definition: mlp_gen.cc:35
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