StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
L2wEemc2009.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: L2wEemc2009.cxx,v 1.2 2009/11/19 15:48:49 balewski Exp $
9  * \author Jan Balewski, MIT, 2008
10  ***********************************************************
11  * Descripion: see .h
12  **********************************************************
13  */
14 
15 #include "../L2algoUtil/L2Histo.h"
16 #include "../L2algoUtil/L2EmcDb.h"
17 
18 #include "L2wEemc2009.h"
19 
20 //=================================================
21 //=================================================
22 L2wEemc2009::L2wEemc2009(const char* name, L2EmcDb* db, L2EmcGeom *geoX, char* outDir, int resOff) : L2VirtualAlgo2009( name, db, outDir, false,true, resOff ) {
23  /* called one per days
24  all memory allocation must be done here
25  */
26 
27  // geoX is not used, ignore
28 
29  setMaxHist(2); // set upper range, I uses only 2^N -it is easier to remember
30  createHisto();
31 
32 }
33 
34 /* ========================================
35  ======================================== */
36 int
37 L2wEemc2009::initRunUser( int runNo, int *rc_ints, float *rc_floats) {
38 
39  // unpack params from run control GUI
40  par_dbg = rc_ints[0];
41  par_RndAcceptPrescale = rc_ints[1];
42  par_EtThresh = rc_floats[0];
43 
44  // verify consistency of input params
45  int kBad=0;
46  kBad+=2*(par_EtThresh<0);
47 
48  //FIX log output
49  if (mLogFile) {
50  fprintf(mLogFile,"L2%s algorithm initRun(R=%d), compiled: %s , %s\n",getName(),mRunNumber,__DATE__,__TIME__);
51  fprintf(mLogFile," - use ET Thresh =%f, RndAcceptPrescale=%d debug=%d\n", par_EtThresh , par_RndAcceptPrescale, par_dbg);
52  fprintf(mLogFile,"initRun() params checked for consistency, Error flag=0x%04x\n",kBad);
53  }
54  if(kBad) return -kBad;
55 
56  // clear content of all histograms & token-dependent memory
57  int i;
58  for (i=0; i<mxHA;i++) if(hA[i])hA[i]->reset();
59  for (i=0;i<L2eventStream2009::mxToken;i++) highestEt[i]=0;
60 
61  // update titles of histos, add values of params
62  char txt[1000];
63 
64  sprintf(txt,"highest endcap tower ET; x: tower ET; y: counts");
65  hA[0]->setTitle(txt);
66 
67  sprintf(txt,"accepted: highest endcap tower ET; x: tower ET; y: counts");
68  hA[1]->setTitle(txt);
69 
70  return 0; //OK
71 }
72 
73 
74 
75 /* ========================================
76  ======================================== */
77 void
78 L2wEemc2009::computeUser(int token){
79  // token range is guaranteed by virtual09-class
80  // ----------- SCAN FOR HIGHEST TOWER ----
81 
82  int i;
83  // get pointer to input list towers from calib-algo
84  const HitTower1 *hit=0;
85  int hitSize=0;
86 
87  hit =mEveStream_etow[token].get_hits();
88  hitSize=mEveStream_etow[token].get_hitSize();
89 
90  highestEt[token]=0;
91  for(i=0;i< hitSize;i++,hit++)
92  if (hit->et>highestEt[token]) highestEt[token]=hit->et;
93 }
94 
95 
96 /* ========================================
97  ======================================== */
98 bool
99 L2wEemc2009::decisionUser(int token, int *myL2Result){
100  // INPUT: token + comput() results stored internally
101  // OUTPUT: YES if the highestEt>par_EtThresh. Plot highestEt.
102  float h=highestEt[token];
103  highestEt[token]=0; //clear it, just in case of stale data.
104  hA[0]->fill((int)h);
105 
106  if (h>par_EtThresh)
107  {
108  hA[1]->fill((int)h);
109  return true;
110  }
111  return false;
112 }
113 
114 
115 /* ========================================
116  ======================================== */
117 void
118 L2wEemc2009::finishRunUser() { /* called once at the end of the run */
119  // do whatever you want, log-file & histo-file are still open
120 
121  // if (mLogFile){
122  // fprintf(mLogFile,"finishRunUser-%s bhla bhla\n",getName());
123  // }
124 
125 }
126 
127 
128 //=======================================
129 //=======================================
130 void
131 L2wEemc2009::createHisto() {
132  memset(hA,0,sizeof(hA));
133 
134  hA[0]=new L2Histo(0,(char*)"L0triggered: highest endcap tower ET; x: tower ET; y: counts", 100); // title set in initRun
135  hA[1]=new L2Histo(1,(char*)"accepted: highest endcap tower ET; x: tower ET; y: counts", 100); // title set in initRun
136 
137  // printf("L2-%s::createHisto() done\n",getName());
138 }
139 
140 /**********************************************************************
141  $Log: L2wEemc2009.cxx,v $
142  Revision 1.2 2009/11/19 15:48:49 balewski
143  add (char*) to many strings to make SL5 happ, few other adjustments
144 
145  Revision 1.1 2009/03/28 19:43:53 balewski
146  2009 code
147 
148  Revision 1.0 2009/03/20 05:00:00 rcorliss
149  adapted from L2hienAlgo.
150 
151 */
152 
153