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 }
TkCommonModeTopology::initialStrips
std::vector< int > & initialStrips()
Definition: TkCommonModeTopology.h:26
mps_fire.i
i
Definition: mps_fire.py:355
funct::false
false
Definition: Factorize.h:34
TkApvMask::MaskType
std::vector< StripMaskType > MaskType
Definition: TkApvMask.h:15
TT6CommonModeCalculator::setCM
void setCM(TkCommonMode *in) override
Definition: TT6CommonModeCalculator.h:19
TkCommonModeTopology::setOfStrip
int setOfStrip(int)
Definition: TkCommonModeTopology.cc:3
gather_cfg.cout
cout
Definition: gather_cfg.py:144
TkApvMask
Definition: TkApvMask.h:9
TkNoiseCalculator
Definition: TkNoiseCalculator.h:10
TkCommonModeTopology::finalStrips
std::vector< int > & finalStrips()
Definition: TkCommonModeTopology.h:27
TT6CommonModeCalculator::~TT6CommonModeCalculator
~TT6CommonModeCalculator() override
Definition: TT6CommonModeCalculator.cc:14
TT6CommonModeCalculator::slope
float slope
Definition: TT6CommonModeCalculator.h:35
TT6CommonModeCalculator::calculateCommonMode
void calculateCommonMode(ApvAnalysis::PedestalType &)
Definition: TT6CommonModeCalculator.cc:39
TkApvMask::mask
virtual MaskType mask()=0
TT6CommonModeCalculator::theTkCommonMode
TkCommonMode * theTkCommonMode
Definition: TT6CommonModeCalculator.h:30
alignCSCRings.s
s
Definition: alignCSCRings.py:92
TT6CommonModeCalculator::calculateCMSlope
void calculateCMSlope(ApvAnalysis::PedestalType &)
Definition: TT6CommonModeCalculator.cc:79
TkCommonModeTopology::numberOfSets
int numberOfSets() const
Definition: TkCommonModeTopology.h:22
TT6CommonModeCalculator.h
TkNoiseCalculator::noise
virtual ApvAnalysis::PedestalType noise() const =0
TkApvMask::ok
Definition: TkApvMask.h:13
TT6CommonModeCalculator::newEvent
void newEvent() override
Definition: TT6CommonModeCalculator.cc:75
TT6CommonModeCalculator::alreadyUsedEvent
bool alreadyUsedEvent
Definition: TT6CommonModeCalculator.h:34
TT6CommonModeCalculator::theApvMask
TkApvMask * theApvMask
Definition: TT6CommonModeCalculator.h:33
std
Definition: JetResolutionObject.h:76
TT6CommonModeCalculator::theNoiseCalculator
TkNoiseCalculator * theNoiseCalculator
Definition: TT6CommonModeCalculator.h:32
TT6CommonModeCalculator::cutToAvoidSignal
float cutToAvoidSignal
Definition: TT6CommonModeCalculator.h:37
TT6CommonModeCalculator::theCommonModeValues
std::vector< float > theCommonModeValues
Definition: TT6CommonModeCalculator.h:31
TT6CommonModeCalculator::doIt
ApvAnalysis::PedestalType doIt(const ApvAnalysis::PedestalType &) override
Definition: TT6CommonModeCalculator.cc:21
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ApvAnalysis::PedestalType
std::vector< float > PedestalType
Definition: ApvAnalysis.h:44
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
TkCommonMode::topology
virtual TkCommonModeTopology & topology()
Definition: TkCommonMode.h:17
TT6CommonModeCalculator::TT6CommonModeCalculator
TT6CommonModeCalculator(TkNoiseCalculator *noise_calc, TkApvMask *mask_calc, float sig_cut)
Definition: TT6CommonModeCalculator.cc:5