BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcID.cxx
Go to the documentation of this file.
1#include "Identifier/EmcID.h"
2#include <assert.h>
3
4EmcID::EmcID( void ) {}
5
6EmcID::~EmcID( void ) {}
7
8//----------------------------------------------------------------------------
9bool EmcID::values_ok( const unsigned int barrel_ec, const unsigned int theta_module,
10 const unsigned int phi_module ) {
11 // Check values
12 // unsigned int >= 0, this is definitely true.
13 // Omit the compare with MIN(0) to avoid warnings in compile.
14 if ( barrel_ec > BARREL_EC_MAX ) return false;
15
16 if ( barrel_ec == BARREL )
17 {
18 if ( phi_module > PHI_BARREL_MAX ) return false;
19 if ( theta_module > THETA_BARREL_MAX ) return false;
20 }
21 else
22 { // for endcap
23 if ( theta_module > THETA_ENDCAP_MAX ) return false;
24 if ( phi_module > getPHI_ENDCAP_MAX( theta_module ) ) return false;
25 }
26 return true;
27}
28
29//----------------------------------------------------------------------------
30bool EmcID::is_barrel( const Identifier& id ) {
31 unsigned int pos = ( id.get_value() & EmcID::BARREL_EC_MASK ) >> EmcID::BARREL_EC_INDEX;
32 return ( pos == BARREL ) ? true : false;
33}
34
35//----------------------------------------------------------------------------
36unsigned int EmcID::barrel_ec( const Identifier& id ) {
37 return ( ( id.get_value() & EmcID::BARREL_EC_MASK ) >> EmcID::BARREL_EC_INDEX );
38}
39
40//----------------------------------------------------------------------------
41unsigned int EmcID::theta_module( const Identifier& id ) {
42 return ( id.get_value() & EmcID::THETA_MASK ) >> EmcID::THETA_INDEX;
43}
44
45//----------------------------------------------------------------------------
46unsigned int EmcID::phi_module( const Identifier& id ) {
47 return ( id.get_value() & EmcID::PHI_MASK ) >> EmcID::PHI_INDEX;
48}
49
50//----------------------------------------------------------------------------
51unsigned int EmcID::theta_module_max( const Identifier& id ) {
52 if ( is_barrel( id ) ) { return THETA_BARREL_MAX; }
53 else { return THETA_ENDCAP_MAX; }
54}
55
56//----------------------------------------------------------------------------
57unsigned int EmcID::phi_module_max( const Identifier& id ) {
58 if ( is_barrel( id ) ) { return PHI_BARREL_MAX; }
59 else { return getPHI_ENDCAP_MAX( theta_module( id ) ); }
60}
61
62//----------------------------------------------------------------------------
63Identifier EmcID::crystal_id( const unsigned int barrel_ec, const unsigned int theta_module,
64 const unsigned int phi_module ) {
66 unsigned int value = ( EMC_ID << EMC_INDEX ) | ( barrel_ec << BARREL_EC_INDEX ) |
67 ( theta_module << THETA_INDEX ) | ( phi_module << PHI_INDEX );
68 return Identifier( value );
69}
70
71unsigned int EmcID::getIntID( const unsigned int barrel_ec, const unsigned int theta_module,
72 const unsigned int phi_module ) {
74 unsigned int value = ( EMC_ID << EMC_INDEX ) | ( barrel_ec << BARREL_EC_INDEX ) |
75 ( theta_module << THETA_INDEX ) | ( phi_module << PHI_INDEX );
76 return value;
77}
78
79unsigned int EmcID::getTHETA_BARREL_MAX() { return THETA_BARREL_MAX; }
80unsigned int EmcID::getTHETA_BARREL_MIN() { return THETA_BARREL_MIN; }
81unsigned int EmcID::getTHETA_ENDCAP_MAX() { return THETA_ENDCAP_MAX; }
82unsigned int EmcID::getTHETA_ENDCAP_MIN() { return THETA_ENDCAP_MIN; }
83unsigned int EmcID::getPHI_BARREL_MAX() { return PHI_BARREL_MAX; }
84unsigned int EmcID::getPHI_BARREL_MIN() { return PHI_BARREL_MIN; }
85unsigned int EmcID::getPHI_ENDCAP_MAX( const unsigned int theta ) {
86 if ( theta == 0 || theta == 1 ) { return PHI_ENDCAP_MAX1; }
87 if ( theta == 2 || theta == 3 ) { return PHI_ENDCAP_MAX2; }
88 if ( theta == 4 || theta == 5 ) { return PHI_ENDCAP_MAX3; }
89 return 0; // no available number
90}
91unsigned int EmcID::getPHI_ENDCAP_MIN() { return PHI_ENDCAP_MIN; }
92unsigned int EmcID::getBARREL_EC_MAX() { return BARREL_EC_MAX; }
93unsigned int EmcID::getBARREL_EC_MIN() { return BARREL_EC_MIN; }
94
95unsigned int EmcID::getENDCAP_EAST() { return ENDCAP_EAST; }
96
97unsigned int EmcID::getBARREL() { return BARREL; }
98
99unsigned int EmcID::getENDCAP_WEST() { return ENDCAP_WEST; }
static unsigned int getPHI_BARREL_MAX()
Definition EmcID.cxx:83
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.
Definition EmcID.cxx:63
static unsigned int getENDCAP_WEST()
Definition EmcID.cxx:99
~EmcID()
destructor
Definition EmcID.cxx:6
static bool values_ok(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
Definition EmcID.cxx:9
static unsigned int getBARREL_EC_MIN()
Definition EmcID.cxx:93
EmcID()
constructor
Definition EmcID.cxx:4
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0).
Definition EmcID.cxx:36
static bool is_barrel(const Identifier &id)
Test for barrel.
Definition EmcID.cxx:30
static unsigned int getENDCAP_EAST()
Definition EmcID.cxx:95
static unsigned int getBARREL_EC_MAX()
Definition EmcID.cxx:92
static unsigned int getTHETA_ENDCAP_MIN()
Definition EmcID.cxx:82
static unsigned int getTHETA_ENDCAP_MAX()
Definition EmcID.cxx:81
static unsigned int getBARREL()
Definition EmcID.cxx:97
unsigned int theta_module_max(const Identifier &id)
Max/Min values for each field (error returns -999).
Definition EmcID.cxx:51
unsigned int phi_module_max(const Identifier &id)
Definition EmcID.cxx:57
static unsigned int getTHETA_BARREL_MIN()
Definition EmcID.cxx:80
static unsigned int getIntID(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
Definition EmcID.cxx:71
static unsigned int getTHETA_BARREL_MAX()
Definition EmcID.cxx:79
static unsigned int theta_module(const Identifier &id)
Definition EmcID.cxx:41
static unsigned int getPHI_ENDCAP_MAX(const unsigned int theta)
Definition EmcID.cxx:85
static unsigned int getPHI_ENDCAP_MIN()
Definition EmcID.cxx:91
static unsigned int getPHI_BARREL_MIN()
Definition EmcID.cxx:84
static unsigned int phi_module(const Identifier &id)
Definition EmcID.cxx:46