BOSS 8.0.0
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
5HltID::HltID( void ) {}
6
7HltID::~HltID( void ) {}
8
9//----------------------------------------------------------------------------
10Identifier HltID::convert( const unsigned int id, const int nmdc, const int ntof,
11 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: return true; break;
55 default: return false; break;
56 }
57
58 return true;
59}
60
61//----------------------------------------------------------------------------
63 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
64 return ( pos == HLT ) ? true : false;
65}
66
68 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
69 unsigned int no = ( id.get_value() & HltID::ID_SUB_MASK ) >> HltID::ID_SUB_INDEX;
70 return ( ( pos == HLT ) && ( no == EVENTTYPE ) ) ? true : false;
71}
72
74 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
75 unsigned int no = ( id.get_value() & HltID::ID_SUB_MASK ) >> HltID::ID_SUB_INDEX;
76 return ( ( pos == HLT ) && ( no == ALGORITHM ) ) ? true : false;
77}
78
79bool HltID::is_criteria( const Identifier& id ) {
80 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
81 unsigned int no = ( id.get_value() & HltID::ID_SUB_MASK ) >> HltID::ID_SUB_INDEX;
82 return ( ( pos == HLT ) && ( no == CRITERIA ) ) ? true : false;
83}
84
85bool HltID::is_version( const Identifier& id ) {
86 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
87 unsigned int no = ( id.get_value() & HltID::ID_SUB_MASK ) >> HltID::ID_SUB_INDEX;
88 return ( ( pos == HLT ) && ( no == VERSION ) ) ? true : false;
89}
90
91bool HltID::is_energy( const Identifier& id ) {
92 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
93 unsigned int no = ( id.get_value() & HltID::ID_SUB_MASK ) >> HltID::ID_SUB_INDEX;
94 return ( ( pos == HLT ) && ( no == ENERGY ) ) ? true : false;
95}
96
97bool HltID::is_number( const Identifier& id ) {
98 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
99 unsigned int no = ( id.get_value() & HltID::ID_SUB_MASK ) >> HltID::ID_SUB_INDEX;
100 return ( ( pos == HLT ) && ( no == NUMSUB ) ) ? true : false;
101}
102
103bool HltID::is_ncon( const Identifier& id ) {
104 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
105 unsigned int no = ( id.get_value() & HltID::ID_SUB_MASK ) >> HltID::ID_SUB_INDEX;
106 return ( ( pos == CON ) && ( no == NUMCON ) ) ? true : false;
107}
108
109bool HltID::is_mdc_inf( const Identifier& id ) {
110 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
111 return ( pos == MDC ) ? true : false;
112}
113
114bool HltID::is_tof_inf( const Identifier& id ) {
115 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
116 return ( pos == TOF ) ? true : false;
117}
118
119bool HltID::is_emc_inf( const Identifier& id ) {
120 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
121 return ( pos == EMC ) ? true : false;
122}
123
124bool HltID::is_muc_inf( const Identifier& id ) {
125 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
126 return ( pos == MUC ) ? true : false;
127}
128
129bool HltID::is_con_inf( const Identifier& id ) {
130 unsigned int pos = ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX;
131 return ( pos == CON ) ? true : false;
132}
133
134//----------------------------------------------------------------------------
135unsigned int HltID::detector( const Identifier& id ) {
136 return ( ( id.get_value() & HltID::DETECTOR_MASK ) >> HltID::DETECTOR_INDEX );
137}
138
139//----------------------------------------------------------------------------
140unsigned int HltID::id_sub( const Identifier& id ) {
141 return ( id.get_value() & HltID::ID_SUB_MASK ) >> HltID::ID_SUB_INDEX;
142}
143
144//----------------------------------------------------------------------------
145unsigned int HltID::id_sub_max( const Identifier& id ) {
146 if ( is_ef_result( id ) ) { return ID_HLT_MAX; }
147 else if ( is_mdc_inf( id ) ) { return ID_MDC_MAX; }
148 else if ( is_tof_inf( id ) ) { return ID_TOF_MAX; }
149 else if ( is_emc_inf( id ) ) { return ID_EMC_MAX; }
150 else if ( is_muc_inf( id ) ) { return ID_MUC_MAX; }
151 else { return 0; }
152}
153
154//----------------------------------------------------------------------------
155Identifier HltID::data_type_id( const unsigned int detector, const unsigned int id_in_sub ) {
156 assert( values_ok( detector, id_in_sub ) );
157 // if(!values_ok(detector, id_in_sub)) return Identifier(0);
158
159 unsigned int value =
160 ( HLT_ID << HLT_INDEX ) | ( detector << DETECTOR_INDEX ) | ( id_in_sub << ID_SUB_INDEX );
161 return Identifier( value );
162}
163
164unsigned int HltID::getIntID( const unsigned int detector, const unsigned int id_in_sub ) {
165 assert( values_ok( detector, id_in_sub ) );
166 // if(!values_ok(detector, id_in_sub)) return 0;
167
168 unsigned int value =
169 ( HLT_ID << HLT_INDEX ) | ( detector << DETECTOR_INDEX ) | ( id_in_sub << ID_SUB_INDEX );
170 return value;
171}
static bool is_ncon(const Identifier &id)
Definition HltID.cxx:103
static bool is_tof_inf(const Identifier &id)
Definition HltID.cxx:114
static bool is_version(const Identifier &id)
Definition HltID.cxx:85
static bool is_con_inf(const Identifier &id)
Definition HltID.cxx:129
static bool is_ef_result(const Identifier &id)
Test for data type.
Definition HltID.cxx:62
static bool is_eventtype(const Identifier &id)
Definition HltID.cxx:67
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:155
~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:10
static unsigned int detector(const Identifier &id)
Values of different levels (failure returns 0).
Definition HltID.cxx:135
static bool is_algorithm(const Identifier &id)
Definition HltID.cxx:73
static bool is_muc_inf(const Identifier &id)
Definition HltID.cxx:124
static bool is_criteria(const Identifier &id)
Definition HltID.cxx:79
static unsigned int getIntID(const unsigned int detector, const unsigned int id_in_sub=0)
Definition HltID.cxx:164
static unsigned int id_sub_max(const Identifier &id)
Definition HltID.cxx:145
static bool is_emc_inf(const Identifier &id)
Definition HltID.cxx:119
static bool is_number(const Identifier &id)
Definition HltID.cxx:97
static bool is_mdc_inf(const Identifier &id)
Definition HltID.cxx:109
static unsigned int id_sub(const Identifier &id)
Definition HltID.cxx:140
static bool values_ok(const unsigned int detector, const unsigned int id_in_sub=0)
Definition HltID.cxx:33
static bool is_energy(const Identifier &id)
Definition HltID.cxx:91