Go to the documentation of this file.00001
00002 #include <iostream>
00003 #include <vector>
00004 #include <memory>
00005 #include <sstream>
00006
00007
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010 #include "DataFormats/Common/interface/Handle.h"
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012 #include "FWCore/Utilities/interface/Exception.h"
00013
00014
00015 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00016 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00017 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00018 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00019
00020
00021 #include "RecoEcal/EgammaClusterProducers/interface/SuperClusterProducer.h"
00022
00023
00024 SuperClusterProducer::SuperClusterProducer(const edm::ParameterSet& ps)
00025 {
00026
00027 std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
00028 if (verbosityString == "DEBUG") verbosity = BremRecoveryClusterAlgo::pDEBUG;
00029 else if (verbosityString == "WARNING") verbosity = BremRecoveryClusterAlgo::pWARNING;
00030 else if (verbosityString == "INFO") verbosity = BremRecoveryClusterAlgo::pINFO;
00031 else verbosity = BremRecoveryClusterAlgo::pERROR;
00032
00033 endcapClusterProducer_ = ps.getParameter<std::string>("endcapClusterProducer");
00034 barrelClusterProducer_ = ps.getParameter<std::string>("barrelClusterProducer");
00035
00036 endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
00037 barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
00038
00039 endcapSuperclusterCollection_ = ps.getParameter<std::string>("endcapSuperclusterCollection");
00040 barrelSuperclusterCollection_ = ps.getParameter<std::string>("barrelSuperclusterCollection");
00041
00042 doBarrel_ = ps.getParameter<bool>("doBarrel");
00043 doEndcaps_ = ps.getParameter<bool>("doEndcaps");
00044
00045
00046 barrelEtaSearchRoad_ = ps.getParameter<double>("barrelEtaSearchRoad");
00047 barrelPhiSearchRoad_ = ps.getParameter<double>("barrelPhiSearchRoad");
00048 endcapEtaSearchRoad_ = ps.getParameter<double>("endcapEtaSearchRoad");
00049 endcapPhiSearchRoad_ = ps.getParameter<double>("endcapPhiSearchRoad");
00050 seedTransverseEnergyThreshold_ = ps.getParameter<double>("seedTransverseEnergyThreshold");
00051
00052 bremAlgo_p = new BremRecoveryClusterAlgo(barrelEtaSearchRoad_, barrelPhiSearchRoad_,
00053 endcapEtaSearchRoad_, endcapPhiSearchRoad_,
00054 seedTransverseEnergyThreshold_, verbosity);
00055
00056 produces< reco::SuperClusterCollection >(endcapSuperclusterCollection_);
00057 produces< reco::SuperClusterCollection >(barrelSuperclusterCollection_);
00058
00059 totalE = 0;
00060 noSuperClusters = 0;
00061 nEvt_ = 0;
00062 }
00063
00064
00065 SuperClusterProducer::~SuperClusterProducer()
00066 {
00067 delete bremAlgo_p;
00068 }
00069
00070 void
00071 SuperClusterProducer::endJob() {
00072 double averEnergy = 0.;
00073 std::ostringstream str;
00074 str << "SuperClusterProducer::endJob()\n"
00075 << " total # reconstructed super clusters: " << noSuperClusters << "\n"
00076 << " total energy of all clusters: " << totalE << "\n";
00077 if(noSuperClusters>0) {
00078 averEnergy = totalE / noSuperClusters;
00079 str << " average SuperCluster energy = " << averEnergy << "\n";
00080 }
00081 edm::LogInfo("SuperClusterProducerInfo") << str.str() << "\n";
00082
00083 }
00084
00085
00086 void SuperClusterProducer::produce(edm::Event& evt, const edm::EventSetup& es)
00087 {
00088 if(doEndcaps_)
00089 produceSuperclustersForECALPart(evt, endcapClusterProducer_, endcapClusterCollection_, endcapSuperclusterCollection_);
00090
00091 if(doBarrel_)
00092 produceSuperclustersForECALPart(evt, barrelClusterProducer_, barrelClusterCollection_, barrelSuperclusterCollection_);
00093
00094 nEvt_++;
00095 }
00096
00097
00098 void SuperClusterProducer::produceSuperclustersForECALPart(edm::Event& evt,
00099 std::string clusterProducer,
00100 std::string clusterCollection,
00101 std::string superclusterCollection)
00102 {
00103
00104 reco::CaloClusterPtrVector *clusterPtrVector_p = new reco::CaloClusterPtrVector;
00105 getClusterPtrVector(evt, clusterProducer, clusterCollection, clusterPtrVector_p);
00106
00107
00108 std::auto_ptr<reco::SuperClusterCollection>
00109 superclusters_ap(new reco::SuperClusterCollection(bremAlgo_p->makeSuperClusters(*clusterPtrVector_p)));
00110
00111
00112 reco::SuperClusterCollection::iterator it;
00113 for (it = superclusters_ap->begin(); it != superclusters_ap->end(); it++)
00114 {
00115 totalE += it->energy();
00116 noSuperClusters++;
00117 }
00118
00119
00120 evt.put(superclusters_ap, superclusterCollection);
00121
00122 delete clusterPtrVector_p;
00123 }
00124
00125
00126 void SuperClusterProducer::getClusterPtrVector(edm::Event& evt, std::string clusterProducer_, std::string clusterCollection_, reco::CaloClusterPtrVector *clusterPtrVector_p)
00127 {
00128 edm::Handle<reco::BasicClusterCollection> bccHandle;
00129
00130 evt.getByLabel(clusterProducer_, clusterCollection_, bccHandle);
00131 if (!(bccHandle.isValid()))
00132 {
00133 edm::LogError("SuperClusterProducerError") << "could not get a handle on the BasicCluster Collection!";
00134 edm::LogError("SuperClusterProducerError") << "Error! can't get the product " << clusterCollection_.c_str();
00135 clusterPtrVector_p = 0;
00136 }
00137
00138 const reco::BasicClusterCollection *clusterCollection_p = bccHandle.product();
00139 for (unsigned int i = 0; i < clusterCollection_p->size(); i++)
00140 {
00141 clusterPtrVector_p->push_back(reco::CaloClusterPtr(bccHandle, i));
00142 }
00143 }
00144
00145
00146
00147