CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ExampleClusterProducer.cc
Go to the documentation of this file.
5 
9 
10 #include <vector>
11 
13 
14 
15  // use onfiguration file to setup input/output collection names
16  nMaxPrintout_ = ps.getUntrackedParameter<int>("nMaxPrintout",1);
17 
18  hitProducer_ = ps.getParameter<std::string>("hitProducer");
19  hitCollection_ = ps.getParameter<std::string>("hitCollection");
20  clusterCollection_ = ps.getParameter<std::string>("clusterCollection");
21 
22 
23  // configure your algorithm via ParameterSet
24  double energyCut = ps.getUntrackedParameter<double>("energyCut",0.);
25  int nXtalCut = ps.getUntrackedParameter<int>("nXtalCut",-1);
26 
27  algo_ = new ExampleClusterAlgo(energyCut,nXtalCut);
28 
29 }
30 
32  delete algo_;
33 }
34 
35 
36 void
38 
39  using namespace edm;
40 
41  // handle to the product
43 
44  // fetch the product
45  evt.getByLabel( hitProducer_, hitCollection_, pRecHits);
46  if (!pRecHits.isValid()) {
47  edm::LogError("ExampleClusterProducerError") << "Error! can't get the product " << hitCollection_.c_str() ;
48  }
49 
50  // pointer to the object in the product
51  const EcalRecHitCollection* rechits = pRecHits.product();
52  edm::LogInfo("ExampleClusterProducerInfo") << "total # calibrated rechits: " << rechits->size() ;
53 
54  // output collection of basic clusters
55  // reco::BasicClusterCollection defined in BasicClusterFwd.h
56 
57  // make the clusters by passing rechits to the agorithm
58  std::auto_ptr< reco::BasicClusterCollection >
59  clusters( new reco::BasicClusterCollection(algo_->makeClusters( *rechits )) );
60 
61  // put the product in the event
62  evt.put( clusters, clusterCollection_ );
63 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ExampleClusterAlgo * algo_
reco::BasicClusterCollection makeClusters(const EcalRecHitCollection &rechits)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
virtual void produce(edm::Event &evt, const edm::EventSetup &es)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
ExampleClusterProducer(const edm::ParameterSet &ps)