StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StZdcTriggerDetector.cxx
1 /***************************************************************************
2  *
3  * $Id: StZdcTriggerDetector.cxx,v 2.14 2006/09/14 00:02:53 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, Sep 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StZdcTriggerDetector.cxx,v $
13  * Revision 2.14 2006/09/14 00:02:53 ullrich
14  * Removed argument (run) in constructor. Not needed anymore.
15  *
16  * Revision 2.13 2006/08/21 19:43:35 ullrich
17  * Run number becomes constructor argument. Needed for ZDC. (Akio)
18  *
19  * Revision 2.12 2006/02/06 18:52:59 ullrich
20  * Fixed bug in constructor. mAdc[3] and mAdc[7] were wrong.
21  *
22  * Revision 2.11 2004/04/14 22:47:06 ullrich
23  * SMD problem fixed.
24  *
25  * Revision 2.10 2004/04/06 19:39:44 ullrich
26  * Added ZDC SMD support.
27  *
28  * Revision 2.9 2004/02/11 01:42:09 ullrich
29  * Added new constructor to load data from StTriggerData.
30  *
31  * Revision 2.8 2002/03/05 17:11:52 ullrich
32  * Corrected bug in constructor. Wrong table entry was used.
33  *
34  * Revision 2.7 2001/09/14 19:11:11 ullrich
35  * Load corrected vertex-Z from trigger table.
36  *
37  * Revision 2.6 2001/07/12 22:58:33 ullrich
38  * Added variable to store the vertex_z from timing info.
39  *
40  * Revision 2.5 2001/04/05 04:00:59 ullrich
41  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
42  *
43  * Revision 2.4 2000/07/13 12:51:09 ullrich
44  * Added new method numberOfZdcWords to replace old one with wrong name.
45  *
46  * Revision 2.3 1999/12/21 15:09:28 ullrich
47  * Modified to cope with new compiler version on Sun (CC5.0).
48  *
49  * Revision 2.2 1999/10/28 22:28:21 ullrich
50  * Adapted new StArray version. First version to compile on Linux and Sun.
51  *
52  * Revision 2.1 1999/10/13 19:45:50 ullrich
53  * Initial Revision
54  *
55  **************************************************************************/
56 #include <algorithm>
57 #include "StZdcTriggerDetector.h"
58 #include "tables/St_dst_TrgDet_Table.h"
59 #include "StTriggerData.h"
60 #if !defined(ST_NO_NAMESPACES)
61 using std::fill_n;
62 using std::copy;
63 #endif
64 
65 static const char rcsid[] = "$Id: StZdcTriggerDetector.cxx,v 2.14 2006/09/14 00:02:53 ullrich Exp $";
66 
67 ClassImp(StZdcTriggerDetector)
68 
70 {
71  fill_n(mAdc, static_cast<int>(mMaxZdcWords), 0);
72  fill_n(mTdc, static_cast<int>(mMaxZdcWords), 0);
73  fill_n(mZdcSmdEast, static_cast<int>(mMaxZdcWords), 0);
74  fill_n(mZdcSmdWest, static_cast<int>(mMaxZdcWords), 0);
75  fill_n(mSumAdc, 2, 0);
76  mSum = 0;
77  mVertexZ = 0;
78 }
79 
80 StZdcTriggerDetector::StZdcTriggerDetector(const dst_TrgDet_st& t)
81 {
82  copy(t.adcZDC+0, t.adcZDC+mMaxZdcWords, mAdc);
83  copy(t.tdcZDC+0, t.tdcZDC+mMaxZdcWords, mTdc);
84  fill_n(mZdcSmdEast, static_cast<int>(mMaxZdcWords), 0);
85  fill_n(mZdcSmdWest, static_cast<int>(mMaxZdcWords), 0);
86  mSumAdc[east] = t.adcZDCEast;
87  mSumAdc[west] = t.adcZDCWest;
88  mSum = t.adcZDCsum;
89  mVertexZ = t.ZDCvertexZ;
90 }
91 
92 StZdcTriggerDetector::StZdcTriggerDetector(const StTriggerData& t)
93 {
94  //
95  // This is a temporary fix only. In future this
96  // class will become obsolete and users should
97  // get this info from StTriggerData.
98  // This info is only a subset of what is available
99  // in StTriggerData.
100  // tu 2/10/2004
101  //
102 
103  // unattenuated
104  mAdc[0] = t.zdcUnAttenuated(west);
105  mAdc[1] = t.zdcADC(west, 3);
106  mAdc[2] = t.zdcADC(west, 2);
107  mAdc[3] = t.zdcADC(west, 1); // was 2 bug ?
108  mAdc[4] = t.zdcUnAttenuated(east);
109  mAdc[5] = t.zdcADC(east, 3);
110  mAdc[6] = t.zdcADC(east, 2);
111  mAdc[7] = t.zdcADC(east, 1); // was 2 bug ?
112  // TDC
113  mAdc[8] = t.zdcTDC(east);
114  mAdc[9] = t.zdcTDC(west);
115  // attenuated
116  mAdc[10] = t.zdcAttenuated(west);
117  mAdc[11] = t.zdcAtAddress(11);
118  mAdc[12] = t.zdcAtAddress(12);
119  mAdc[13] = t.zdcAttenuated(east);
120  mAdc[14] = t.zdcAtAddress(14);
121  mAdc[15] = t.zdcAtAddress(15);
122  mVertexZ = t.zdcVertexZ();
123 
124  mSumAdc[east] = t.zdcAttenuated(east);
125  mSumAdc[west] = t.zdcAttenuated(west);
126  mSum = t.zdcAtAddress(14);
127 
128  for (int i=0; i<mMaxZdcWords; i++)
129  mZdcSmdEast[i] = t.zdcSMD(east, ((i>7) ? 1 : 0), ((i>7) ? (i-7) : (i+1)));
130  for (int i=0; i<mMaxZdcWords; i++)
131  mZdcSmdWest[i] = t.zdcSMD(west, ((i>7) ? 1 : 0), ((i>7) ? (i-7) : (i+1)));
132 
133  fill_n(mTdc, static_cast<int>(mMaxZdcWords), 0); // always 0
134 }
135 
136 StZdcTriggerDetector::~StZdcTriggerDetector() {/* noop */}
137 
138 unsigned int
139 StZdcTriggerDetector::numberOfZdcCounters() const {return mMaxZdcWords;}
140 
141 unsigned int
142 StZdcTriggerDetector::numberOfZdcWords() const {return mMaxZdcWords;}
143 
144 float
145 StZdcTriggerDetector::adc(unsigned int i) const
146 {
147  if (i < mMaxZdcWords)
148  return mAdc[i];
149  else
150  return 0;
151 }
152 
153 float
154 StZdcTriggerDetector::tdc(unsigned int i) const
155 {
156  if (i < mMaxZdcWords)
157  return mTdc[i];
158  else
159  return 0;
160 }
161 
162 float
163 StZdcTriggerDetector::adcSum(StBeamDirection dir) const
164 {
165  return mSumAdc[dir];
166 }
167 
168 
169 float
170 StZdcTriggerDetector::zdcSmd(StBeamDirection eastwest, int verthori, int strip) const
171 {
172 
173  if (eastwest<0 || eastwest>1) return 0.;
174  if (verthori<0 || verthori>1) return 0.;
175  if (strip > 8) return 0.;
176 
177  return ((eastwest<1) ? (mZdcSmdEast[strip -1 + verthori*8]) : (mZdcSmdWest[strip-1 + verthori*8]));
178 }
179 
180 
181 float
182 StZdcTriggerDetector::adcSum() const {return mSum;}
183 
184 float
185 StZdcTriggerDetector::vertexZ() const {return mVertexZ;}
186 
187 void
188 StZdcTriggerDetector::setAdc(unsigned int i, float val)
189 {
190  if (i < mMaxZdcWords)
191  mAdc[i] = val;
192 }
193 
194 void
195 StZdcTriggerDetector::setTdc(unsigned int i, float val)
196 {
197  if (i < mMaxZdcWords)
198  mTdc[i] = val;
199 }
200 
201 void
202 StZdcTriggerDetector::setAdcSum(StBeamDirection dir, float val)
203 {
204  mSumAdc[dir] = val;
205 }
206 
207 void
208 StZdcTriggerDetector::setAdcSum(float val)
209 {
210  mSum = val;
211 }
212 
213 void
214 StZdcTriggerDetector::setVertexZ(float val)
215 {
216  mVertexZ = val;
217 }
218 
219 void
220 StZdcTriggerDetector::setZdcSmd(StBeamDirection eastwest, int verthori, int strip, float val)
221 {
222  if (eastwest<0 || eastwest>1) return ;
223  if (verthori<0 || verthori>1) return ;
224  if (strip > 8) return ;
225 
226  if (eastwest==0) mZdcSmdEast[strip -1 + verthori*8] = val;
227  else if (eastwest==1) mZdcSmdWest[strip -1 + verthori*8] = val;
228 
229 }