Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
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
6
//DataFormats
7
#include <
DataFormats/Candidate/interface/Particle.h
>
8
#include <
DataFormats/Candidate/interface/Candidate.h
>
9
#include <
DataFormats/TrackReco/interface/Track.h
>
10
#include <
DataFormats/JetReco/interface/CaloJet.h
>
11
#include <
DataFormats/MuonReco/interface/MuonFwd.h
>
12
#include <
DataFormats/MuonReco/interface/Muon.h
>
13
14
#include <
DataFormats/RecoCandidate/interface/RecoCandidate.h
>
//for the get<TrackRef>() Call
15
16
#include <
DataFormats/Math/interface/deltaR.h
>
17
18
//STL
19
#include <
math.h
>
20
21
#include "
Alignment/CommonAlignmentProducer/interface/AlignmentGlobalTrackSelector.h
"
22
23
24
using namespace
std;
25
using namespace
edm;
26
27
// constructor ----------------------------------------------------------------
28
29
AlignmentGlobalTrackSelector::AlignmentGlobalTrackSelector
(
const
edm::ParameterSet
& cfg) :
30
theMuonSource(
"muons"
),
31
theJetIsoSource(
"fastjet6CaloJets"
),
32
theJetCountSource(
"fastjet6CaloJets"
)
33
{
34
theIsoFilterSwitch
= cfg.
getParameter
<
bool
>(
"applyIsolationtest"
);
35
theGMFilterSwitch
= cfg.
getParameter
<
bool
>(
"applyGlobalMuonFilter"
);
36
theJetCountFilterSwitch
= cfg.
getParameter
<
bool
>(
"applyJetCountFilter"
);
37
if
(
theIsoFilterSwitch
|| theGMFilterSwitch || theJetCountFilterSwitch)
38
LogDebug
(
"Alignment"
) <<
"> applying global Trackfilter ..."
;
39
40
if
(theGMFilterSwitch){
41
theMuonSource
= cfg.
getParameter
<
InputTag
>(
"muonSource"
);
42
theMaxTrackDeltaR
=cfg.
getParameter
<
double
>(
"maxTrackDeltaR"
);
43
theMinIsolatedCount
= cfg.
getParameter
<
int
>(
"minIsolatedCount"
);
44
LogDebug
(
"Alignment"
) <<
"> GlobalMuonFilter : source, maxTrackDeltaR, min. Count : "
<<
theMuonSource
<<
" , "
<<theMaxTrackDeltaR<<
" , "
<<
theMinIsolatedCount
;
45
}
else
{
46
theMaxTrackDeltaR
= 0;
47
theMinIsolatedCount
= 0;
48
}
49
50
if
(
theIsoFilterSwitch
){
51
theJetIsoSource
= cfg.
getParameter
<
InputTag
>(
"jetIsoSource"
);
52
theMaxJetPt
= cfg.
getParameter
<
double
>(
"maxJetPt"
);
53
theMinJetDeltaR
= cfg.
getParameter
<
double
>(
"minJetDeltaR"
);
54
theMinGlobalMuonCount
= cfg.
getParameter
<
int
>(
"minGlobalMuonCount"
);
55
LogDebug
(
"Alignment"
) <<
"> Isolationtest : source, maxJetPt, minJetDeltaR, min. Count: "
<<
theJetIsoSource
<<
" , "
<< theMaxJetPt<<
" ,"
<<theMinJetDeltaR<<
" ,"
<<
theMinGlobalMuonCount
;
56
}
else
{
57
theMaxJetPt
= 0;
58
theMinJetDeltaR
= 0;
59
theMinGlobalMuonCount
= 0;
60
}
61
62
if
(theJetCountFilterSwitch){
63
theJetCountSource
= cfg.
getParameter
<
InputTag
>(
"jetCountSource"
);
64
theMinJetPt
= cfg.
getParameter
<
double
>(
"minJetPt"
);
65
theMaxJetCount
= cfg.
getParameter
<
int
>(
"maxJetCount"
);
66
LogDebug
(
"Alignment"
) <<
"> JetCountFilter : source, minJetPt, maxJetCount : "
<<
theJetCountSource
<<
" , "
<< theMinJetPt<<
" ,"
<<
theMaxJetCount
;
67
}
68
69
70
}
71
72
73
// destructor -----------------------------------------------------------------
74
75
AlignmentGlobalTrackSelector::~AlignmentGlobalTrackSelector
()
76
{}
77
78
80
bool
AlignmentGlobalTrackSelector::useThisFilter
()
81
{
82
return
theGMFilterSwitch
||
theIsoFilterSwitch
||
theJetCountFilterSwitch
;
83
}
84
85
// do selection ---------------------------------------------------------------
86
AlignmentGlobalTrackSelector::Tracks
87
AlignmentGlobalTrackSelector::select
(
const
Tracks
&
tracks
,
const
edm::Event
&
iEvent
)
88
{
89
Tracks
result
=
tracks
;
90
91
if
(
theGMFilterSwitch
) result =
findMuons
(result,iEvent);
92
if
(
theIsoFilterSwitch
) result =
checkIsolation
(result,iEvent);
93
if
(
theJetCountFilterSwitch
) result =
checkJetCount
(result,iEvent);
94
LogDebug
(
"Alignment"
) <<
"> Global: tracks all,kept: "
<< tracks.size() <<
","
<< result.size();
95
// LogDebug("Alignment")<<"> o kept:";
96
// printTracks(result);
97
98
return
result
;
99
}
100
102
AlignmentGlobalTrackSelector::Tracks
103
AlignmentGlobalTrackSelector::checkIsolation
(
const
Tracks
& cands,
const
edm::Event
&
iEvent
)
const
104
{
105
Tracks
result
; result.clear();
106
107
Handle<reco::CaloJetCollection>
jets
;
108
iEvent.
getByLabel
(
theJetIsoSource
,jets);
109
if
(jets.
isValid
()){
110
for
(Tracks::const_iterator it = cands.begin();it < cands.end();++it){
111
bool
isolated =
true
;
112
for
(reco::CaloJetCollection::const_iterator itJet = jets->begin(); itJet != jets->end() ; ++itJet)
113
isolated &= !((*itJet).pt() >
theMaxJetPt
&&
deltaR
(*(*it),(*itJet)) <
theMinJetDeltaR
);
114
115
if
(isolated)
116
result.push_back(*it);
117
}
118
// LogDebug("Alignment") << "D Found "<<result.size()<<" isolated of "<< cands.size()<<" Tracks!";
119
120
}
else
LogError
(
"Alignment"
)<<
"@SUB=AlignmentGlobalTrackSelector::checkIsolation"
121
<<
"> could not optain jetCollection!"
;
122
123
if
(static_cast<int>(result.size()) <
theMinIsolatedCount
) result.clear();
124
return
result
;
125
}
126
128
AlignmentGlobalTrackSelector::Tracks
129
AlignmentGlobalTrackSelector::checkJetCount
(
const
Tracks
&
tracks
,
const
edm::Event
&
iEvent
)
const
130
{
131
Tracks
result
; result.clear();
132
Handle<reco::CaloJetCollection>
jets
;
133
iEvent.
getByLabel
(
theJetCountSource
,jets);
134
if
(jets.
isValid
()){
135
int
jetCount = 0;
136
for
(reco::CaloJetCollection::const_iterator itJet = jets->begin(); itJet != jets->end() ; ++itJet){
137
if
((*itJet).pt() >
theMinJetPt
)
138
jetCount++;
139
}
140
if
(jetCount <=
theMaxJetCount
)
141
result =
tracks
;
142
LogDebug
(
"Alignment"
)<<
"> found "
<<jetCount<<
" Jets"
;
143
}
else
LogError
(
"Alignment"
)<<
"@SUB=AlignmentGlobalTrackSelector::checkJetCount"
144
<<
"> could not optain jetCollection!"
;
145
return
result
;
146
}
147
149
AlignmentGlobalTrackSelector::Tracks
150
AlignmentGlobalTrackSelector::findMuons
(
const
Tracks
&
tracks
,
const
edm::Event
&
iEvent
)
const
151
{
152
Tracks
result
;
153
Tracks
globalMuons
;
154
155
//fill globalMuons with muons
156
Handle<reco::MuonCollection>
muons
;
157
iEvent.
getByLabel
(
theMuonSource
, muons);
158
if
(muons.
isValid
()) {
159
for
(reco::MuonCollection::const_iterator itMuon = muons->begin(); itMuon != muons->end();
160
++itMuon) {
161
const
reco::Track
* muonTrack = (*itMuon).get<
reco::TrackRef
>().
get
();
162
if
(!muonTrack) {
163
LogDebug
(
"Alignment"
) <<
"@SUB=AlignmentGlobalTrackSelector::findMuons"
164
<<
"Found muon without track: Standalone Muon!"
;
165
}
else
{
166
globalMuons.push_back(muonTrack);
167
}
168
}
169
}
else
{
170
LogError
(
"Alignment"
) <<
"@SUB=AlignmentGlobalTrackSelector::findMuons"
171
<<
"> could not optain mounCollection!"
;
172
}
173
174
result = this->
matchTracks
(tracks, globalMuons);
175
176
if
(static_cast<int>(result.size()) <
theMinGlobalMuonCount
) result.clear();
177
178
return
result
;
179
}
180
181
//===================HELPERS===================
182
184
AlignmentGlobalTrackSelector::Tracks
185
AlignmentGlobalTrackSelector::matchTracks
(
const
Tracks
&
src
,
const
Tracks
& comp)
const
186
{
187
Tracks
result
;
188
for
(Tracks::const_iterator itComp = comp.begin(); itComp < comp.end();++itComp){
189
int
match
= -1;
190
double
min
=
theMaxTrackDeltaR
;
191
for
(
unsigned
int
i
=0;
i
< src.size();
i
++){
192
// LogDebug("Alignment") << "> Trackmatch dist: "<<deltaR(src.at(i),*itComp);
193
if
(min >
deltaR
(*(src.at(
i
)),*(*itComp))){
194
min =
deltaR
(*(src.at(
i
)),*(*itComp));
195
match =
static_cast<
int
>
(
i
);
196
}
197
}
198
if
(match > -1)
199
result.push_back(src.at(match));
200
}
201
return
result
;
202
}
203
205
void
AlignmentGlobalTrackSelector::printTracks
(
const
Tracks
& col)
const
206
{
207
int
count
= 0;
208
LogDebug
(
"Alignment"
) <<
">......................................"
;
209
for
(Tracks::const_iterator it = col.begin();it < col.end();++it,++
count
){
210
LogDebug
(
"Alignment"
)
211
<<
"> Track No. "
<< count <<
": p = ("
<<(*it)->px()<<
","
<<(*it)->py()<<
","
<<(*it)->pz()<<
")\n"
212
<<
"> pT = "
<<(*it)->pt()<<
" eta = "
<<(*it)->eta()<<
" charge = "
<<(*it)->charge();
213
}
214
LogDebug
(
"Alignment"
) <<
">......................................"
;
215
}
LogDebug
#define LogDebug(id)
Definition:
MessageLogger.h:510
math.h
AlignmentGlobalTrackSelector::theGMFilterSwitch
bool theGMFilterSwitch
Definition:
AlignmentGlobalTrackSelector.h:45
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
i
int i
Definition:
DBlmapReader.cc:9
prof2calltree.count
list count
Definition:
prof2calltree.py:146
AlignmentGlobalTrackSelector::theMaxTrackDeltaR
double theMaxTrackDeltaR
Definition:
AlignmentGlobalTrackSelector.h:53
MessageLogger.h
AlignmentGlobalTrackSelector::theMinJetDeltaR
double theMinJetDeltaR
Definition:
AlignmentGlobalTrackSelector.h:52
AlignmentGlobalTrackSelector::theMaxJetPt
double theMaxJetPt
Definition:
AlignmentGlobalTrackSelector.h:51
AlignmentGlobalTrackSelector::theMaxJetCount
int theMaxJetCount
Definition:
AlignmentGlobalTrackSelector.h:58
AlignmentGlobalTrackSelector::theMinJetPt
double theMinJetPt
Definition:
AlignmentGlobalTrackSelector.h:57
AlignmentGlobalTrackSelector::theJetIsoSource
edm::InputTag theJetIsoSource
Definition:
AlignmentGlobalTrackSelector.h:50
Event.h
AlignmentGlobalTrackSelector.h
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:150
min
#define min(a, b)
Definition:
mlp_lapack.h:161
AlignmentGlobalTrackSelector::Tracks
std::vector< const reco::Track * > Tracks
Definition:
AlignmentGlobalTrackSelector.h:19
edm::Handle< reco::CaloJetCollection >
MuonFwd.h
AlignmentGlobalTrackSelector::theMuonSource
edm::InputTag theMuonSource
Definition:
AlignmentGlobalTrackSelector.h:47
analyzePatCleaning_cfg.jets
tuple jets
Definition:
analyzePatCleaning_cfg.py:8
Candidate.h
edm::LogError
Definition:
MessageLogger.h:157
iEvent
int iEvent
Definition:
GenABIO.cc:243
deltaR.h
EDMException.h
AlignmentGlobalTrackSelector::theMinIsolatedCount
int theMinIsolatedCount
Definition:
AlignmentGlobalTrackSelector.h:54
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:129
query.result
tuple result
Definition:
query.py:137
AlignmentGlobalTrackSelector::theJetCountFilterSwitch
bool theJetCountFilterSwitch
Definition:
AlignmentGlobalTrackSelector.h:44
AlignmentGlobalTrackSelector::~AlignmentGlobalTrackSelector
~AlignmentGlobalTrackSelector()
destructor
Definition:
AlignmentGlobalTrackSelector.cc:75
AlignmentGlobalTrackSelector::printTracks
void printTracks(const Tracks &col) const
print Information on Track-Collection
Definition:
AlignmentGlobalTrackSelector.cc:205
AlignmentGlobalTrackSelector::theIsoFilterSwitch
bool theIsoFilterSwitch
Definition:
AlignmentGlobalTrackSelector.h:43
Muon.h
edm::HandleBase::isValid
bool isValid() const
Definition:
HandleBase.h:76
edm::Event::getByLabel
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition:
Event.h:359
deltaR
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition:
TreeUtility.cc:17
AlignmentGlobalTrackSelector::checkIsolation
Tracks checkIsolation(const Tracks &cands, const edm::Event &iEvent) const
returns only isolated tracks in [cands]
Definition:
AlignmentGlobalTrackSelector.cc:103
testEve_cfg.tracks
tuple tracks
Definition:
testEve_cfg.py:39
AlignmentGlobalTrackSelector::AlignmentGlobalTrackSelector
AlignmentGlobalTrackSelector(const edm::ParameterSet &cfg)
constructor
Definition:
AlignmentGlobalTrackSelector.cc:29
AlignmentGlobalTrackSelector::theMinGlobalMuonCount
int theMinGlobalMuonCount
Definition:
AlignmentGlobalTrackSelector.h:48
globalMuons_cfi.globalMuons
tuple globalMuons
Definition:
globalMuons_cfi.py:6
AlignmentGlobalTrackSelector::theJetCountSource
edm::InputTag theJetCountSource
Definition:
AlignmentGlobalTrackSelector.h:56
reco::Track
Definition:
Track.h:27
edm::InputTag
Definition:
InputTag.h:12
edm::ParameterSet
Definition:
ParameterSet.h:31
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:6
AlignmentGlobalTrackSelector::select
Tracks select(const Tracks &tracks, const edm::Event &iEvent)
select tracks
Definition:
AlignmentGlobalTrackSelector.cc:87
CaloJet.h
edm::Event
Definition:
Event.h:49
Track.h
ExpressReco_HICollisions_FallBack.muons
tuple muons
Definition:
ExpressReco_HICollisions_FallBack.py:4424
Particle.h
edm::Ref< TrackCollection >
RecoCandidate.h
AlignmentGlobalTrackSelector::useThisFilter
bool useThisFilter()
returns if any of the Filters is used.
Definition:
AlignmentGlobalTrackSelector.cc:80
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:185
align_tpl.src
tuple src
Definition:
align_tpl.py:87
Generated for CMSSW Reference Manual by
1.8.5