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