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 }
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
TT6CMNSubtractor::noiseToken_
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
Definition: TT6CMNSubtractor.h:29
TT6CMNSubtractor::qualityHandle
const SiStripQuality * qualityHandle
Definition: TT6CMNSubtractor.h:32
SiStripNoises::getNoiseFast
static float getNoiseFast(const uint16_t &strip, const Range &range)
Definition: SiStripNoises.h:68
SiStripBadStrip::getRange
const Range getRange(const uint32_t detID) const
Definition: SiStripBadStrip.cc:27
TT6CMNSubtractor::init
void init(const edm::EventSetup &es) override
Definition: TT6CMNSubtractor.cc:7
TT6CMNSubtractor.h
TT6CMNSubtractor::qualityToken_
edm::ESGetToken< SiStripQuality, SiStripQualityRcd > qualityToken_
Definition: TT6CMNSubtractor.h:30
SiStripNoises.h
SiStripNoises::getRange
const Range getRange(const uint32_t detID) const
Definition: SiStripNoises.cc:34
SiStripBadStrip::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripBadStrip.h:53
SiStripNoises::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripNoises.h:47
SiStripQuality::IsStripBad
bool IsStripBad(const uint32_t &detid, const short &strip) const
Definition: SiStripQuality.cc:623
TT6CMNSubtractor::cut_to_avoid_signal_
double cut_to_avoid_signal_
Definition: TT6CMNSubtractor.h:28
TT6CMNSubtractor::subtract_
void subtract_(uint32_t detId, uint16_t firstAPV, std::vector< T > &digis)
Definition: TT6CMNSubtractor.cc:24
edm::EventSetup
Definition: EventSetup.h:58
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
TT6CMNSubtractor::qualityWatcher_
edm::ESWatcher< SiStripQualityRcd > qualityWatcher_
Definition: TT6CMNSubtractor.h:34
TT6CMNSubtractor::noiseWatcher_
edm::ESWatcher< SiStripNoisesRcd > noiseWatcher_
Definition: TT6CMNSubtractor.h:33
SiStripQuality.h
TT6CMNSubtractor::subtract
void subtract(uint32_t detId, uint16_t firstAPV, std::vector< int16_t > &digis) override
Definition: TT6CMNSubtractor.cc:16
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TT6CMNSubtractor::noiseHandle
const SiStripNoises * noiseHandle
Definition: TT6CMNSubtractor.h:31