CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/HLTrigger/Muon/interface/HLTMuonL2ToL1Map.h

Go to the documentation of this file.
00001 #ifndef HLTMuonL2ToL1Map_h
00002 #define HLTMuonL2ToL1Map_h
00003 
00013 #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h"
00014 #include "DataFormats/TrackReco/interface/Track.h"
00015 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00016 #include "DataFormats/MuonSeed/interface/L2MuonTrajectorySeedCollection.h"
00017 #include "DataFormats/Common/interface/AssociationMap.h"
00018 #include "DataFormats/Common/interface/OneToMany.h"
00019 #include "DataFormats/Common/interface/Handle.h"
00020 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00021 
00022 typedef edm::AssociationMap<edm::OneToMany<std::vector<L2MuonTrajectorySeed>, std::vector<L2MuonTrajectorySeed> > > SeedMap;
00023 
00024 class HLTMuonL2ToL1Map{
00025 
00026   public:
00028     explicit HLTMuonL2ToL1Map(edm::InputTag& previousCandTag, edm::InputTag& seedMapTag, edm::Event& iEvent){
00029       // get hold of muons that fired the previous level
00030       edm::Handle<trigger::TriggerFilterObjectWithRefs> previousLevelCands;
00031       iEvent.getByLabel(previousCandTag, previousLevelCands);
00032       previousLevelCands->getObjects(trigger::TriggerL1Mu, firedL1Muons_);
00033 
00034       // get hold of the seed map
00035       iEvent.getByLabel(seedMapTag, seedMapHandle_);
00036     }
00037 
00038     ~HLTMuonL2ToL1Map(){
00039     }
00040 
00042     bool isTriggeredByL1(reco::TrackRef& l2muon){
00043       bool isTriggered = false;
00044       const edm::RefVector<L2MuonTrajectorySeedCollection>& seeds = (*seedMapHandle_)[l2muon->seedRef().castTo<edm::Ref<L2MuonTrajectorySeedCollection> >()];
00045       for(size_t i=0; i<seeds.size(); i++){
00046         if(find(firedL1Muons_.begin(), firedL1Muons_.end(), seeds[i]->l1Particle()) != firedL1Muons_.end()){
00047           isTriggered = true;
00048           break;
00049         }
00050       }
00051       return isTriggered;
00052     }
00053 
00055     std::string getL1Keys(reco::TrackRef& l2muon){
00056       std::ostringstream ss;
00057       const edm::RefVector<L2MuonTrajectorySeedCollection>& seeds = (*seedMapHandle_)[l2muon->seedRef().castTo<edm::Ref<L2MuonTrajectorySeedCollection> >()];
00058       for(size_t i=0; i<seeds.size(); i++){
00059         ss<<seeds[i]->l1Particle().key()<<" ";
00060       }
00061       return ss.str();
00062     }
00063 
00064   private:
00066     std::vector<l1extra::L1MuonParticleRef> firedL1Muons_;
00067 
00069     edm::Handle<SeedMap> seedMapHandle_;
00070 };
00071 
00072 #endif //HLTMuonL2ToL1Map_h