46 inputDTRecSegment4DToken_(
48 inputCSCSegmentToken_(
55 produces<reco::TrackCollection>();
56 produces<reco::TrackExtraCollection>();
57 produces<TrackingRecHitCollection>();
63 edm::LogVerbatim(
"MuonTrackProducer") <<
"\n ignoring missing muon collection.";
82 edm::LogVerbatim(
"MuonTrackProducer") <<
"\nThere are " << dtSegmentCollection.size() <<
" DT segments.";
83 unsigned int index_dt_segment = 0;
85 segment != dtSegmentCollection.end();
86 ++segment, index_dt_segment++) {
87 LocalPoint segmentLocalPosition = segment->localPosition();
88 LocalVector segmentLocalDirection = segment->localDirection();
89 LocalError segmentLocalPositionError = segment->localPositionError();
90 LocalError segmentLocalDirectionError = segment->localDirectionError();
91 DetId geoid = segment->geographicalId();
97 float segmentX = segmentLocalPosition.
x();
98 float segmentY = segmentLocalPosition.
y();
99 float segmentdXdZ = segmentLocalDirection.
x() / segmentLocalDirection.
z();
100 float segmentdYdZ = segmentLocalDirection.
y() / segmentLocalDirection.
z();
101 float segmentXerr =
sqrt(segmentLocalPositionError.
xx());
102 float segmentYerr =
sqrt(segmentLocalPositionError.
yy());
103 float segmentdXdZerr =
sqrt(segmentLocalDirectionError.
xx());
104 float segmentdYdZerr =
sqrt(segmentLocalDirectionError.
yy());
107 <<
"\nDT segment index :" << index_dt_segment <<
"\nchamber Wh:" <<
wheel <<
",St:" <<
station 108 <<
",Se:" <<
sector <<
"\nLocal Position (X,Y)=(" << segmentX <<
"," << segmentY <<
") +/- (" << segmentXerr
109 <<
"," << segmentYerr <<
"), " 110 <<
"Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ <<
"," << segmentdYdZ <<
") +/- (" << segmentdXdZerr <<
"," 111 << segmentdYdZerr <<
")";
114 edm::LogVerbatim(
"MuonTrackProducer") <<
"\nThere are " << cscSegmentCollection.size() <<
" CSC segments.";
115 unsigned int index_csc_segment = 0;
117 segment != cscSegmentCollection.end();
118 ++segment, index_csc_segment++) {
119 LocalPoint segmentLocalPosition = segment->localPosition();
120 LocalVector segmentLocalDirection = segment->localDirection();
121 LocalError segmentLocalPositionError = segment->localPositionError();
122 LocalError segmentLocalDirectionError = segment->localDirectionError();
124 DetId geoid = segment->geographicalId();
131 float segmentX = segmentLocalPosition.
x();
132 float segmentY = segmentLocalPosition.
y();
133 float segmentdXdZ = segmentLocalDirection.
x() / segmentLocalDirection.
z();
134 float segmentdYdZ = segmentLocalDirection.
y() / segmentLocalDirection.
z();
135 float segmentXerr =
sqrt(segmentLocalPositionError.
xx());
136 float segmentYerr =
sqrt(segmentLocalPositionError.
yy());
137 float segmentdXdZerr =
sqrt(segmentLocalDirectionError.
xx());
138 float segmentdYdZerr =
sqrt(segmentLocalDirectionError.
yy());
141 <<
"\nCSC segment index :" << index_csc_segment <<
"\nchamber Endcap:" <<
endcap <<
",St:" <<
station 142 <<
",Ri:" <<
ring <<
",Ch:" <<
chamber <<
"\nLocal Position (X,Y)=(" << segmentX <<
"," << segmentY
143 <<
") +/- (" << segmentXerr <<
"," << segmentYerr <<
"), " 144 <<
"Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ <<
"," << segmentdYdZ <<
") +/- (" << segmentdXdZerr <<
"," 145 << segmentdYdZerr <<
")";
148 edm::LogVerbatim(
"MuonTrackProducer") <<
"\nThere are " << muonCollectionH->size() <<
" reco::Muons.";
149 unsigned int muon_index = 0;
150 for (reco::MuonCollection::const_iterator
muon = muonCollectionH->begin();
muon != muonCollectionH->end();
151 ++
muon, muon_index++) {
152 edm::LogVerbatim(
"MuonTrackProducer") <<
"\n******* muon index : " << muon_index;
154 const bool isGoodResult =
163 bool addMatchedMuonSegments =
false;
166 if (
muon->innerTrack().isNonnull())
167 trackref =
muon->innerTrack();
171 if (
muon->outerTrack().isNonnull())
172 trackref =
muon->outerTrack();
176 if (
muon->globalTrack().isNonnull())
177 trackref =
muon->globalTrack();
180 }
else if (
trackType ==
"innerTrackPlusSegments") {
181 if (
muon->innerTrack().isNonnull()) {
182 trackref =
muon->innerTrack();
183 addMatchedMuonSegments =
true;
186 }
else if (
trackType ==
"rpcMuonTrack") {
187 if (
muon->innerTrack().isNonnull() &&
muon->isRPCMuon()) {
188 trackref =
muon->innerTrack();
191 }
else if (
trackType ==
"gemMuonTrack") {
192 if (
muon->innerTrack().isNonnull() &&
muon->isGEMMuon()) {
193 trackref =
muon->innerTrack();
196 }
else if (
trackType ==
"me0MuonTrack") {
197 if (
muon->innerTrack().isNonnull() &&
muon->isME0Muon()) {
198 trackref =
muon->innerTrack();
202 if (
muon->isGlobalMuon() &&
muon->tunePMuonBestTrack().isNonnull())
203 trackref =
muon->tunePMuonBestTrack();
207 if (
muon->isPFMuon() &&
muon->muonBestTrack().isNonnull())
208 trackref =
muon->muonBestTrack();
211 }
else if (
trackType ==
"recomuonTrack") {
212 if (
muon->muonBestTrackType() !=
muon->tunePMuonBestTrackType())
213 edm::LogVerbatim(
"MuonTrackProducer") <<
"\n *** PF != TuneP *** \n" << std::endl;
217 <<
"isTracker ? " <<
muon->isTrackerMuon() <<
", isRPC ? " <<
muon->isRPCMuon() <<
", isGEM ? " 218 <<
muon->isGEMMuon() <<
", isME0 ? " <<
muon->isME0Muon() << std::endl;
219 edm::LogVerbatim(
"MuonTrackProducer") <<
"isStandAlone ? " <<
muon->isStandAloneMuon() << std::endl;
221 edm::LogVerbatim(
"MuonTrackProducer") <<
"isPF ? " <<
muon->isPFMuon() << std::endl << std::endl;
224 <<
" enum MuonTrackType {None, InnerTrack, OuterTrack, CombinedTrack, TPFMS, Picky, DYT }" << std::endl;
227 <<
"(muon) pt = " <<
muon->pt() <<
", eta = " <<
muon->eta() <<
", phi = " <<
muon->phi() << std::endl;
229 if (
muon->muonBestTrack().isNonnull())
231 <<
"(best) pt = " <<
muon->muonBestTrack()->pt() <<
", eta = " <<
muon->muonBestTrack()->eta()
232 <<
", phi = " <<
muon->muonBestTrack()->phi()
233 <<
", N mu hits = " <<
muon->muonBestTrack()->hitPattern().numberOfValidMuonHits()
234 <<
", N trk hits = " <<
muon->muonBestTrack()->hitPattern().numberOfValidTrackerHits()
235 <<
", MuonTrackType = " <<
muon->muonBestTrackType() << std::endl;
236 if (
muon->tunePMuonBestTrack().isNonnull())
238 <<
"(tuneP) pt = " <<
muon->tunePMuonBestTrack()->pt()
239 <<
", eta = " <<
muon->tunePMuonBestTrack()->eta() <<
", phi = " <<
muon->tunePMuonBestTrack()->phi()
240 <<
", N mu hits = " <<
muon->tunePMuonBestTrack()->hitPattern().numberOfValidMuonHits()
241 <<
", N trk hits = " <<
muon->tunePMuonBestTrack()->hitPattern().numberOfValidTrackerHits()
242 <<
", MuonTrackType = " <<
muon->tunePMuonBestTrackType() << std::endl;
243 if (
muon->innerTrack().isNonnull())
245 <<
"(inner) pt = " <<
muon->innerTrack()->pt() <<
", eta = " <<
muon->innerTrack()->eta()
246 <<
", phi = " <<
muon->innerTrack()->phi()
247 <<
", N trk hits = " <<
muon->innerTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
248 if (
muon->globalTrack().isNonnull())
250 <<
"(global) pt = " <<
muon->globalTrack()->pt() <<
", eta = " <<
muon->globalTrack()->eta()
251 <<
", phi = " <<
muon->globalTrack()->phi()
252 <<
", N mu hits = " <<
muon->globalTrack()->hitPattern().numberOfValidMuonHits()
253 <<
", N trk hits = " <<
muon->globalTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
254 if (
muon->outerTrack().isNonnull())
256 <<
"(outer) pt = " <<
muon->outerTrack()->pt() <<
", eta = " <<
muon->outerTrack()->eta()
257 <<
", phi = " <<
muon->outerTrack()->phi()
258 <<
", N mu hits = " <<
muon->outerTrack()->hitPattern().numberOfValidMuonHits() << std::endl;
259 if (
muon->tpfmsTrack().isNonnull())
261 <<
"(tpfms) pt = " <<
muon->tpfmsTrack()->pt() <<
", eta = " <<
muon->tpfmsTrack()->eta()
262 <<
", phi = " <<
muon->tpfmsTrack()->phi()
263 <<
", N mu hits = " <<
muon->tpfmsTrack()->hitPattern().numberOfValidMuonHits()
264 <<
", N trk hits = " <<
muon->tpfmsTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
265 if (
muon->pickyTrack().isNonnull())
267 <<
"(picky) pt = " <<
muon->pickyTrack()->pt() <<
", eta = " <<
muon->pickyTrack()->eta()
268 <<
", phi = " <<
muon->pickyTrack()->phi()
269 <<
", N mu hits = " <<
muon->pickyTrack()->hitPattern().numberOfValidMuonHits()
270 <<
", N trk hits = " <<
muon->pickyTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
271 if (
muon->dytTrack().isNonnull())
273 <<
"(dyt) pt = " <<
muon->dytTrack()->pt() <<
", eta = " <<
muon->dytTrack()->eta()
274 <<
", phi = " <<
muon->dytTrack()->phi()
275 <<
", N mu hits = " <<
muon->dytTrack()->hitPattern().numberOfValidMuonHits()
276 <<
", N trk hits = " <<
muon->dytTrack()->hitPattern().numberOfValidTrackerHits() << std::endl;
278 if (
muon->isGlobalMuon() &&
muon->globalTrack()->hitPattern().numberOfValidMuonHits() > 0)
279 trackref =
muon->globalTrack();
280 else if (
muon->isTrackerMuon()) {
281 trackref =
muon->innerTrack();
282 addMatchedMuonSegments =
true;
283 }
else if (
muon->isPFMuon())
284 trackref =
muon->muonBestTrack();
285 else if (
muon->isStandAloneMuon())
286 trackref =
muon->outerTrack();
287 else if (
muon->isRPCMuon())
288 trackref =
muon->innerTrack();
289 else if (
muon->isGEMMuon())
290 trackref =
muon->innerTrack();
291 else if (
muon->isME0Muon())
292 trackref =
muon->innerTrack();
294 trackref =
muon->muonBestTrack();
306 trk->outerMomentum(),
308 trk->innerPosition(),
309 trk->innerMomentum(),
311 trk->outerStateCovariance(),
313 trk->innerStateCovariance(),
322 unsigned int nHitsToAdd = 0;
325 selectedTrackHits->push_back(
hit);
329 if (addMatchedMuonSegments) {
334 <<
"Number of chambers: " <<
muon->matches().size()
336 unsigned int index_chamber = 0;
338 for (std::vector<reco::MuonChamberMatch>::const_iterator chamberMatch =
muon->matches().begin();
339 chamberMatch !=
muon->matches().end();
340 ++chamberMatch, index_chamber++) {
341 std::stringstream chamberStr;
342 chamberStr <<
"\nchamber index: " << index_chamber;
344 int subdet = chamberMatch->detector();
345 DetId did = chamberMatch->id;
362 chamberStr <<
", Number of segments: " << chamberMatch->segmentMatches.size();
365 unsigned int index_segment = 0;
367 for (std::vector<reco::MuonSegmentMatch>::const_iterator segmentMatch =
368 chamberMatch->segmentMatches.begin();
369 segmentMatch != chamberMatch->segmentMatches.end();
370 ++segmentMatch, index_segment++) {
371 float segmentX = segmentMatch->x;
372 float segmentY = segmentMatch->y;
373 float segmentdXdZ = segmentMatch->dXdZ;
374 float segmentdYdZ = segmentMatch->dYdZ;
375 float segmentXerr = segmentMatch->xErr;
376 float segmentYerr = segmentMatch->yErr;
377 float segmentdXdZerr = segmentMatch->dXdZErr;
378 float segmentdYdZerr = segmentMatch->dYdZErr;
387 if (segment_arbitrated_Ok)
388 ARBITRATED =
" ***ARBITRATED OK*** ";
392 <<
"\n\t segment index: " << index_segment << ARBITRATED <<
"\n\t Local Position (X,Y)=(" 393 << segmentX <<
"," << segmentY <<
") +/- (" << segmentXerr <<
"," << segmentYerr <<
"), " 394 <<
"\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ <<
"," << segmentdYdZ <<
") +/- (" 395 << segmentdXdZerr <<
"," << segmentdYdZerr <<
")";
397 if (!segment_arbitrated_Ok)
400 if (segmentDT.
get() !=
nullptr) {
404 <<
"\t ===> MATCHING with DT segment with index = " << segmentDT.
key();
408 std::vector<const TrackingRecHit *> phiHits = phiSeg->
recHits();
409 for (std::vector<const TrackingRecHit *>::const_iterator ihit = phiHits.begin();
410 ihit != phiHits.end();
413 newTrk->appendHitPattern(*seghit, ttopo);
418 selectedTrackHits->push_back(seghit);
425 std::vector<const TrackingRecHit *> zedHits = zSeg->
recHits();
426 for (std::vector<const TrackingRecHit *>::const_iterator ihit = zedHits.begin();
427 ihit != zedHits.end();
430 newTrk->appendHitPattern(*seghit, ttopo);
435 selectedTrackHits->push_back(seghit);
440 edm::LogWarning(
"MuonTrackProducer") <<
"\n***WARNING: UNMATCHED DT segment ! \n";
445 <<
"\n\t segment index: " << index_segment << ARBITRATED <<
"\n\t Local Position (X,Y)=(" 446 << segmentX <<
"," << segmentY <<
") +/- (" << segmentXerr <<
"," << segmentYerr <<
"), " 447 <<
"\n\t Local Direction (dXdZ,dYdZ)=(" << segmentdXdZ <<
"," << segmentdYdZ <<
") +/- (" 448 << segmentdXdZerr <<
"," << segmentdYdZerr <<
")";
450 if (!segment_arbitrated_Ok)
453 if (segmentCSC.
get() !=
nullptr) {
457 <<
"\t ===> MATCHING with CSC segment with index = " << segmentCSC.
key();
459 std::vector<const TrackingRecHit *>
hits = segment->
recHits();
460 for (std::vector<const TrackingRecHit *>::const_iterator ihit =
hits.begin(); ihit !=
hits.end();
463 newTrk->appendHitPattern(*seghit, ttopo);
468 selectedTrackHits->push_back(seghit);
472 edm::LogWarning(
"MuonTrackProducer") <<
"\n***WARNING: UNMATCHED CSC segment ! \n";
482 newExtra->setHits(rHits, hidx, nHitsToAdd);
486 selectedTrackExtras->push_back(*newExtra);
Log< level::Info, true > LogVerbatim
int station() const
Return the station number.
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
bool hasPhi() const
Does it have the Phi projection?
edm::EDGetTokenT< DTRecSegment4DCollection > inputDTRecSegment4DToken_
std::vector< std::string > selectionTags
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
edm::EDGetTokenT< reco::MuonCollection > muonsToken
std::vector< Track > TrackCollection
collection of Tracks
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttopoToken_
key_type key() const
Accessor for product key.
std::vector< Muon > MuonCollection
collection of Muon objects
SelectionType
Selector type.
bool ignoreMissingMuonCollection
C::const_iterator const_iterator
constant access iterator type
#define DEFINE_FWK_MODULE(type)
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
static const unsigned int BestInChamberByDR
ignoreMissingMuonCollection
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
virtual TrackingRecHit * clone() const =0
MuonTrackProducer(const edm::ParameterSet &)
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
edm::OwnVector< TrackingRecHit > TrackingRecHitCollection
collection of TrackingRecHits
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
SelectionType selectionTypeFromString(const std::string &label)
static const unsigned int BelongsToTrackByDR
int wheel() const
Return the wheel number.
std::string dump(unsigned int indent=0) const
T const * get() const
Returns C++ pointer to the item.
Log< level::Warning, false > LogWarning
bool hasZed() const
Does it have the Z projection?
edm::EDGetTokenT< CSCSegmentCollection > inputCSCSegmentToken_