Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-28 04:16:01

0001 #ifndef DQMOFFLINE_L1TRIGGER_L1TTAUOFFLINE_H
0002 #define DQMOFFLINE_L1TRIGGER_L1TTAUOFFLINE_H
0003 
0004 // DataFormats
0005 #include "DataFormats/L1Trigger/interface/BXVector.h"
0006 #include "DataFormats/L1Trigger/interface/Tau.h"
0007 #include "DataFormats/TauReco/interface/PFTauFwd.h"
0008 #include "DataFormats/TauReco/interface/PFTauDiscriminator.h"
0009 #include "DataFormats/TauReco/interface/TauDiscriminatorContainer.h"
0010 #include "DataFormats/Common/interface/TriggerResults.h"
0011 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0012 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0013 #include "DataFormats/METReco/interface/METFwd.h"
0014 #include "DataFormats/METReco/interface/PFMET.h"
0015 #include "DataFormats/METReco/interface/PFMETCollection.h"
0016 #include "DataFormats/VertexReco/interface/Vertex.h"
0017 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0018 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0019 #include "DataFormats/Provenance/interface/ProcessHistoryID.h"
0020 #include "DataFormats/Provenance/interface/ProductProvenance.h"
0021 
0022 // FWCore
0023 #include "FWCore/Common/interface/Provenance.h"
0024 #include "FWCore/Framework/interface/Frameworkfwd.h"
0025 #include "FWCore/Framework/interface/ESHandle.h"
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/LuminosityBlock.h"
0028 #include "FWCore/Framework/interface/MakerMacros.h"
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 #include "FWCore/ServiceRegistry/interface/Service.h"
0031 
0032 // TrackingTools
0033 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
0034 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0035 
0036 // DQMServices
0037 #include "DQMServices/Core/interface/DQMStore.h"
0038 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0039 
0040 #include "DQMOffline/L1Trigger/interface/HistDefinition.h"
0041 
0042 // MagneticField
0043 #include "MagneticField/Engine/interface/MagneticField.h"
0044 
0045 // HLTrigger
0046 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0047 
0048 #include <iostream>
0049 #include <fstream>
0050 #include <utility>
0051 #include <vector>
0052 
0053 class TauL1TPair {
0054 public:
0055   TauL1TPair(const reco::PFTau* tau, const l1t::Tau* regTau)
0056       : m_tau(tau), m_regTau(regTau), m_eta(999.), m_phi_bar(999.), m_phi_end(999.){};
0057 
0058   TauL1TPair(const TauL1TPair& tauL1tPair);
0059 
0060   ~TauL1TPair(){};
0061 
0062   double dR();
0063   double eta() const { return m_tau->eta(); };
0064   double phi() const { return m_tau->phi(); };
0065   double pt() const { return m_tau->pt(); };
0066   double l1tPt() const { return m_regTau ? m_regTau->pt() : -1.; };
0067   double l1tIso() const { return m_regTau ? m_regTau->hwIso() : -1.; };
0068   double l1tPhi() const { return m_regTau ? m_regTau->phi() : -5.; };
0069   double l1tEta() const { return m_regTau ? m_regTau->eta() : -5.; };
0070 
0071 private:
0072   const reco::PFTau* m_tau;
0073   const l1t::Tau* m_regTau;
0074 
0075   double m_eta;
0076   double m_phi_bar;
0077   double m_phi_end;
0078 };
0079 
0080 class L1TTauOffline : public DQMEDAnalyzer {
0081 public:
0082   L1TTauOffline(const edm::ParameterSet& ps);
0083   ~L1TTauOffline() override;
0084 
0085   enum PlotConfig { nVertex, ETvsET, PHIvsPHI };
0086 
0087   static const std::map<std::string, unsigned int> PlotConfigNames;
0088 
0089 protected:
0090   void dqmBeginRun(const edm::Run& run, const edm::EventSetup& iSetup) override;
0091   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0092   void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
0093 
0094   const reco::Vertex getPrimaryVertex(edm::Handle<reco::VertexCollection> const& vertex,
0095                                       edm::Handle<reco::BeamSpot> const& beamSpot);
0096   bool matchHlt(edm::Handle<trigger::TriggerEvent> const& triggerEvent, const reco::Muon* muon);
0097 
0098   // Cut and Matching
0099   void getTauL1tPairs(edm::Handle<l1t::TauBxCollection> const& l1tCands);
0100   void getTightMuons(edm::Handle<reco::MuonCollection> const& muons,
0101                      edm::Handle<reco::PFMETCollection> const& mets,
0102                      const reco::Vertex& vertex,
0103                      edm::Handle<trigger::TriggerEvent> const& trigEvent);
0104   void getProbeTaus(const edm::Event& e,
0105                     edm::Handle<reco::PFTauCollection> const& taus,
0106                     edm::Handle<reco::MuonCollection> const& muons,
0107                     const reco::Vertex& vertex);
0108 
0109 private:
0110   void bookTauHistos(DQMStore::IBooker&);
0111 
0112   // other functions
0113   double Distance(const reco::Candidate& c1, const reco::Candidate& c2);
0114   double DistancePhi(const reco::Candidate& c1, const reco::Candidate& c2);
0115   double calcDeltaPhi(double phi1, double phi2);
0116 
0117   void normalise2DHistogramsToBinArea();
0118 
0119   math::XYZPoint PVPoint_;
0120 
0121   HLTConfigProvider m_hltConfig;
0122 
0123   edm::ESHandle<MagneticField> m_BField;
0124   edm::ESHandle<Propagator> m_propagatorAlong;
0125   edm::ESHandle<Propagator> m_propagatorOpposite;
0126 
0127   edm::ProcessHistoryID phID_;
0128 
0129   // variables from config file
0130   edm::EDGetTokenT<reco::PFTauCollection> theTauCollection_;
0131   edm::EDGetTokenT<reco::TauDiscriminatorContainer> AntiMuInputTag_;
0132   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> mFieldToken_;
0133   std::string AntiMuWP_;
0134   int AntiMuWPIndex_;
0135   edm::EDGetTokenT<reco::TauDiscriminatorContainer> AntiEleInputTag_;
0136   std::string AntiEleWP_;
0137   int AntiEleWPIndex_;
0138   edm::EDGetTokenT<reco::PFTauDiscriminator> DecayModeFindingInputTag_;
0139   edm::EDGetTokenT<reco::TauDiscriminatorContainer> comb3TInputTag_;
0140   std::string comb3TWP_;
0141   int comb3TWPIndex_;
0142   edm::EDGetTokenT<reco::MuonCollection> MuonInputTag_;
0143   edm::EDGetTokenT<reco::PFMETCollection> MetInputTag_;
0144   edm::EDGetTokenT<reco::VertexCollection> VtxInputTag_;
0145   edm::EDGetTokenT<reco::BeamSpot> BsInputTag_;
0146   edm::EDGetTokenT<trigger::TriggerEvent> triggerEvent_;
0147   std::string trigProcess_;
0148   edm::EDGetTokenT<edm::TriggerResults> triggerResults_;
0149   std::vector<std::string> triggerPath_;
0150   std::string histFolder_;
0151   std::string efficiencyFolder_;
0152   edm::EDGetTokenT<l1t::TauBxCollection> stage2CaloLayer2TauToken_;
0153   std::vector<int> tauEfficiencyThresholds_;
0154   std::vector<double> tauEfficiencyBins_;
0155   dqmoffline::l1t::HistDefinitions histDefinitions_;
0156 
0157   std::vector<const reco::Muon*> m_TightMuons;
0158   std::vector<const reco::PFTau*> m_ProbeTaus;
0159   std::vector<TauL1TPair> m_TauL1tPairs;
0160 
0161   std::vector<reco::PFTauCollection> m_RecoTaus;
0162   std::vector<l1t::TauBxCollection> m_L1tTaus;
0163   std::vector<reco::PFTau> m_RecoRecoTaus;
0164   BXVector<l1t::Tau> m_L1tL1tTaus;
0165 
0166   // config params
0167   std::vector<int> m_L1tPtCuts;
0168 
0169   float m_MaxTauEta;
0170   float m_MaxL1tTauDR;
0171   float m_MaxHltTauDR;
0172 
0173   std::vector<int> m_trigIndices;
0174 
0175   // Histograms
0176   MonitorElement* h_nVertex_;
0177   MonitorElement* h_tagAndProbeMass_;
0178 
0179   // electron reco vs L1
0180   MonitorElement* h_L1TauETvsTauET_EB_;
0181   MonitorElement* h_L1TauETvsTauET_EE_;
0182   MonitorElement* h_L1TauETvsTauET_EB_EE_;
0183 
0184   MonitorElement* h_L1TauPhivsTauPhi_EB_;
0185   MonitorElement* h_L1TauPhivsTauPhi_EE_;
0186   MonitorElement* h_L1TauPhivsTauPhi_EB_EE_;
0187 
0188   MonitorElement* h_L1TauEtavsTauEta_;
0189 
0190   // electron resolutions
0191   MonitorElement* h_resolutionTauET_EB_;
0192   MonitorElement* h_resolutionTauET_EE_;
0193   MonitorElement* h_resolutionTauET_EB_EE_;
0194 
0195   MonitorElement* h_resolutionTauPhi_EB_;
0196   MonitorElement* h_resolutionTauPhi_EE_;
0197   MonitorElement* h_resolutionTauPhi_EB_EE_;
0198 
0199   MonitorElement* h_resolutionTauEta_;
0200 
0201   // tau turn-ons
0202   std::map<double, MonitorElement*> h_efficiencyIsoTauET_EB_pass_;
0203   std::map<double, MonitorElement*> h_efficiencyIsoTauET_EE_pass_;
0204   std::map<double, MonitorElement*> h_efficiencyIsoTauET_EB_EE_pass_;
0205 
0206   std::map<double, MonitorElement*> h_efficiencyNonIsoTauET_EB_pass_;
0207   std::map<double, MonitorElement*> h_efficiencyNonIsoTauET_EE_pass_;
0208   std::map<double, MonitorElement*> h_efficiencyNonIsoTauET_EB_EE_pass_;
0209 
0210   // we could drop the map here, but L1TEfficiency_Harvesting expects
0211   // identical names except for the suffix
0212   std::map<double, MonitorElement*> h_efficiencyIsoTauET_EB_total_;
0213   std::map<double, MonitorElement*> h_efficiencyIsoTauET_EE_total_;
0214   std::map<double, MonitorElement*> h_efficiencyIsoTauET_EB_EE_total_;
0215 
0216   std::map<double, MonitorElement*> h_efficiencyNonIsoTauET_EB_total_;
0217   std::map<double, MonitorElement*> h_efficiencyNonIsoTauET_EE_total_;
0218   std::map<double, MonitorElement*> h_efficiencyNonIsoTauET_EB_EE_total_;
0219 };
0220 
0221 #endif