CMS 3D CMS Logo

LASProfileJudge.cc
Go to the documentation of this file.
1 
2 
4 
5 // terminal colors
6 #define _R "\033[1;31m"
7 #define _B "\033[1;34m"
8 #define _G "\033[1;32m"
9 #define _N "\033[22;30m"
10 
14 LASProfileJudge::LASProfileJudge() : overdriveThreshold(0) {
15  // switch on the zero filter by default
16  isZeroFilter = true;
17 }
18 
24 bool LASProfileJudge::IsSignalIn(const LASModuleProfile& aProfile, double offset) {
25  profile = aProfile;
26 
27  // need only approx values, so cast here to use integers throughout
28  const int approxOffset = static_cast<int>(offset);
29 
30  const double negativity = GetNegativity(approxOffset);
31  const bool isPeaks = IsPeaksInProfile(approxOffset);
32  const bool isNegativePeaks = IsNegativePeaksInProfile(approxOffset);
33 
34  bool result = (negativity < -1000.) || // if we see negativity, there was laser..
35  (isPeaks) || // if we see a peak, " " "
36  (isNegativePeaks); // same here
37 
38  return (result);
39 }
40 
45 bool LASProfileJudge::JudgeProfile(const LASModuleProfile& aProfile, double offset = 0.) {
46  profile = aProfile;
47 
48  // need only approx values, so cast here to use integers throughout
49  const int approxOffset = static_cast<int>(offset);
50 
51  // run the tests
52  const double negativity = GetNegativity(approxOffset);
53 
54  bool isPeaks;
55  if (!isZeroFilter)
56  isPeaks = true; // disable this test if set in cfg
57  else
58  isPeaks = IsPeaksInProfile(approxOffset);
59 
60  const bool isNegativePeaks = IsNegativePeaksInProfile(approxOffset);
61 
62  bool isOverdrive; // disable this test if set in cfg
63  if (!isZeroFilter)
64  isOverdrive = false;
65  else
66  isOverdrive = IsOverdrive(approxOffset);
67 
68  bool result = (negativity > -1000.) && // < 1000. = distorted profile
69  (isPeaks) && // want to see a peak (zero filter)
70  !(isNegativePeaks) && // no negative peaks
71  !(isOverdrive); // no overdrive
72 
73  return (result);
74 }
75 
79 void LASProfileJudge::EnableZeroFilter(bool zeroFilter) {
80  if (!zeroFilter) {
81  std::cerr << " [LASProfileJudge::EnableZeroFilter] ** WARNING: Zero filter has been disabled." << std::endl;
82  }
83 
84  isZeroFilter = zeroFilter;
85 }
86 
90 void LASProfileJudge::SetOverdriveThreshold(unsigned int aThreshold) { overdriveThreshold = aThreshold; }
91 
98  // here we could later run the sum only on the affected (pair of) APV
99 
100  // expected beam position (in strips)
101  const unsigned int meanPosition = 256 + offset;
102  // backplane "alignment hole" (="signal region") approx. half size
103  const unsigned int halfWindowSize = 33;
104  // half size of range over which is summed (must be > halfWindowSize)
105  const unsigned int sumHalfRange = 128;
106 
107  double neg = 0;
108 
109  // need only x values, so cast here
110  for (unsigned int i = meanPosition - sumHalfRange; i < meanPosition - halfWindowSize; ++i) {
111  neg += profile.GetValue(i);
112  }
113 
114  for (unsigned int i = meanPosition + halfWindowSize; i < meanPosition + sumHalfRange; ++i) {
115  neg += profile.GetValue(i);
116  }
117 
118  return (neg);
119 }
120 
126  // expected beam position (in strips)
127  const unsigned int meanPosition = 256 + offset;
128  // backplane "alignment hole" approx. half size (in strips)
129  const unsigned int halfWindowSize = 33;
130 
131  bool returnValue = false;
132 
133  // calculate average out-of-signal
134  double average = 0., counterD = 0.;
135  for (unsigned int strip = 0; strip < 512; ++strip) {
136  if (strip < meanPosition - halfWindowSize || strip > meanPosition + halfWindowSize) {
138  counterD += 1.;
139  }
140  }
141  average /= counterD;
142 
143  // find peaks well above noise level
144  const double noiseLevel = 2.; // to be softcoded..
145  for (unsigned int strip = meanPosition - halfWindowSize; strip < meanPosition + halfWindowSize; ++strip) {
146  if (profile.GetValue(strip) > (average + 10. * noiseLevel)) {
147  returnValue = true;
148  thePeak.first = strip;
149  thePeak.second = profile.GetValue(strip);
150  break;
151  }
152  }
153 
154  return (returnValue);
155 }
156 
162  // expected beam position in middle of module (in strips)
163  const unsigned int meanPosition = 256 + offset;
164  // backplane "alignment hole" approx. half size (in strips)
165  const unsigned int halfWindowSize = 33;
166 
167  bool returnValue = false;
168 
169  // calculate average out-of-signal
170  double average = 0., counterD = 0.;
171  for (unsigned int strip = 0; strip < 512; ++strip) {
172  if (strip < meanPosition - halfWindowSize || strip > meanPosition + halfWindowSize) {
174  counterD += 1.;
175  }
176  }
177  average /= counterD;
178 
179  // find strips with negative amplitude way above noise level
180  const double noiseLevel = 2.;
181  for (unsigned int strip = 0; strip < 512; ++strip) {
182  if (profile.GetValue(strip) < (average - 10. * noiseLevel)) {
183  returnValue = true;
184  thePeak.first = strip;
185  thePeak.second = profile.GetValue(strip);
186  break;
187  }
188  }
189 
190  return (returnValue);
191 }
192 
198  // expected beam position in middle of module (in strips)
199  const unsigned int meanPosition = 256 + offset;
200  // backplane "alignment hole" approx. half size (in strips)
201  const unsigned int halfWindowSize = 33;
202 
203  // find maximum strip amplitude in range
204  for (unsigned int strip = meanPosition - halfWindowSize; strip < meanPosition + halfWindowSize; ++strip) {
206  return true;
207  }
208 
209  return false;
210 }
mps_fire.i
i
Definition: mps_fire.py:355
LASModuleProfile::GetValue
double GetValue(unsigned int theStripNumber) const
Definition: LASModuleProfile.h:19
LASProfileJudge::IsOverdrive
bool IsOverdrive(int)
Definition: LASProfileJudge.cc:197
LASProfileJudge::SetOverdriveThreshold
void SetOverdriveThreshold(unsigned int)
Definition: LASProfileJudge.cc:90
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
LASProfileJudge::GetNegativity
double GetNegativity(int)
Definition: LASProfileJudge.cc:97
LASProfileJudge::JudgeProfile
bool JudgeProfile(const LASModuleProfile &, double)
Definition: LASProfileJudge.cc:45
LASProfileJudge::EnableZeroFilter
void EnableZeroFilter(bool)
Definition: LASProfileJudge.cc:79
LASProfileJudge::IsNegativePeaksInProfile
bool IsNegativePeaksInProfile(int)
Definition: LASProfileJudge.cc:161
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
LASProfileJudge::profile
LASModuleProfile profile
Definition: LASProfileJudge.h:28
average
Definition: average.py:1
LASProfileJudge::thePeak
std::pair< unsigned int, double > thePeak
Definition: LASProfileJudge.h:29
LASProfileJudge::isZeroFilter
bool isZeroFilter
Definition: LASProfileJudge.h:30
LASProfileJudge::IsPeaksInProfile
bool IsPeaksInProfile(int)
Definition: LASProfileJudge.cc:125
fftjetproducer_cfi.noiseLevel
noiseLevel
Definition: fftjetproducer_cfi.py:90
LASProfileJudge::IsSignalIn
bool IsSignalIn(const LASModuleProfile &, double)
Definition: LASProfileJudge.cc:24
LASProfileJudge::overdriveThreshold
unsigned int overdriveThreshold
Definition: LASProfileJudge.h:31
mps_fire.result
result
Definition: mps_fire.py:303
LASProfileJudge::LASProfileJudge
LASProfileJudge()
Definition: LASProfileJudge.cc:14
LASModuleProfile
Definition: LASModuleProfile.h:7
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:78
LASProfileJudge.h