Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:56

0001 #ifndef BTagPerformanceAnalyzerMC_H
0002 #define BTagPerformanceAnalyzerMC_H
0003 
0004 #include "DQMOffline/RecoB/interface/AcceptJet.h"
0005 #include "DQMOffline/RecoB/interface/BaseTagInfoPlotter.h"
0006 #include "DQMOffline/RecoB/interface/JetTagPlotter.h"
0007 #include "DQMOffline/RecoB/interface/MatchJet.h"
0008 #include "DQMOffline/RecoB/interface/TagCorrelationPlotter.h"
0009 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0010 #include "DataFormats/Common/interface/Association.h"
0011 #include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
0012 #include "DataFormats/JetReco/interface/GenJet.h"
0013 #include "DataFormats/JetReco/interface/Jet.h"
0014 #include "FWCore/Framework/interface/Frameworkfwd.h"
0015 #include "JetMETCorrections/JetCorrector/interface/JetCorrector.h"
0016 #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
0017 #include "DataFormats/JetMatching/interface/JetFlavour.h"
0018 #include "DataFormats/JetMatching/interface/JetFlavourInfo.h"
0019 #include "DataFormats/JetMatching/interface/JetFlavourInfoMatching.h"
0020 #include "DataFormats/JetMatching/interface/JetFlavourMatching.h"
0021 /** \class BTagPerformanceAnalyzerMC
0022  *
0023  *  Top level steering routine for b tag performance analysis.
0024  *
0025  */
0026 
0027 class BTagPerformanceAnalyzerMC : public DQMEDAnalyzer {
0028 public:
0029   explicit BTagPerformanceAnalyzerMC(const edm::ParameterSet &pSet);
0030 
0031   ~BTagPerformanceAnalyzerMC() override;
0032 
0033   void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override;
0034 
0035 private:
0036   struct JetRefCompare {
0037     inline bool operator()(const edm::RefToBase<reco::Jet> &j1, const edm::RefToBase<reco::Jet> &j2) const {
0038       return j1.id() < j2.id() || (j1.id() == j2.id() && j1.key() < j2.key());
0039     }
0040   };
0041 
0042   // Get histogram plotting options from configuration.
0043   void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
0044 
0045   EtaPtBin getEtaPtBin(const int &iEta, const int &iPt);
0046 
0047   typedef std::pair<reco::Jet, reco::JetFlavourInfo> JetWithFlavour;
0048   typedef std::map<edm::RefToBase<reco::Jet>, unsigned int, JetRefCompare> FlavourMap;
0049   typedef std::map<edm::RefToBase<reco::Jet>, reco::JetFlavour::Leptons, JetRefCompare> LeptonMap;
0050 
0051   bool getJetWithFlavour(const edm::Event &iEvent,
0052                          edm::RefToBase<reco::Jet> caloRef,
0053                          const FlavourMap &_flavours,
0054                          JetWithFlavour &jetWithFlavour,
0055                          const reco::JetCorrector *corrector,
0056                          edm::Handle<edm::Association<reco::GenJetCollection>> genJetsMatched);
0057   bool getJetWithGenJet(edm::RefToBase<reco::Jet> jetRef,
0058                         edm::Handle<edm::Association<reco::GenJetCollection>> genJetsMatched);
0059 
0060   std::vector<std::string> tiDataFormatType;
0061   AcceptJet jetSelector;  // Decides if jet and parton satisfy kinematic cuts.
0062   std::vector<double> etaRanges, ptRanges;
0063   bool useOldFlavourTool;
0064   bool doJEC;
0065 
0066   bool ptHatWeight;
0067 
0068   edm::InputTag jetMCSrc;
0069   edm::InputTag slInfoTag;
0070   edm::InputTag genJetsMatchedSrc;
0071 
0072   std::vector<std::vector<std::unique_ptr<JetTagPlotter>>> binJetTagPlotters;
0073   std::vector<std::vector<std::unique_ptr<TagCorrelationPlotter>>> binTagCorrelationPlotters;
0074   std::vector<std::vector<std::unique_ptr<BaseTagInfoPlotter>>> binTagInfoPlotters;
0075   std::vector<edm::InputTag> jetTagInputTags;
0076   std::vector<std::pair<edm::InputTag, edm::InputTag>> tagCorrelationInputTags;
0077   std::vector<std::vector<edm::InputTag>> tagInfoInputTags;
0078   //  JetFlavourIdentifier jfi;
0079   std::vector<edm::ParameterSet> moduleConfig;
0080 
0081   std::string flavPlots_;
0082   unsigned int mcPlots_;
0083 
0084   CorrectJet jetCorrector;
0085   MatchJet jetMatcher;
0086 
0087   bool doPUid;
0088   bool eventInitialized;
0089   bool electronPlots, muonPlots, tauPlots;
0090 
0091   // add consumes
0092   edm::EDGetTokenT<GenEventInfoProduct> genToken;
0093   edm::EDGetTokenT<edm::Association<reco::GenJetCollection>> genJetsMatchedToken;
0094   edm::EDGetTokenT<reco::JetCorrector> jecMCToken;
0095   edm::EDGetTokenT<reco::JetCorrector> jecDataToken;
0096   edm::EDGetTokenT<reco::JetFlavourInfoMatchingCollection> jetToken;
0097   edm::EDGetTokenT<reco::JetFlavourMatchingCollection> caloJetToken;
0098   edm::EDGetTokenT<reco::SoftLeptonTagInfoCollection> slInfoToken;
0099   std::vector<edm::EDGetTokenT<reco::JetTagCollection>> jetTagToken;
0100   std::vector<std::pair<edm::EDGetTokenT<reco::JetTagCollection>, edm::EDGetTokenT<reco::JetTagCollection>>>
0101       tagCorrelationToken;
0102   std::vector<std::vector<edm::EDGetTokenT<edm::View<reco::BaseTagInfo>>>> tagInfoToken;
0103 };
0104 
0105 #endif