21 #ifdef IS_REAL_L2 //in l2-ana environment
22 #include "../L2algoUtil/L2EmcDb.h"
23 #include "../L2algoUtil/L2Histo.h"
25 #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2EmcDb.h"
26 #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2Histo.h"
29 #include "L2jetAlgo2009.h"
30 #include "L2jetResults2009.h"
31 #include "Map_DeltaPhiJets.h"
35 L2jetAlgo2009::L2jetAlgo2009(
const char* name,
L2EmcDb* db,
char* outDir,
int resOff,
bool writeHighResult)
41 if (writeHighResult) namechar=
'H';
45 printf(
"L2jetAlgo2009 instantiated, logPath='%s'\n",mOutDir1.c_str());
53 L2jetAlgo2009::paramsChanged(
int *rc_ints,
float *rc_floats) {
56 if(rc_ints[i]!=raw_ints[i])
goto foundProblem;
59 if(fabs(rc_floats[i]-raw_floats[i])>0.00001)
goto foundProblem;
64 if (mLogFile) fprintf(mLogFile,
"L2jet-ghost initRun - inconsistent params, ABORT initialization\n");
71 L2jetAlgo2009::initRunUser(
int runNo,
int *rc_ints,
float *rc_floats) {
75 for (i=0; i<mxHA;i++)
if(hA[i])hA[i]->reset();
78 memset(db_btowL2PhiBin, 0,
sizeof(db_btowL2PhiBin));
79 memset(db_btowL2PatchBin,0,
sizeof(db_btowL2PatchBin));
81 memset(db_etowL2PhiBin, 0 ,
sizeof(db_etowL2PhiBin));
82 memset(db_etowL2PatchBin,0 ,
sizeof(db_etowL2PatchBin));
84 run_startUnix=time(0);
87 raw_floats =rc_floats;
88 run_nEventOneJet=run_nEventDiJet= run_nEventRnd=0;
92 if( mLogFile==0) printf(
" L2jetAlgo2009() UNABLE to open run summary log file, continue anyhow\n");
95 par_useBtowEast= (rc_ints[0]&1 )>0;
96 par_useBtowWest= (rc_ints[0]&2)>0;
97 par_useEndcap = rc_ints[1]&1;
98 int par_adcThr = rc_ints[2];
100 par_RndAcceptPrescale = rc_ints[4];
101 par_minPhiBinDiff= 7;
103 par_oneJetThr = rc_floats[0];
104 par_diJetThrHigh= rc_floats[1];
105 par_diJetThrLow = rc_floats[2];
106 par_diJetThr_2 = rc_floats[3];
107 par_diJetThr_3 = rc_floats[4];
108 par_diJetThr_4 = rc_floats[5];
109 par_diJetThr_5 = rc_floats[6];
110 par_diJetEtaHigh = rc_floats[7];
111 par_diJetEtaLow = rc_floats[8];
116 float monTwEtThr=2.0;
117 par_hotTwEtThr = monTwEtThr;
119 if(par_dbg) printf(
"Brian version is running!\n");
122 fprintf(mLogFile,
"L2jet algorithm initRun(%d), compiled: %s , %s\n params:\n",run_number,__DATE__,__TIME__);
123 fprintf(mLogFile,
" - use BTOW: East=%d West=%d, Endcap=%d L2ResOffset=%d\n", par_useBtowEast, par_useBtowWest,par_useEndcap ,mResultOffset);
124 fprintf(mLogFile,
" - threshold: ADC-ped> %d \n", par_adcThr);
125 fprintf(mLogFile,
" - min phi opening angle Jet1<->Jet2: %d in L2phiBins\n",par_minPhiBinDiff);
126 fprintf(mLogFile,
" - diJet Et thrHigh= %.2f (GeV) thrLow= %.2f (GeV)\n", par_diJetThrHigh, par_diJetThrLow);
127 fprintf(mLogFile,
" - new diJet Et thr_2= %.2f (GeV) ; thr_3= %.2f (Gev) ; thr_4= %.2f (GeV) ; thr_5= %.2f (GeV)\n",par_diJetThr_2, par_diJetThr_3, par_diJetThr_4, par_diJetThr_5);
128 fprintf(mLogFile,
" - oneJet Et thr = %.2f (GeV) ; rndAccPrescale=%d \n",par_oneJetThr,par_RndAcceptPrescale);
129 fprintf(mLogFile,
" - new diJet Eta_low= %.2f ; diJet Eta_High= %.2f \n", par_diJetEtaLow, par_diJetEtaHigh);
130 fprintf(mLogFile,
" - debug=%d, hot tower threshold: Et> %.1f GeV ( only monitoring)\n",par_dbg, monTwEtThr);
135 kBad+=0x0001 * ( !par_useBtowEast & !par_useBtowWest & !par_useEndcap);
137 kBad+=0x0004 * (par_adcThr>16);
138 kBad+=0x0008 * (par_minPhiBinDiff<5);
139 kBad+=0x0010 * (par_minPhiBinDiff>=15);
140 kBad+=0x0020 * (par_oneJetThr<3.);
141 kBad+=0x0040 * (par_oneJetThr>12.);
142 kBad+=0x0080 * (par_diJetThrLow<1.9);
143 kBad+=0x0100 * (par_diJetThrHigh<par_diJetThrLow);
144 kBad+=0x0200 * (par_diJetThrHigh>12.);
146 kBad+=0x0800 * ( par_RndAcceptPrescale<0 );
147 kBad+=0x1000 * (par_diJetThr_2<par_diJetThrLow || par_diJetThr_5>par_diJetThrHigh);
148 kBad+=0x2000 * (par_diJetThr_2>par_diJetThr_3 || par_diJetThr_3>par_diJetThr_4 || par_diJetThr_4>par_diJetThr_5);
149 kBad+=0x4000 * (par_diJetEtaLow>par_diJetEtaHigh);
151 fprintf(mLogFile,
"L2jet initRun() params checked for consistency, Error flag=0x%04x\n",kBad);
152 if(kBad) fprintf(mLogFile,
"L2jet initRun() ABORT\n");
158 fprintf(mLogFile,
"L2jet algorithm init: crashB in internal logic\n");
165 sprintf(tit,
"# BTOW towers>ped+%d (input); x: # of towers/event",par_adcThr);
166 hA[47]->setTitle(tit);
168 sprintf(tit,
"# ETOW towers>ped+%d (input); x: # of towers/event",par_adcThr);
169 hA[48]->setTitle(tit);
172 const int mxEtaBinsE=12,mxEtaBinsB=40;
176 int etowEtaBin2Patch[mxEtaBinsE]={14,14,13,13,12,12,11,11,11,10,10,10};
181 for(i=0; i<EmcDbIndexMax; i++) {
183 if(mDb->isEmpty(x))
continue;
184 if(x->fail)
continue;
185 if(x->gain<=0)
continue;
190 if (mDb->isBTOW(x) ) {
193 if(x->eta<0 || x->eta>mxEtaBinsB)
goto crashIt_1;
194 if(!par_useBtowEast && x->eta<=20)
continue;
195 if(!par_useBtowWest && x->eta>=21)
continue;
197 int iphiTw=(x->sec-1)*10 + x->sub-
'a';
200 if(iphiTw<0) iphiTw=119;
205 db_btowL2PhiBin[x->rdo]=iphiP;
206 db_btowL2PatchBin[x->rdo]=ietaP+ iphiP*cl2jetMaxEtaBins;
208 }
else if(mDb->isETOW(x) && par_useEndcap) {
211 int iphiTw= (x->sec-1)*5 + x->sub-
'A';
214 if(iphiTw<0) iphiTw=59;
217 if(x->eta<0 || x->eta>mxEtaBinsE)
goto crashIt_1;
218 ietaP=etowEtaBin2Patch[x->eta-1];
220 db_etowL2PhiBin[x->rdo]=iphiP;
221 db_etowL2PatchBin[x->rdo]=ietaP+ iphiP*cl2jetMaxEtaBins;
228 fprintf(mLogFile,
"L2jet algorithm: found working/calibrated: %d/%d=ETOW & %d/%d=BTOW, based on ASCII DB\n",nE,nEg,nB,nBg);
236 fprintf(mLogFile,
"L2jet algorithm init: crashC in internal logic\n");
245 void L2jetAlgo2009::computeUser(
int token){
252 L2jetAlgo2009::decisionUser(
int token,
int *myL2Result){
256 unsigned long mEveTimeStart,mEveTimeStop, mEveTimeDiff;
257 rdtscl_macro(mEveTimeStart);
275 int runTimeSec=time(0)- run_startUnix;
277 hA[12]->fill(runTimeSec);
279 if(par_dbg>1) printf(
"\n......... in L2Jet_doEvent(ID=%d)... bIn=%d eIn=%d\n",eve_ID,bemcIn,eemcIn);
285 if (bemcIn || eemcIn){
289 int nBtowTw=0, nEtowTw=0;
294 if(bemcIn==1 && (par_useBtowEast||par_useBtowWest) ) {
296 nBtowTw=projectAdc( mEveStream_btow[token].get_hits(), mEveStream_btow[token].get_hitSize(),
297 db_btowL2PhiBin, db_btowL2PatchBin,
303 if(eemcIn==1 && par_useEndcap ) {
304 nEtowTw=projectAdc( mEveStream_etow[token].get_hits(), mEveStream_etow[token].get_hitSize(),
305 db_etowL2PhiBin, db_etowL2PatchBin,
310 float totEneGeV=true2Dscan();
311 int itotEneGeV=(int)totEneGeV;
313 for(iK=0; iK<mxJ; iK++)
316 L2Jet *K=eve_Jet[iK];
318 K->phiRad=0.21*(6.0-K->fphiBin);
319 while(K->phiRad<0) K->phiRad+=6.2832;
320 while(K->phiRad>6.2832) K->phiRad-=6.2832;
323 if(eve_Jet[0]->eneGeV <eve_Jet[1]->eneGeV) {
324 L2Jet *Jx=eve_Jet[0];
325 eve_Jet[0]=eve_Jet[1];
329 if(par_dbg>2) printf(
"doEvent iphiBin1=%d iene1=%f , iphiBin2=%d iene2=%f rms1PhiBin=%f \n",eve_Jet[0]->iphiBin,eve_Jet[0]->iene,eve_Jet[1]->iphiBin,eve_Jet[1]->iene,eve_Jet[0]->rmsPhiBin);
336 float rjetEta_0=eve_Jet[0]->fetaBin*0.2 -1.0;
337 float rjetEta_1=eve_Jet[1]->fetaBin*0.2 -1.0;
342 bool acceptDiJet_EE=((rjetEta_0+rjetEta_1) > par_diJetEtaHigh && eve_Jet[0]->eneGeV > par_diJetThr_4 && eve_Jet[1]->eneGeV > par_diJetThrLow);
344 bool acceptDiJet_EB=((rjetEta_0+rjetEta_1) > par_diJetEtaLow && eve_Jet[0]->eneGeV > par_diJetThr_5 && eve_Jet[1]->eneGeV > par_diJetThr_2);
348 bool acceptDiJet_BB=(eve_Jet[0]->eneGeV > par_diJetThrHigh && eve_Jet[1]->eneGeV > par_diJetThr_3);
350 bool acceptDiJet=acceptDiJet_EE || acceptDiJet_EB || acceptDiJet_BB;
352 bool acceptOneJet=( eve_Jet[0]->eneGeV > par_oneJetThr) ;
354 bool acceptRnd=mRandomAccept>0;
355 mAccept=acceptDiJet || acceptOneJet || acceptRnd;
360 int iet1 =(int)eve_Jet[0]->eneGeV;
361 int iet2 =(int)eve_Jet[1]->eneGeV;
362 int ieta1=(int)eve_Jet[0]->fetaBin;
363 int ieta2=(int)eve_Jet[1]->fetaBin;
364 int iphi1=(int)eve_Jet[0]->fphiBin;
365 int iphi2=(int)eve_Jet[1]->fphiBin;
367 hA[40]->fill(iet1,iet2);
369 hA[41]->fill(ieta1,iphi1);
370 hA[42]->fill(ieta2,iphi2);
371 hA[43]->fill(iphi1,iphi2);
374 hA[46]->fill(itotEneGeV);
375 hA[47]->fill(nBtowTw);
376 hA[48]->fill(nEtowTw);
379 int kphi1=int(eve_Jet[0]->phiRad*10.);
380 int kphi2=int(eve_Jet[1]->phiRad*10.);
381 int idelZeta=map_DelPhiJets[kphi1*MxPhiRad10 + kphi2];
383 if( mAccept) hA[10]->fill(8);
388 hA[13]->fill(runTimeSec);
390 hA[51]->fill(ieta1,iphi1);
398 hA[14]->fill(runTimeSec);
399 hA[60]->fill(iet1,iet2);
400 hA[61]->fill(ieta1,iphi1);
401 hA[62]->fill(ieta2,iphi2);
402 hA[63]->fill(iphi1,iphi2);
409 hA[70]->fill(idelZeta);
410 hA[71]->fill(ieta1,idelZeta);
411 hA[72]->fill(ieta1,ieta2);
412 hA[73]->fill((iphi1+iphi2)/2,idelZeta);
413 hA[74]->fill(itotEneGeV);
418 hA[80]->fill(iet1,iet2);
419 hA[81]->fill(ieta1,iphi1);
420 hA[82]->fill(ieta2,iphi2);
421 hA[83]->fill(iphi1,iphi2);
428 hA[90]->fill(idelZeta);
429 hA[91]->fill(ieta1,idelZeta);
430 hA[92]->fill(ieta1,ieta2);
431 hA[93]->fill((iphi1+iphi2)/2,idelZeta);
432 hA[94]->fill(itotEneGeV);
437 hA[100]->fill(iet1,iet2);
438 hA[101]->fill(ieta1,iphi1);
439 hA[102]->fill(ieta2,iphi2);
440 hA[103]->fill(iphi1,iphi2);
443 hA[106]->fill(ieta1);
444 hA[107]->fill(ieta2);
445 hA[108]->fill(iphi1);
446 hA[109]->fill(iphi2);
447 hA[110]->fill(idelZeta);
448 hA[111]->fill(ieta1,idelZeta);
449 hA[112]->fill(ieta1,ieta2);
450 hA[113]->fill((iphi1+iphi2)/2,idelZeta);
451 hA[114]->fill(itotEneGeV);
456 hA[120]->fill(iet1,iet2);
457 hA[121]->fill(ieta1,iphi1);
458 hA[122]->fill(ieta2,iphi2);
459 hA[123]->fill(iphi1,iphi2);
462 hA[126]->fill(ieta1);
463 hA[127]->fill(ieta2);
464 hA[128]->fill(iphi1);
465 hA[129]->fill(iphi2);
466 hA[130]->fill(idelZeta);
467 hA[131]->fill(ieta1,idelZeta);
468 hA[132]->fill(ieta1,ieta2);
469 hA[133]->fill((iphi1+iphi2)/2,idelZeta);
470 hA[134]->fill(itotEneGeV);
476 hA[15]->fill(runTimeSec);
482 memset(&out,0,
sizeof(out));
486 out.int0.version=L2JET_RESULTS_VERSION;
488 ( par_useBtowEast <<0 ) +
489 ( par_useBtowWest <<1 ) +
490 ( par_useEndcap <<2 ) +
493 ( mRandomAccept <<5 ) +
494 ( acceptOneJet <<6 ) +
495 ( acceptDiJet <<7 ) +
496 ( acceptDiJet_EE <<8 ) +
497 ( acceptDiJet_EB <<9 ) +
498 ( acceptDiJet_BB <<10 ) ;
499 out.int0.dumm=namechar;
501 out.int1.iTotEne=(
unsigned short)(totEneGeV*100.);
502 out.int2.nBtowTw=nBtowTw;
503 out.int2.nEtowTw=nEtowTw;
505 out.jet1.jPhi=(int)(eve_Jet[0]->phiRad*28.65);
506 out.jet1.jEta=(int)(eve_Jet[0]->fetaBin*10.);
507 out.jet1.iEne=(
unsigned short)(eve_Jet[0]->eneGeV*100.);
509 out.jet2.jPhi=(int)(eve_Jet[1]->phiRad*28.65);
510 out.jet2.jEta=(int)(eve_Jet[1]->fetaBin*10.);
511 out.jet2.iEne=(
unsigned short)(eve_Jet[1]->eneGeV*100.);
513 out.jet1.rmsEta=(
unsigned short)(eve_Jet[0]->rmsEtaBin*20.);
514 out.jet1.rmsPhi=(
unsigned short)(eve_Jet[0]->rmsPhiBin*120.);
516 out.jet2.rmsEta=(
unsigned short)(eve_Jet[1]->rmsEtaBin*20.);
517 out.jet2.rmsPhi=(
unsigned short)(eve_Jet[1]->rmsPhiBin*120.);
520 rdtscl_macro(mEveTimeStop);
521 mEveTimeDiff=mEveTimeStop-mEveTimeStart;
522 int kTick=mEveTimeDiff/1000;
526 out.int0.kTick= kTick>255 ? 255 : kTick;
529 out.int1.checkSum=-L2jetResults2009_doCheckSum(&out);
539 L2jetResults2009_print(&out);
540 printf(
" phiRad1=%f phiRad2=%f \n",eve_Jet[0]->phiRad,eve_Jet[1]->phiRad);
541 printf(
"idelZeta=%d delZeta/deg=%.1f \n\n",idelZeta,idelZeta/31.416*180);
544 if( out.jet1.iEne+out.jet2.iEne > out.int1.iTotEne) {
548 printf(
"L2jet-fatal error,neveId=%d, phi1,2=%d,%d\n",mEventsInRun,iphi1,iphi2);
552 if( L2jetResults2009_doCheckSum(&out)) {
553 printf(
"L2jet-fatal error, wrong cSum=%d\n", L2jetResults2009_doCheckSum(&out));
554 L2jetResults2009_print(&out);
570 L2jetAlgo2009::finishRunUser() {
571 if(run_number<0)
return;
574 fprintf(mLogFile,
"L2-jet algorithm finishRun(%d)\n",run_number);
575 fprintf(mLogFile,
" - %d events seen by L2 di-jet\n",mEventsInRun);
576 fprintf(mLogFile,
" - accepted: rnd=%d oneJet=%d diJet=%d \n", run_nEventRnd, run_nEventOneJet, run_nEventDiJet);
580 hA[10]->printCSV(mLogFile);
585 printf(
" L2jetAlgo2009: finishRun() UNABLE to open run summary log file, continue anyhow\n");
587 fprintf(mLogFile,
"L2 di-jet histos NOT saved, I/O error\n");
591 for(j=0;j<mxHA;j++) {
592 if(hA[j]==0)
continue;
593 hA[j]->write(mHistFile);
605 L2jetAlgo2009::createHisto() {
606 memset(hA,0,
sizeof(hA));
608 hA[10]=
new L2Histo(10,
"total event counter; x=cases",9);
609 hA[11]=
new L2Histo(11,
"L2 time used per input event; x: time (CPU kTics), range=100muSec; y: events ",160);
611 int mxRunDration=2500;
612 hA[12]=
new L2Histo(12,
"rate of input events; x: time in this run (seconds); y: rate (Hz)", mxRunDration);
614 hA[13]=
new L2Histo(13,
"rate of accepted one-Jet; x: time in this run (seconds); y: rate (Hz)", mxRunDration);
615 hA[14]=
new L2Histo(14,
"rate of accepted di-Jet ; x: time in this run (seconds); y: rate (Hz)", mxRunDration);
616 hA[15]=
new L2Histo(15,
"rate of random accepted ; x: time in this run (seconds); y: rate (Hz)", mxRunDration);
619 hA[20]=
new L2Histo(20,
"BTOW tower, Et>2.0 GeV (input); x: BTOW RDO index=chan*30+fiber; y: counts", 4800);
620 hA[21]=
new L2Histo(21,
"BTOW tower, Et>2.0 GeV (input); x: BTOW softID", 4800);
621 hA[22]=
new L2Histo(22,
"BTOW tower, Et>2.0 GeV (input); x: eta bin, [-1,+1]; y: phi bin ~sector",40,120);
624 hA[30]=
new L2Histo(30,
"ETOW tower, Et>2.0 GeV (input); x: ETOW RDO index=chan*6+fiber; y: counts", 720 );
625 hA[31]=
new L2Histo(31,
"ETOW tower, Et>2.0 GeV (input); x: i=chan+128*crate", 768);
626 hA[32]=
new L2Histo(32,
"ETOW tower, Et>2.0 GeV (input); x: 12 - Endcap etaBin ,[+1,+2]; y: phi bin ~sector",12,60);
629 hA[40]=
new L2Histo(40,
"Et Jet1-Jet2 (input); x: Jet1 Et/GeV ; Jet2 Et/GeV",30,30);
630 hA[41]=
new L2Histo(41,
"diJet1 eta-phi (input); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
631 hA[42]=
new L2Histo(42,
"diJet2 eta-phi (input); x: iEta [-1,+2] ; y: iPhi ~sector",15,30);
633 hA[43]=
new L2Histo(43,
"diJet phi1-phi2 (input); x: iPhi1 ~sector ; y: iPhi2 ~sector ",30,30);
635 hA[44]=
new L2Histo(44,
"Jet1 Et (input); x: Et (GeV)", 60);
636 hA[45]=
new L2Histo(45,
"Jet2 Et (input); x: Et (GeV)", 60);
637 hA[46]=
new L2Histo(46,
"total Et (input); x: Et (GeV)", 100);
638 hA[47]=
new L2Histo(47,
"# BTOW towers>thrXX (input); x: # of towers/event", 200);
639 hA[48]=
new L2Histo(48,
"# ETOW towers>thrXX (input); x: # of towers/event", 100);
642 hA[50]=
new L2Histo(50,
"one-Jet Et (accepted); x: jet Et (GeV)", 60);
643 hA[51]=
new L2Histo(51,
"one-Jet eta-phi (accepted); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
644 hA[52]=
new L2Histo(52,
"one-Jet eta (accepted); x: iEta [-1,+2]", 15);
645 hA[53]=
new L2Histo(53,
"one-Jet phi (accepted); x: iPhi ~sector", 30);
648 hA[60]=
new L2Histo(60,
"Et of Jet1 vs. Jet2 (accepted); x: Jet1/GeV ; Jet2/GeV",30,30);
649 hA[61]=
new L2Histo(61,
"diJet1 eta-phi (accepted); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
650 hA[62]=
new L2Histo(62,
"diJet2 eta-phi (accepted); x: iEta [-1,+2] ; y: iPhi ~sector",15,30);
652 hA[63]=
new L2Histo(63,
"diJet phi1-phi2 (accepted); x: iPhi1 ~sector ; y: iPhi2 ~sector ",30,30);
654 hA[64]=
new L2Histo(64,
"diJet1 Et (accepted); x: Et (GeV)", 60);
655 hA[65]=
new L2Histo(65,
"diJet2 Et (accepted); x: Et (GeV)", 60);
657 hA[66]=
new L2Histo(66,
"diJet1 eta (accepted); x: i Eta [-1,+2]", 15);
658 hA[67]=
new L2Histo(67,
"diJet2 eta (accepted); x: i Eta [-1,+2]", 15);
659 hA[68]=
new L2Histo(68,
"diJet1 phi (accepted); x: iPhi ~sector", 30);
660 hA[69]=
new L2Histo(69,
"diJet2 phi (accepted); x: iPhi ~sector", 30);
661 hA[70]=
new L2Histo(70,
"diJet delZeta (accepted); x: delta zeta (rad*10)", MxPhiRad10);
662 hA[71]=
new L2Histo(71,
"diJet delZeta vs. eta1 (accepted); x: iEta1 [-1,+2] ; y: delta zeta (rad*10)",15, MxPhiRad10);
663 hA[72]=
new L2Histo(72,
"diJet eta2 vs. eta1 (accepted); x: iEta1 [-1,+2] ;x: iEta2 [-1,+2] ",15,15);
664 hA[73]=
new L2Histo(73,
"diJet delZeta vs. avrPhi (accepted); x: (iphi1+iphi2)/2 (12 deg/bin); y: delta zeta (rad*10)",30, MxPhiRad10);
665 hA[74]=
new L2Histo(74,
"total Et diJet (accepted); x: Et (GeV)", 100);
668 hA[80]=
new L2Histo(80,
"Et of Jet1 vs. Jet2 (accepted_EE); x: Jet1/GeV ; Jet2/GeV",30,30);
669 hA[81]=
new L2Histo(81,
"diJet1 eta-phi (accepted_EE); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
670 hA[82]=
new L2Histo(82,
"diJet2 eta-phi (accepted_EE); x: iEta [-1,+2] ; y: iPhi ~sector",15,30);
672 hA[83]=
new L2Histo(83,
"diJet phi1-phi2 (accepted_EE); x: iPhi1 ~sector ; y: iPhi2 ~sector ",30,30);
674 hA[84]=
new L2Histo(84,
"diJet1 Et (accepted_EE); x: Et (GeV)", 60);
675 hA[85]=
new L2Histo(85,
"diJet2 Et (accepted_EE); x: Et (GeV)", 60);
677 hA[86]=
new L2Histo(86,
"diJet1 eta (accepted_EE); x: i Eta [-1,+2]", 15);
678 hA[87]=
new L2Histo(87,
"diJet2 eta (accepted_EE); x: i Eta [-1,+2]", 15);
679 hA[88]=
new L2Histo(88,
"diJet1 phi (accepted_EE); x: iPhi ~sector", 30);
680 hA[89]=
new L2Histo(89,
"diJet2 phi (accepted_EE); x: iPhi ~sector", 30);
681 hA[90]=
new L2Histo(90,
"diJet delZeta (accepted_EE); x: delta zeta (rad*10)", MxPhiRad10);
682 hA[91]=
new L2Histo(91,
"diJet delZeta vs. eta1 (accepted_EE); x: iEta1 [-1,+2] ; y: delta zeta (rad*10)",15, MxPhiRad10);
683 hA[92]=
new L2Histo(92,
"diJet eta2 vs. eta1 (accepted_EE); x: iEta1 [-1,+2] ;x: iEta2 [-1,+2] ",15,15);
684 hA[93]=
new L2Histo(93,
"diJet delZeta vs. avrPhi (accepted_EE); x: (iphi1+iphi2)/2 (12 deg/bin); y: delta zeta (rad*10)",30, MxPhiRad10);
685 hA[94]=
new L2Histo(94,
"total Et diJet (accepted_EE); x: Et (GeV)", 60);
688 hA[100]=
new L2Histo(100,
"Et of Jet1 vs. Jet2 (accepted_EB); x: Jet1/GeV ; Jet2/GeV",30,30);
689 hA[101]=
new L2Histo(101,
"diJet1 eta-phi (accepted_EB); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
690 hA[102]=
new L2Histo(102,
"diJet2 eta-phi (accepted_EB); x: iEta [-1,+2] ; y: iPhi ~sector",15,30);
692 hA[103]=
new L2Histo(103,
"diJet phi1-phi2 (accepted_EB); x: iPhi1 ~sector ; y: iPhi2 ~sector ",30,30);
694 hA[104]=
new L2Histo(104,
"diJet1 Et (accepted_EB); x: Et (GeV)", 60);
695 hA[105]=
new L2Histo(105,
"diJet2 Et (accepted_EB); x: Et (GeV)", 60);
697 hA[106]=
new L2Histo(106,
"diJet1 eta (accepted_EB); x: i Eta [-1,+2]", 15);
698 hA[107]=
new L2Histo(107,
"diJet2 eta (accepted_EB); x: i Eta [-1,+2]", 15);
699 hA[108]=
new L2Histo(108,
"diJet1 phi (accepted_EB); x: iPhi ~sector", 30);
700 hA[109]=
new L2Histo(109,
"diJet2 phi (accepted_EB); x: iPhi ~sector", 30);
701 hA[110]=
new L2Histo(110,
"diJet delZeta (accepted_EB); x: delta zeta (rad*10)", MxPhiRad10);
702 hA[111]=
new L2Histo(111,
"diJet delZeta vs. eta1 (accepted_EB); x: iEta1 [-1,+2] ; y: delta zeta (rad*10)",15, MxPhiRad10);
703 hA[112]=
new L2Histo(112,
"diJet eta2 vs. eta1 (accepted_EB); x: iEta1 [-1,+2] ;x: iEta2 [-1,+2] ",15,15);
704 hA[113]=
new L2Histo(113,
"diJet delZeta vs. avrPhi (accepted_EB); x: (iphi1+iphi2)/2 (12 deg/bin); y: delta zeta (rad*10)",30, MxPhiRad10);
705 hA[114]=
new L2Histo(114,
"total Et diJet (accepted_EB); x: Et (GeV)", 60);
708 hA[120]=
new L2Histo(120,
"Et of Jet1 vs. Jet2 (accepted_BB); x: Jet1/GeV ; Jet2/GeV",30,30);
709 hA[121]=
new L2Histo(121,
"diJet1 eta-phi (accepted_BB); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
710 hA[122]=
new L2Histo(122,
"diJet2 eta-phi (accepted_BB); x: iEta [-1,+2] ; y: iPhi ~sector",15,30);
712 hA[123]=
new L2Histo(123,
"diJet phi1-phi2 (accepted_BB); x: iPhi1 ~sector ; y: iPhi2 ~sector ",30,30);
714 hA[124]=
new L2Histo(124,
"diJet1 Et (accepted_BB); x: Et (GeV)", 60);
715 hA[125]=
new L2Histo(125,
"diJet2 Et (accepted_BB); x: Et (GeV)", 60);
717 hA[126]=
new L2Histo(126,
"diJet1 eta (accepted_BB); x: i Eta [-1,+2]", 15);
718 hA[127]=
new L2Histo(127,
"diJet2 eta (accepted_BB); x: i Eta [-1,+2]", 15);
719 hA[128]=
new L2Histo(128,
"diJet1 phi (accepted_BB); x: iPhi ~sector", 30);
720 hA[129]=
new L2Histo(129,
"diJet2 phi (accepted_BB); x: iPhi ~sector", 30);
721 hA[130]=
new L2Histo(130,
"diJet delZeta (accepted_BB); x: delta zeta (rad*10)", MxPhiRad10);
722 hA[131]=
new L2Histo(131,
"diJet delZeta vs. eta1 (accepted_BB); x: iEta1 [-1,+2] ; y: delta zeta (rad*10)",15, MxPhiRad10);
723 hA[132]=
new L2Histo(132,
"diJet eta2 vs. eta1 (accepted_BB); x: iEta1 [-1,+2] ;x: iEta2 [-1,+2] ",15,15);
724 hA[133]=
new L2Histo(133,
"diJet delZeta vs. avrPhi (accepted_BB); x: (iphi1+iphi2)/2 (12 deg/bin); y: delta zeta (rad*10)",30, MxPhiRad10);
725 hA[134]=
new L2Histo(134,
"total Et diJet (accepted_BB); x: Et (GeV)", 100);
732 L2jetAlgo2009::clearEvent(){
736 memset(eve_patchEne,0,
sizeof(eve_patchEne));
737 memset(eve_phiEne,0,
sizeof(eve_phiEne));
747 L2jetAlgo2009::projectAdc(
const HitTower1 *
hit,
const int hitSize,
748 unsigned short *phiBin,
unsigned short *patchBin,
754 for(
int i=0;i< hitSize;i++,hit++) {
756 low_noise_et=hit->low_noise_et;
757 eve_patchEne[patchBin[rdo]]+=low_noise_et;
758 eve_phiEne[phiBin[rdo]]+=low_noise_et;
761 if(low_noise_et > par_hotTwEtThr) hHot->fill(rdo);
770 float L2jetAlgo2009::true2Dscan(){
774 float maxPatchEt = 0.0;
777 float *totalCaloEt=eve_phiEne;
778 float eneA[cl2jetMaxEtaBins];
779 float secondPatchArray[cl2jetMaxPhiBins][cl2jetMaxEtaBins-cl2jet_par_mxEtaBin+1];
780 memset(secondPatchArray,0,
sizeof(secondPatchArray));
788 for(i=0;i<cl2jetMaxPhiBins;i++)
790 sumTot+=totalCaloEt[i];
791 memset(eneA,0,
sizeof(eneA));
792 for(j=0;j<cl2jet_par_mxPhiBin;j++)
794 j1 = (i+j)%cl2jetMaxPhiBins;
795 float *patchEneA=eve_patchEne+(j1*cl2jetMaxEtaBins);
796 for(j2=0;j2<cl2jetMaxEtaBins;j2++,patchEneA++)
798 eneA[j2]+=*patchEneA;
802 for(k=0;k<cl2jetMaxEtaBins-cl2jet_par_mxEtaBin+1;k++,eneAp++)
806 float sum=eneAp[0]+eneAp[1]+eneAp[2]+eneAp[3]+eneAp[4];
808 secondPatchArray[i][k]=sum;
809 if(maxPatchEt>sum)
continue;
817 eve_Jet[0]->iphiBin=iphiBinEdge;
818 eve_Jet[0]->ietaBin=ietaBinEdge;
819 eve_Jet[0]->iene=maxPatchEt;
824 float maxPatchEt2=0.0;
826 int a1=iphiBinEdge-par_minPhiBinDiff;
827 int a2=iphiBinEdge+par_minPhiBinDiff;
828 if (a1<0) { a1+=cl2jetMaxPhiBins; doWrap+=1; }
829 if (a2>=cl2jetMaxPhiBins) { a2-=cl2jetMaxPhiBins; doWrap+=2; }
835 for(b=0;b<cl2jetMaxPhiBins;b++)
837 if(b>=a1 && b<=a2)
continue;
838 for(b1=0;b1<cl2jetMaxEtaBins-cl2jet_par_mxEtaBin+1;b1++)
840 if(maxPatchEt2>secondPatchArray[b][b1])
continue;
841 maxPatchEt2=secondPatchArray[b][b1];
851 for(b1=0;b1<cl2jetMaxEtaBins-cl2jet_par_mxEtaBin+1;b1++)
853 if(maxPatchEt2>secondPatchArray[b][b1])
continue;
854 maxPatchEt2=secondPatchArray[b][b1];
861 eve_Jet[1]->iphiBin=iphiBinEdge2;
862 eve_Jet[1]->ietaBin=ietaBinEdge2;
863 eve_Jet[1]->iene=maxPatchEt2;
870 void L2jetAlgo2009::weightedEtaPhi(
int iK){
871 L2Jet *J=eve_Jet[iK];
876 J->fphiBin=J->iphiBin+.333;
877 J->fetaBin=J->ietaBin+.333;
883 int iphi0=J->iphiBin;
884 int ieta0=J->ietaBin;
902 float etaEneA[cl2jet_par_mxEtaBin];
903 memset(etaEneA,0,
sizeof(etaEneA));
907 for(iy=iphi0;iy<iphi0+cl2jet_par_mxPhiBin;iy++)
909 int jy=iy % cl2jetMaxPhiBins;
910 float *patchEneA=eve_patchEne+(jy*cl2jetMaxEtaBins);
913 for(ix=ieta0;ix<ieta0+cl2jet_par_mxEtaBin;ix++)
916 etaEneA[ix-ieta0]+=patchEneA[ix];
918 if(sum1>0) nEnePhi++;
925 for(jx=ieta0;jx<ieta0+cl2jet_par_mxEtaBin;jx++)
927 if(etaEneA[jx-ieta0]>0) nEneEta++;
928 sumX+=jx*etaEneA[jx-ieta0];
929 sumXX+=(jx*jx*etaEneA[jx-ieta0]);
933 float phiMean= 1.*sumY/iene0;
934 float fphiBinMax=0.5 +phiMean;
938 rmsPhi=sqrt(nEnePhi/(nEnePhi-1.) *(sumYY/iene0 - phiMean*phiMean));
940 if(fphiBinMax>cl2jetMaxPhiBins) fphiBinMax-=cl2jetMaxPhiBins;
943 float etaMean = 1.*sumX/iene0;
944 float fetaBin=0.5 + etaMean;
948 rmsEta=sqrt(nEneEta/(nEneEta-1.) *(sumXX/iene0 - etaMean*etaMean));
951 J->fphiBin=fphiBinMax;
961 L2jetAlgo2009:: dumpPatchEneA(){
964 for(iy=0;iy<cl2jetMaxPhiBins;iy++) {
965 float *patchEneA=eve_patchEne+(iy*cl2jetMaxEtaBins);
967 for(ix=0;ix<cl2jetMaxEtaBins;ix++,patchEneA++){
968 printf(
" %6f",*patchEneA);
970 printf(
" iPhi=%d\n",iy);
979 L2jetAlgo2009::computeE(
int token){
984 L2jetAlgo2009::finishRunHisto(){
987 const int *data20=hA[20]->getData();
988 const int *data30=hA[30]->getData();
990 int bHotSum=1,bHotId=-1;
995 for(i=0; i<EmcDbIndexMax; i++) {
997 if(mDb->isEmpty(x))
continue;
998 if (mDb->isBTOW(x) ) {
999 int softId=atoi(x->tube+2);
1000 int ieta= (x->eta-1);
1001 int iphi= (x->sec-1)*10 + x->sub-
'a' ;
1003 hA[21]->fillW(softId,data20[x->rdo]);
1004 hA[22]->fillW(ieta, iphi,data20[x->rdo]);
1005 if(bHotSum<data20[x->rdo]) {
1006 bHotSum=data20[x->rdo];
1011 else if (mDb->isETOW(x) ) {
1012 int ihard=x->chan+(x->crate-1)*128;
1013 int ieta= 12-x->eta;
1014 int iphi= (x->sec-1)*5 + x->sub-
'A' ;
1015 hA[31]->fillW(ihard,data30[x->rdo]);
1016 hA[32]->fillW(ieta, iphi,data30[x->rdo]);
1017 if(eHotSum<data30[x->rdo]) {
1018 eHotSum=data30[x->rdo];
1025 fprintf(mLogFile,
"L2jet::finishRun()\n");
1026 fprintf(mLogFile,
"#BTOW_hot tower _candidate_ (bHotSum=%d) :, softID %d , crate %d , chan %d , name %s\n",bHotSum,bHotId,xB->crate,xB->chan,xB->name);
1027 fprintf(mLogFile,
"#ETOW_hot tower _candidate_ (eHotSum=%d) :, name %s , crate %d , chan %d\n",eHotSum,xE->name,xE->crate,xE->chan);