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 "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00040 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00041 #include "CondFormats/EcalObjects/interface/EcalChannelStatusCode.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 edm::ESHandle<EcalChannelStatus> chStatus;
00162 iSetup.get<EcalChannelStatusRcd>().get(chStatus);
00163
00164
00165
00166
00167 const reco::SuperClusterCollection *rawClusters = pRawSuperClusters.product();
00168
00169
00170 EcalClusterLazyTools lazyTool(iEvent, iSetup, rHInputProducerB_,rHInputProducerE_);
00171
00172
00173 std::auto_ptr<reco::SuperClusterCollection> corrClusters(new reco::SuperClusterCollection);
00174
00175
00176 reco::SuperClusterCollection::const_iterator aClus;
00177 for(aClus = rawClusters->begin(); aClus != rawClusters->end(); aClus++)
00178 {
00179 double theEt = aClus->energy()/cosh( aClus->eta() ) ;
00180
00181
00182 if ( theEt < etCut_ ) continue;
00183
00184 bool flagS = true;
00185 int severity(-100);
00186 float swissCrx(0);
00187
00188 const reco::CaloClusterPtr seed = aClus->seed();
00189 DetId id = lazyTool.getMaximum(*seed).first;
00190 const EcalRecHitCollection & rechits = *pRecHitsB;
00191 EcalRecHitCollection::const_iterator it = rechits.find( id );
00192
00193 if( it != rechits.end() ) {
00194 severity = EcalSeverityLevelAlgo::severityLevel(id, rechits, *chStatus );
00195 swissCrx = EcalSeverityLevelAlgo::swissCross (id, rechits, 0.,true);
00196
00197
00198 }
00199
00200 if ( fabs(it->time()) > TimingCut_ ) {
00201 flagS = false;
00202
00203
00204 }
00205 if ( swissCrx > (float)swissCutThr_ ) {
00206 flagS = false ;
00207
00208
00209 }
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 reco::SuperCluster newClus;
00220 if ( flagS == true)
00221 newClus=*aClus;
00222 else
00223 continue;
00224 corrClusters->push_back(newClus);
00225 }
00226
00227
00228 iEvent.put(corrClusters, outputCollection_);
00229
00230 }
00231
00232
00233 void
00234 HiSpikeCleaner::beginJob()
00235 {
00236 }
00237
00238
00239 void
00240 HiSpikeCleaner::endJob() {
00241 }
00242
00243
00244 DEFINE_FWK_MODULE(HiSpikeCleaner);