CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/EventFilter/SiStripRawToDigi/plugins/SiStripRawToClusters.cc

Go to the documentation of this file.
00001 #include "EventFilter/SiStripRawToDigi/plugins/SiStripRawToClusters.h"
00002 #include "CalibTracker/Records/interface/SiStripRegionCablingRcd.h"
00003 #include "CalibFormats/SiStripObjects/interface/SiStripRegionCabling.h"
00004 #include "DataFormats/Common/interface/Handle.h"
00005 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00006 #include "FWCore/Framework/interface/Event.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 #include "FWCore/Framework/interface/ESHandle.h"
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 #include "RecoLocalTracker/SiStripClusterizer/interface/StripClusterizerAlgorithmFactory.h"
00011 #include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripRawProcessingFactory.h"
00012 
00013 using namespace std;
00014 
00015 namespace sistrip {
00016 
00017 RawToClusters::RawToClusters( const edm::ParameterSet& conf ) :
00018   productLabel_(conf.getParameter<edm::InputTag>("ProductLabel")),
00019   cabling_(0),
00020   cacheId_(0),
00021   clusterizer_(StripClusterizerAlgorithmFactory::create(conf.getParameter<edm::ParameterSet>("Clusterizer"))),
00022   rawAlgos_(SiStripRawProcessingFactory::create(conf.getParameter<edm::ParameterSet>("Algorithms")))
00023 {
00024   if ( edm::isDebugEnabled() ) {
00025     LogTrace("SiStripRawToCluster")
00026       << "[RawToClusters::" << __func__ << "]"
00027       << " Constructing object...";
00028   }
00029   produces<LazyGetter>();
00030 }
00031 
00032   RawToClusters::~RawToClusters() {
00033     if ( edm::isDebugEnabled() ) {
00034       LogTrace("SiStripRawToCluster")
00035         << "[RawToClusters::" << __func__ << "]"
00036         << " Destructing object...";
00037     }
00038   }
00039 
00040   void RawToClusters::beginRun( edm::Run&, const edm::EventSetup& setup) {
00041     updateCabling( setup );  
00042     clusterizer_->initialize(setup);
00043     rawAlgos_->initialize(setup);
00044   }
00045 
00046   void RawToClusters::produce( edm::Event& event,const edm::EventSetup& setup ) {
00047   
00048     // update cabling
00049     updateCabling( setup );  
00050     clusterizer_->initialize( setup );
00051     rawAlgos_->initialize( setup );
00052   
00053     // get raw data
00054     edm::Handle<FEDRawDataCollection> buffers;
00055     event.getByLabel( productLabel_, buffers ); 
00056 
00057     // create lazy unpacker
00058     boost::shared_ptr<LazyUnpacker> unpacker( new LazyUnpacker( *cabling_, *clusterizer_, *rawAlgos_, *buffers ) );
00059 
00060     // create lazy getter
00061     std::auto_ptr<LazyGetter> collection( new LazyGetter( cabling_->getRegionCabling().size() * SiStripRegionCabling::ALLSUBDETS * SiStripRegionCabling::ALLLAYERS, unpacker ) );
00062   
00063     // add collection to the event
00064     event.put( collection );
00065   
00066   }
00067 
00068   void RawToClusters::updateCabling( const edm::EventSetup& setup ) {
00069 
00070     uint32_t cache_id = setup.get<SiStripRegionCablingRcd>().cacheIdentifier();
00071     if ( cacheId_ != cache_id ) {
00072       edm::ESHandle<SiStripRegionCabling> c;
00073       setup.get<SiStripRegionCablingRcd>().get( c );
00074       cabling_ = c.product();
00075       cacheId_ = cache_id;
00076     }
00077   }
00078 
00079 }