Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDProducer.h"
00027 #include "FWCore/Framework/interface/EventSetup.h"
00028 #include "FWCore/Framework/interface/ESHandle.h"
00029
00030 #include "FWCore/Framework/interface/Event.h"
00031 #include "FWCore/Framework/interface/MakerMacros.h"
00032
00033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00034 #include "FWCore/Utilities/interface/InputTag.h"
00035
00036 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00037 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00038
00039 #include "RecoEcal/EgammaCoreTools/interface/EcalTools.h"
00040 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
00041 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00042 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
00043
00044
00045
00046
00047
00048
00049
00050 class HiSpikeCleaner : public edm::EDProducer {
00051 public:
00052 explicit HiSpikeCleaner(const edm::ParameterSet&);
00053 ~HiSpikeCleaner();
00054
00055 private:
00056 virtual void beginJob() ;
00057 virtual void produce(edm::Event&, const edm::EventSetup&);
00058 virtual void endJob() ;
00059
00060
00061
00062 edm::InputTag sCInputProducer_;
00063 edm::InputTag rHInputProducerB_;
00064 edm::InputTag rHInputProducerE_;
00065
00066 std::string outputCollection_;
00067 double TimingCut_;
00068 double swissCutThr_;
00069 double etCut_;
00070
00071 };
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 HiSpikeCleaner::HiSpikeCleaner(const edm::ParameterSet& iConfig)
00086 {
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 rHInputProducerB_ = iConfig.getParameter<edm::InputTag>("recHitProducerBarrel");
00097 rHInputProducerE_ = iConfig.getParameter<edm::InputTag>("recHitProducerEndcap");
00098
00099 sCInputProducer_ = iConfig.getParameter<edm::InputTag>("originalSuperClusterProducer");
00100 TimingCut_ = iConfig.getUntrackedParameter<double> ("TimingCut",4.0);
00101 swissCutThr_ = iConfig.getUntrackedParameter<double>("swissCutThr",0.95);
00102 etCut_ = iConfig.getParameter<double>("etCut");
00103
00104 outputCollection_ = iConfig.getParameter<std::string>("outputColl");
00105 produces<reco::SuperClusterCollection>(outputCollection_);
00106
00107
00108
00109 }
00110
00111
00112 HiSpikeCleaner::~HiSpikeCleaner()
00113 {
00114
00115
00116 }
00117
00118
00119
00120
00121
00122
00123
00124 void
00125 HiSpikeCleaner::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00126 {
00127 using namespace edm;
00128
00129
00130
00131 Handle<reco::SuperClusterCollection> pRawSuperClusters;
00132 try {
00133 iEvent.getByLabel(sCInputProducer_, pRawSuperClusters);
00134 } catch ( cms::Exception& ex ) {
00135 edm::LogError("EgammaSCCorrectionMakerError")
00136 << "Error! can't get the rawSuperClusters "
00137 << sCInputProducer_.label() ;
00138 }
00139
00140
00141 Handle<EcalRecHitCollection> pRecHitsB;
00142 try {
00143 iEvent.getByLabel(rHInputProducerB_, pRecHitsB);
00144 } catch ( cms::Exception& ex ) {
00145 edm::LogError("EgammaSCCorrectionMakerError")
00146 << "Error! can't get the RecHits "
00147 << rHInputProducerB_.label();
00148 }
00149
00150 Handle<EcalRecHitCollection> pRecHitsE;
00151 try {
00152 iEvent.getByLabel(rHInputProducerE_, pRecHitsE);
00153 } catch ( cms::Exception& ex ) {
00154 edm::LogError("EgammaSCCorrectionMakerError")
00155 << "Error! can't get the RecHits "
00156 << rHInputProducerE_.label();
00157 }
00158
00159
00160
00161
00162
00163
00164 edm::ESHandle<EcalSeverityLevelAlgo> ecalSevLvlAlgoHndl;
00165 iSetup.get<EcalSeverityLevelAlgoRcd>().get(ecalSevLvlAlgoHndl);
00166
00167
00168
00169 const reco::SuperClusterCollection *rawClusters = pRawSuperClusters.product();
00170
00171
00172 EcalClusterLazyTools lazyTool(iEvent, iSetup, rHInputProducerB_,rHInputProducerE_);
00173
00174
00175 std::auto_ptr<reco::SuperClusterCollection> corrClusters(new reco::SuperClusterCollection);
00176
00177
00178 reco::SuperClusterCollection::const_iterator aClus;
00179 for(aClus = rawClusters->begin(); aClus != rawClusters->end(); aClus++)
00180 {
00181 double theEt = aClus->energy()/cosh( aClus->eta() ) ;
00182
00183
00184 if ( theEt < etCut_ ) continue;
00185
00186 bool flagS = true;
00187 float swissCrx(0);
00188
00189 const reco::CaloClusterPtr seed = aClus->seed();
00190 DetId id = lazyTool.getMaximum(*seed).first;
00191 const EcalRecHitCollection & rechits = *pRecHitsB;
00192 EcalRecHitCollection::const_iterator it = rechits.find( id );
00193
00194 if( it != rechits.end() ) {
00195 ecalSevLvlAlgoHndl->severityLevel(id, rechits);
00196 swissCrx = EcalTools::swissCross (id, rechits, 0.,true);
00197
00198
00199 }
00200
00201 if ( fabs(it->time()) > TimingCut_ ) {
00202 flagS = false;
00203
00204
00205 }
00206 if ( swissCrx > (float)swissCutThr_ ) {
00207 flagS = false ;
00208
00209
00210 }
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220 reco::SuperCluster newClus;
00221 if ( flagS == true)
00222 newClus=*aClus;
00223 else
00224 continue;
00225 corrClusters->push_back(newClus);
00226 }
00227
00228
00229 iEvent.put(corrClusters, outputCollection_);
00230
00231 }
00232
00233
00234 void
00235 HiSpikeCleaner::beginJob()
00236 {
00237 }
00238
00239
00240 void
00241 HiSpikeCleaner::endJob() {
00242 }
00243
00244
00245 DEFINE_FWK_MODULE(HiSpikeCleaner);