16 srcSelectedMuons_(cfg.getParameter<edm::InputTag>(
"selectedMuons")),
17 dRmatch_(cfg.getParameter<double>(
"dRmatch")),
18 removeDuplicates_(cfg.getParameter<bool>(
"removeDuplicates")),
19 maxWarnings_tooMany_(100),
20 numWarnings_tooMany_(0),
21 maxWarnings_tooFew_(3),
22 numWarnings_tooFew_(0)
28 else if ( type_string ==
"links" )
type_ =
kLink;
29 else if ( type_string.find(
"tev") == 0 )
type_ =
kTeV;
31 <<
"Invalid Configuration Parameter 'type' = " << type_string <<
" !!\n";
33 typedef std::vector<edm::InputTag> VInputTag;
34 VInputTag srcTracks = cfg.
getParameter<VInputTag>(
"tracks");
35 for ( VInputTag::const_iterator srcTracks_i = srcTracks.begin();
36 srcTracks_i != srcTracks.end(); ++srcTracks_i ) {
51 struct muonToTrackMatchInfoType
55 trackPt_(track->
pt()),
56 trackCharge_(track->charge()),
60 ~muonToTrackMatchInfoType() {}
68 struct SortMuonToTrackMatchInfosDescendingMatchQuality
70 bool operator() (
const muonToTrackMatchInfoType& m1,
const muonToTrackMatchInfoType& m2)
73 if ( m1.trackPt_ > (0.5*m1.muonPt_) && m2.trackPt_ < (0.5*m2.muonPt_) )
return true;
74 if ( m1.trackPt_ < (0.5*m1.muonPt_) && m2.trackPt_ > (0.5*m2.muonPt_) )
return false;
77 return (m1.dR_ < m2.dR_);
86 std::ostringstream retVal;
87 retVal <<
"Run = " << run_number <<
", LS = " << ls_number <<
", Event = " << event_number;
101 muonMomentum.
pt_ = muon_candidate.
pt();
102 muonMomentum.
eta_ = muon_candidate.
eta();
103 muonMomentum.
phi_ = muon_candidate.
phi();
130 std::vector<muonMomentumType> selMuonMomenta;
132 if (
verbosity_ )
std::cout <<
" muPlus: Pt = " << muPlus->
pt() <<
", eta = " << muPlus->
eta() <<
", phi = " << muPlus->
phi() << std::endl;
136 if (
verbosity_ )
std::cout <<
" muMinus: Pt = " << muMinus->
pt() <<
", eta = " << muMinus->
eta() <<
", phi = " << muMinus->
phi() << std::endl;
141 for (
typename std::vector<todoListEntryType>::const_iterator todoItem =
todoList_.begin();
142 todoItem !=
todoList_.end(); ++todoItem ) {
143 if (
verbosity_ )
std::cout <<
"processing trackCollection = " << todoItem->srcTracks_ << std::endl;
145 todoItem->trackRefMap_.clear();
153 size_t idxTrack_cleaned = 0;
155 std::vector<muonToTrackMatchInfoType> selMuonToTrackMatches;
156 for ( std::vector<muonMomentumType>::const_iterator selMuonMomentum = selMuonMomenta.begin();
157 selMuonMomentum != selMuonMomenta.end(); ++selMuonMomentum ) {
158 std::vector<muonToTrackMatchInfoType> tmpMatches;
159 for ( reco::TrackCollection::const_iterator track = tracks->begin();
160 track != tracks->end(); ++track ) {
161 double dR =
reco::deltaR(track->eta(), track->phi(), selMuonMomentum->eta_, selMuonMomentum->phi_);
162 if ( dR <
dRmatch_ ) tmpMatches.push_back(muonToTrackMatchInfoType(selMuonMomentum->pt_, &(*track), dR));
165 std::sort(tmpMatches.begin(), tmpMatches.end(), SortMuonToTrackMatchInfosDescendingMatchQuality());
166 if ( tmpMatches.size() > 0 ) selMuonToTrackMatches.push_back(tmpMatches.front());
170 for ( std::vector<muonToTrackMatchInfoType>::const_iterator tmpMatch = tmpMatches.begin();
171 tmpMatch != tmpMatches.end(); ++tmpMatch ) {
172 if ( (tmpMatch->dR_ < 1.e-3 && tmpMatch->trackPt_ > (0.33*tmpMatch->muonPt_)) ||
173 (tmpMatch->dR_ < 1.e-1 && tmpMatch->trackPt_ >
TMath::Max(0.66*tmpMatch->muonPt_, 10.)) ) selMuonToTrackMatches.push_back(*tmpMatch);
178 std::vector<reco::TrackRef> removedTracks;
179 size_t numTracks = tracks->size();
180 for (
size_t trackIdx = 0; trackIdx < numTracks; ++trackIdx ) {
183 for ( std::vector<muonToTrackMatchInfoType>::const_iterator muonMatchInfo = selMuonToTrackMatches.begin();
184 muonMatchInfo != selMuonToTrackMatches.end(); ++muonMatchInfo ) {
185 if ( muonMatchInfo->track_ == &(*track) ) isMuon =
true;
188 std::cout <<
"track: Pt = " << track->pt() <<
", eta = " << track->eta() <<
", phi = " << track->phi() <<
", isMuon = " << isMuon << std::endl;
191 removedTracks.push_back(track);
193 tracks_cleaned->push_back(*track);
194 todoItem->trackRefMap_[
reco::TrackRef(trackCollectionRefProd_cleaned, idxTrack_cleaned)] = track;
201 <<
" (" << runLumiEventNumbers_to_string(evt) <<
")" << std::endl
202 <<
" Removed " << removedTracks.size() <<
" tracks from event containing " << selMuons.size() <<
" muons !!" << std::endl;
203 if ( muPlus.
isNonnull() )
std::cout <<
" muPlus: Pt = " << muPlus->
pt() <<
", eta = " << muPlus->
eta() <<
", phi = " << muPlus->
phi() << std::endl;
204 if ( muMinus.
isNonnull() )
std::cout <<
" muMinus: Pt = " << muMinus->
pt() <<
", eta = " << muMinus->
eta() <<
", phi = " << muMinus->
phi() << std::endl;
205 std::cout <<
"Removed tracks:" << std::endl;
207 for ( std::vector<reco::TrackRef>::const_iterator removedTrack = removedTracks.begin();
208 removedTrack != removedTracks.end(); ++removedTrack ) {
210 <<
" Pt = " << (*removedTrack)->pt() <<
", eta = " << (*removedTrack)->eta() <<
", phi = " << (*removedTrack)->phi() << std::endl;
217 evt.
put(tracks_cleaned, todoItem->srcTracks_.instance());
T getParameter(std::string const &) const
EventNumber_t event() const
reco::CandidateBaseRef getTheMuMinus(const std::vector< reco::CandidateBaseRef > &)
bool isNonnull() const
Checks for non-null.
bool isMuon(const Candidate &part)
virtual TrackRef innerTrack() const
virtual float eta() const =0
momentum pseudorapidity
std::vector< Track > TrackCollection
collection of Tracks
bool exists(std::string const ¶meterName) const
checks if a parameter exists
unsigned long long EventNumber_t
edm::LuminosityBlockNumber_t luminosityBlock() const
virtual float phi() const =0
momentum azimuthal angle
bool isNonnull() const
Checks for non-null.
double deltaR(const T1 &t1, const T2 &t2)
unsigned int LuminosityBlockNumber_t
virtual float pt() const =0
transverse momentum
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual void produce(edm::Event &, const edm::EventSetup &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
edm::InputTag srcSelectedMuons_
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
RefProd< PROD > getRefBeforePut()
muonMomentumType getMuonMomentum(const reco::Candidate &)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
virtual void produceTrackExtras(edm::Event &, const edm::EventSetup &)=0
MuonTrackCleanerBase(const edm::ParameterSet &)
std::vector< reco::CandidateBaseRef > getSelMuons(const edm::Event &, const edm::InputTag &)
reco::CandidateBaseRef getTheMuPlus(const std::vector< reco::CandidateBaseRef > &)
std::vector< todoListEntryType > todoList_
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
virtual void produceTracks(edm::Event &, const edm::EventSetup &)