41 edm::LogVerbatim(
"MuonTrackProducer") <<
"\n ignoring missing muon collection.";
63 unsigned int index_dt_segment = 0;
66 ++segment, index_dt_segment++) {
67 LocalPoint segmentLocalPosition = segment->localPosition();
68 LocalVector segmentLocalDirection = segment->localDirection();
69 LocalError segmentLocalPositionError = segment->localPositionError();
70 LocalError segmentLocalDirectionError = segment->localDirectionError();
71 DetId geoid = segment->geographicalId();
75 int sector = dtdetid.
sector();
77 float segmentX = segmentLocalPosition.
x();
78 float segmentY = segmentLocalPosition.
y();
79 float segmentdXdZ = segmentLocalDirection.
x() / segmentLocalDirection.
z();
80 float segmentdYdZ = segmentLocalDirection.
y() / segmentLocalDirection.
z();
81 float segmentXerr =
sqrt(segmentLocalPositionError.
xx());
82 float segmentYerr =
sqrt(segmentLocalPositionError.
yy());
83 float segmentdXdZerr =
sqrt(segmentLocalDirectionError.
xx());
84 float segmentdYdZerr =
sqrt(segmentLocalDirectionError.
yy());
87 <<
"\nDT segment index :" << index_dt_segment <<
"\nchamber Wh:" <<
wheel <<
",St:" <<
station
88 <<
",Se:" << sector <<
"\nLocal Position (X,Y)=(" << segmentX <<
"," << segmentY <<
") +/- (" << segmentXerr
89 <<
"," << segmentYerr <<
"), "
90 <<
"Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ <<
"," << segmentdYdZ <<
") +/- (" << segmentdXdZerr <<
","
91 << segmentdYdZerr <<
")";
95 unsigned int index_csc_segment = 0;
98 ++segment, index_csc_segment++) {
99 LocalPoint segmentLocalPosition = segment->localPosition();
100 LocalVector segmentLocalDirection = segment->localDirection();
101 LocalError segmentLocalPositionError = segment->localPositionError();
102 LocalError segmentLocalDirectionError = segment->localDirectionError();
104 DetId geoid = segment->geographicalId();
111 float segmentX = segmentLocalPosition.
x();
112 float segmentY = segmentLocalPosition.
y();
113 float segmentdXdZ = segmentLocalDirection.
x() / segmentLocalDirection.
z();
114 float segmentdYdZ = segmentLocalDirection.
y() / segmentLocalDirection.
z();
115 float segmentXerr =
sqrt(segmentLocalPositionError.
xx());
116 float segmentYerr =
sqrt(segmentLocalPositionError.
yy());
117 float segmentdXdZerr =
sqrt(segmentLocalDirectionError.
xx());
118 float segmentdYdZerr =
sqrt(segmentLocalDirectionError.
yy());
121 <<
"\nCSC segment index :" << index_csc_segment <<
"\nchamber Endcap:" <<
endcap <<
",St:" <<
station
122 <<
",Ri:" <<
ring <<
",Ch:" <<
chamber <<
"\nLocal Position (X,Y)=(" << segmentX <<
"," << segmentY
123 <<
") +/- (" << segmentXerr <<
"," << segmentYerr <<
"), "
124 <<
"Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ <<
"," << segmentdYdZ <<
") +/- (" << segmentdXdZerr <<
","
125 << segmentdYdZerr <<
")";
129 unsigned int muon_index = 0;
131 ++
muon, muon_index++) {
132 edm::LogVerbatim(
"MuonTrackProducer") <<
"\n******* muon index : " << muon_index;
134 std::vector<bool> isGood;
136 isGood.push_back(
false);
142 bool isGoodResult =
true;
144 isGoodResult *= isGood[
index];
150 bool addMatchedMuonSegments =
false;
153 if (
muon->innerTrack().isNonnull())
154 trackref =
muon->innerTrack();
158 if (
muon->outerTrack().isNonnull())
159 trackref =
muon->outerTrack();
163 if (
muon->globalTrack().isNonnull())
164 trackref =
muon->globalTrack();
167 }
else if (
trackType ==
"innerTrackPlusSegments") {
168 if (
muon->innerTrack().isNonnull()) {
169 trackref =
muon->innerTrack();
170 addMatchedMuonSegments =
true;
173 }
else if (
trackType ==
"rpcMuonTrack") {
174 if (
muon->innerTrack().isNonnull() &&
muon->isRPCMuon()) {
175 trackref =
muon->innerTrack();
178 }
else if (
trackType ==
"gemMuonTrack") {
179 if (
muon->innerTrack().isNonnull() &&
muon->isGEMMuon()) {
180 trackref =
muon->innerTrack();
183 }
else if (
trackType ==
"me0MuonTrack") {
184 if (
muon->innerTrack().isNonnull() &&
muon->isME0Muon()) {
185 trackref =
muon->innerTrack();
189 if (
muon->isGlobalMuon() &&
muon->tunePMuonBestTrack().isNonnull())
190 trackref =
muon->tunePMuonBestTrack();
194 if (
muon->isPFMuon() &&
muon->muonBestTrack().isNonnull())
195 trackref =
muon->muonBestTrack();
198 }
else if (
trackType ==
"recomuonTrack") {
199 if (
muon->isGlobalMuon())
200 trackref =
muon->globalTrack();
201 else if (
muon->isTrackerMuon()) {
202 trackref =
muon->innerTrack();
203 addMatchedMuonSegments =
true;
204 }
else if (
muon->isStandAloneMuon())
205 trackref =
muon->outerTrack();
206 else if (
muon->isRPCMuon())
207 trackref =
muon->innerTrack();
208 else if (
muon->isGEMMuon())
209 trackref =
muon->innerTrack();
210 else if (
muon->isME0Muon())
211 trackref =
muon->innerTrack();
213 trackref =
muon->muonBestTrack();
215 if (
muon->muonBestTrackType() !=
muon->tunePMuonBestTrackType())
216 edm::LogVerbatim(
"MuonTrackProducer") <<
"\n *** PF != TuneP *** \n" << std::endl;
220 <<
"isTracker ? " <<
muon->isTrackerMuon() <<
", isRPC ? " <<
muon->isRPCMuon() <<
", isGEM ? "
221 <<
muon->isGEMMuon() <<
", isME0 ? " <<
muon->isME0Muon() << std::endl;
222 edm::LogVerbatim(
"MuonTrackProducer") <<
"isStandAlone ? " <<
muon->isStandAloneMuon() << std::endl;
224 edm::LogVerbatim(
"MuonTrackProducer") <<
"isPF ? " <<
muon->isPFMuon() << std::endl << std::endl;
227 <<
" enum MuonTrackType {None, InnerTrack, OuterTrack, CombinedTrack, TPFMS, Picky, DYT }" << std::endl;
230 <<
"(muon) pt = " <<
muon->pt() <<
", eta = " <<
muon->eta() <<
", phi = " <<
muon->phi() << std::endl;
232 if (
muon->muonBestTrack().isNonnull())
234 <<
"(best) pt = " <<
muon->muonBestTrack()->pt() <<
", eta = " <<
muon->muonBestTrack()->eta()
235 <<
", phi = " <<
muon->muonBestTrack()->phi()
236 <<
", N mu hits = " <<
muon->muonBestTrack()->hitPattern().numberOfValidMuonHits()
237 <<
", N trk hits = " <<
muon->muonBestTrack()->hitPattern().numberOfValidTrackerHits()
238 <<
", MuonTrackType = " <<
muon->muonBestTrackType() << std::endl;
239 if (
muon->tunePMuonBestTrack().isNonnull())
241 <<
"(tuneP) pt = " <<
muon->tunePMuonBestTrack()->pt()
242 <<
", eta = " <<
muon->tunePMuonBestTrack()->eta() <<
", phi = " <<
muon->tunePMuonBestTrack()->phi()
243 <<
", N mu hits = " <<
muon->tunePMuonBestTrack()->hitPattern().numberOfValidMuonHits()
244 <<
", N trk hits = " <<
muon->tunePMuonBestTrack()->hitPattern().numberOfValidTrackerHits()
245 <<
", MuonTrackType = " <<
muon->tunePMuonBestTrackType() << std::endl;
246 if (
muon->innerTrack().isNonnull())
248 <<
"(inner) pt = " <<
muon->innerTrack()->pt() <<
", eta = " <<
muon->innerTrack()->eta()
249 <<
", phi = " <<
muon->innerTrack()->phi()
250 <<
", N trk hits = " <<
muon->innerTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
251 if (
muon->globalTrack().isNonnull())
253 <<
"(global) pt = " <<
muon->globalTrack()->pt() <<
", eta = " <<
muon->globalTrack()->eta()
254 <<
", phi = " <<
muon->globalTrack()->phi()
255 <<
", N mu hits = " <<
muon->globalTrack()->hitPattern().numberOfValidMuonHits()
256 <<
", N trk hits = " <<
muon->globalTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
257 if (
muon->outerTrack().isNonnull())
259 <<
"(outer) pt = " <<
muon->outerTrack()->pt() <<
", eta = " <<
muon->outerTrack()->eta()
260 <<
", phi = " <<
muon->outerTrack()->phi()
261 <<
", N mu hits = " <<
muon->outerTrack()->hitPattern().numberOfValidMuonHits() << std::endl;
262 if (
muon->tpfmsTrack().isNonnull())
264 <<
"(tpfms) pt = " <<
muon->tpfmsTrack()->pt() <<
", eta = " <<
muon->tpfmsTrack()->eta()
265 <<
", phi = " <<
muon->tpfmsTrack()->phi()
266 <<
", N mu hits = " <<
muon->tpfmsTrack()->hitPattern().numberOfValidMuonHits()
267 <<
", N trk hits = " <<
muon->tpfmsTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
268 if (
muon->pickyTrack().isNonnull())
270 <<
"(picky) pt = " <<
muon->pickyTrack()->pt() <<
", eta = " <<
muon->pickyTrack()->eta()
271 <<
", phi = " <<
muon->pickyTrack()->phi()
272 <<
", N mu hits = " <<
muon->pickyTrack()->hitPattern().numberOfValidMuonHits()
273 <<
", N trk hits = " <<
muon->pickyTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
274 if (
muon->dytTrack().isNonnull())
276 <<
"(dyt) pt = " <<
muon->dytTrack()->pt() <<
", eta = " <<
muon->dytTrack()->eta()
277 <<
", phi = " <<
muon->dytTrack()->phi()
278 <<
", N mu hits = " <<
muon->dytTrack()->hitPattern().numberOfValidMuonHits()
279 <<
", N trk hits = " <<
muon->dytTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
285 std::unique_ptr<reco::Track> newTrk(
new reco::Track(*trk));
307 unsigned int nHitsToAdd = 0;
310 selectedTrackHits->push_back(
hit);
314 if (addMatchedMuonSegments) {
319 <<
"Number of chambers: " <<
muon->matches().size()
321 unsigned int index_chamber = 0;
323 for (std::vector<reco::MuonChamberMatch>::const_iterator chamberMatch =
muon->matches().begin();
324 chamberMatch !=
muon->matches().end();
325 ++chamberMatch, index_chamber++) {
326 std::stringstream chamberStr;
327 chamberStr <<
"\nchamber index: " << index_chamber;
329 int subdet = chamberMatch->detector();
330 DetId did = chamberMatch->id;
336 sector = dtdetid.
sector();
337 chamberStr <<
", DT chamber Wh:" <<
wheel <<
",St:" <<
station <<
",Se:" << sector;
347 chamberStr <<
", Number of segments: " << chamberMatch->segmentMatches.size();
350 unsigned int index_segment = 0;
352 for (std::vector<reco::MuonSegmentMatch>::const_iterator segmentMatch =
353 chamberMatch->segmentMatches.begin();
354 segmentMatch != chamberMatch->segmentMatches.end();
355 ++segmentMatch, index_segment++) {
356 float segmentX = segmentMatch->x;
357 float segmentY = segmentMatch->y;
358 float segmentdXdZ = segmentMatch->dXdZ;
359 float segmentdYdZ = segmentMatch->dYdZ;
360 float segmentXerr = segmentMatch->xErr;
361 float segmentYerr = segmentMatch->yErr;
362 float segmentdXdZerr = segmentMatch->dXdZErr;
363 float segmentdYdZerr = segmentMatch->dYdZErr;
372 if (segment_arbitrated_Ok)
373 ARBITRATED =
" ***ARBITRATED OK*** ";
377 <<
"\n\t segment index: " << index_segment << ARBITRATED <<
"\n\t Local Position (X,Y)=("
378 << segmentX <<
"," << segmentY <<
") +/- (" << segmentXerr <<
"," << segmentYerr <<
"), "
379 <<
"\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ <<
"," << segmentdYdZ <<
") +/- ("
380 << segmentdXdZerr <<
"," << segmentdYdZerr <<
")";
382 if (!segment_arbitrated_Ok)
385 if (segmentDT.
get() !=
nullptr) {
389 <<
"\t ===> MATCHING with DT segment with index = " << segmentDT.
key();
393 std::vector<const TrackingRecHit *> phiHits = phiSeg->
recHits();
394 for (std::vector<const TrackingRecHit *>::const_iterator ihit = phiHits.begin();
395 ihit != phiHits.end();
398 newTrk->appendHitPattern(*seghit, ttopo);
403 selectedTrackHits->push_back(seghit);
410 std::vector<const TrackingRecHit *> zedHits = zSeg->
recHits();
411 for (std::vector<const TrackingRecHit *>::const_iterator ihit = zedHits.begin();
412 ihit != zedHits.end();
415 newTrk->appendHitPattern(*seghit, ttopo);
420 selectedTrackHits->push_back(seghit);
425 edm::LogWarning(
"MuonTrackProducer") <<
"\n***WARNING: UNMATCHED DT segment ! \n";
430 <<
"\n\t segment index: " << index_segment << ARBITRATED <<
"\n\t Local Position (X,Y)=("
431 << segmentX <<
"," << segmentY <<
") +/- (" << segmentXerr <<
"," << segmentYerr <<
"), "
432 <<
"\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ <<
"," << segmentdYdZ <<
") +/- ("
433 << segmentdXdZerr <<
"," << segmentdYdZerr <<
")";
435 if (!segment_arbitrated_Ok)
438 if (segmentCSC.
get() !=
nullptr) {
442 <<
"\t ===> MATCHING with CSC segment with index = " << segmentCSC.
key();
444 std::vector<const TrackingRecHit *>
hits = segment->
recHits();
445 for (std::vector<const TrackingRecHit *>::const_iterator ihit =
hits.begin(); ihit !=
hits.end();
448 newTrk->appendHitPattern(*seghit, ttopo);
453 selectedTrackHits->push_back(seghit);
457 edm::LogWarning(
"MuonTrackProducer") <<
"\n***WARNING: UNMATCHED CSC segment ! \n";
467 newExtra->setHits(rHits, hidx, nHitsToAdd);
471 selectedTrackExtras->push_back(*newExtra);