StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuFstRawHit.cxx
1 /***************************************************************************
2  *
3  * StMuFstRawHit.cxx
4  *
5  * Author: tchuang 2022
6  ***************************************************************************
7  *
8  * Description: Implementation of StMuFstRawHit, the StEvent hit structure
9  *
10  ***************************************************************************/
11 #include "StMuFstRawHit.h"
12 #include "St_base/StMessMgr.h"
13 #include "StEvent/StEnumerations.h"
14 #include "StEvent/StFstRawHit.h"
15 
16 ClassImp(StMuFstRawHit)
17 
18 StMuFstRawHit::StMuFstRawHit() : TObject() { /* no op */ }
19 
20 StMuFstRawHit::~StMuFstRawHit() { /* no op */ }
21 
22 int StMuFstRawHit::getChannelId() const { return mChannelId; };
23 int StMuFstRawHit::getGeoId() const { return mGeoId; };
24 int StMuFstRawHit::getSeedhitflag() const { return mSeedhitflag; };
25 unsigned char StMuFstRawHit::getMaxTimeBin() const { return mMaxTimeBin; };
26 unsigned char StMuFstRawHit::getDefaultTimeBin() { return mDefaultTimeBin; };
27 unsigned short StMuFstRawHit::getIdTruth() const { return mIdTruth; };
28 
29 unsigned char StMuFstRawHit::getDisk() const
30 {
31  return 1 + mGeoId / ((kFstNumInnerSensorsPerWedge * kFstNumStripsPerInnerSensor + kFstNumOuterSensorsPerWedge * kFstNumStripsPerOuterSensor) * kFstNumWedgePerDisk);
32 };
33 
34 unsigned char StMuFstRawHit::getWedge() const
35 {
36  return 1 + mGeoId / (kFstNumInnerSensorsPerWedge * kFstNumStripsPerInnerSensor + kFstNumOuterSensorsPerWedge * kFstNumStripsPerOuterSensor);
37 };
38 
39 unsigned char StMuFstRawHit::getPhiStrip() const
40 {
41  int strip = mGeoId % (kFstNumInnerSensorsPerWedge * kFstNumStripsPerInnerSensor + kFstNumOuterSensorsPerWedge * kFstNumStripsPerOuterSensor);
42  return strip % kFstNumPhiSegPerWedge;
43 };
44 
45 unsigned char StMuFstRawHit::getRStrip() const
46 {
47  int strip = mGeoId % (kFstNumInnerSensorsPerWedge * kFstNumStripsPerInnerSensor + kFstNumOuterSensorsPerWedge * kFstNumStripsPerOuterSensor);
48  return strip / kFstNumPhiSegPerWedge;
49 };
50 
51 unsigned char StMuFstRawHit::getRdo() const
52 {
53  return 1 + mChannelId / (kFstNumArmsPerRdo * kFstNumChanPerArm);
54 };
55 
56 unsigned char StMuFstRawHit::getArm() const
57 {
58  return (mChannelId % (kFstNumArmsPerRdo * kFstNumChanPerArm)) / kFstNumChanPerArm;
59 };
60 
61 unsigned char StMuFstRawHit::getApv() const
62 {
63  return ((mChannelId % (kFstNumArmsPerRdo * kFstNumChanPerArm)) % kFstNumChanPerArm) / kFstNumApvChannels;
64 };
65 
66 unsigned char StMuFstRawHit::getSensor() const
67 {
68  int strip = mChannelId % (kFstNumInnerSensorsPerWedge * kFstNumStripsPerInnerSensor + kFstNumOuterSensorsPerWedge * kFstNumStripsPerOuterSensor);
69  if(strip < kFstNumStripsPerInnerSensor) return strip/kFstNumStripsPerInnerSensor;
70  else return strip / kFstNumStripsPerOuterSensor - 1;
71 };
72 
73 unsigned char StMuFstRawHit::getChannel() const
74 {
75  return ((mChannelId % (kFstNumArmsPerRdo * kFstNumChanPerArm)) % kFstNumChanPerArm) % kFstNumApvChannels;
76 };
77 
78 float StMuFstRawHit::getCharge( int tb ) const
79 {
80  return mCharge[ (tb < 0 || tb >= kFstNumTimeBins) ? mDefaultTimeBin : tb ];
81 };
82 
83 float StMuFstRawHit::getChargeErr( int tb ) const
84 {
85  return mChargeErr[ (tb < 0 || tb >= kFstNumTimeBins) ? mDefaultTimeBin : tb ];
86 };
87 
88 //modifiers
89 void StMuFstRawHit::setChannelId(int rChannelId)
90 {
91  mChannelId = rChannelId;
92 };
93 
94 void StMuFstRawHit::setGeoId(int rGeoId)
95 {
96  mGeoId = rGeoId;
97 };
98 
99 void StMuFstRawHit::setSeedhitflag(int rSeedhitflag)
100 {
101  mSeedhitflag = rSeedhitflag;
102 };
103 
104 void StMuFstRawHit::setDefaultTimeBin( int tb )
105 {
106  mDefaultTimeBin = tb;
107 };
108 
109 void StMuFstRawHit::setIdTruth(unsigned short idTruth)
110 {
111  mIdTruth = idTruth;
112 };
113 
114 void StMuFstRawHit::setCharge( float charge, int tb )
115 {
116  mCharge[ (tb < 0 || tb >= kFstNumTimeBins) ? mDefaultTimeBin : tb ] = charge;
117 };
118 
119 
120 void StMuFstRawHit::setChargeErr(float rChargeErr, int tb)
121 {
122  mChargeErr[ (tb < 0 || tb >= kFstNumTimeBins) ? mDefaultTimeBin : tb ] = rChargeErr;
123 };
124 
125 void StMuFstRawHit::setMaxTimeBin(int tb)
126 {
127  mMaxTimeBin = ((tb < 0 || tb >= kFstNumTimeBins) ? mDefaultTimeBin : tb);
128 };
129 
130 
131 void StMuFstRawHit::print(int nTimeBins)
132 {
133  LOG_DEBUG << " elecId=" << getChannelId() << " Charge=(" ;
134  for(int i=0; i<nTimeBins; i++)
135  LOG_DEBUG << getCharge(i) << " " ;
136  LOG_DEBUG << ") ChargeErr=(" ;
137 
138  for(int i=0; i<nTimeBins; i++)
139  LOG_DEBUG << getChargeErr(i) << " " ;
140  LOG_DEBUG << ") decode0: at disk=" << (short) getDisk() << " wedge=" << (short) getWedge() << " sensor=" << (short) getSensor()
141  << " rstrip=" << (short) getRStrip() << " phistrip=" << (short) getPhiStrip() << endm;
142 }
143 
144 unsigned char StMuFstRawHit::mDefaultTimeBin = 2;
145 
146 void StMuFstRawHit::set( StFstRawHit *hit ){
147 
148  mChannelId = hit->getChannelId();
149  mGeoId = hit->getGeoId();
150  mSeedhitflag = hit->getSeedhitflag();
151  for(int ibin=0; ibin<kFstNumTimeBins; ibin++){
152  mCharge[ibin] = hit->getCharge(ibin);
153  mChargeErr[ibin] = hit->getChargeErr(ibin);
154  }
155  mMaxTimeBin = hit->getMaxTimeBin();
156  mIdTruth = hit->getIdTruth();
157 
158  mDefaultTimeBin = hit->getDefaultTimeBin();
159 } // set from StEvent
unsigned char getApv() const
0-15
unsigned char getRStrip() const
0-7
int getSeedhitflag() const
0 or 1
unsigned char getChannel() const
0-127
int getGeoId() const
0-36863
Definition: StFstRawHit.cxx:51
unsigned char getRdo() const
1-6
int getChannelId() const
0-36863
unsigned char getDisk() const
1-3
unsigned char getArm() const
0-2
int getGeoId() const
0-36863
unsigned short getIdTruth() const
for embedding, 0 as background
unsigned short getIdTruth() const
for embedding, 0 as background
Definition: StFstRawHit.cxx:55
int getChannelId() const
0-36863
Definition: StFstRawHit.cxx:50
unsigned char getSensor() const
0-2
unsigned char getWedge() const
1-36
int getSeedhitflag() const
0 or 1
Definition: StFstRawHit.cxx:52
unsigned char getPhiStrip() const
0-127