BOSS 7.0.1
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
5}
6
8}
9
10//----------------------------------------------------------------------------
11bool EmcID::values_ok (const unsigned int barrel_ec,
12 const unsigned int theta_module,
13 const unsigned int phi_module
14 ) {
15 // Check values
16 // unsigned int >= 0, this is definitely true.
17 // Omit the compare with MIN(0) to avoid warnings in compile.
18 if (barrel_ec > BARREL_EC_MAX ) return false;
19
20 if ( barrel_ec == BARREL ) {
21 if ( phi_module > PHI_BARREL_MAX ) return false;
22 if ( theta_module > THETA_BARREL_MAX ) return false;
23 }
24 else { // for endcap
25 if ( theta_module > THETA_ENDCAP_MAX ) return false;
26 if ( phi_module > getPHI_ENDCAP_MAX(theta_module) ) return false;
27 }
28 return true;
29}
30
31//----------------------------------------------------------------------------
32bool EmcID::is_barrel (const Identifier& id) {
33 unsigned int pos = (id.get_value() & EmcID::BARREL_EC_MASK) >> EmcID::BARREL_EC_INDEX;
34 return (pos == BARREL) ? true : false ;
35}
36
37//----------------------------------------------------------------------------
38unsigned int EmcID::barrel_ec (const Identifier& id) {
39 return ((id.get_value() & EmcID::BARREL_EC_MASK) >> EmcID::BARREL_EC_INDEX);
40}
41
42//----------------------------------------------------------------------------
43unsigned int EmcID::theta_module (const Identifier& id) {
44 return (id.get_value() & EmcID::THETA_MASK) >> EmcID::THETA_INDEX;
45}
46
47//----------------------------------------------------------------------------
48unsigned int EmcID::phi_module (const Identifier& id) {
49 return (id.get_value() & EmcID::PHI_MASK) >> EmcID::PHI_INDEX;
50}
51
52//----------------------------------------------------------------------------
53unsigned int EmcID::theta_module_max (const Identifier& id) {
54 if (is_barrel(id)) {
55 return THETA_BARREL_MAX;
56 } else {
57 return THETA_ENDCAP_MAX;
58 }
59}
60
61//----------------------------------------------------------------------------
62unsigned int EmcID::phi_module_max (const Identifier& id) {
63 if (is_barrel(id)) {
64 return PHI_BARREL_MAX;
65 } else {
67 }
68}
69
70//----------------------------------------------------------------------------
71Identifier EmcID::crystal_id (const unsigned int barrel_ec,
72 const unsigned int theta_module,
73 const unsigned int phi_module
74 ) {
76 unsigned int value = (EMC_ID << EMC_INDEX) | (barrel_ec << BARREL_EC_INDEX)|
77 (theta_module << THETA_INDEX) | (phi_module << PHI_INDEX);
78 return Identifier(value);
79}
80
81unsigned int EmcID::getIntID (const unsigned int barrel_ec,
82 const unsigned int theta_module,
83 const unsigned int phi_module
84 ) {
86 unsigned int value = (EMC_ID << EMC_INDEX) | (barrel_ec << BARREL_EC_INDEX)|
87 (theta_module << THETA_INDEX) | (phi_module << PHI_INDEX);
88 return value;
89}
90
92{
93 return THETA_BARREL_MAX;
94}
96{
97 return THETA_BARREL_MIN;
98}
100{
101 return THETA_ENDCAP_MAX;
102}
104{
105 return THETA_ENDCAP_MIN;
106}
108{
109 return PHI_BARREL_MAX;
110}
112{
113 return PHI_BARREL_MIN;
114}
115unsigned int EmcID::getPHI_ENDCAP_MAX(const unsigned int theta)
116{
117 if(theta==0 || theta==1) {
118 return PHI_ENDCAP_MAX1;
119 }
120 if(theta==2 || theta==3) {
121 return PHI_ENDCAP_MAX2;
122 }
123 if(theta==4 || theta==5) {
124 return PHI_ENDCAP_MAX3;
125 }
126 return 0; //no available number
127}
129{
130 return PHI_ENDCAP_MIN;
131}
133{
134 return BARREL_EC_MAX;
135}
137{
138 return BARREL_EC_MIN;
139}
140
142{
143 return ENDCAP_EAST;
144}
145
146unsigned int EmcID::getBARREL()
147{
148 return BARREL;
149}
150
152{
153 return ENDCAP_WEST;
154}
static unsigned int getPHI_BARREL_MAX()
Definition: EmcID.cxx:107
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:71
static unsigned int getENDCAP_WEST()
Definition: EmcID.cxx:151
~EmcID()
destructor
Definition: EmcID.cxx:7
static bool values_ok(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
Definition: EmcID.cxx:11
static unsigned int getBARREL_EC_MIN()
Definition: EmcID.cxx:136
EmcID()
constructor
Definition: EmcID.cxx:4
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0)
Definition: EmcID.cxx:38
static bool is_barrel(const Identifier &id)
Test for barrel.
Definition: EmcID.cxx:32
static unsigned int getENDCAP_EAST()
Definition: EmcID.cxx:141
static unsigned int getBARREL_EC_MAX()
Definition: EmcID.cxx:132
static unsigned int getTHETA_ENDCAP_MIN()
Definition: EmcID.cxx:103
static unsigned int getTHETA_ENDCAP_MAX()
Definition: EmcID.cxx:99
static unsigned int getBARREL()
Definition: EmcID.cxx:146
unsigned int theta_module_max(const Identifier &id)
Max/Min values for each field (error returns -999)
Definition: EmcID.cxx:53
unsigned int phi_module_max(const Identifier &id)
Definition: EmcID.cxx:62
static unsigned int getTHETA_BARREL_MIN()
Definition: EmcID.cxx:95
static unsigned int getIntID(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
Definition: EmcID.cxx:81
static unsigned int getTHETA_BARREL_MAX()
Definition: EmcID.cxx:91
static unsigned int theta_module(const Identifier &id)
Definition: EmcID.cxx:43
static unsigned int getPHI_ENDCAP_MAX(const unsigned int theta)
Definition: EmcID.cxx:115
static unsigned int getPHI_ENDCAP_MIN()
Definition: EmcID.cxx:128
static unsigned int getPHI_BARREL_MIN()
Definition: EmcID.cxx:111
static unsigned int phi_module(const Identifier &id)
Definition: EmcID.cxx:48