Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-04 02:02:32

0001 #ifndef DQMOFFLINE_TRIGGER_EGHLTOFFHELPER
0002 #define DQMOFFLINE_TRIGGER_EGHLTOFFHELPER
0003 
0004 //class: EgHLTOffHelper (Egamma HLT offline helper)
0005 //
0006 //author: Sam Harper (July 2008)
0007 //
0008 //
0009 //aim: to hide temporary place holder code away from the rest of the system
0010 //
0011 //implimentation: currently no isolation producers or electron selection cut meets my needs
0012 //                while I would like to use a central tool, for now I'm cludging my own as
0013 //                placeholders
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 class EgammaHLTTrackIsolation;
0053 class HLTConfigProvider;
0054 class EcalSeverityLevelAlgo;
0055 class EcalSeverityLevelAlgoRcd;
0056 
0057 namespace egHLT {
0058 
0059   class OffHelper {
0060   private:
0061     OffEgSel eleLooseCuts_;  //loose selection cuts (loose has no relation to other 'loose' cuts)
0062     OffEgSel eleCuts_;       //normal selection cuts
0063     OffEgSel phoLooseCuts_;  //loose selection cuts (loose has no relation to other 'loose' cuts)
0064     OffEgSel phoCuts_;       //normal selection cuts
0065 
0066     std::vector<std::pair<TrigCodes::TrigBitSet, OffEgSel> > trigCuts_;  //non sorted vector (for now)
0067 
0068     edm::EDGetTokenT<EcalRecHitCollection> ecalRecHitsEBToken;
0069     edm::EDGetTokenT<EcalRecHitCollection> ecalRecHitsEEToken;
0070     edm::EDGetTokenT<reco::CaloJetCollection> caloJetsToken;
0071     edm::EDGetTokenT<reco::TrackCollection> isolTrkToken;
0072     edm::EDGetTokenT<HBHERecHitCollection> hbheHitsToken;
0073     edm::EDGetTokenT<HFRecHitCollection> hfHitsToken;
0074     edm::EDGetTokenT<trigger::TriggerEvent> triggerSummaryToken;
0075     edm::EDGetTokenT<reco::GsfElectronCollection> electronsToken;
0076     edm::EDGetTokenT<reco::PhotonCollection> photonsToken;
0077     edm::EDGetTokenT<reco::BeamSpot> beamSpotToken;
0078     edm::EDGetTokenT<CaloTowerCollection> caloTowersToken;
0079     edm::EDGetTokenT<edm::TriggerResults> trigResultsToken;
0080     edm::EDGetTokenT<reco::VertexCollection> vertexToken;
0081 
0082     edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeomToken_;
0083     edm::ESGetToken<CaloTopology, CaloTopologyRecord> caloTopoToken_;
0084     edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magFieldToken_;
0085     edm::ESGetToken<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd> ecalSeverityToken_;
0086 
0087     edm::ESHandle<CaloGeometry> caloGeom_;
0088     edm::ESHandle<CaloTopology> caloTopology_;
0089     edm::ESHandle<MagneticField> magField_;
0090     edm::ESHandle<EcalSeverityLevelAlgo> ecalSeverityLevel_;
0091 
0092     edm::Handle<EcalRecHitCollection> ebRecHits_;
0093     edm::Handle<EcalRecHitCollection> eeRecHits_;
0094     edm::Handle<HFRecHitCollection> hfHits_;
0095     edm::Handle<HBHERecHitCollection> hbheHits_;
0096     edm::Handle<reco::TrackCollection> isolTrks_;
0097 
0098     edm::Handle<trigger::TriggerEvent> trigEvt_;
0099     edm::Handle<reco::PhotonCollection> recoPhos_;
0100     edm::Handle<reco::GsfElectronCollection> recoEles_;
0101     edm::Handle<std::vector<reco::CaloJet> > recoJets_;
0102 
0103     edm::Handle<reco::BeamSpot> beamSpot_;
0104     edm::Handle<CaloTowerCollection> caloTowers_;
0105 
0106     edm::Handle<edm::TriggerResults> trigResults_;
0107 
0108     edm::Handle<reco::VertexCollection> recoVertices_;
0109 
0110     std::string hltTag_;
0111     std::vector<std::string> hltFiltersUsed_;
0112     std::vector<std::pair<std::string, int> >
0113         hltFiltersUsedWithNrCandsCut_;  //stores the filter name + number of candidates required to pass that filter for it to accept
0114     std::vector<std::pair<std::string, std::string> >
0115         l1PreAndSeedFilters_;                      //filter names of a l1 prescaler and the corresponding l1 seed filter
0116     std::vector<std::string> l1PreScaledPaths_;    //l1 pre-scaled path names
0117     std::vector<std::string> l1PreScaledFilters_;  //l1 pre scale filters
0118 
0119     //allow us to recompute e/gamma HLT isolations (note we also have em and hcal but they have to be declared for every event)
0120     //which is awkward and I havent thought of a good way around it yet
0121     EgammaHLTTrackIsolation* hltEleTrkIsolAlgo_;
0122     EgammaHLTTrackIsolation* hltPhoTrkIsolAlgo_;
0123 
0124     //our hlt isolation parameters...
0125     //ecal
0126     double hltEMIsolOuterCone_;
0127     double hltEMIsolInnerConeEB_;
0128     double hltEMIsolEtaSliceEB_;
0129     double hltEMIsolEtMinEB_;
0130     double hltEMIsolEMinEB_;
0131     double hltEMIsolInnerConeEE_;
0132     double hltEMIsolEtaSliceEE_;
0133     double hltEMIsolEtMinEE_;
0134     double hltEMIsolEMinEE_;
0135     //tracker
0136     double hltPhoTrkIsolPtMin_;
0137     double hltPhoTrkIsolOuterCone_;
0138     double hltPhoTrkIsolInnerCone_;
0139     double hltPhoTrkIsolZSpan_;
0140     double hltPhoTrkIsolRSpan_;
0141     bool hltPhoTrkIsolCountTrks_;
0142     double hltEleTrkIsolPtMin_;
0143     double hltEleTrkIsolOuterCone_;
0144     double hltEleTrkIsolInnerCone_;
0145     double hltEleTrkIsolZSpan_;
0146     double hltEleTrkIsolRSpan_;
0147     //hcal
0148     double hltHadIsolOuterCone_;
0149     double hltHadIsolInnerCone_;
0150     double hltHadIsolEtMin_;
0151     int hltHadIsolDepth_;
0152     //flags to disable calculations if same as reco (saves time)
0153     bool calHLTHcalIsol_;
0154     bool calHLTEmIsol_;
0155     bool calHLTEleTrkIsol_;
0156     bool calHLTPhoTrkIsol_;
0157 
0158     std::vector<edm::ParameterSet> trigCutParams_;  //probably the least bad option
0159 
0160   public:
0161     OffHelper()
0162         : eleLooseCuts_(),
0163           eleCuts_(),
0164           phoLooseCuts_(),
0165           phoCuts_(),
0166           hltEleTrkIsolAlgo_(nullptr),
0167           hltPhoTrkIsolAlgo_(nullptr) {}
0168     OffHelper& operator=(const OffHelper&) = delete;
0169     OffHelper(const OffHelper&) = delete;
0170     ~OffHelper();
0171 
0172     void setup(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC);
0173     void setupTriggers(const HLTConfigProvider& config,
0174                        const std::vector<std::string>& hltFiltersUsed,
0175                        const TrigCodes& trigCodes);
0176 
0177     //int is the error code, 0 = no error
0178     //it should never throw, print to screen or crash, this is the only error reporting it does
0179     int makeOffEvt(const edm::Event& edmEvent,
0180                    const edm::EventSetup& setup,
0181                    egHLT::OffEvt& offEvent,
0182                    const TrigCodes& trigCodes);
0183 
0184     int getHandles(const edm::Event& event, const edm::EventSetup& setup);
0185     int fillOffEleVec(std::vector<OffEle>& offEles);
0186     int fillOffPhoVec(std::vector<OffPho>& offPhos);
0187     int setTrigInfo(const edm::Event& edmEvent, egHLT::OffEvt& offEvent, const TrigCodes& trigCodes);
0188 
0189     void fillIsolData(const reco::GsfElectron& ele, OffEle::IsolData& isolData);
0190     void fillClusShapeData(const reco::GsfElectron& ele, OffEle::ClusShapeData& clusShapeData);
0191     void fillHLTData(const reco::GsfElectron& ele, OffEle::HLTData& hltData);
0192 
0193     void fillIsolData(const reco::Photon& pho, OffPho::IsolData& isolData);
0194     void fillClusShapeData(const reco::Photon& pho, OffPho::ClusShapeData& clusShapeData);
0195     void fillHLTDataPho(const reco::Photon& pho, OffPho::HLTData& hltData);
0196 
0197     //tempory debugging functions
0198     const trigger::TriggerEvent* trigEvt() const { return trigEvt_.product(); }
0199     const std::vector<std::pair<TrigCodes::TrigBitSet, OffEgSel> >& trigCuts() const { return trigCuts_; }
0200 
0201     template <class T>
0202     static bool getHandle(const edm::Event& event, const edm::EDGetTokenT<T>& token, edm::Handle<T>& handle);
0203   };
0204 
0205   template <class T>
0206   bool OffHelper::getHandle(const edm::Event& event, const edm::EDGetTokenT<T>& token, edm::Handle<T>& handle) {
0207     bool success = event.getByToken(token, handle);
0208     return success && handle.product();
0209   }
0210 }  // namespace egHLT
0211 
0212 #endif