StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
L2eemcGamma2009.cxx
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <time.h>
5 #include <math.h>
6 
7 /*********************************************************************
8  * $Id: L2eemcGamma2009.cxx,v 1.1 2011/03/09 16:29:07 pibero Exp $
9  * \author Jan Balewski,MIT , 2008
10  *********************************************************************
11  * Descripion: see .h
12  *********************************************************************
13  */
14 
15 
16 #ifdef IS_REAL_L2 //in l2-ana environment
17  #include "../L2algoUtil/L2EmcDb.h"
18  #include "../L2algoUtil/L2Histo.h"
19 #else //full path needed for cvs'd code
20  #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2EmcDb.h"
21  #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2Histo.h"
22  #include "StTriggerUtilities/L2Emulator/L2algoUtil/L2EmcGeom.h"
23 #endif
24 
25 #include "L2eemcGamma2009.h"
26 
27 
28 //=================================================
29 //=================================================
30 void L2eemcGamma2009::quickSort(int array[], int start, int end)
31 {
32  int i = start; // index of left-to-right scan
33  int k = end; // index of right-to-left scan
34 
35  if (end - start >= 1) // check that there are at least two elements to sort
36  {
37  float pivot = wrkEtow_et[array[start]]; // set the pivot as the first element in the partition
38 
39  while (k > i) // while the scan indices from left and right have not met,
40  {
41  while (wrkEtow_et[array[i]] <= pivot && i <= end && k > i) // from the left, look for the first
42  i++; // element greater than the pivot
43  while (wrkEtow_et[array[k]] > pivot && k >= start && k >= i) // from the right, look for the first
44  k--; // element not greater than the pivot
45  if (k > i) // if the left seekindex is still smaller than
46  swap(array, i, k); // the right index, swap the corresponding elements
47  }
48  swap(array, start, k); // after the indices have crossed, swap the last element in
49  // the left partition with the pivot
50  quickSort(array, start, k - 1); // quicksort the left partition
51  quickSort(array, k + 1, end); // quicksort the right partition
52  }
53  else // if there is only one element in the partition, do not do any sorting
54  {
55  return; // the array is sorted, so exit
56  }
57 }
58 
59 void L2eemcGamma2009::swap(int array[], int index1, int index2)
60 // pre: array is full and index1, index2 < array.length
61 // post: the values at indices 1 and 2 have been swapped
62 {
63  int temp = array[index1]; // store the first value in a temp
64  array[index1] = array[index2]; // copy the value of the second into the first
65  array[index2] = temp; // copy the value of the temp into the second
66 }
67 
68 
69 
70 //=================================================
71 //=================================================
72 L2eemcGamma2009::L2eemcGamma2009(const char* name, L2EmcDb* db, L2EmcGeom *geoX, char* outDir, int resOff) : L2VirtualAlgo2009( name, db, outDir, false,true, resOff) {
73  /* called one per days
74  all memory allocation must be done here
75  */
76  mGeom=geoX;
77  if (!mGeom)
78  criticalError("L2eemcGamma is broken -- can't find geom.");
79 
80  setMaxHist(16); // set upper range, I uses only 2^N -it is easier to remember
81  createHisto();
82 
83  //------- self-consistency checks, should never fail
84  if (sizeof(L2gammaResult2009)!= L2gammaResult2009::mySizeChar)
85 
86  criticalError("L2eemcGamma has failed consistency check. sizeof(L2gammaResult2009)!= L2gammaResult2009::mySizeChar");
87 
88 
89 
90 }
91 
92 /* ========================================
93  ======================================== */
94 int
95 L2eemcGamma2009::initRunUser( int runNo, int *rc_ints, float *rc_floats) {
96 
97  // unpack params from run control GUI
98  par_dbg = rc_ints[0];
99  par_RndAcceptPrescale = rc_ints[1];
100  par_seedEtThres = rc_floats[0];
101  par_clusterEtThres= rc_floats[1];
102  par_eventEtThres = rc_floats[2];
103 
104  // verify consistency of input params
105  int kBad=0;
106  kBad+=0x00001 * (par_seedEtThres<1.0);
107  kBad+=0x00002 * (par_clusterEtThres<par_seedEtThres);
108 
109  if (mLogFile) {
110  fprintf(mLogFile,"L2%s algorithm initRun(R=%d), compiled: %s , %s\n params:\n",getName(),mRunNumber,__DATE__,__TIME__);
111  fprintf(mLogFile," - use Thres/GeV seed=%.2f, clusterList=%.2f debug=%d, prescale=%d\n", par_seedEtThres,par_clusterEtThres, par_dbg,par_RndAcceptPrescale);
112 
113  fprintf(mLogFile," - accept event cluster Thres/GeV=%.2f\n",par_eventEtThres);
114  fprintf(mLogFile,"initRun() params checked for consistency, Error flag=0x%04x\n",kBad);
115  }
116 
117 
118  // clear content of all histograms & token-dependent memory
119  int i;
120  for (i=0; i<mxHA;i++) if(hA[i])hA[i]->reset();
121 
122  if(kBad) return -1*kBad;
123 
124  memset(mEtow,0,sizeof(mEtow));
125 
126  // update tiltles of histos
127  char txt[1000];
128  sprintf(txt,"ETOW-compute: #seed towers ET>%.2f GeV / event; x: # ETOW towers; y: counts",par_seedEtThres);
129  hA[3]->setTitle(txt);
130 
131  sprintf(txt,"ETOW-decision: #cluster ET>%.2f GeV / event ; x: # ETOW towers; y: counts",par_clusterEtThres);
132  hA[4]->setTitle(txt);
133 
134  sprintf(txt,"ETOW-decision: acc cluster ET>%.2f GeV; x:cluster ET(GeV) ; y: counts",par_eventEtThres);
135  hA[4]->setTitle(txt);
136 
137 
138 
139  for ( int index=0; index<EmcDbIndexMax; index++ )
140  {
141  const L2EmcDb::EmcCDbItem *x = mDb->getByIndex(index);
142  if ( x==0 ) continue;
143  if ( !mDb->isETOW(x) ) continue;
144  int sec = x->sec - 1;
145  int sub = 8192;
146  sub = x->sub - 'A';
147  int eta = x->eta - 1;
148  int phi = EtowGeom::mxSubs *sec + sub;
149  int tow = EtowGeom::mxEtaBin *phi + eta; // phi- changes faster
150  int rdo = x->rdo;
151  if (tow<0 || tow>mxEtow || rdo<0 || rdo>mxEtow) return -101;
152 
153  mTower2rdo[ tow ] = rdo; // returns rdo channel for given tower
154  mRdo2tower[ rdo ] = tow; // returns tower for given rdo channel
155  }
156  return 0; //OK
157 
158 }
159 
160 /* ========================================
161  ======================================== */
162 int
163 L2eemcGamma2009::countNonZeroTow(int phi, int eta) {
164  int tow = EtowGeom::mxEtaBin *((phi+EtowGeom::mxPhiBin)%EtowGeom::mxPhiBin) + ((eta+EtowGeom::mxEtaBin)%EtowGeom::mxEtaBin); // phi- changes faster
165  const int maxTowers = EtowGeom::mxEtaBin * EtowGeom::mxPhiBin;
166  int towPlusOne;
167  int count=0;
168 
169  if (etow_used[tow]==0) {
170  if(wrkEtow_et[tow]!=0) count++;
171  }
172 
173  towPlusOne = tow+1;
174  towPlusOne%= maxTowers;
175  if (etow_used[towPlusOne]==0) {
176  if(wrkEtow_et[towPlusOne]!=0) count++;
177  }
178 
179  tow+=EtowGeom::mxEtaBin;
180  tow%=maxTowers;
181  if (etow_used[tow]==0) {
182  if(wrkEtow_et[tow]!=0) count++;
183  }
184 
185  towPlusOne = tow+1;
186  towPlusOne%= maxTowers;
187  if (etow_used[towPlusOne]==0) {
188  if(wrkEtow_et[towPlusOne]!=0) count++;
189  }
190  return count;
191 }
192 
193 
194 /* ========================================
195  ======================================== */
196 void
197 L2eemcGamma2009::flagUsed(int phi, int eta) {
198  int tow = EtowGeom::mxEtaBin *((phi+EtowGeom::mxPhiBin)%EtowGeom::mxPhiBin) + ((eta+EtowGeom::mxEtaBin)%EtowGeom::mxEtaBin); // phi- changes faster
199  const int maxTowers = EtowGeom::mxEtaBin * EtowGeom::mxPhiBin;
200  int towPlusOne;
201  etow_used[tow] = 1;
202 
203  towPlusOne = tow+1;
204  towPlusOne%= maxTowers;
205  etow_used[towPlusOne] = 1;
206 
207  tow+=EtowGeom::mxEtaBin;
208  tow%=maxTowers;
209  etow_used[tow] = 1;
210 
211  towPlusOne = tow+1;
212  towPlusOne%= maxTowers;
213  etow_used[towPlusOne] = 1;
214 }
215 
216 /* ========================================
217  ======================================== */
218 void
219 L2eemcGamma2009::averageEtaPhi(int phi, int eta, float *avePhi, float *aveEta) {
220  int tow = EtowGeom::mxEtaBin *((phi+EtowGeom::mxPhiBin)%EtowGeom::mxPhiBin) + ((eta+EtowGeom::mxEtaBin)%EtowGeom::mxEtaBin); // phi- changes faster
221  const int maxTowers = EtowGeom::mxEtaBin * EtowGeom::mxPhiBin;
222  int towPlusOne;
223  float ETsum;
224  float etaSum;
225  float phiSum;
226 
227  ETsum=wrkEtow_et[tow];
228  etaSum = wrkEtow_et[tow]*(float)eta;
229  phiSum = wrkEtow_et[tow]*(float)phi;
230 
231  towPlusOne = tow+1;
232  towPlusOne%= maxTowers;
233  ETsum+=wrkEtow_et[towPlusOne];
234  etaSum += wrkEtow_et[towPlusOne]*(float)(eta+1);
235  phiSum += wrkEtow_et[towPlusOne]*(float)phi;
236 
237  tow+=EtowGeom::mxEtaBin;
238  tow%=maxTowers;
239  ETsum+=wrkEtow_et[tow];
240  etaSum += wrkEtow_et[tow]*(float)eta;
241  phiSum += wrkEtow_et[tow]*(float)(phi+1);
242 
243  towPlusOne = tow+1;
244  towPlusOne%= maxTowers;
245  ETsum+=wrkEtow_et[towPlusOne];
246  etaSum += wrkEtow_et[towPlusOne]*(float)(eta+1);
247  phiSum += wrkEtow_et[towPlusOne]*(float)(phi+1);
248 
249 
250  *aveEta = etaSum/ETsum;
251  *avePhi = phiSum/ETsum;
252  //printf("eta:%d phi:%d --> etaSum:%f phiSum%f ETsum:%f aveEta:%f avePhi:%f\n",eta, phi, etaSum, phiSum, ETsum, *aveEta, *avePhi);
253 }
254 
255 
256 /* ========================================
257  ======================================== */
258 float
259 L2eemcGamma2009::sumET(int phi, int eta) {
260  int tow = EtowGeom::mxEtaBin *((phi+EtowGeom::mxPhiBin)%EtowGeom::mxPhiBin) + ((eta+EtowGeom::mxEtaBin)%EtowGeom::mxEtaBin); // phi- changes faster
261 
262  const int maxTowers = EtowGeom::mxEtaBin * EtowGeom::mxPhiBin;
263  int towPlusOne;
264  float sum;
265  sum=0;
266  if (etow_used[tow]==0) {
267  sum=wrkEtow_et[tow];
268  }
269  towPlusOne = tow+1;
270  towPlusOne%= maxTowers;
271  if (etow_used[towPlusOne]==0) {
272  sum+=wrkEtow_et[towPlusOne];
273  }
274  //if(tow==0 || towPlusOne==0) {
275  //printf("tow : %d, %d --> %f %f \n",tow, towPlusOne,wrkEtow_et[tow],wrkEtow_et[towPlusOne]);
276  //}
277  tow+=EtowGeom::mxEtaBin;
278  tow%=maxTowers;
279  if (etow_used[tow]==0) {
280  sum+=wrkEtow_et[tow];
281  }
282  towPlusOne = tow+1;
283  towPlusOne%= maxTowers;
284  if (etow_used[towPlusOne]==0) {
285  sum+=wrkEtow_et[towPlusOne];
286  }
287  //if(tow==0 || towPlusOne==0) {
288  //printf("tow : %d, %d --> %f %f \n",tow, towPlusOne,wrkEtow_et[tow],wrkEtow_et[towPlusOne]);
289  //}
290  return sum;
291 }
292 
293 
294 /* ========================================
295  ======================================== */
296 void
298  // token range is guaranteed by virtual08-class
299 
300  /* 2x2 cluster finder:
301  - can find clusters through the tower border in Phi
302  - sorts hit towers by Et and selects Highest Seed Towers first
303  */
304 
305  clearEvent(token);
306 
307  // ------ PROJECT INPUT LIST TO 2D ARRAY AND SCAN FOR SEED TOWERS ----
308  int i;
309  // printf("L2-%s-compute: ---ETOW ADC list--- size=%d\n",getName(),*globEve_etow_hitSize);
310 
311  L2eemcGammaEvent2009 *etowEve=mEtow+token;
312  const HitTower1 *hit=mEveStream_etow[token].get_hits();
313  const int hitSize=mEveStream_etow[token].get_hitSize();
314  for(i=0;i< hitSize;i++,hit++) {
315  //sortIndex[i] = i;
316  int tower=mRdo2tower[hit->rdo];
317  wrkEtow_tower_index[i]=tower;
318  wrkEtow_et[tower]=hit->et;
319  //if(hit->et<par_seedEtThres)continue;
320  //wrkEtow_tower_seed[wrkEtow_tower_seed_size++]=tower;
321  }
322  hA[2]->fill(hitSize);
323  // long int start, stop;
324 
325  quickSort(wrkEtow_tower_index,0,hitSize-1);
326  //print4(token,hitSize);
327 
328  // ----------- FIND 2x2 CLUSTER AROUND EVERY SEED -----
329  for(i=hitSize-1;i >= 0; i--) {
330  if(wrkEtow_et[wrkEtow_tower_index[i]] < par_seedEtThres) {
331  i = -1; // Early loop termination condition. Remaining elements are below threshold
332  continue;
333  }
334  int seedTow=wrkEtow_tower_index[i];
335  int seedEta=seedTow%EtowGeom::mxEtaBin;
336  int seedPhi=seedTow/EtowGeom::mxEtaBin;
337 
338  // ........drop seeds close to boundaries, fix it
340  //if(seedEta==0 || seedEta==EtowGeom::mxEtaBin-1) continue;
341  //if(seedPhi==0 || seedPhi==EtowGeom::mxPhiBin-1) continue;
342  // now every seed has 4 2x2 clusters
343 
344  //.... find max of 4 possible clusters
345  float maxET;
346  float sum;
347 
348  if (etow_used[seedTow]!=0) continue; // if seed tower has been used in another cluster
349  wrkEtow_tower_seed_size++;
350 
351  int high_quadrant;
352  high_quadrant = 0;
353  maxET = 0;
354  if(seedEta < EtowGeom::mxEtaBin) {
355  maxET = sumET(seedPhi,seedEta);
356  sum=sumET(seedPhi-1,seedEta);
357  //printf("0. max=%f sum=%f q=%d\n",maxET,sum,high_quadrant);
358  if(maxET<sum) {
359  maxET=sum;
360  high_quadrant = 1;
361  }
362  }
363  if (seedEta > 0) {
364  sum=sumET(seedPhi-1,seedEta-1);
365  //printf("1. max=%f sum=%f q=%d\n",maxET,sum,high_quadrant);
366  if(maxET<sum) {
367  maxET=sum;
368  high_quadrant = 2;
369  }
370  sum=sumET(seedPhi,seedEta-1);
371  //printf("2. max=%f sum=%f q=%d\n",maxET,sum,high_quadrant);
372  if(maxET<sum) {
373  maxET=sum;
374  high_quadrant = 3;
375  }
376  }
377  //printf("3. max=%f sum=%f q=%d\n",maxET,sum,high_quadrant);
378 
379  if(maxET<par_clusterEtThres)continue;
380  //........record clusters....
381 
382  hA[6]->fill((int)(maxET));
383  hA[7]->fill(seedTow);
384  hA[8]->fill(hitSize-i);
385  //hA[9]->fill(high_quadrant);
386  //hA[10]->fill((int)maxET);
387  hA[11]->fill((int)wrkEtow_et[seedTow]);
388  hA[12]->fill((int)(10.*wrkEtow_et[seedTow]/maxET));
389 
390  if(etowEve->size>=L2eemcGammaEvent2009::mxClust) continue; // overflow protection
391  etowEve->clusterET[etowEve->size]=maxET;
392  etowEve->clusterQuad[etowEve->size]=high_quadrant;
393  etowEve->clusterSeedTow[etowEve->size]=seedTow;
394 
395 
396 
397  // flag all towers used in this cluster so they will
398  // not be used in other clusters
399  int numNonZeroTow=0;
400  float clusterEta;
401  float clusterPhi;
402  if (high_quadrant==0) {
403  numNonZeroTow = countNonZeroTow(seedPhi, seedEta);
404  flagUsed(seedPhi, seedEta);
405  averageEtaPhi(seedPhi, seedEta,&clusterPhi, &clusterEta);
406  } else if (high_quadrant==1) {
407  numNonZeroTow = countNonZeroTow(seedPhi-1, seedEta);
408  flagUsed(seedPhi-1, seedEta);
409  averageEtaPhi(seedPhi-1, seedEta,&clusterPhi, &clusterEta);
410  } else if (high_quadrant==2) {
411  numNonZeroTow = countNonZeroTow(seedPhi-1, seedEta-1);
412  flagUsed(seedPhi-1, seedEta-1);
413  averageEtaPhi(seedPhi-1, seedEta-1,&clusterPhi, &clusterEta);
414  } else if (high_quadrant==3) {
415  numNonZeroTow = countNonZeroTow(seedPhi, seedEta-1);
416  flagUsed(seedPhi, seedEta-1);
417  averageEtaPhi(seedPhi, seedEta-1,&clusterPhi, &clusterEta);
418  }
419  hA[13]->fill(numNonZeroTow);
420  //printf("clusterEta:%f clusterPhi:%f\n",clusterEta, clusterPhi);
421  etowEve->clusterEta[etowEve->size]=clusterEta;
422  etowEve->clusterPhi[etowEve->size]=clusterPhi;
423 
424  etowEve->size++;
425 
426  }// end of cluster search
427 
428  hA[3]->fill(wrkEtow_tower_seed_size);
429  //printf("SeedSize=%d \n",wrkEtow_tower_seed_size);
430  hA[4]->fill(etowEve->size);
431 
432  //---------- histo cluster energies-----
433  //for(i=0;i<etow_clusterET_size;i++) {
434  // printf("clust ET=%.3f \n",etow_clusterET[i]);
435  //}
436 
437  // debugging should be off for any time critical computation
438  if(par_dbg>0){
439  printf("dbg=%s, etow-adcL-size=%d\n",getName(),hitSize);
440  // if(par_dbg>0) print1();
441  print2();
442  print3();// tmp, must have token
443  }
444 }
445 
446 
447 /* ========================================
448  ======================================== */
449 bool
450 L2eemcGamma2009::decisionUser(int token, int *myL2Result){
451  // INPUT: token + comput() results stored internally
452  // OUTPUT: yes/now + pointer to L2Result
453 
454  //the below is now handled in virtual algo
455  //if(par_prescale>0) {
456  // prescale++;
457  // prescale %= par_prescale;
458  //};
459  //printf("prescale %d\n",prescale);
460 
461  // get pointers to internal private event storage
462  L2eemcGammaEvent2009 *etowEve=mEtow+token;
463 
464  // printf("eee %p\n",*myL2Result);
465  int ic;
466 
467  //...... some histos just for fun
468  if(etowEve->size>= L2eemcGammaEvent2009::mxClust) mhN->fill(5); // was overflow
469  if(etowEve->isFresh>L2eemcGammaEvent2009::kDataFresh) mhN->fill(6); // stale data
470  etowEve->isFresh++; // mark the data as stale
471 
472  hA[4]->fill(etowEve->size);
473 
474  for(ic=0;ic<etowEve->size;ic++) {
475  float clustET=etowEve->clusterET[ic];
476  hA[5]->fill((int)clustET);
477  // printf("DDD clust ET=%.3f\n", clustET);
478  if(clustET<par_eventEtThres) continue;
479  hA[6]->fill((int)clustET);
480  }
481  //printf("clustzzzzzzzzzzzzzzzzz s=%d tkn=%d\n",etow_clusterET_size,token);
482 
483  //........ fill (some) L2Result
484  //etowEve->resultBlob.kTicksCompute=mComputeTimeDiff[token]/1000;
485  //etowEve->resultBlob.decision=0;
486  //etowEve->resultBlob.numberOfL2Clust=etowEve->size;
487 
488  float maxClusterEt;
489  maxClusterEt=-1;
490  int maxClusterID;
491  maxClusterID =-1;
492 
493  //........ compute the final decision
494  for(ic=0;ic<etowEve->size;ic++) {
495  if(etowEve->clusterET[ic]>maxClusterEt) {
496  maxClusterEt = etowEve->clusterET[ic];
497  maxClusterID = ic;
498  }
499  }
500  if(maxClusterEt>par_eventEtThres) {
501  etowEve->resultBlob.clusterEt=(unsigned char)(etowEve->clusterET[maxClusterID]*256.0/60.0);
502  etowEve->resultBlob.TowerID=(unsigned short)etowEve->clusterSeedTow[maxClusterID]+(etowEve->clusterQuad[maxClusterID]<<13);
503  etowEve->resultBlob.meanEtaBin=(unsigned char)((int)(etowEve->clusterEta[maxClusterID]*256.0/EtowGeom::mxEtaBin)%256);
504  etowEve->resultBlob.meanPhiBin=(unsigned char)((int)(etowEve->clusterPhi[maxClusterID]*256.0/EtowGeom::mxPhiBin)%256);
505  etowEve->resultBlob.isolationSum=(unsigned char)1;
506  etowEve->resultBlob.Time=(unsigned char)(mComputeTimeDiff[token]/1000);
507  etowEve->resultBlob.trigger=(unsigned char)5;
508  if (mRandomAccept) {//accept at random - never gets there for events below threshold, JanB
509  etowEve->resultBlob.trigger=(unsigned char)7;
510  }
511  /*printf("clustixxxxxxxxxxxxxxx clustEt=%f trigger=%d tower=%d quad=%d eta%f phi%f\n",
512  etowEve->clusterET[maxClusterID],
513  etowEve->resultBlob.trigger,
514  etowEve->clusterSeedTow[maxClusterID],
515  etowEve->clusterQuad[maxClusterID],
516  etowEve->clusterEta[maxClusterID],
517  etowEve->clusterPhi[maxClusterID]);
518  printf("Max Eta=%d maxPhi=%d \n", EtowGeom::mxEtaBin, EtowGeom::mxPhiBin);
519  */
520  hA[9]->fill(etowEve->clusterQuad[maxClusterID]);
521  hA[10]->fill((int)etowEve->clusterET[maxClusterID]);
522  if(etowEve->size>= L2eemcGammaEvent2009::mxClust) mhN->fill(15);
523  mhN->fill(15);
524  memcpy(myL2Result,&(etowEve->resultBlob),sizeof(L2gammaResult2009));
525  return true;
526  }
527 
528  // never gets there for accepted events, JanB
529  if (mRandomAccept) {
530  etowEve->resultBlob.trigger=(unsigned char)6;
531  etowEve->resultBlob.Time=(unsigned char)(mComputeTimeDiff[token]/1000);
532  mhN->fill(16);
533  memcpy(myL2Result,&(etowEve->resultBlob),sizeof(L2gammaResult2009));
534  return false; //randomAccept is handled in the virtualAlgo, so return false here and let Virtual do the ||
535  }
536 
537  memcpy(myL2Result,&(etowEve->resultBlob),sizeof(L2gammaResult2009));
538  return false;
539 
540 }
541 
542 
543 /* ========================================
544  ======================================== */
545 void
546 L2eemcGamma2009::finishRunUser() { /* called once at the end of the run */
547  // do whatever you want, log-file & histo-file are still open
548 
549  if (mLogFile){
550  fprintf(mLogFile,"finishRunUser-%s bhla bhla\n",getName());
551  }
552 
553 }
554 
555 
556 //=======================================
557 //=======================================
558 void
559 L2eemcGamma2009::createHisto() {
560  setMaxHist(15); // PMN added - histogram count does not seem to be initialiazed anywere.
561  //memset(hA,0,sizeof(hA));
562 
563  hA[2]=new L2Histo(2,"ETOW-compute: #towers w/ energy /event; x: # ETOW towers; y: counts", 100);
564  hA[3]=new L2Histo(3,"ETOW-compute: #seed ....... ", 100); // title in initRun
565  hA[4]=new L2Histo(4,"ETOW-decision: #clust ....... ", 50); // title in initRun
566 
567  hA[5]=new L2Histo(5,"ETOW-decision: any cluster ; x: ET(GeV)", 30);
568  hA[6]=new L2Histo(6,"ETOW-decision: accepted clust ... ; x: ET(GeV)", 30);// title in initRun
569 
570  hA[7]=new L2Histo(7,"ETOW: Seed Tower Number", 5000); // title in initRun
571  hA[8]=new L2Histo(8,"ETOW: Seed Tower Rank", 20); // title in initRun
572  hA[9]=new L2Histo(9,"ETOW: Seed Tower Quadrant", 5); // title in initRun
573  hA[10]=new L2Histo(10,"ETOW: Cluster Et Sum GeV", 30); // title in initRun
574  hA[11]=new L2Histo(11,"ETOW: Cluster Seed Et GeV", 30); // title in initRun
575  hA[12]=new L2Histo(12,"ETOW: 10*Seed Et/Cluster Et GeV", 30); // title in initRun
576  hA[13]=new L2Histo(13,"ETOW: # non-zero towers per cluster", 5); // title in initRun
577 
578  // printf("L2-%s::createHisto() done\n",getName());
579 }
580 
581 //=======================================
582 //=======================================
583 void
584 L2eemcGamma2009::clearEvent(int token){
585  memset(wrkEtow_et,0,sizeof(wrkEtow_et));
586  memset(etow_used,0,sizeof(etow_used));
587  memset(wrkEtow_tower_seed,0,sizeof(wrkEtow_tower_seed));
588  wrkEtow_tower_seed_size=0;
589  //etow_clusterET_size=0;
590  mEtow[token].size=0;
591  //previously the fresh flag was not set here, but now it is, since it was never being set anywhere else either.
592  mEtow[token].isFresh=L2eemcGammaEvent2009::kDataFresh;
593 // do not set 'fresh-flag here, only after compute() finishes
594  memset(&(mEtow[token].resultBlob),0, sizeof(L2gammaResult2009));
595 }
596 
597 /* ========================================
598  ======================================== */
599 void
600 L2eemcGamma2009::print2(){ // full , local ADC array
601  int i;
602  printf("pr2-%s: ---ETOW ADC 2D array, only non-zero\n",getName());
603 
604  for(i=0;i<mxEtow;i++) {
605  if(wrkEtow_et[i]<=0) continue;
606  int rdo=mTower2rdo[i];
607  float et=wrkEtow_et[i];
608  printf(" etow: tower=%4d rdo=%4d et=%.3f \n",i,rdo,et);
609  }
610 
611 }
612 
613 /* ========================================
614  ======================================== */
615 void
616 L2eemcGamma2009::print3(){ // seed list
617  int i;
618  printf("pr3-%s: ---seed list, size=%d\n",getName(),wrkEtow_tower_seed_size);
619 
620  for(i=0;i<wrkEtow_tower_seed_size;i++) {
621  int tower=wrkEtow_tower_seed[i];
622  float et=wrkEtow_et[tower];
623  printf(" etow: i=%4d tower=%4d et=%.3f \n",i,tower,et);
624  }
625 
626 }
627 
628 /* ========================================
629  ======================================== */
630 void
631 L2eemcGamma2009::print4(int token, int hitSize){ // L2-algo input list
632  int i;
633  printf("print4 IS NOT Fully FUNCTIONAL **********************\n");
634  printf("pr1-%s: ---ETOW Sorted ADC list--- size=%d\n",getName(),hitSize);
635  //const HitTower *hit=globEve_etow_hit;
636  for(i=0;i< hitSize;i++) {
637  int adc=0;//(mEveStream_etow[token].get_hits()[wrkEtow_tower_index[i]]).adc;
638  int rdo=0;//(mEveStream_etow[token].get_hits()[wrkEtow_tower_index[i]]).rdo;
639  float et=wrkEtow_et[wrkEtow_tower_index[i]];
640  float ene=0;//(mEveStream_etow[token].get_hits()[wrkEtow_tower_index[i]]).ene;
641  printf(" tower=%2d ",wrkEtow_tower_index[i]);
642  printf(" etow: i=%2d rdo=%4d adc=%d et=%.3f ene=%.3f\n",i,rdo,adc,et,ene);
643  }
644 }
645 
646 /**********************************************************************
647  $Log: L2eemcGamma2009.cxx,v $
648  Revision 1.1 2011/03/09 16:29:07 pibero
649  Added L2gamma2009
650 
651  Revision 1.6 2008/01/30 21:56:40 balewski
652  E+B high-enery-filter L2-algo fuly functional
653 
654  Revision 1.5 2008/01/30 00:47:17 balewski
655  Added L2-Etow-calib
656 
657  Revision 1.4 2008/01/18 23:29:13 balewski
658  now L2result is exported
659 
660  Revision 1.3 2008/01/17 23:15:51 balewski
661  bug in token-addressed memory fixed
662 
663  Revision 1.2 2008/01/16 23:32:35 balewski
664  toward token dependent compute()
665 
666  Revision 1.1 2007/12/19 02:30:18 balewski
667  new L2-etow-calib-2008
668 
669 
670 
671 */
672 
673 
void computeUser(int token)