File indexing completed on 2024-04-06 12:09:50
0001 #ifndef DQMOFFLINE_TRIGGER_EGHLTOFFHELPER
0002 #define DQMOFFLINE_TRIGGER_EGHLTOFFHELPER
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "DataFormats/Common/interface/Handle.h"
0016 #include "DataFormats/Common/interface/ValueMap.h"
0017 #include "DataFormats/Common/interface/TriggerResults.h"
0018 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0019 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
0020 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0021 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
0022
0023 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0024 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0025 #include "DataFormats/JetReco/interface/CaloJet.h"
0026 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
0027 #include "DataFormats/CaloTowers/interface/CaloTower.h"
0028 #include "DataFormats/CaloTowers/interface/CaloTowerDefs.h"
0029 #include "DataFormats/VertexReco/interface/Vertex.h"
0030 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0031
0032 #include "DQMOffline/Trigger/interface/EgHLTOffEvt.h"
0033 #include "DQMOffline/Trigger/interface/EgHLTOffEle.h"
0034 #include "DQMOffline/Trigger/interface/EgHLTOffPho.h"
0035 #include "DQMOffline/Trigger/interface/EgHLTOffEgSel.h"
0036 #include "DQMOffline/Trigger/interface/EgHLTTrigCodes.h"
0037
0038 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0039 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0040 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0041 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0042
0043 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0044 #include "MagneticField/Engine/interface/MagneticField.h"
0045
0046 #include "FWCore/Utilities/interface/InputTag.h"
0047 #include "FWCore/Framework/interface/Event.h"
0048 #include "FWCore/Framework/interface/ESHandle.h"
0049 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0050 #include "FWCore/Framework/interface/ConsumesCollector.h"
0051
0052 #include "CondFormats/EcalObjects/interface/EcalPFRecHitThresholds.h"
0053 #include "CondFormats/DataRecord/interface/EcalPFRecHitThresholdsRcd.h"
0054
0055 class EgammaHLTTrackIsolation;
0056 class HLTConfigProvider;
0057 class EcalSeverityLevelAlgo;
0058 class EcalSeverityLevelAlgoRcd;
0059
0060 namespace egHLT {
0061
0062 class OffHelper {
0063 private:
0064 OffEgSel eleLooseCuts_;
0065 OffEgSel eleCuts_;
0066 OffEgSel phoLooseCuts_;
0067 OffEgSel phoCuts_;
0068
0069 std::vector<std::pair<TrigCodes::TrigBitSet, OffEgSel> > trigCuts_;
0070
0071 edm::EDGetTokenT<EcalRecHitCollection> ecalRecHitsEBToken;
0072 edm::EDGetTokenT<EcalRecHitCollection> ecalRecHitsEEToken;
0073 edm::EDGetTokenT<reco::CaloJetCollection> caloJetsToken;
0074 edm::EDGetTokenT<reco::TrackCollection> isolTrkToken;
0075 edm::EDGetTokenT<HBHERecHitCollection> hbheHitsToken;
0076 edm::EDGetTokenT<HFRecHitCollection> hfHitsToken;
0077 edm::EDGetTokenT<trigger::TriggerEvent> triggerSummaryToken;
0078 edm::EDGetTokenT<reco::GsfElectronCollection> electronsToken;
0079 edm::EDGetTokenT<reco::PhotonCollection> photonsToken;
0080 edm::EDGetTokenT<reco::BeamSpot> beamSpotToken;
0081 edm::EDGetTokenT<CaloTowerCollection> caloTowersToken;
0082 edm::EDGetTokenT<edm::TriggerResults> trigResultsToken;
0083 edm::EDGetTokenT<reco::VertexCollection> vertexToken;
0084
0085 edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
0086 edm::ESGetToken<CaloTopology, CaloTopologyRecord> caloTopoToken_;
0087 edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
0088 edm::ESGetToken<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd> ecalSeverityToken_;
0089
0090 edm::ESHandle<CaloGeometry> caloGeom_;
0091 edm::ESHandle<CaloTopology> caloTopology_;
0092 edm::ESHandle<MagneticField> magField_;
0093 edm::ESHandle<EcalSeverityLevelAlgo> ecalSeverityLevel_;
0094
0095 edm::Handle<EcalRecHitCollection> ebRecHits_;
0096 edm::Handle<EcalRecHitCollection> eeRecHits_;
0097 edm::Handle<HFRecHitCollection> hfHits_;
0098 edm::Handle<HBHERecHitCollection> hbheHits_;
0099 edm::Handle<reco::TrackCollection> isolTrks_;
0100
0101 edm::Handle<trigger::TriggerEvent> trigEvt_;
0102 edm::Handle<reco::PhotonCollection> recoPhos_;
0103 edm::Handle<reco::GsfElectronCollection> recoEles_;
0104 edm::Handle<std::vector<reco::CaloJet> > recoJets_;
0105
0106 edm::Handle<reco::BeamSpot> beamSpot_;
0107 edm::Handle<CaloTowerCollection> caloTowers_;
0108
0109 edm::Handle<edm::TriggerResults> trigResults_;
0110
0111 edm::Handle<reco::VertexCollection> recoVertices_;
0112
0113 std::string hltTag_;
0114 std::vector<std::string> hltFiltersUsed_;
0115 std::vector<std::pair<std::string, int> >
0116 hltFiltersUsedWithNrCandsCut_;
0117 std::vector<std::pair<std::string, std::string> >
0118 l1PreAndSeedFilters_;
0119 std::vector<std::string> l1PreScaledPaths_;
0120 std::vector<std::string> l1PreScaledFilters_;
0121
0122
0123
0124 EgammaHLTTrackIsolation* hltEleTrkIsolAlgo_;
0125 EgammaHLTTrackIsolation* hltPhoTrkIsolAlgo_;
0126
0127
0128
0129 double hltEMIsolOuterCone_;
0130 double hltEMIsolInnerConeEB_;
0131 double hltEMIsolEtaSliceEB_;
0132 double hltEMIsolEtMinEB_;
0133 double hltEMIsolEMinEB_;
0134 double hltEMIsolInnerConeEE_;
0135 double hltEMIsolEtaSliceEE_;
0136 double hltEMIsolEtMinEE_;
0137 double hltEMIsolEMinEE_;
0138
0139 double hltPhoTrkIsolPtMin_;
0140 double hltPhoTrkIsolOuterCone_;
0141 double hltPhoTrkIsolInnerCone_;
0142 double hltPhoTrkIsolZSpan_;
0143 double hltPhoTrkIsolRSpan_;
0144 bool hltPhoTrkIsolCountTrks_;
0145 double hltEleTrkIsolPtMin_;
0146 double hltEleTrkIsolOuterCone_;
0147 double hltEleTrkIsolInnerCone_;
0148 double hltEleTrkIsolZSpan_;
0149 double hltEleTrkIsolRSpan_;
0150
0151 double hltHadIsolOuterCone_;
0152 double hltHadIsolInnerCone_;
0153 double hltHadIsolEtMin_;
0154 int hltHadIsolDepth_;
0155
0156 bool calHLTHcalIsol_;
0157 bool calHLTEmIsol_;
0158 bool calHLTEleTrkIsol_;
0159 bool calHLTPhoTrkIsol_;
0160
0161 std::vector<edm::ParameterSet> trigCutParams_;
0162
0163 public:
0164 OffHelper()
0165 : eleLooseCuts_(),
0166 eleCuts_(),
0167 phoLooseCuts_(),
0168 phoCuts_(),
0169 hltEleTrkIsolAlgo_(nullptr),
0170 hltPhoTrkIsolAlgo_(nullptr) {}
0171 OffHelper& operator=(const OffHelper&) = delete;
0172 OffHelper(const OffHelper&) = delete;
0173 ~OffHelper();
0174
0175 void setup(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC);
0176 void setupTriggers(const HLTConfigProvider& config,
0177 const std::vector<std::string>& hltFiltersUsed,
0178 const TrigCodes& trigCodes);
0179
0180
0181
0182 int makeOffEvt(const edm::Event& edmEvent,
0183 const edm::EventSetup& setup,
0184 egHLT::OffEvt& offEvent,
0185 const TrigCodes& trigCodes);
0186
0187 int getHandles(const edm::Event& event, const edm::EventSetup& setup);
0188 int fillOffEleVec(std::vector<OffEle>& offEles);
0189 int fillOffPhoVec(std::vector<OffPho>& offPhos);
0190 int setTrigInfo(const edm::Event& edmEvent, egHLT::OffEvt& offEvent, const TrigCodes& trigCodes);
0191
0192 void fillIsolData(const reco::GsfElectron& ele, OffEle::IsolData& isolData);
0193 void fillClusShapeData(const reco::GsfElectron& ele, OffEle::ClusShapeData& clusShapeData);
0194 void fillHLTData(const reco::GsfElectron& ele, OffEle::HLTData& hltData);
0195
0196 void fillIsolData(const reco::Photon& pho, OffPho::IsolData& isolData);
0197 void fillClusShapeData(const reco::Photon& pho, OffPho::ClusShapeData& clusShapeData);
0198 void fillHLTDataPho(const reco::Photon& pho, OffPho::HLTData& hltData);
0199
0200
0201 const trigger::TriggerEvent* trigEvt() const { return trigEvt_.product(); }
0202 const std::vector<std::pair<TrigCodes::TrigBitSet, OffEgSel> >& trigCuts() const { return trigCuts_; }
0203
0204 template <class T>
0205 static bool getHandle(const edm::Event& event, const edm::EDGetTokenT<T>& token, edm::Handle<T>& handle);
0206
0207 const EcalPFRecHitThresholds* thresholds = nullptr;
0208 };
0209
0210 template <class T>
0211 bool OffHelper::getHandle(const edm::Event& event, const edm::EDGetTokenT<T>& token, edm::Handle<T>& handle) {
0212 bool success = event.getByToken(token, handle);
0213 return success && handle.product();
0214 }
0215 }
0216
0217 #endif