#include <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_ |
example of producer for BasicCluster from recHits
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_.
{ // use onfiguration file to setup input/output collection names nMaxPrintout_ = ps.getUntrackedParameter<int>("nMaxPrintout",1); hitProducer_ = ps.getParameter<std::string>("hitProducer"); hitCollection_ = ps.getParameter<std::string>("hitCollection"); clusterCollection_ = ps.getParameter<std::string>("clusterCollection"); // configure your algorithm via ParameterSet double energyCut = ps.getUntrackedParameter<double>("energyCut",0.); int nXtalCut = ps.getUntrackedParameter<int>("nXtalCut",-1); algo_ = new ExampleClusterAlgo(energyCut,nXtalCut); }
ExampleClusterProducer::~ExampleClusterProducer | ( | ) |
bool ExampleClusterProducer::counterExceeded | ( | ) | const [inline, private] |
Definition at line 41 of file ExampleClusterProducer.h.
References nEvt_, and nMaxPrintout_.
{ 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(), and edm::Event::put().
{ using namespace edm; // handle to the product Handle< EcalRecHitCollection > pRecHits; // fetch the product evt.getByLabel( hitProducer_, hitCollection_, pRecHits); if (!pRecHits.isValid()) { edm::LogError("ExampleClusterProducerError") << "Error! can't get the product " << hitCollection_.c_str() ; } // pointer to the object in the product const EcalRecHitCollection* rechits = pRecHits.product(); edm::LogInfo("ExampleClusterProducerInfo") << "total # calibrated rechits: " << rechits->size() ; // output collection of basic clusters // reco::BasicClusterCollection defined in BasicClusterFwd.h // make the clusters by passing rechits to the agorithm std::auto_ptr< reco::BasicClusterCollection > clusters( new reco::BasicClusterCollection(algo_->makeClusters( *rechits )) ); // put the product in the event evt.put( clusters, clusterCollection_ ); }
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] |
Definition at line 39 of file ExampleClusterProducer.h.
Referenced by counterExceeded().
int ExampleClusterProducer::nMaxPrintout_ [private] |
Definition at line 38 of file ExampleClusterProducer.h.
Referenced by counterExceeded(), and ExampleClusterProducer().