25 StFcsHit::StFcsHit(
unsigned short zs,
unsigned short det,
unsigned short id,
26 unsigned short ns,
unsigned short ehp,
unsigned short dep,
unsigned short ch,
27 int ntimebin,
unsigned short*
data)
29 setFcsHit(zs, det,
id, ns, ehp, dep, ch, ntimebin, data);
31 StFcsHit::StFcsHit(
unsigned short zs,
unsigned short det,
unsigned short id,
32 unsigned short ns,
unsigned short ehp,
unsigned short dep,
unsigned short ch,
35 setFcsHit(zs, det,
id, ns, ehp, dep, ch, e);
38 StFcsHit::~StFcsHit() {
39 if(mData)
delete mData;
42 unsigned short StFcsHit::zs()
const {
return (mDetId >> 15 ) & 0x0001;}
43 unsigned short StFcsHit::detectorId()
const {
return (mDetId >> 12 ) & 0x0007;}
44 unsigned short StFcsHit::id()
const {
return (mDetId ) & 0x0fff;}
45 unsigned short StFcsHit::ns()
const {
return (mDepCh >> 15 ) & 0x01;}
46 unsigned short StFcsHit::ehp()
const {
return (mDepCh >> 13 ) & 0x03;}
47 unsigned short StFcsHit::dep()
const {
return (mDepCh >> 8 ) & 0x1f;}
48 unsigned short StFcsHit::channel()
const {
return (mDepCh ) & 0xff;}
49 unsigned int StFcsHit::nTimeBin()
const {
51 if(zs())
return mData->GetSize()/2;
52 return mData->GetSize();
56 unsigned short StFcsHit::data(
int i)
const {
return mData->At(i);}
57 unsigned short StFcsHit::timebin(
int i)
const {
58 if(zs())
return mData->At(i*2+1);
61 unsigned short StFcsHit::adc(
int i)
const {
62 if(zs())
return mData->At(i*2 ) & 0xfff;
63 return mData->At(i) & 0xfff;
65 unsigned short StFcsHit::flag(
int i)
const {
66 if(zs())
return mData->At(i*2 ) >> 12;
67 return mData->At(i) >> 12;
70 int StFcsHit::adcSum()
const {
return mAdcSum;}
71 float StFcsHit::fitPeak()
const {
return mFitPeak;}
72 float StFcsHit::fitSigma()
const {
return mFitSigma;}
73 float StFcsHit::fitChi2()
const {
return mFitChi2;}
74 int StFcsHit::nPeak()
const {
return mNPeak;}
75 float StFcsHit::energy()
const {
return mEnergy;}
77 void StFcsHit::setDepCh(
unsigned short ns,
unsigned short ehp,
unsigned short dep,
unsigned short ch) {
78 mDepCh = ((ns&0x1) << 15) | ((ehp&0x3)<<13) | ((dep&0x1f)<<8) | (ch & 0xff);
80 void StFcsHit::setNS(
unsigned short val) { setDepCh(val,ehp(),dep(),channel());}
81 void StFcsHit::setEHP(
unsigned short val) { setDepCh(ns(),val,dep(),channel());}
82 void StFcsHit::setDep(
unsigned short val) { setDepCh(ns(),ehp(),val,channel());}
83 void StFcsHit::setChannel(
unsigned short val) { setDepCh(ns(),ehp(),dep(),val);}
85 void StFcsHit::setDetId(
unsigned short zs,
unsigned short det,
unsigned short id) {
86 mDetId = (zs & 0x1)<<15 | (det & 0x7)<<12 | (
id & 0xfff);
88 void StFcsHit::setZS(
unsigned short val) { setDetId(val,detectorId(),
id()); }
89 void StFcsHit::setDetectorId(
unsigned short val) { setDetId(zs(),val,
id()); }
90 void StFcsHit::setId(
unsigned short val) { setDetId(zs(),detectorId(),val); }
92 void StFcsHit::setData(
int ntimebin,
const unsigned short*
data) {
94 mData =
new TArrayS(ntimebin,(
const short*)data);
97 mData->Set(ntimebin,(
const short*)data);
100 void StFcsHit::setDataAt(
int i,
unsigned short val) { mData->AddAt(val,i); }
101 void StFcsHit::setAdcFlag(
int i,
unsigned short adc,
unsigned short flag) { mData->AddAt(((flag&0xf)<<12) + adc, i); }
102 void StFcsHit::setAdc(
int i,
unsigned short val) { setAdcFlag(i,val,flag(i)); }
103 void StFcsHit::setFlag(
int i,
unsigned short val) { setAdcFlag(i,adc(i),val); }
105 void StFcsHit::setAdcSum(
int val) { mAdcSum = val; }
106 void StFcsHit::setFitPeak(
float val) { mFitPeak = val; }
107 void StFcsHit::setFitSigma(
float val) { mFitSigma = val; }
108 void StFcsHit::setFitChi2(
float val) { mFitChi2 = val; }
109 void StFcsHit::setNPeak(
int val) { mNPeak = val; }
110 void StFcsHit::setEnergy(
float val) { mEnergy = val; }
112 void StFcsHit::setFcsHit(
unsigned short zs,
unsigned short det,
unsigned short id,
113 unsigned short ns,
unsigned short ehp,
unsigned short dep,
unsigned short ch,
114 int ntimebin,
unsigned short* data) {
115 setDetId(zs, det,
id);
116 setDepCh(ns,ehp,dep,ch);
117 setData(ntimebin,data);
119 void StFcsHit::setFcsHit(
unsigned short zs,
unsigned short det,
unsigned short id,
120 unsigned short ns,
unsigned short ehp,
unsigned short dep,
unsigned short ch,
122 setDetId(zs, det,
id);
123 setDepCh(ns,ehp,dep,ch);
124 unsigned short data[2]={0,0};
134 void StFcsHit::print(Option_t *option)
const {
135 cout << Form(
"StFcsHit: det=%2d id=%3d | ns=%1d ehp=%1d dep=%2d ch=%2d | Ntb=%3d Sum=%6d Fit=%6.2f %6.2f E=%6.2f | ",
136 detectorId(),
id(),ns(),ehp(),dep(),channel(),
137 nTimeBin(),adcSum(),fitPeak(),fitSigma(),energy());
138 for(
unsigned int i=0; i<nTimeBin(); i++) {
140 cout << Form(
"%4d (%3d) ",adc(i),timebin(i));
145 void StFcsHit::addGeantTrack(
unsigned int id,
float e){
147 auto cmp = [id](decltype(mGeantTracks)::value_type t){
return t.first == id; };
148 auto trk = find_if(mGeantTracks.rbegin(), mGeantTracks.rend(), cmp);
149 if(trk == mGeantTracks.rend()){
150 mGeantTracks.push_back(make_pair(
id, e));