CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 //
24 {
26  calculateCommonMode(indat);
27  int setNumber;
28  if(theCommonModeValues.size() >0) {
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 {
43  if (alreadyUsedEvent == false) {
44  alreadyUsedEvent = true;
45  // cout<< "I am inside the calculateCommonMode"<<endl;
46  TkApvMask::MaskType strip_mask = theApvMask->mask();
48  theCommonModeValues.clear();
49 
50  if(strip_noise.size() > 0) {
51  int nSet = theTkCommonMode->topology().numberOfSets();
52  for (int i=0; i<nSet; i++){
53  int initial = theTkCommonMode->topology().initialStrips()[i];
54  int final = theTkCommonMode->topology().finalStrips()[i];
55  double sumVal = 0.0;
56  double sumWt = 0.0;
57  for (int j = initial; j <= final; j++) {
58  if (strip_mask[j] == TkApvMask::ok ) {
59  if(fabs(indat[j]) < cutToAvoidSignal*strip_noise[j]) {
60  double nWeight = 1/(strip_noise[j]*strip_noise[j]);
61  sumVal += (indat[j]*nWeight);
62  sumWt += nWeight;
63  }
64  }
65  }
66  double avVal = (sumWt) ? sumVal/sumWt :0.0;
67  theCommonModeValues.push_back(static_cast<float>(avVal));
68  //cout <<"Setting CM values"<<endl;
69  }
70  }
71  }
73  calculateCMSlope(indat);
74 }
75 //
76 // Define New Event
77 //
79  alreadyUsedEvent = false;
80 }
81 //
82 // Calculate CMSlope
83 //
85  if (indat.size() != 128) {
86  slope = -100.0;
87  return;
88  }
90  diffVec.clear();
91  for(int s=0;s<64;s++) diffVec.push_back(indat[s+64]-indat[s]);
92  std::sort(diffVec.begin(),diffVec.end());
93  slope = (diffVec[31]+diffVec[32])/2./64.;
94 }
95 
std::vector< StripMaskType > MaskType
Definition: TkApvMask.h:15
int i
Definition: DBlmapReader.cc:9
std::vector< float > PedestalType
Definition: ApvAnalysis.h:48
std::vector< int > & initialStrips()
ApvAnalysis::PedestalType doIt(ApvAnalysis::PedestalType)
std::vector< int > & finalStrips()
virtual ApvAnalysis::PedestalType noise() const =0
void calculateCommonMode(ApvAnalysis::PedestalType &)
int j
Definition: DBlmapReader.cc:9
TkNoiseCalculator * theNoiseCalculator
tuple out
Definition: dbtoconf.py:99
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)
tuple cout
Definition: gather_cfg.py:121