CMS 3D CMS Logo

TT6CommonModeCalculator.cc
Go to the documentation of this file.
2 #include <cmath>
3 
4 using namespace std;
6  : theNoiseCalculator(noise_calc), theApvMask(mask_calc), alreadyUsedEvent(false) {
7  if (false)
8  cout << "Constructing TT6CommonMode Calculator ..." << endl;
9  cutToAvoidSignal = sig_cut;
10 }
11 //
12 // Destructor
13 //
15  if (false)
16  cout << "Destructing TT6CommonModeCalculator " << endl;
17 }
18 //
19 // Action :
20 //
22  ApvAnalysis::PedestalType indat = _indat;
24  calculateCommonMode(indat);
25  int setNumber;
26  if (!theCommonModeValues.empty()) {
27  for (unsigned int i = 0; i < indat.size(); i++) {
28  setNumber = theTkCommonMode->topology().setOfStrip(i);
29  out.push_back(indat[i] - theCommonModeValues[setNumber]);
30  }
31  } else {
32  out = indat;
33  }
34  return out;
35 }
36 //
37 // Calculation of Common Mode Values :
38 //
40  if (alreadyUsedEvent == false) {
41  alreadyUsedEvent = true;
42  // cout<< "I am inside the calculateCommonMode"<<endl;
43  TkApvMask::MaskType strip_mask = theApvMask->mask();
45  theCommonModeValues.clear();
46 
47  if (!strip_noise.empty()) {
48  int nSet = theTkCommonMode->topology().numberOfSets();
49  for (int i = 0; i < nSet; i++) {
50  int initial = theTkCommonMode->topology().initialStrips()[i];
51  int final = theTkCommonMode->topology().finalStrips()[i];
52  double sumVal = 0.0;
53  double sumWt = 0.0;
54  for (int j = initial; j <= final; j++) {
55  if (strip_mask[j] == TkApvMask::ok) {
56  if (fabs(indat[j]) < cutToAvoidSignal * strip_noise[j]) {
57  double nWeight = 1 / (strip_noise[j] * strip_noise[j]);
58  sumVal += (indat[j] * nWeight);
59  sumWt += nWeight;
60  }
61  }
62  }
63  double avVal = (sumWt) ? sumVal / sumWt : 0.0;
64  theCommonModeValues.push_back(static_cast<float>(avVal));
65  //cout <<"Setting CM values"<<endl;
66  }
67  }
68  }
70  calculateCMSlope(indat);
71 }
72 //
73 // Define New Event
74 //
76 //
77 // Calculate CMSlope
78 //
80  if (indat.size() != 128) {
81  slope = -100.0;
82  return;
83  }
85  diffVec.clear();
86  for (int s = 0; s < 64; s++)
87  diffVec.push_back(indat[s + 64] - indat[s]);
88  std::sort(diffVec.begin(), diffVec.end());
89  slope = (diffVec[31] + diffVec[32]) / 2. / 64.;
90 }
std::vector< StripMaskType > MaskType
Definition: TkApvMask.h:15
std::vector< float > PedestalType
Definition: ApvAnalysis.h:44
virtual ApvAnalysis::PedestalType noise() const =0
std::vector< int > & initialStrips()
void setCM(TkCommonMode *in) override
std::vector< int > & finalStrips()
void calculateCommonMode(ApvAnalysis::PedestalType &)
TkNoiseCalculator * theNoiseCalculator
TT6CommonModeCalculator(TkNoiseCalculator *noise_calc, TkApvMask *mask_calc, float sig_cut)
virtual TkCommonModeTopology & topology()
Definition: TkCommonMode.h:17
void calculateCMSlope(ApvAnalysis::PedestalType &)
std::vector< float > theCommonModeValues
virtual MaskType mask()=0
ApvAnalysis::PedestalType doIt(const ApvAnalysis::PedestalType &) override