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 #include "RecoEcal/EgammaClusterProducers/interface/HybridClusterProducer.h"
00034 #include "RecoEcal/EgammaCoreTools/interface/PositionCalc.h"
00035
00036
00037
00038 HybridClusterProducer::HybridClusterProducer(const edm::ParameterSet& ps)
00039 {
00040
00041
00042 std::string debugString = ps.getParameter<std::string>("debugLevel");
00043 if (debugString == "DEBUG") debugL = HybridClusterAlgo::pDEBUG;
00044 else if (debugString == "INFO") debugL = HybridClusterAlgo::pINFO;
00045 else debugL = HybridClusterAlgo::pERROR;
00046
00047 basicclusterCollection_ = ps.getParameter<std::string>("basicclusterCollection");
00048 superclusterCollection_ = ps.getParameter<std::string>("superclusterCollection");
00049 hitproducer_ = ps.getParameter<std::string>("ecalhitproducer");
00050 hitcollection_ =ps.getParameter<std::string>("ecalhitcollection");
00051
00052
00053 edm::ParameterSet posCalcParameters =
00054 ps.getParameter<edm::ParameterSet>("posCalcParameters");
00055
00056 posCalculator_ = PositionCalc(posCalcParameters);
00057
00058 hybrid_p = new HybridClusterAlgo(ps.getParameter<double>("HybridBarrelSeedThr"),
00059 ps.getParameter<int>("step"),
00060 ps.getParameter<double>("ethresh"),
00061 ps.getParameter<double>("eseed"),
00062 ps.getParameter<double>("ewing"),
00063 ps.getParameter<std::vector<int> >("RecHitFlagToBeExcluded"),
00064 posCalculator_,
00065 debugL,
00066 ps.getParameter<bool>("dynamicEThresh"),
00067 ps.getParameter<double>("eThreshA"),
00068 ps.getParameter<double>("eThreshB"),
00069 ps.getParameter<std::vector<int> >("RecHitSeverityToBeExcluded"),
00070 ps.getParameter<double>("severityRecHitThreshold"),
00071 ps.getParameter<int>("severitySpikeId"),
00072 ps.getParameter<double>("severitySpikeThreshold"),
00073 ps.getParameter<bool>("excludeFlagged")
00074 );
00075
00076
00077
00078 bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
00079 if (dynamicPhiRoad) {
00080 edm::ParameterSet bremRecoveryPset = ps.getParameter<edm::ParameterSet>("bremRecoveryPset");
00081 hybrid_p->setDynamicPhiRoad(bremRecoveryPset);
00082 }
00083
00084 produces< reco::BasicClusterCollection >(basicclusterCollection_);
00085 produces< reco::SuperClusterCollection >(superclusterCollection_);
00086 nEvt_ = 0;
00087 }
00088
00089
00090 HybridClusterProducer::~HybridClusterProducer()
00091 {
00092 delete hybrid_p;
00093 }
00094
00095
00096 void HybridClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es)
00097 {
00098
00099 edm::Handle<EcalRecHitCollection> rhcHandle;
00100
00101 evt.getByLabel(hitproducer_, hitcollection_, rhcHandle);
00102 if (!(rhcHandle.isValid()))
00103 {
00104 if (debugL <= HybridClusterAlgo::pINFO)
00105 std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl;
00106 return;
00107 }
00108 const EcalRecHitCollection *hit_collection = rhcHandle.product();
00109
00110
00111 edm::ESHandle<CaloGeometry> geoHandle;
00112 es.get<CaloGeometryRecord>().get(geoHandle);
00113 const CaloGeometry& geometry = *geoHandle;
00114 const CaloSubdetectorGeometry *geometry_p;
00115 std::auto_ptr<const CaloSubdetectorTopology> topology;
00116
00117 edm::ESHandle<EcalChannelStatus> chStatus;
00118 es.get<EcalChannelStatusRcd>().get(chStatus);
00119 const EcalChannelStatus* theEcalChStatus = chStatus.product();
00120
00121 if (debugL == HybridClusterAlgo::pDEBUG)
00122 std::cout << "\n\n\n" << hitcollection_ << "\n\n" << std::endl;
00123
00124 if(hitcollection_ == "EcalRecHitsEB") {
00125 geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
00126 topology.reset(new EcalBarrelTopology(geoHandle));
00127 } else if(hitcollection_ == "EcalRecHitsEE") {
00128 geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
00129 topology.reset(new EcalEndcapTopology(geoHandle));
00130 } else if(hitcollection_ == "EcalRecHitsPS") {
00131 geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
00132 topology.reset(new EcalPreshowerTopology (geoHandle));
00133 } else throw(std::runtime_error("\n\nHybrid Cluster Producer encountered invalied ecalhitcollection type.\n\n"));
00134
00135
00136 reco::BasicClusterCollection basicClusters;
00137 hybrid_p->makeClusters(hit_collection, geometry_p, basicClusters, false, std::vector<EcalEtaPhiRegion>(),theEcalChStatus);
00138 if (debugL == HybridClusterAlgo::pDEBUG)
00139 std::cout << "Finished clustering - BasicClusterCollection returned to producer..." << std::endl;
00140
00141
00142 std::auto_ptr< reco::BasicClusterCollection > basicclusters_p(new reco::BasicClusterCollection);
00143 basicclusters_p->assign(basicClusters.begin(), basicClusters.end());
00144 edm::OrphanHandle<reco::BasicClusterCollection> bccHandle = evt.put(basicclusters_p,
00145 basicclusterCollection_);
00146
00147 if (debugL == HybridClusterAlgo::pDEBUG)
00148 std::cout << "Basic Clusters now put into event." << std::endl;
00149
00150
00151
00152
00153
00154 if (!(bccHandle.isValid())) {
00155 if (debugL <= HybridClusterAlgo::pINFO)
00156 std::cout << "could not get a handle on the BasicClusterCollection!" << std::endl;
00157 return;
00158 }
00159 reco::BasicClusterCollection clusterCollection = *bccHandle;
00160 if (debugL == HybridClusterAlgo::pDEBUG)
00161 std::cout << "Got the BasicClusterCollection" << std::endl;
00162
00163 reco::CaloClusterPtrVector clusterPtrVector;
00164 for (unsigned int i = 0; i < clusterCollection.size(); i++){
00165 clusterPtrVector.push_back(reco::CaloClusterPtr(bccHandle, i));
00166 }
00167
00168 reco::SuperClusterCollection superClusters = hybrid_p->makeSuperClusters(clusterPtrVector);
00169
00170 if (debugL == HybridClusterAlgo::pDEBUG)
00171 std::cout << "Found: " << superClusters.size() << " superclusters." << std::endl;
00172
00173 std::auto_ptr< reco::SuperClusterCollection > superclusters_p(new reco::SuperClusterCollection);
00174 superclusters_p->assign(superClusters.begin(), superClusters.end());
00175
00176 evt.put(superclusters_p, superclusterCollection_);
00177
00178 if (debugL == HybridClusterAlgo::pDEBUG)
00179 std::cout << "Hybrid Clusters (Basic/Super) added to the Event! :-)" << std::endl;
00180
00181 nEvt_++;
00182 }
00183