1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include "CalibTracker/SiStripAPVAnalysis/interface/MedianCommonModeCalculator.h"
#include <cmath>
using namespace std;
MedianCommonModeCalculator::MedianCommonModeCalculator()
: // theNoiseCalculator(noise_calc),
// theApvMask(mask_calc),
alreadyUsedEvent(false) {
if (false)
cout << "Constructing MedianCommonMode Calculator ..." << endl;
// cutToAvoidSignal = sig_cut;
}
//
// Destructor
//
MedianCommonModeCalculator::~MedianCommonModeCalculator() {
if (false)
cout << "Destructing TT6CommonModeCalculator " << endl;
}
//
// Action :
//
ApvAnalysis::PedestalType MedianCommonModeCalculator::doIt(const ApvAnalysis::PedestalType& _indat) {
ApvAnalysis::PedestalType indat = _indat;
ApvAnalysis::PedestalType out;
calculateCommonMode(indat);
int setNumber;
if (!theCommonModeValues.empty()) {
for (unsigned int i = 0; i < indat.size(); i++) {
setNumber = theTkCommonMode->topology().setOfStrip(i);
out.push_back(indat[i] - theCommonModeValues[setNumber]);
}
} else {
out = indat;
}
return out;
}
//
// Calculation of Common Mode Values :
//
void MedianCommonModeCalculator::calculateCommonMode(ApvAnalysis::PedestalType& indat) {
if (alreadyUsedEvent == false) {
alreadyUsedEvent = true;
theCommonModeValues.clear();
double avVal = 0.0;
sort(indat.begin(), indat.end());
uint16_t index = indat.size() % 2 ? indat.size() / 2 : indat.size() / 2 - 1;
if (!indat.empty()) {
avVal = indat[index];
}
theCommonModeValues.push_back(static_cast<float>(avVal));
MedianCommonModeCalculator::setCM(theCommonModeValues);
}
}
//
// Define New Event
//
void MedianCommonModeCalculator::newEvent() { alreadyUsedEvent = false; }
|