00001
00002
00003
00004
00005 #include <iostream>
00006 #include <assert.h>
00007
00008
00009 #include "EEfeeTP.h"
00010
00011
00012
00013
00014
00015 EEfeeTP::EEfeeTP( int xcrate, const char *TPname, int lenX, int xcha0L, int xcha0H) {
00016
00017 assert(lenX%2==0);
00018 lenCh=lenX;
00019 cha0L=xcha0L;
00020 cha0H=xcha0H;
00021 crateID=xcrate;
00022 strncpy(name,TPname,mxTxt);
00023 nT=0;
00024 }
00025
00026
00027
00028
00029 void
00030 EEfeeTP::clear() {
00031 memset(adc12,0,sizeof(adc12));
00032 memset(ped4,0,sizeof(ped4));
00033 memset(chanID,0,sizeof(chanID));
00034 memset(adc10p,0,sizeof(adc10p));
00035 memset(adc6,0,sizeof(adc6));
00036
00037 nT=0;
00038 HT6b=0;
00039 TPsum6b=0;
00040 HTchId=-2;
00041 }
00042
00043
00044
00045 void
00046 EEfeeTP::compute(int *adcA, int *ped4A, int *maskA, int highTowerMask, int patchSumMask){
00047
00048
00049 int i;
00050 int len=lenCh;
00051 if(cha0H>0) len=len/2;
00052
00053 for (i=0; i<len; i++){
00054 if( maskA[cha0L+i]) continue;
00055 adc12[nT]= adcA[cha0L+i] & 0xfff;
00056 ped4 [nT]=ped4A[cha0L+i];
00057 chanID[nT]= cha0L+i;
00058 nT++;
00059 }
00060
00061 if(cha0H>0) {
00062 for (i=0; i<len; i++){
00063 if( maskA[cha0H+i]) continue;
00064 adc12[nT]= adcA[cha0H+i] & 0xfff;
00065 ped4 [nT]=ped4A[cha0H+i];
00066 chanID[nT]= cha0H+i;
00067 nT++;
00068 }
00069 }
00070
00071
00072 HTchId=-1;
00073 HT6b=0;
00074 int TPsum8b=0;
00075
00076 for (i=0; i<nT; i++){
00077 int adc10=adc12[i]>>2;
00078 int x10=adc10+ped4[i];
00079 if ( x10<0) x10=0;
00080 x10 &= 0x3ff;
00081 adc10p[i]=x10;
00082 TPsum8b+=x10 >>2;
00083
00084
00085 int y=x10;
00086 if(( y>>7) & 0x7 ) y |=(1<<7);
00087 y=( y >> 2 ) & 0x3f;
00088 adc6[i]=y;
00089
00090 if( HT6b < y ) {
00091 HT6b=y;
00092 HTchId=chanID[i];
00093 }
00094
00095 }
00096
00097 TPsum6b =TPsum8b - nT + 1;
00098
00099 if (TPsum6b <0 ) TPsum6b=0;
00100 if (TPsum6b > 62) TPsum6b=62;
00101
00102 if (!highTowerMask) HT6b = 0;
00103 if (!patchSumMask) TPsum6b = 0;
00104 }
00105
00106
00107
00108
00109 void
00110 EEfeeTP::print( int k) const {
00111 printf("EEfeeTP: name=%s nT=%d\n",name,nT);
00112 int i;
00113 printf(" channel: "); for(i=0;i<nT;i++) printf(" %4d",chanID[i]); printf("\n");
00114 printf(" rawADC : "); for(i=0;i<nT;i++) printf(" %4d",adc12[i]);printf("\n");
00115 printf(" ped4: "); for(i=0;i<nT;i++) printf(" %4d",ped4[i]);printf("\n");
00116 printf(" adc10+p: "); for(i=0;i<nT;i++) printf(" %4d",adc10p[i]);printf("\n");
00117 printf(" adc6 : ");
00118 for(i=0;i<nT;i++) {
00119 printf("%4d",adc6[i]);
00120 if(HTchId==chanID[i]) printf("*"); else printf(" ");
00121 }
00122 printf("\nOUTPUT: HT6b=%d TPsum6b=%d \n",getOutHT(),getOutTPsum());
00123 }
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144