CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/RecoLocalTracker/SiStripZeroSuppression/src/SiStripPedestalsSubtractor.cc

Go to the documentation of this file.
00001 #include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripPedestalsSubtractor.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "CondFormats/DataRecord/interface/SiStripPedestalsRcd.h"
00004 #include "FWCore/Utilities/interface/Exception.h"
00005 
00006 void SiStripPedestalsSubtractor::init(const edm::EventSetup& es){
00007   uint32_t p_cache_id = es.get<SiStripPedestalsRcd>().cacheIdentifier();
00008   if(p_cache_id != peds_cache_id) {
00009     es.get<SiStripPedestalsRcd>().get(pedestalsHandle);
00010     peds_cache_id = p_cache_id;
00011   }
00012 }
00013 
00014 void SiStripPedestalsSubtractor::subtract(const uint32_t& id, const uint16_t& firstStrip, std::vector<int16_t>& digis) {subtract_(id, firstStrip, digis, digis);}
00015 void SiStripPedestalsSubtractor::subtract(const edm::DetSet<SiStripRawDigi>& input, std::vector<int16_t>& output) {subtract_(input.id, 0, input, output);}
00016 
00017 template <class input_t>
00018 inline
00019 void SiStripPedestalsSubtractor::
00020 subtract_(const uint32_t& id, const uint16_t& firstStrip, const input_t& input, std::vector<int16_t>& output) {
00021   try {
00022 
00023     pedestals.resize(firstStrip + input.size());
00024     SiStripPedestals::Range pedestalsRange = pedestalsHandle->getRange(id);
00025     pedestalsHandle->allPeds(pedestals, pedestalsRange);
00026 
00027     typename input_t::const_iterator inDigi = input.begin();
00028     std::vector<int>::const_iterator ped = pedestals.begin() + firstStrip;  
00029     std::vector<int16_t>::iterator   outDigi = output.begin();
00030 
00031     while( inDigi != input.end() ) {
00032       
00033       *outDigi = ( *ped > 895 )        
00034         ? eval(*inDigi) - *ped + 1024
00035         : eval(*inDigi) - *ped;
00036       
00037       if(fedmode_ && *outDigi < 0) //FED bottoms out at 0
00038         *outDigi=0;
00039       
00040       ++inDigi; 
00041       ++ped; 
00042       ++outDigi;
00043     }
00044 
00045 
00046   } catch(cms::Exception& e){
00047     edm::LogError("SiStripPedestalsSubtractor")  
00048       << "[SiStripPedestalsSubtractor::subtract] DetId " << id << " propagating error from SiStripPedestal" << e.what();
00049     output.clear();
00050   }
00051 
00052 }