Go to the documentation of this file.00001 #include "RecoEgamma/EgammaIsolationAlgos/plugins/GamIsoDetIdCollectionProducer.h"
00002
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include "FWCore/Framework/interface/EventSetup.h"
00005 #include "FWCore/Framework/interface/ESHandle.h"
00006
00007 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00008
00009 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00010 #include "RecoCaloTools/Selectors/interface/CaloDualConeSelector.h"
00011 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00012 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00013 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00014 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00015 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00016 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00017 #include "RecoCaloTools/MetaCollections/interface/CaloRecHitMetaCollections.h"
00018 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00019
00020 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00021 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00022
00023 #include "DataFormats/DetId/interface/DetIdCollection.h"
00024
00025 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
00026 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00027
00028 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00029 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
00030
00031 GamIsoDetIdCollectionProducer::GamIsoDetIdCollectionProducer(const edm::ParameterSet& iConfig) :
00032 recHitsLabel_(iConfig.getParameter< edm::InputTag > ("recHitsLabel")),
00033 emObjectLabel_(iConfig.getParameter< edm::InputTag > ("emObjectLabel")),
00034 energyCut_(iConfig.getParameter<double>("energyCut")),
00035 etCut_(iConfig.getParameter<double>("etCut")),
00036 etCandCut_(iConfig.getParameter<double> ("etCandCut")),
00037 outerRadius_(iConfig.getParameter<double>("outerRadius")),
00038 innerRadius_(iConfig.getParameter<double>("innerRadius")),
00039 interestingDetIdCollection_(iConfig.getParameter<std::string>("interestingDetIdCollection")),
00040 severityLevelCut_(iConfig.getParameter<int>("severityLevelCut")),
00041
00042
00043
00044 v_chstatus_(iConfig.getParameter<std::vector<int> >("recHitFlagsToBeExcluded")) {
00045
00046
00047
00048
00049
00050
00051
00052 produces< DetIdCollection > (interestingDetIdCollection_) ;
00053 }
00054
00055 GamIsoDetIdCollectionProducer::~GamIsoDetIdCollectionProducer() {}
00056
00057 void GamIsoDetIdCollectionProducer::beginJob ()
00058 {}
00059
00060
00061 void
00062 GamIsoDetIdCollectionProducer::produce (edm::Event& iEvent,
00063 const edm::EventSetup& iSetup)
00064 {
00065 using namespace edm;
00066 using namespace std;
00067
00068
00069 Handle<reco::PhotonCollection> emObjectH;
00070 iEvent.getByLabel(emObjectLabel_,emObjectH);
00071
00072
00073 Handle<EcalRecHitCollection> recHitsH;
00074 iEvent.getByLabel(recHitsLabel_,recHitsH);
00075 std::auto_ptr<CaloRecHitMetaCollectionV> recHits_(0);
00076 recHits_ = std::auto_ptr<CaloRecHitMetaCollectionV>(new EcalRecHitMetaCollection(*recHitsH));
00077
00078 edm::ESHandle<CaloGeometry> pG;
00079 iSetup.get<CaloGeometryRecord>().get(pG);
00080 const CaloGeometry* caloGeom = pG.product();
00081
00082
00083 edm::ESHandle<EcalChannelStatus> chStatus;
00084 iSetup.get<EcalChannelStatusRcd>().get(chStatus);
00085
00086 edm::ESHandle<EcalSeverityLevelAlgo> sevlv;
00087 iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
00088 const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
00089
00090 CaloDualConeSelector *doubleConeSel_ = 0;
00091 if(recHitsLabel_.instance() == "EcalRecHitsEB")
00092 doubleConeSel_= new CaloDualConeSelector(innerRadius_,outerRadius_, &*pG, DetId::Ecal, EcalBarrel);
00093 else if(recHitsLabel_.instance() == "EcalRecHitsEE")
00094 doubleConeSel_= new CaloDualConeSelector(innerRadius_,outerRadius_, &*pG, DetId::Ecal, EcalEndcap);
00095
00096
00097 std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection() ) ;
00098
00099 reco::PhotonCollection::const_iterator emObj;
00100 if(doubleConeSel_) {
00101 for (emObj = emObjectH->begin(); emObj != emObjectH->end(); emObj++) {
00102
00103 if(emObj->et() < etCandCut_) continue;
00104
00105 GlobalPoint pclu (emObj->caloPosition().x(),emObj->caloPosition().y(),emObj->caloPosition().z());
00106 std::auto_ptr<CaloRecHitMetaCollectionV> chosen = doubleConeSel_->select(pclu,*recHits_);
00107
00108 CaloRecHitMetaCollectionV::const_iterator recIt;
00109 for (recIt = chosen->begin(); recIt!= chosen->end () ; ++recIt) {
00110
00111 if ( fabs(recIt->energy()) < energyCut_) continue;
00112
00113 double et = recIt->energy() *
00114 caloGeom->getPosition(recIt->detid()).perp() /
00115 caloGeom->getPosition(recIt->detid()).mag();
00116
00117 if ( fabs(et) < etCut_) continue;
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 if(recHitsLabel_.instance() == "EcalRecHitsEB" &&
00129 sevLevel->severityLevel(EBDetId(recIt->detid()), *recHitsH)>= severityLevelCut_) continue;
00130
00131
00132
00133
00134
00135
00136
00137
00138 std::vector<int>::const_iterator vit = std::find( v_chstatus_.begin(), v_chstatus_.end(), ((EcalRecHit*)(&*recIt))->recoFlag() );
00139 if ( vit != v_chstatus_.end() ) continue;
00140
00141 if(std::find(detIdCollection->begin(),detIdCollection->end(),recIt->detid()) == detIdCollection->end())
00142 detIdCollection->push_back(recIt->detid());
00143 }
00144
00145 }
00146
00147 delete doubleConeSel_;
00148 }
00149
00150 iEvent.put( detIdCollection, interestingDetIdCollection_ );
00151 }