StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StBTofHeader.cxx
1 /***************************************************************************
2  *
3  * $Id: StBTofHeader.cxx,v 2.6 2021/05/28 19:00:21 ullrich Exp $
4  *
5  * Author: Xin Dong, Nov 2008
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StBTofHeader.cxx,v $
13  * Revision 2.6 2021/05/28 19:00:21 ullrich
14  * Added 3 member plus access fct: mTCanFirst, mTCanLast, mNTzeroCan (Frank)
15  *
16  * Revision 2.5 2010/05/12 15:12:03 ullrich
17  * Added member mNTzero and access methods.
18  *
19  * Revision 2.4 2009/11/23 22:45:51 ullrich
20  * Fixed order of operator precedence in removeVpdHit().
21  *
22  * Revision 2.3 2009/11/23 22:24:05 ullrich
23  * Cleaned up compiler warning in removeVpdHit().
24  *
25  * Revision 2.2 2009/01/15 00:45:19 ullrich
26  * mTriggerTime becomes array, setVpdVz() gets default argument.
27  *
28  * Revision 2.1 2008/12/22 20:30:56 ullrich
29  * Initial Revision.
30  *
31  *
32  **************************************************************************/
33 #include "StBTofHeader.h"
34 #include "PhysicalConstants.h"
35 
36 ClassImp(StBTofHeader)
37 
39 {
40  for(int i=0; i<MAXFIBER; i++) {
41  mFiberHeader[i] = -1;
42  mFiberTriggerWord[i] = 0;
43  mTriggerTime[i] = 0;
44  }
45  for(int i=0; i<2; i++) mVpdHitPattern[i] = 0;
46  for(int i=0; i<MAXVPDVZ; i++) mVpdVz[i] = -999.;
47  mTStart = 0.;
48  mTStartErr = 0.;
49  mTDiff = -999.;
50  for(int i=0; i<2; i++)
51  for(int j=0; j<MAXVPD; j++)
52  mVpdTime[i][j] = 0.;
53  mNTzero = 0;
54  mNTzeroCan = 0;
55  mTCanFirst = 99999.;
56  mTCanLast = -99999.;
57  mVpdEHits = 0;
58  mVpdWHits = 0;
59  mVpdEGoodHits = 0;
60  mVpdWGoodHits = 0;
61  mEarliestVpdEHit = 99999.;
62  mEarliestVpdWHit = 99999.;
63  mClosestVpdEHit = 99999.;
64  mClosestVpdWHit = 99999.;
65  mLatestVpdEHit = -99999.;
66  mLatestVpdWHit = -99999.;
67 }
68 
69 StBTofHeader::~StBTofHeader() {/* no op */}
70 
71 short
72 StBTofHeader::fiberHeader(int fiberId) const { return mFiberHeader[fiberId]; }
73 
74 unsigned int
75 StBTofHeader::fiberTriggerWord(int fiberId) const { return mFiberTriggerWord[fiberId]; }
76 
77 unsigned int
78 StBTofHeader::vpdHitPattern(StBeamDirection eastwest) const
79 {
80  return mVpdHitPattern[eastwest];
81 }
82 
83 unsigned short
84 StBTofHeader::numberOfVpdHits(StBeamDirection eastwest) const
85 {
86  unsigned short nHit = 0;
87  for(int i=0; i<MAXVPD; i++) {
88  int tubeId = i + 1;
89  if (isVpdHit(eastwest, tubeId)) nHit++;
90  }
91  return nHit;
92 }
93 
94 bool
95 StBTofHeader::isVpdHit(StBeamDirection eastwest, int tubeId) const
96 {
97  return ( (mVpdHitPattern[eastwest])>>(tubeId-1) ) & 0x1;
98 }
99 
100 float
101 StBTofHeader::vpdVz(int rank) const
102 {
103  return mVpdVz[rank];
104 }
105 
106 double
107 StBTofHeader::tStart() const { return mTStart; }
108 
109 double
110 StBTofHeader::tStartError() const { return mTStartErr; }
111 
112 double
113 StBTofHeader::tDiff() const { return mTDiff; }
114 
115 double
116 StBTofHeader::vpdTime(StBeamDirection eastwest, int tubeId) const
117 {
118  return mVpdTime[eastwest][tubeId-1];
119 }
120 
121 unsigned int
122 StBTofHeader::triggerTime(int fiberId) const { return mTriggerTime[fiberId]; }
123 
124 int
125 StBTofHeader::nTzero() const { return mNTzero; }
126 
127 int
128 StBTofHeader::nTzeroCan() const { return mNTzeroCan; }
129 
130 double
131 StBTofHeader::tCanFirst() const { return mTCanFirst; }
132 
133 double
134 StBTofHeader::tCanLast() const { return mTCanLast; }
135 
136 int
137 StBTofHeader::vpdEHits() const { return mVpdEHits; }
138 
139 int
140 StBTofHeader::vpdWHits() const { return mVpdWHits; }
141 
142 int
143 StBTofHeader::vpdEGoodHits() const { return mVpdEGoodHits; }
144 
145 int
146 StBTofHeader::vpdWGoodHits() const { return mVpdWGoodHits; }
147 
148 double
149 StBTofHeader::earliestVpdEHit() const { return mEarliestVpdEHit; }
150 
151 double
152 StBTofHeader::earliestVpdWHit() const { return mEarliestVpdWHit; }
153 
154 double
155 StBTofHeader::closestVpdEHit() const { return mClosestVpdEHit; }
156 
157 double
158 StBTofHeader::closestVpdWHit() const { return mClosestVpdWHit; }
159 
160 double
161 StBTofHeader::latestVpdEHit() const { return mLatestVpdEHit; }
162 
163 double
164 StBTofHeader::latestVpdWHit() const { return mLatestVpdWHit; }
165 
166 void
167 StBTofHeader::setFiberHeader(int fiberId, short val)
168 {
169  mFiberHeader[fiberId] = val;
170 }
171 
172 void
173 StBTofHeader::setFiberTriggerWord(int fiberId, unsigned int val)
174 {
175  mFiberTriggerWord[fiberId] = val;
176 }
177 
178 void
179 StBTofHeader::setVpdHit(StBeamDirection eastwest, int tubeId)
180 {
181  mVpdHitPattern[eastwest] |= 0x1 << (tubeId-1);
182 }
183 
184 void
185 StBTofHeader::removeVpdHit(StBeamDirection eastwest, int tubeId)
186 {
187  mVpdHitPattern[eastwest] &= ( 0x7ffff - (0x1 << (tubeId-1)) );
188 }
189 
190 void
191 StBTofHeader::setVpdHitPattern(StBeamDirection eastwest, unsigned int val)
192 {
193  mVpdHitPattern[eastwest] = val;
194 }
195 
196 void
197 StBTofHeader::setVpdVz(float vz, int rank)
198 {
199  mVpdVz[rank] = vz;
200 }
201 
202 void
203 StBTofHeader::setTStart(double t) { mTStart = t; }
204 
205 void
206 StBTofHeader::setTStartError(double t_err) { mTStartErr = t_err; }
207 
208 void
209 StBTofHeader::setTDiff(double tdiff) { mTDiff = tdiff; }
210 
211 void
212 StBTofHeader::setVpdTime(StBeamDirection eastwest, int tubeId, double t)
213 {
214  mVpdTime[eastwest][tubeId-1] = t;
215 }
216 
217 void
218 StBTofHeader::setTriggerTime(unsigned int tdc, int fiberId) { mTriggerTime[fiberId] = tdc; }
219 
220 void
221 StBTofHeader::setNTzero(short n) { mNTzero = n; }
222 
223 void
224 StBTofHeader::setNTzeroCan(short nCan) { mNTzeroCan = nCan; }
225 
226 void
227 StBTofHeader::setTCanFirst(double tFirst) { mTCanFirst = tFirst; }
228 
229 void
230 StBTofHeader::setTCanLast(double tLast) { mTCanLast = tLast; }
231 
232 void
233 StBTofHeader::setVpdEHits(short vpdEHits) { mVpdEHits = vpdEHits; }
234 
235 void
236 StBTofHeader::setVpdWHits(short vpdWHits) { mVpdWHits = vpdWHits; }
237 
238 void
239 StBTofHeader::setVpdEGoodHits(short vpdEGoodHits) { mVpdEGoodHits = vpdEGoodHits; }
240 
241 void
242 StBTofHeader::setVpdWGoodHits(short vpdWGoodHits) { mVpdWGoodHits = vpdWGoodHits; }
243 
244 void
245 StBTofHeader::setEarliestVpdEHit(double earliestVpdEHit) { mEarliestVpdEHit = earliestVpdEHit; }
246 
247 void
248 StBTofHeader::setEarliestVpdWHit(double earliestVpdWHit) { mEarliestVpdWHit = earliestVpdWHit; }
249 
250 void
251 StBTofHeader::setClosestVpdEHit(double closestVpdEHit) { mClosestVpdEHit = closestVpdEHit; }
252 
253 void
254 StBTofHeader::setClosestVpdWHit(double closestVpdWHit) { mClosestVpdWHit = closestVpdWHit; }
255 
256 void
257 StBTofHeader::setLatestVpdEHit(double latestVpdEHit) { mLatestVpdEHit = latestVpdEHit; }
258 
259 void
260 StBTofHeader::setLatestVpdWHit(double latestVpdWHit) { mLatestVpdWHit = latestVpdWHit; }