Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:36

0001 #ifndef HLTMuonL2ToL1Map_h
0002 #define HLTMuonL2ToL1Map_h
0003 
0004 /** \class HLTMuonL2ToL1Map
0005  *
0006  *  
0007  *  This is a helper class to check L2 to L1 links
0008  *
0009  *  \author Z. Gecse
0010  *
0011  */
0012 
0013 #include "DataFormats/L1Trigger/interface/L1MuonParticleFwd.h"
0014 #include "DataFormats/TrackReco/interface/Track.h"
0015 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0016 #include "DataFormats/MuonSeed/interface/L2MuonTrajectorySeedCollection.h"
0017 #include "DataFormats/Common/interface/AssociationMap.h"
0018 #include "DataFormats/Common/interface/OneToMany.h"
0019 #include "DataFormats/Common/interface/Handle.h"
0020 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0021 
0022 #include "FWCore/Framework/interface/Event.h"
0023 
0024 typedef edm::AssociationMap<edm::OneToMany<std::vector<L2MuonTrajectorySeed>, std::vector<L2MuonTrajectorySeed> > >
0025     SeedMap;
0026 
0027 class HLTMuonL2ToL1Map {
0028 public:
0029   /// construct with the Token of the L1 filter object, the Token of the L2 seed map ("hltL2Muons") and the Event
0030   explicit HLTMuonL2ToL1Map(const edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs>& previousCandToken,
0031                             const edm::EDGetTokenT<SeedMap> seedMapToken,
0032                             const edm::Event& iEvent) {
0033     // get hold of muons that fired the previous level
0034     edm::Handle<trigger::TriggerFilterObjectWithRefs> previousLevelCands;
0035     iEvent.getByToken(previousCandToken, previousLevelCands);
0036     previousLevelCands->getObjects(trigger::TriggerL1Mu, firedL1Muons_);
0037 
0038     // get hold of the seed map
0039     iEvent.getByToken(seedMapToken, seedMapHandle_);
0040   }
0041 
0042   ~HLTMuonL2ToL1Map() {}
0043 
0044   /// checks if a L2 muon was seeded by a fired L1
0045   bool isTriggeredByL1(reco::TrackRef& l2muon) {
0046     bool isTriggered = false;
0047     const edm::RefVector<L2MuonTrajectorySeedCollection>& seeds =
0048         (*seedMapHandle_)[l2muon->seedRef().castTo<edm::Ref<L2MuonTrajectorySeedCollection> >()];
0049     for (size_t i = 0; i < seeds.size(); i++) {
0050       if (find(firedL1Muons_.begin(), firedL1Muons_.end(), seeds[i]->l1Particle()) != firedL1Muons_.end()) {
0051         isTriggered = true;
0052         break;
0053       }
0054     }
0055     return isTriggered;
0056   }
0057 
0058   /// returns the indices of L1 seeds
0059   std::string getL1Keys(reco::TrackRef& l2muon) {
0060     std::ostringstream ss;
0061     const edm::RefVector<L2MuonTrajectorySeedCollection>& seeds =
0062         (*seedMapHandle_)[l2muon->seedRef().castTo<edm::Ref<L2MuonTrajectorySeedCollection> >()];
0063     for (size_t i = 0; i < seeds.size(); i++) {
0064       ss << seeds[i]->l1Particle().key() << " ";
0065     }
0066     return ss.str();
0067   }
0068 
0069 private:
0070   /// contains the vector of references to fired L1 candidates
0071   std::vector<l1extra::L1MuonParticleRef> firedL1Muons_;
0072 
0073   /// containes the map from a L2 seed to its sister seeds the track of which has been cleaned
0074   edm::Handle<SeedMap> seedMapHandle_;
0075 };
0076 
0077 #endif  //HLTMuonL2ToL1Map_h