#include <CellUniqueId.h>
Public Types | |
| enum | { kLvl = 3, kFac = 1000 } |
Public Member Functions | |
| CellUniqueId () | |
| CellUniqueId (const char *path) | |
| void | Set (const char *path) |
| bool | operator!= (const CellUniqueId &rhs) const |
| bool | operator== (const CellUniqueId &rhs) const |
| bool | operator< (const CellUniqueId &rhs) const |
| bool | operator<= (const CellUniqueId &rhs) const |
| bool | operator> (const CellUniqueId &rhs) const |
| bool | operator>= (const CellUniqueId &rhs) const |
| ClassDef (CellUniqueId, 1) | |
Public Attributes | |
| unsigned long int | fId [kLvl] |
Definition at line 15 of file CellUniqueId.h.
|
|
Definition at line 30 of file CellUniqueId.h.
|
|
|
Definition at line 14 of file CellUniqueId.cxx.
|
|
|
Definition at line 22 of file CellUniqueId.cxx. References Set().
00023 {
00024 this->Set(path);
00025 }
|
|
||||||||||||
|
|
|
|
Definition at line 102 of file CellUniqueId.cxx.
|
|
|
Definition at line 111 of file CellUniqueId.cxx.
|
|
|
Definition at line 123 of file CellUniqueId.cxx.
|
|
|
Definition at line 93 of file CellUniqueId.cxx.
|
|
|
Definition at line 135 of file CellUniqueId.cxx.
|
|
|
Definition at line 147 of file CellUniqueId.cxx.
|
|
|
Setting a unique id is a somewhat tricky busines. To save memory, the ROOT TGeo classes re-used physical volumes. So, if the material and geometry for all the cells is the same, they will be represented by the same object. A volume in the detector is then uniquely identified by the "path" to that volume. In the TGeo classes this is represented by a string of the format: World_1/BigVolume_4/SmallVolume_6/TinyVolume_9 The numbers in the path are the "copy" numbers for the volumes. To make look ups faster, this routine maps this string path name to a long integer number. In the above case, that number would be 1004006009. Due to the depth of the geometry, these integers can become quite large. To ensure that enough digits are available, they are stored in three long ints (fId[0-2])
Definition at line 48 of file CellUniqueId.cxx. References fId, kFac, and kLvl. Referenced by geo::CellGeo::CellGeo(), CellUniqueId(), geo::Geometry::CurrentCell(), geo::Geometry::CurrentCellId(), and novamc::MCApplication::Stepping().
00049 {
00050 register int i, j=0, k;
00051 char buff[8]; // Will hold the digits extracted from 'path'
00052 bool lastisnumber = false; // Was the last charater seen in 'path' a digit?
00053
00054 fId[0] = fId[1] = fId[2] = 0;
00055 memset(buff,'\0',8*sizeof(char));
00056
00057 // Loop over all charaters in 'path'
00058 for (i=0; ; ++i) {
00059 // If current character in the string is a digit, copy it to the
00060 // buffer
00061 if (path[i]>='0' && path[i]<='9') {
00062 buff[j] = path[i];
00063 ++j;
00064 lastisnumber = true;
00065 }
00066 else {
00067 // If the current charater in the string is not a digit, but the
00068 // last character was, the number in 'buff' is complete and
00069 // ready to be added to the unique id
00070 if (lastisnumber) {
00071 for (k=0; k<kLvl; ++k) {
00072 // Check if the k'th component of fId has already saturated
00073 // the size of a ULONG. If yes, continue to the next
00074 // component.
00075 if (fId[k]>0 && ULONG_MAX/fId[k]<kFac) continue;
00076 fId[k] += kFac*fId[k] + atoi(buff);
00077 break;
00078 }
00079 // Clear the buffer to ready ourselves for the next digit in
00080 // the string
00081 memset(buff, '\0', 8*sizeof(char));
00082 j = 0;
00083 }
00084 lastisnumber = false;
00085 }
00086 // Are we done parsing 'path'?
00087 if (path[i] == '\0') break;
00088 }
00089 }
|
|
|
Definition at line 34 of file CellUniqueId.h. Referenced by CellUniqueId(), geo::Geometry::CurrentCell(), geo::Geometry::IdToCell(), main(), geo::Geometry::MakeIdMap(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and Set(). |
1.3.5