13 #include "StMuFcsHit.h"
16 #include "StMuFcsCluster.h"
21 StMuFcsHit::StMuFcsHit(
unsigned short zs,
unsigned short det,
unsigned short id,
22 unsigned short ns,
unsigned short ehp,
unsigned short dep,
unsigned short ch,
23 int ntimebin,
unsigned short*
data)
25 setFcsHit(zs, det,
id, ns, ehp, dep, ch, ntimebin, data);
27 StMuFcsHit::StMuFcsHit(
unsigned short zs,
unsigned short det,
unsigned short id,
28 unsigned short ns,
unsigned short ehp,
unsigned short dep,
unsigned short ch,
31 setFcsHit(zs, det,
id, ns, ehp, dep, ch, e);
34 StMuFcsHit::~StMuFcsHit() {
38 unsigned short StMuFcsHit::zs()
const {
return (mDetId >> 15 ) & 0x0001;}
39 unsigned short StMuFcsHit::detectorId()
const {
return (mDetId >> 12 ) & 0x0007;}
40 unsigned short StMuFcsHit::id()
const {
return (mDetId ) & 0x0fff;}
41 unsigned short StMuFcsHit::ns()
const {
return (mDepCh >> 15 ) & 0x01;}
42 unsigned short StMuFcsHit::ehp()
const {
return (mDepCh >> 13 ) & 0x03;}
43 unsigned short StMuFcsHit::dep()
const {
return (mDepCh >> 8 ) & 0x1f;}
44 unsigned short StMuFcsHit::channel()
const {
return (mDepCh ) & 0xff;}
45 unsigned int StMuFcsHit::nTimeBin()
const {
46 if(zs())
return mData.GetSize()/2;
47 return mData.GetSize();
49 unsigned short StMuFcsHit::data(
int i)
const {
return mData.At(i);}
50 unsigned short StMuFcsHit::timebin(
int i)
const {
51 if(zs())
return mData.At(i*2+1);
54 unsigned short StMuFcsHit::adc(
int i)
const {
55 if(zs())
return mData.At(i*2 ) & 0xfff;
56 return mData.At(i) & 0xfff;
58 unsigned short StMuFcsHit::flag(
int i)
const {
59 if(zs())
return mData.At(i*2 ) >> 12;
60 return mData.At(i) >> 12;
63 int StMuFcsHit::adcSum()
const {
return mAdcSum;}
64 float StMuFcsHit::fitPeak()
const {
return mFitPeak;}
65 float StMuFcsHit::fitSigma()
const {
return mFitSigma;}
66 float StMuFcsHit::fitChi2()
const {
return mFitChi2;}
67 int StMuFcsHit::nPeak()
const {
return mNPeak;}
68 float StMuFcsHit::energy()
const {
return mEnergy;}
70 void StMuFcsHit::setDepCh(
unsigned short ns,
unsigned short ehp,
unsigned short dep,
unsigned short ch) {
71 mDepCh = (ns << 15) | (ehp<<13) | (dep<<8) | ch;
73 void StMuFcsHit::setNS(
unsigned short val) { setDepCh(val,ehp(),dep(),channel());}
74 void StMuFcsHit::setEHP(
unsigned short val) { setDepCh(ns(),val,dep(),channel());}
75 void StMuFcsHit::setDep(
unsigned short val) { setDepCh(ns(),ehp(),val,channel());}
76 void StMuFcsHit::setChannel(
unsigned short val) { setDepCh(ns(),ehp(),dep(),val);}
78 void StMuFcsHit::setDetId(
unsigned short zs,
unsigned short det,
unsigned short id) {
79 mDetId = (zs & 0x1)<<15 | (det & 0x7)<<12 | (
id & 0xfff);
81 void StMuFcsHit::setZS(
unsigned short val) { setDetId(val,detectorId(),
id()); }
82 void StMuFcsHit::setDetectorId(
unsigned short val) { setDetId(zs(),val,
id()); }
83 void StMuFcsHit::setId(
unsigned short val) { setDetId(zs(),detectorId(),val); }
85 void StMuFcsHit::setData(
int ndata,
const unsigned short*
data) {
86 mData.Set(ndata,(
const short*)data);
88 void StMuFcsHit::setDataAt(
int i,
unsigned short val) { mData.AddAt(val,i); }
89 void StMuFcsHit::setAdcFlag(
int i,
unsigned short adc,
unsigned short flag) { mData.AddAt(((flag&0xf)<<12) + adc, i); }
90 void StMuFcsHit::setAdc(
int i,
unsigned short val) { setAdcFlag(i,val,flag(i)); }
91 void StMuFcsHit::setFlag(
int i,
unsigned short val) { setAdcFlag(i,adc(i),val); }
93 void StMuFcsHit::setAdcSum(
int val) { mAdcSum = val; }
94 void StMuFcsHit::setFitPeak(
float val) { mFitPeak = val; }
95 void StMuFcsHit::setFitSigma(
float val) { mFitSigma = val; }
96 void StMuFcsHit::setFitChi2(
float val) { mFitChi2 = val; }
97 void StMuFcsHit::setNPeak(
int val) { mNPeak = val; }
98 void StMuFcsHit::setEnergy(
float val) { mEnergy = val; }
100 void StMuFcsHit::setFcsHit(
unsigned short zs,
unsigned short det,
unsigned short id,
101 unsigned short ns,
unsigned short ehp,
unsigned short dep,
unsigned short ch,
102 int ntimebin,
unsigned short* data) {
103 setDetId(zs, det,
id);
104 setDepCh(ns,ehp,dep,ch);
105 setData(ntimebin,data);
107 void StMuFcsHit::setFcsHit(
unsigned short zs,
unsigned short det,
unsigned short id,
108 unsigned short ns,
unsigned short ehp,
unsigned short dep,
unsigned short ch,
110 setDetId(zs, det,
id);
111 setDepCh(ns,ehp,dep,ch);
112 unsigned short data[2]={0,0};
122 void StMuFcsHit::print(Option_t *option)
const {
123 cout << Form(
"StMuFcsHit: det=%2d id=%3d | ns=%1d ehp=%1d dep=%2d ch=%2d | Ntb=%3d Sum=%6d Fit=%6.2f %6.2f E=%6.2f | ",
124 detectorId(),
id(),ns(),ehp(),dep(),channel(),
125 nTimeBin(),adcSum(),fitPeak(),fitSigma(),energy());
126 for(
unsigned int i=0; i<nTimeBin(); i++) {
128 cout << Form(
"%4d (%3d) ",adc(i),timebin(i));