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),
7  theApvMask(mask_calc),
8  alreadyUsedEvent(false)
9 {
10  if (0) cout << "Constructing TT6CommonMode Calculator ..." << endl;
11  cutToAvoidSignal = sig_cut;
12 }
13 //
14 // Destructor
15 //
17  if (0) 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.size() >0) {
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  // cout<< "I am inside the calculateCommonMode"<<endl;
47  TkApvMask::MaskType strip_mask = theApvMask->mask();
49  theCommonModeValues.clear();
50 
51  if(strip_noise.size() > 0) {
52  int nSet = theTkCommonMode->topology().numberOfSets();
53  for (int i=0; i<nSet; i++){
54  int initial = theTkCommonMode->topology().initialStrips()[i];
55  int final = theTkCommonMode->topology().finalStrips()[i];
56  double sumVal = 0.0;
57  double sumWt = 0.0;
58  for (int j = initial; j <= final; j++) {
59  if (strip_mask[j] == TkApvMask::ok ) {
60  if(fabs(indat[j]) < cutToAvoidSignal*strip_noise[j]) {
61  double nWeight = 1/(strip_noise[j]*strip_noise[j]);
62  sumVal += (indat[j]*nWeight);
63  sumWt += nWeight;
64  }
65  }
66  }
67  double avVal = (sumWt) ? sumVal/sumWt :0.0;
68  theCommonModeValues.push_back(static_cast<float>(avVal));
69  //cout <<"Setting CM values"<<endl;
70  }
71  }
72  }
74  calculateCMSlope(indat);
75 }
76 //
77 // Define New Event
78 //
80  alreadyUsedEvent = false;
81 }
82 //
83 // Calculate CMSlope
84 //
86  if (indat.size() != 128) {
87  slope = -100.0;
88  return;
89  }
91  diffVec.clear();
92  for(int s=0;s<64;s++) diffVec.push_back(indat[s+64]-indat[s]);
93  std::sort(diffVec.begin(),diffVec.end());
94  slope = (diffVec[31]+diffVec[32])/2./64.;
95 }
96 
std::vector< StripMaskType > MaskType
Definition: TkApvMask.h:17
std::vector< float > PedestalType
Definition: ApvAnalysis.h:48
virtual ApvAnalysis::PedestalType noise() const =0
std::vector< int > & initialStrips()
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
void setCM(TkCommonMode *in)
ApvAnalysis::PedestalType doIt(const ApvAnalysis::PedestalType &)