StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPicoEmcTrigger.cxx
1 //
2 // The StPicoEmc trigger class holds EMC trigger information
3 //
4 
5 // C++ headers
6 #include <limits>
7 
8 // PicoDst headers
9 #include "StPicoMessMgr.h"
10 #include "StPicoEmcTrigger.h"
11 
12 ClassImp(StPicoEmcTrigger)
13 
14 //_________________
15 StPicoEmcTrigger::StPicoEmcTrigger(): TObject(), mFlag(0), mId(0), mAdc(0),
16  mSmdE(0), mSmdP(0) {
17  /* empty */
18 }
19 
20 //_________________
21 StPicoEmcTrigger::StPicoEmcTrigger(Int_t flag, Int_t id, Int_t adc): StPicoEmcTrigger() {
22 
23  if (flag < 0 || id < 0 || adc < 0) return;
24  mFlag = ( (flag > std::numeric_limits<unsigned char>::max()) ?
25  std::numeric_limits<unsigned char>::max() : (UChar_t)flag );
26  mId = ( (id > std::numeric_limits<unsigned short>::max()) ?
27  std::numeric_limits<unsigned short>::max() : (UShort_t)id );
28  mAdc = ( (adc > std::numeric_limits<unsigned short>::max()) ?
29  std::numeric_limits<unsigned short>::max() : (UShort_t)adc );
30  mSmdE = {};
31  mSmdP = {};
32 }
33 
34 //_________________
35 StPicoEmcTrigger::StPicoEmcTrigger(Int_t flag, Int_t id, Int_t adc,
36  std::vector<unsigned short> smdE,
37  std::vector<unsigned short> smdP): StPicoEmcTrigger() {
38 
39  if (flag < 0 || id < 0 || adc < 0) return;
40  mFlag = ( (flag > std::numeric_limits<unsigned char>::max()) ?
41  std::numeric_limits<unsigned char>::max() : (UChar_t)flag );
42  mId = ( (id > std::numeric_limits<unsigned short>::max()) ?
43  std::numeric_limits<unsigned short>::max() : (UShort_t)id );
44  mAdc = ( (adc > std::numeric_limits<unsigned short>::max()) ?
45  std::numeric_limits<unsigned short>::max() : (UShort_t)adc );
46  mSmdE = smdE;
47  mSmdP = smdP;
48 }
49 
50 //_________________
52  mFlag = trigger.mFlag;
53  mId = trigger.mId;
54  mAdc = trigger.mAdc;
55  mSmdE = trigger.mSmdE;
56  mSmdP = trigger.mSmdP;
57 
58 }
59 
60 //_________________
62  /* empty */
63 }
64 
65 //_________________
66 void StPicoEmcTrigger::Print(const Char_t* option __attribute__((unused)) ) const {
67  LOG_INFO << "flag: " << mFlag << " id: " << mId << " ADC: " << mAdc
68  << " SMDE hits num: " << mSmdE.size()
69  << " SMDP hits num: " << mSmdP.size() << endm;
70 }
71 
72 //_________________
73 void StPicoEmcTrigger::setFlag(Int_t flag) {
74  if (flag < 0) {
75  flag = 0;
76  }
77  else {
78  mFlag = (flag > std::numeric_limits<unsigned char>::max()) ?
79  std::numeric_limits<unsigned char>::max() : (UChar_t)flag;
80  }
81 }
82 
83 //_________________
84 void StPicoEmcTrigger::setId(Int_t id) {
85  if (id < 0) {
86  mId = 0;
87  }
88  else {
89  mId = (id > std::numeric_limits<unsigned short>::max()) ?
90  std::numeric_limits<unsigned short>::max() : (UShort_t)id;
91  }
92 }
93 
94 //_________________
95 void StPicoEmcTrigger::setAdc(Int_t adc) {
96  if (adc < 0) {
97  mAdc = 0;
98  }
99  else {
100  mAdc = (adc > std::numeric_limits<unsigned short>::max()) ?
101  std::numeric_limits<unsigned short>::max() : (UShort_t)adc;
102  }
103 }
104 
105 //_________________
106 Int_t StPicoEmcTrigger::smdEIndex(Int_t i) const {
107  if ( mSmdE.empty() ) {
108  return -1; // Error: no entries in the STL vector
109  }
110  else {
111  if ( i>=0 && i<=(Int_t)mSmdE.size() ) {
112  return (Int_t)mSmdE.at( i );
113  }
114  else {
115  return -2; // Error: out of range
116  }
117  }
118 }
119 
120 //_________________
121 Int_t StPicoEmcTrigger::smdPIndex(Int_t i) const {
122  if ( mSmdP.empty() ) {
123  return -1; // Error: no entries in the STL vector
124  }
125  else {
126  if ( i>=0 && i<=(Int_t)mSmdP.size() ) {
127  return (Int_t)mSmdP.at( i );
128  }
129  else {
130  return -2; // Error: out of range
131  }
132  }
133 }
void setAdc(Int_t adc)
Set ADC.
UShort_t mId
SoftId. bjp: 1-18, ht: 1-4800.
void setFlag(Int_t flag)
Set trigger flag.
void setId(Int_t id)
Set ID.
Int_t smdPIndex(Int_t i) const
Return i-th BEmc SMDP hit index. -1 = no entries, -2 = out of range.
UShort_t mAdc
ADC.
std::vector< unsigned short > mSmdP
Vector of associated BEmc SMD Phi hit indices.
StPicoEmcTrigger()
Default constructor.
Holds EMC trigger information.
std::vector< unsigned short > mSmdE
Vector of associated BEmc SMD Eta hit indices.
virtual ~StPicoEmcTrigger()
Destructor.
Int_t smdEIndex(Int_t i) const
Return i-th BEmc SMDE hit index. -1 = no entries, -2 = out of range.
virtual void Print(const Char_t *option="") const
Print EMC trigger information.