StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPicoBTowHit.cxx
1 //
2 // StPicoBTowHit stores BEMC tower information
3 //
4 
5 // C++ headers
6 #include <limits>
7 
8 // ROOT headers
9 #include "TMath.h"
10 
11 // PicoDst headers
12 #include "StPicoMessMgr.h"
13 #include "StPicoBTowHit.h"
14 
15 ClassImp(StPicoBTowHit)
16 
17 //_________________
18 StPicoBTowHit::StPicoBTowHit(): TObject(), mAdc(0), mE(-9000) {
19  /* empty */
20 }
21 
22 //_________________
23 StPicoBTowHit::StPicoBTowHit(Int_t adc, Float_t e) : TObject() {
24 
25  if (adc < 0) return;
26  mAdc = (adc > std::numeric_limits<unsigned short>::max()) ?
27  std::numeric_limits<unsigned short>::max() : (UShort_t)adc;
28 
29  mE = ( fabs(e * 1000.) > std::numeric_limits<short>::max() ?
30  ( (e > 0.) ? std::numeric_limits<short>::max() :
31  std::numeric_limits<short>::min() ) :
32  (Short_t)( TMath::Nint(e * 1000.) ) );
33 }
34 
35 //_________________
37  mAdc = hit.mAdc;
38  mE = hit.mE;
39 }
40 
41 //_________________
43  /* empty */
44 }
45 
46 //_________________
47 void StPicoBTowHit::Print(const Char_t* option __attribute__((unused)) ) const {
48  LOG_INFO << " Adc = " << adc() << " Energy = " << energy() << endm;
49 }
50 
51 //_________________
52 Bool_t StPicoBTowHit::isBad() const {
53  if( energy()<=-2. && mAdc==0) {
54  return kTRUE;
55  }
56  else {
57  return kFALSE;
58  }
59 }
60 
61 //_________________
62 void StPicoBTowHit::setEnergy(Float_t energy) {
63  mE = ( fabs(energy * 1000) > std::numeric_limits<short>::max() ?
64  ( (energy > 0) ? std::numeric_limits<short>::max() :
65  std::numeric_limits<short>::min() ) :
66  (Short_t)( TMath::Nint(energy * 1000) ) );
67 }
68 
69 //_________________
70 void StPicoBTowHit::setAdc(Int_t adc) {
71  if( adc<0 ) {
72  mAdc = 0;
73  }
74  else {
75  mAdc = (adc > std::numeric_limits<unsigned short>::max()) ?
76  std::numeric_limits<unsigned short>::max() : (UShort_t)adc;
77  }
78 }
StPicoBTowHit()
Default constructor.
Holds information about BEMC tower.
Definition: StPicoBTowHit.h:19
void setAdc(Int_t adc)
Set tower ADC.
Int_t adc() const
Return ADC of the tower.
Definition: StPicoBTowHit.h:38
virtual ~StPicoBTowHit()
Destructor.
virtual void Print(const Char_t *option="") const
Print tower information.
Short_t mE
Energy * 1000.
Definition: StPicoBTowHit.h:60
UShort_t mAdc
ADC.
Definition: StPicoBTowHit.h:58
Float_t energy() const
Return energy of the tower.
Definition: StPicoBTowHit.h:40
Bool_t isBad() const
Return if the tower is bad.
void setEnergy(Float_t energy)
Set tower energy.