00001 #include "RecoMuon/TrackerSeedGenerator/plugins/DualByL2TSG.h" 00002 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00003 #include "FWCore/Framework/interface/Event.h" 00004 #include "DataFormats/Common/interface/Handle.h" 00005 00006 #include "DataFormats/TrackReco/interface/Track.h" 00007 #include "DataFormats/TrackReco/interface/TrackFwd.h" 00008 #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeed.h" 00009 #include "DataFormats/MuonSeed/interface/L3MuonTrajectorySeedCollection.h" 00010 #include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedGenerator.h" 00011 00012 DualByL2TSG::DualByL2TSG(const edm::ParameterSet &pset) : SeparatingTSG(pset){ theCategory ="DualByL2TSG"; 00013 theL3CollectionLabelA = pset.getParameter<edm::InputTag>("L3TkCollectionA"); 00014 if (nTSGs()!=2) 00015 {edm::LogError(theCategory)<<"not two seed generators provided";} 00016 } 00017 00018 unsigned int DualByL2TSG::selectTSG(const TrackCand & muonTrackCand, const TrackingRegion& region) 00019 { 00020 LogDebug(theCategory)<<"|eta|=|"<<muonTrackCand.second->eta()<<"|"; 00021 00022 bool re_do_this_L2 = true; 00023 //LogDebug("TrackerSeedGenerator")<<theEvent; 00024 //getEvent(); 00025 00026 //retrieve L3 track collection 00027 edm::Handle<reco::TrackCollection> l3muonH; 00028 getEvent()->getByLabel(theL3CollectionLabelA ,l3muonH); 00029 if(l3muonH.failedToGet()) return 0; 00030 00031 unsigned int maxI = l3muonH->size(); 00032 00033 LogDebug(theCategory) << "TheCollectionA size " << maxI; 00034 00035 // Loop through all tracks, if the track was seeded from this L2, then skip 00036 for (unsigned int i=0;i!=maxI;++i){ 00037 reco::TrackRef tk(l3muonH,i); 00038 edm::Ref<L3MuonTrajectorySeedCollection> l3seedRef = tk->seedRef().castTo<edm::Ref<L3MuonTrajectorySeedCollection> >(); 00039 reco::TrackRef staTrack = l3seedRef->l2Track(); 00040 00041 if(staTrack == (muonTrackCand.second) ) re_do_this_L2 = false; 00042 //LogDebug(theCategory) << "The DualByL2TSG selectTSG loop " << re_do_this_L2 << " staCand " << muonTrackCand.second->eta() << " " << muonTrackCand.second->pt() << " alreadyMadeRefToL3 " << staTrack->eta() << " " << staTrack->pt(); 00043 } 00044 00045 LogDebug(theCategory) << "The DualByL2TSG to use " << re_do_this_L2 ; 00046 00047 return re_do_this_L2 ? 1 : 0; 00048 }