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