Go to the documentation of this file.00001 #include "RecoEgamma/EgammaIsolationAlgos/plugins/EleIsoDetIdCollectionProducer.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/GsfElectron.h"
00012 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.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 EleIsoDetIdCollectionProducer::EleIsoDetIdCollectionProducer(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
00053 produces< DetIdCollection > (interestingDetIdCollection_) ;
00054 }
00055
00056 EleIsoDetIdCollectionProducer::~EleIsoDetIdCollectionProducer() {}
00057
00058 void EleIsoDetIdCollectionProducer::beginJob ()
00059 {}
00060
00061
00062 void
00063 EleIsoDetIdCollectionProducer::produce (edm::Event& iEvent,
00064 const edm::EventSetup& iSetup)
00065 {
00066 using namespace edm;
00067 using namespace std;
00068
00069
00070 Handle<reco::GsfElectronCollection> emObjectH;
00071 iEvent.getByLabel(emObjectLabel_,emObjectH);
00072
00073
00074 Handle<EcalRecHitCollection> recHitsH;
00075 iEvent.getByLabel(recHitsLabel_,recHitsH);
00076 std::auto_ptr<CaloRecHitMetaCollectionV> recHits_(0);
00077 recHits_ = std::auto_ptr<CaloRecHitMetaCollectionV>(new EcalRecHitMetaCollection(*recHitsH));
00078
00079 edm::ESHandle<CaloGeometry> pG;
00080 iSetup.get<CaloGeometryRecord>().get(pG);
00081 const CaloGeometry* caloGeom = pG.product();
00082
00083
00084 edm::ESHandle<EcalChannelStatus> chStatus;
00085 iSetup.get<EcalChannelStatusRcd>().get(chStatus);
00086
00087 edm::ESHandle<EcalSeverityLevelAlgo> sevlv;
00088 iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
00089 const EcalSeverityLevelAlgo* sevLevel = sevlv.product();
00090
00091 CaloDualConeSelector *doubleConeSel_ = 0;
00092 if(recHitsLabel_.instance() == "EcalRecHitsEB")
00093 doubleConeSel_= new CaloDualConeSelector(innerRadius_,outerRadius_, &*pG, DetId::Ecal, EcalBarrel);
00094 else if(recHitsLabel_.instance() == "EcalRecHitsEE")
00095 doubleConeSel_= new CaloDualConeSelector(innerRadius_,outerRadius_, &*pG, DetId::Ecal, EcalEndcap);
00096
00097
00098 std::auto_ptr< DetIdCollection > detIdCollection (new DetIdCollection() ) ;
00099
00100 reco::GsfElectronCollection::const_iterator emObj;
00101 if(doubleConeSel_) {
00102 for (emObj = emObjectH->begin(); emObj != emObjectH->end(); emObj++) {
00103
00104 if(emObj->et() < etCandCut_) continue;
00105
00106 GlobalPoint pclu (emObj->caloPosition().x(),emObj->caloPosition().y(),emObj->caloPosition().z());
00107 std::auto_ptr<CaloRecHitMetaCollectionV> chosen = doubleConeSel_->select(pclu,*recHits_);
00108
00109 CaloRecHitMetaCollectionV::const_iterator recIt;
00110 for (recIt = chosen->begin(); recIt!= chosen->end () ; ++recIt) {
00111
00112 if ( fabs(recIt->energy()) < energyCut_) continue;
00113
00114
00115 double et = recIt->energy() *
00116 caloGeom->getPosition(recIt->detid()).perp() /
00117 caloGeom->getPosition(recIt->detid()).mag();
00118
00119 if ( fabs(et) < etCut_) continue;
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 if(recHitsLabel_.instance() == "EcalRecHitsEB" &&
00132 sevLevel->severityLevel(EBDetId(recIt->detid()), *recHitsH) >= severityLevelCut_) continue;
00133
00134
00135
00136
00137
00138
00139
00140
00141 std::vector<int>::const_iterator vit = std::find( v_chstatus_.begin(), v_chstatus_.end(), ((EcalRecHit*)(&*recIt))->recoFlag() );
00142 if ( vit != v_chstatus_.end() ) continue;
00143
00144
00145 if(std::find(detIdCollection->begin(),detIdCollection->end(),recIt->detid()) == detIdCollection->end())
00146 detIdCollection->push_back(recIt->detid());
00147 }
00148
00149 }
00150
00151 delete doubleConeSel_;
00152 }
00153
00154 iEvent.put( detIdCollection, interestingDetIdCollection_ );
00155 }