StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StIstRawHit.cxx
1 // $Id: StIstRawHit.cxx,v 1.20 2018/01/04 17:34:38 smirnovd Exp $
2 
3 #include <algorithm>
4 
5 #include "StIstRawHit.h"
6 #include "St_base/StMessMgr.h"
7 
8 using namespace StIstConsts;
9 
10 
11 bool rawHitPtrLessThan::operator() (const StIstRawHit *rawHit1, const StIstRawHit *rawHit2) const
12 {
13  if ( rawHit1 && rawHit2 )
14  return (rawHit1->getGeoId() < rawHit2->getGeoId());
15  else
16  return 0;
17 }
18 
19 
20 StIstRawHit::StIstRawHit() : StObject(), mChannelId(-1), mGeoId(-1), mCharge(), mChargeErr(), mMaxTimeBin(3),
21  mIdTruth(0)
22 {
23  std::fill_n(mCharge, kIstNumTimeBins, -999);
24 }
25 
26 
27 template<typename Container>
28 StIstRawHit::StIstRawHit(int channelId, int geoId,
29  const Container &charges, const Container &chargeErrs,
30  UChar_t maxTimeBin, UShort_t idTruth) :
31  StObject(),
32  mChannelId(channelId), mGeoId(geoId), mCharge(), mChargeErr(),
33  mMaxTimeBin(maxTimeBin), mIdTruth(idTruth)
34 {
35  std::copy(std::begin(charges), std::end(charges), mCharge);
36  std::copy(std::begin(chargeErrs), std::end(chargeErrs), mChargeErr);
37 }
38 
39 
40 int StIstRawHit::getChannelId() const { return mChannelId; };
41 int StIstRawHit::getGeoId() const { return mGeoId; };
42 unsigned char StIstRawHit::getMaxTimeBin() const { return mMaxTimeBin; };
43 unsigned char StIstRawHit::getDefaultTimeBin() { return mDefaultTimeBin;};
44 unsigned short StIstRawHit::getIdTruth() const { return mIdTruth; };
45 
46 unsigned char StIstRawHit::getLadder() const
47 {
48  return 1 + (mGeoId - 1) / (kIstNumSensorsPerLadder * kIstNumPadsPerSensor);
49 };
50 
51 unsigned char StIstRawHit::getSensor() const
52 {
53  return 1 + ((mGeoId - 1) % (kIstNumSensorsPerLadder * kIstNumPadsPerSensor)) / kIstNumPadsPerSensor;
54 };
55 
56 unsigned char StIstRawHit::getRow() const
57 {
58  int pad = ((mGeoId - 1) % (kIstNumSensorsPerLadder * kIstNumPadsPerSensor)) % kIstNumPadsPerSensor;
59  return 1 + pad % kIstNumRowsPerSensor;
60 };
61 
62 unsigned char StIstRawHit::getColumn() const
63 {
64  int pad = ((mGeoId - 1) % (kIstNumSensorsPerLadder * kIstNumPadsPerSensor)) % kIstNumPadsPerSensor;
65  return 1 + pad / kIstNumRowsPerSensor;
66 };
67 
68 unsigned char StIstRawHit::getRdo() const
69 {
70  return 1 + mChannelId / (kIstNumArmsPerRdo * kIstNumChanPerArm);
71 };
72 
73 unsigned char StIstRawHit::getArm() const
74 {
75  return (mChannelId % (kIstNumArmsPerRdo * kIstNumChanPerArm)) / kIstNumChanPerArm;
76 };
77 
78 unsigned char StIstRawHit::getApv() const
79 {
80  return ((mChannelId % (kIstNumArmsPerRdo * kIstNumChanPerArm)) % kIstNumChanPerArm) / kIstNumApvChannels;
81 };
82 
83 unsigned char StIstRawHit::getChannel() const
84 {
85  return ((mChannelId % (kIstNumArmsPerRdo * kIstNumChanPerArm)) % kIstNumChanPerArm) % kIstNumApvChannels;
86 };
87 
88 float StIstRawHit::getCharge( int tb ) const
89 {
90  return mCharge[ (tb < 0 || tb >= kIstNumTimeBins) ? mDefaultTimeBin : tb ];
91 };
92 
93 float StIstRawHit::getChargeErr( int tb ) const
94 {
95  return mChargeErr[ (tb < 0 || tb >= kIstNumTimeBins) ? mDefaultTimeBin : tb ];
96 };
97 
98 //modifiers
99 void StIstRawHit::setChannelId(int rChannelId)
100 {
101  mChannelId = rChannelId;
102 };
103 
104 void StIstRawHit::setGeoId(int rGeoId)
105 {
106  mGeoId = rGeoId;
107 };
108 
109 void StIstRawHit::setDefaultTimeBin( int tb )
110 {
111  mDefaultTimeBin = tb;
112 };
113 
114 void StIstRawHit::setIdTruth(unsigned short idTruth)
115 {
116  mIdTruth = idTruth;
117 };
118 
119 void StIstRawHit::setCharge( float charge, int tb )
120 {
121  mCharge[ (tb < 0 || tb >= kIstNumTimeBins) ? mDefaultTimeBin : tb ] = charge;
122 };
123 
124 
125 void StIstRawHit::setChargeErr(float rChargeErr, int tb)
126 {
127  mChargeErr[ (tb < 0 || tb >= kIstNumTimeBins) ? mDefaultTimeBin : tb ] = rChargeErr;
128 };
129 
130 void StIstRawHit::setMaxTimeBin(int tb)
131 {
132  mMaxTimeBin = ((tb < 0 || tb >= kIstNumTimeBins) ? mDefaultTimeBin : tb);
133 };
134 
135 
136 void StIstRawHit::Print(int nTimeBins) const
137 {
138  LOG_DEBUG << " elecId=" << getChannelId() << " Charge=(" ;
139  for(int i=0; i<nTimeBins; i++)
140  LOG_DEBUG << getCharge(i) << " " ;
141  LOG_DEBUG << ") ChargeErr=(" ;
142 
143  for(int i=0; i<nTimeBins; i++)
144  LOG_DEBUG << getChargeErr(i) << " " ;
145  LOG_DEBUG << ") decode0: at ladder=" << (short) getLadder() << " sensor=" << (short) getSensor()
146  << " column=" << (short) getColumn() << " row=" << (short) getRow() << endm;
147 }
148 
149 unsigned char StIstRawHit::mDefaultTimeBin = 2;
150 
151 ClassImp(StIstRawHit);
const int kIstNumPadsPerSensor
768 pads in each sensor
unsigned char getLadder() const
1-24
Definition: StIstRawHit.cxx:46
unsigned char getArm() const
0-5
Definition: StIstRawHit.cxx:73
unsigned char getColumn() const
1-12
Definition: StIstRawHit.cxx:62
unsigned char getRow() const
1-64
Definition: StIstRawHit.cxx:56
int getGeoId() const
1-110592
Definition: StIstRawHit.cxx:41
unsigned char getApv() const
0-23
Definition: StIstRawHit.cxx:78
int getChannelId() const
0-110591
Definition: StIstRawHit.cxx:40
Float_t mChargeErr
charge uncertainty
Definition: StIstHit.h:55
unsigned short getIdTruth() const
for embedding, 0 as background
Definition: StIstRawHit.cxx:44
unsigned char getRdo() const
1-6
Definition: StIstRawHit.cxx:68
const int kIstNumSensorsPerLadder
6 sensor per one IST Ladder
unsigned char getChannel() const
0-127
Definition: StIstRawHit.cxx:83
unsigned char getSensor() const
1-6
Definition: StIstRawHit.cxx:51
const int kIstNumRowsPerSensor
64 rows in r-phi direction per each sensor