BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcID.cxx
Go to the documentation of this file.
1#include "Identifier/MdcID.h"
2#include <assert.h>
3#include <iostream>
4
6}
7
9}
10
11//----------------------------------------------------------------------------
12bool MdcID::values_ok ( const unsigned int wireType,
13 const unsigned int layer,
14 const unsigned int wire
15 ) {
16 // Check values
17 if ( wireType != AXIAL_WIRE && wireType != STEREO_WIRE ) return false;
18
19 if ( wireType == STEREO_WIRE ) {
20 if ( layer < INNER_STEREO_LAYER_MAX
21 || layer < ( INNER_STEREO_LAYER_MAX
22 + INNER_AXIAL_LAYER_MAX
23 + OUTER_STEREO_LAYER_MAX )
24 && layer >= (INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX ))
25 return true;
26 }
27
28 if ( wireType == AXIAL_WIRE ) {
29 if ( layer >= INNER_STEREO_LAYER_MAX
30 && layer < ( INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX )
31 || layer >= ( INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX
32 + OUTER_STEREO_LAYER_MAX ) && layer < LAYER_MAX )
33
34 return true;
35 }
36
37 std::cout << " ++ MdcID::values_ok++ wiretype = " << wireType << " layer = " << layer << " wire = " << wire << std::endl;
38
39 return false;
40}
41
42//----------------------------------------------------------------------------
43bool MdcID::is_axial (const Identifier& id) {
44 unsigned int type = (id.get_value() & MdcID::WIRETYPE_MASK) >> MdcID::WIRETYPE_INDEX;
45 return (type == AXIAL_WIRE) ? true : false;
46}
47
48//----------------------------------------------------------------------------
49int MdcID::layer (const Identifier& id) {
50 return (id.get_value() & MdcID::LAYER_MASK) >> MdcID::LAYER_INDEX;
51}
52
53//----------------------------------------------------------------------------
54int MdcID::wire (const Identifier& id) {
55 return (id.get_value() & MdcID::WIRE_MASK) >> MdcID::WIRE_INDEX;
56}
57
58//----------------------------------------------------------------------------
60 if (is_axial(id)) {
61 return AXIAL_LAYER_MAX;
62 } else {
63 return STEREO_LAYER_MAX;
64 }
65}
66
67//----------------------------------------------------------------------------
68int MdcID::wire_max (const Identifier& id) {
69 if (is_axial(id)) {
70 return AXIAL_WIRE_MAX;
71 } else {
72 return STEREO_WIRE_MAX;
73 }
74}
75
76//----------------------------------------------------------------------------
78 int layer,
79 int wire
80 ) {
81 assert ( values_ok(wireType, layer, wire) );
82 int value = (BesDetectorID::MDC_ID << MDC_INDEX) |
83 (wireType << WIRETYPE_INDEX) |
84 (layer << LAYER_INDEX) |
85 (wire << WIRE_INDEX);
86 return Identifier(value);
87}
88
89//----------------------------------------------------------------------------
91 int wire
92 ) {
93 if ( layer < INNER_STEREO_LAYER_MAX
94 || layer < (INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX + OUTER_STEREO_LAYER_MAX)
95 && layer >= (INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX )
96 )
97 return MdcID::wire_id ( STEREO_WIRE, layer, wire );
98 else return MdcID::wire_id (AXIAL_WIRE, layer, wire );
99
100}
101
102unsigned int MdcID::getIntID(unsigned int layer,
103 unsigned int wire)
104{
105 unsigned int value;
106 unsigned int wireType;
107
108 if ( layer < INNER_STEREO_LAYER_MAX
109 || layer < (INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX + OUTER_STEREO_LAYER_MAX)
110 && layer >= (INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX )
111 )
112 wireType = STEREO_WIRE;
113 else wireType = AXIAL_WIRE;
114
116 ((wireType << WIRETYPE_INDEX)&WIRETYPE_MASK) |
117 ((layer << LAYER_INDEX)&LAYER_MASK) |
118 ((wire << WIRE_INDEX)&WIRE_MASK);
119
120 return value;
121
122}
123
124unsigned int MdcID::getIntID(unsigned int wireType,
125 unsigned int layer,
126 unsigned int wire)
127{
128 unsigned int value = ((BesDetectorID::MDC_ID << MDC_INDEX)&MDC_MASK) |
129 ((wireType << WIRETYPE_INDEX)&WIRETYPE_MASK) |
130 ((layer << LAYER_INDEX)&LAYER_MASK) |
131 ((wire << WIRE_INDEX)&WIRE_MASK);
132 return value;
133
134}
135
136
137
139{
140 return AXIAL_LAYER_MAX;
141}
143{
144 return STEREO_LAYER_MAX;
145}
147{
148 return AXIAL_WIRE_MAX;
149}
151{
152 return STEREO_WIRE_MAX;
153}
154
156{
157 return AXIAL_WIRE;
158}
159
161{
162 return STEREO_WIRE;
163}
164
static value_type getAXIAL_LAYER_MAX()
Definition: MdcID.cxx:138
static Identifier wire_id(int wireType, int layer, int wire)
For a single wire.
Definition: MdcID.cxx:77
int layer_max(const Identifier &id)
Max/Min values for each field (error returns -999)
Definition: MdcID.cxx:59
bool is_axial(const Identifier &id)
Test for axial and stereo wire.
Definition: MdcID.cxx:43
static value_type getSTEREO_WIRE()
Definition: MdcID.cxx:160
static bool values_ok(const unsigned int wireType, const unsigned int layer, const unsigned int wire)
Definition: MdcID.cxx:12
~MdcID()
destructor
Definition: MdcID.cxx:8
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
Definition: MdcID.cxx:49
int wire_max(const Identifier &id)
Definition: MdcID.cxx:68
static value_type getAXIAL_WIRE_MAX()
Definition: MdcID.cxx:146
static int wire(const Identifier &id)
Definition: MdcID.cxx:54
static value_type getIntID(unsigned int wireType, unsigned int layer, unsigned int wire)
Definition: MdcID.cxx:124
MdcID()
constructor
Definition: MdcID.cxx:5
static value_type getSTEREO_WIRE_MAX()
Definition: MdcID.cxx:150
static value_type getSTEREO_LAYER_MAX()
Definition: MdcID.cxx:142
static value_type getAXIAL_WIRE()
Definition: MdcID.cxx:155