Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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