ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
packet_cdevpolarimeter.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file packet_cdevpolarimeter.cc
2 #include <stdio.h>
3 
5  : Packet_w4 (data)
6 {
7  ps = 0;
8  haspoldata = 0;
9 }
10 
12 {
13 
14  if (ps != 0) return 0;
15 
16  int *k = (int *) findPacketDataStart(packet);
17  if (k == 0)
18  {
19  ps = 0;
20  *nwout = 0;
21  return 0;
22  }
23 
24  if ( getHitFormat() == IDCDEVPOLARIMETER )
25  {
26  haspoldata = 0;
27  ps = ( struct cdevPolarimeterData *) &k[1];
28  }
29  else if (getHitFormat() == IDCDEVPOLARIMETERZ )
30  {
31  haspoldata = 1;
32  ps = ( struct cdevPolarimeterData *) &k[1];
33  }
34 
35  // fix_endianess (&ps->m_cdevCaptureTimeStamp);
36  // ejd 4/26/03 strings are garbled do not byte swap
37  // fix_endianess (&ps->runIdS);
38  //fix_endianess ( ps->daqVersionS, 80);
39  //fix_endianess ( ps->cutIdS, 80);
40  //fix_endianess ( ps->targetIdS, 80);
41  //fix_endianess ( ps->statusStringS, 80);
42 
43 
44  // fix_endianess(&ps->startTimeS); // Unix time
45  // fix_endianess(&ps->stopTimeS); // Unix time
46 
47  // for (i=0; i<2; i++) fix_endianess(&ps->encoderPositionS[i]);
48  // fix_endianess(&ps->statusS); // bit pattern if <0 data is not usable
49  // fix_endianess(&ps->totalCountsS);
50  // fix_endianess(&ps->upCountsS);
51  // fix_endianess(&ps->downCountsS);
52  // fix_endianess(&ps->unpolCountsS);
53 
54 // for (i=0; i<360; i++) fix_endianess(&ps->countsUpLeftS[i]);
55 // for (i=0; i<360; i++) fix_endianess(&ps->countsLeftS[i]);
56 // for (i=0; i<360; i++)fix_endianess(&ps->countsDownLeftS[i]);
57 // for (i=0; i<360; i++)fix_endianess(&ps->countsDownRightS[i]);
58 // for (i=0; i<360; i++)fix_endianess(&ps->countsRightS[i]);
59 // for (i=0; i<360; i++)fix_endianess(&ps->countsUpRightS[i]);
60 
61 
62 
63 // fix_endianess(&ps->numberEventsS); // provided by MCR before measurement
64 // fix_endianess(&ps->maxTimeS);
65 
66  *nwout = 0;
67 
68  return 0;
69 }
70 
71 
72 // ------------------------------------------------------
73 
74 
76 {
77 
78  int i;
79 
80  decode (&i);
81 
82  this->identify(os);
83 
84  os << "daqVersionS " << ps->daqVersionS << std::endl;
85  os << "cutIdS " << ps->cutIdS << std::endl;
86  os << "targetIdS " << ps->targetIdS << std::endl;
87  os << "statusStringS " << ps->statusStringS << std::endl;
88 
89  os << "m_cdevCaptureTimeStamp " << ps->m_cdevCaptureTimeStamp << std::endl;
90  os << "runIdS " << ps->runIdS << std::endl; // FILL.XXX --- where XXX is the run number
91  os << "startTimeS " << ps->startTimeS << std::endl; // Unix time
92  os << "stopTimeS " << ps->stopTimeS << std::endl; // Unix time
93  os << "encoderPositionS " << ps->encoderPositionS[0] <<" " << ps->encoderPositionS[1] << std::endl;
94 
95  // os << ps->daqVersionS << std::endl;
96  // os << ps->cutIdS << std::endl;
97  //os << ps->targetIdS << std::endl;
98 
99  os << "statusS " << ps->statusS << std::endl; // bit pattern if <0 data is not usable
100  os << "totalCountsS " << ps->totalCountsS << std::endl;
101  os << "upCountsS " << ps->upCountsS << std::endl;
102  os << "downCountsS " << ps->downCountsS << std::endl;
103  os << "unpolCountsS " << ps->unpolCountsS << std::endl;
104  os << "avgAsymXS " << ps->avgAsymXS << std::endl;
105  os << "avgAsymX45S " << ps->avgAsymX45S << std::endl;
106  os << "avgAsymX90S " << ps->avgAsymX90S << std::endl;
107  os << "avgAsymYS " << ps->avgAsymYS << std::endl;
108  os << "avgAsymErrorXS " << ps->avgAsymErrorXS << std::endl;
109  os << "avgAsymErrorX45S " << ps->avgAsymErrorX45S << std::endl;
110  os << "avgAsymErrorX90S " << ps->avgAsymErrorX90S << std::endl;
111  os << "avgAsymErrorYS " << ps->avgAsymErrorYS << std::endl;
112 
113  os << "beamEnergyS " << ps->beamEnergyS << std::endl; // the same as ringSpec.color:beamEnergyM just for reference
114 
115 
116  os << "analyzingPowerS " << ps->analyzingPowerS << std::endl;
117  os << "analyzingPowerErrorS " << ps->analyzingPowerErrorS << std::endl;
118  os << "numberEventsS " << ps->numberEventsS << std::endl; // provided by MCR before measurement
119  os << "maxTimeS " << ps->maxTimeS << std::endl;
120  if (haspoldata )
121  {
122  os << "polarizationM " << ps->polarizationM << std::endl;
123  }
124 
125 
126 
127 
128  os << " index AsymXS AsymYS AsymErrorXS AsymErrorYS UpLeftS LeftS DownLeftS DownRightS RightS UpRightS" << std::endl;
129 
130 
131  for (i=0; i< 360; i++)
132  {
133 
134  os << std::setw(5) << i << " | ";
135 
136 
137  os << std::setw(12) << rValue(i,"bunchAsymXS"); //ps->bunchAsymXS[i];
138  os << std::setw(12) << rValue(i,"bunchAsymYS"); //ps->bunchAsymYS[i];
139  os << std::setw(12) << ps->bunchAsymErrorXS[i];
140  os << std::setw(12) << ps->bunchAsymErrorYS[i];
141 
142  os << std::setw(12) << ps->countsUpLeftS[i];
143  os << std::setw(12) << ps->countsLeftS[i];
144  os << std::setw(12) << ps->countsDownLeftS[i];
145  os << std::setw(12) << ps->countsDownRightS[i];
146  os << std::setw(12) << ps->countsRightS[i];
147  os << std::setw(12) << ps->countsUpRightS[i] << std::endl;
148  }
149 
150 
151  dumpErrorBlock(os);
152  dumpDebugBlock(os);
153 }
154 
155 
156 int Packet_cdevpolarimeter::iValue(const int ich, const char *what)
157 {
158 
159  int i;
160  decode (&i);
161 
162  if ( strcmp(what, "cdevCaptureTimeStamp") == 0 ) return ps->m_cdevCaptureTimeStamp ; // is this not an int??
163  if ( strcmp(what, "startTimeS") == 0 ) return ps->startTimeS ; // Unix time
164  if ( strcmp(what, "stopTimeS") == 0 ) return ps->stopTimeS ; // Unix time
165 
166  if ( strcmp(what,"daqVersionS") == 0)
167  {
168  if ( ich >= 0 && ich < 80)
169  return ps->daqVersionS[ich];
170  }
171 
172  if ( strcmp(what,"cutIdS") == 0)
173  {
174  if ( ich >= 0 && ich < 80)
175  return ps->cutIdS[ich];
176  }
177 
178  if ( strcmp(what,"targetIdS") == 0)
179  {
180  if ( ich >= 0 && ich < 80)
181  return ps->targetIdS[ich];
182  }
183 
184  if ( strcmp(what, "encoderPositionS") == 0 )
185  {
186  if ( ich >= 0 && ich < 2 )
187  return ps->encoderPositionS[ich];
188  }
189 
190  if ( strcmp(what, "statusS") == 0 ) return ps->statusS ;
191 
192  if ( strcmp(what, "statusStringS") == 0 )
193  {
194  if ( ich >= 0 && ich < 2 )
195  return ps->statusStringS[ich];
196  }
197 
198  if ( strcmp(what, "totalCountsS") == 0 ) return ps->totalCountsS ;
199  if ( strcmp(what, "upCountsS") == 0 ) return ps->upCountsS ;
200  if ( strcmp(what, "downCountsS") == 0 ) return ps->downCountsS ;
201  if ( strcmp(what, "unpolCountsS") == 0 ) return ps->unpolCountsS ;
202  if ( strcmp(what,"countsUpLeftS") == 0)
203  {
204  if ( ich >= 0 && ich < 360)
205  return ps->countsUpLeftS[ich];
206  }
207 
208 
209  if ( strcmp(what,"countsLeftS") == 0)
210  {
211  if ( ich >= 0 && ich < 360)
212  return ps->countsLeftS[ich];
213  }
214 
215  if ( strcmp(what,"countsDownLeftS") == 0)
216  {
217  if ( ich >= 0 && ich < 360)
218  return ps->countsDownLeftS[ich];
219  }
220 
221  if ( strcmp(what,"countsDownRightS") == 0)
222  {
223  if ( ich >= 0 && ich < 360)
224  return ps->countsDownRightS[ich];
225  }
226 
227  if ( strcmp(what,"countsRightS") == 0)
228  {
229  if ( ich >= 0 && ich < 360)
230  return ps->countsRightS[ich];
231  }
232 
233  if ( strcmp(what,"countsUpRightS") == 0)
234  {
235  if ( ich >= 0 && ich < 360)
236  return ps->countsUpRightS[ich];
237  }
238 
239  if ( strcmp(what, "numberEventsS") == 0 ) return ps->numberEventsS ;
240  if ( strcmp(what, "maxTimeS") == 0 ) return ps->maxTimeS ;
241 
242  std::cout << "packet_cdevpolarimeter::iValue error unknown datum: " << what << std::endl;
243  return 0;
244 }
245 
246 
247 float Packet_cdevpolarimeter::rValue(const int ich, const char *what)
248 {
249 
250 
251  // std::cout << "IN Packet_cdevpolarimeter::rValue " << std::endl;
252  int i;
253  decode (&i);
254 
255  if ( strcmp(what, "avgAsymXS") == 0 ) return ps->avgAsymXS ;
256  if ( strcmp(what, "avgAsymX45S") == 0 ) return ps->avgAsymX45S ;
257  if ( strcmp(what, "avgAsymX90S") == 0 ) return ps->avgAsymX90S ;
258  if ( strcmp(what, "avgAsymYS") == 0 ) return ps->avgAsymYS ;
259  if ( strcmp(what, "avgAsymErrorXS") == 0 ) return ps->avgAsymErrorXS ;
260  if ( strcmp(what, "avgAsymErrorX45S") == 0 ) return ps->avgAsymErrorX45S ;
261  if ( strcmp(what, "avgAsymErrorX90S") == 0 ) return ps->avgAsymErrorX90S ;
262  if ( strcmp(what, "avgAsymErrorYS") == 0 ) return ps->avgAsymErrorYS ;
263 
264 
265  if ( strcmp(what,"bunchAsymXS") == 0)
266  {
267  if ( ich >= 0 && ich < 360)
268  return ps->bunchAsymXS[ich];
269  }
270 
271  if ( strcmp(what,"bunchAsymYS") == 0)
272  {
273  if ( ich >= 0 && ich < 360)
274  return ps->bunchAsymYS[ich];
275  }
276 
277  if ( strcmp(what,"bunchAsymErrorXS") == 0)
278  {
279  if ( ich >= 0 && ich < 360)
280  return ps->bunchAsymErrorXS[ich];
281  }
282 
283  if ( strcmp(what,"bunchAsymErrorYS") == 0)
284  {
285  if ( ich >= 0 && ich < 360)
286  return ps->bunchAsymErrorYS[ich];
287  }
288 
289 
290  if ( strcmp(what, "beamEnergyS") == 0 ) return ps->beamEnergyS ;
291  if ( strcmp(what, "analyzingPowerS") == 0 ) return ps->analyzingPowerS ;
292  if ( strcmp(what, "analyzingPowerErrorS") == 0 ) return ps->analyzingPowerErrorS ;
293  if (haspoldata )
294  {
295  if ( strcmp(what, "polarizationM") == 0 ) return ps->polarizationM ;
296  }
297 
298  std::cout << "packet_cdevpolarimeter::iValue error unknown datum: " << what << std::endl;
299  return 0.;
300 }
301 
302 
303 double Packet_cdevpolarimeter::dValue(const int ich, const char *what)
304 {
305 
306 
307  // std::cout << "IN Packet_cdevpolarimeter::rValue " << std::endl;
308  int i;
309  decode (&i);
310 
311  if ( strcmp(what, "runIdS") == 0 ) return ps->runIdS ; // FILL.XXX --- where XXX is the run number
312 
313  std::cout << "packet_cdevpolarimeter::iValue error unknown datum: " << what << std::endl;
314  return 0;
315 }
316 
317 
318