CMS 3D CMS Logo

TT6CMNSubtractor.cc
Go to the documentation of this file.
2 
5 #include <cmath>
6 
8  if (noiseWatcher_.check(es)) {
10  }
11  if (qualityWatcher_.check(es)) {
13  }
14 }
15 
16 void TT6CMNSubtractor::subtract(uint32_t detId, uint16_t firstAPV, std::vector<int16_t>& digis) {
17  subtract_(detId, firstAPV, digis);
18 }
19 void TT6CMNSubtractor::subtract(uint32_t detId, uint16_t firstAPV, std::vector<float>& digis) {
20  subtract_(detId, firstAPV, digis);
21 }
22 
23 template <typename T>
24 inline void TT6CMNSubtractor::subtract_(uint32_t detId, uint16_t firstAPV, std::vector<T>& digis) {
25  short FixedBias = 128;
26  SiStripNoises::Range detNoiseRange = noiseHandle->getRange(detId);
27  SiStripQuality::Range detQualityRange = qualityHandle->getRange(detId);
28 
29  typename std::vector<T>::iterator fs, ls;
30  double sumVal = 0.0;
31  double sumWt = 0.0;
32 
33  for (uint16_t istrip = 0; istrip < digis.size(); ++istrip) {
34  if (!qualityHandle->IsStripBad(detQualityRange, istrip + firstAPV * 128)) {
35  float stripNoise = noiseHandle->getNoiseFast(istrip + firstAPV * 128, detNoiseRange);
36 
37  if (std::abs(digis[istrip] - FixedBias) < cut_to_avoid_signal_ * stripNoise) {
38  double nWeight = 1 / (stripNoise * stripNoise);
39  sumVal += (digis[istrip] - FixedBias) * nWeight;
40  sumWt += nWeight;
41  }
42  }
43 
44  if (istrip % 128 == 127) {
45  double CM = (sumWt) ? sumVal / sumWt : 0.0;
46 
47  fs = digis.begin() + istrip - 127;
48  ls = digis.begin() + istrip + 1;
49 
50  while (fs < ls) {
51  *fs = static_cast<T>(*fs - FixedBias - CM);
52  fs++;
53  }
54 
55  sumVal = 0.0;
56  sumWt = 0.0;
57  }
58  }
59 }
void subtract_(uint32_t detId, uint16_t firstAPV, std::vector< T > &digis)
void subtract(uint32_t detId, uint16_t firstAPV, std::vector< int16_t > &digis) override
edm::ESWatcher< SiStripQualityRcd > qualityWatcher_
const SiStripNoises * noiseHandle
const Range getRange(const uint32_t detID) const
edm::ESWatcher< SiStripNoisesRcd > noiseWatcher_
static float getNoiseFast(const uint16_t &strip, const Range &range)
Definition: SiStripNoises.h:68
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool getData(T &iHolder) const
Definition: EventSetup.h:122
def ls(path, rec=False)
Definition: eostools.py:349
const SiStripQuality * qualityHandle
bool IsStripBad(uint32_t detid, short strip) const
void init(const edm::EventSetup &es) override
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
const Range getRange(const uint32_t detID) const
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
std::pair< ContainerIterator, ContainerIterator > Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:47
long double T