CMS 3D CMS Logo

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