StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFmsHit.cxx
1 /***************************************************************************
2  *
3  * $Id: StFmsHit.cxx,v 2.2 2015/09/01 21:01:47 ullrich Exp $
4  *
5  * Author: Jingguo Ma, Dec 2009
6  ***************************************************************************
7  *
8  * Description: StFmsHit is data for individual cell
9  *
10  ***************************************************************************
11  *
12  * $Log: StFmsHit.cxx,v $
13  * Revision 2.2 2015/09/01 21:01:47 ullrich
14  * Minor changes to format of print statments and \nchange to naming of data member.
15  *
16  * Revision 2.1 2010/01/08 22:42:31 ullrich
17  * Initial Revision.
18  *
19  **************************************************************************/
20 #include "StFmsHit.h"
21 
22 ClassImp(StFmsHit)
23 
24 StFmsHit::StFmsHit() {
25  mDetectorId = 0;
26  mChannel = 0;
27  mQTCrtSlotCh = 0;
28  mAdc = 0;
29  mTdc = 0;
30  mEnergy = 0;
31 }
32 
33 StFmsHit::StFmsHit(unsigned short det, unsigned short ch,
34  unsigned short qtcrate, unsigned short qtslot,
35  unsigned short qtch, unsigned short adc,
36  unsigned short tdc, float e)
37 {
38  setFmsHit(det, ch, qtcrate, qtslot, qtch, adc, tdc, e);
39 }
40 
41 StFmsHit::~StFmsHit() {/* no op */}
42 
43 unsigned short
44 StFmsHit::detectorId() const {return mDetectorId;}
45 
46 unsigned short
47 StFmsHit::channel() const {return mChannel;}
48 
49 unsigned short
50 StFmsHit::adc() const {return mAdc;}
51 
52 unsigned short
53 StFmsHit::tdc() const {return mTdc;}
54 
55 float
56 StFmsHit::energy() const {return mEnergy;}
57 
58 unsigned short
59 StFmsHit::qtCrate() const {return (mQTCrtSlotCh>>12) & 0x0f;}
60 
61 unsigned short
62 StFmsHit::qtSlot() const {return (mQTCrtSlotCh>>8 ) & 0x0f;}
63 
64 unsigned short
65 StFmsHit::qtChannel() const {return (mQTCrtSlotCh ) & 0xff;}
66 
67 void
68 StFmsHit::encodeQTCrtSlotCh(unsigned short qtcrate, unsigned short qtslot,
69  unsigned short qtch)
70 {
71  mQTCrtSlotCh = (qtcrate<<12) + (qtslot<<8) + qtch;
72 }
73 
74 void StFmsHit::setQtCrate(unsigned short val) { mQTCrtSlotCh |= (val<<12); }
75 void StFmsHit::setQtSlot(unsigned short val) { mQTCrtSlotCh |= (val<<8); }
76 void StFmsHit::setQtChannel(unsigned short val) { mQTCrtSlotCh |= val; }
77 void StFmsHit::setDetectorId(unsigned short val) { mDetectorId = val; }
78 void StFmsHit::setChannel(unsigned short val) { mChannel = val; }
79 void StFmsHit::setAdc(unsigned short val) { mAdc = val; }
80 void StFmsHit::setTdc(unsigned short val) { mTdc = val; }
81 void StFmsHit::setEnergy(float val) { mEnergy = val; }
82 void StFmsHit::setFmsHit(unsigned short det, unsigned short ch,
83  unsigned short qtcrate, unsigned short qtslot,
84  unsigned short qtch, unsigned short adc,
85  unsigned short tdc, Float_t e){
86  mDetectorId = det;
87  mChannel = ch;
88  mAdc = adc;
89  mTdc = tdc;
90  mEnergy = e;
91  encodeQTCrtSlotCh(qtcrate, qtslot, qtch);
92 }
93 
94 void StFmsHit::print(Option_t *option) const {cout<< *this <<endl;}
95 
96 ostream& operator<<(ostream& os, const StFmsHit& v)
97 {
98  return os << Form("StFmsHit: detId=%2d ch=%3d QTCrt=%1d QTSlot=%2d QTCh=%2d adc=%4d tdc=%4d E=%6.2f",
99  v.detectorId(),v.channel(),v.qtCrate(),v.qtSlot(),v.qtChannel()
100  ,v.adc(),v.tdc(),v.energy());
101 }