1 #include "SSD_Reader.hh"
2 #include "StDaqLib/EVP/ssdReader.h"
8 static unsigned short log8to10_table[256] = {
9 0, 1, 2, 3, 4, 5, 6, 7,
10 8, 9, 10, 11, 12, 13, 14, 15,
11 16, 17, 18, 19, 20, 21, 22, 23,
12 24, 25, 26, 27, 28, 29, 30, 31,
13 32, 33, 34, 35, 36, 37, 38, 39,
14 40, 41, 42, 43, 44, 45, 46, 47,
15 48, 49, 50, 51, 52, 53, 54, 55,
16 56, 57, 58, 59, 60, 61, 62, 63,
17 64, 65, 66, 67, 68, 69, 70, 71,
18 72, 73, 74, 75, 76, 77, 78, 79,
19 80, 81, 82, 83, 84, 85, 86, 87,
20 88, 89, 90, 91, 92, 93, 94, 95,
21 96, 97, 98, 99, 100, 101, 102, 103,
22 104, 105, 106, 107, 108, 110, 112, 114,
23 116, 118, 120, 122, 124, 127, 129, 131,
24 133, 136, 138, 140, 143, 145, 147, 150,
25 152, 155, 158, 160, 163, 166, 168, 171,
26 174, 177, 180, 182, 185, 188, 192, 195,
27 198, 201, 204, 208, 211, 214, 218, 221,
28 225, 228, 232, 236, 240, 243, 247, 251,
29 255, 259, 263, 267, 271, 275, 280, 284,
30 288, 293, 297, 302, 306, 311, 316, 321,
31 325, 330, 335, 341, 346, 351, 356, 362,
32 367, 373, 379, 384, 390, 396, 402, 408,
33 414, 420, 427, 433, 439, 446, 452, 459,
34 466, 473, 480, 487, 494, 502, 509, 517,
35 525, 532, 540, 548, 556, 564, 573, 581,
36 589, 598, 607, 615, 624, 634, 643, 652,
37 662, 672, 681, 691, 701, 711, 722, 732,
38 743, 753, 764, 775, 786, 798, 809, 821,
39 833, 845, 857, 870, 882, 895, 907, 920,
40 934, 947, 961, 975, 989, 1003, 1017, 1023 };
45 using namespace OLDEVP;
47 int SSD_Reader::ssdData(
int ladder,
54 int cnt=0,strip,pad,i,det,pos,mtime,time,daqLadder;
55 static unsigned int cache1[12288];
56 static unsigned int cache2[12288];
57 static int daqLadderInit=-1;
59 data = -1; ped = -1; noise= -1;
62 daqLadder = SSDDaqLadder(eastWest,ladder);
67 if(daqLadderInit!=daqLadder) {
68 daqLadderInit=daqLadder;
69 for(i=0;i<12288;i++) { cache1[i]=0; cache2[i]=0; }
72 for(time=0;time<192;time++) {
73 for(pad=0;pad<64;pad++) {
74 if (!ssd.counts[daqLadder][pad])
continue;
75 for(mtime=0;mtime<ssd.counts[daqLadder][pad];mtime++) {
76 if (time==ssd.strip[daqLadder][pad][mtime])
78 det=pos/768; strip=pos%768;
79 assert(pos>=0&&pos<12288);
80 cache1[pos]=log8to10_table[ssd.adc[daqLadder][pad][mtime]];
87 }
else if(ssd.mode==1) {
89 for(time=0;time<192;time++) {
90 for(pad=0;pad<64;pad++) {
91 cache1[pos]=ssd.adc[daqLadder][pad][time];
92 cache2[pos]=ssd.strip[daqLadder][pad][time];
102 data=cache1[channel];
103 }
else if(ssd.mode==1) {
105 noise=cache2[channel];
119 datap=er->getDATAP();
122 std::time_t utime = er->getEventInfo().UnixTime;
123 std::tm *time = gmtime(&utime);
129 LDate = (1900+time->tm_year)*10000 + (1 + time->tm_mon)*100 + time->tm_mday;
130 LTime = (time->tm_hour*100 + time->tm_min)*100 + time->tm_sec;
132 #ifndef NEW_DAQ_READER_DAQLIB
133 OLDEVP::ssdReader(datap);
137 daqReader *rdr=er->getDaqReader(); assert(rdr);
138 ::ssdReader((
char*)rdr);
143 int SSD_Reader::SSDDaqLadder(
char eastWest,
int ladder)
147 if ( (LDate < 20040731) && (LTime < 1)){
153 case 1: daqLadder=38;
break;
154 case 2: daqLadder=36;
break;
155 case 3: daqLadder=39;
break;
156 case 9: daqLadder=29;
break;
157 case 10: daqLadder=26;
break;
158 case 11: daqLadder=28;
break;
159 case 12: daqLadder=23;
break;
160 case 13: daqLadder=20;
break;
161 case 19: daqLadder=30;
break;
162 case 20: daqLadder=33;
break;
168 case 1: daqLadder=18;
break;
169 case 2: daqLadder=16;
break;
170 case 3: daqLadder=19;
break;
171 case 9: daqLadder= 9;
break;
172 case 10: daqLadder= 6;
break;
173 case 11: daqLadder= 8;
break;
174 case 12: daqLadder= 3;
break;
175 case 13: daqLadder= 0;
break;
176 case 19: daqLadder=10;
break;
177 case 20: daqLadder=13;
break;
183 if ((LDate >= 20040731) && (LDate <= 20050731))
190 case 1: daqLadder=27;
break;
191 case 2: daqLadder=29;
break;
192 case 3: daqLadder=26;
break;
193 case 4: daqLadder=28;
break;
194 case 5: daqLadder=25;
break;
195 case 6: daqLadder=22;
break;
196 case 7: daqLadder=24;
break;
197 case 8: daqLadder=21;
break;
198 case 9: daqLadder=23;
break;
199 case 10: daqLadder=20;
break;
200 case 11: daqLadder=30;
break;
201 case 12: daqLadder=33;
break;
202 case 13: daqLadder=31;
break;
203 case 14: daqLadder=34;
break;
204 case 15: daqLadder=32;
break;
205 case 16: daqLadder=35;
break;
206 case 17: daqLadder=38;
break;
207 case 18: daqLadder=36;
break;
208 case 19: daqLadder=39;
break;
209 case 20: daqLadder=37;
break;
215 case 1: daqLadder=7;
break;
216 case 2: daqLadder=9;
break;
217 case 3: daqLadder=6;
break;
218 case 4: daqLadder=8;
break;
219 case 5: daqLadder=5;
break;
220 case 6: daqLadder=2;
break;
221 case 7: daqLadder=4;
break;
222 case 8: daqLadder=1;
break;
223 case 9: daqLadder=3;
break;
224 case 10: daqLadder=0;
break;
225 case 11: daqLadder=10;
break;
226 case 12: daqLadder=13;
break;
227 case 13: daqLadder=11;
break;
228 case 14: daqLadder=14;
break;
229 case 15: daqLadder=12;
break;
230 case 16: daqLadder=15;
break;
231 case 17: daqLadder=18;
break;
232 case 18: daqLadder=16;
break;
233 case 19: daqLadder=19;
break;
234 case 20: daqLadder=17;
break;
240 if(LDate > 20060731) {
246 case 1: daqLadder=27;
break;
247 case 2: daqLadder=29;
break;
248 case 3: daqLadder=26;
break;
249 case 4: daqLadder=28;
break;
250 case 5: daqLadder=25;
break;
251 case 6: daqLadder=22;
break;
252 case 7: daqLadder=24;
break;
253 case 8: daqLadder=21;
break;
254 case 9: daqLadder=23;
break;
255 case 10: daqLadder=20;
break;
256 case 11: daqLadder=30;
break;
257 case 12: daqLadder=33;
break;
258 case 13: daqLadder=31;
break;
259 case 14: daqLadder=34;
break;
260 case 15: daqLadder=32;
break;
261 case 16: daqLadder=35;
break;
262 case 17: daqLadder=38;
break;
263 case 18: daqLadder=36;
break;
264 case 19: daqLadder=39;
break;
265 case 20: daqLadder=37;
break;
271 case 1: daqLadder=17;
break;
272 case 2: daqLadder=19;
break;
273 case 3: daqLadder=16;
break;
274 case 4: daqLadder=18;
break;
275 case 5: daqLadder=15;
break;
276 case 6: daqLadder=12;
break;
277 case 7: daqLadder=14;
break;
278 case 8: daqLadder=11;
break;
279 case 9: daqLadder=13;
break;
280 case 10: daqLadder=10;
break;
281 case 11: daqLadder=0;
break;
282 case 12: daqLadder=3;
break;
283 case 13: daqLadder=1;
break;
284 case 14: daqLadder=4;
break;
285 case 15: daqLadder=2;
break;
286 case 16: daqLadder=5;
break;
287 case 17: daqLadder=8;
break;
288 case 18: daqLadder=6;
break;
289 case 19: daqLadder=9;
break;
290 case 20: daqLadder=7;
break;
297 assert(daqLadder>=0 && daqLadder < 40);