5 #include "L2gammaAlgo.h"
6 #include "L2gammaResult2006.h"
8 #include "bemcConstants.h"
9 #include "eemcConstants.h"
23 if(strstr(name,
"etow_gamma")) {
24 geom= L2gammaAlgo::kEEmcAlgo; thresh = L2gammaAlgo::kThresh1;
25 }
else if(strstr(name,
"etow_ht2")) {
26 geom= L2gammaAlgo::kEEmcAlgo; thresh = L2gammaAlgo::kThresh2;
27 }
else if(strstr(name,
"btow_gamma")) {
28 geom= L2gammaAlgo::kBEmcAlgo; thresh = L2gammaAlgo::kThresh1;
29 }
else if(strstr(name,
"btow_ht2")) {
30 geom= L2gammaAlgo::kBEmcAlgo; thresh = L2gammaAlgo::kThresh2;
32 printf(
"undefined config of L2gamma-algo ->%s<-, abort L2main\n",name);
38 printf(
"L2gammaEmCall2006 instantiated geom=%d thresh=%d logpath=%s\n",geom,thresh,mOutDir);
53 mThresholdLevel=thresh;
54 init(geom,I_par,F_par);
69 printf(
"+ init geom=%d\n",geom);
78 for (
int i=0;i<5;i++ )
80 mDefaultI_par[i]=I_par[i];
81 mDefaultF_par[i]=F_par[i];
84 if ( I_par[1] ) mPrescale=I_par[1];
89 mEEmc=geom;mBEmc=!geom;
91 mNumEtas = (
mEEmc)? kEEmcNumEtas : kBEmcNumEtas;
92 mNumPhis = (
mEEmc)? kEEmcNumPhis : kBEmcNumPhis;
93 mNumSubs = (
mEEmc)? kEEmcNumSubs : kBEmcNumSubs;
94 mNumSecs = (
mEEmc)? kEEmcNumSecs : kBEmcNumSecs;
96 mNumTower = (
mEEmc)? kEEmcNumTower : kBEmcNumTower;
97 mNumClust = mNumTower;
99 mEtaBins = (
mEEmc)? kEEmcEtaBins : kBEmcEtaBins;
101 mMaxADC = (
mEEmc)? kEEmcMaxADC : kBEmcMaxADC;
102 mMaxET = (
mEEmc)? kEEmcMaxET : kBEmcMaxET;
103 mIdealGainT = (
mEEmc)? kEEmcIdealGainT : kBEmcIdealGainT;
105 const char *names[]={
"bemc",
"eemc"};
107 printf(
"L2gammaAlgo v0.92 (prociutto) \n");
108 printf(
"registering new threshold for %4s \n",names[geom]);
113 printf(
"============================================================================\n");
119 printf(
"algorithm residing at %p\n",
this);
120 printf(
"l2algo used as input at %p\n",
mL2input);
123 printf(
"mNumEtas = %-2d\n",mNumEtas);
124 printf(
"mNumPhis = %-4d\n",mNumPhis);
125 printf(
"mNumSubs = %-4d\n",mNumSubs);
126 printf(
"mNumSecs = %-4d\n",mNumSecs);
127 printf(
"mNumTower = %-4d\n",mNumTower);
128 printf(
"mNumClust = %-4d\n",mNumClust);
129 printf(
"mNumRdo = %-4d\n",mNumRdo);
130 printf(
"mEtaBins = {");
131 for (
int i=0;i<mNumEtas+1;i++ ) {
132 printf(
"%4.2f, ",mEtaBins[i]);
133 if ( !((i+1)%4) ) printf(
"\n ");
136 printf(
"mMaxADC = %4d\n",mMaxADC);
137 printf(
"mMaxET = %4.1f\n",mMaxET);
138 printf(
"mIdealGainT = %5.3f\n",mIdealGainT);
140 printf(
"============================================================================\n");
174 return initRun(run,mDefaultI_par,mDefaultF_par);
178 return initRun( run, I_par, F_par );
184 printf(
"%s ::initRun() for run=%d\n",mName,run);
186 if ( mDb->initRun(run) )
return -7;
195 if ( I_par[1] ) mPrescale = I_par[1];
206 if ( F_par[1] < 0. ) {
207 printf(
"L2gammaAlgo::ERROR -- patch threshold < 0\n");
210 if ( F_par[1] > 2.0 * F_par[0] ) {
211 printf(
"L2gammaAlgo::ERROR -- patch threshold > 2x tower threshold\n");
217 if ( F_par[0] <
mL2input->getPatchThreshold() ) {
218 printf(
"L2gammaAlgo::WARNING -- l2input to this algorithm has a patch threshold < tower threshold\n");
223 if ( I_par[0] < 0 || I_par[0] > 1 )
225 printf(
"L2gammaAlgo::ERROR -- I_par[0] should be 0 (use ideal gains) or 1 (use online gains)\n");
232 if ( mLogFile && mLogFile != stdout ) fclose(mLogFile);
233 if ( mHistFile ) fclose(mHistFile);
238 sprintf(clog,
"%s/run%d.l2%s.out",mOutDir,run,mName);
242 mLogFile=fopen(clog,
"w");
244 if(mLogFile==0) printf(
"%s ::initRun() for run=%d UNABLE to open log-file=%s=, it is not fatal, continue initialization\n",mName,run,clog);
247 fprintf(mLogFile,
"\n\n====================================================================================================================================\n");
248 fprintf(mLogFile,
"L2gammaAlgo start of run %d summary, compiled: %s , %s\n",run,__DATE__,__TIME__);
249 fprintf(mLogFile,
"calorimeter: %s\n",mName);
250 fprintf(mLogFile,
"run: %d\n",run);
252 fprintf(mLogFile,
"prescaled accept I[1]: %d\n",mPrescale);
253 fprintf(mLogFile,
"threshold level: %d\n",mThresholdLevel);
254 fprintf(mLogFile,
"tower threshold F[0]: %-5.2f [GeV]\n",
mTowerThreshold);
255 fprintf(mLogFile,
"patch threshold F[1]: %-5.2f [GeV]\n",
mPatchThreshold);
256 fprintf(mLogFile,
"patch size: %s\n",
"3x3");
257 fprintf(mLogFile,
"logfile: %s\n",clog);
259 fprintf(mLogFile,
"database at: %p\n",mDb);
260 fprintf(mLogFile,
"l2 input at: %p\n",
mL2input);
262 fprintf(mLogFile,
"\nDetector Geometry\n");
263 fprintf(mLogFile,
"mEtaBins = {");
264 for (
int i=0;i<mNumEtas+1;i++ ) {
265 fprintf(mLogFile,
"%4.2f, ",mEtaBins[i]);
266 if ( !((i+1)%4) ) fprintf(mLogFile,
"\n ");
268 fprintf(mLogFile,
"X}\n");
269 fprintf(mLogFile,
"mMaxADC = %4d\n",mMaxADC);
270 fprintf(mLogFile,
"mMaxET = %4.1f\n",mMaxET);
271 fprintf(mLogFile,
"mIdealGainT = %5.3f\n",mIdealGainT);
272 fprintf(mLogFile,
"\n");
274 fprintf(mLogFile,
"\n");
276 if ( !mDb )
return 100;
288 if(mLogFile) fprintf(mLogFile,
"initialize EMC ascii database\n\n");
290 if(mLogFile) fprintf(mLogFile,
"\n");
296 float *emc_ideal_gains =
new float[mNumEtas];
297 if(mLogFile) fprintf(mLogFile,
"configure ideal gains for %d eta bins\n",mNumEtas);
298 for (
int i=0;i<mNumEtas;i++ )
300 float eta_mean = mEtaBins[ i ] + mEtaBins[ i+1 ];
302 emc_ideal_gains[i] = mMaxADC / mMaxET / cosh(eta_mean);
303 if(mLogFile) fprintf(mLogFile,
"+ etabin=%d eta=%5.2f bemc ideal gain=%5.2f\n", i+1, eta_mean, emc_ideal_gains[i]);
307 if ( mNumEtas != 12 && mNumEtas != 40 ) {
308 if(mLogFile) fprintf(mLogFile,
"L2gammaEmCal::FATAL ERROR -- expect 12 or 40 etabins, got %d\n",mNumEtas);
309 if(mLogFile) fprintf(mLogFile,
" + likely cause -- invalid runtime parameter\n");
310 delete emc_ideal_gains;
315 for (
int index=0;index<mNumTower;index++ )
321 mTowerFrequency[index]=0;
322 mPatchFrequency[index]=0;
323 mTowerGain[index]=-1.0;
326 if(mLogFile) fprintf(mLogFile,
"\nInitializing tower ADC threshods\n");
329 for (
int index=0; index<EmcDbIndexMax; index++ )
335 if ( x==0 )
continue;
339 if ( mBEmc && !mDb->isBTOW(x) )
341 if (
mEEmc && !mDb->isETOW(x) )
350 int sec = x->sec - 1;
352 if (
mEEmc ) sub = x->sub -
'A';
353 if ( mBEmc ) sub = x->sub -
'a';
354 int eta = x->eta - 1;
355 int phi =
phibin(sec,sub);
356 int tow = tower(phi,eta);
368 float gain = x->gain;
369 float ideal = emc_ideal_gains[eta];
374 unsigned short stat = x->stat;
375 unsigned short fail = x->fail;
377 if(mLogFile) fprintf(mLogFile,
"L2gammaEmCal::WARN %s gain=%5.2f will be masked\n",x->name,x->gain);
382 mTowerFail[rdo]=fail; mPatchFail[rdo]=fail;
383 mTowerGain[rdo]=gain;
384 mTowerGainIdeal[rdo]=ideal;
390 mTowerAdcCorrection[rdo]=0.;
406 mTower2rdo[ tow ] = rdo;
418 if(mLogFile) fprintf(mLogFile,
"Initializing 3x3 tower cluster thresholds\n");
422 for (
int index=0; index<EmcDbIndexMax; index++ )
428 if ( x==0 )
continue;
431 if ( mBEmc && !mDb->isBTOW(x) )
433 if (
mEEmc && !mDb->isETOW(x) )
437 int sec = x->sec - 1;
439 if (
mEEmc ) sub = x->sub -
'A';
440 if ( mBEmc ) sub = x->sub -
'a';
441 int eta = x->eta - 1;
442 int phi =
phibin(sec,sub);
447 mPatchFail[rdo] |= x->fail;
453 if ( x->fail )
continue;
454 if ( mTowerFail[rdo] )
continue;
466 for (
int ieta=eta-1;ieta<=eta+1;ieta++ )
467 for (
int iphi=phi-1;iphi<=phi+1;iphi++ )
470 if ( ieta < 0 || ieta > mNumEtas-1 )
continue;
472 int jphi=(iphi+mNumPhis)%mNumPhis;
473 int jtow=tower(jphi,jeta);
474 int jrdo=mTower2rdo[jtow];
477 mTowerAdcCorrection[rdo];
480 if(mLogFile) fprintf(mLogFile,
"+ name=%s ped=%5.2f gfact=%5.2f thresh=%5.2f\n",x->name,x->ped,mTowerAdcCorrection[rdo],
mPatchAdcThreshold[jrdo] );
485 mPatchPed[jrdo]+=ped;
488 mRdoPatch[rdo][nn++]=jrdo;
503 for (
int index=0;index<EmcDbIndexMax;index++ )
510 if ( x==0 )
continue;
514 if ( mBEmc && !mDb->isBTOW(x) )
516 if (
mEEmc && !mDb->isETOW(x) )
522 if ( gain==0. ) gain=-1.;
525 int eta=tow%mNumEtas;
533 fprintf(mLogFile,
"tower=%s tow=%d rdo=%d mask=%2x gain=%5.2f ideal=%5.2f ped=%5.2f thr=%d %5.2f GeV patch=%5.2f + %5.2f GeV\n",
539 emc_ideal_gains[eta],
548 if(mLogFile) fprintf(mLogFile,
"tower=%s tow=%d rdo=%d ideal=%5.2f thr=%d patch=%5.2f GeV\n",
552 emc_ideal_gains[eta],
561 #ifdef DEBUG_PATCH_THRESHOLDS
562 for (
int rdo=0;rdo<mNumRdo;rdo++ )
567 fprintf(mLogFile,
"\n");
568 fprintf(mLogFile,
"total number of towers: %d\n",mNumTower);
569 fprintf(mLogFile,
"number of unmasked towers: %d\n",
mNumberLive);
570 fprintf(mLogFile,
"\n====================================================================================================================================\n\n");
576 delete emc_ideal_gains;
605 int bemcIn,
unsigned short *bemcData,
606 int eemcIn,
unsigned short *eemcData )
608 rdtscl_macro(mEveTimeStart);
611 mAccept=
doEvent( inputEventID, trgData, eemcIn, eemcData );
614 mAccept=
doEvent( inputEventID, trgData, bemcIn, bemcData );
617 rdtscl_macro(mEveTimeStop);
618 mEveTimeDiff=mEveTimeStop-mEveTimeStart;
619 int kTick=mEveTimeDiff/1000;
628 int emcIn,
unsigned short *emcData )
633 if ( !emcIn )
return false;
644 unsigned long eval_time_start;
645 unsigned long eval_time_stop;
646 rdtscl_macro(eval_time_start);
652 unsigned short htrdo=8192;
653 unsigned short tprdo=8192;
659 #ifdef OPT_PREPROCESS
666 for (
unsigned short i=0;i<
mL2input->getNumberOfHighTowers();i++ )
668 unsigned short rdo=
mL2input->mListOfRdosHT[i];
670 mHistos[3].fill( emcData[rdo] );
673 mADCofHT[ nRdosHT ] = emcData[rdo];
674 mListOfRdosHT[ nRdosHT++ ] = rdo;
675 mHistos[4].fill( emcData[rdo] );
681 int prdo=mRdoPatch[rdo][i];
682 if ( mTowerFail[prdo] )
continue;
683 sum += emcData[prdo] / mIdealGainT * mTowerAdcCorrection[rdo];
685 unsigned short sumx2=(
unsigned short)(2.0*sum);
694 mListOfRdosTP[ nRdosTP++ ] = rdo;
695 mHistos[5].fill( emcData[rdo] );
709 for (
unsigned short rdo=0; rdo<mNumRdo; rdo++ )
716 mHistos[3].fill( emcData[rdo] );
724 mADCofHT[ nRdosHT ] = emcData[rdo];
725 mListOfRdosHT[ nRdosHT++ ] = rdo;
726 mHistos[4].fill( emcData[rdo] );
735 int prdo=mRdoPatch[rdo][i];
736 if ( mTowerFail[prdo] )
continue;
737 sum += emcData[prdo] / mIdealGainT * mTowerAdcCorrection[rdo];
739 unsigned short sumx2=(
unsigned short)(2.0*sum);
751 mListOfRdosTP[ nRdosTP++ ] = rdo;
752 mHistos[5].fill( emcData[rdo] );
762 #ifdef OPT_PREPROCESS
766 bool prescaleAccept =
false;
785 rdtscl_macro(eval_time_stop);
788 unsigned long qa_time_start;
789 unsigned long qa_time_stop;
790 rdtscl_macro(qa_time_start);
797 mResult.result_version = LEVEL2_GAMMA_RESULT_VERSION;
798 mResult.threshold = (mThresholdLevel==kThresh1)? (0x1|0x2) : (0x4|0x8);
800 mResult.elapsed=0x00;
802 mResult.trigger = 0x00;
805 unsigned short maxrdo=8192;
809 mResult.trigger |= 0x1;
813 for (
unsigned short i=0;i<nRdosTP;i++ )
815 if ( mETofTP[i] > max ) {
817 maxrdo=mListOfRdosTP[i];
820 if ( maxrdo < mNumRdo )
822 mResult.trigger |= 0x2;
824 mResult.phibin=tow/mNumEtas;
825 mResult.etabin=tow%mNumEtas;
829 mResult.ptclusterx2 = ((
unsigned short)(2.0*max));
831 mResult.ptclusterx2 = 255;
832 float pttow=emcData[maxrdo]-mTowerPed[maxrdo];
833 pttow*=mTowerAdcCorrection[maxrdo]/mIdealGainT;
835 mResult.pttowerx2 = (
unsigned short)(2.0*pttow);
837 mResult.pttowerx2 = 255;
838 if (
mEEmc ) mResult.phibin |= 0x8;
843 if ( prescaleAccept )
844 mResult.trigger |= 0x4;
847 if ( trig || prescaleAccept )
848 mResult.trigger |= 0x8;
850 rdtscl_macro(qa_time_stop);
851 int dt=(int)(qa_time_stop-eval_time_start)/1000;
859 unsigned int *pResult
861 = &trgData->TrgSum.L2Result[mResultOffset+2*
mEEmc+mThresholdLevel];
868 #ifdef __L2GAMMA_PRINT_RESULT__
869 print_L2gammaResult(mResult);
877 if ( trig || prescaleAccept )
880 for (
unsigned short i=0;i<nRdosHT;i++ ) {
882 mHistos[6].fill( (mADCofHT[i] - (
unsigned short)mTowerPed[ mListOfRdosHT[i] ])/5,tower );
886 for (
unsigned short i=0;i<nRdosTP;i++ ) {
888 mHistos[9].fill( (
int)(mETofTP[i]*2),tower );
897 if ( eht )
mHistos[16].fill(dt);
898 if ( trig )
mHistos[17].fill(dt);
900 return ( trig || prescaleAccept );
924 printf(
"%s/run%d.l2%s.hist.bin\n",mOutDir,run,mName);
925 sprintf(chis,
"%s/run%d.l2%s.hist.bin",mOutDir,run,mName);
926 printf(
"L2gamma:saving '%s'\n",chis);
930 mHistFile=fopen(chis,
"w");
931 if(mHistFile==0) printf(
"%s ::finishRun() for run=%d UNABLE to open histo-file=%s=, continue initialization\n",mName,run,chis);
944 fprintf(mLogFile,
"\n\n===================================================================================================================================\n");
945 fprintf(mLogFile,
"L2gammaAlgo end of run %d summary\n",run);
946 fprintf(mLogFile,
"run: %d\n",run);
949 fprintf(mLogFile,
"patch size: 3x3\n");
950 fprintf(mLogFile,
"eval time: %d [kTicks]\n",mEvalTime);
951 fprintf(mLogFile,
"avg time/event: %d [kTicks]\n",mEvalTime/
mNumberInput);
953 fprintf(mLogFile,
"# ht accept: %d\n",mNumberAcceptHT);
954 fprintf(mLogFile,
"# ht+tp accept: %d\n",mNumberAcceptTP);
955 fprintf(mLogFile,
"\n");
964 for (
int tow=0;tow<mNumTower;tow++ )
966 avgt+=mTowerFrequency[tow];
967 avgp+=mPatchFrequency[tow];
968 if ( mTowerFrequency[tow]>maxtf ) maxtf=mTowerFrequency[tow];
969 if ( mPatchFrequency[tow]>maxpf ) maxpf=mTowerFrequency[tow];
972 avgp=( ((float)avgp)/(float)mNumberLive );
975 fprintf(mLogFile,
"max # ht accept in one tower: %d\n",maxtf);
976 fprintf(mLogFile,
"max # ht+tp accept in one tower: %d\n",maxpf);
977 fprintf(mLogFile,
"avg # ht accept: %6f\n",avgt);
978 fprintf(mLogFile,
"avg # ht+tp accept: %6f\n",avgp);
979 fprintf(mLogFile,
"expected # ht accept in one tower: %6f\n",((
float)mNumberAcceptHT)/mNumberLive);
980 fprintf(mLogFile,
"expected # ht+tp accept in one tower: %6f\n",((
float)mNumberAcceptTP)/mNumberLive);
981 fprintf(mLogFile,
"\n");
986 #ifndef DEBUG_PATCH_THRESHOLDS
987 fprintf(mLogFile,
"Summary of hot towers (# ht accept > 3*average or # ht+tp accept > 3*average):\n\n");
989 for (
int tow=0;tow<mNumTower;tow++ )
991 int phi=tow/mNumEtas;
992 int eta=tow%mNumEtas;
993 int sec=phi/mNumSubs;
994 int sub=phi%mNumSubs;
995 int myrdo=mTower2rdo[tow];
998 bool hott = (mTowerFrequency[tow] > (3.0*avgt));
999 bool hotp = 0 && (mPatchFrequency[tow] > (3.0*avgp));
1003 if ( hott||hotp ) fprintf(mLogFile,
"\n");
1008 fprintf(mLogFile,
"L2gammaAlgo::WARNING -- possible hot tower %02dt%c%02d freq=%d avg=%5.2f\n",sec+1,sub+
'a',eta+1,mTowerFrequency[tow],avgt);
1010 fprintf(mLogFile,
"L2gammaAlgo::WARNING -- possible hot patch %02dt%c%02d freq=%d avg=%5.2f\n",sec+1,sub+
'a',eta+1,mPatchFrequency[tow],avgp);
1015 fprintf(mLogFile,
"L2gammaAlgo::WARNING -- possible hot tower %02dT%c%02d freq=%d avg=%5.2f\n",sec+1,sub+
'A',eta+1,mTowerFrequency[tow],avgt);
1017 fprintf(mLogFile,
"L2gammaAlgo::WARNING -- possible hot patch %02dT%c%02d freq=%d avg=%5.2f\n",sec+1,sub+
'A',eta+1,mPatchFrequency[tow],avgp);
1032 fprintf(mLogFile,
"\n====================================================================================================================================\n\n");
1033 finishCommonHistos();
1055 void L2gammaAlgo::jclear()
1057 for (
int i=0;i<19;i++ )
mHistos[i].reset();
1059 void L2gammaAlgo::jbook()
1068 mHistos[0]=
L2Histo(100,
"Counter. 0=N_{input} 1=N_{ht} 2=N_{clust} 3=N_{accept}", 10);
1076 mHistos[5]=
L2Histo(105,
"Raw ADC of ht, cluster > threshold", 1024);
1077 mHistos[6]=
L2Histo(106,
"HT event accepted; X: (ADC-ped)/5; Y: tower index", 128,mNumTower);
1081 mHistos[7]=
L2Histo(107,
"2*ET sum of cluster, ht > threshold", 32);
1082 mHistos[8]=
L2Histo(108,
"2*ET sum of cluster, cluster > threshold", 32);
1083 mHistos[9]=
L2Histo(109,
"2*ET sum of cluster - ped/gain, event accepted", 32,mNumTower);
1087 mHistos[10]=
L2Histo(110,
"Raw BBC TAC difference+256 (not implemented)", 1);
1088 mHistos[11]=
L2Histo(111,
"Raw BBC TAC difference+256, ht > threshold (not implemented)", 1);
1089 mHistos[12]=
L2Histo(112,
"Raw BBC TAC difference+256, cluster > threshold (not implemented)" , 1);
1093 mHistos[13]=
L2Histo(113,
"High tower > threshold frequency, X: ieta+mNumEta*iphi", mNumTower);
1094 mHistos[14]=
L2Histo(114,
"Cluster > threshold frequency, X: ieta+mNumEta*iphi", mNumTower);
1109 #ifndef DEBUG_PATCH_THRESHOLDS
1115 int phi = tow/mNumEtas;
1116 int eta = tow%mNumEtas;
1118 int sec = phi/mNumSubs;
1119 int sub = phi%mNumSubs;
1147 fprintf(mLogFile,
"etow: %02dT%c%02d\n",sec+1,sub+
'A',eta+1);
1149 fprintf(mLogFile,
"btow: %02dt%c%02d\n",sec+1,sub+
'a',eta+1);
1151 fprintf(mLogFile,
"index: %4d\n",tow);
1152 fprintf(mLogFile,
"gain: %6.3f [ideal=%6.3f]\n",mTowerGain[rdo],mTowerGainIdeal[rdo]);
1153 fprintf(mLogFile,
"ped: %6.3f\n",mTowerPed[rdo]);
1155 fprintf(mLogFile,
"\n");
1158 fprintf(mLogFile,
"loaded peds gain factors status bits mask bits frequency > thr\n");
1160 for (
int i_eta=eta+1;i_eta>=eta-1;i_eta-- ) {
1162 int phi_l = (phi+mNumPhis-1)%mNumPhis;
1163 int phi_r = (phi+mNumPhis+1)%mNumPhis;
1167 float peds[]={0,0,0};
1168 float gains[]={0,0,0};
1169 unsigned short stats[]={0xff,0xff,0xff};
1170 unsigned short fails[]={0xff,0xff,0xff};
1171 int freqs[]={0,0,0};
1174 if ( i_eta < mNumEtas && i_eta >= 0 ) {
1176 int tow_l = tower(phi_l,i_eta);
1177 int tow_r = tower(phi_r,i_eta);
1178 int tow_c = tower(phi_c,i_eta);
1180 int rdo_l = mTower2rdo[tow_l];
1181 int rdo_r = mTower2rdo[tow_r];
1182 int rdo_c = mTower2rdo[tow_c];
1184 peds[0]=mTowerPed[rdo_l];peds[1]=mTowerPed[rdo_c];peds[2]=mTowerPed[rdo_r];
1185 gains[0]=mTowerAdcCorrection[rdo_l];gains[1]=mTowerAdcCorrection[rdo_c];gains[2]=mTowerAdcCorrection[rdo_r];
1186 stats[0]=mTowerStat[rdo_l];stats[1]=mTowerStat[rdo_c];stats[2]=mTowerStat[rdo_r];
1187 fails[0]=mTowerFail[rdo_l];fails[1]=mTowerFail[rdo_c];fails[2]=mTowerFail[rdo_r];
1188 freqs[0]=mTowerFrequency[tow_l];freqs[1]=mTowerFrequency[tow_c];freqs[2]=mTowerFrequency[tow_r];
1193 fprintf(mLogFile,
"%4.1f | %4.1f | %4.1f\t", peds[0],peds[1],peds[2] );
1194 fprintf(mLogFile,
"%4.2f | %4.2f | %4.2f\t", gains[0],gains[1],gains[2] );
1195 fprintf(mLogFile,
"%2x | %2x | %2x \t", stats[0],stats[1],stats[2] );
1196 fprintf(mLogFile,
"%2x | %2x | %2x \t", fails[0],fails[1],fails[2] );
1197 fprintf(mLogFile,
"%4.0f | %4.0f | %4.0f\t", (
float)freqs[0],(
float)freqs[1],(
float)freqs[2] );
1199 fprintf(mLogFile,
"\n");
1201 if ( i_eta > eta-1 ) {
1202 fprintf(mLogFile,
"-----+------+-----\t");
1203 fprintf(mLogFile,
"-----+------+-----\t");
1204 fprintf(mLogFile,
"-----+------+-----\t");
1205 fprintf(mLogFile,
"-----+------+-----\t");
1206 fprintf(mLogFile,
"-----+------+-----\t");
1207 fprintf(mLogFile,
"\n" );
1214 #ifdef DEBUG_PATCH_THRESHOLDS
1220 int phi = tow/mNumEtas;
1221 int eta = tow%mNumEtas;
1223 int sec = phi/mNumSubs;
1224 int sub = phi%mNumSubs;
1252 fprintf(mLogFile,
"etow: %02dT%c%02d\n",sec+1,sub+
'A',eta+1);
1254 fprintf(mLogFile,
"btow: %02dt%c%02d\n",sec+1,sub+
'a',eta+1);
1256 fprintf(mLogFile,
"index: %4d\n",tow);
1257 fprintf(mLogFile,
"gain: %6.3f [ideal=%6.3f]\n",mTowerGain[rdo],mTowerGainIdeal[rdo]);
1258 fprintf(mLogFile,
"ped: %6.3f\n",mTowerPed[rdo]);
1261 fprintf(mLogFile,
"\n");
1264 fprintf(mLogFile,
"loaded peds gain factors status bits mask bits frequency > thr\n");
1266 for (
int i_eta=eta+1;i_eta>=eta-1;i_eta-- ) {
1268 int phi_l = (phi+mNumPhis-1)%mNumPhis;
1269 int phi_r = (phi+mNumPhis+1)%mNumPhis;
1272 int phis[]={phi_l,phi,phi_r};
1273 float peds[]={0,0,0};
1274 float gains[]={0,0,0};
1275 unsigned short stats[]={0xff,0xff,0xff};
1276 unsigned short fails[]={0xff,0xff,0xff};
1277 int freqs[]={0,0,0};
1279 float corr[]={0.,0.,0.};
1282 if ( i_eta < mNumEtas && i_eta >= 0 ) {
1284 int tow_l = tower(phi_l,i_eta);
1285 int tow_r = tower(phi_r,i_eta);
1286 int tow_c = tower(phi_c,i_eta);
1288 int rdo_l = mTower2rdo[tow_l];
1289 int rdo_r = mTower2rdo[tow_r];
1290 int rdo_c = mTower2rdo[tow_c];
1292 peds[0]=mTowerPed[rdo_l];peds[1]=mTowerPed[rdo_c];peds[2]=mTowerPed[rdo_r];
1294 gains[0]=(float)mIdealGainT;
1295 gains[1]=(float)mIdealGainT;
1296 gains[2]=(float)mIdealGainT;
1298 stats[0]=mTowerStat[rdo_l];stats[1]=mTowerStat[rdo_c];stats[2]=mTowerStat[rdo_r];
1299 fails[0]=mTowerFail[rdo_l];fails[1]=mTowerFail[rdo_c];fails[2]=mTowerFail[rdo_r];
1300 freqs[0]=mTowerFrequency[tow_l];freqs[1]=mTowerFrequency[tow_c];freqs[2]=mTowerFrequency[tow_r];
1302 corr[0]=mTowerAdcCorrection[rdo_l];
1303 corr[1]=mTowerAdcCorrection[rdo_c];
1304 corr[2]=mTowerAdcCorrection[rdo_r];
1309 fprintf(mLogFile,
"%4.1f | %4.1f | %4.1f\t", peds[0],peds[1],peds[2] );
1310 fprintf(mLogFile,
"%4.0f | %4.0f | %4.0f\t", gains[0],gains[1],gains[2] );
1311 fprintf(mLogFile,
"%2x | %2x | %2x \t", stats[0],stats[1],stats[2] );
1312 fprintf(mLogFile,
"%2x | %2x | %2x \t", fails[0],fails[1],fails[2] );
1313 fprintf(mLogFile,
"%4.2f | %4.2f | %4.2f\t",
1314 corr[0]*peds[0]/gains[0],
1315 corr[1]*peds[1]/gains[1],
1316 corr[2]*peds[2]/gains[2]);
1318 fprintf(mLogFile,
"\n");
1320 if ( i_eta > eta-1 ) {
1321 fprintf(mLogFile,
"-----+------+-----\t");
1322 fprintf(mLogFile,
"-----+------+-----\t");
1323 fprintf(mLogFile,
"-----+------+-----\t");
1324 fprintf(mLogFile,
"-----+------+-----\t");
1325 fprintf(mLogFile,
"-----+------+-----\t");
1326 fprintf(mLogFile,
"\n" );
1329 fprintf(mLogFile,
"\n\n" );
bool doEvent(int inpEveId, TrgDataType *trgData, int emcIn, unsigned short *emcData)
L2gammaAlgo(const char *name, L2EmcDb *db, char *outDir, int resOff)
class constructor
float mPatchAdcThreshold[MAX_TOWERS]
int mNumberInput
event counters
void finishRun()
cleanup for runs. output of warnings (eg hot channels) etc...
void printPatchConfig(int rdo)
float mPatchThreshold
Patch threshold.
unsigned short mTowerAdcThreshold[MAX_TOWERS]
unsigned short mRdo2tower[MAX_TOWERS]
Map to go from Rdo to Tower and Tower to Rdo.
void setLogFile(const char *fname="./bsqueal.log")
Set logfile for summary output (overrides constructor option)
void setPatchThreshold(float pt)
set the L2 trigger patch threshold. F_par[1]
L2Histo mHistos[19]
L2 histograms.
unsigned short mPatchStat[MAX_TOWERS]
int mNumberLive
Counters for error monitoring.
int initRun(int run)
initialize the data structures for the next run
void init(int run, int I_par[5], float F_par[5])
One time initialization.
void clear()
clear data structures for ...
void setHistFile(const char *fname="./bsqueal.dat")
Set filename for histogram output (overrides constructor option)
unsigned short mNumPatch[MAX_TOWERS]
Number and list of up to 9 neighboring towers.
void finish()
final output of statistics, histograms, etc...
unsigned short phibin(unsigned short sec, unsigned short sub)
Log file.
float mTowerThreshold
High tower threshold.
void setTowerThreshold(float pt)
set the L2 high tower threshold. F_par[0]
int mUseBbc
Option to correct for vertex effects (not in use yet)
int mRunNumber
Run number for the current run.
int mUseOfflineGains
Option to use offline gains.