src
Alignment
CommonAlignmentProducer
src
AlignmentGlobalTrackSelector.cc
Go to the documentation of this file.
1
//Framework
2
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
3
#include "
FWCore/Framework/interface/Event.h
"
4
#include "
FWCore/Utilities/interface/EDMException.h
"
5
#include "
FWCore/Utilities/interface/InputTag.h
"
6
7
//DataFormats
8
#include <
DataFormats/Candidate/interface/Particle.h
>
9
#include <
DataFormats/Candidate/interface/Candidate.h
>
10
#include <
DataFormats/TrackReco/interface/Track.h
>
11
#include <
DataFormats/JetReco/interface/CaloJet.h
>
12
13
#include <
DataFormats/MuonReco/interface/Muon.h
>
14
15
#include <
DataFormats/RecoCandidate/interface/RecoCandidate.h
>
//for the get<TrackRef>() Call
16
17
#include <
DataFormats/Math/interface/deltaR.h
>
18
19
//STL
20
#include <cmath>
21
22
#include "
Alignment/CommonAlignmentProducer/interface/AlignmentGlobalTrackSelector.h
"
23
24
using namespace
std
;
25
using namespace
edm
;
26
27
// constructor ----------------------------------------------------------------
28
AlignmentGlobalTrackSelector::AlignmentGlobalTrackSelector
(
const
edm::ParameterSet
&
cfg
,
edm::ConsumesCollector
& iC)
29
: theGMFilterSwitch(
cfg
.getParameter<
bool
>(
"applyGlobalMuonFilter"
)),
30
theIsoFilterSwitch(
cfg
.getParameter<
bool
>(
"applyIsolationtest"
)),
31
theJetCountFilterSwitch(
cfg
.getParameter<
bool
>(
"applyJetCountFilter"
)) {
32
if
(
theGMFilterSwitch
||
theIsoFilterSwitch
||
theJetCountFilterSwitch
)
33
LogDebug
(
"Alignment"
) <<
"> applying global Trackfilter ..."
;
34
35
if
(
theGMFilterSwitch
) {
36
edm::InputTag
theMuonSource =
cfg
.getParameter<
InputTag
>(
"muonSource"
);
37
theMuonToken
= iC.
consumes
<
reco::MuonCollection
>(theMuonSource);
38
theMaxTrackDeltaR
=
cfg
.getParameter<
double
>(
"maxTrackDeltaR"
);
39
theMinGlobalMuonCount
=
cfg
.getParameter<
int
>(
"minGlobalMuonCount"
);
40
LogDebug
(
"Alignment"
) <<
"> GlobalMuonFilter : source, maxTrackDeltaR, min. Count : "
<< theMuonSource
41
<<
" , "
<<
theMaxTrackDeltaR
<<
" , "
<<
theMinIsolatedCount
;
42
}
43
44
if
(
theIsoFilterSwitch
) {
45
edm::InputTag
theJetIsoSource =
cfg
.getParameter<
InputTag
>(
"jetIsoSource"
);
46
theJetIsoToken
= iC.
consumes
<
reco::CaloJetCollection
>(theJetIsoSource);
47
theMaxJetPt
=
cfg
.getParameter<
double
>(
"maxJetPt"
);
48
theMinJetDeltaR
=
cfg
.getParameter<
double
>(
"minJetDeltaR"
);
49
theMinIsolatedCount
=
cfg
.getParameter<
int
>(
"minIsolatedCount"
);
50
LogDebug
(
"Alignment"
) <<
"> Isolationtest : source, maxJetPt, minJetDeltaR, min. Count: "
<< theJetIsoSource
51
<<
" , "
<<
theMaxJetPt
<<
" ,"
<<
theMinJetDeltaR
<<
" ,"
<<
theMinGlobalMuonCount
;
52
}
53
54
if
(
theJetCountFilterSwitch
) {
55
edm::InputTag
theJetCountSource =
cfg
.getParameter<
InputTag
>(
"jetCountSource"
);
56
theJetCountToken
= iC.
consumes
<
reco::CaloJetCollection
>(theJetCountSource);
57
theMinJetPt
=
cfg
.getParameter<
double
>(
"minJetPt"
);
58
theMaxJetCount
=
cfg
.getParameter<
int
>(
"maxJetCount"
);
59
LogDebug
(
"Alignment"
) <<
"> JetCountFilter : source, minJetPt, maxJetCount : "
<< theJetCountSource
60
<<
" , "
<<
theMinJetPt
<<
" ,"
<<
theMaxJetCount
;
61
}
62
}
63
64
// destructor -----------------------------------------------------------------
65
AlignmentGlobalTrackSelector::~AlignmentGlobalTrackSelector
() {}
66
68
bool
AlignmentGlobalTrackSelector::useThisFilter
() {
69
return
theGMFilterSwitch
||
theIsoFilterSwitch
||
theJetCountFilterSwitch
;
70
}
71
72
// do selection ---------------------------------------------------------------
73
AlignmentGlobalTrackSelector::Tracks
AlignmentGlobalTrackSelector::select
(
const
Tracks
&
tracks
,
74
const
edm::Event
&
iEvent
,
75
const
edm::EventSetup
& iSetup) {
76
Tracks
result
=
tracks
;
77
78
if
(
theGMFilterSwitch
)
79
result
=
findMuons
(
result
,
iEvent
);
80
if
(
theIsoFilterSwitch
)
81
result
=
checkIsolation
(
result
,
iEvent
);
82
if
(
theJetCountFilterSwitch
)
83
result
=
checkJetCount
(
result
,
iEvent
);
84
LogDebug
(
"Alignment"
) <<
"> Global: tracks all, kept: "
<<
tracks
.size() <<
", "
<<
result
.size();
85
// LogDebug("Alignment")<<"> o kept:";
86
// printTracks(result);
87
88
return
result
;
89
}
90
92
AlignmentGlobalTrackSelector::Tracks
AlignmentGlobalTrackSelector::findMuons
(
const
Tracks
&
tracks
,
93
const
edm::Event
&
iEvent
)
const
{
94
Tracks
result
;
95
Tracks
globalMuons
;
96
97
//fill globalMuons with muons
98
Handle<reco::MuonCollection>
muons
;
99
iEvent
.getByToken(
theMuonToken
,
muons
);
100
101
if
(
muons
.isValid()) {
102
for
(reco::MuonCollection::const_iterator itMuon =
muons
->begin(); itMuon !=
muons
->end(); ++itMuon) {
103
const
reco::Track
* muonTrack = (*itMuon).get<
reco::TrackRef
>().
get
();
104
if
(!muonTrack) {
105
LogDebug
(
"Alignment"
) <<
"@SUB=AlignmentGlobalTrackSelector::findMuons"
106
<<
"Found muon without track: Standalone Muon!"
;
107
}
else
{
108
globalMuons
.push_back(muonTrack);
109
}
110
}
111
}
else
{
112
LogError
(
"Alignment"
) <<
"@SUB=AlignmentGlobalTrackSelector::findMuons"
113
<<
"> could not optain mounCollection!"
;
114
}
115
116
result
= this->
matchTracks
(tracks,
globalMuons
);
117
118
if
(static_cast<int>(
result
.size()) <
theMinGlobalMuonCount
)
119
result
.clear();
120
121
return
result
;
122
}
123
125
AlignmentGlobalTrackSelector::Tracks
AlignmentGlobalTrackSelector::checkIsolation
(
const
Tracks
&
cands
,
126
const
edm::Event
&
iEvent
)
const
{
127
Tracks
result
;
128
result
.clear();
129
130
Handle<reco::CaloJetCollection>
jets
;
131
iEvent
.getByToken(
theJetIsoToken
,
jets
);
132
133
if
(
jets
.isValid()) {
134
for
(Tracks::const_iterator
it
=
cands
.begin();
it
!=
cands
.end(); ++
it
) {
135
bool
isolated =
true
;
136
for
(reco::CaloJetCollection::const_iterator itJet =
jets
->begin(); itJet !=
jets
->end(); ++itJet)
137
isolated &= !((*itJet).pt() >
theMaxJetPt
&&
deltaR
(*(*
it
), (*itJet)) <
theMinJetDeltaR
);
138
139
if
(isolated)
140
result
.push_back(*
it
);
141
}
142
// LogDebug("Alignment") << "D Found "<<result.size()<<" isolated of "<< cands.size()<<" Tracks!";
143
144
}
else
145
LogError
(
"Alignment"
) <<
"@SUB=AlignmentGlobalTrackSelector::checkIsolation"
146
<<
"> could not optain jetCollection!"
;
147
148
if
(static_cast<int>(
result
.size()) <
theMinIsolatedCount
)
149
result
.clear();
150
151
return
result
;
152
}
153
155
AlignmentGlobalTrackSelector::Tracks
AlignmentGlobalTrackSelector::checkJetCount
(
const
Tracks
&
tracks
,
156
const
edm::Event
&
iEvent
)
const
{
157
Tracks
result
;
158
result
.clear();
159
160
Handle<reco::CaloJetCollection>
jets
;
161
iEvent
.getByToken(
theJetCountToken
,
jets
);
162
163
if
(
jets
.isValid()) {
164
int
jetCount = 0;
165
for
(reco::CaloJetCollection::const_iterator itJet =
jets
->begin(); itJet !=
jets
->end(); ++itJet) {
166
if
((*itJet).pt() >
theMinJetPt
)
167
jetCount++;
168
}
169
170
if
(jetCount <=
theMaxJetCount
)
171
result
=
tracks
;
172
173
LogDebug
(
"Alignment"
) <<
"> found "
<< jetCount <<
" Jets"
;
174
}
else
175
LogError
(
"Alignment"
) <<
"@SUB=AlignmentGlobalTrackSelector::checkJetCount"
176
<<
"> could not optain jetCollection!"
;
177
178
return
result
;
179
}
180
181
//===================HELPERS===================
182
184
AlignmentGlobalTrackSelector::Tracks
AlignmentGlobalTrackSelector::matchTracks
(
const
Tracks
&
src
,
185
const
Tracks
&
comp
)
const
{
186
Tracks
result
;
187
for
(Tracks::const_iterator itComp =
comp
.begin(); itComp !=
comp
.end(); ++itComp) {
188
int
match
= -1;
189
double
min
=
theMaxTrackDeltaR
;
190
for
(
unsigned
int
i
= 0;
i
<
src
.size();
i
++) {
191
// LogDebug("Alignment") << "> Trackmatch dist: "<<deltaR(src.at(i),*itComp);
192
if
(
min
>
deltaR
(*(
src
.at(
i
)), *(*itComp))) {
193
min
=
deltaR
(*(
src
.at(
i
)), *(*itComp));
194
match
=
static_cast<
int
>
(
i
);
195
}
196
}
197
if
(
match
> -1)
198
result
.push_back(
src
.at(
match
));
199
}
200
return
result
;
201
}
202
204
void
AlignmentGlobalTrackSelector::printTracks
(
const
Tracks
&
col
)
const
{
205
int
count
= 0;
206
LogDebug
(
"Alignment"
) <<
">......................................"
;
207
for
(Tracks::const_iterator
it
=
col
.begin();
it
<
col
.end(); ++
it
, ++
count
) {
208
LogDebug
(
"Alignment"
) <<
"> Track No. "
<<
count
<<
": p = ("
<< (*it)->px() <<
","
<< (*it)->py() <<
","
209
<< (*it)->pz() <<
")\n"
210
<<
"> pT = "
<< (*it)->pt() <<
" eta = "
<< (*it)->eta()
211
<<
" charge = "
<< (*it)->charge();
212
}
213
LogDebug
(
"Alignment"
) <<
">......................................"
;
214
}
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition:
ConsumesCollector.h:55
AlignmentGlobalTrackSelector::theGMFilterSwitch
bool theGMFilterSwitch
Definition:
AlignmentGlobalTrackSelector.h:49
deltaR.h
AlignmentGlobalTrackSelector::theMaxTrackDeltaR
double theMaxTrackDeltaR
Definition:
AlignmentGlobalTrackSelector.h:55
globalMuons_cfi.globalMuons
globalMuons
Definition:
globalMuons_cfi.py:6
AlignmentGlobalTrackSelector::AlignmentGlobalTrackSelector
AlignmentGlobalTrackSelector(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC)
constructor
Definition:
AlignmentGlobalTrackSelector.cc:28
mps_fire.i
i
Definition:
mps_fire.py:429
AlignmentGlobalTrackSelector::theMinJetDeltaR
double theMinJetDeltaR
Definition:
AlignmentGlobalTrackSelector.h:61
AlignmentGlobalTrackSelector::theMaxJetPt
double theMaxJetPt
Definition:
AlignmentGlobalTrackSelector.h:60
AlignmentGlobalTrackSelector::theMaxJetCount
int theMaxJetCount
Definition:
AlignmentGlobalTrackSelector.h:67
MessageLogger.h
mps_fire.result
result
Definition:
mps_fire.py:311
edm::Ref< TrackCollection >
AlignmentGlobalTrackSelector::theMinJetPt
double theMinJetPt
Definition:
AlignmentGlobalTrackSelector.h:66
Event.h
edm::Handle< reco::MuonCollection >
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition:
PbPb_ZMuSkimMuonDPG_cff.py:63
AlignmentGlobalTrackSelector.h
PDWG_EXODelayedJetMET_cff.jets
jets
Definition:
PDWG_EXODelayedJetMET_cff.py:14
std
Definition:
JetResolutionObject.h:76
AlignmentGlobalTrackSelector::Tracks
std::vector< const reco::Track * > Tracks
Definition:
AlignmentGlobalTrackSelector.h:24
edm::LogError
Log< level::Error, false > LogError
Definition:
MessageLogger.h:129
AlCaHLTBitMon_QueryRunRegistry.comp
string comp
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:249
AlignmentGlobalTrackSelector::findMuons
Tracks findMuons(const Tracks &tracks, const edm::Event &iEvent) const
filter for Tracks that match the Track of a global Muon
Definition:
AlignmentGlobalTrackSelector.cc:92
AlignmentGlobalTrackSelector::theJetCountToken
edm::EDGetTokenT< reco::CaloJetCollection > theJetCountToken
Definition:
AlignmentGlobalTrackSelector.h:65
DiMuonV_cfg.muons
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition:
DiMuonV_cfg.py:214
HLT_2024v14_cff.cands
cands
Definition:
HLT_2024v14_cff.py:16585
reco::MuonCollection
std::vector< Muon > MuonCollection
collection of Muon objects
Definition:
MuonFwd.h:9
DiMuonV_cfg.tracks
tracks
Definition:
DiMuonV_cfg.py:215
Candidate.h
iEvent
int iEvent
Definition:
GenABIO.cc:224
EDMException.h
AlignmentGlobalTrackSelector::select
Tracks select(const Tracks &tracks, const edm::Event &iEvent, const edm::EventSetup &eSetup)
select tracks
Definition:
AlignmentGlobalTrackSelector.cc:73
AlignmentGlobalTrackSelector::theMinIsolatedCount
int theMinIsolatedCount
Definition:
AlignmentGlobalTrackSelector.h:62
AlignmentGlobalTrackSelector::theJetCountFilterSwitch
bool theJetCountFilterSwitch
Definition:
AlignmentGlobalTrackSelector.h:51
AlignmentGlobalTrackSelector::~AlignmentGlobalTrackSelector
~AlignmentGlobalTrackSelector()
destructor
Definition:
AlignmentGlobalTrackSelector.cc:65
SiStripPI::min
Definition:
SiStripPayloadInspectorHelper.h:178
edm::EventSetup
Definition:
EventSetup.h:56
AlignmentGlobalTrackSelector::theIsoFilterSwitch
bool theIsoFilterSwitch
Definition:
AlignmentGlobalTrackSelector.h:50
Muon.h
CaloJet.h
looper.cfg
cfg
Definition:
looper.py:296
submitPVResolutionJobs.count
count
Definition:
submitPVResolutionJobs.py:359
AlignmentGlobalTrackSelector::theMuonToken
edm::EDGetTokenT< reco::MuonCollection > theMuonToken
Definition:
AlignmentGlobalTrackSelector.h:54
TrackRefitter_38T_cff.src
src
Definition:
TrackRefitter_38T_cff.py:24
AlignmentGlobalTrackSelector::matchTracks
Tracks matchTracks(const Tracks &src, const Tracks &comp) const
matches [src] with [comp] returns collection with matching Tracks coming from [src] ...
Definition:
AlignmentGlobalTrackSelector.cc:184
AlignmentGlobalTrackSelector::theMinGlobalMuonCount
int theMinGlobalMuonCount
Definition:
AlignmentGlobalTrackSelector.h:56
nano_mu_local_reco_cff.bool
bool
Definition:
nano_mu_local_reco_cff.py:14
AlignmentGlobalTrackSelector::checkIsolation
Tracks checkIsolation(const Tracks &cands, const edm::Event &iEvent) const
returns only isolated tracks in [cands]
Definition:
AlignmentGlobalTrackSelector.cc:125
reco::Track
Definition:
Track.h:27
ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it
auto & it
Definition:
splitVertices.h:28
edm
HLT enums.
Definition:
AlignableModifier.h:19
edm::InputTag
Definition:
InputTag.h:15
InputTag.h
cuy.col
col
Definition:
cuy.py:1009
AlignmentGlobalTrackSelector::printTracks
void printTracks(const Tracks &col) const
print Information on Track-Collection
Definition:
AlignmentGlobalTrackSelector.cc:204
Track.h
edm::ParameterSet
Definition:
ParameterSet.h:48
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
AlignmentGlobalTrackSelector::checkJetCount
Tracks checkJetCount(const Tracks &cands, const edm::Event &iEvent) const
returns [tracks] if there are less than theMaxCount Jets with theMinJetPt and an empty set if not ...
Definition:
AlignmentGlobalTrackSelector.cc:155
edm::Event
Definition:
Event.h:73
Particle.h
RecoCandidate.h
AlignmentGlobalTrackSelector::useThisFilter
bool useThisFilter()
returns if any of the Filters is used.
Definition:
AlignmentGlobalTrackSelector.cc:68
AlignmentGlobalTrackSelector::theJetIsoToken
edm::EDGetTokenT< reco::CaloJetCollection > theJetIsoToken
Definition:
AlignmentGlobalTrackSelector.h:59
edm::ConsumesCollector
Definition:
ConsumesCollector.h:45
reco::CaloJetCollection
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
Definition:
CaloJetCollection.h:15
LogDebug
#define LogDebug(id)
Definition:
MessageLogger.h:241
Generated for CMSSW Reference Manual by
1.8.14