CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/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   doAPVEmulatorCheck_(conf.existsAs<bool>("DoAPVEmulatorCheck") ? conf.getParameter<bool>("DoAPVEmulatorCheck") : true)
00024 {
00025   if ( edm::isDebugEnabled() ) {
00026     LogTrace("SiStripRawToCluster")
00027       << "[RawToClusters::" << __func__ << "]"
00028       << " Constructing object...";
00029   }
00030   produces<LazyGetter>();
00031 
00032 }
00033 
00034   RawToClusters::~RawToClusters() {
00035     if ( edm::isDebugEnabled() ) {
00036       LogTrace("SiStripRawToCluster")
00037         << "[RawToClusters::" << __func__ << "]"
00038         << " Destructing object...";
00039     }
00040   }
00041 
00042   void RawToClusters::beginRun( edm::Run&, const edm::EventSetup& setup) {
00043     updateCabling( setup );  
00044     clusterizer_->initialize(setup);
00045     rawAlgos_->initialize(setup);
00046   }
00047 
00048   void RawToClusters::produce( edm::Event& event,const edm::EventSetup& setup ) {
00049   
00050     // update cabling
00051     updateCabling( setup );  
00052     clusterizer_->initialize( setup );
00053     rawAlgos_->initialize( setup );
00054   
00055     // get raw data
00056     edm::Handle<FEDRawDataCollection> buffers;
00057     event.getByLabel( productLabel_, buffers ); 
00058 
00059     // create lazy unpacker
00060     boost::shared_ptr<LazyUnpacker> unpacker( new LazyUnpacker( *cabling_, *clusterizer_, *rawAlgos_, *buffers ) );
00061 
00062     // propagate the parameter doAPVEmulatorCheck_ to the unpacker.
00063     unpacker->doAPVEmulatorCheck(doAPVEmulatorCheck_);
00064 
00065     // create lazy getter
00066     std::auto_ptr<LazyGetter> collection( new LazyGetter( cabling_->getRegionCabling().size() * SiStripRegionCabling::ALLSUBDETS * SiStripRegionCabling::ALLLAYERS, unpacker ) );
00067   
00068     // add collection to the event
00069     event.put( collection );
00070   
00071   }
00072 
00073   void RawToClusters::updateCabling( const edm::EventSetup& setup ) {
00074 
00075     uint32_t cache_id = setup.get<SiStripRegionCablingRcd>().cacheIdentifier();
00076     if ( cacheId_ != cache_id ) {
00077       edm::ESHandle<SiStripRegionCabling> c;
00078       setup.get<SiStripRegionCablingRcd>().get( c );
00079       cabling_ = c.product();
00080       cacheId_ = cache_id;
00081     }
00082   }
00083 
00084 }