CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/EventFilter/ESRawToDigi/src/ESUnpackerWorker.cc

Go to the documentation of this file.
00001 #include "EventFilter/ESRawToDigi/interface/ESUnpackerWorker.h"
00002 
00003 #include "RecoLocalCalo/EcalRecProducers/interface/ESRecHitWorkerFactory.h"
00004 
00005 
00006 ESUnpackerWorker::ESUnpackerWorker(const edm::ParameterSet & conf){
00007   
00008   edm::ParameterSet DCCpset = conf.getParameter<edm::ParameterSet>("DCCDataUnpacker");
00009   ESUnpacker_ = new ESUnpacker(DCCpset);
00010   
00011   edm::ParameterSet  RH = conf.getParameter<edm::ParameterSet>("RHAlgo");
00012   std::string componentType =  RH.getParameter<std::string>("Type");
00013   RHWorker_ = ESRecHitWorkerFactory::get()->create(componentType, RH);
00014 
00015 }
00016 
00017 ESUnpackerWorker::~ESUnpackerWorker(){
00018   delete ESUnpacker_;
00019   delete RHWorker_;
00020 }
00021 
00022 void ESUnpackerWorker::setHandles(const EcalUnpackerWorkerRecord & iRecord) {
00023 
00024 }
00025 
00026 void ESUnpackerWorker::set(const edm::EventSetup & es) const {
00027   RHWorker_->set(es);
00028 }
00029 
00030 void ESUnpackerWorker::write(edm::Event & e) const{
00031 
00032 }
00033 
00034 void ESUnpackerWorker::update(const edm::Event & e)const{
00036   evt=&e;
00037 }
00038 
00039 
00040 std::auto_ptr< EcalRecHitCollection > ESUnpackerWorker::work(const uint32_t & index, const FEDRawDataCollection & rawdata)const{
00041   MyWatcher watcher("Worker");
00042   LogDebug("ESRawToRecHit|Worker")<<"is going to work on index: "<<index
00043                                   <<watcher.lap();
00044 
00045   int fedIndex = EcalRegionCabling::esFedIndex(index);
00046 
00047 
00048   const FEDRawData & fedData = rawdata.FEDData(fedIndex);
00049 
00050   //###### get the digi #######
00051   ESRawDataCollection productDCC;
00052   ESLocalRawDataCollection productKCHIP;
00053   ESDigiCollection productdigis;
00054 
00055   ESUnpacker_->interpretRawData(fedIndex, fedData, productDCC, productKCHIP, productdigis);
00056   
00057   LogDebug("ESRawToRecHit|Worker")<<"unpacked "<<productdigis.size()<<" digis"
00058                                   <<watcher.lap();
00059 
00060 
00061   //then make rechits
00062   ESDigiCollection::const_iterator beginDigiES = productdigis.begin();
00063   ESDigiCollection::const_iterator endDigiES = productdigis.end();
00064 
00065   std::auto_ptr< EcalRecHitCollection > ecalrechits( new EcalRecHitCollection );
00066 
00067   ecalrechits->reserve(productdigis.size());
00068   
00069   ESDigiCollection::const_iterator esIt=beginDigiES;
00070   for (;esIt!=endDigiES;++esIt){
00071     RHWorker_->run( *evt, esIt, *ecalrechits );
00072   }
00073 
00074   LogDebug("ESRawToRecHit|Worker")<<" made : "<<ecalrechits->size()<<" es rechits"
00075                                   <<watcher.lap();
00076 
00077   return ecalrechits;
00078 }
00079