Skip to content

Commit 19c1787

Browse files
authored
Merge pull request cms-sw#42532 from CeliaFernandez/dev-addNonUpdatedSTAMu
Include an additional input to fill standalone muon tracks in MuonIdProducer
2 parents 41284a4 + 3182908 commit 19c1787

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ MuonIdProducer::MuonIdProducer(const edm::ParameterSet& iConfig)
136136
throw cms::Exception("ConfigurationError")
137137
<< "Number of input collection labels is different from number of types. "
138138
<< "For each collection label there should be exactly one collection type specified.";
139-
if (inputCollectionLabels_.size() > 7 || inputCollectionLabels_.empty())
140-
throw cms::Exception("ConfigurationError") << "Number of input collections should be from 1 to 7.";
139+
if (inputCollectionLabels_.size() > 8 || inputCollectionLabels_.empty())
140+
throw cms::Exception("ConfigurationError") << "Number of input collections should be from 1 to 8.";
141141

142142
debugWithTruthMatching_ = iConfig.getParameter<bool>("debugWithTruthMatching");
143143
if (debugWithTruthMatching_) {
@@ -180,8 +180,10 @@ MuonIdProducer::MuonIdProducer(const edm::ParameterSet& iConfig)
180180

181181
if (inputType == ICTypes::INNER_TRACKS) {
182182
innerTrackCollectionToken_ = consumes<reco::TrackCollection>(inputLabel);
183-
} else if (inputType == ICTypes::OUTER_TRACKS) {
183+
} else if (inputType == ICTypes::OUTER_TRACKS && outerTrackCollectionToken_.isUninitialized()) {
184184
outerTrackCollectionToken_ = consumes<reco::TrackCollection>(inputLabel);
185+
} else if (inputType == ICTypes::OUTER_TRACKS) {
186+
outerTrackSecondaryCollectionToken_ = consumes<reco::TrackCollection>(inputLabel);
185187
} else if (inputType == ICTypes::LINKS) {
186188
linkCollectionToken_ = consumes<reco::MuonTrackLinksCollection>(inputLabel);
187189
} else if (inputType == ICTypes::MUONS) {
@@ -205,6 +207,7 @@ MuonIdProducer::~MuonIdProducer() {
205207
void MuonIdProducer::init(edm::Event& iEvent, const edm::EventSetup& iSetup) {
206208
innerTrackCollectionHandle_.clear();
207209
outerTrackCollectionHandle_.clear();
210+
outerTrackSecondaryCollectionHandle_.clear();
208211
linkCollectionHandle_.clear();
209212
muonCollectionHandle_.clear();
210213

@@ -225,11 +228,17 @@ void MuonIdProducer::init(edm::Event& iEvent, const edm::EventSetup& iSetup) {
225228
if (!innerTrackCollectionHandle_.isValid())
226229
throw cms::Exception("FatalError") << "Failed to get input track collection with label: " << inputLabel;
227230
LogTrace("MuonIdentification") << "Number of input inner tracks: " << innerTrackCollectionHandle_->size();
228-
} else if (inputType == ICTypes::OUTER_TRACKS) {
231+
} else if (inputType == ICTypes::OUTER_TRACKS && !outerTrackCollectionHandle_.isValid()) {
229232
iEvent.getByToken(outerTrackCollectionToken_, outerTrackCollectionHandle_);
230233
if (!outerTrackCollectionHandle_.isValid())
231234
throw cms::Exception("FatalError") << "Failed to get input track collection with label: " << inputLabel;
232235
LogTrace("MuonIdentification") << "Number of input outer tracks: " << outerTrackCollectionHandle_->size();
236+
} else if (inputType == ICTypes::OUTER_TRACKS) {
237+
iEvent.getByToken(outerTrackSecondaryCollectionToken_, outerTrackSecondaryCollectionHandle_);
238+
if (!outerTrackSecondaryCollectionHandle_.isValid())
239+
throw cms::Exception("FatalError") << "Failed to get input track collection with label: " << inputLabel;
240+
LogTrace("MuonIdentification") << "Number of input outer secondary tracks: "
241+
<< outerTrackSecondaryCollectionHandle_->size();
233242
} else if (inputType == ICTypes::LINKS) {
234243
iEvent.getByToken(linkCollectionToken_, linkCollectionHandle_);
235244
if (!linkCollectionHandle_.isValid())
@@ -629,8 +638,14 @@ void MuonIdProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
629638
// and at last the stand alone muons
630639
if (outerTrackCollectionHandle_.isValid()) {
631640
LogTrace("MuonIdentification") << "Looking for new muons among stand alone muon tracks";
632-
for (unsigned int i = 0; i < outerTrackCollectionHandle_->size(); ++i) {
633-
const auto& outerTrack = outerTrackCollectionHandle_->at(i);
641+
const unsigned int nouter = outerTrackCollectionHandle_->size();
642+
const unsigned int nsecond =
643+
(outerTrackSecondaryCollectionHandle_.isValid()) ? outerTrackSecondaryCollectionHandle_->size() : 0;
644+
for (unsigned int i = 0; i < nouter + nsecond; ++i) {
645+
const auto& outerTrack =
646+
(i < nouter) ? outerTrackCollectionHandle_->at(i) : outerTrackSecondaryCollectionHandle_->at(i - nouter);
647+
reco::TrackRef refToTrack = (i < nouter) ? reco::TrackRef(outerTrackCollectionHandle_, i)
648+
: reco::TrackRef(outerTrackSecondaryCollectionHandle_, i - nouter);
634649

635650
// check if this muon is already in the list of global muons
636651
bool newMuon = true;
@@ -654,16 +669,15 @@ void MuonIdProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
654669
if (overlap(muon, outerTrack) > 0) {
655670
LogTrace("MuonIdentification") << "Found associated tracker muon. Set a reference and move on";
656671
newMuon = false;
657-
muon.setOuterTrack(reco::TrackRef(outerTrackCollectionHandle_, i));
672+
muon.setOuterTrack(refToTrack);
658673
muon.setType(muon.type() | reco::Muon::StandAloneMuon);
659674
break;
660675
}
661676
}
662677
}
663678
if (newMuon) {
664679
LogTrace("MuonIdentification") << "No associated stand alone track is found. Making a muon";
665-
outputMuons->push_back(
666-
makeMuon(iEvent, iSetup, reco::TrackRef(outerTrackCollectionHandle_, i), reco::Muon::OuterTrack));
680+
outputMuons->push_back(makeMuon(iEvent, iSetup, refToTrack, reco::Muon::OuterTrack));
667681
outputMuons->back().setType(reco::Muon::StandAloneMuon);
668682
}
669683
}

RecoMuon/MuonIdentification/plugins/MuonIdProducer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ class MuonIdProducer : public edm::stream::EDProducer<> {
228228

229229
edm::Handle<reco::TrackCollection> innerTrackCollectionHandle_;
230230
edm::Handle<reco::TrackCollection> outerTrackCollectionHandle_;
231+
edm::Handle<reco::TrackCollection> outerTrackSecondaryCollectionHandle_;
231232
edm::Handle<reco::MuonCollection> muonCollectionHandle_;
232233
edm::Handle<reco::MuonTrackLinksCollection> linkCollectionHandle_;
233234
edm::Handle<reco::TrackToTrackMap> tpfmsCollectionHandle_;
@@ -237,6 +238,7 @@ class MuonIdProducer : public edm::stream::EDProducer<> {
237238

238239
edm::EDGetTokenT<reco::TrackCollection> innerTrackCollectionToken_;
239240
edm::EDGetTokenT<reco::TrackCollection> outerTrackCollectionToken_;
241+
edm::EDGetTokenT<reco::TrackCollection> outerTrackSecondaryCollectionToken_;
240242
edm::EDGetTokenT<reco::MuonCollection> muonCollectionToken_;
241243
edm::EDGetTokenT<reco::MuonTrackLinksCollection> linkCollectionToken_;
242244
edm::EDGetTokenT<reco::TrackToTrackMap> tpfmsCollectionToken_;

RecoMuon/MuonIdentification/python/muons1stStep_cfi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
inputCollectionTypes = cms.vstring('inner tracks',
3636
'links',
3737
'outer tracks',
38+
'outer tracks',
3839
'tev firstHit',
3940
'tev picky',
4041
'tev dyt'),
@@ -44,7 +45,7 @@
4445
# internal
4546
debugWithTruthMatching = cms.bool(False),
4647
# input tracks
47-
inputCollectionLabels = cms.VInputTag(cms.InputTag("generalTracks"), cms.InputTag("globalMuons"), cms.InputTag("standAloneMuons","UpdatedAtVtx"),
48+
inputCollectionLabels = cms.VInputTag(cms.InputTag("generalTracks"), cms.InputTag("globalMuons"), cms.InputTag("standAloneMuons","UpdatedAtVtx"), cms.InputTag("standAloneMuons"),
4849
cms.InputTag("tevMuons","firstHit"),cms.InputTag("tevMuons","picky"),cms.InputTag("tevMuons","dyt")),
4950
fillCaloCompatibility = cms.bool(True),
5051
# OR

0 commit comments

Comments
 (0)