EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HoughCell.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HoughCell.cxx
1 //
2 // AYK (ayk@bnl.gov)
3 //
4 // Hough transform code elementary cell structure;
5 //
6 // Initial port from OLYMPUS sources: Oct'2015;
7 //
8 
9 #include <HoughTree.h>
10 #include <HoughCell.h>
11 
12 // ---------------------------------------------------------------------------------------
13 
14 HoughCell::HoughCell(const HoughTree *tree): mDaughters(0)
15 {
16  unsigned gdim = tree->GetGdim();
17 
18  // Allocate cell range arrays and reset elements to the __OUT_OF_RANGE_BIT_ values;
19  mFrom = new t_hough_range[gdim];
20  mTo = new t_hough_range[gdim];
21 
22  ResetRanges(tree);
23 } // HoughCell::HoughCell()
24 
25 // ---------------------------------------------------------------------------------------
26 
27 void HoughCell::ResetRanges(const HoughTree *tree, bool immunity[])
28 {
29  // Yes, it is easier to have both mFrom/mTo limits reset;
30  for(unsigned gr=0; gr<tree->GetGdim(); gr++)
31  // Some of the entries should NOT be modified -> check on that;
32  if (!immunity || !immunity[gr])
33  mFrom[gr] = mTo[gr] = __OUT_OF_RANGE_BIT_;
34 } // HoughCell::ResetRanges()
35 
36 // ---------------------------------------------------------------------------------------
37 
38 void HoughCell::UpdateRanges(const HoughTree *tree, const t_hough_range id[])
39 {
40  for(unsigned gr=0; gr<tree->GetGdim(); gr++) {
41  // Mask out out-of-range bit, it does not matter here;
42  t_hough_range range = id[gr] & ~__OUT_OF_RANGE_BIT_;
43 
44  // FIXME: unify the below stuff in one loop?;
45  if (mFrom[gr] == __OUT_OF_RANGE_BIT_)
46  mFrom[gr] = range;
47  else {
48  t_hough_range value = 0x0;
49 
50  for(unsigned iq=0; iq<tree->GetGroup(gr)->GetCoordDescr().size(); iq++) {
51  const CoordinateDescriptor *descr = &tree->GetGroup(gr)->GetCoordDescr()[iq];
52 
53  t_hough_range is = descr->UnpackCoord(mFrom[gr]);
54  t_hough_range offer = descr->UnpackCoord(range);
55 
56  value |= descr->PackCoord(offer < is ? offer : is);
57  } //for iq
58 
59  mFrom[gr] = value;
60  } //if
61 
62  if (mTo[gr] == __OUT_OF_RANGE_BIT_)
63  mTo[gr] = range;
64  else {
65  t_hough_range value = 0x0;
66 
67  for(unsigned iq=0; iq<tree->GetGroup(gr)->GetCoordDescr().size(); iq++) {
68  const CoordinateDescriptor *descr = &tree->GetGroup(gr)->GetCoordDescr()[iq];
69 
70  t_hough_range is = descr->UnpackCoord(mTo[gr]);
71  t_hough_range offer = descr->UnpackCoord(range);
72 
73  value |= descr->PackCoord(offer > is ? offer : is);
74  } //for iq
75 
76  mTo[gr] = value;
77  } //if
78  } //for gr
79 } // HoughCell::UpdateRanges()
80 
81 // ---------------------------------------------------------------------------------------