BOSS 8.0.0
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
5MdcID::MdcID( void ) {}
6
7MdcID::~MdcID( void ) {}
8
9//----------------------------------------------------------------------------
10bool MdcID::values_ok( const unsigned int wireType, const unsigned int layer,
11 const unsigned int wire ) {
12 // Check values
13 if ( wireType != AXIAL_WIRE && wireType != STEREO_WIRE ) return false;
14
15 if ( wireType == STEREO_WIRE )
16 {
17 if ( layer < INNER_STEREO_LAYER_MAX ||
18 layer < ( INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX + OUTER_STEREO_LAYER_MAX ) &&
19 layer >= ( INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX ) )
20 return true;
21 }
22
23 if ( wireType == AXIAL_WIRE )
24 {
25 if ( layer >= INNER_STEREO_LAYER_MAX &&
26 layer < ( INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX ) ||
27 layer >=
28 ( INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX + OUTER_STEREO_LAYER_MAX ) &&
29 layer < LAYER_MAX )
30
31 return true;
32 }
33
34 std::cout << " ++ MdcID::values_ok++ wiretype = " << wireType << " layer = " << layer
35 << " wire = " << wire << std::endl;
36
37 return false;
38}
39
40//----------------------------------------------------------------------------
41bool MdcID::is_axial( const Identifier& id ) {
42 unsigned int type = ( id.get_value() & MdcID::WIRETYPE_MASK ) >> MdcID::WIRETYPE_INDEX;
43 return ( type == AXIAL_WIRE ) ? true : false;
44}
45
46//----------------------------------------------------------------------------
47int MdcID::layer( const Identifier& id ) {
48 return ( id.get_value() & MdcID::LAYER_MASK ) >> MdcID::LAYER_INDEX;
49}
50
51//----------------------------------------------------------------------------
52int MdcID::wire( const Identifier& id ) {
53 return ( id.get_value() & MdcID::WIRE_MASK ) >> MdcID::WIRE_INDEX;
54}
55
56//----------------------------------------------------------------------------
57int MdcID::layer_max( const Identifier& id ) {
58 if ( is_axial( id ) ) { return AXIAL_LAYER_MAX; }
59 else { return STEREO_LAYER_MAX; }
60}
61
62//----------------------------------------------------------------------------
63int MdcID::wire_max( const Identifier& id ) {
64 if ( is_axial( id ) ) { return AXIAL_WIRE_MAX; }
65 else { return STEREO_WIRE_MAX; }
66}
67
68//----------------------------------------------------------------------------
69Identifier MdcID::wire_id( int wireType, int layer, int wire ) {
70 assert( values_ok( wireType, layer, wire ) );
71 int value = ( BesDetectorID::MDC_ID << MDC_INDEX ) | ( wireType << WIRETYPE_INDEX ) |
72 ( layer << LAYER_INDEX ) | ( wire << WIRE_INDEX );
73 return Identifier( value );
74}
75
76//----------------------------------------------------------------------------
78 if ( layer < INNER_STEREO_LAYER_MAX ||
79 layer < ( INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX + OUTER_STEREO_LAYER_MAX ) &&
80 layer >= ( INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX ) )
81 return MdcID::wire_id( STEREO_WIRE, layer, wire );
82 else return MdcID::wire_id( AXIAL_WIRE, layer, wire );
83}
84
85unsigned int MdcID::getIntID( unsigned int layer, unsigned int wire ) {
86 unsigned int value;
87 unsigned int wireType;
88
89 if ( layer < INNER_STEREO_LAYER_MAX ||
90 layer < ( INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX + OUTER_STEREO_LAYER_MAX ) &&
91 layer >= ( INNER_STEREO_LAYER_MAX + INNER_AXIAL_LAYER_MAX ) )
92 wireType = STEREO_WIRE;
93 else wireType = AXIAL_WIRE;
94
95 value = ( ( BesDetectorID::MDC_ID << MDC_INDEX ) & MDC_MASK ) |
96 ( ( wireType << WIRETYPE_INDEX ) & WIRETYPE_MASK ) |
97 ( ( layer << LAYER_INDEX ) & LAYER_MASK ) | ( ( wire << WIRE_INDEX ) & WIRE_MASK );
98
99 return value;
100}
101
102unsigned int MdcID::getIntID( unsigned int wireType, unsigned int layer, unsigned int wire ) {
103 unsigned int value = ( ( BesDetectorID::MDC_ID << MDC_INDEX ) & MDC_MASK ) |
104 ( ( wireType << WIRETYPE_INDEX ) & WIRETYPE_MASK ) |
105 ( ( layer << LAYER_INDEX ) & LAYER_MASK ) |
106 ( ( wire << WIRE_INDEX ) & WIRE_MASK );
107 return value;
108}
109
110unsigned int MdcID::getAXIAL_LAYER_MAX() { return AXIAL_LAYER_MAX; }
111unsigned int MdcID::getSTEREO_LAYER_MAX() { return STEREO_LAYER_MAX; }
112unsigned int MdcID::getAXIAL_WIRE_MAX() { return AXIAL_WIRE_MAX; }
113unsigned int MdcID::getSTEREO_WIRE_MAX() { return STEREO_WIRE_MAX; }
114
115unsigned int MdcID::getAXIAL_WIRE() { return AXIAL_WIRE; }
116
117unsigned int MdcID::getSTEREO_WIRE() { return STEREO_WIRE; }
static value_type getAXIAL_LAYER_MAX()
Definition MdcID.cxx:110
static Identifier wire_id(int wireType, int layer, int wire)
For a single wire.
Definition MdcID.cxx:69
int layer_max(const Identifier &id)
Max/Min values for each field (error returns -999).
Definition MdcID.cxx:57
bool is_axial(const Identifier &id)
Test for axial and stereo wire.
Definition MdcID.cxx:41
static value_type getSTEREO_WIRE()
Definition MdcID.cxx:117
static bool values_ok(const unsigned int wireType, const unsigned int layer, const unsigned int wire)
Definition MdcID.cxx:10
~MdcID()
destructor
Definition MdcID.cxx:7
static int layer(const Identifier &id)
Values of different levels (failure returns 0).
Definition MdcID.cxx:47
int wire_max(const Identifier &id)
Definition MdcID.cxx:63
static value_type getAXIAL_WIRE_MAX()
Definition MdcID.cxx:112
static int wire(const Identifier &id)
Definition MdcID.cxx:52
static value_type getIntID(unsigned int wireType, unsigned int layer, unsigned int wire)
Definition MdcID.cxx:102
MdcID()
constructor
Definition MdcID.cxx:5
static value_type getSTEREO_WIRE_MAX()
Definition MdcID.cxx:113
static value_type getSTEREO_LAYER_MAX()
Definition MdcID.cxx:111
static value_type getAXIAL_WIRE()
Definition MdcID.cxx:115