Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:15

0001 #include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripPedestalsSubtractor.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 
0005 void SiStripPedestalsSubtractor::init(const edm::EventSetup& es) {
0006   if (pedestalsWatcher_.check(es)) {
0007     pedestalsHandle = &es.getData(pedestalsToken_);
0008   }
0009 }
0010 
0011 void SiStripPedestalsSubtractor::subtract(uint32_t detId, uint16_t firstStrip, std::vector<int16_t>& digis) {
0012   subtract_(detId, firstStrip, digis, digis);
0013 }
0014 void SiStripPedestalsSubtractor::subtract(const edm::DetSet<SiStripRawDigi>& input, std::vector<int16_t>& output) {
0015   subtract_(input.id, 0, input, output);
0016 }
0017 
0018 template <class input_t>
0019 inline void SiStripPedestalsSubtractor::subtract_(uint32_t id,
0020                                                   uint16_t firstStrip,
0021                                                   const input_t& input,
0022                                                   std::vector<int16_t>& output) {
0023   try {
0024     pedestals.resize(firstStrip + input.size());
0025     SiStripPedestals::Range pedestalsRange = pedestalsHandle->getRange(id);
0026     pedestalsHandle->allPeds(pedestals, pedestalsRange);
0027 
0028     typename input_t::const_iterator inDigi = input.begin();
0029     std::vector<int>::const_iterator ped = pedestals.begin() + firstStrip;
0030     std::vector<int16_t>::iterator outDigi = output.begin();
0031 
0032     while (inDigi != input.end()) {
0033       *outDigi = eval(*inDigi) - *ped + ((*ped > 895) ? 1024 : 0);
0034 
0035       if (fedmode_ && *outDigi < 0)  //FED bottoms out at 0
0036         *outDigi = 0;
0037 
0038       ++inDigi;
0039       ++ped;
0040       ++outDigi;
0041     }
0042 
0043   } catch (cms::Exception& e) {
0044     edm::LogError("SiStripPedestalsSubtractor") << "[SiStripPedestalsSubtractor::subtract] DetId " << id
0045                                                 << " propagating error from SiStripPedestal" << e.what();
0046     output.clear();
0047   }
0048 }