Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:33

0001 #ifndef L1TEGammaOffline_H
0002 #define L1TEGammaOffline_H
0003 
0004 //Framework
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/Utilities/interface/InputTag.h"
0007 #include "FWCore/ServiceRegistry/interface/Service.h"
0008 
0009 //event
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0013 
0014 //DQM
0015 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0016 #include "DQMServices/Core/interface/DQMStore.h"
0017 #include "DQMOffline/L1Trigger/interface/HistDefinition.h"
0018 
0019 //Candidate handling
0020 #include "DataFormats/Candidate/interface/Candidate.h"
0021 
0022 // Electron & photon collections
0023 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0024 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0025 
0026 // Vertex utilities
0027 #include "DataFormats/VertexReco/interface/Vertex.h"
0028 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0029 
0030 // Trigger
0031 #include "DataFormats/Common/interface/TriggerResults.h"
0032 #include "DataFormats/HLTReco/interface/TriggerObject.h"
0033 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0034 
0035 // stage2 collections:
0036 #include "DataFormats/L1Trigger/interface/EGamma.h"
0037 
0038 class L1TEGammaOffline : public DQMOneEDAnalyzer<> {
0039 public:
0040   L1TEGammaOffline(const edm::ParameterSet& ps);
0041   ~L1TEGammaOffline() override;
0042 
0043   enum PlotConfig { nVertex, ETvsET, PHIvsPHI };
0044 
0045   static const std::map<std::string, unsigned int> PlotConfigNames;
0046 
0047 protected:
0048   void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
0049   void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
0050   void analyze(edm::Event const& e, edm::EventSetup const& eSetup) override;
0051   void dqmEndRun(edm::Run const& run, edm::EventSetup const& eSetup) override;
0052 
0053 private:
0054   bool passesLooseEleId(reco::GsfElectron const& electron) const;
0055   bool passesMediumEleId(reco::GsfElectron const& electron) const;
0056   void bookElectronHistos(DQMStore::IBooker&);
0057   void bookPhotonHistos(DQMStore::IBooker&);
0058 
0059   //other functions
0060   double Distance(const reco::Candidate& c1, const reco::Candidate& c2);
0061   double DistancePhi(const reco::Candidate& c1, const reco::Candidate& c2);
0062   double calcDeltaPhi(double phi1, double phi2);
0063 
0064   void fillElectrons(edm::Event const& e, const unsigned int nVertex);
0065   void fillPhotons(edm::Event const& e, const unsigned int nVertex);
0066   bool findTagAndProbePair(edm::Handle<reco::GsfElectronCollection> const& electrons);
0067   bool matchesAnHLTObject(double eta, double phi) const;
0068 
0069   void normalise2DHistogramsToBinArea();
0070 
0071   math::XYZPoint PVPoint_;
0072 
0073   //variables from config file
0074   edm::EDGetTokenT<reco::GsfElectronCollection> theGsfElectronCollection_;
0075   edm::EDGetTokenT<std::vector<reco::Photon> > thePhotonCollection_;
0076   edm::EDGetTokenT<reco::VertexCollection> thePVCollection_;
0077   edm::EDGetTokenT<reco::BeamSpot> theBSCollection_;
0078   edm::EDGetTokenT<trigger::TriggerEvent> triggerInputTag_;
0079   edm::EDGetTokenT<edm::TriggerResults> triggerResultsInputTag_;
0080   std::string triggerProcess_;
0081   std::vector<std::string> triggerNames_;
0082   std::string histFolder_;
0083   std::string efficiencyFolder_;
0084 
0085   edm::EDGetTokenT<l1t::EGammaBxCollection> stage2CaloLayer2EGammaToken_;
0086 
0087   std::vector<double> electronEfficiencyThresholds_;
0088   std::vector<double> electronEfficiencyBins_;
0089   double probeToL1Offset_;
0090   std::vector<double> deepInspectionElectronThresholds_;
0091 
0092   std::vector<double> photonEfficiencyThresholds_;
0093   std::vector<double> photonEfficiencyBins_;
0094 
0095   double maxDeltaRForL1Matching_;
0096   double maxDeltaRForHLTMatching_;
0097   double recoToL1TThresholdFactor_;
0098 
0099   reco::GsfElectron tagElectron_;
0100   reco::GsfElectron probeElectron_;
0101   double tagAndProbleInvariantMass_;
0102 
0103   HLTConfigProvider hltConfig_;
0104   std::vector<unsigned int> triggerIndices_;
0105   edm::TriggerResults triggerResults_;
0106   trigger::TriggerEvent triggerEvent_;
0107   dqmoffline::l1t::HistDefinitions histDefinitions_;
0108 
0109   // TODO: add turn-on cuts (vectors of doubles)
0110   // Histograms
0111   MonitorElement* h_nVertex_;
0112   MonitorElement* h_tagAndProbeMass_;
0113 
0114   // electron reco vs L1
0115   MonitorElement* h_L1EGammaETvsElectronET_EB_;
0116   MonitorElement* h_L1EGammaETvsElectronET_EE_;
0117   MonitorElement* h_L1EGammaETvsElectronET_EB_EE_;
0118 
0119   MonitorElement* h_L1EGammaPhivsElectronPhi_EB_;
0120   MonitorElement* h_L1EGammaPhivsElectronPhi_EE_;
0121   MonitorElement* h_L1EGammaPhivsElectronPhi_EB_EE_;
0122 
0123   MonitorElement* h_L1EGammaEtavsElectronEta_;
0124 
0125   // electron resolutions
0126   MonitorElement* h_resolutionElectronET_EB_;
0127   MonitorElement* h_resolutionElectronET_EE_;
0128   MonitorElement* h_resolutionElectronET_EB_EE_;
0129 
0130   MonitorElement* h_resolutionElectronPhi_EB_;
0131   MonitorElement* h_resolutionElectronPhi_EE_;
0132   MonitorElement* h_resolutionElectronPhi_EB_EE_;
0133 
0134   MonitorElement* h_resolutionElectronEta_;
0135 
0136   // electron turn-ons
0137   std::map<double, MonitorElement*> h_efficiencyElectronET_EB_pass_;
0138   std::map<double, MonitorElement*> h_efficiencyElectronET_EE_pass_;
0139   std::map<double, MonitorElement*> h_efficiencyElectronET_EB_EE_pass_;
0140   std::map<double, MonitorElement*> h_efficiencyElectronPhi_vs_Eta_pass_;
0141   // for deep inspection only
0142   std::map<double, MonitorElement*> h_efficiencyElectronEta_pass_;
0143   std::map<double, MonitorElement*> h_efficiencyElectronPhi_pass_;
0144   std::map<double, MonitorElement*> h_efficiencyElectronNVertex_pass_;
0145 
0146   // we could drop the map here, but L1TEfficiency_Harvesting expects
0147   // identical names except for the suffix
0148   std::map<double, MonitorElement*> h_efficiencyElectronET_EB_total_;
0149   std::map<double, MonitorElement*> h_efficiencyElectronET_EE_total_;
0150   std::map<double, MonitorElement*> h_efficiencyElectronET_EB_EE_total_;
0151   std::map<double, MonitorElement*> h_efficiencyElectronPhi_vs_Eta_total_;
0152   // for deep inspection only
0153   std::map<double, MonitorElement*> h_efficiencyElectronEta_total_;
0154   std::map<double, MonitorElement*> h_efficiencyElectronPhi_total_;
0155   std::map<double, MonitorElement*> h_efficiencyElectronNVertex_total_;
0156 
0157   // photons
0158   MonitorElement* h_L1EGammaETvsPhotonET_EB_;
0159   MonitorElement* h_L1EGammaETvsPhotonET_EE_;
0160   MonitorElement* h_L1EGammaETvsPhotonET_EB_EE_;
0161 
0162   MonitorElement* h_L1EGammaPhivsPhotonPhi_EB_;
0163   MonitorElement* h_L1EGammaPhivsPhotonPhi_EE_;
0164   MonitorElement* h_L1EGammaPhivsPhotonPhi_EB_EE_;
0165 
0166   MonitorElement* h_L1EGammaEtavsPhotonEta_;
0167 
0168   // electron resolutions
0169   MonitorElement* h_resolutionPhotonET_EB_;
0170   MonitorElement* h_resolutionPhotonET_EE_;
0171   MonitorElement* h_resolutionPhotonET_EB_EE_;
0172 
0173   MonitorElement* h_resolutionPhotonPhi_EB_;
0174   MonitorElement* h_resolutionPhotonPhi_EE_;
0175   MonitorElement* h_resolutionPhotonPhi_EB_EE_;
0176 
0177   MonitorElement* h_resolutionPhotonEta_;
0178 
0179   // photon turn-ons
0180   std::map<double, MonitorElement*> h_efficiencyPhotonET_EB_pass_;
0181   std::map<double, MonitorElement*> h_efficiencyPhotonET_EE_pass_;
0182   std::map<double, MonitorElement*> h_efficiencyPhotonET_EB_EE_pass_;
0183 
0184   // we could drop the map here, but L1TEfficiency_Harvesting expects
0185   // identical names except for the suffix
0186   std::map<double, MonitorElement*> h_efficiencyPhotonET_EB_total_;
0187   std::map<double, MonitorElement*> h_efficiencyPhotonET_EE_total_;
0188   std::map<double, MonitorElement*> h_efficiencyPhotonET_EB_EE_total_;
0189 };
0190 
0191 #endif