17 #ifdef IS_REAL_L2 //in l2-ana environment
18 #include "../L2algoUtil/L2EmcDb.h"
19 #include "../L2algoUtil/L2Histo.h"
21 #include "../L2algoUtil/L2EmcDb.h"
22 #include "../L2algoUtil/L2Histo.h"
23 #include "../L2algoUtil/L2EmcGeom.h"
26 #include "L2exampleAlgo08.h"
36 mGeom=geoX; assert(mGeom);
48 L2exampleAlgo08::initRunUser(
int runNo,
int *rc_ints,
float *rc_floats) {
52 par_seedEtThres = rc_floats[0];
53 par_clusterEtThres= rc_floats[1];
54 par_eventEtThres = rc_floats[2];
58 kBad+=0x00001 * (par_seedEtThres<1.0);
59 kBad+=0x00002 * (par_clusterEtThres<par_seedEtThres);
62 fprintf(mLogFile,
"L2%s algorithm initRun(R=%d), compiled: %s , %s\n params:\n",getName(),mRunNumber,__DATE__,__TIME__);
63 fprintf(mLogFile,
" - use Thres/GeV seed=%.2f, clusterList=%.2f debug=%d\n", par_seedEtThres,par_clusterEtThres, par_dbg);
64 fprintf(mLogFile,
" - accept event cluster Thres/GeV=%.2f\n",par_eventEtThres);
65 fprintf(mLogFile,
"initRun() params checked for consistency, Error flag=0x%04x\n",kBad);
73 for (i=0; i<mxHA;i++)
if(hA[i])hA[i]->reset();
74 memset(mBtow,0,
sizeof(mBtow));
78 sprintf(txt,
"BTOW-compute: #seed towers ET>%.2f GeV / event; x: # BTOW towers; y: counts",par_seedEtThres);
81 sprintf(txt,
"BTOW-decision: #cluster ET>%.2f GeV / event ; x: # BTOW towers; y: counts",par_clusterEtThres);
84 sprintf(txt,
"BTOW-decision: acc cluster ET>%.2f GeV; x:cluster ET(GeV) ; y: counts",par_eventEtThres);
89 for (
int index=0; index<EmcDbIndexMax; index++ )
93 if ( !mDb->isBTOW(x) )
continue;
98 int phi = BtowGeom::mxSubs *sec + sub;
99 int tow = BtowGeom::mxEtaBin *phi + eta;
101 assert(tow>=0); assert(tow<=mxBtow);
102 assert(rdo>=0); assert(rdo<=mxBtow);
104 mTower2rdo[ tow ] = rdo;
105 mRdo2tower[ rdo ] = tow;
114 L2exampleAlgo08::sumET(
int phi,
int eta) {
115 int tow = BtowGeom::mxEtaBin *phi + eta;
116 float sum=wrkBtow_et[tow]+wrkBtow_et[tow+1];
118 tow+=BtowGeom::mxEtaBin;
120 sum+=wrkBtow_et[tow]+wrkBtow_et[tow+1];
128 L2exampleAlgo08::computeUser(
int token){
143 const int hitSize=mEveStream_btow[token].get_hitSize();
144 for(i=0;i< hitSize;i++,hit++) {
145 int tower=mRdo2tower[hit->rdo];
146 wrkBtow_et[tower]=hit->et;
147 if(hit->et<par_seedEtThres)
continue;
148 wrkBtow_tower_seed[wrkBtow_tower_seed_size++]=tower;
150 hA[2]->fill(hitSize);
151 hA[3]->fill(wrkBtow_tower_seed_size);
159 for(i=0;i<wrkBtow_tower_seed_size;i++) {
160 int seedTow=wrkBtow_tower_seed[i];
161 int seedEta=seedTow%BtowGeom::mxEtaBin;
162 int seedPhi=seedTow/BtowGeom::mxEtaBin;
167 if(seedEta==0 || seedEta==BtowGeom::mxEtaBin-1)
continue;
168 if(seedPhi==0 || seedPhi==BtowGeom::mxPhiBin-1)
continue;
177 float maxET=sumET(seedPhi,seedEta);
178 float sum=sumET(seedPhi-1,seedEta);
179 if(maxET<sum) maxET=sum;
180 sum=sumET(seedPhi-1,seedEta-1);
181 if(maxET<sum) maxET=sum;
182 sum=sumET(seedPhi,seedEta-1);
183 if(maxET<sum) maxET=sum;
185 if(maxET<par_clusterEtThres)
continue;
186 if(btowEve->size>=L2exampleEvent08::mxClust)
continue;
188 btowEve->clusterET[btowEve->size++]=maxET;
191 btowEve->isFresh=L2exampleEvent08::kDataFresh;
196 printf(
"dbg=%s, btow-adcL-size=%d\n",getName(),hitSize);
207 L2exampleAlgo08::decisionUser(
int token,
void **myL2Result){
213 (*myL2Result)=&(btowEve->resultBlob);
218 if(btowEve->size>= L2exampleEvent08::mxClust) mhN->fill(5);
219 if(btowEve->isFresh>L2exampleEvent08::kDataFresh) mhN->fill(6);
222 hA[4]->fill(btowEve->size);
224 for(ic=0;ic<btowEve->size;ic++) {
225 float clustET=btowEve->clusterET[ic];
226 hA[5]->fill((
int)clustET);
228 if(clustET<par_eventEtThres)
continue;
229 hA[6]->fill((
int)clustET);
234 btowEve->resultBlob.kTicksCompute=mComputeTimeDiff[token]/1000;
235 btowEve->resultBlob.decision=0;
236 btowEve->resultBlob.numberOfL2Clust=btowEve->size;
239 for(ic=0;ic<btowEve->size;ic++) {
240 if(btowEve->clusterET[ic]<par_eventEtThres)
continue;
241 btowEve->resultBlob.decision=1;
242 btowEve->resultBlob.clusterET=btowEve->clusterET[ic];
250 if(btowEve->size>= L2exampleEvent08::mxClust) mhN->fill(15);
259 L2exampleAlgo08::finishRunUser() {
263 fprintf(mLogFile,
"finishRunUser-%s bhla bhla\n",getName());
272 L2exampleAlgo08::createHisto() {
273 memset(hA,0,
sizeof(hA));
275 hA[2]=
new L2Histo(2,
"BTOW-compute: #towers w/ energy /event; x: # BTOW towers; y: counts", 100);
276 hA[3]=
new L2Histo(3,
"BTOW-compute: #seed ....... ", 100);
277 hA[4]=
new L2Histo(4,
"BTOW-decision: #clust ....... ", 50);
279 hA[5]=
new L2Histo(5,
"BTOW-decision: any cluster ; x: ET(GeV)", 30);
280 hA[6]=
new L2Histo(6,
"BTOW-decision: accepted clust ... ; x: ET(GeV)", 30);
288 L2exampleAlgo08::clearEvent(
int token){
289 memset(wrkBtow_et,0,
sizeof(wrkBtow_et));
290 memset(wrkBtow_tower_seed,0,
sizeof(wrkBtow_tower_seed));
291 wrkBtow_tower_seed_size=0;
299 L2exampleAlgo08::print2(){
301 printf(
"pr2-%s: ---BTOW ADC 2D array, only non-zero\n",getName());
303 for(i=0;i<mxBtow;i++) {
304 if(wrkBtow_et[i]<=0)
continue;
305 int rdo=mTower2rdo[i];
306 float et=wrkBtow_et[i];
307 printf(
" btow: tower=%4d rdo=%4d et=%.3f \n",i,rdo,et);
315 L2exampleAlgo08::print3(){
317 printf(
"pr3-%s: ---seed list, size=%d\n",getName(),wrkBtow_tower_seed_size);
319 for(i=0;i<wrkBtow_tower_seed_size;i++) {
320 int tower=wrkBtow_tower_seed[i];
321 float et=wrkBtow_et[tower];
322 printf(
" btow: i=%4d tower=%4d et=%.3f \n",i,tower,et);