22 |
|
//TH2D* hMuHitsCSCvsEta; |
23 |
|
|
24 |
|
BestMuonFinder::BestMuonFinder(const edm::ParameterSet& cfg) |
25 |
< |
: lastEvent(0), lastRun(0), theConfig(cfg), theUnique(true), theMuon(0), |
25 |
> |
: lastEvent(0), lastRun(0), theConfig(cfg), theUnique(true), theAllMuons(0), theMuon(0), |
26 |
|
hMuChi2Tk(0), hMuChi2Gl(0), hMuNHitsTk(0), |
27 |
|
hMuPtVsEta(0), hMuHitsRPCvsCSC(0), hMuHitsRPCvsDT(0), |
28 |
|
hMuonPt_BMF(0),hMuonEta_BMF (0),hMuonPhi_BMF(0) |
37 |
|
theMuon = 0; |
38 |
|
theUnique = true; |
39 |
|
|
40 |
+ |
|
41 |
|
//getBeamSpot |
42 |
|
math::XYZPoint reference(0.,0.,0.); |
43 |
|
edm::InputTag beamSpot = theConfig.getParameter<edm::InputTag>("beamSpot"); |
48 |
|
//get Muon |
49 |
|
edm::Handle<reco::MuonCollection> muons; |
50 |
|
ev.getByLabel( theConfig.getParameter<std::string>("muonColl"), muons); |
51 |
+ |
theAllMuons = muons->size(); |
52 |
|
|
53 |
|
for (reco::MuonCollection::const_iterator im = muons->begin(); im != muons->end(); ++im) { |
54 |
|
|
55 |
< |
if (!im->isTrackerMuon() || !im->innerTrack().isNonnull()) continue; |
56 |
< |
if (hMuonPt_BMF) hMuonPt_BMF->Fill( im->innerTrack()->pt()); |
57 |
< |
if (hMuonEta_BMF) hMuonEta_BMF->Fill( im->innerTrack()->eta()); |
58 |
< |
if (hMuonPhi_BMF) hMuonPhi_BMF->Fill( im->innerTrack()->phi()); |
59 |
< |
if (hMuPtVsEta) hMuPtVsEta->Fill(im->innerTrack()->eta(), im->innerTrack()->pt()); |
60 |
< |
if (im->innerTrack()->pt() < theConfig.getParameter<double>("minPt")) continue; |
61 |
< |
if (fabs(im->innerTrack()->eta()) > theConfig.getParameter<double>("maxEta")) continue; |
62 |
< |
if (im->innerTrack()->dxy(reference) > theConfig.getParameter<double>("maxTIP")) continue; |
63 |
< |
if (hMuChi2Tk) hMuChi2Tk->Fill(im->innerTrack()->normalizedChi2()); |
64 |
< |
if (im->innerTrack()->normalizedChi2() > theConfig.getParameter<double>("maxChi2Tk")) continue; |
65 |
< |
if (hMuChi2Gl && im->isGlobalMuon()) hMuChi2Gl->Fill(im->combinedMuon()->normalizedChi2()); |
55 |
> |
/* |
56 |
> |
if (ev.id().event() == 352597514) { |
57 |
> |
std::cout << "HERE Muon: matched stations:"<<im->numberOfMatchedStations() <<std::endl; |
58 |
> |
if (im->isGlobalMuon()) { |
59 |
> |
std::cout <<" GlobalMuon: " |
60 |
> |
<<" pt="<<im->combinedMuon()->pt() |
61 |
> |
<<" eta="<<im->combinedMuon()->eta() |
62 |
> |
<<" phi="<<im->combinedMuon()->phi() |
63 |
> |
<<" chi2: "<<im->combinedMuon()->normalizedChi2()<<std::endl; |
64 |
> |
} |
65 |
> |
if (im->isTrackerMuon() && im->innerTrack().isNonnull()) { |
66 |
> |
std::cout <<" TrackerMuon: " |
67 |
> |
<<" pt="<<im->innerTrack()->pt() |
68 |
> |
<<" eta="<<im->innerTrack()->eta() |
69 |
> |
<<" phi="<<im->innerTrack()->phi() |
70 |
> |
<< std::endl; |
71 |
> |
} |
72 |
> |
if (im->isStandAloneMuon()) std::cout <<" StandaloneMuon"<<std::endl; |
73 |
> |
} |
74 |
> |
*/ |
75 |
> |
if (im->bestTrack()->eta() > theConfig.getParameter<double>("maxEta")) continue; |
76 |
> |
if (im->bestTrack()->pt() < theConfig.getParameter<double>("minPt")) continue; |
77 |
> |
if (im->bestTrack()->dxy(reference) > theConfig.getParameter<double>("maxTIP")) continue; |
78 |
> |
|
79 |
> |
if ( theConfig.getParameter<bool>("requireInnerTrack")) { |
80 |
> |
if (!im->isTrackerMuon() || !im->innerTrack().isNonnull()) continue; |
81 |
> |
if (im->innerTrack()->normalizedChi2() > theConfig.getParameter<double>("maxChi2Tk")) continue; |
82 |
> |
if (hMuonPt_BMF) hMuonPt_BMF->Fill( im->innerTrack()->pt()); |
83 |
> |
if (hMuonEta_BMF) hMuonEta_BMF->Fill( im->innerTrack()->eta()); |
84 |
> |
if (hMuonPhi_BMF) hMuonPhi_BMF->Fill( im->innerTrack()->phi()); |
85 |
> |
if (hMuChi2Tk) hMuChi2Tk->Fill(im->innerTrack()->normalizedChi2()); |
86 |
> |
if (hMuPtVsEta) hMuPtVsEta->Fill(im->innerTrack()->eta(), im->innerTrack()->pt()); |
87 |
> |
} |
88 |
|
if ( theConfig.getParameter<bool>("requireOuterTrack")){ |
89 |
< |
if(!im->isStandAloneMuon() || !im->outerTrack().isNonnull())continue; |
90 |
< |
if(im->standAloneMuon()->normalizedChi2() > theConfig.getParameter<double>("maxChi2Sa")) continue; |
89 |
> |
if(!im->isStandAloneMuon() || !im->outerTrack().isNonnull())continue; |
90 |
> |
if(im->standAloneMuon()->normalizedChi2() > theConfig.getParameter<double>("maxChi2Sa")) continue; |
91 |
|
} |
92 |
|
if ( theConfig.getParameter<bool>("requireGlobalTrack")) { |
93 |
|
if(!im->isGlobalMuon() || !im->globalTrack().isNonnull()) continue; |
94 |
|
if(im->combinedMuon()->normalizedChi2() > theConfig.getParameter<double>("maxChi2Mu")) continue; |
95 |
|
} |
96 |
|
|
97 |
+ |
if (hMuChi2Gl && im->isGlobalMuon()) hMuChi2Gl->Fill(im->combinedMuon()->normalizedChi2()); |
98 |
|
if (im->numberOfMatchedStations() < theConfig.getParameter<int>("minNumberOfMatchedStations")) continue; |
74 |
– |
if (! (im->track()->hitPattern().numberOfValidPixelHits() > 0)) continue; |
99 |
|
|
100 |
|
// |
101 |
|
// TMP TIGHT SELECTION FOR IVAN |
131 |
|
if ( nRPCHits < theConfig.getParameter<int>("minNumberRpcHits")) continue; |
132 |
|
if ( nDTHits + nCSCHits < theConfig.getParameter<int>("minNumberDtCscHits") ) continue; |
133 |
|
|
134 |
< |
if (!theMuon || (im->track()->pt() > theMuon->track()->pt()) ) theMuon = &(*im); |
134 |
> |
if (!theMuon || (im->bestTrack()->pt() > theMuon->bestTrack()->pt()) ) theMuon = &(*im); |
135 |
|
} |
136 |
|
|
137 |
|
// |
138 |
|
// check if muon is unigue |
139 |
|
// |
140 |
|
if (theMuon) { |
141 |
< |
double muonEta = theMuon->innerTrack()->eta(); |
142 |
< |
double muonPhi = theMuon->innerTrack()->phi(); |
141 |
> |
double muonEta = theMuon->bestTrack()->eta(); |
142 |
> |
double muonPhi = theMuon->bestTrack()->phi(); |
143 |
|
for (reco::MuonCollection::const_iterator im = muons->begin(); im != muons->end(); ++im) { |
120 |
– |
if (!im->isTrackerMuon() || !im->innerTrack().isNonnull()) continue; |
144 |
|
if (&(*im) == theMuon) continue; |
145 |
< |
if ( fabs(reco::deltaPhi(muonPhi, im->innerTrack()->phi())) > theConfig.getParameter<double>("deltaPhiUnique")) continue; |
146 |
< |
if ( fabs(muonEta-im->innerTrack()->eta()) > theConfig.getParameter<double>("deltaEtaUnique")) continue; |
145 |
> |
if ( fabs(reco::deltaPhi(muonPhi, im->bestTrack()->phi())) > theConfig.getParameter<double>("deltaPhiUnique")) continue; |
146 |
> |
if ( fabs(muonEta-im->bestTrack()->eta()) > theConfig.getParameter<double>("deltaEtaUnique")) continue; |
147 |
|
theUnique = false; |
148 |
|
} |
149 |
|
} |