ElectroWeakAnalysis
ZMuMu
plugins
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
{
return
i1
<
cut_
&&
i2
<
cut_
; }
10
double
cut
()
const
{
return
cut_
; }
11
12
private
:
13
double
cut_
;
14
};
15
16
struct
NonIsolatedSelector
{
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
:
22
IsolatedSelector
isolated_
;
23
};
24
25
struct
OneNonIsolatedSelector
{
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
34
struct
TwoNonIsolatedSelector
{
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
43
#include "
FWCore/Framework/interface/ConsumesCollector.h
"
44
#include "
DataFormats/PatCandidates/interface/Muon.h
"
45
#include "
DataFormats/PatCandidates/interface/GenericParticle.h
"
46
#include "
FWCore/Utilities/interface/EDMException.h
"
47
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
48
49
template
<
typename
Isolator>
50
class
ZToMuMuIsolationSelector
{
51
public
:
52
ZToMuMuIsolationSelector
(
const
edm::ParameterSet
&
cfg
,
edm::ConsumesCollector
&iC)
53
:
isolator_
(
cfg
.
template
getParameter<double>(
"isoCut"
)) {
54
std::string
iso =
cfg
.template getParameter<std::string>(
"isolationType"
);
55
if
(iso ==
"track"
) {
56
leptonIsolation_
= &
pat::Lepton<reco::Muon>::trackIso
;
57
trackIsolation_
= &
pat::GenericParticle::trackIso
;
58
}
else
if
(iso ==
"ecal"
) {
59
leptonIsolation_
= &
pat::Lepton<reco::Muon>::ecalIso
;
60
trackIsolation_
= &
pat::GenericParticle::ecalIso
;
61
}
else
if
(iso ==
"hcal"
) {
62
leptonIsolation_
= &
pat::Lepton<reco::Muon>::hcalIso
;
63
trackIsolation_
= &
pat::GenericParticle::hcalIso
;
64
}
else
if
(iso ==
"calo"
) {
65
leptonIsolation_
= &
pat::Lepton<reco::Muon>::caloIso
;
66
trackIsolation_
= &
pat::GenericParticle::caloIso
;
67
}
else
68
throw
edm::Exception
(
edm::errors::Configuration
) <<
"Invalid isolation type: "
<< iso <<
". Valid types are:"
69
<<
"'track', 'ecal', 'hcal', 'calo'\n"
;
70
}
71
bool
operator()
(
const
reco::Candidate
&
z
)
const
{
72
if
(
z
.numberOfDaughters() != 2)
73
throw
edm::Exception
(
edm::errors::InvalidReference
)
74
<<
"Candidate has "
<<
z
.numberOfDaughters() <<
" daughters, 2 expected\n"
;
75
const
reco::Candidate
*dau0 =
z
.daughter(0);
76
const
reco::Candidate
*dau1 =
z
.daughter(1);
77
if
(!(dau0->
hasMasterClone
() && dau1->
hasMasterClone
()))
78
throw
edm::Exception
(
edm::errors::InvalidReference
) <<
"Candidate daughters have no master clone\n"
;
79
const
reco::Candidate
*m0 = &*dau0->
masterClone
(), *m1 = &*dau1->
masterClone
();
80
double
iso0 = -1, iso1 = -1;
81
const
pat::Muon
*mu0 = dynamic_cast<const pat::Muon *>(m0);
82
if
(mu0 !=
nullptr
) {
83
iso0 = ((*mu0).*(
leptonIsolation_
))();
84
}
else
{
85
const
pat::GenericParticle
*trk0 = dynamic_cast<const pat::GenericParticle *>(m0);
86
if
(trk0 !=
nullptr
) {
87
iso0 = ((*trk0).*(
trackIsolation_
))();
88
}
else
{
89
throw
edm::Exception
(
edm::errors::InvalidReference
)
90
<<
"Candidate daughter #0 is neither pat::Muons nor pat::GenericParticle\n"
;
91
}
92
}
93
const
pat::Muon
*mu1 = dynamic_cast<const pat::Muon *>(m1);
94
if
(mu1 !=
nullptr
) {
95
iso1 = ((*mu1).*(
leptonIsolation_
))();
96
}
else
{
97
const
pat::GenericParticle
*trk1 = dynamic_cast<const pat::GenericParticle *>(m1);
98
if
(trk1 !=
nullptr
) {
99
iso1 = ((*trk1).*(
trackIsolation_
))();
100
}
else
{
101
throw
edm::Exception
(
edm::errors::InvalidReference
)
102
<<
"Candidate daughter #1 is neither pat::Muons nor pat::GenericParticle\n"
;
103
}
104
}
105
bool
pass =
isolator_
(iso0, iso1);
106
return
pass;
107
}
108
109
private
:
110
typedef
float
(
pat::Lepton<reco::Muon>
::*
LeptonIsolationType
)()
const
;
111
typedef
float
(
pat::GenericParticle
::*
TrackIsolationType
)()
const
;
112
LeptonIsolationType
leptonIsolation_
;
113
TrackIsolationType
trackIsolation_
;
114
Isolator
isolator_
;
115
};
116
117
namespace
dummy
{
118
void
Isolationdummy
() {
119
pat::Lepton<reco::Muon>
pat
;
120
//ignore return values
121
pat
.trackIso();
122
pat
.ecalIso();
123
pat
.hcalIso();
124
pat
.caloIso();
125
}
126
}
// namespace dummy
127
128
#include "
CommonTools/UtilAlgos/interface/SingleObjectSelector.h
"
129
#include "
CommonTools/UtilAlgos/interface/AndSelector.h
"
130
#include "
CommonTools/UtilAlgos/interface/StringCutObjectSelector.h
"
131
132
typedef
SingleObjectSelector
<
133
reco::CandidateView
,
134
AndSelector<ZToMuMuIsolationSelector<IsolatedSelector>
,
StringCutObjectSelector<reco::Candidate>
> >
135
ZToMuMuIsolatedSelector
;
136
137
typedef
SingleObjectSelector
<
138
reco::CandidateView
,
139
AndSelector<ZToMuMuIsolationSelector<NonIsolatedSelector>
,
StringCutObjectSelector<reco::Candidate>
> >
140
ZToMuMuNonIsolatedSelector
;
141
142
typedef
SingleObjectSelector
<
143
reco::CandidateView
,
144
AndSelector<ZToMuMuIsolationSelector<OneNonIsolatedSelector>
,
StringCutObjectSelector<reco::Candidate>
> >
145
ZToMuMuOneNonIsolatedSelector
;
146
147
typedef
SingleObjectSelector
<
148
reco::CandidateView
,
149
AndSelector<ZToMuMuIsolationSelector<TwoNonIsolatedSelector>
,
StringCutObjectSelector<reco::Candidate>
> >
150
ZToMuMuTwoNonIsolatedSelector
;
151
152
#include "
FWCore/Framework/interface/MakerMacros.h
"
153
154
DEFINE_FWK_MODULE
(
ZToMuMuIsolatedSelector
);
155
DEFINE_FWK_MODULE
(
ZToMuMuNonIsolatedSelector
);
156
DEFINE_FWK_MODULE
(
ZToMuMuOneNonIsolatedSelector
);
157
DEFINE_FWK_MODULE
(
ZToMuMuTwoNonIsolatedSelector
);
OneNonIsolatedSelector
Definition:
ZToMuMuIsoDepositSelector.cc:25
ZToMuMuIsolationSelector::ZToMuMuIsolationSelector
ZToMuMuIsolationSelector(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
Definition:
ZToMuMuIsolationSelector.cc:52
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition:
testProducerWithPsetDescEmpty_cfi.py:46
reco::CandidateView
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition:
CandidateFwd.h:23
OneNonIsolatedSelector::operator()
bool operator()(double i1, double i2) const
Definition:
ZToMuMuIsolationSelector.cc:27
ZToMuMuIsolationSelector::LeptonIsolationType
float(pat::Lepton< reco::Muon >::* LeptonIsolationType)() const
Definition:
ZToMuMuIsolationSelector.cc:110
dqmMemoryStats.float
float
Definition:
dqmMemoryStats.py:127
ZToMuMuOneNonIsolatedSelector
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsolationSelector< OneNonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuOneNonIsolatedSelector
Definition:
ZToMuMuIsolationSelector.cc:145
edm::errors::InvalidReference
Definition:
EDMException.h:39
StringCutObjectSelector.h
AndSelector
Definition:
AndSelector.h:26
ZToMuMuNonIsolatedSelector
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsolationSelector< NonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuNonIsolatedSelector
Definition:
ZToMuMuIsolationSelector.cc:140
NonIsolatedSelector
Definition:
ZToMuMuIsoDepositSelector.cc:16
pat::GenericParticle::caloIso
float caloIso() const
Definition:
GenericParticle.h:222
Muon.h
GenericParticle.h
SingleObjectSelector.h
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition:
testProducerWithPsetDescEmpty_cfi.py:45
pat::Lepton
Analysis-level lepton class.
Definition:
Lepton.h:29
IsolatedSelector::cut_
double cut_
Definition:
ZToMuMuIsoDepositSelector.cc:13
pat::GenericParticle::trackIso
float trackIso() const
Definition:
GenericParticle.h:218
NonIsolatedSelector::cut
double cut() const
Definition:
ZToMuMuIsoDepositSelector.cc:19
NonIsolatedSelector::isolated_
IsolatedSelector isolated_
Definition:
ZToMuMuIsoDepositSelector.cc:22
ZToMuMuIsolationSelector::TrackIsolationType
float(pat::GenericParticle::* TrackIsolationType)() const
Definition:
ZToMuMuIsolationSelector.cc:111
pat::GenericParticle::ecalIso
float ecalIso() const
Definition:
GenericParticle.h:225
pat::Muon
Analysis-level muon class.
Definition:
Muon.h:51
dummy::Isolationdummy
void Isolationdummy()
Definition:
ZToMuMuIsolationSelector.cc:118
IsolatedSelector::cut
double cut() const
Definition:
ZToMuMuIsoDepositSelector.cc:10
ZToMuMuTwoNonIsolatedSelector
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsolationSelector< TwoNonIsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuTwoNonIsolatedSelector
Definition:
ZToMuMuIsolationSelector.cc:150
ZToMuMuIsolationSelector::trackIsolation_
TrackIsolationType trackIsolation_
Definition:
ZToMuMuIsolationSelector.cc:113
edm::Exception
Definition:
EDMException.h:77
EDMException.h
TwoNonIsolatedSelector::TwoNonIsolatedSelector
TwoNonIsolatedSelector(double cut)
Definition:
ZToMuMuIsolationSelector.cc:35
NonIsolatedSelector::NonIsolatedSelector
NonIsolatedSelector(double cut)
Definition:
ZToMuMuIsolationSelector.cc:17
MakerMacros.h
ZToMuMuIsolationSelector::operator()
bool operator()(const reco::Candidate &z) const
Definition:
ZToMuMuIsolationSelector.cc:71
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
DDAxes::z
TwoNonIsolatedSelector::cut_
double cut_
Definition:
ZToMuMuIsoDepositSelector.cc:40
pat::GenericParticle::hcalIso
float hcalIso() const
Definition:
GenericParticle.h:228
reco::Candidate::hasMasterClone
virtual bool hasMasterClone() const =0
ZToMuMuIsolatedSelector
SingleObjectSelector< reco::CandidateView, AndSelector< ZToMuMuIsolationSelector< IsolatedSelector >, StringCutObjectSelector< reco::Candidate > > > ZToMuMuIsolatedSelector
Definition:
ZToMuMuIsolationSelector.cc:135
TwoNonIsolatedSelector::cut
double cut() const
Definition:
ZToMuMuIsoDepositSelector.cc:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
pat::GenericParticle
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed)
Definition:
GenericParticle.h:38
edm::ParameterSet
Definition:
ParameterSet.h:47
OneNonIsolatedSelector::cut
double cut() const
Definition:
ZToMuMuIsoDepositSelector.cc:28
ZToMuMuIsolationSelector::isolator_
Isolator isolator_
Definition:
ZToMuMuIsolationSelector.cc:114
pat
Definition:
HeavyIon.h:7
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition:
svgfig.py:521
OneNonIsolatedSelector::OneNonIsolatedSelector
OneNonIsolatedSelector(double cut)
Definition:
ZToMuMuIsolationSelector.cc:26
SingleObjectSelectorBase
Definition:
SingleObjectSelector.h:26
looper.cfg
cfg
Definition:
looper.py:297
reco::Candidate
Definition:
Candidate.h:27
TwoNonIsolatedSelector::operator()
bool operator()(double i1, double i2) const
Definition:
ZToMuMuIsolationSelector.cc:36
AndSelector.h
NonIsolatedSelector::operator()
bool operator()(double i1, double i2) const
Definition:
ZToMuMuIsolationSelector.cc:18
IsolatedSelector::operator()
bool operator()(double i1, double i2) const
Definition:
ZToMuMuIsolationSelector.cc:9
StringCutObjectSelector< reco::Candidate >
Exception
Definition:
hltDiff.cc:246
OneNonIsolatedSelector::cut_
double cut_
Definition:
ZToMuMuIsoDepositSelector.cc:31
reco::Candidate::masterClone
virtual const CandidateBaseRef & masterClone() const =0
IsolatedSelector
Definition:
ZToMuMuIsoDepositSelector.cc:7
TwoNonIsolatedSelector
Definition:
ZToMuMuIsoDepositSelector.cc:34
ConsumesCollector.h
ZToMuMuIsolationSelector::leptonIsolation_
LeptonIsolationType leptonIsolation_
Definition:
ZToMuMuIsolationSelector.cc:112
ParameterSet.h
dummy
Definition:
DummySelector.h:38
edm::errors::Configuration
Definition:
EDMException.h:36
ZToMuMuIsolationSelector
Definition:
ZToMuMuIsolationSelector.cc:50
edm::ConsumesCollector
Definition:
ConsumesCollector.h:45
IsolatedSelector::IsolatedSelector
IsolatedSelector(double cut)
Definition:
ZToMuMuIsolationSelector.cc:8
Generated for CMSSW Reference Manual by
1.8.16