EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResolutionLevel.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ResolutionLevel.cxx
1 //
2 // AYK (ayk@bnl.gov)
3 //
4 // Resolution level description;
5 //
6 // Initial port from OLYMPUS sources: Oct'2015;
7 //
8 
9 // Yes, unfortunately I need HoughTree include here;
10 #include <HoughTree.h>
11 #include <ResolutionLevel.h>
12 
13 // ---------------------------------------------------------------------------------------
14 
15 ResolutionLevel::ResolutionLevel(const HoughTree *tree, const unsigned div[])
16 {
17  unsigned ddim = tree->GetDdim(), ldim = tree->GetLdim();
18 
19  {
20  mParameterSplit = new unsigned[ddim];
21  mTotalDivisionNum = new unsigned[ddim];
22  mCellSize = new double [ddim];
23 
24  // THINK: really needed?;
25  if (!div || !mParameterSplit || !mTotalDivisionNum || !mCellSize) throw;
26  }
27 
28  mDaughterCellNum = 1;
29 
30  {
31  for(int iq=0; iq<ddim; iq++) {
32  mParameterSplit[iq] = div[iq];
33  mTotalDivisionNum [iq] = (ldim == 0 ? 1 : tree->GetLevel(ldim-1)->mTotalDivisionNum[iq])*div[iq];
34 
35  // And cell size, please;
36  {
37  const HoughDimension *dimension = tree->GetDimension(iq);
38 
39  mCellSize[iq] = (dimension->GetMax() - dimension->GetMin())/mTotalDivisionNum[iq];
40  }
41 
43  } //for iq
44  }
45 
46  // FIXME: suitable for 2D & 3D parameter space only;
47  if (tree->GetVerbosityLevel() >= 1)
48  printf("lv=%2d -> accu=%5d/%5d/%5d; mCellSize[]: %8.3f %8.3f %8.3f\n",
50  ddim == 2 ? 0 : mTotalDivisionNum [2],
51  mCellSize[0], mCellSize[1], ddim == 2 ? 0.0 : mCellSize[2]);
52 
53  mTotalCellNum = (ldim == 0 ? 1 : tree->GetLevel(ldim-1)->mTotalCellNum)*mDaughterCellNum;
54 
55  mRemap = new unsigned[mDaughterCellNum*ddim];
56  // THINK: really needed?;
57  if (!mRemap) throw;
58 
59  {
60  // In 4D case id(a,b,c,d) = a*d2*d3*d4 + b*d3*d4 + c*d4 + d; sdim[] is just
61  // array of coefficients by {a,b,c,d};
62  unsigned sdim[ddim];
63 
64  for(int iq=ddim-1; iq>=0; iq--)
65  sdim[iq] = iq == ddim-1 ? 1 : mParameterSplit[iq+1]*sdim[iq+1];
66 
67  // Loop through all the entries and fill the array out;
68  for(unsigned ip=0; ip<mDaughterCellNum; ip++) {
69  // Figure out 1D-indices;
70  unsigned curr = ip;
71 
72  // NB: indices in mRemap[] array are sort of swapped for convenience;
73  for(int iq=0; iq<ddim; iq++) {
74  mRemap[ip+iq*mDaughterCellNum] = curr / sdim[iq];
75  curr -= mRemap[ip+iq*mDaughterCellNum]*sdim[iq];
76  } //for iq
77  } //for ip
78  }
79 } // ResolutionLevel::ResolutionLevel()
80 
81 // ---------------------------------------------------------------------------------------