LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LCTrackerConf.h
Go to the documentation of this file.
1 #ifndef LCTrackerConf_h
2 #define LCTrackerConf_h 1
3 
4 #include <string>
5 #include "UTIL/BitField64.h"
6 
7 namespace UTIL {
8 
9 
24 
25 
26  enum {
27  subdetID = 0 ,
28  sideID = 1 ,
29  layerID = 2 ,
30  moduleID = 3 ,
31  sensorID = 4 ,
32  } ;
33 
34 
35  public:
36 
38  static LCTrackerCellID _me ;
39  return _me ;
40  }
41 
43  static unsigned subdet() { return subdetID ; }
44 
46  static unsigned side() { return sideID ; }
47 
49  static unsigned layer() { return layerID ; }
50 
52  static unsigned module() { return moduleID ; }
53 
55  static unsigned sensor() { return sensorID ; }
56 
57  // get the current encoding string
58  static const std::string& encoding_string() {
59  instance()._accessed = true;
60  return instance()._encoding ;
61  }
62 
64  static std::string valueString( unsigned val ){
67  encoder.setValue( val ) ;
68  return encoder.valueString() ;
69  }
70 
72  void set_encoding_string( const std::string& encodingString ) {
73  if( _accessed ) throw std::logic_error( "The encoding string was already accessed! Changing it now will lead to inconsistencies! Fix your code!" );
74 
75  bool isValid = true ;
76 
77  unsigned long long subdetPos = encodingString.find( "subdet" );
78  unsigned long long systemPos = encodingString.find( "system" );
79  unsigned long long sidePos = encodingString.find( "side" ) ;
80  unsigned long long layerPos = encodingString.find( "layer" ) ;
81  unsigned long long modulePos = encodingString.find( "module" ) ;
82  unsigned long long sensorPos = encodingString.find( "sensor" ) ;
83 
84  isValid = ( (subdetPos != std::string::npos || systemPos != std::string::npos) &&
85  sidePos != std::string::npos &&
86  layerPos != std::string::npos &&
87  modulePos != std::string::npos &&
88  sensorPos != std::string::npos &&
89  (
90  (( subdetPos < sidePos ) || (systemPos < sidePos ) ) &&
91  ( sidePos < layerPos ) &&
92  ( layerPos < modulePos ) &&
93  ( modulePos < sensorPos)
94  )
95  );
96 
97  if( ! isValid ) throw std::runtime_error(" LCTrackerCellID::set_encoding_string(): string needs to contain"
98  " \"subdet:A,side:B,layer:C,module:D,sensor:E\" " ) ;
99 
100  _encoding = encodingString;
101  }
102 
104  void setAccessed() {
105  _accessed = true;
106  }
107 
108 
109  protected:
111  LCTrackerCellID() : _encoding("subdet:5,side:-2,layer:9,module:8,sensor:8" ),
112  _accessed(false) {}
113 
115  bool _accessed;
116  } ;
117 
118 }
119 
120 #endif
LCTrackerCellID()
c&#39;tor initialize the encoding string with the &#39;canonical&#39; encoding
void setAccessed()
set accessed to true
static LCTrackerCellID & instance()
Definition: LCTrackerConf.h:37
static unsigned layer()
index of layer in cellID
Definition: LCTrackerConf.h:49
static std::string valueString(unsigned val)
return a string with the details of the given id:
Definition: LCTrackerConf.h:64
void set_encoding_string(const std::string &encodingString)
set the encoding string. Throws exception if it was already accessed to prevent inconsistencies ...
Definition: LCTrackerConf.h:72
A bit field of 64bits that allows convenient declaration and manipulation of sub fields of various wi...
Definition: BitField64.h:132
std::string valueString() const
Return a string with a comma separated list of the current sub field values.
Definition: BitField64.cc:122
static unsigned side()
index of side in cellID
Definition: LCTrackerConf.h:46
STL class.
static unsigned module()
index of module in cellID
Definition: LCTrackerConf.h:52
static unsigned sensor()
index of sensor in cellID
Definition: LCTrackerConf.h:55
static const std::string & encoding_string()
Definition: LCTrackerConf.h:58
void setValue(lcio::long64 value)
Set a new 64bit value.
Definition: BitField64.h:172
T find(T...args)
STL class.
static unsigned subdet()
index of subdet in cellID
Definition: LCTrackerConf.h:43
Singleton helper class defining the cellID encoding used in the LC tracking packages.
Definition: LCTrackerConf.h:23