00001 // -*- C++ -*- 00002 // 00003 // Package: MonoPhotonSkimmer 00004 // Class: MonoPhotonSkimmer 00005 // 00013 // 00014 // Original Author: Jie Chen 00015 // Created: Wed Nov 17 14:33:08 CST 2010 00016 // $Id: MonoPhotonSkimmer.cc,v 1.1 2010/12/13 20:32:22 jiechen Exp $ 00017 // 00018 // 00019 00020 00021 // system include files 00022 #include <memory> 00023 00024 // user include files 00025 #include "FWCore/Framework/interface/Frameworkfwd.h" 00026 #include "FWCore/Framework/interface/EDFilter.h" 00027 00028 #include "FWCore/Framework/interface/Event.h" 00029 #include "FWCore/Framework/interface/MakerMacros.h" 00030 00031 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00032 #include "FWCore/Utilities/interface/InputTag.h" 00033 #include "DataFormats/EgammaCandidates/interface/Photon.h" 00034 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h" 00035 #include "DataFormats/Common/interface/View.h" 00036 #include "DataFormats/TrackReco/interface/Track.h" 00037 #include <string> 00038 00039 // 00040 // class declaration 00041 // 00042 00043 class MonoPhotonSkimmer : public edm::EDFilter { 00044 public: 00045 explicit MonoPhotonSkimmer(const edm::ParameterSet&); 00046 ~MonoPhotonSkimmer(); 00047 00048 private: 00049 virtual void beginJob() ; 00050 virtual bool filter(edm::Event&, const edm::EventSetup&); 00051 virtual void endJob() ; 00052 00053 // ----------member data --------------------------- 00054 edm::InputTag _phoTag; 00055 bool _selectEE; //Do you want to select EE photons? 00056 //True enables this. 00057 00058 double _ecalisoOffsetEB; //Photon Preselection has linearized cuts. 00059 double _ecalisoSlopeEB; //slope * photonpt + offset is the isolation 00060 //threshold. This is ECAL EB. 00061 00062 double _hcalisoOffsetEB; //Linearized cut on HCAL towers, EB. 00063 double _hcalisoSlopeEB; 00064 00065 double _hadoveremEB; //Flat selection cut on HadOverEM. 00066 00067 double _minPhoEtEB; //Minimum Photon ET threshold, EB. 00068 00069 double _trackisoOffsetEB;//Linearized cut on track isolation EB 00070 double _trackisoSlopeEB; 00071 00072 double _etawidthEB; //eta width for EB 00073 00074 double _ecalisoOffsetEE; //As above, but separately set for EE. 00075 double _ecalisoSlopeEE; 00076 double _hcalisoOffsetEE; 00077 double _hcalisoSlopeEE; 00078 double _hadoveremEE; 00079 double _minPhoEtEE; 00080 double _trackisoOffsetEE; 00081 double _trackisoSlopeEE; 00082 double _etawidthEE; 00083 }; 00084 00085 // 00086 // constants, enums and typedefs 00087 // 00088 00089 // 00090 // static data member definitions 00091 // 00092 00093 // 00094 // constructors and destructor 00095 // 00096 MonoPhotonSkimmer::MonoPhotonSkimmer(const edm::ParameterSet& iConfig) 00097 { 00098 //now do what ever initialization is needed 00099 _phoTag = iConfig.getParameter<edm::InputTag>("phoTag"); 00100 _selectEE = iConfig.getParameter<bool>("selectEE"); 00101 00102 _ecalisoOffsetEB = iConfig.getParameter<double>("ecalisoOffsetEB"); 00103 _ecalisoSlopeEB = iConfig.getParameter<double>("ecalisoSlopeEB"); 00104 00105 _hcalisoOffsetEB = iConfig.getParameter<double>("hcalisoOffsetEB"); 00106 _hcalisoSlopeEB = iConfig.getParameter<double>("hcalisoSlopeEB"); 00107 00108 _hadoveremEB = iConfig.getParameter<double>("hadoveremEB"); 00109 _minPhoEtEB = iConfig.getParameter<double>("minPhoEtEB"); 00110 00111 00112 _trackisoOffsetEB= iConfig.getParameter<double>("trackIsoOffsetEB"); 00113 _trackisoSlopeEB= iConfig.getParameter<double>("trackIsoSlopeEB"); 00114 _etawidthEB=iConfig.getParameter<double>("etaWidthEB"); 00115 00116 _ecalisoOffsetEE = iConfig.getParameter<double>("ecalisoOffsetEE"); 00117 _ecalisoSlopeEE = iConfig.getParameter<double>("ecalisoSlopeEE"); 00118 00119 _hcalisoOffsetEE = iConfig.getParameter<double>("hcalisoOffsetEE"); 00120 _hcalisoSlopeEE = iConfig.getParameter<double>("hcalisoSlopeEE"); 00121 00122 _hadoveremEE = iConfig.getParameter<double>("hadoveremEE"); 00123 _minPhoEtEE = iConfig.getParameter<double>("minPhoEtEE"); 00124 00125 00126 _trackisoOffsetEE= iConfig.getParameter<double>("trackIsoOffsetEE"); 00127 _trackisoSlopeEE= iConfig.getParameter<double>("trackIsoSlopeEE"); 00128 00129 _etawidthEE= iConfig.getParameter<double>("etaWidthEE"); 00130 00131 } 00132 00133 00134 MonoPhotonSkimmer::~MonoPhotonSkimmer() 00135 { 00136 00137 // do anything here that needs to be done at desctruction time 00138 // (e.g. close files, deallocate resources etc.) 00139 00140 } 00141 00142 00143 // 00144 // member functions 00145 // 00146 00147 // ------------ method called on each new Event ------------ 00148 bool 00149 MonoPhotonSkimmer::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) 00150 { 00151 using namespace edm; 00152 Handle<reco::PhotonCollection> photonColl; 00153 iEvent.getByLabel(_phoTag, photonColl); 00154 const reco::PhotonCollection *photons = photonColl.product(); 00155 //Iterate over photon collection. 00156 // std::vector<reco::Photon> PreselPhotons; 00157 int PreselPhotons=0; 00158 reco::PhotonCollection::const_iterator pho; 00159 for (pho = (*photons).begin(); pho!= (*photons).end(); pho++){ 00160 if (!pho->isEB() && !_selectEE) continue; 00161 00162 double ecalisocut = 0; 00163 double hcalisocut = 0; 00164 double hadoverem = 0; 00165 double minphoet = 0; 00166 double trackiso = 0; 00167 double etawidth = 0; 00168 if (pho->isEB()){ 00169 ecalisocut = _ecalisoOffsetEB + _ecalisoSlopeEB * pho->pt(); 00170 hcalisocut = _hcalisoOffsetEB + _hcalisoSlopeEB * pho->pt(); 00171 hadoverem = _hadoveremEB; 00172 minphoet = _minPhoEtEB; 00173 trackiso = _trackisoOffsetEB + _trackisoSlopeEB * pho->pt(); 00174 etawidth = _etawidthEB; 00175 } 00176 else{ 00177 ecalisocut = _ecalisoOffsetEE + _ecalisoSlopeEE * pho->pt(); 00178 hcalisocut = _hcalisoOffsetEE + _hcalisoSlopeEE * pho->pt(); 00179 hadoverem = _hadoveremEE; 00180 minphoet = _minPhoEtEE; 00181 trackiso = _trackisoOffsetEE + _trackisoSlopeEE * pho->pt(); 00182 etawidth = _etawidthEE; 00183 } 00184 00185 if (pho->ecalRecHitSumEtConeDR04() < ecalisocut 00186 && pho->hcalTowerSumEtConeDR04() < hcalisocut 00187 && pho->hadronicOverEm() < hadoverem 00188 && pho->pt() > minphoet 00189 && pho->trkSumPtHollowConeDR04()<trackiso 00190 && pho->sigmaIetaIeta() <etawidth 00191 ) PreselPhotons++; 00192 00193 }//Loop over Photons 00194 if (PreselPhotons > 0 ) return true; 00195 return false; 00196 } 00197 00198 // ------------ method called once each job just before starting event loop ------------ 00199 void 00200 MonoPhotonSkimmer::beginJob() 00201 { 00202 } 00203 00204 // ------------ method called once each job just after ending the event loop ------------ 00205 void 00206 MonoPhotonSkimmer::endJob() { 00207 } 00208 00209 //define this as a plug-in 00210 DEFINE_FWK_MODULE(MonoPhotonSkimmer);