Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:15

0001 #include "RecoMuon/TrackerSeedGenerator/plugins/DualByL2TSG.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "DataFormats/Common/interface/Handle.h"
0005 
0006 #include "DataFormats/TrackReco/interface/Track.h"
0007 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0008 #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeed.h"
0009 #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeedCollection.h"
0010 #include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedGenerator.h"
0011 
0012 DualByL2TSG::DualByL2TSG(const edm::ParameterSet& pset, edm::ConsumesCollector& iC) : SeparatingTSG(pset, iC) {
0013   theCategory = "DualByL2TSG";
0014   theL3CollectionLabelA = pset.getParameter<edm::InputTag>("L3TkCollectionA");
0015   if (nTSGs() != 2) {
0016     edm::LogError(theCategory) << "not two seed generators provided";
0017   }
0018 
0019   l3muonToken = iC.consumes<reco::TrackCollection>(theL3CollectionLabelA);
0020 }
0021 
0022 unsigned int DualByL2TSG::selectTSG(const TrackCand& muonTrackCand, const TrackingRegion& region) {
0023   LogDebug(theCategory) << "|eta|=|" << muonTrackCand.second->eta() << "|";
0024 
0025   bool re_do_this_L2 = true;
0026   //LogDebug("TrackerSeedGenerator")<<theEvent;
0027   //getEvent();
0028 
0029   //retrieve L3 track collection
0030   edm::Handle<reco::TrackCollection> l3muonH;
0031   getEvent()->getByToken(l3muonToken, l3muonH);
0032   if (l3muonH.failedToGet())
0033     return 0;
0034 
0035   unsigned int maxI = l3muonH->size();
0036 
0037   LogDebug(theCategory) << "TheCollectionA size " << maxI;
0038 
0039   // Loop through all tracks, if the track was seeded from this L2, then skip
0040   for (unsigned int i = 0; i != maxI; ++i) {
0041     reco::TrackRef tk(l3muonH, i);
0042     edm::Ref<L3MuonTrajectorySeedCollection> l3seedRef =
0043         tk->seedRef().castTo<edm::Ref<L3MuonTrajectorySeedCollection> >();
0044     reco::TrackRef staTrack = l3seedRef->l2Track();
0045 
0046     if (staTrack == (muonTrackCand.second))
0047       re_do_this_L2 = false;
0048     //LogDebug(theCategory) << "The DualByL2TSG selectTSG loop " << re_do_this_L2 << " staCand " << muonTrackCand.second->eta() << " " << muonTrackCand.second->pt() << " alreadyMadeRefToL3 " << staTrack->eta() << " " << staTrack->pt();
0049   }
0050 
0051   LogDebug(theCategory) << "The DualByL2TSG to use " << re_do_this_L2;
0052 
0053   return re_do_this_L2 ? 1 : 0;
0054 }