BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
HltID.cxx
Go to the documentation of this file.
1#include "Identifier/HltID.h"
2#include <assert.h>
3#include <stdint.h>
4
6}
7
9}
10
11//----------------------------------------------------------------------------
12Identifier HltID::convert(const unsigned int id,const int nmdc,const int ntof,const int nemc,const int nmuc) {
13 uint32_t subid=id&(HltID::DETECTOR_MASK|HltID::ID_SUB_MASK);
14
15 if(subid<=getID_HLT_MAX()) return data_type_id(HLT,subid);
16
17 subid = subid - getID_HLT_MAX();
18 if(subid<=nmdc) return data_type_id(MDC,subid-1);
19
20 subid = subid - nmdc;
21 if(subid<=ntof) return data_type_id(TOF,subid-1);
22
23 subid = subid - ntof;
24 if(subid<=nemc) return data_type_id(EMC,subid-1);
25
26 subid = subid - nemc;
27 if(subid<=nmuc) return data_type_id(MUC,subid-1);
28
29 subid = subid - nmuc;
30 return data_type_id(CON,subid-1);
31}
32
33//----------------------------------------------------------------------------
34bool HltID::values_ok (const unsigned int detector,const unsigned int id_in_sub) {
35 // Check values
36 // unsigned int >= 0, this is definitely true.
37 // Omit the compare with MIN(0) to avoid warnings in compile.
38 switch(detector)
39 {
40 case HLT:
41 if ( id_in_sub > ID_HLT_MAX ) return false;
42 break;
43 case MDC:
44 if ( id_in_sub > ID_MDC_MAX ) return false;
45 break;
46 case TOF:
47 if ( id_in_sub > ID_TOF_MAX ) return false;
48 break;
49 case EMC:
50 if ( id_in_sub > ID_EMC_MAX ) return false;
51 break;
52 case MUC:
53 if ( id_in_sub > ID_MUC_MAX ) return false;
54 break;
55 case CON:
56 return true;
57 break;
58 default:
59 return false;
60 break;
61 }
62
63 return true;
64}
65
66//----------------------------------------------------------------------------
68 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
69 return (pos == HLT) ? true : false ;
70}
71
73 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
74 unsigned int no = (id.get_value() & HltID::ID_SUB_MASK) >> HltID::ID_SUB_INDEX;
75 return ((pos == HLT)&&(no==EVENTTYPE)) ? true : false ;
76}
77
79 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
80 unsigned int no = (id.get_value() & HltID::ID_SUB_MASK) >> HltID::ID_SUB_INDEX;
81 return ((pos == HLT)&&(no==ALGORITHM)) ? true : false ;
82}
83
85 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
86 unsigned int no = (id.get_value() & HltID::ID_SUB_MASK) >> HltID::ID_SUB_INDEX;
87 return ((pos == HLT)&&(no==CRITERIA)) ? true : false ;
88}
89
90bool HltID::is_version (const Identifier& id) {
91 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
92 unsigned int no = (id.get_value() & HltID::ID_SUB_MASK) >> HltID::ID_SUB_INDEX;
93 return ((pos == HLT)&&(no==VERSION)) ? true : false ;
94}
95
96bool HltID::is_energy (const Identifier& id) {
97 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
98 unsigned int no = (id.get_value() & HltID::ID_SUB_MASK) >> HltID::ID_SUB_INDEX;
99 return ((pos == HLT)&&(no==ENERGY)) ? true : false ;
100}
101
102bool HltID::is_number (const Identifier& id) {
103 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
104 unsigned int no = (id.get_value() & HltID::ID_SUB_MASK) >> HltID::ID_SUB_INDEX;
105 return ((pos == HLT)&&(no==NUMSUB)) ? true : false ;
106}
107
108bool HltID::is_ncon (const Identifier& id) {
109 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
110 unsigned int no = (id.get_value() & HltID::ID_SUB_MASK) >> HltID::ID_SUB_INDEX;
111 return ((pos == CON)&&(no==NUMCON)) ? true : false ;
112}
113
115 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
116 return (pos == MDC) ? true : false ;
117}
118
120 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
121 return (pos == TOF) ? true : false ;
122}
123
125 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
126 return (pos == EMC) ? true : false ;
127}
128
130 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
131 return (pos == MUC) ? true : false ;
132}
133
135 unsigned int pos = (id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX;
136 return (pos == CON) ? true : false ;
137}
138
139//----------------------------------------------------------------------------
140unsigned int HltID::detector (const Identifier& id) {
141 return ((id.get_value() & HltID::DETECTOR_MASK) >> HltID::DETECTOR_INDEX);
142}
143
144//----------------------------------------------------------------------------
145unsigned int HltID::id_sub (const Identifier& id) {
146 return (id.get_value() & HltID::ID_SUB_MASK) >> HltID::ID_SUB_INDEX;
147}
148
149//----------------------------------------------------------------------------
150unsigned int HltID::id_sub_max (const Identifier& id) {
151 if (is_ef_result(id)) {
152 return ID_HLT_MAX;
153 }
154 else if (is_mdc_inf(id)) {
155 return ID_MDC_MAX;
156 }
157 else if (is_tof_inf(id)) {
158 return ID_TOF_MAX;
159 }
160 else if (is_emc_inf(id)) {
161 return ID_EMC_MAX;
162 }
163 else if (is_muc_inf(id)) {
164 return ID_MUC_MAX;
165 }
166 else {
167 return 0;
168 }
169}
170
171//----------------------------------------------------------------------------
172Identifier HltID::data_type_id(const unsigned int detector,const unsigned int id_in_sub){
173 assert ( values_ok(detector, id_in_sub) );
174 //if(!values_ok(detector, id_in_sub)) return Identifier(0);
175
176 unsigned int value = (HLT_ID << HLT_INDEX) | (detector << DETECTOR_INDEX)|
177 (id_in_sub<< ID_SUB_INDEX);
178 return Identifier(value);
179}
180
181unsigned int HltID::getIntID (const unsigned int detector,const unsigned int id_in_sub){
182 assert ( values_ok(detector, id_in_sub) );
183 //if(!values_ok(detector, id_in_sub)) return 0;
184
185 unsigned int value = (HLT_ID << HLT_INDEX) | (detector << DETECTOR_INDEX)|
186 (id_in_sub<< ID_SUB_INDEX);
187 return value;
188}
189
const int no
static const unsigned int HLT_INDEX
Definition: BesDetectorID.h:83
static const unsigned int HLT_ID
Definition: BesDetectorID.h:82
static bool is_ncon(const Identifier &id)
Definition: HltID.cxx:108
static bool is_tof_inf(const Identifier &id)
Definition: HltID.cxx:119
static unsigned int getID_HLT_MAX()
Definition: HltID.h:67
static bool is_version(const Identifier &id)
Definition: HltID.cxx:90
static bool is_con_inf(const Identifier &id)
Definition: HltID.cxx:134
@ EMC
Definition: HltID.h:21
@ MUC
Definition: HltID.h:21
@ TOF
Definition: HltID.h:21
@ HLT
Definition: HltID.h:21
@ MDC
Definition: HltID.h:21
@ CON
Definition: HltID.h:21
static bool is_ef_result(const Identifier &id)
Test for data type.
Definition: HltID.cxx:67
static bool is_eventtype(const Identifier &id)
Definition: HltID.cxx:72
HltID(void)
constructor
Definition: HltID.cxx:5
static Identifier data_type_id(const unsigned int detector, const unsigned int id_in_sub=0)
For a single data.
Definition: HltID.cxx:172
~HltID(void)
destructor
Definition: HltID.cxx:8
static Identifier convert(const unsigned int id, const int nmdc=0, const int ntof=0, const int nemc=0, const int nmuc=0)
convert global id to sub-id(Identifier)
Definition: HltID.cxx:12
static unsigned int detector(const Identifier &id)
Values of different levels (failure returns 0)
Definition: HltID.cxx:140
static bool is_algorithm(const Identifier &id)
Definition: HltID.cxx:78
static bool is_muc_inf(const Identifier &id)
Definition: HltID.cxx:129
static bool is_criteria(const Identifier &id)
Definition: HltID.cxx:84
static unsigned int getIntID(const unsigned int detector, const unsigned int id_in_sub=0)
Definition: HltID.cxx:181
static unsigned int id_sub_max(const Identifier &id)
Definition: HltID.cxx:150
static bool is_emc_inf(const Identifier &id)
Definition: HltID.cxx:124
static bool is_number(const Identifier &id)
Definition: HltID.cxx:102
static bool is_mdc_inf(const Identifier &id)
Definition: HltID.cxx:114
static unsigned int id_sub(const Identifier &id)
Definition: HltID.cxx:145
static bool values_ok(const unsigned int detector, const unsigned int id_in_sub=0)
Definition: HltID.cxx:34
@ ALGORITHM
Definition: HltID.h:20
@ NUMCON
Definition: HltID.h:20
@ CRITERIA
Definition: HltID.h:20
@ VERSION
Definition: HltID.h:20
@ NUMSUB
Definition: HltID.h:20
@ EVENTTYPE
Definition: HltID.h:20
@ ENERGY
Definition: HltID.h:20
static bool is_energy(const Identifier &id)
Definition: HltID.cxx:96