CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ExampleClusterProducer Class Reference

#include <ExampleClusterProducer.h>

Inheritance diagram for ExampleClusterProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

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

ExampleClusterAlgoalgo_
std::string clusterCollection_
std::string hitCollection_
std::string hitProducer_
int nEvt_
int nMaxPrintout_

Detailed Description

example of producer for BasicCluster from recHits

Id:
ExampleClusterProducer.h,v 1.1 2006/04/13 14:40:05 rahatlou Exp
Date:
2006/04/13 14:40:05
Revision:
1.1
Author:
Shahram Rahatlou, University of Rome & INFN, April 2006

Definition at line 21 of file ExampleClusterProducer.h.


Constructor & Destructor Documentation

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 ( )

Definition at line 31 of file ExampleClusterProducer.cc.

References algo_.

                                                {
 delete algo_;
}

Member Function Documentation

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_ );
}

Member Data Documentation

Definition at line 36 of file ExampleClusterProducer.h.

Referenced by ExampleClusterProducer(), and produce().

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().

Definition at line 39 of file ExampleClusterProducer.h.

Referenced by counterExceeded().

Definition at line 38 of file ExampleClusterProducer.h.

Referenced by counterExceeded(), and ExampleClusterProducer().