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