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