Go to the documentation of this file.00001
00002 #include <iostream>
00003 #include <vector>
00004 #include <memory>
00005
00006
00007 #include "FWCore/Framework/interface/Event.h"
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 #include "DataFormats/Common/interface/Handle.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "FWCore/Framework/interface/ESHandle.h"
00012
00013
00014 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00015 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00016 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00017 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00018 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00019 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00020 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00021 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
00022
00023
00024 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00025 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00026 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00027 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00028 #include "Geometry/CaloTopology/interface/EcalBarrelTopology.h"
00029 #include "Geometry/CaloTopology/interface/EcalEndcapTopology.h"
00030 #include "Geometry/CaloTopology/interface/EcalPreshowerTopology.h"
00031
00032
00033
00034 #include "DataFormats/L1Trigger/interface/L1EmParticle.h"
00035 #include "DataFormats/L1Trigger/interface/L1EmParticleFwd.h"
00036 #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h"
00037 #include "CondFormats/DataRecord/interface/L1CaloGeometryRecord.h"
00038
00039
00040 #include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h"
00041 #include "RecoEcal/EgammaCoreTools/interface/EcalEtaPhiRegion.h"
00042
00043
00044 #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHybridClusterProducer.h"
00045
00046
00047 EgammaHLTHybridClusterProducer::EgammaHLTHybridClusterProducer(const edm::ParameterSet& ps)
00048 {
00049
00050
00051 std::string debugString = ps.getParameter<std::string>("debugLevel");
00052 if (debugString == "DEBUG") debugL = HybridClusterAlgo::pDEBUG;
00053 else if (debugString == "INFO") debugL = HybridClusterAlgo::pINFO;
00054 else debugL = HybridClusterAlgo::pERROR;
00055
00056 basicclusterCollection_ = ps.getParameter<std::string>("basicclusterCollection");
00057 superclusterCollection_ = ps.getParameter<std::string>("superclusterCollection");
00058 hitproducer_ = ps.getParameter<edm::InputTag>("ecalhitproducer");
00059 hitcollection_ =ps.getParameter<std::string>("ecalhitcollection");
00060
00061
00062
00063
00064 l1TagIsolated_ = ps.getParameter< edm::InputTag > ("l1TagIsolated");
00065 l1TagNonIsolated_ = ps.getParameter< edm::InputTag > ("l1TagNonIsolated");
00066
00067 doIsolated_ = ps.getParameter<bool>("doIsolated");
00068
00069 l1LowerThr_ = ps.getParameter<double> ("l1LowerThr");
00070 l1UpperThr_ = ps.getParameter<double> ("l1UpperThr");
00071 l1LowerThrIgnoreIsolation_ = ps.getParameter<double> ("l1LowerThrIgnoreIsolation");
00072
00073 regionEtaMargin_ = ps.getParameter<double>("regionEtaMargin");
00074 regionPhiMargin_ = ps.getParameter<double>("regionPhiMargin");
00075
00076
00077 posCalculator_ = PositionCalc( ps.getParameter<edm::ParameterSet>("posCalcParameters") );
00078
00079
00080 hybrid_p = new HybridClusterAlgo(ps.getParameter<double>("HybridBarrelSeedThr"),
00081 ps.getParameter<int>("step"),
00082 ps.getParameter<double>("ethresh"),
00083 ps.getParameter<double>("eseed"),
00084 ps.getParameter<double>("ewing"),
00085 ps.getParameter<std::vector<int> >("RecHitFlagToBeExcluded"),
00086 posCalculator_,
00087 debugL,
00088 ps.getParameter<bool>("dynamicEThresh"),
00089 ps.getParameter<double>("eThreshA"),
00090 ps.getParameter<double>("eThreshB"),
00091 ps.getParameter<std::vector<int> >("RecHitSeverityToBeExcluded"),
00092 ps.getParameter<double>("severityRecHitThreshold"),
00093 ps.getParameter<int>("severitySpikeId"),
00094 ps.getParameter<double>("severitySpikeThreshold"),
00095 ps.getParameter<bool>("excludeFlagged")
00096 );
00097
00098 bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
00099 if (dynamicPhiRoad) {
00100 edm::ParameterSet bremRecoveryPset = ps.getParameter<edm::ParameterSet>("bremRecoveryPset");
00101 hybrid_p->setDynamicPhiRoad(bremRecoveryPset);
00102 }
00103
00104
00105 produces< reco::BasicClusterCollection >(basicclusterCollection_);
00106 produces< reco::SuperClusterCollection >(superclusterCollection_);
00107 nEvt_ = 0;
00108 }
00109
00110
00111 EgammaHLTHybridClusterProducer::~EgammaHLTHybridClusterProducer()
00112 {
00113 delete hybrid_p;
00114 }
00115
00116
00117 void EgammaHLTHybridClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es)
00118 {
00119
00120 edm::Handle<EcalRecHitCollection> rhcHandle;
00121
00122 evt.getByLabel(hitproducer_.label(), hitcollection_, rhcHandle);
00123 if (!(rhcHandle.isValid()))
00124 {
00125 if (debugL <= HybridClusterAlgo::pINFO)
00126 std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl;
00127 return;
00128 }
00129 const EcalRecHitCollection *hit_collection = rhcHandle.product();
00130
00131
00132 edm::ESHandle<CaloGeometry> geoHandle;
00133 es.get<CaloGeometryRecord>().get(geoHandle);
00134 const CaloGeometry& geometry = *geoHandle;
00135 const CaloSubdetectorGeometry *geometry_p;
00136 std::auto_ptr<const CaloSubdetectorTopology> topology;
00137
00138 edm::ESHandle<EcalChannelStatus> chStatus;
00139 es.get<EcalChannelStatusRcd>().get(chStatus);
00140 const EcalChannelStatus* theEcalChStatus = chStatus.product();
00141
00142
00143
00144
00145 if(hitcollection_ == "EcalRecHitsEB") {
00146 geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
00147 topology.reset(new EcalBarrelTopology(geoHandle));
00148 } else if(hitcollection_ == "EcalRecHitsEE") {
00149 geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
00150 topology.reset(new EcalEndcapTopology(geoHandle));
00151 } else if(hitcollection_ == "EcalRecHitsPS") {
00152 geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
00153 topology.reset(new EcalPreshowerTopology (geoHandle));
00154 } else throw(std::runtime_error("\n\nHybrid Cluster Producer encountered invalied ecalhitcollection type.\n\n"));
00155
00156
00157
00158 edm::Handle< l1extra::L1EmParticleCollection > emIsolColl ;
00159 if(doIsolated_)
00160 evt.getByLabel(l1TagIsolated_, emIsolColl);
00161
00162 edm::Handle< l1extra::L1EmParticleCollection > emNonIsolColl ;
00163 evt.getByLabel(l1TagNonIsolated_, emNonIsolColl);
00164
00165
00166 edm::ESHandle<L1CaloGeometry> l1CaloGeom ;
00167 es.get<L1CaloGeometryRecord>().get(l1CaloGeom) ;
00168
00169 std::vector<EcalEtaPhiRegion> regions;
00170
00171 if(doIsolated_) {
00172 for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end() ;++emItr ){
00173
00174 if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_
00175
00177 ) {
00178
00179
00180
00181
00182
00183 int etaIndex = emItr->gctEmCand()->etaIndex() ;
00184 int phiIndex = emItr->gctEmCand()->phiIndex() ;
00185
00186 double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
00187 double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
00188 double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
00189 double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;
00190
00191 int isbarl=0;
00192
00193
00194 if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) ||
00195 ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1;
00196
00197
00198
00199 etaLow -= regionEtaMargin_;
00200 etaHigh += regionEtaMargin_;
00201 phiLow -= regionPhiMargin_;
00202 phiHigh += regionPhiMargin_;
00203
00204 if (etaHigh>1.479) etaHigh=1.479;
00205 if (etaLow<-1.479) etaLow=-1.479;
00206
00207 if(isbarl) regions.push_back(EcalEtaPhiRegion(etaLow,etaHigh,phiLow,phiHigh));
00208
00209 }
00210 }
00211 }
00212
00213 if(!doIsolated_||l1LowerThrIgnoreIsolation_<64) {
00214 for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end() ;++emItr ){
00215
00216 if(doIsolated_&&emItr->et()<l1LowerThrIgnoreIsolation_) continue;
00217
00218 if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_
00219
00221 ) {
00222
00223
00224
00225
00226
00227 int etaIndex = emItr->gctEmCand()->etaIndex() ;
00228 int phiIndex = emItr->gctEmCand()->phiIndex() ;
00229
00230 double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
00231 double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
00232 double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
00233 double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;
00234
00235 int isbarl=0;
00236
00237
00238 if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) ||
00239 ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1;
00240
00241
00242
00243 etaLow -= regionEtaMargin_;
00244 etaHigh += regionEtaMargin_;
00245 phiLow -= regionPhiMargin_;
00246 phiHigh += regionPhiMargin_;
00247
00248 if (etaHigh>1.479) etaHigh=1.479;
00249 if (etaLow<-1.479) etaLow=-1.479;
00250
00251 if(isbarl) regions.push_back(EcalEtaPhiRegion(etaLow,etaHigh,phiLow,phiHigh));
00252
00253 }
00254 }
00255 }
00256
00257
00258 reco::BasicClusterCollection basicClusters;
00259 hybrid_p->makeClusters(hit_collection, geometry_p, basicClusters, true, regions,theEcalChStatus);
00260
00261
00262
00263
00264 std::auto_ptr< reco::BasicClusterCollection > basicclusters_p(new reco::BasicClusterCollection);
00265 basicclusters_p->assign(basicClusters.begin(), basicClusters.end());
00266 edm::OrphanHandle<reco::BasicClusterCollection> bccHandle = evt.put(basicclusters_p,
00267 basicclusterCollection_);
00268
00269
00270
00271
00272
00273
00274
00275
00276 if (!(bccHandle.isValid())) {
00277
00278
00279 return;
00280 }
00281 reco::BasicClusterCollection clusterCollection = *bccHandle;
00282
00283
00284
00285 reco::CaloClusterPtrVector clusterRefVector;
00286 for (unsigned int i = 0; i < clusterCollection.size(); i++){
00287 clusterRefVector.push_back(reco::CaloClusterPtr(bccHandle, i));
00288 }
00289
00290 reco::SuperClusterCollection superClusters = hybrid_p->makeSuperClusters(clusterRefVector);
00291
00292
00293
00294 std::auto_ptr< reco::SuperClusterCollection > superclusters_p(new reco::SuperClusterCollection);
00295 superclusters_p->assign(superClusters.begin(), superClusters.end());
00296 evt.put(superclusters_p, superclusterCollection_);
00297
00298
00299
00300
00301 nEvt_++;
00302 }
00303