Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTEcalRecIsolationProducer.h"
00012
00013
00014
00015 #include "FWCore/Framework/interface/Event.h"
00016 #include "FWCore/Framework/interface/EventSetup.h"
00017 #include "DataFormats/Common/interface/Handle.h"
00018 #include "FWCore/Framework/interface/ESHandle.h"
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020 #include "FWCore/Utilities/interface/Exception.h"
00021
00022 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00023 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h"
00024
00025 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00026 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00027
00028 #include "DataFormats/DetId/interface/DetId.h"
00029 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00030
00031 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00032
00033 #include "DataFormats/Common/interface/RefToBase.h"
00034 #include "DataFormats/Common/interface/Ref.h"
00035 #include "DataFormats/Common/interface/RefProd.h"
00036
00037 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00038
00039
00040 EgammaHLTEcalRecIsolationProducer::EgammaHLTEcalRecIsolationProducer(const edm::ParameterSet& config) : conf_(config)
00041 {
00042
00043
00044 recoEcalCandidateProducer_ = conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer");
00045 ecalBarrelRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitProducer");
00046 ecalBarrelRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalBarrelRecHitCollection");
00047 ecalEndcapRecHitProducer_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitProducer");
00048 ecalEndcapRecHitCollection_ = conf_.getParameter<edm::InputTag>("ecalEndcapRecHitCollection");
00049
00050
00051 egIsoPtMinBarrel_ = conf_.getParameter<double>("etMinBarrel");
00052 egIsoEMinBarrel_ = conf_.getParameter<double>("eMinBarrel");
00053 egIsoPtMinEndcap_ = conf_.getParameter<double>("etMinEndcap");
00054 egIsoEMinEndcap_ = conf_.getParameter<double>("eMinEndcap");
00055 egIsoConeSizeInBarrel_ = conf_.getParameter<double>("intRadiusBarrel");
00056 egIsoConeSizeInEndcap_ = conf_.getParameter<double>("intRadiusEndcap");
00057 egIsoConeSizeOut_ = conf_.getParameter<double>("extRadius");
00058 egIsoJurassicWidth_ = conf_.getParameter<double>("jurassicWidth");
00059
00060
00061
00062 useIsolEt_ = conf_.getParameter<bool>("useIsolEt");
00063 tryBoth_ = conf_.getParameter<bool>("tryBoth");
00064 subtract_ = conf_.getParameter<bool>("subtract");
00065 useNumCrystals_ = conf_.getParameter<bool>("useNumCrystals");
00066
00067
00068 produces < reco::RecoEcalCandidateIsolationMap >();
00069
00070 }
00071
00072 EgammaHLTEcalRecIsolationProducer::~EgammaHLTEcalRecIsolationProducer(){}
00073
00074
00075
00076 void EgammaHLTEcalRecIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){
00077
00078
00079 edm::Handle<reco::RecoEcalCandidateCollection> recoecalcandHandle;
00080 iEvent.getByLabel(recoEcalCandidateProducer_,recoecalcandHandle);
00081
00082
00083 edm::Handle<EcalRecHitCollection> ecalBarrelRecHitHandle;
00084 iEvent.getByLabel(ecalBarrelRecHitProducer_.label(),ecalBarrelRecHitCollection_.label(), ecalBarrelRecHitHandle);
00085
00086
00087 edm::Handle<EcalRecHitCollection> ecalEndcapRecHitHandle;
00088 iEvent.getByLabel(ecalEndcapRecHitProducer_.label(), ecalEndcapRecHitCollection_.label(),ecalEndcapRecHitHandle);
00089
00090
00091
00092 EcalRecHitMetaCollection ecalBarrelHits(*ecalBarrelRecHitHandle);
00093 EcalRecHitMetaCollection ecalEndcapHits(*ecalEndcapRecHitHandle);
00094
00095
00096 edm::ESHandle<CaloGeometry> pG;
00097 iSetup.get<CaloGeometryRecord>().get(pG);
00098 const CaloGeometry* caloGeom = pG.product();
00099
00100
00101 reco::RecoEcalCandidateIsolationMap isoMap;
00102
00103
00104 EgammaRecHitIsolation ecalBarrelIsol(egIsoConeSizeOut_,egIsoConeSizeInBarrel_,egIsoJurassicWidth_,egIsoPtMinBarrel_,egIsoEMinBarrel_,edm::ESHandle<CaloGeometry>(caloGeom),&ecalBarrelHits,DetId::Ecal);
00105 ecalBarrelIsol.setUseNumCrystals(useNumCrystals_);
00106 EgammaRecHitIsolation ecalEndcapIsol(egIsoConeSizeOut_,egIsoConeSizeInEndcap_,egIsoJurassicWidth_,egIsoPtMinEndcap_,egIsoEMinEndcap_,edm::ESHandle<CaloGeometry>(caloGeom),&ecalEndcapHits,DetId::Ecal);
00107 ecalEndcapIsol.setUseNumCrystals(useNumCrystals_);
00108
00109 for (reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand= recoecalcandHandle->begin(); iRecoEcalCand!=recoecalcandHandle->end(); iRecoEcalCand++) {
00110
00111
00112 reco::RecoEcalCandidateRef recoecalcandref(reco::RecoEcalCandidateRef(recoecalcandHandle,iRecoEcalCand -recoecalcandHandle ->begin()));
00113
00114
00115 reco::SuperClusterRef superClus = iRecoEcalCand->get<reco::SuperClusterRef>();
00116
00117
00118
00119
00120
00121 float isol =0.;
00122
00123 if(tryBoth_){
00124 if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
00125 else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand)) + ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
00126 }
00127 else if( fabs(superClus->eta())<1.479) {
00128 if(useIsolEt_) isol = ecalBarrelIsol.getEtSum(&(*iRecoEcalCand));
00129 else isol = ecalBarrelIsol.getEnergySum(&(*iRecoEcalCand));
00130 }
00131 else{
00132 if(useIsolEt_) isol = ecalEndcapIsol.getEtSum(&(*iRecoEcalCand));
00133 else isol = ecalEndcapIsol.getEnergySum(&(*iRecoEcalCand));
00134 }
00135
00136
00137 double subtractVal=0;
00138
00139 if(useIsolEt_) subtractVal = superClus.get()->rawEnergy()*sin(2*atan(exp(-superClus.get()->eta())));
00140 else subtractVal = superClus.get()->rawEnergy();
00141
00142 if(subtract_) isol-= subtractVal;
00143
00144
00145
00146 isoMap.insert(recoecalcandref, isol);
00147
00148 }
00149
00150 std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
00151 iEvent.put(isolMap);
00152
00153 }
00154
00155