CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusterizer.cc

Go to the documentation of this file.
00001 #include "RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusterizer.h"
00002 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00003 #include "RecoLocalTracker/SiStripClusterizer/interface/StripClusterizerAlgorithmFactory.h"
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "boost/foreach.hpp"
00006 
00007 SiStripClusterizer::
00008 SiStripClusterizer(const edm::ParameterSet& conf) 
00009   : inputTags( conf.getParameter<std::vector<edm::InputTag> >("DigiProducersList") ),
00010     algorithm( StripClusterizerAlgorithmFactory::create(conf.getParameter<edm::ParameterSet>("Clusterizer")) ) {
00011   produces< edmNew::DetSetVector<SiStripCluster> > ();
00012 }
00013 
00014 void SiStripClusterizer::
00015 produce(edm::Event& event, const edm::EventSetup& es)  {
00016 
00017   std::auto_ptr< edmNew::DetSetVector<SiStripCluster> > output(new edmNew::DetSetVector<SiStripCluster>());
00018   output->reserve(10000,4*10000);
00019 
00020   edm::Handle< edm::DetSetVector<SiStripDigi> >     inputOld;  
00021   edm::Handle< edmNew::DetSetVector<SiStripDigi> >  inputNew;  
00022 
00023   algorithm->initialize(es);  
00024 
00025   BOOST_FOREACH( const edm::InputTag& tag, inputTags) {
00026     if(      findInput( tag, inputOld, event) ) algorithm->clusterize(*inputOld, *output); 
00027     else if( findInput( tag, inputNew, event) ) algorithm->clusterize(*inputNew, *output);
00028     else edm::LogError("Input Not Found") << "[SiStripClusterizer::produce] " << tag;
00029   }
00030 
00031   LogDebug("Output") << output->dataSize() << " clusters from " 
00032                      << output->size()     << " modules";
00033   event.put(output);
00034 }
00035 
00036 template<class T>
00037 inline
00038 bool SiStripClusterizer::
00039 findInput(const edm::InputTag& tag, edm::Handle<T>& handle, const edm::Event& e) {
00040     e.getByLabel( tag, handle);
00041     return handle.isValid();
00042 }