Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-24 03:14:54

0001 #ifndef HLTBTagPerformanceAnalyzer_H
0002 #define HLTBTagPerformanceAnalyzer_H
0003 
0004 // system include files
0005 #include <map>
0006 #include <memory>
0007 #include <string>
0008 #include <vector>
0009 
0010 // user include files
0011 #include "DataFormats/BTauReco/interface/JetTag.h"
0012 #include "DataFormats/BTauReco/interface/ShallowTagInfo.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/Frameworkfwd.h"
0015 #include "FWCore/Framework/interface/MakerMacros.h"
0016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0017 #include <DQMServices/Core/interface/DQMEDAnalyzer.h>
0018 
0019 // Trigger
0020 #include "DataFormats/Common/interface/TriggerResults.h"
0021 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0022 
0023 // DQM services
0024 #include "DQMServices/Core/interface/DQMStore.h"
0025 #include "FWCore/Framework/interface/ConsumesCollector.h"
0026 #include "FWCore/ServiceRegistry/interface/Service.h"
0027 #include <DQMServices/Core/interface/DQMEDAnalyzer.h>
0028 
0029 // for gen matching
0030 #include "DataFormats/JetMatching/interface/JetFlavourMatching.h"
0031 #include <Math/GenVector/VectorUtil.h>
0032 
0033 #include "FWCore/Utilities/interface/transform.h"
0034 
0035 /** \class HLTBTagPerformanceAnalyzer
0036  *
0037  *  Code used to produce DQM validation plots for b-tag at HLT.
0038  *  It plots the 1D distribution of the b-tag discriminant for all,b,c,lights,g
0039  * jets And it plots the 2D distribution of the b-tag discriminant for
0040  * all,b,c,lights,g jets vs pT
0041  */
0042 
0043 class HLTBTagPerformanceAnalyzer : public DQMEDAnalyzer {
0044 public:
0045   explicit HLTBTagPerformanceAnalyzer(const edm::ParameterSet &);
0046   ~HLTBTagPerformanceAnalyzer() override;
0047   void dqmBeginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) override;
0048 
0049 private:
0050   void analyze(const edm::Event &, const edm::EventSetup &) override;
0051   void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &iRun, edm::EventSetup const &iSetup) override;
0052 
0053   struct JetRefCompare {
0054     inline bool operator()(const edm::RefToBase<reco::Jet> &j1, const edm::RefToBase<reco::Jet> &j2) const {
0055       return j1.id() < j2.id() || (j1.id() == j2.id() && j1.key() < j2.key());
0056     }
0057   };
0058 
0059   typedef std::map<edm::RefToBase<reco::Jet>, float, JetRefCompare> JetTagMap;
0060 
0061   enum HCALSpecials { HEP17, HEP18, HEM17 };
0062 
0063   // variables from python configuration
0064   edm::EDGetTokenT<edm::TriggerResults> hlTriggerResults_;
0065   std::string mainFolder_;
0066   std::vector<std::string> hltPathNames_;
0067   HLTConfigProvider hltConfigProvider_;
0068   bool triggerConfChanged_;
0069   std::vector<edm::EDGetTokenT<reco::JetTagCollection>> JetTagCollection_;
0070   //                edm::EDGetTokenT<std::vector<reco::ShallowTagInfo> >
0071   //                shallowTagInfosTokenCalo_;
0072   edm::EDGetTokenT<std::vector<reco::ShallowTagInfo>> shallowTagInfosTokenPf_;
0073   //                edm::Handle<std::vector<reco::ShallowTagInfo> >
0074   //                shallowTagInfosCalo;
0075   edm::Handle<std::vector<reco::ShallowTagInfo>> shallowTagInfosPf;
0076 
0077   /// other class variable
0078   std::vector<bool> _isfoundHLTs;
0079   std::vector<int> hltPathIndexs_;
0080 
0081   // gen level tag-handlers
0082   typedef unsigned int flavour_t;
0083   typedef std::vector<flavour_t> flavours_t;
0084 
0085   edm::EDGetTokenT<reco::JetFlavourMatchingCollection> m_mcPartons;  // MC truth match - jet association to partons
0086   std::vector<std::string> m_mcLabels;                               // MC truth match - labels
0087   std::vector<flavours_t> m_mcFlavours;                              // MC truth match - flavours selection
0088   double m_mcRadius;                                                 // MC truth match - deltaR association radius
0089   bool m_mcMatching;                                                 // MC truth matching anabled/disabled
0090 
0091   /// DQM folder handle
0092   std::vector<std::string> folders;
0093 
0094   // Histogram handler
0095   std::vector<std::map<std::string, MonitorElement *>> H1_;
0096   std::vector<std::map<std::string, std::map<HCALSpecials, MonitorElement *>>> H1mod_;
0097   std::vector<std::map<std::string, MonitorElement *>> H2_;
0098   std::vector<std::map<std::string, std::map<HCALSpecials, MonitorElement *>>> H2mod_;
0099   std::vector<std::map<std::string, MonitorElement *>> H2Eta_;
0100   std::vector<std::map<std::string, MonitorElement *>> H2EtaPhi_;
0101   std::vector<std::map<std::string, MonitorElement *>> H2EtaPhi_threshold_;
0102   std::vector<std::map<std::string, MonitorElement *>> H2Phi_;
0103 
0104   // Other variables
0105   edm::EDConsumerBase::Labels label;
0106   std::string m_mcPartons_Label;
0107   std::vector<std::string> JetTagCollection_Label;
0108   std::string hlTriggerResults_Label;
0109   std::string hltConfigProvider_Label;
0110   std::map<HLTBTagPerformanceAnalyzer::HCALSpecials, std::string> HCALSpecialsNames;
0111 };
0112 
0113 #endif