CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DQMOffline/Trigger/interface/EgHLTOffHelper.h

Go to the documentation of this file.
00001 #ifndef DQMOFFLINE_TRIGGER_EGHLTOFFHELPER
00002 #define DQMOFFLINE_TRIGGER_EGHLTOFFHELPER
00003 
00004 //class: EgHLTOffHelper (Egamma HLT offline helper)
00005 //
00006 //author: Sam Harper (July 2008)
00007 //
00008 //
00009 //aim: to hide temporary place holder code away from the rest of the system
00010 //
00011 //implimentation: currently no isolation producers or electron selection cut meets my needs
00012 //                while I would like to use a central tool, for now I'm cludging my own as
00013 //                placeholders
00014 
00015 
00016 #include "DataFormats/Common/interface/Handle.h"
00017 #include "DataFormats/Common/interface/ValueMap.h"
00018 #include "DataFormats/Common/interface/TriggerResults.h"
00019 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00020 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00021 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00022 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00023 
00024 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00025 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00026 #include "DataFormats/JetReco/interface/CaloJet.h"
00027 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00028 #include "DataFormats/CaloTowers/interface/CaloTower.h"
00029 #include "DataFormats/CaloTowers/interface/CaloTowerFwd.h"
00030 #include "DataFormats/VertexReco/interface/Vertex.h"
00031 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00032 
00033 #include "DQMOffline/Trigger/interface/EgHLTOffEvt.h"
00034 #include "DQMOffline/Trigger/interface/EgHLTOffEle.h"
00035 #include "DQMOffline/Trigger/interface/EgHLTOffPho.h"
00036 #include "DQMOffline/Trigger/interface/EgHLTOffEgSel.h"
00037 #include "DQMOffline/Trigger/interface/EgHLTTrigCodes.h"
00038 
00039 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00040 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
00041 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00042 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00043 
00044 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00045 #include "MagneticField/Engine/interface/MagneticField.h"
00046 
00047 #include "FWCore/Utilities/interface/InputTag.h"
00048 #include "FWCore/Framework/interface/Event.h"
00049 #include "FWCore/Framework/interface/ESHandle.h"
00050 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00051 
00052 class EgammaHLTTrackIsolation;
00053 class HLTConfigProvider;
00054 class EcalSeverityLevelAlgo;
00055 
00056 namespace egHLT {
00057 
00058   class OffHelper {
00059 
00060   private:
00061     OffEgSel eleLooseCuts_; //loose selection cuts (loose has no relation to other 'loose' cuts)
00062     OffEgSel eleCuts_; //normal selection cuts
00063     OffEgSel phoLooseCuts_; //loose selection cuts (loose has no relation to other 'loose' cuts)
00064     OffEgSel phoCuts_; //normal selection cuts
00065     
00066     std::vector<std::pair<TrigCodes::TrigBitSet,OffEgSel> > trigCuts_;//non sorted vector (for now)
00067     
00068     
00069     edm::InputTag ecalRecHitsEBTag_;
00070     edm::InputTag ecalRecHitsEETag_;
00071     edm::InputTag caloJetsTag_;
00072     edm::InputTag isolTrkTag_;
00073     edm::InputTag hbheHitsTag_;
00074     edm::InputTag hfHitsTag_;
00075     edm::InputTag triggerSummaryLabel_;
00076     edm::InputTag electronsTag_;
00077     edm::InputTag photonsTag_;
00078     edm::InputTag beamSpotTag_;
00079     edm::InputTag caloTowersTag_;
00080     edm::InputTag trigResultsTag_;
00081     edm::InputTag vertexTag_;
00082 
00083     edm::ESHandle<CaloGeometry> caloGeom_;
00084     edm::ESHandle<CaloTopology> caloTopology_;
00085     edm::ESHandle<MagneticField> magField_;
00086     edm::ESHandle<EcalSeverityLevelAlgo> ecalSeverityLevel_;
00087 
00088     edm::Handle<EcalRecHitCollection> ebRecHits_;
00089     edm::Handle<EcalRecHitCollection> eeRecHits_; 
00090     edm::Handle<HFRecHitCollection> hfHits_;
00091     edm::Handle<HBHERecHitCollection> hbheHits_;
00092     edm::Handle<reco::TrackCollection> isolTrks_;
00093 
00094     edm::Handle<trigger::TriggerEvent> trigEvt_;
00095     edm::Handle<reco::PhotonCollection> recoPhos_;
00096     edm::Handle<reco::GsfElectronCollection> recoEles_;
00097     edm::Handle<std::vector<reco::CaloJet> > recoJets_;
00098     
00099     edm::Handle<reco::BeamSpot> beamSpot_;
00100     edm::Handle<CaloTowerCollection> caloTowers_;
00101    
00102     edm::Handle<edm::TriggerResults> trigResults_;
00103 
00104     edm::Handle<reco::VertexCollection> recoVertices_;
00105     
00106  
00107 
00108     std::string hltTag_;
00109     std::vector<std::string> hltFiltersUsed_;
00110     std::vector<std::pair<std::string,int> > hltFiltersUsedWithNrCandsCut_; //stores the filter name + number of candidates required to pass that filter for it to accept
00111     std::vector<std::pair<std::string,std::string> > l1PreAndSeedFilters_; //filter names of a l1 prescaler and the corresponding l1 seed filter
00112     std::vector<std::string> l1PreScaledPaths_;//l1 pre-scaled path names
00113     std::vector<std::string> l1PreScaledFilters_;//l1 pre scale filters
00114 
00115     //allow us to recompute e/gamma HLT isolations (note we also have em and hcal but they have to be declared for every event)
00116     //which is awkward and I havent thought of a good way around it yet
00117     EgammaHLTTrackIsolation* hltEleTrkIsolAlgo_;
00118     EgammaHLTTrackIsolation* hltPhoTrkIsolAlgo_;
00119 
00120     //our hlt isolation parameters...
00121     //ecal
00122     double hltEMIsolOuterCone_;
00123     double hltEMIsolInnerConeEB_;
00124     double hltEMIsolEtaSliceEB_;
00125     double hltEMIsolEtMinEB_;
00126     double hltEMIsolEMinEB_;
00127     double hltEMIsolInnerConeEE_;
00128     double hltEMIsolEtaSliceEE_;
00129     double hltEMIsolEtMinEE_;
00130     double hltEMIsolEMinEE_;
00131     //tracker
00132     double hltPhoTrkIsolPtMin_;
00133     double hltPhoTrkIsolOuterCone_;
00134     double hltPhoTrkIsolInnerCone_;
00135     double hltPhoTrkIsolZSpan_;
00136     double hltPhoTrkIsolRSpan_;
00137     bool hltPhoTrkIsolCountTrks_;
00138     double hltEleTrkIsolPtMin_;
00139     double hltEleTrkIsolOuterCone_;
00140     double hltEleTrkIsolInnerCone_;
00141     double hltEleTrkIsolZSpan_;
00142     double hltEleTrkIsolRSpan_;
00143     //hcal
00144     double hltHadIsolOuterCone_;
00145     double hltHadIsolInnerCone_;
00146     double hltHadIsolEtMin_;
00147     int hltHadIsolDepth_;
00148     //flags to disable calculations if same as reco (saves time)
00149     bool calHLTHcalIsol_;
00150     bool calHLTEmIsol_;
00151     bool calHLTEleTrkIsol_;
00152     bool calHLTPhoTrkIsol_;
00153     
00154     
00155     std::vector<edm::ParameterSet> trigCutParams_; //probably the least bad option
00156 
00157   private: //disabling copy / assignment
00158     OffHelper& operator=(const OffHelper& rhs){return *this;}
00159     OffHelper(const OffHelper& rhs){}
00160     
00161   public:
00162     OffHelper():eleLooseCuts_(),eleCuts_(),phoLooseCuts_(),phoCuts_(),hltEleTrkIsolAlgo_(NULL),hltPhoTrkIsolAlgo_(NULL){}
00163     ~OffHelper();
00164     
00165     void setup(const edm::ParameterSet& conf);
00166     void setupTriggers(const HLTConfigProvider& config,const std::vector<std::string>& hltFiltersUsed);
00167 
00168     //int is the error code, 0 = no error
00169     //it should never throw, print to screen or crash, this is the only error reporting it does
00170     int makeOffEvt(const edm::Event& edmEvent,const edm::EventSetup& setup,egHLT::OffEvt& offEvent);
00171     
00172     
00173     int getHandles(const edm::Event& event,const edm::EventSetup& setup);
00174     int fillOffEleVec(std::vector<OffEle>& offEles);
00175     int fillOffPhoVec(std::vector<OffPho>& offPhos);
00176     int setTrigInfo(const edm::Event & edmEvent, egHLT::OffEvt& offEvent);
00177 
00178     void fillIsolData(const reco::GsfElectron& ele,OffEle::IsolData& isolData);
00179     void fillClusShapeData(const reco::GsfElectron& ele,OffEle::ClusShapeData& clusShapeData);
00180     void fillHLTData(const reco::GsfElectron& ele,OffEle::HLTData& hltData);
00181     
00182     void fillIsolData(const reco::Photon& pho,OffPho::IsolData& isolData);
00183     void fillClusShapeData(const reco::Photon& pho,OffPho::ClusShapeData& clusShapeData);
00184 
00185     //tempory debugging functions
00186     const trigger::TriggerEvent* trigEvt()const{return trigEvt_.product();}
00187     const std::vector<std::pair<TrigCodes::TrigBitSet,OffEgSel> >& trigCuts()const{return trigCuts_;}
00188     
00189     
00190     template<class T> static bool getHandle(const edm::Event& event,const edm::InputTag& tag,edm::Handle<T>& handle);
00191     
00192   };
00193   
00194 
00195   template<class T> bool OffHelper::getHandle(const edm::Event& event,const edm::InputTag& tag,edm::Handle<T>& handle)
00196   {
00197   
00198     bool success=event.getByLabel(tag,handle);
00199     return success &&  handle.product();
00200     
00201 
00202   }
00203 }
00204 
00205 #endif