16 #ifdef IS_REAL_L2 //in l2-ana environment
17 #include "../L2algoUtil/L2EmcDb.h"
18 #include "../L2algoUtil/L2Histo.h"
20 #include "../L2algoUtil/L2EmcDb.h"
21 #include "../L2algoUtil/L2Histo.h"
24 #include "L2hienAlgo08.h"
28 L2hienAlgo08::L2hienAlgo08(
const char* name,
L2EmcDb* db,
L2EmcGeom *geoX,
char* outDir, L2VirtualAlgo2008::EmcSwitch beSwitch) :
L2VirtualAlgo2008( name, db, outDir) {
35 assert(beSwitch==kIsBtow || beSwitch==kIsEtow);
45 L2hienAlgo08::initRunUser(
int runNo,
int *rc_ints,
float *rc_floats) {
49 par_adcThres = rc_ints[1];
50 par_maxList = rc_ints[2];
54 kBad+=0x00001 * (par_adcThres<10);
57 if(par_maxList<10 ) par_maxList=10;
58 if(par_maxList>L2hienList08::mxListSize ) par_maxList=L2hienList08::mxListSize;
61 fprintf(mLogFile,
"L2%s algorithm initRun(R=%d), compiled: %s , %s\n params for ",getName(),mRunNumber,__DATE__,__TIME__);
62 if(mSwitch==kIsBtow) fprintf(mLogFile,
" BTOW setup:\n");
63 if(mSwitch==kIsEtow) fprintf(mLogFile,
" ETOW setup:\n");
64 fprintf(mLogFile,
" - use adcThresh =%d, maxList=%d debug=%d\n", par_adcThres , par_maxList, par_dbg);
65 fprintf(mLogFile,
"initRun() params checked for consistency, Error flag=0x%04x\n",kBad);
71 for (i=0; i<mxHA;i++)
if(hA[i])hA[i]->reset();
72 memset(mHiEnTw,0,
sizeof(mHiEnTw));
77 sprintf(txt,
"compute: # towers w/ ADC-ped>%d / event; x: # towers; y: counts",par_adcThres);
80 sprintf(txt,
"accepted: # towers w/ ADC-ped>%d / event; x: # towers; y: counts",par_adcThres);
83 sprintf(txt,
"accepted: # towers w/ ADC-ped>%d vs. eta ring;x: BTOW eta-bin, 0=eta=-1.0; y: counts",par_adcThres*2);
85 sprintf(txt,
"accepted: # towers w/ ADC-ped>%d vs. eta ring;x: ETOW eta-bin, 0=eta=+2.0; y: counts",par_adcThres*2);
88 sprintf(txt,
"accepted: # towers w/ ADC-ped>%d vs. phi ring;x: phi-bin, 0=12:30, follows TPC; y: counts",par_adcThres*2);
91 sprintf(txt,
"accpeted: ADC sum over towers w/ ADC-ped>%d ; ADC sum/16; y: counts",par_adcThres);
97 memset(mRdo2towerID_B,0,
sizeof(mRdo2towerID_B));
98 memset(mTowerID2etaBin_B,0,
sizeof(mTowerID2etaBin_B));
99 memset(mTowerID2phiBin_B,0,
sizeof(mTowerID2phiBin_B));
101 memset(mRdo2towerID_E,0,
sizeof(mRdo2towerID_E));
102 memset(mTowerID2etaBin_E,0,
sizeof(mTowerID2etaBin_E));
103 memset(mTowerID2phiBin_E,0,
sizeof(mTowerID2phiBin_E));
106 for (
int index=0; index<EmcDbIndexMax; index++ ) {
108 if ( x==0 )
continue;
109 if ( !mDb->isBTOW(x) )
continue;
110 int sec = x->sec - 1;
113 int eta = x->eta - 1;
114 int phi = BtowGeom::mxSubs *sec + sub;
115 int tow = BtowGeom::mxEtaBin *phi + eta;
117 assert(tow>=0); assert(tow<=mxBtow);
118 assert(rdo>=0); assert(rdo<=mxBtow);
120 mRdo2towerID_B[ rdo ] = tow;
121 mTowerID2etaBin_B[tow]=eta;
122 mTowerID2phiBin_B[tow]=phi;
127 for (
int index=0; index<EmcDbIndexMax; index++ ) {
129 if ( x==0 )
continue;
130 if ( !mDb->isETOW(x) )
continue;
131 int sec = x->sec - 1;
134 int eta = x->eta - 1;
135 int phi = EtowGeom::mxSubs *sec + sub;
136 int tow = EtowGeom::mxEtaBin *phi + eta;
138 assert(tow>=0); assert(tow<=mxEtow);
139 assert(rdo>=0); assert(rdo<=mxEtow);
141 mRdo2towerID_E[ rdo ] = tow;
142 mTowerID2etaBin_E[tow]=eta;
143 mTowerID2phiBin_E[tow]=phi;
154 L2hienAlgo08::computeUser(
int token){
159 mHiEnTw[token].size=0;
166 if(mSwitch==kIsBtow) {
167 hit =mEveStream_btow[token].get_hits();
168 hitSize=mEveStream_btow[token].get_hitSize();
169 mRdo2towerID=mRdo2towerID_B;
171 hit =mEveStream_etow[token].get_hits();
172 hitSize=mEveStream_etow[token].get_hitSize();
173 mRdo2towerID=mRdo2towerID_E;
180 unsigned int *value=hiTwEve->value;
182 for(i=0;i< hitSize;i++,hit++) {
184 if(hit->adc<par_adcThres)
continue;
185 if(hiTwEve->size>=par_maxList)
break;
186 int softID=mRdo2towerID[hit->rdo];
188 (*value)= ((hit->adc)<<16 )+ softID;
195 hiTwEve->isFresh=L2hienList08::kDataFresh;
196 hA[2]->fill(hiTwEve->size);
203 L2hienAlgo08::decisionUser(
int token,
void **myL2Result){
215 hA[3]->fill(hiTwEve->size);
216 if(hiTwEve->size>= par_maxList) mhN->fill(5);
217 if(hiTwEve->isFresh>L2hienList08::kDataFresh) mhN->fill(6);
221 int adc4QaThres=(par_adcThres/8);
222 int * mTowerID2etaBin=0 , *mTowerID2phiBin=0;
223 if(mSwitch==kIsBtow) {
224 mTowerID2etaBin=mTowerID2etaBin_B;
225 mTowerID2phiBin=mTowerID2phiBin_B;
227 mTowerID2etaBin=mTowerID2etaBin_E;
228 mTowerID2phiBin=mTowerID2phiBin_E;
231 unsigned int *value=hiTwEve->value;
234 for(ic=0;ic<hiTwEve->size;ic++,value++) {
235 int adc4=(*value)>>(16+4);
236 int softID=(*value)&0xffff;
240 if(adc4<adc4QaThres)
continue;
241 hA[5]->fill(mTowerID2etaBin[softID]);
242 hA[6]->fill(mTowerID2phiBin[softID]);
244 if(adcSum4>0) hA[7]->fill(adcSum4);
266 L2hienAlgo08::finishRunUser() {
270 fprintf(mLogFile,
"finishRunUser-%s bhla bhla\n",getName());
279 L2hienAlgo08::createHisto() {
280 memset(hA,0,
sizeof(hA));
282 hA[2]=
new L2Histo(2, (
char*)
"compute: #towers w/ .....energy /event; x: # towers; y: counts", 35);
283 hA[3]=
new L2Histo(3, (
char*)
"decision: #towers w/ .....energy /event; x: # towers; y: counts", 35);
285 int nEtaBin=BtowGeom::mxEtaBin;
286 int nPhiBin=BtowGeom::mxPhiBin;
287 if(mSwitch==kIsEtow) {
288 nEtaBin=EtowGeom::mxEtaBin;
289 nPhiBin=EtowGeom::mxPhiBin;
291 hA[4]=
new L2Histo(4, (
char*)
"accepted: towers ET (watch units!) ; x: (ADC-ped)/16", 100);
292 hA[5]=
new L2Histo(5, (
char*)
"accepted: #towers w/ ..... vs. eta ring",nEtaBin);
293 hA[6]=
new L2Histo(6, (
char*)
"accepted: #towers w/ .... vs. phi ring",nPhiBin);
294 hA[7]=
new L2Histo(7, (
char*)
"accepted: ADC sum ...",100);
303 L2hienAlgo08::print2(
int token){
305 assert(token<L2eventStream2008::mxToken);
307 int hiSize=getListSize(token);
308 const unsigned int *value=getListData(token);
310 printf(
"pr2-%s: dump %d acceted towers for token=%d\n softID ADC-ped\n",getName(),hiSize, token);
311 for(
int ic=0;ic<hiSize;ic++,value++) {
312 int adc=(*value)>>16;
313 int softID=(*value)&0xffff;
314 printf(
"%4d %d, \n",softID,adc);