#include <RecoEcal/EgammaClusterProducers/interface/ExampleClusterProducer.h>
Public Member Functions | |
ExampleClusterProducer (const edm::ParameterSet &ps) | |
virtual void | produce (edm::Event &evt, const edm::EventSetup &es) |
~ExampleClusterProducer () | |
Private Member Functions | |
bool | counterExceeded () const |
Private Attributes | |
ExampleClusterAlgo * | algo_ |
std::string | clusterCollection_ |
std::string | hitCollection_ |
std::string | hitProducer_ |
int | nEvt_ |
int | nMaxPrintout_ |
Definition at line 21 of file ExampleClusterProducer.h.
ExampleClusterProducer::ExampleClusterProducer | ( | const edm::ParameterSet & | ps | ) |
Definition at line 12 of file ExampleClusterProducer.cc.
References algo_, clusterCollection_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hitCollection_, hitProducer_, and nMaxPrintout_.
00012 { 00013 00014 00015 // use onfiguration file to setup input/output collection names 00016 nMaxPrintout_ = ps.getUntrackedParameter<int>("nMaxPrintout",1); 00017 00018 hitProducer_ = ps.getParameter<std::string>("hitProducer"); 00019 hitCollection_ = ps.getParameter<std::string>("hitCollection"); 00020 clusterCollection_ = ps.getParameter<std::string>("clusterCollection"); 00021 00022 00023 // configure your algorithm via ParameterSet 00024 double energyCut = ps.getUntrackedParameter<double>("energyCut",0.); 00025 int nXtalCut = ps.getUntrackedParameter<int>("nXtalCut",-1); 00026 00027 algo_ = new ExampleClusterAlgo(energyCut,nXtalCut); 00028 00029 }
ExampleClusterProducer::~ExampleClusterProducer | ( | ) |
Definition at line 31 of file ExampleClusterProducer.cc.
References algo_.
00031 { 00032 delete algo_; 00033 }
bool ExampleClusterProducer::counterExceeded | ( | ) | const [inline, private] |
Definition at line 41 of file ExampleClusterProducer.h.
References nEvt_, and nMaxPrintout_.
00041 { return ((nEvt_ > nMaxPrintout_) || (nMaxPrintout_ < 0)); }
void ExampleClusterProducer::produce | ( | edm::Event & | evt, | |
const edm::EventSetup & | es | |||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 37 of file ExampleClusterProducer.cc.
References algo_, clusterCollection_, edm::Event::getByLabel(), hitCollection_, hitProducer_, ExampleClusterAlgo::makeClusters(), edm::Event::put(), and edm::SortedCollection< T, SORT >::size().
00037 { 00038 00039 using namespace edm; 00040 00041 // handle to the product 00042 Handle< EcalRecHitCollection > pRecHits; 00043 00044 // fetch the product 00045 evt.getByLabel( hitProducer_, hitCollection_, pRecHits); 00046 if (!pRecHits.isValid()) { 00047 edm::LogError("ExampleClusterProducerError") << "Error! can't get the product " << hitCollection_.c_str() ; 00048 } 00049 00050 // pointer to the object in the product 00051 const EcalRecHitCollection* rechits = pRecHits.product(); 00052 edm::LogInfo("ExampleClusterProducerInfo") << "total # calibrated rechits: " << rechits->size() ; 00053 00054 // output collection of basic clusters 00055 // reco::BasicClusterCollection defined in BasicClusterFwd.h 00056 00057 // make the clusters by passing rechits to the agorithm 00058 std::auto_ptr< reco::BasicClusterCollection > 00059 clusters( new reco::BasicClusterCollection(algo_->makeClusters( *rechits )) ); 00060 00061 // put the product in the event 00062 evt.put( clusters, clusterCollection_ ); 00063 }
ExampleClusterAlgo* ExampleClusterProducer::algo_ [private] |
Definition at line 32 of file ExampleClusterProducer.h.
Referenced by ExampleClusterProducer(), produce(), and ~ExampleClusterProducer().
std::string ExampleClusterProducer::clusterCollection_ [private] |
Definition at line 36 of file ExampleClusterProducer.h.
Referenced by ExampleClusterProducer(), and produce().
std::string ExampleClusterProducer::hitCollection_ [private] |
Definition at line 35 of file ExampleClusterProducer.h.
Referenced by ExampleClusterProducer(), and produce().
std::string ExampleClusterProducer::hitProducer_ [private] |
Definition at line 34 of file ExampleClusterProducer.h.
Referenced by ExampleClusterProducer(), and produce().
int ExampleClusterProducer::nEvt_ [private] |
int ExampleClusterProducer::nMaxPrintout_ [private] |
Definition at line 38 of file ExampleClusterProducer.h.
Referenced by counterExceeded(), and ExampleClusterProducer().