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