CMS 3D CMS Logo

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