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