CMS 3D CMS Logo

CSCDQM_StripClusterFinder.cc
Go to the documentation of this file.
1 
3 
4 namespace cscdqm {
5 
6  StripClusterFinder::StripClusterFinder(int l, int s, int cf, int st) {
7  //
8  // Options
9  //
10  // fOpt = new CalibOptions();
11  LayerNmb = l;
12  TimeSliceNmb = s;
13  StripNmb = cf * 16;
14  }
15  void StripClusterFinder::DoAction(int LayerId, float* Cathodes) {
16  int TimeId, StripId;
17  this->LId = LayerId;
18  MEStripClusters.clear();
19  StripClusterFitData PulseHeightMapTMP;
20 
21  thePulseHeightMap.clear();
22 
23  // fill
24  //===========================================================================
25 
26  for (StripId = 0; StripId < StripNmb; StripId++) {
27  for (TimeId = 0; TimeId < TimeSliceNmb; TimeId++) {
28  PulseHeightMapTMP.height_[TimeId] = *(Cathodes + StripNmb * (TimeSliceNmb * LayerId + TimeId) + StripId);
29  }
30  PulseHeightMapTMP.bx_ = 0;
31  PulseHeightMapTMP.channel_ = StripId; // was StripId
32  thePulseHeightMap.push_back(PulseHeightMapTMP);
33  }
34  sort(thePulseHeightMap.begin(), thePulseHeightMap.end(), Sort());
35  //===========================================================================
36 
37  if (thePulseHeightMap.empty())
38  return;
39  SearchMax();
40  SearchBorders();
41  Match();
42  RefindMax();
43  /*
44  int val;
45  for(i=0;i<MEStripClusters.size();i++){
46  val=MEStripClusters[i].LFTBNDStrip;
47  MEStripClusters[i].LFTBNDStrip=thePulseHeightMap[val].channel_;
48  val=MEStripClusters[i].IRTBNDStrip;
49  MEStripClusters[i].IRTBNDStrip=thePulseHeightMap[val].channel_;
50  for(j=0;j<MEStripClusters[i].localMax.size();j++){
51  val=MEStripClusters[i].localMax[j].Strip;
52  MEStripClusters[i].localMax[j].Strip=thePulseHeightMap[val].channel_;
53  }
54  }
55  */
56 
57  float sumstrip;
58  float sumtime;
59  float sumheight;
60 
61  for (i = 0; i < MEStripClusters.size(); i++) {
62  MEStripClusters[i].ClusterPulseMapHeight.clear();
63  for (j = 0; j < thePulseHeightMap.size(); j++) {
64  if (thePulseHeightMap[j].channel_ >= MEStripClusters[i].LFTBNDStrip &&
65  thePulseHeightMap[j].channel_ <= MEStripClusters[i].IRTBNDStrip)
66  MEStripClusters[i].ClusterPulseMapHeight.push_back(thePulseHeightMap[j]);
67  }
68  sumstrip = 0;
69  sumtime = 0;
70  sumheight = 0;
71  for (uint32_t k = 0; k < MEStripClusters[i].ClusterPulseMapHeight.size(); k++) {
72  for (int l = 0; l < 16; l++) {
73  sumstrip += MEStripClusters[i].ClusterPulseMapHeight[k].height_[l] *
74  (MEStripClusters[i].ClusterPulseMapHeight[k].channel_ + 1);
75  sumtime += MEStripClusters[i].ClusterPulseMapHeight[k].height_[l] * (l + 1);
76  sumheight += MEStripClusters[i].ClusterPulseMapHeight[k].height_[l];
77  }
78  }
79  if (sumheight) {
80  MEStripClusters[i].Mean[0] = sumstrip / sumheight;
81  MEStripClusters[i].Mean[1] = sumtime / sumheight;
82  }
83  }
84  // printClusters();
85  return;
86  }
87 
89  StripCluster tmpCluster;
90  for (i = 1; i < (thePulseHeightMap.size() - 1); i++) {
91  if (thePulseHeightMap[i].channel_ == 63 || thePulseHeightMap[i].channel_ == 64)
92  continue;
93  for (j = 1; j < 15; j++) {
94  if (thePulseHeightMap[i].height_[j] > thePulseHeightMap[i - 1].height_[j] &&
95  thePulseHeightMap[i].height_[j] > thePulseHeightMap[i + 1].height_[j] &&
96  thePulseHeightMap[i].height_[j] > thePulseHeightMap[i].height_[j - 1] &&
97  thePulseHeightMap[i].height_[j] > thePulseHeightMap[i].height_[j + 1] &&
98  thePulseHeightMap[i].height_[j] > thePulseHeightMap[i - 1].height_[j - 1] &&
99  thePulseHeightMap[i].height_[j] > thePulseHeightMap[i - 1].height_[j + 1] &&
100  thePulseHeightMap[i].height_[j] > thePulseHeightMap[i + 1].height_[j - 1] &&
101  thePulseHeightMap[i].height_[j] > thePulseHeightMap[i + 1].height_[j + 1]) {
102  tmpCluster.localMax.clear();
103  localMaxTMP.Strip = i;
104  localMaxTMP.Time = j;
105  tmpCluster.localMax.push_back(localMaxTMP);
106  tmpCluster.LayerId = this->LId;
107  tmpCluster.LFTBNDTime = -100;
108  tmpCluster.LFTBNDStrip = -100;
109  tmpCluster.IRTBNDTime = -100;
110  tmpCluster.IRTBNDStrip = -100;
111  MEStripClusters.push_back(tmpCluster);
112  }
113  }
114  }
115  return;
116  }
118  uint32_t iS, iT, iL, jL, iR, jR;
119 
120  // SEARCHING PARAMETERS OF THE CLASTERS (LEFT DOWN & RIGHT UP)
121 
122  for (i = 0; i < MEStripClusters.size(); i++) {
123  if (MEStripClusters[i].localMax.empty()) {
124  std::cout << "!!!Warning Cluster has'nt local Maxima" << std::endl;
125  continue;
126  }
127  iS = MEStripClusters[i].localMax[0].Strip;
128  iT = MEStripClusters[i].localMax[0].Time;
129  // LEFT DOWN
130  // strip
131  MEStripClusters[i].LFTBNDStrip = 0;
132  for (iL = iS - 1; iL > 0; iL--) {
133  if (thePulseHeightMap[iL].channel_ == 64) {
134  MEStripClusters[i].LFTBNDStrip = iL;
135  break;
136  }
137  if (thePulseHeightMap[iL].height_[iT] == 0.) {
138  MEStripClusters[i].LFTBNDStrip = iL + 1;
139  break;
140  }
141  }
142  //time
143  MEStripClusters[i].LFTBNDTime = 0;
144  for (jL = iT - 1; jL > 0; jL--) {
145  if (thePulseHeightMap[iS].height_[jL] == 0.) {
146  MEStripClusters[i].LFTBNDTime = jL + 1;
147  break;
148  }
149  }
150  // RIGHT UP
151  //strip
152  MEStripClusters[i].IRTBNDStrip = thePulseHeightMap.size() - 1;
153  for (iR = iS + 1; iR < thePulseHeightMap.size(); iR++) {
154  if (thePulseHeightMap[iR].channel_ == 63) {
155  MEStripClusters[i].IRTBNDStrip = iR;
156  break;
157  }
158  if (thePulseHeightMap[iR].height_[iT] == 0.) {
159  MEStripClusters[i].IRTBNDStrip = iR - 1;
160  break;
161  }
162  }
163  //time
164  MEStripClusters[i].IRTBNDTime = 15;
165  for (jR = iT + 1; jR < 16; jR++) {
166  if (thePulseHeightMap[iS].height_[jR] == 0.) {
167  MEStripClusters[i].IRTBNDTime = jR - 1;
168  break;
169  }
170  }
171  }
172  return;
173  }
174 
176  // MATCHING THE OVERLAPING CLASTERS
177  bool find2match = true;
178  do {
179  find2match = FindAndMatch();
180  } while (find2match);
181 
182  return;
183  }
184 
186  // Find clusters to match
187  icstart = 0;
188  for (ic1 = icstart; ic1 < MEStripClusters.size(); ic1++) {
189  IC1MIN = MEStripClusters[ic1].LFTBNDStrip;
190  IC1MAX = MEStripClusters[ic1].IRTBNDStrip;
191  JC1MIN = MEStripClusters[ic1].LFTBNDTime;
192  JC1MAX = MEStripClusters[ic1].IRTBNDTime;
193  for (ic2 = ic1 + 1; ic2 < MEStripClusters.size(); ic2++) {
194  IC2MIN = MEStripClusters[ic2].LFTBNDStrip;
195  IC2MAX = MEStripClusters[ic2].IRTBNDStrip;
196  JC2MIN = MEStripClusters[ic2].LFTBNDTime;
197  JC2MAX = MEStripClusters[ic2].IRTBNDTime;
198  if ((IC2MIN >= IC1MIN && IC2MIN <= IC1MAX && JC2MIN >= JC1MIN && JC2MIN <= JC1MAX) ||
199  (IC2MIN >= IC1MIN && IC2MIN <= IC1MAX && JC2MAX >= JC1MIN && JC2MAX <= JC1MAX) ||
200  (IC2MAX >= IC1MIN && IC2MAX <= IC1MAX && JC2MIN >= JC1MIN && JC2MIN <= JC1MAX) ||
201  (IC2MAX >= IC1MIN && IC2MAX <= IC1MAX && JC2MAX >= JC1MIN && JC2MAX <= JC1MAX)) {
202  KillCluster();
203  return true;
204  } else {
205  if ((IC1MIN >= IC2MIN && IC1MIN <= IC2MAX && JC1MIN >= JC2MIN && JC1MIN <= JC2MAX) ||
206  (IC1MIN >= IC2MIN && IC1MIN <= IC2MAX && JC1MAX >= JC2MIN && JC1MAX <= JC2MAX) ||
207  (IC1MAX >= IC2MIN && IC1MAX <= IC2MAX && JC1MIN >= JC2MIN && JC1MIN <= JC2MAX) ||
208  (IC1MAX >= IC2MIN && IC1MAX <= IC2MAX && JC1MAX >= JC2MIN && JC1MAX <= JC2MAX)) {
209  KillCluster();
210  return true;
211  }
212  }
213  }
214  }
215  return false;
216  }
218  // Match Clusters and kill one of clusters.
219  if (IC1MIN < IC2MIN)
220  MEStripClusters[ic1].LFTBNDStrip = IC1MIN;
221  else
222  MEStripClusters[ic1].LFTBNDStrip = IC2MIN;
223  if (JC1MIN < JC2MIN)
224  MEStripClusters[ic1].LFTBNDTime = JC1MIN;
225  else
226  MEStripClusters[ic1].LFTBNDTime = JC2MIN;
227  if (IC1MAX > IC2MAX)
228  MEStripClusters[ic1].IRTBNDStrip = IC1MAX;
229  else
230  MEStripClusters[ic1].IRTBNDStrip = IC2MAX;
231  if (JC1MAX > JC2MAX)
232  MEStripClusters[ic1].IRTBNDTime = JC1MAX;
233  else
234  MEStripClusters[ic1].IRTBNDTime = JC2MAX;
235 
236  MEStripClusters.erase(MEStripClusters.begin() + ic2);
237  icstart = ic1;
238 
239  return;
240  }
242  int iLS, iRS, iLT, iRT;
243  int iS, jT;
244  int ilocal;
245  float GlobalMax;
246  bool Erased;
247  // SEARCHING EXTREMUMS IN THE CLASTERS
248 
249  for (i = 0; i < MEStripClusters.size(); i++) {
250  MEStripClusters[i].localMax.clear();
251  ilocal = 0;
252  iLS = MEStripClusters[i].LFTBNDStrip;
253  iRS = MEStripClusters[i].IRTBNDStrip;
254  iLT = MEStripClusters[i].LFTBNDTime;
255  iRT = MEStripClusters[i].IRTBNDTime;
256 
257  /*
258  for(iS=iLS+1;iS<=iRS-1;iS++){
259  for(jT=iLT+1;jT<=iRT-1;jT++){
260  */
261  for (iS = iLS; iS <= iRS; iS++) {
262  if (thePulseHeightMap[iS].channel_ == 63 || thePulseHeightMap[iS].channel_ == 64)
263  continue;
264  for (jT = iLT; jT <= iRT; jT++) {
265  if (iS == 0 || jT == 0 || iS == 79 || jT == 7)
266  continue;
267  if (thePulseHeightMap[iS].height_[jT] > thePulseHeightMap[iS - 1].height_[jT] &&
268  thePulseHeightMap[iS].height_[jT] > thePulseHeightMap[iS + 1].height_[jT] &&
269  thePulseHeightMap[iS].height_[jT] > thePulseHeightMap[iS].height_[jT - 1] &&
270  thePulseHeightMap[iS].height_[jT] > thePulseHeightMap[iS].height_[jT + 1] &&
271  thePulseHeightMap[iS].height_[jT] > thePulseHeightMap[iS - 1].height_[jT - 1] &&
272  thePulseHeightMap[iS].height_[jT] > thePulseHeightMap[iS - 1].height_[jT + 1] &&
273  thePulseHeightMap[iS].height_[jT] > thePulseHeightMap[iS + 1].height_[jT - 1] &&
274  thePulseHeightMap[iS].height_[jT] > thePulseHeightMap[iS + 1].height_[jT + 1]) {
275  localMaxTMP.Strip = iS;
276  localMaxTMP.Time = jT;
277  MEStripClusters[i].localMax.push_back(localMaxTMP);
278  ilocal++;
279  }
280  }
281  }
282  // kill local maximums rellated to noise, maximums with pulse height less then 10% of Global max of clust.
283  //fing Global Max
284  GlobalMax = 0;
285  if (!MEStripClusters[i].localMax.empty()) {
286  //std::cout << "Cluster: " << i << " Number of local maximums before erase: "
287  // << MEStripClusters[i].localMax.size() << std::endl;
288  for (j = 0; j < MEStripClusters[i].localMax.size(); j++) {
289  iS = MEStripClusters[i].localMax[j].Strip;
290  jT = MEStripClusters[i].localMax[j].Time;
291  /*
292  std::cout << "Current Max:"
293  << " " << iS
294  << " " << jT
295  << " " << thePulseHeightMap[iS].height_[jT] << std::endl;
296  */
297  if (thePulseHeightMap[iS].height_[jT] > GlobalMax)
298  GlobalMax = thePulseHeightMap[iS].height_[jT];
299  }
300  GlobalMax = (float)(GlobalMax / 10.);
301  //erase noise localMaximums
302  do {
303  Erased = false;
304  for (j = 0; j < MEStripClusters[i].localMax.size(); j++) {
305  iS = MEStripClusters[i].localMax[j].Strip;
306  jT = MEStripClusters[i].localMax[j].Time;
307  if (thePulseHeightMap[iS].height_[jT] < GlobalMax) {
308  MEStripClusters[i].localMax.erase(MEStripClusters[i].localMax.begin() + j);
309  Erased = true;
310  break;
311  }
312  }
313  } while (Erased);
314 
315  //debug outs
316  //std::cout << "Cluster: " << i << " Number of local maximums: "
317  // << MEStripClusters[i].localMax.size() << std::endl;
318  /*
319  for(j=0;j<MEStripClusters[i].localMax.size();j++){
320  iS=MEStripClusters[i].localMax[j].Strip;
321  jT=MEStripClusters[i].localMax[j].Time;
322  std::cout << "Local Max: " << j << " Strip: " << iS << " Time: " << jT
323  << " Height: " << thePulseHeightMap[iS].height_[jT]
324  << " Cut Value: " << GlobalMax << std::endl;
325  }
326  */
327  }
328  }
329  return;
330  }
332  int iS, jT;
333  std::cout << "====================================================================" << std::endl;
334  std::cout << "debug information from StripClusterFinder" << std::endl;
335  for (i = 0; i < MEStripClusters.size(); i++) {
336  if (MEStripClusters[i].localMax.empty())
337  continue;
338  std::cout << " Cluster: " << i + 1 << " Number of local Maximums " << MEStripClusters[i].localMax.size()
339  << std::endl;
340  for (j = 0; j < MEStripClusters[i].localMax.size(); j++) {
341  iS = MEStripClusters[i].localMax[j].Strip;
342  jT = MEStripClusters[i].localMax[j].Time;
343 
344  // std::cout << "Local Max: " << j << " Strip: " << iS << " Time: " << jT << std::endl;
345  for (uint32_t k = 0; k < MEStripClusters[i].ClusterPulseMapHeight.size(); k++) {
346  if (MEStripClusters[i].ClusterPulseMapHeight[k].channel_ == iS)
347  std::cout << "Local Max: " << j + 1 << " Strip: " << iS + 1 << " Time: " << jT + 1
348  << " Height: " << MEStripClusters[i].ClusterPulseMapHeight[k].height_[jT] << std::endl;
349  }
350  }
351  for (uint32_t k = 0; k < MEStripClusters[i].ClusterPulseMapHeight.size(); k++) {
352  std::cout << "Strip: " << MEStripClusters[i].ClusterPulseMapHeight[k].channel_ + 1;
353  for (int l = 0; l < 16; l++)
354  std::cout << " " << MEStripClusters[i].ClusterPulseMapHeight[k].height_[l];
355  std::cout << std::endl;
356  }
357 
358  std::cout << " Left Top corner strip: " << MEStripClusters[i].LFTBNDStrip + 1 << " "
359  << " time: " << MEStripClusters[i].LFTBNDTime + 1 << std::endl;
360  std::cout << " Right Bottom corner strip: " << MEStripClusters[i].IRTBNDStrip + 1 << " "
361  << " time: " << MEStripClusters[i].IRTBNDTime + 1 << std::endl;
362  }
363  std::cout << "======================================================================" << std::endl;
364  return;
365  }
367  return a.channel_ < b.channel_;
368  }
369 
370 } // namespace cscdqm
cscdqm::ClusterLocalMax::Strip
int Strip
Definition: CSCDQM_ClusterLocalMax.h:15
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
cscdqm::StripClusterFinder::TimeSliceNmb
int TimeSliceNmb
Definition: CSCDQM_StripClusterFinder.h:44
cscdqm::StripClusterFinder::JC2MIN
uint32_t JC2MIN
Definition: CSCDQM_StripClusterFinder.h:43
cscdqm::StripClusterFinder::LayerNmb
int LayerNmb
Definition: CSCDQM_StripClusterFinder.h:44
cscdqm::StripClusterFinder::Match
void Match(void)
Definition: CSCDQM_StripClusterFinder.cc:175
cscdqm::StripClusterFitData
Strip Cluster Fit Data Object.
Definition: CSCDQM_StripClusterFitData.h:12
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cscdqm::StripCluster::LFTBNDStrip
int LFTBNDStrip
Definition: CSCDQM_StripCluster.h:22
cscdqm::StripClusterFinder::JC1MIN
uint32_t JC1MIN
Definition: CSCDQM_StripClusterFinder.h:43
cscdqm::StripClusterFitData::channel_
int channel_
Definition: CSCDQM_StripClusterFitData.h:19
cscdqm::StripClusterFinder::IC2MIN
uint32_t IC2MIN
Definition: CSCDQM_StripClusterFinder.h:43
cscdqm::StripClusterFinder::IC1MAX
uint32_t IC1MAX
Definition: CSCDQM_StripClusterFinder.h:43
cscdqm::StripClusterFinder::localMaxTMP
ClusterLocalMax localMaxTMP
Definition: CSCDQM_StripClusterFinder.h:36
cscdqm::StripClusterFinder::ic1
uint32_t ic1
Definition: CSCDQM_StripClusterFinder.h:43
cscdqm::StripClusterFitData::bx_
float bx_
Definition: CSCDQM_StripClusterFitData.h:21
cscdqm::StripCluster::LFTBNDTime
int LFTBNDTime
Definition: CSCDQM_StripCluster.h:21
alignCSCRings.s
s
Definition: alignCSCRings.py:92
cscdqm::StripClusterFinder::FindAndMatch
bool FindAndMatch(void)
Definition: CSCDQM_StripClusterFinder.cc:185
cscdqm::StripClusterFinder::IC1MIN
uint32_t IC1MIN
Definition: CSCDQM_StripClusterFinder.h:43
cscdqm::StripClusterFinder::thePulseHeightMap
std::vector< StripClusterFitData > thePulseHeightMap
Definition: CSCDQM_StripClusterFinder.h:28
cscdqm::StripClusterFinder::JC2MAX
uint32_t JC2MAX
Definition: CSCDQM_StripClusterFinder.h:43
cscdqm::StripCluster::localMax
std::vector< ClusterLocalMax > localMax
Definition: CSCDQM_StripCluster.h:20
dqmdumpme.k
k
Definition: dqmdumpme.py:60
cscdqm::StripClusterFinder::StripClusterFinder
StripClusterFinder(int l, int s, int cf, int st)
Definition: CSCDQM_StripClusterFinder.cc:6
b
double b
Definition: hdecay.h:118
cscdqm::StripCluster::LayerId
int LayerId
Definition: CSCDQM_StripCluster.h:25
cscdqm::StripClusterFinder::RefindMax
void RefindMax(void)
Definition: CSCDQM_StripClusterFinder.cc:241
cscdqm::StripClusterFinder::SearchMax
void SearchMax(void)
Definition: CSCDQM_StripClusterFinder.cc:88
cscdqm::StripClusterFinder::Sort
Definition: CSCDQM_StripClusterFinder.h:31
a
double a
Definition: hdecay.h:119
cscdqm::StripClusterFinder::j
uint32_t j
Definition: CSCDQM_StripClusterFinder.h:42
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
cscdqm
Definition: CSCDQM_DCSBase.h:29
cscdqm::StripClusterFitData::height_
float height_[16]
Definition: CSCDQM_StripClusterFitData.h:20
cscdqm::StripClusterFinder::MEStripClusters
std::vector< StripCluster > MEStripClusters
Definition: CSCDQM_StripClusterFinder.h:35
cscdqm::StripClusterFinder::DoAction
void DoAction(int layerId, float *cathodes)
Definition: CSCDQM_StripClusterFinder.cc:15
cscdqm::StripClusterFinder::i
uint32_t i
Definition: CSCDQM_StripClusterFinder.h:41
cscdqm::StripClusterFinder::icstart
uint32_t icstart
Definition: CSCDQM_StripClusterFinder.h:43
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
cscdqm::StripCluster::IRTBNDTime
int IRTBNDTime
Definition: CSCDQM_StripCluster.h:23
cscdqm::StripClusterFinder::KillCluster
void KillCluster(void)
Definition: CSCDQM_StripClusterFinder.cc:217
cscdqm::StripClusterFinder::LId
int32_t LId
Definition: CSCDQM_StripClusterFinder.h:40
cscdqm::StripClusterFinder::ic2
uint32_t ic2
Definition: CSCDQM_StripClusterFinder.h:43
cscdqm::StripClusterFinder::StripNmb
int StripNmb
Definition: CSCDQM_StripClusterFinder.h:44
cscdqm::StripClusterFinder::IC2MAX
uint32_t IC2MAX
Definition: CSCDQM_StripClusterFinder.h:43
cscdqm::ClusterLocalMax::Time
int Time
Definition: CSCDQM_ClusterLocalMax.h:14
cscdqm::StripClusterFinder::printClusters
void printClusters(void)
Definition: CSCDQM_StripClusterFinder.cc:331
cscdqm::StripClusterFinder::JC1MAX
uint32_t JC1MAX
Definition: CSCDQM_StripClusterFinder.h:43
cscdqm::StripClusterFinder::SearchBorders
void SearchBorders(void)
Definition: CSCDQM_StripClusterFinder.cc:117
cscdqm::StripClusterFinder::Sort::operator()
bool operator()(const StripClusterFitData &a, const StripClusterFitData &b) const
Definition: CSCDQM_StripClusterFinder.cc:366
cscdqm::StripCluster::IRTBNDStrip
int IRTBNDStrip
Definition: CSCDQM_StripCluster.h:24
cscdqm::StripCluster
Strip Cluster.
Definition: CSCDQM_StripCluster.h:17
CSCDQM_StripClusterFinder.h