CMS 3D CMS Logo

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