6 #include <fakeRtsLog.h>
22 #ifdef IS_REAL_L2 //in l2-ana environment
23 #include "../L2algoUtil/L2EmcDb2012.h"
24 #include "../L2algoUtil/L2Histo.h"
26 #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2EmcDb2012.h"
27 #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2Histo.h"
30 #include "L2jetAlgo2012.h"
31 #include "L2jetResults2012.h"
32 #include "Map_DeltaPhiJets.h"
36 L2jetAlgo2012::L2jetAlgo2012(
const char* name,
const char *uid,
L2EmcDb2012* db,
char* outDir,
int resOff,
bool writeHighResult)
42 if (writeHighResult) namechar=
'H';
46 LOG(DBG,
"L2jetAlgo2012 instantiated, logPath='%s'\n",mOutDir1.c_str());
54 L2jetAlgo2012::paramsChanged(
int *rc_ints,
float *rc_floats) {
57 if(rc_ints[i]!=raw_ints[i])
goto foundProblem;
60 if(fabs(rc_floats[i]-raw_floats[i])>0.00001)
goto foundProblem;
65 if (mLogFile) fprintf(mLogFile,
"L2jet-ghost initRun - inconsistent params, ABORT initialization\n");
72 L2jetAlgo2012::initRunUser(
int runNo,
int *rc_ints,
float *rc_floats) {
76 for (i=0; i<mxHA;i++)
if(hA[i])hA[i]->reset();
79 memset(db_btowL2PhiBin, 0,
sizeof(db_btowL2PhiBin));
80 memset(db_btowL2PatchBin,0,
sizeof(db_btowL2PatchBin));
82 memset(db_etowL2PhiBin, 0 ,
sizeof(db_etowL2PhiBin));
83 memset(db_etowL2PatchBin,0 ,
sizeof(db_etowL2PatchBin));
85 run_startUnix=time(0);
88 raw_floats =rc_floats;
89 run_nEventOneJet=run_nEventDiJet= run_nEventRnd=0;
93 if( mLogFile==0) LOG(ERR,
" L2jetAlgo2012() UNABLE to open run summary log file, continue anyhow\n");
96 par_useBtowEast= (rc_ints[0]&1 )>0;
97 par_useBtowWest= (rc_ints[0]&2)>0;
98 par_useEndcap = rc_ints[1]&1;
99 int par_adcThr = rc_ints[2];
100 par_dbg = rc_ints[3];
101 par_RndAcceptPrescale = rc_ints[4];
102 par_minPhiBinDiff= 7;
104 par_oneJetThr = rc_floats[0];
105 par_diJetThrHigh= rc_floats[1];
106 par_diJetThrLow = rc_floats[2];
107 par_diJetThr_2 = rc_floats[3];
108 par_diJetThr_3 = rc_floats[4];
109 par_diJetThr_4 = rc_floats[5];
110 par_diJetThr_5 = rc_floats[6];
111 par_diJetEtaHigh = rc_floats[7];
112 par_diJetEtaLow = rc_floats[8];
117 float monTwEtThr=2.0;
118 par_hotTwEtThr = monTwEtThr;
120 if(par_dbg) LOG(DBG,
"Brian version is running!\n");
123 fprintf(mLogFile,
"L2jet algorithm initRun(%d), compiled: %s , %s\n params:\n",run_number,__DATE__,__TIME__);
124 fprintf(mLogFile,
" - use BTOW: East=%d West=%d, Endcap=%d L2ResOffset=%d\n", par_useBtowEast, par_useBtowWest,par_useEndcap ,mResultOffset);
125 fprintf(mLogFile,
" - threshold: ADC-ped> %d \n", par_adcThr);
126 fprintf(mLogFile,
" - min phi opening angle Jet1<->Jet2: %d in L2phiBins\n",par_minPhiBinDiff);
127 fprintf(mLogFile,
" - diJet Et thrHigh= %.2f (GeV) thrLow= %.2f (GeV)\n", par_diJetThrHigh, par_diJetThrLow);
128 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);
129 fprintf(mLogFile,
" - oneJet Et thr = %.2f (GeV) ; rndAccPrescale=%d \n",par_oneJetThr,par_RndAcceptPrescale);
130 fprintf(mLogFile,
" - new diJet Eta_low= %.2f ; diJet Eta_High= %.2f \n", par_diJetEtaLow, par_diJetEtaHigh);
131 fprintf(mLogFile,
" - debug=%d, hot tower threshold: Et> %.1f GeV ( only monitoring)\n",par_dbg, monTwEtThr);
136 kBad+=0x0001 * ( !par_useBtowEast & !par_useBtowWest & !par_useEndcap);
138 kBad+=0x0004 * (par_adcThr>16);
139 kBad+=0x0008 * (par_minPhiBinDiff<5);
140 kBad+=0x0010 * (par_minPhiBinDiff>=15);
141 kBad+=0x0020 * (par_oneJetThr<3.);
142 kBad+=0x0040 * (par_oneJetThr>12.);
143 kBad+=0x0080 * (par_diJetThrLow<1.9);
144 kBad+=0x0100 * (par_diJetThrHigh<par_diJetThrLow);
145 kBad+=0x0200 * (par_diJetThrHigh>12.);
147 kBad+=0x0800 * ( par_RndAcceptPrescale<0 );
148 kBad+=0x1000 * (par_diJetThr_2<par_diJetThrLow || par_diJetThr_5>par_diJetThrHigh);
149 kBad+=0x2000 * (par_diJetThr_2>par_diJetThr_3 || par_diJetThr_3>par_diJetThr_4 || par_diJetThr_4>par_diJetThr_5);
150 kBad+=0x4000 * (par_diJetEtaLow>par_diJetEtaHigh);
152 fprintf(mLogFile,
"L2jet initRun() params checked for consistency, Error flag=0x%04x\n",kBad);
153 if(kBad) fprintf(mLogFile,
"L2jet initRun() ABORT\n");
159 fprintf(mLogFile,
"L2jet algorithm init: crashB in internal logic\n");
166 sprintf(tit,
"# BTOW towers>ped+%d (input); x: # of towers/event",par_adcThr);
167 hA[47]->setTitle(tit);
169 sprintf(tit,
"# ETOW towers>ped+%d (input); x: # of towers/event",par_adcThr);
170 hA[48]->setTitle(tit);
173 const int mxEtaBinsE=12,mxEtaBinsB=40;
177 int etowEtaBin2Patch[mxEtaBinsE]={14,14,13,13,12,12,11,11,11,10,10,10};
182 for(i=0; i<EmcDbIndexMax; i++) {
184 if(mDb->isEmpty(x))
continue;
185 if(x->fail)
continue;
186 if(x->gain<=0)
continue;
191 if (mDb->isBTOW(x) ) {
194 if(x->eta<0 || x->eta>mxEtaBinsB)
goto crashIt_1;
195 if(!par_useBtowEast && x->eta<=20)
continue;
196 if(!par_useBtowWest && x->eta>=21)
continue;
198 int iphiTw=(x->sec-1)*10 + x->sub-
'a';
201 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];
219 db_etowL2PhiBin[x->rdo]=iphiP;
220 db_etowL2PatchBin[x->rdo]=ietaP+ iphiP*cl2jetMaxEtaBins;
227 fprintf(mLogFile,
"L2jet algorithm: found working/calibrated: %d/%d=ETOW & %d/%d=BTOW, based on ASCII DB\n",nE,nEg,nB,nBg);
235 fprintf(mLogFile,
"L2jet algorithm init: crashC in internal logic\n");
244 void L2jetAlgo2012::computeUser(
int token){
251 L2jetAlgo2012::decisionUser(
int token,
int *myL2Result){
255 unsigned long mEveTimeStart,mEveTimeStop, mEveTimeDiff;
256 rdtscl_macro(mEveTimeStart);
274 int runTimeSec=time(0)- run_startUnix;
276 hA[12]->fill(runTimeSec);
278 if(par_dbg>1) LOG(DBG,
"\n......... in L2Jet_doEvent(ID=%d)... bIn=%d eIn=%d\n",eve_ID,bemcIn,eemcIn);
284 if (bemcIn || eemcIn){
288 int nBtowTw=0, nEtowTw=0;
293 if(bemcIn==1 && (par_useBtowEast||par_useBtowWest) ) {
295 nBtowTw=projectAdc( mEveStream_btow[token].get_hits(), mEveStream_btow[token].get_hitSize(),
296 db_btowL2PhiBin, db_btowL2PatchBin,
302 if(eemcIn==1 && par_useEndcap ) {
303 nEtowTw=projectAdc( mEveStream_etow[token].get_hits(), mEveStream_etow[token].get_hitSize(),
304 db_etowL2PhiBin, db_etowL2PatchBin,
309 float totEneGeV=true2Dscan();
310 int itotEneGeV=(int)totEneGeV;
312 for(iK=0; iK<mxJ; iK++)
315 L2Jet *K=eve_Jet[iK];
317 K->phiRad=0.21*(6.0-K->fphiBin);
318 while(K->phiRad<0) K->phiRad+=6.2832;
319 while(K->phiRad>6.2832) K->phiRad-=6.2832;
322 if(eve_Jet[0]->eneGeV <eve_Jet[1]->eneGeV) {
323 L2Jet *Jx=eve_Jet[0];
324 eve_Jet[0]=eve_Jet[1];
328 if(par_dbg>2) LOG(DBG,
"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);
335 float rjetEta_0=eve_Jet[0]->fetaBin*0.2 -1.0;
336 float rjetEta_1=eve_Jet[1]->fetaBin*0.2 -1.0;
338 bool acceptDiJet_EE=((rjetEta_0+rjetEta_1) > par_diJetEtaHigh && eve_Jet[0]->eneGeV > par_diJetThr_4 && eve_Jet[1]->eneGeV > par_diJetThrLow);
340 bool acceptDiJet_EB=((rjetEta_0+rjetEta_1) > par_diJetEtaLow && eve_Jet[0]->eneGeV > par_diJetThr_5 && eve_Jet[1]->eneGeV > par_diJetThr_2);
344 bool acceptDiJet_BB=(eve_Jet[0]->eneGeV > par_diJetThrHigh && eve_Jet[1]->eneGeV > par_diJetThr_3);
346 bool acceptDiJet=acceptDiJet_EE || acceptDiJet_EB || acceptDiJet_BB;
348 bool acceptOneJet=( eve_Jet[0]->eneGeV > par_oneJetThr) ;
350 bool acceptRnd=mRandomAccept>0;
351 mAccept=acceptDiJet || acceptOneJet || acceptRnd;
356 int iet1 =(int)eve_Jet[0]->eneGeV;
357 int iet2 =(int)eve_Jet[1]->eneGeV;
358 int ieta1=(int)eve_Jet[0]->fetaBin;
359 int ieta2=(int)eve_Jet[1]->fetaBin;
360 int iphi1=(int)eve_Jet[0]->fphiBin;
361 int iphi2=(int)eve_Jet[1]->fphiBin;
363 hA[40]->fill(iet1,iet2);
365 hA[41]->fill(ieta1,iphi1);
366 hA[42]->fill(ieta2,iphi2);
367 hA[43]->fill(iphi1,iphi2);
370 hA[46]->fill(itotEneGeV);
371 hA[47]->fill(nBtowTw);
372 hA[48]->fill(nEtowTw);
375 int kphi1=int(eve_Jet[0]->phiRad*10.);
376 int kphi2=int(eve_Jet[1]->phiRad*10.);
377 int idelZeta=map_DelPhiJets[kphi1*MxPhiRad10 + kphi2];
379 if( mAccept) hA[10]->fill(8);
384 hA[13]->fill(runTimeSec);
386 hA[51]->fill(ieta1,iphi1);
394 hA[14]->fill(runTimeSec);
395 hA[60]->fill(iet1,iet2);
396 hA[61]->fill(ieta1,iphi1);
397 hA[62]->fill(ieta2,iphi2);
398 hA[63]->fill(iphi1,iphi2);
405 hA[70]->fill(idelZeta);
406 hA[71]->fill(ieta1,idelZeta);
407 hA[72]->fill(ieta1,ieta2);
408 hA[73]->fill((iphi1+iphi2)/2,idelZeta);
409 hA[74]->fill(itotEneGeV);
414 hA[80]->fill(iet1,iet2);
415 hA[81]->fill(ieta1,iphi1);
416 hA[82]->fill(ieta2,iphi2);
417 hA[83]->fill(iphi1,iphi2);
424 hA[90]->fill(idelZeta);
425 hA[91]->fill(ieta1,idelZeta);
426 hA[92]->fill(ieta1,ieta2);
427 hA[93]->fill((iphi1+iphi2)/2,idelZeta);
428 hA[94]->fill(itotEneGeV);
433 hA[100]->fill(iet1,iet2);
434 hA[101]->fill(ieta1,iphi1);
435 hA[102]->fill(ieta2,iphi2);
436 hA[103]->fill(iphi1,iphi2);
439 hA[106]->fill(ieta1);
440 hA[107]->fill(ieta2);
441 hA[108]->fill(iphi1);
442 hA[109]->fill(iphi2);
443 hA[110]->fill(idelZeta);
444 hA[111]->fill(ieta1,idelZeta);
445 hA[112]->fill(ieta1,ieta2);
446 hA[113]->fill((iphi1+iphi2)/2,idelZeta);
447 hA[114]->fill(itotEneGeV);
452 hA[120]->fill(iet1,iet2);
453 hA[121]->fill(ieta1,iphi1);
454 hA[122]->fill(ieta2,iphi2);
455 hA[123]->fill(iphi1,iphi2);
458 hA[126]->fill(ieta1);
459 hA[127]->fill(ieta2);
460 hA[128]->fill(iphi1);
461 hA[129]->fill(iphi2);
462 hA[130]->fill(idelZeta);
463 hA[131]->fill(ieta1,idelZeta);
464 hA[132]->fill(ieta1,ieta2);
465 hA[133]->fill((iphi1+iphi2)/2,idelZeta);
466 hA[134]->fill(itotEneGeV);
472 hA[15]->fill(runTimeSec);
478 memset(&out,0,
sizeof(out));
482 out.int0.version=L2JET_RESULTS_VERSION;
484 ( par_useBtowEast <<0 ) +
485 ( par_useBtowWest <<1 ) +
486 ( par_useEndcap <<2 ) +
489 ( mRandomAccept <<5 ) +
490 ( acceptOneJet <<6 ) +
491 ( acceptDiJet <<7 ) +
492 ( acceptDiJet_EE <<8 ) +
493 ( acceptDiJet_EB <<9 ) +
494 ( acceptDiJet_BB <<10 ) ;
495 out.int0.dumm=namechar;
497 out.int1.iTotEne=(
unsigned short)(totEneGeV*100.);
498 out.int2.nBtowTw=nBtowTw;
499 out.int2.nEtowTw=nEtowTw;
501 out.jet1.jPhi=(int)(eve_Jet[0]->phiRad*28.65);
502 out.jet1.jEta=(int)(eve_Jet[0]->fetaBin*10.);
503 out.jet1.iEne=(
unsigned short)(eve_Jet[0]->eneGeV*100.);
505 out.jet2.jPhi=(int)(eve_Jet[1]->phiRad*28.65);
506 out.jet2.jEta=(int)(eve_Jet[1]->fetaBin*10.);
507 out.jet2.iEne=(
unsigned short)(eve_Jet[1]->eneGeV*100.);
509 out.jet1.rmsEta=(
unsigned short)(eve_Jet[0]->rmsEtaBin*20.);
510 out.jet1.rmsPhi=(
unsigned short)(eve_Jet[0]->rmsPhiBin*120.);
512 out.jet2.rmsEta=(
unsigned short)(eve_Jet[1]->rmsEtaBin*20.);
513 out.jet2.rmsPhi=(
unsigned short)(eve_Jet[1]->rmsPhiBin*120.);
516 rdtscl_macro(mEveTimeStop);
517 mEveTimeDiff=mEveTimeStop-mEveTimeStart;
518 int kTick=mEveTimeDiff/1000;
522 out.int0.kTick= kTick>255 ? 255 : kTick;
525 out.int1.checkSum=-L2jetResults2012_doCheckSum(&out);
535 L2jetResults2012_print(&out);
536 LOG(DBG,
" phiRad1=%f phiRad2=%f \n",eve_Jet[0]->phiRad,eve_Jet[1]->phiRad);
537 LOG(DBG,
"idelZeta=%d delZeta/deg=%.1f \n\n",idelZeta,idelZeta/31.416*180);
540 if( out.jet1.iEne+out.jet2.iEne > out.int1.iTotEne) {
543 LOG(ERR,
"L2jet-fatal error,neveId=%d, phi1,2=%d,%d\n",mEventsInRun,iphi1,iphi2);
547 if( L2jetResults2012_doCheckSum(&out)) {
548 LOG(ERR,
"L2jet-fatal error, wrong cSum=%d\n", L2jetResults2012_doCheckSum(&out));
549 L2jetResults2012_print(&out);
565 L2jetAlgo2012::finishRunUser() {
566 if(run_number<0)
return;
569 fprintf(mLogFile,
"L2-jet algorithm finishRun(%d)\n",run_number);
570 fprintf(mLogFile,
" - %d events seen by L2 di-jet\n",mEventsInRun);
571 fprintf(mLogFile,
" - accepted: rnd=%d oneJet=%d diJet=%d \n", run_nEventRnd, run_nEventOneJet, run_nEventDiJet);
574 hA[10]->printCSV(mLogFile);
579 LOG(ERR,
" L2jetAlgo2012: finishRun() UNABLE to open run summary log file, continue anyhow\n");
581 fprintf(mLogFile,
"L2 di-jet histos NOT saved, I/O error\n");
585 for(j=0;j<mxHA;j++) {
586 if(hA[j]==0)
continue;
587 hA[j]->write(mHistFile);
599 L2jetAlgo2012::createHisto() {
600 memset(hA,0,
sizeof(hA));
602 hA[10]=
new L2Histo(10,
"total event counter; x=cases",9);
603 hA[11]=
new L2Histo(11,
"L2 time used per input event; x: time (CPU kTics), range=100muSec; y: events ",160);
605 int mxRunDration=2500;
606 hA[12]=
new L2Histo(12,
"rate of input events; x: time in this run (seconds); y: rate (Hz)", mxRunDration);
608 hA[13]=
new L2Histo(13,
"rate of accepted one-Jet; x: time in this run (seconds); y: rate (Hz)", mxRunDration);
609 hA[14]=
new L2Histo(14,
"rate of accepted di-Jet ; x: time in this run (seconds); y: rate (Hz)", mxRunDration);
610 hA[15]=
new L2Histo(15,
"rate of random accepted ; x: time in this run (seconds); y: rate (Hz)", mxRunDration);
613 hA[20]=
new L2Histo(20,
"BTOW tower, Et>2.0 GeV (input); x: BTOW RDO index=chan*30+fiber; y: counts", 4800);
614 hA[21]=
new L2Histo(21,
"BTOW tower, Et>2.0 GeV (input); x: BTOW softID", 4800);
615 hA[22]=
new L2Histo(22,
"BTOW tower, Et>2.0 GeV (input); x: eta bin, [-1,+1]; y: phi bin ~sector",40,120);
618 hA[30]=
new L2Histo(30,
"ETOW tower, Et>2.0 GeV (input); x: ETOW RDO index=chan*6+fiber; y: counts", 720 );
619 hA[31]=
new L2Histo(31,
"ETOW tower, Et>2.0 GeV (input); x: i=chan+128*crate", 768);
620 hA[32]=
new L2Histo(32,
"ETOW tower, Et>2.0 GeV (input); x: 12 - Endcap etaBin ,[+1,+2]; y: phi bin ~sector",12,60);
623 hA[40]=
new L2Histo(40,
"Et Jet1-Jet2 (input); x: Jet1 Et/GeV ; Jet2 Et/GeV",30,30);
624 hA[41]=
new L2Histo(41,
"diJet1 eta-phi (input); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
625 hA[42]=
new L2Histo(42,
"diJet2 eta-phi (input); x: iEta [-1,+2] ; y: iPhi ~sector",15,30);
627 hA[43]=
new L2Histo(43,
"diJet phi1-phi2 (input); x: iPhi1 ~sector ; y: iPhi2 ~sector ",30,30);
629 hA[44]=
new L2Histo(44,
"Jet1 Et (input); x: Et (GeV)", 60);
630 hA[45]=
new L2Histo(45,
"Jet2 Et (input); x: Et (GeV)", 60);
631 hA[46]=
new L2Histo(46,
"total Et (input); x: Et (GeV)", 100);
632 hA[47]=
new L2Histo(47,
"# BTOW towers>thrXX (input); x: # of towers/event", 200);
633 hA[48]=
new L2Histo(48,
"# ETOW towers>thrXX (input); x: # of towers/event", 100);
636 hA[50]=
new L2Histo(50,
"one-Jet Et (accepted); x: jet Et (GeV)", 60);
637 hA[51]=
new L2Histo(51,
"one-Jet eta-phi (accepted); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
638 hA[52]=
new L2Histo(52,
"one-Jet eta (accepted); x: iEta [-1,+2]", 15);
639 hA[53]=
new L2Histo(53,
"one-Jet phi (accepted); x: iPhi ~sector", 30);
642 hA[60]=
new L2Histo(60,
"Et of Jet1 vs. Jet2 (accepted); x: Jet1/GeV ; Jet2/GeV",30,30);
643 hA[61]=
new L2Histo(61,
"diJet1 eta-phi (accepted); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
644 hA[62]=
new L2Histo(62,
"diJet2 eta-phi (accepted); x: iEta [-1,+2] ; y: iPhi ~sector",15,30);
646 hA[63]=
new L2Histo(63,
"diJet phi1-phi2 (accepted); x: iPhi1 ~sector ; y: iPhi2 ~sector ",30,30);
648 hA[64]=
new L2Histo(64,
"diJet1 Et (accepted); x: Et (GeV)", 60);
649 hA[65]=
new L2Histo(65,
"diJet2 Et (accepted); x: Et (GeV)", 60);
651 hA[66]=
new L2Histo(66,
"diJet1 eta (accepted); x: i Eta [-1,+2]", 15);
652 hA[67]=
new L2Histo(67,
"diJet2 eta (accepted); x: i Eta [-1,+2]", 15);
653 hA[68]=
new L2Histo(68,
"diJet1 phi (accepted); x: iPhi ~sector", 30);
654 hA[69]=
new L2Histo(69,
"diJet2 phi (accepted); x: iPhi ~sector", 30);
655 hA[70]=
new L2Histo(70,
"diJet delZeta (accepted); x: delta zeta (rad*10)", MxPhiRad10);
656 hA[71]=
new L2Histo(71,
"diJet delZeta vs. eta1 (accepted); x: iEta1 [-1,+2] ; y: delta zeta (rad*10)",15, MxPhiRad10);
657 hA[72]=
new L2Histo(72,
"diJet eta2 vs. eta1 (accepted); x: iEta1 [-1,+2] ;x: iEta2 [-1,+2] ",15,15);
658 hA[73]=
new L2Histo(73,
"diJet delZeta vs. avrPhi (accepted); x: (iphi1+iphi2)/2 (12 deg/bin); y: delta zeta (rad*10)",30, MxPhiRad10);
659 hA[74]=
new L2Histo(74,
"total Et diJet (accepted); x: Et (GeV)", 100);
662 hA[80]=
new L2Histo(80,
"Et of Jet1 vs. Jet2 (accepted_EE); x: Jet1/GeV ; Jet2/GeV",30,30);
663 hA[81]=
new L2Histo(81,
"diJet1 eta-phi (accepted_EE); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
664 hA[82]=
new L2Histo(82,
"diJet2 eta-phi (accepted_EE); x: iEta [-1,+2] ; y: iPhi ~sector",15,30);
666 hA[83]=
new L2Histo(83,
"diJet phi1-phi2 (accepted_EE); x: iPhi1 ~sector ; y: iPhi2 ~sector ",30,30);
668 hA[84]=
new L2Histo(84,
"diJet1 Et (accepted_EE); x: Et (GeV)", 60);
669 hA[85]=
new L2Histo(85,
"diJet2 Et (accepted_EE); x: Et (GeV)", 60);
671 hA[86]=
new L2Histo(86,
"diJet1 eta (accepted_EE); x: i Eta [-1,+2]", 15);
672 hA[87]=
new L2Histo(87,
"diJet2 eta (accepted_EE); x: i Eta [-1,+2]", 15);
673 hA[88]=
new L2Histo(88,
"diJet1 phi (accepted_EE); x: iPhi ~sector", 30);
674 hA[89]=
new L2Histo(89,
"diJet2 phi (accepted_EE); x: iPhi ~sector", 30);
675 hA[90]=
new L2Histo(90,
"diJet delZeta (accepted_EE); x: delta zeta (rad*10)", MxPhiRad10);
676 hA[91]=
new L2Histo(91,
"diJet delZeta vs. eta1 (accepted_EE); x: iEta1 [-1,+2] ; y: delta zeta (rad*10)",15, MxPhiRad10);
677 hA[92]=
new L2Histo(92,
"diJet eta2 vs. eta1 (accepted_EE); x: iEta1 [-1,+2] ;x: iEta2 [-1,+2] ",15,15);
678 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);
679 hA[94]=
new L2Histo(94,
"total Et diJet (accepted_EE); x: Et (GeV)", 60);
682 hA[100]=
new L2Histo(100,
"Et of Jet1 vs. Jet2 (accepted_EB); x: Jet1/GeV ; Jet2/GeV",30,30);
683 hA[101]=
new L2Histo(101,
"diJet1 eta-phi (accepted_EB); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
684 hA[102]=
new L2Histo(102,
"diJet2 eta-phi (accepted_EB); x: iEta [-1,+2] ; y: iPhi ~sector",15,30);
686 hA[103]=
new L2Histo(103,
"diJet phi1-phi2 (accepted_EB); x: iPhi1 ~sector ; y: iPhi2 ~sector ",30,30);
688 hA[104]=
new L2Histo(104,
"diJet1 Et (accepted_EB); x: Et (GeV)", 60);
689 hA[105]=
new L2Histo(105,
"diJet2 Et (accepted_EB); x: Et (GeV)", 60);
691 hA[106]=
new L2Histo(106,
"diJet1 eta (accepted_EB); x: i Eta [-1,+2]", 15);
692 hA[107]=
new L2Histo(107,
"diJet2 eta (accepted_EB); x: i Eta [-1,+2]", 15);
693 hA[108]=
new L2Histo(108,
"diJet1 phi (accepted_EB); x: iPhi ~sector", 30);
694 hA[109]=
new L2Histo(109,
"diJet2 phi (accepted_EB); x: iPhi ~sector", 30);
695 hA[110]=
new L2Histo(110,
"diJet delZeta (accepted_EB); x: delta zeta (rad*10)", MxPhiRad10);
696 hA[111]=
new L2Histo(111,
"diJet delZeta vs. eta1 (accepted_EB); x: iEta1 [-1,+2] ; y: delta zeta (rad*10)",15, MxPhiRad10);
697 hA[112]=
new L2Histo(112,
"diJet eta2 vs. eta1 (accepted_EB); x: iEta1 [-1,+2] ;x: iEta2 [-1,+2] ",15,15);
698 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);
699 hA[114]=
new L2Histo(114,
"total Et diJet (accepted_EB); x: Et (GeV)", 60);
702 hA[120]=
new L2Histo(120,
"Et of Jet1 vs. Jet2 (accepted_BB); x: Jet1/GeV ; Jet2/GeV",30,30);
703 hA[121]=
new L2Histo(121,
"diJet1 eta-phi (accepted_BB); x: iEta [-1,+2] ; y: iPhi ~sector ",15,30);
704 hA[122]=
new L2Histo(122,
"diJet2 eta-phi (accepted_BB); x: iEta [-1,+2] ; y: iPhi ~sector",15,30);
706 hA[123]=
new L2Histo(123,
"diJet phi1-phi2 (accepted_BB); x: iPhi1 ~sector ; y: iPhi2 ~sector ",30,30);
708 hA[124]=
new L2Histo(124,
"diJet1 Et (accepted_BB); x: Et (GeV)", 60);
709 hA[125]=
new L2Histo(125,
"diJet2 Et (accepted_BB); x: Et (GeV)", 60);
711 hA[126]=
new L2Histo(126,
"diJet1 eta (accepted_BB); x: i Eta [-1,+2]", 15);
712 hA[127]=
new L2Histo(127,
"diJet2 eta (accepted_BB); x: i Eta [-1,+2]", 15);
713 hA[128]=
new L2Histo(128,
"diJet1 phi (accepted_BB); x: iPhi ~sector", 30);
714 hA[129]=
new L2Histo(129,
"diJet2 phi (accepted_BB); x: iPhi ~sector", 30);
715 hA[130]=
new L2Histo(130,
"diJet delZeta (accepted_BB); x: delta zeta (rad*10)", MxPhiRad10);
716 hA[131]=
new L2Histo(131,
"diJet delZeta vs. eta1 (accepted_BB); x: iEta1 [-1,+2] ; y: delta zeta (rad*10)",15, MxPhiRad10);
717 hA[132]=
new L2Histo(132,
"diJet eta2 vs. eta1 (accepted_BB); x: iEta1 [-1,+2] ;x: iEta2 [-1,+2] ",15,15);
718 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);
719 hA[134]=
new L2Histo(134,
"total Et diJet (accepted_BB); x: Et (GeV)", 100);
726 L2jetAlgo2012::clearEvent(){
728 memset(eve_patchEne,0,
sizeof(eve_patchEne));
729 memset(eve_phiEne,0,
sizeof(eve_phiEne));
739 L2jetAlgo2012::projectAdc(
const HitTower1 *
hit,
const int hitSize,
740 unsigned short *phiBin,
unsigned short *patchBin,
746 for(
int i=0;i< hitSize;i++,hit++) {
748 low_noise_et=hit->low_noise_et;
749 eve_patchEne[patchBin[rdo]]+=low_noise_et;
750 eve_phiEne[phiBin[rdo]]+=low_noise_et;
753 if(low_noise_et > par_hotTwEtThr) hHot->fill(rdo);
762 float L2jetAlgo2012::true2Dscan(){
766 float maxPatchEt = 0.0;
769 float *totalCaloEt=eve_phiEne;
770 float eneA[cl2jetMaxEtaBins];
771 float secondPatchArray[cl2jetMaxPhiBins][cl2jetMaxEtaBins-cl2jet_par_mxEtaBin+1];
772 memset(secondPatchArray,0,
sizeof(secondPatchArray));
780 for(i=0;i<cl2jetMaxPhiBins;i++)
782 sumTot+=totalCaloEt[i];
783 memset(eneA,0,
sizeof(eneA));
784 for(j=0;j<cl2jet_par_mxPhiBin;j++)
786 j1 = (i+j)%cl2jetMaxPhiBins;
787 float *patchEneA=eve_patchEne+(j1*cl2jetMaxEtaBins);
788 for(j2=0;j2<cl2jetMaxEtaBins;j2++,patchEneA++)
790 eneA[j2]+=*patchEneA;
794 for(k=0;k<cl2jetMaxEtaBins-cl2jet_par_mxEtaBin+1;k++,eneAp++)
796 float sum=eneAp[0]+eneAp[1]+eneAp[2]+eneAp[3]+eneAp[4];
797 secondPatchArray[i][k]=sum;
798 if(maxPatchEt>sum)
continue;
806 eve_Jet[0]->iphiBin=iphiBinEdge;
807 eve_Jet[0]->ietaBin=ietaBinEdge;
808 eve_Jet[0]->iene=maxPatchEt;
813 float maxPatchEt2=0.0;
815 int a1=iphiBinEdge-par_minPhiBinDiff;
816 int a2=iphiBinEdge+par_minPhiBinDiff;
817 if (a1<0) { a1+=cl2jetMaxPhiBins; doWrap+=1; }
818 if (a2>=cl2jetMaxPhiBins) { a2-=cl2jetMaxPhiBins; doWrap+=2; }
824 for(b=0;b<cl2jetMaxPhiBins;b++)
826 if(b>=a1 && b<=a2)
continue;
827 for(b1=0;b1<cl2jetMaxEtaBins-cl2jet_par_mxEtaBin+1;b1++)
829 if(maxPatchEt2>secondPatchArray[b][b1])
continue;
830 maxPatchEt2=secondPatchArray[b][b1];
840 for(b1=0;b1<cl2jetMaxEtaBins-cl2jet_par_mxEtaBin+1;b1++)
842 if(maxPatchEt2>secondPatchArray[b][b1])
continue;
843 maxPatchEt2=secondPatchArray[b][b1];
850 eve_Jet[1]->iphiBin=iphiBinEdge2;
851 eve_Jet[1]->ietaBin=ietaBinEdge2;
852 eve_Jet[1]->iene=maxPatchEt2;
859 void L2jetAlgo2012::weightedEtaPhi(
int iK){
860 L2Jet *J=eve_Jet[iK];
865 J->fphiBin=J->iphiBin+.333;
866 J->fetaBin=J->ietaBin+.333;
872 int iphi0=J->iphiBin;
873 int ieta0=J->ietaBin;
891 float etaEneA[cl2jet_par_mxEtaBin];
892 memset(etaEneA,0,
sizeof(etaEneA));
896 for(iy=iphi0;iy<iphi0+cl2jet_par_mxPhiBin;iy++)
898 int jy=iy % cl2jetMaxPhiBins;
899 float *patchEneA=eve_patchEne+(jy*cl2jetMaxEtaBins);
902 for(ix=ieta0;ix<ieta0+cl2jet_par_mxEtaBin;ix++)
905 etaEneA[ix-ieta0]+=patchEneA[ix];
907 if(sum1>0) nEnePhi++;
914 for(jx=ieta0;jx<ieta0+cl2jet_par_mxEtaBin;jx++)
916 if(etaEneA[jx-ieta0]>0) nEneEta++;
917 sumX+=jx*etaEneA[jx-ieta0];
918 sumXX+=(jx*jx*etaEneA[jx-ieta0]);
922 float phiMean= 1.*sumY/iene0;
923 float fphiBinMax=0.5 +phiMean;
927 rmsPhi=sqrt(nEnePhi/(nEnePhi-1.) *(sumYY/iene0 - phiMean*phiMean));
929 if(fphiBinMax>cl2jetMaxPhiBins) fphiBinMax-=cl2jetMaxPhiBins;
932 float etaMean = 1.*sumX/iene0;
933 float fetaBin=0.5 + etaMean;
937 rmsEta=sqrt(nEneEta/(nEneEta-1.) *(sumXX/iene0 - etaMean*etaMean));
940 J->fphiBin=fphiBinMax;
950 L2jetAlgo2012:: dumpPatchEneA(){
953 for(iy=0;iy<cl2jetMaxPhiBins;iy++) {
954 float *patchEneA=eve_patchEne+(iy*cl2jetMaxEtaBins);
956 for(ix=0;ix<cl2jetMaxEtaBins;ix++,patchEneA++){
957 printf(
" %6f",*patchEneA);
959 printf(
" iPhi=%d\n",iy);
968 L2jetAlgo2012::computeE(
int token){
973 L2jetAlgo2012::finishRunHisto(){
976 const int *data20=hA[20]->getData();
977 const int *data30=hA[30]->getData();
979 int bHotSum=1,bHotId=-1;
984 for(i=0; i<EmcDbIndexMax; i++) {
986 if(mDb->isEmpty(x))
continue;
987 if (mDb->isBTOW(x) ) {
988 int softId=atoi(x->tube+2);
989 int ieta= (x->eta-1);
990 int iphi= (x->sec-1)*10 + x->sub-
'a' ;
991 hA[21]->fillW(softId,data20[x->rdo]);
992 hA[22]->fillW(ieta, iphi,data20[x->rdo]);
993 if(bHotSum<data20[x->rdo]) {
994 bHotSum=data20[x->rdo];
999 else if (mDb->isETOW(x) ) {
1000 int ihard=x->chan+(x->crate-1)*128;
1001 int ieta= 12-x->eta;
1002 int iphi= (x->sec-1)*5 + x->sub-
'A' ;
1003 hA[31]->fillW(ihard,data30[x->rdo]);
1004 hA[32]->fillW(ieta, iphi,data30[x->rdo]);
1005 if(eHotSum<data30[x->rdo]) {
1006 eHotSum=data30[x->rdo];
1013 fprintf(mLogFile,
"L2jet::finishRun()\n");
1014 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);
1015 fprintf(mLogFile,
"#ETOW_hot tower _candidate_ (eHotSum=%d) :, name %s , crate %d , chan %d\n",eHotSum,xE->name,xE->crate,xE->chan);