35 #include "StDaqLib/GENERIC/EventReader.hh"
40 using namespace OLDEVP;
51 banks = (classname(Bank_SVTADCR) *)NULL;
54 SVTV1P0_ADCR_SR::SVTV1P0_ADCR_SR(
int b,
int l,
int w,
SVTV1P0_Reader *det)
63 banks = (classname(Bank_SVTADCR) *)NULL;
66 int SVTV1P0_ADCR_SR::initialize()
69 anodkr = detector->getANODKReader();
70 if (!anodkr)
return FALSE;
72 int hypersector, rcb, mz;
78 anodkr->get(barrel, ladder, wafer, hybrid, &ent);
80 anodkr->get(wafer, hybrid, &ent);
82 hypersector = ent.hypersector;
91 if ((hypersector) && (rcb) && (mz)) {
92 banks = detector->getBankSVTADCR(hypersector,rcb,mz);
96 if (banks->header.FormatNumber == 2) {
98 u_char *adc_old = (u_char *)banks->ADC;
99 u_char adc_new[6][256][128];
100 for (hybrid=0; hybrid<6; hybrid++) {
101 u_char *ptr0 = adc_old + hybrid*128*256;
102 u_char *ptr64 = adc_old + hybrid*128*256 + 1;
103 u_char *ptr128 = adc_old + hybrid*128*256 + 2;
104 u_char *ptr192 = adc_old + hybrid*128*256 + 3;
105 for (
int anode=0; anode<64; anode++)
106 for (
int tb=0; tb<128; tb++) {
107 adc_new[hybrid][anode][tb] = *ptr0;
108 adc_new[hybrid][anode+64][tb] = *ptr64;
109 adc_new[hybrid][anode+128][tb] = *ptr128;
110 adc_new[hybrid][anode+192][tb] = *ptr192;
111 ptr0+=4; ptr64+=4; ptr128+=4; ptr192+=4;
114 memcpy((
void *)adc_old, (
const void *)adc_new, 6*256*128);
117 banks->header.FormatNumber = 0;
127 SVTV1P0_ADCR_SR::~SVTV1P0_ADCR_SR()
132 int SVTV1P0_ADCR_SR::getPadList(
int hybrid, u_char **anodeList)
140 for(i=1; i<=SVT_ANODES; i++)
143 anodkr->get(barrel, ladder, wafer, hybrid, &ent);
145 anodkr->get(wafer, hybrid, &ent);
147 if((ent.mz == 0) || (ent.rb == 0) || (ent.hypersector == 0))
continue;
148 anodelist[hybrid-1][j++] = i;
151 *anodeList = &anodelist[hybrid-1][0];
155 int SVTV1P0_ADCR_SR::getSequences(
int hybrid,
int Anode,
int *nArray,
160 anodkr->get(barrel, ladder, wafer, hybrid, &ent);
162 anodkr->get(wafer, hybrid, &ent);
164 if((ent.mz == 0) || (ent.rb == 0) || (ent.hypersector == 0))
172 int offset = (ent.offset * anodkr->getADCBytes() * SVT_MZANODES) +
173 (anodkr->getADCBytes() * (Anode-1));
174 *nArray = anodkr->getADCBytes();
181 *Array = (((u_char *)banks->ADC) + offset);
189 int SVTV1P0_ADCR_SR::MemUsed()
205 banks = (classname(Bank_SVTPEDR) *)NULL;
209 SVTV1P0_PEDR_SR::SVTV1P0_PEDR_SR(
int b,
int l,
int w,
SVTV1P0_Reader *det)
218 banks = (classname(Bank_SVTPEDR) *)NULL;
222 int SVTV1P0_PEDR_SR::initialize()
225 anodkr = detector->getANODKReader();
226 if (!anodkr)
return FALSE;
228 int hypersector, rcb, mz;
234 anodkr->get(barrel, ladder, wafer, hybrid, &ent);
236 anodkr->get(wafer, hybrid, &ent);
238 hypersector = ent.hypersector;
242 banks = detector->getBankSVTPEDR(hypersector,rcb,mz);
245 numEvents = banks->NumEvents;
247 if (banks->header.FormatNumber == 2) {
249 u_char *adc_old = (u_char *)banks->pedestal;
250 u_char adc_new[6][256][128];
251 for (hybrid=0; hybrid<6; hybrid++) {
252 u_char *ptr0 = adc_old + hybrid*128*256;
253 u_char *ptr64 = adc_old + hybrid*128*256 + 1;
254 u_char *ptr128 = adc_old + hybrid*128*256 + 2;
255 u_char *ptr192 = adc_old + hybrid*128*256 + 3;
256 for (
int anode=0; anode<64; anode++)
257 for (
int tb=0; tb<128; tb++) {
258 adc_new[hybrid][anode][tb] = *ptr0;
259 adc_new[hybrid][anode+64][tb] = *ptr64;
260 adc_new[hybrid][anode+128][tb] = *ptr128;
261 adc_new[hybrid][anode+192][tb] = *ptr192;
262 ptr0+=4; ptr64+=4; ptr128+=4; ptr192+=4;
265 memcpy((
void *)adc_old, (
const void *)adc_new, 6*256*128);
268 banks->header.FormatNumber = 0;
275 SVTV1P0_PEDR_SR::~SVTV1P0_PEDR_SR()
280 int SVTV1P0_PEDR_SR::getPadList(
int hybrid, u_char **anodeList)
288 for(i=1; i<=SVT_ANODES; i++)
291 anodkr->get(barrel, ladder, wafer, hybrid, &ent);
293 anodkr->get(wafer, hybrid, &ent);
295 if((ent.mz == 0) || (ent.rb == 0) || (ent.hypersector == 0))
continue;
296 anodelist[hybrid-1][j++] = i;
299 *anodeList = &anodelist[hybrid-1][0];
303 int SVTV1P0_PEDR_SR::getSequences(
int hybrid,
int Anode,
int *nArray,
308 anodkr->get(barrel, ladder, wafer, hybrid, &ent);
310 anodkr->get(wafer, hybrid, &ent);
312 if((ent.mz == 0) || (ent.rb == 0) || (ent.hypersector == 0))
320 int offset = (ent.offset * anodkr->getPEDBytes() * SVT_MZANODES) +
321 (anodkr->getPEDBytes() * (Anode-1));
322 *nArray = anodkr->getPEDBytes();
327 *Array = (((u_char *)banks->pedestal) + offset);
333 int SVTV1P0_PEDR_SR::getNumberOfEvents()
338 int SVTV1P0_PEDR_SR::MemUsed()
355 banks = (classname(Bank_SVTRMSR) *)NULL;
360 SVTV1P0_PRMS_SR::SVTV1P0_PRMS_SR(
int b,
int l,
int w,
SVTV1P0_Reader *det)
369 banks = (classname(Bank_SVTRMSR) *)NULL;
373 int SVTV1P0_PRMS_SR::initialize()
376 anodkr = detector->getANODKReader();
377 if (!anodkr)
return FALSE;
379 int hypersector, rcb, mz;
385 anodkr->get(barrel, ladder, wafer, hybrid, &ent);
387 anodkr->get(wafer, hybrid, &ent);
389 hypersector = ent.hypersector;
393 banks = detector->getBankSVTRMSR(hypersector,rcb,mz);
396 numEvents = banks->NumEvents;
399 if (banks->header.FormatNumber == 2) {
401 u_char *adc_old = (u_char *)banks->pedRMSt16;
402 u_char adc_new[6][256][128];
403 for (hybrid=0; hybrid<6; hybrid++) {
404 u_char *ptr0 = adc_old + hybrid*128*256;
405 u_char *ptr64 = adc_old + hybrid*128*256 + 1;
406 u_char *ptr128 = adc_old + hybrid*128*256 + 2;
407 u_char *ptr192 = adc_old + hybrid*128*256 + 3;
408 for (
int anode=0; anode<64; anode++)
409 for (
int tb=0; tb<128; tb++) {
410 adc_new[hybrid][anode][tb] = *ptr0;
411 adc_new[hybrid][anode+64][tb] = *ptr64;
412 adc_new[hybrid][anode+128][tb] = *ptr128;
413 adc_new[hybrid][anode+192][tb] = *ptr192;
414 ptr0+=4; ptr64+=4; ptr128+=4; ptr192+=4;
417 memcpy((
void *)adc_old, (
const void *)adc_new, 6*256*128);
420 banks->header.FormatNumber = 0;
427 SVTV1P0_PRMS_SR::~SVTV1P0_PRMS_SR()
432 int SVTV1P0_PRMS_SR::getPadList(
int hybrid, u_char **anodeList)
440 for(i=1; i<=SVT_ANODES; i++)
443 anodkr->get(barrel, ladder, wafer, hybrid, &ent);
445 anodkr->get(wafer, hybrid, &ent);
447 if((ent.mz == 0) || (ent.rb == 0) || (ent.hypersector == 0))
continue;
448 anodelist[hybrid-1][j++] = i;
451 *anodeList = &anodelist[hybrid-1][0];
455 int SVTV1P0_PRMS_SR::getSequences(
int hybrid,
int Anode,
int *nArray,
460 anodkr->get(barrel, ladder, wafer, hybrid, &ent);
462 anodkr->get(wafer, hybrid, &ent);
464 if((ent.mz == 0) || (ent.rb == 0) || (ent.hypersector == 0))
472 int offset = (ent.offset * anodkr->getRMSBytes() * SVT_MZANODES) +
473 (anodkr->getRMSBytes() * (Anode-1));
474 *nArray = anodkr->getRMSBytes();
480 *Array = (((u_char *)banks->pedRMSt16) + offset);
486 int SVTV1P0_PRMS_SR::getNumberOfEvents()
491 int SVTV1P0_PRMS_SR::MemUsed()