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 {
10  if (false) cout << "Constructing MedianCommonMode Calculator ..." << endl;
11  // cutToAvoidSignal = sig_cut;
12 }
13 //
14 // Destructor
15 //
17  if (false) cout << "Destructing TT6CommonModeCalculator " << endl;
18 }
19 //
20 // Action :
21 //
23  (const ApvAnalysis::PedestalType& _indat)
24 {
25  ApvAnalysis::PedestalType indat = _indat;
27  calculateCommonMode(indat);
28  int setNumber;
29  if(!theCommonModeValues.empty()) {
30  for (unsigned int i=0; i<indat.size(); i++){
31  setNumber = theTkCommonMode->topology().setOfStrip(i);
32  out.push_back(indat[i] - theCommonModeValues[setNumber]);
33  }
34  }else{
35  out = indat;
36  }
37  return out;
38 }
39 //
40 // Calculation of Common Mode Values :
41 //
43 {
44  if (alreadyUsedEvent == false) {
45  alreadyUsedEvent = true;
46 
47  theCommonModeValues.clear();
48 
49 
50  double avVal = 0.0;
51 
52  sort(indat.begin(),indat.end());
53 
54  uint16_t index = indat.size()%2 ? indat.size()/2 : indat.size()/2-1;
55  if ( !indat.empty() ) { avVal = indat[index]; }
56 
57  theCommonModeValues.push_back(static_cast<float>(avVal));
58 
60 
61  }
62 
63 }
64 
65 //
66 // Define New Event
67 //
69  alreadyUsedEvent = false;
70 }
std::vector< float > PedestalType
Definition: ApvAnalysis.h:48
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