Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:19

0001 // -*- c++ -*-
0002 #ifndef DQMOffline_Trigger_HLTTauDQMPath_h
0003 #define DQMOffline_Trigger_HLTTauDQMPath_h
0004 
0005 #include "DataFormats/Math/interface/LorentzVector.h"
0006 
0007 #include <tuple>
0008 #include <vector>
0009 #include <string>
0010 
0011 class HLTConfigProvider;
0012 namespace edm {
0013   class ParameterSet;
0014   class TriggerResults;
0015 }  // namespace edm
0016 namespace trigger {
0017   class TriggerEvent;
0018   class TriggerObject;
0019 }  // namespace trigger
0020 struct HLTTauDQMOfflineObjects;
0021 
0022 class HLTTauDQMPath {
0023 public:
0024   using LV = math::XYZTLorentzVectorD;
0025   using LVColl = std::vector<LV>;
0026   typedef std::tuple<std::string, std::string, size_t> FilterIndex;
0027 
0028   constexpr static size_t kName = 0;
0029   constexpr static size_t kType = 1;
0030   constexpr static size_t kModuleIndex = 2;
0031   constexpr static size_t kInvalidIndex = std::numeric_limits<size_t>::max();
0032 
0033   struct Object {
0034     const trigger::TriggerObject& object;
0035     const int id;  // from TriggerTypeDefs.h
0036   };
0037 
0038   HLTTauDQMPath(std::string pathName, std::string hltProcess, bool doRefAnalysis, const HLTConfigProvider& HLTCP);
0039   ~HLTTauDQMPath();
0040 
0041   bool isValid() const { return isValid_; }
0042 
0043   bool fired(const edm::TriggerResults& triggerResults) const;
0044 
0045   // index (to getFilterName, getFilterIndex) of the last passed filter
0046   // -1, if the first filter rejects the event
0047   int lastPassedFilter(const edm::TriggerResults& triggerResults) const;
0048 
0049   const std::string& getPathName() const { return pathName_; }
0050   const unsigned int getPathIndex() const { return pathIndex_; }
0051 
0052   size_t filtersSize() const { return filterIndices_.size(); }
0053   const std::string& getFilterName(size_t i) const { return std::get<kName>(filterIndices_[i]); }
0054   const std::string& getFilterType(size_t i) const { return std::get<kType>(filterIndices_[i]); }
0055   int getFilterNTaus(size_t i) const {
0056     if (i < filterTauN_.size())
0057       return filterTauN_[i];
0058     else
0059       return 0;
0060   }
0061   int getFilterNElectrons(size_t i) const {
0062     if (i < filterElectronN_.size())
0063       return filterElectronN_[i];
0064     else
0065       return 0;
0066   }
0067   int getFilterNMuons(size_t i) const {
0068     if (i < filterMuonN_.size())
0069       return filterMuonN_[i];
0070     else
0071       return 0;
0072   }
0073   int getFilterMET(size_t i) const {
0074     if (i < filterMET_.size())
0075       return filterMET_[i];
0076     else
0077       return 0;
0078   }
0079   int getFilterLevel(size_t i) const {
0080     if (i < filterLevel_.size())
0081       return filterLevel_[i];
0082     else
0083       return 0;
0084   }
0085 
0086   bool isFirstFilterL1Seed() const { return isFirstL1Seed_; }
0087   const std::string& getLastFilterName() const { return std::get<kName>(filterIndices_.back()); }
0088 
0089   bool hasL2Taus() const { return lastL2TauFilterIndex_ != kInvalidIndex; }
0090   bool hasL3Taus() const { return lastL3TauFilterIndex_ != kInvalidIndex; }
0091   bool hasL2Electrons() const { return lastL2ElectronFilterIndex_ != kInvalidIndex; }
0092   bool hasL3Electrons() const { return lastL3ElectronFilterIndex_ != kInvalidIndex; }
0093   bool hasL2Muons() const { return lastL2MuonFilterIndex_ != kInvalidIndex; }
0094   bool hasL3Muons() const { return lastL3MuonFilterIndex_ != kInvalidIndex; }
0095   bool hasL2CaloMET() const { return lastL2METFilterIndex_ != kInvalidIndex; }
0096   size_t getLastFilterBeforeL2TauIndex() const { return lastFilterBeforeL2TauIndex_; }
0097   size_t getLastL2TauFilterIndex() const { return lastL2TauFilterIndex_; }
0098   size_t getLastFilterBeforeL3TauIndex() const { return lastFilterBeforeL3TauIndex_; }
0099   size_t getLastL3TauFilterIndex() const { return lastL3TauFilterIndex_; }
0100 
0101   size_t getLastFilterBeforeL2ElectronIndex() const { return lastFilterBeforeL2ElectronIndex_; }
0102   size_t getLastL2ElectronFilterIndex() const { return lastL2ElectronFilterIndex_; }
0103   size_t getLastFilterBeforeL3ElectronIndex() const { return lastFilterBeforeL3ElectronIndex_; }
0104   size_t getLastL3ElectronFilterIndex() const { return lastL3ElectronFilterIndex_; }
0105 
0106   size_t getLastFilterBeforeL2MuonIndex() const { return lastFilterBeforeL2MuonIndex_; }
0107   size_t getLastL2MuonFilterIndex() const { return lastL2MuonFilterIndex_; }
0108   size_t getLastFilterBeforeL3MuonIndex() const { return lastFilterBeforeL3MuonIndex_; }
0109   size_t getLastL3MuonFilterIndex() const { return lastL3MuonFilterIndex_; }
0110 
0111   size_t getLastFilterBeforeL2CaloMETIndex() const { return lastFilterBeforeL2METIndex_; }
0112   size_t getLastL2CaloMETFilterIndex() const { return lastL2METFilterIndex_; }
0113   size_t getFirstFilterBeforeL2CaloMETIndex() const { return firstFilterBeforeL2METIndex_; }
0114   size_t getFirstL2CaloMETFilterIndex() const { return firstL2METFilterIndex_; }
0115 
0116   // index (to edm::TriggerResults) of a filter
0117   size_t getFilterIndex(size_t i) const { return std::get<kModuleIndex>(filterIndices_[i]); }
0118 
0119   // Get objects associated to a filter, i is the "internal" index
0120   void getFilterObjects(const trigger::TriggerEvent& triggerEvent, size_t i, std::vector<Object>& retval) const;
0121 
0122   // i = filter index
0123   bool offlineMatching(size_t i,
0124                        const std::vector<Object>& triggerObjects,
0125                        const HLTTauDQMOfflineObjects& offlineObjects,
0126                        double dR,
0127                        std::vector<Object>& matchedTriggerObjects,
0128                        HLTTauDQMOfflineObjects& matchedOfflineObjects) const;
0129 
0130   bool goodOfflineEvent(size_t i, const HLTTauDQMOfflineObjects& offlineObjects) const;
0131 
0132 private:
0133   const std::string hltProcess_;
0134   const bool doRefAnalysis_;
0135 
0136   std::vector<FilterIndex> filterIndices_;
0137   std::vector<int> filterTauN_;
0138   std::vector<int> filterElectronN_;
0139   std::vector<int> filterMuonN_;
0140   std::vector<int> filterMET_;
0141   std::vector<int> filterLevel_;
0142   const std::string pathName_;
0143   const unsigned int pathIndex_;
0144   size_t lastFilterBeforeL2TauIndex_;
0145   size_t lastL2TauFilterIndex_;
0146   size_t lastFilterBeforeL3TauIndex_;
0147   size_t lastL3TauFilterIndex_;
0148   size_t lastFilterBeforeL2ElectronIndex_;
0149   size_t lastL2ElectronFilterIndex_;
0150   size_t lastFilterBeforeL3ElectronIndex_;
0151   size_t lastL3ElectronFilterIndex_;
0152   size_t lastFilterBeforeL2MuonIndex_;
0153   size_t lastL2MuonFilterIndex_;
0154   size_t lastFilterBeforeL3MuonIndex_;
0155   size_t lastL3MuonFilterIndex_;
0156   size_t lastFilterBeforeL2METIndex_;
0157   size_t lastL2METFilterIndex_;
0158   size_t firstFilterBeforeL2METIndex_;
0159   size_t firstL2METFilterIndex_;
0160   bool isFirstL1Seed_;
0161   bool isValid_;
0162 };
0163 
0164 #endif