Belle II Software development
GlobalLabel Class Reference

Class to convert to/from global labels for Millepede II to/from detector & parameter identificators. More...

#include <GlobalLabel.h>

Classes

struct  TimeInterval
 Struct to hold intervals of validity. More...
 

Public Types

typedef unsigned int gidTYPE
 shortcut for main data type (unsigned int)
 

Public Member Functions

 GlobalLabel ()
 Default constuctor. Members initialized in declaration.
 
 GlobalLabel (gidTYPE globalLabel)
 Constructor from Pede label Depends on registered time dependent parameters if the time flag in the label is non-zero.
 
void construct (gidTYPE dbObjId, gidTYPE element, gidTYPE param)
 Construct label for given DB object id and its element and parameter.
 
void registerTimeDependent (gidTYPE start, gidTYPE end=maxTID)
 Register this Detector element and parameter as time dependent with instance starting at "start" time index and ending at "end" index.
 
gidTYPE setParameterId (gidTYPE paramId)
 Usefull setter to quickly change only the parameter id and return back the encoded label (for use in RecoHits)
 
int label ()
 Returns encoded Pede label.
 
 operator int ()
 Cast to encoded Pede label.
 
 operator unsigned int ()
 Cast to encoded Pede label.
 
gidTYPE getUniqueId () const
 Returns the global id identifing DB object for constantwith this label.
 
gidTYPE getElementId () const
 Returns the element id (like VxdID for silicon sensors) to identify sets of parameters in DB objects.
 
gidTYPE getParameterId () const
 Get id of alignment/calibration parameter.
 
gidTYPE getTimeId () const
 Get time id.
 
bool getTimeFlag () const
 Is label time-dependent?
 
bool isValid ()
 Is label valid? (non-zero)
 
void dump (int level=0) const
 Dumps the label to std::cout.
 
int getEndOfValidity ()
 Get the last time id, where this label is valid.
 
gidTYPE makeEIDPID (gidTYPE eid_, gidTYPE pid_)
 Helper to compose elemnt id & param id.
 
gidTYPE makeTEIDPID (gidTYPE teid_, gidTYPE pid_)
 Helper to compose time elemnt id & param id.
 

Static Public Member Functions

template<class DBObjType >
static GlobalLabel construct (gidTYPE element, gidTYPE param)
 Construct label for given DB object (template argument) and its element and parameter.
 
static void setComponents (const std::set< unsigned short > &components)
 Set which DB objects have non-zero labels (by their id)
 
static void clearTimeDependentParamaters ()
 Forget all previously registered time dependent parameters.
 
static unsigned int & getCurrentTimeIntervalRef ()
 Returns reference to current time id.
 
static void setCurrentTimeInterval (gidTYPE time)
 Sets current time id.
 
static gidTYPE getCurrentTimeInterval ()
 Get current time id.
 
static std::map< gidTYPE, TimeInterval > & getTimeIntervals ()
 Reference to map EIDPID -> (TEIDPID, time intervals)
 
static std::map< gidTYPE, gidTYPE > & getDictionary ()
 Reference to dictionary/map TEIDPID -> EIDPID.
 

Static Public Attributes

static const gidTYPE maxPID = 99
 max 99 parameter types 1..99
 
static const gidTYPE maxEID = 9999999
 max 9.999.999 detector elements 1..9999999 (NOT time-dep-)
 
static const gidTYPE maxTIF = 1
 time-dep.
 
static const gidTYPE maxTEID = 9999
 max time-dep.
 
static const gidTYPE maxTID = 999
 max time slices for a parameter 1..999

 
static const gidTYPE pidOffset = 1
 parameter number are the last 2 decimal digits
 
static const gidTYPE eidOffest = pidOffset * (maxPID + 1)
 Offset of detector element id = 100.
 
static const gidTYPE tifOffset = eidOffest * (maxEID + 1)
 Offset of time flag = 1.000.000.000.
 
static const gidTYPE teidOffset = eidOffest
 Offset of time dependent element(detector+parameter) = 100.
 
static const gidTYPE tidOffset = eidOffest * (maxTEID + 1)
 Offset of time slice id = 1.000.000.
 
static const gidTYPE maxGID
 max internal id = 1.999.999.999
 
static const gidTYPE maxLabel
 Label and internal id ("gid") are the same numbers (label is signed but 0 and <0 values are invalid to give to Pede)
 

Private Member Functions

void construct (gidTYPE elementId, gidTYPE paramId)
 Constructor for any detector.
 

Private Attributes

gidTYPE gid {0}
 global id
 
gidTYPE eid {0}
 element id
 
gidTYPE pid {0}
 parameter id
 
gidTYPE tid {0}
 time id
 
gidTYPE tif {0}
 time identification flag
 

Static Private Attributes

static std::set< unsigned short > m_components = {}
 Set of global ids of components for which to return non-zero labels.
 

Detailed Description

Class to convert to/from global labels for Millepede II to/from detector & parameter identificators.

The labels are in following form (the example shows maximal allowed labels):

|TIF| EID |PID| | 0|9999999 |99 | & TEID=0 & TID=0, or

|TIF|TID|TEID|PID| | 1|999|9999|99 | & (EID,PID)=dictionary(TEID,PID).

where

  • TIF is time flag (0 or 1) for time-dependent parameters,
  • EID is id of detector element (numeric VxdID or WireID + offset),
  • PID is id of alignment/calibration parameter (u/v...),
  • TEID is time-dependent element index (one per time-dep. parameter)
  • TID is time interval id

Definition at line 41 of file GlobalLabel.h.

Member Typedef Documentation

◆ gidTYPE

typedef unsigned int gidTYPE

shortcut for main data type (unsigned int)

Definition at line 45 of file GlobalLabel.h.

Constructor & Destructor Documentation

◆ GlobalLabel() [1/2]

GlobalLabel ( )
inline

Default constuctor. Members initialized in declaration.

Definition at line 62 of file GlobalLabel.h.

62{}

◆ GlobalLabel() [2/2]

GlobalLabel ( GlobalLabel::gidTYPE  globalLabel)
explicit

Constructor from Pede label Depends on registered time dependent parameters if the time flag in the label is non-zero.

Parameters
globalLabelThe encoded label

Definition at line 19 of file GlobalLabel.cc.

19 :
20 gid(0), eid(0), pid(0), tid(0), tif(0)
21{
22 if (globalLabel > maxLabel)
23 return;
24 gid = globalLabel;
25 tif = gid / tifOffset;
27
28 if (!tif) {
30 } else {
31 // Time-dep label
33 gidTYPE teidpid = makeTEIDPID(teid, pid);
34 gidTYPE eidpid = 0;
35 auto& dict = GlobalLabel::getDictionary();
36 auto it = dict.find(teidpid);
37 if (it != dict.end())
38 eidpid = it->second;
39
40 eid = eidpid / eidOffest;
42 }
43}
static const gidTYPE tidOffset
Offset of time slice id = 1.000.000.
Definition: GlobalLabel.h:55
gidTYPE tid
time id
Definition: GlobalLabel.h:305
static const gidTYPE eidOffest
Offset of detector element id = 100.
Definition: GlobalLabel.h:52
gidTYPE gid
global id
Definition: GlobalLabel.h:296
static std::map< gidTYPE, gidTYPE > & getDictionary()
Reference to dictionary/map TEIDPID -> EIDPID.
Definition: GlobalLabel.h:282
static const gidTYPE teidOffset
Offset of time dependent element(detector+parameter) = 100.
Definition: GlobalLabel.h:54
unsigned int gidTYPE
shortcut for main data type (unsigned int)
Definition: GlobalLabel.h:45
static const gidTYPE pidOffset
parameter number are the last 2 decimal digits
Definition: GlobalLabel.h:51
gidTYPE makeTEIDPID(gidTYPE teid_, gidTYPE pid_)
Helper to compose time elemnt id & param id.
Definition: GlobalLabel.h:293
gidTYPE tif
time identification flag
Definition: GlobalLabel.h:308
static const gidTYPE tifOffset
Offset of time flag = 1.000.000.000.
Definition: GlobalLabel.h:53
gidTYPE eid
element id
Definition: GlobalLabel.h:299
static const gidTYPE maxLabel
Label and internal id ("gid") are the same numbers (label is signed but 0 and <0 values are invalid t...
Definition: GlobalLabel.h:58
gidTYPE pid
parameter id
Definition: GlobalLabel.h:302

Member Function Documentation

◆ clearTimeDependentParamaters()

void clearTimeDependentParamaters ( )
static

Forget all previously registered time dependent parameters.

Definition at line 66 of file GlobalLabel.cc.

67{
70}
static std::map< gidTYPE, TimeInterval > & getTimeIntervals()
Reference to map EIDPID -> (TEIDPID, time intervals)
Definition: GlobalLabel.h:274

◆ construct() [1/3]

void construct ( gidTYPE  dbObjId,
gidTYPE  element,
gidTYPE  param 
)
inline

Construct label for given DB object id and its element and parameter.

Parameters
dbObjIdid of the DB object in global calibration
elementElement id in DB object (wire, sensor etc.)
paramParemetr id of the element (shift, angle, etc.)

Definition at line 95 of file GlobalLabel.h.

96 {
97 if (m_components.empty() or m_components.find(dbObjId) != m_components.end())
98 construct(100000 * dbObjId + element, param);
99 else
100 construct(0, 0);
101 }
static GlobalLabel construct(gidTYPE element, gidTYPE param)
Construct label for given DB object (template argument) and its element and parameter.
Definition: GlobalLabel.h:81
static std::set< unsigned short > m_components
Set of global ids of components for which to return non-zero labels.
Definition: GlobalLabel.h:221

◆ construct() [2/3]

static GlobalLabel construct ( gidTYPE  element,
gidTYPE  param 
)
inlinestatic

Construct label for given DB object (template argument) and its element and parameter.

Parameters
elementElement id in DB object (wire, sensor etc.)
paramParemetr id of the element (shift, angle, etc.)
Returns
GlobalLabel

Definition at line 81 of file GlobalLabel.h.

82 {
83 GlobalLabel theLabel;
84 theLabel.construct(DBObjType::getGlobalUniqueID(), element, param);
85 return theLabel;
86 }
GlobalLabel()
Default constuctor. Members initialized in declaration.
Definition: GlobalLabel.h:62

◆ construct() [3/3]

void construct ( GlobalLabel::gidTYPE  elementId,
GlobalLabel::gidTYPE  paramId 
)
private

Constructor for any detector.

Parameters
elementIdUnique id of Belle2 detector element (sensor, layer, wire...)
paramIdid of the parameter of the element

Definition at line 81 of file GlobalLabel.cc.

83{
84 if (elementId > maxEID || paramId > maxPID)
85 return;
86 pid = paramId;
87 eid = elementId;
88
89 gidTYPE eidpid = makeEIDPID(eid, pid);
90 gidTYPE teidpid = 0;
91 auto& ints = GlobalLabel::getTimeIntervals();
92 auto it = ints.find(eidpid);
93 if (it != ints.end())
94 teidpid = it->second.teidpid();
95
96 if (teidpid)
97 tif = 1;
98 else
99 tif = 0;
100
101 if (!tif)
102 gid = (tif * tifOffset + eid * eidOffest + pid * pidOffset);
103 else {
105 gid = (tif * tifOffset + tid * tidOffset + teidpid);
106 }
107 /*
108 if (!teidpid) {
109 // time indep.
110 tif = 0;
111 gid = (tif * tifOffset + eid * eidOffest + pid * pidOffset);
112 }
113 else {
114 tid = it->second.get(GlobalLabel::getCurrentTimeIntervalRef());
115 if (tid == 0) {
116 // actually the first instance of time dep. parameter -> def with orginal time. indep. label
117 //FIXME: code copied from above!
118 tif = 0;
119 gid = (tif * tifOffset + eid * eidOffest + pid * pidOffset);
120 } else {
121 tif = 1;
122 gid = (tif * tifOffset + tid * tidOffset + teidpid);
123 }
124 }
125 */
126}
static const gidTYPE maxEID
max 9.999.999 detector elements 1..9999999 (NOT time-dep-)
Definition: GlobalLabel.h:47
static const gidTYPE maxPID
max 99 parameter types 1..99
Definition: GlobalLabel.h:46
gidTYPE makeEIDPID(gidTYPE eid_, gidTYPE pid_)
Helper to compose elemnt id & param id.
Definition: GlobalLabel.h:290
static unsigned int & getCurrentTimeIntervalRef()
Returns reference to current time id.
Definition: GlobalLabel.h:199

◆ dump()

void dump ( int  level = 0) const

Dumps the label to std::cout.

Definition at line 128 of file GlobalLabel.cc.

129{
130 cout << "GlobalLabel: gid=" << gid << endl;
131 cout << " eid=" << eid << endl;
132 cout << " pid=" << pid << endl;
133 cout << " tid=" << tid << endl;
134 cout << " tif=" << tif << endl;
135 if (level == 0)
136 return;
137 cout << " Time-dependent map:" << endl;
138 cout << " [EIDPID : TEIDPID] (registered time intervals)" << endl;
139 for (auto& it : getTimeIntervals()) {
140 cout << " " << it.first << " : " << it.second.teidpid() << endl;
141 cout << " ";
142 if (level > 1) {
143 for (unsigned int i = 0; i <= GlobalLabel::maxTID; i++) {
144 cout << it.second.get(i) << " ";
145 if ((i + 1) % 40 == 0)
146 cout << endl << " ";
147 }
148 cout << endl;
149 }
150 cout << endl;
151 }
152 cout << endl;
153}
static const gidTYPE maxTID
max time slices for a parameter 1..999
Definition: GlobalLabel.h:50

◆ getCurrentTimeInterval()

static gidTYPE getCurrentTimeInterval ( )
inlinestatic

Get current time id.

Definition at line 214 of file GlobalLabel.h.

215 {
217 }

◆ getCurrentTimeIntervalRef()

static unsigned int & getCurrentTimeIntervalRef ( )
inlinestatic

Returns reference to current time id.

Definition at line 199 of file GlobalLabel.h.

200 {
201 static unsigned int subrun = 0;
202 return subrun;
203 }

◆ getDictionary()

static std::map< gidTYPE, gidTYPE > & getDictionary ( )
inlinestatic

Reference to dictionary/map TEIDPID -> EIDPID.

Definition at line 282 of file GlobalLabel.h.

283 {
284 // Map TEIDPID -> EIDPID
285 static std::map<gidTYPE, gidTYPE> dictionary;
286 return dictionary;
287 }

◆ getElementId()

gidTYPE getElementId ( ) const
inline

Returns the element id (like VxdID for silicon sensors) to identify sets of parameters in DB objects.

Definition at line 161 of file GlobalLabel.h.

161{return eid % 100000;}

◆ getEndOfValidity()

int getEndOfValidity ( )
inline

Get the last time id, where this label is valid.

Definition at line 179 of file GlobalLabel.h.

180 {
181 if (!tif)
182 return maxTID;
184 if (it == GlobalLabel::getTimeIntervals().end())
185 return tid;
186 for (unsigned int i = tid; i < maxTID; i++) {
187 if (it->second.get(i) != tid)
188 return i - 1;
189 }
190 return tid;
191 }

◆ getParameterId()

gidTYPE getParameterId ( ) const
inline

Get id of alignment/calibration parameter.

Definition at line 164 of file GlobalLabel.h.

164{return pid;}

◆ getTimeFlag()

bool getTimeFlag ( ) const
inline

Is label time-dependent?

Definition at line 170 of file GlobalLabel.h.

170{return tif;}

◆ getTimeId()

gidTYPE getTimeId ( ) const
inline

Get time id.

Definition at line 167 of file GlobalLabel.h.

167{return tid;}

◆ getTimeIntervals()

static std::map< gidTYPE, TimeInterval > & getTimeIntervals ( )
inlinestatic

Reference to map EIDPID -> (TEIDPID, time intervals)

Definition at line 274 of file GlobalLabel.h.

275 {
276 // Map EIDPID -> (TEIDPID, time intervals)
277 static std::map<gidTYPE, TimeInterval > intervals;
278 return intervals;
279 }

◆ getUniqueId()

gidTYPE getUniqueId ( ) const
inline

Returns the global id identifing DB object for constantwith this label.

Definition at line 156 of file GlobalLabel.h.

156{return eid / 100000;}

◆ isValid()

bool isValid ( )
inline

Is label valid? (non-zero)

Definition at line 173 of file GlobalLabel.h.

173{return 0 != gid;}

◆ label()

int label ( )
inline

Returns encoded Pede label.

Returns
int

Definition at line 141 of file GlobalLabel.h.

141{return gid;}

◆ makeEIDPID()

gidTYPE makeEIDPID ( gidTYPE  eid_,
gidTYPE  pid_ 
)
inline

Helper to compose elemnt id & param id.

Definition at line 290 of file GlobalLabel.h.

290{return pid_ * pidOffset + eid_ * eidOffest;}

◆ makeTEIDPID()

gidTYPE makeTEIDPID ( gidTYPE  teid_,
gidTYPE  pid_ 
)
inline

Helper to compose time elemnt id & param id.

Definition at line 293 of file GlobalLabel.h.

293{return pid_ * pidOffset + teid_ * teidOffset;}

◆ operator int()

operator int ( )
inline

Cast to encoded Pede label.

Definition at line 146 of file GlobalLabel.h.

146{return (int)label();}
int label()
Returns encoded Pede label.
Definition: GlobalLabel.h:141

◆ operator unsigned int()

operator unsigned int ( )
inline

Cast to encoded Pede label.

Definition at line 151 of file GlobalLabel.h.

151{return (unsigned int)label();}

◆ registerTimeDependent()

void registerTimeDependent ( GlobalLabel::gidTYPE  start,
GlobalLabel::gidTYPE  end = maxTID 
)

Register this Detector element and parameter as time dependent with instance starting at "start" time index and ending at "end" index.

Call this for each time interval, in which the parameter is allowed to have different value (from that at interval 0-0)

Parameters
startStart time of parameter time-dep. instance (the instance has number "start" from start to end). The instance number before is 0 if not set.
endEnd time of parameter instance. The number after "end" is 0 if not set.

Definition at line 45 of file GlobalLabel.cc.

47{
48 auto& dict = GlobalLabel::getDictionary();
49 auto& ints = GlobalLabel::getTimeIntervals();
50 tif = 1;
51 tid = start;
52 gidTYPE eidpid = makeEIDPID(eid, pid);
53
54 auto it = ints.find(eidpid);
55 if (it == ints.end()) {
56 // Not found, insert new record
57 gidTYPE teidpid = makeTEIDPID(dict.size() + 1, pid);
58 dict.insert(make_pair(teidpid, eidpid));
59 ints.insert(make_pair(eidpid, TimeInterval(teidpid, start, end)));
60 } else {
61 // Found, add time interval
62 it->second.set(start, end);
63 }
64}

◆ setComponents()

static void setComponents ( const std::set< unsigned short > &  components)
inlinestatic

Set which DB objects have non-zero labels (by their id)

Parameters
componentsset of global ids of DB objects

Definition at line 107 of file GlobalLabel.h.

108 {
109 m_components = components;
110 }

◆ setCurrentTimeInterval()

static void setCurrentTimeInterval ( gidTYPE  time)
inlinestatic

Sets current time id.

Parameters
timetime id

Definition at line 207 of file GlobalLabel.h.

208 {
210 timeref = time;
211 }

◆ setParameterId()

GlobalLabel::gidTYPE setParameterId ( GlobalLabel::gidTYPE  paramId)

Usefull setter to quickly change only the parameter id and return back the encoded label (for use in RecoHits)

Parameters
paramIdId of calibration/alignment parameter
Returns
Encoded Pede label with new parameter id

Definition at line 72 of file GlobalLabel.cc.

73{
74 if (!getUniqueId() or paramId > maxPID) {
75 return label();
76 }
77 construct(getUniqueId(), getElementId(), paramId);
78 return label();
79}
gidTYPE getUniqueId() const
Returns the global id identifing DB object for constantwith this label.
Definition: GlobalLabel.h:156
gidTYPE getElementId() const
Returns the element id (like VxdID for silicon sensors) to identify sets of parameters in DB objects.
Definition: GlobalLabel.h:161

Member Data Documentation

◆ eid

gidTYPE eid {0}
private

element id

Definition at line 299 of file GlobalLabel.h.

◆ eidOffest

const gidTYPE eidOffest = pidOffset * (maxPID + 1)
static

Offset of detector element id = 100.

Definition at line 52 of file GlobalLabel.h.

◆ gid

gidTYPE gid {0}
private

global id

Definition at line 296 of file GlobalLabel.h.

◆ m_components

std::set< unsigned short > m_components = {}
staticprivate

Set of global ids of components for which to return non-zero labels.

Definition at line 221 of file GlobalLabel.h.

◆ maxEID

const gidTYPE maxEID = 9999999
static

max 9.999.999 detector elements 1..9999999 (NOT time-dep-)

Definition at line 47 of file GlobalLabel.h.

◆ maxGID

const gidTYPE maxGID
static
Initial value:
static const gidTYPE maxTIF
time-dep.
Definition: GlobalLabel.h:48

max internal id = 1.999.999.999

Definition at line 56 of file GlobalLabel.h.

◆ maxLabel

const gidTYPE maxLabel
static
Initial value:
=
static const gidTYPE maxGID
max internal id = 1.999.999.999
Definition: GlobalLabel.h:56

Label and internal id ("gid") are the same numbers (label is signed but 0 and <0 values are invalid to give to Pede)

Definition at line 58 of file GlobalLabel.h.

◆ maxPID

const gidTYPE maxPID = 99
static

max 99 parameter types 1..99

Definition at line 46 of file GlobalLabel.h.

◆ maxTEID

const gidTYPE maxTEID = 9999
static

max time-dep.

parameters 1..9999

Definition at line 49 of file GlobalLabel.h.

◆ maxTID

const gidTYPE maxTID = 999
static

max time slices for a parameter 1..999

Definition at line 50 of file GlobalLabel.h.

◆ maxTIF

const gidTYPE maxTIF = 1
static

time-dep.

flag

Definition at line 48 of file GlobalLabel.h.

◆ pid

gidTYPE pid {0}
private

parameter id

Definition at line 302 of file GlobalLabel.h.

◆ pidOffset

const gidTYPE pidOffset = 1
static

parameter number are the last 2 decimal digits

Definition at line 51 of file GlobalLabel.h.

◆ teidOffset

const gidTYPE teidOffset = eidOffest
static

Offset of time dependent element(detector+parameter) = 100.

Definition at line 54 of file GlobalLabel.h.

◆ tid

gidTYPE tid {0}
private

time id

Definition at line 305 of file GlobalLabel.h.

◆ tidOffset

const gidTYPE tidOffset = eidOffest * (maxTEID + 1)
static

Offset of time slice id = 1.000.000.

Definition at line 55 of file GlobalLabel.h.

◆ tif

gidTYPE tif {0}
private

time identification flag

Definition at line 308 of file GlobalLabel.h.

◆ tifOffset

const gidTYPE tifOffset = eidOffest * (maxEID + 1)
static

Offset of time flag = 1.000.000.000.

Definition at line 53 of file GlobalLabel.h.


The documentation for this class was generated from the following files: