00001 #include <stdio.h>
00002 #include <string.h>
00003 #include <stdlib.h>
00004 #include <time.h>
00005 #include <math.h>
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "../L2algoUtil/L2Histo.h"
00016 #include "../L2algoUtil/L2EmcDb.h"
00017
00018 #include "L2wEemc2009.h"
00019
00020
00021
00022 L2wEemc2009::L2wEemc2009(const char* name, L2EmcDb* db, L2EmcGeom *geoX, char* outDir, int resOff) : L2VirtualAlgo2009( name, db, outDir, false,true, resOff ) {
00023
00024
00025
00026
00027
00028
00029 setMaxHist(2);
00030 createHisto();
00031
00032 }
00033
00034
00035
00036 int
00037 L2wEemc2009::initRunUser( int runNo, int *rc_ints, float *rc_floats) {
00038
00039
00040 par_dbg = rc_ints[0];
00041 par_RndAcceptPrescale = rc_ints[1];
00042 par_EtThresh = rc_floats[0];
00043
00044
00045 int kBad=0;
00046 kBad+=2*(par_EtThresh<0);
00047
00048
00049 if (mLogFile) {
00050 fprintf(mLogFile,"L2%s algorithm initRun(R=%d), compiled: %s , %s\n",getName(),mRunNumber,__DATE__,__TIME__);
00051 fprintf(mLogFile," - use ET Thresh =%f, RndAcceptPrescale=%d debug=%d\n", par_EtThresh , par_RndAcceptPrescale, par_dbg);
00052 fprintf(mLogFile,"initRun() params checked for consistency, Error flag=0x%04x\n",kBad);
00053 }
00054 if(kBad) return -kBad;
00055
00056
00057 int i;
00058 for (i=0; i<mxHA;i++) if(hA[i])hA[i]->reset();
00059 for (i=0;i<L2eventStream2009::mxToken;i++) highestEt[i]=0;
00060
00061
00062 char txt[1000];
00063
00064 sprintf(txt,"highest endcap tower ET; x: tower ET; y: counts");
00065 hA[0]->setTitle(txt);
00066
00067 sprintf(txt,"accepted: highest endcap tower ET; x: tower ET; y: counts");
00068 hA[1]->setTitle(txt);
00069
00070 return 0;
00071 }
00072
00073
00074
00075
00076
00077 void
00078 L2wEemc2009::computeUser(int token){
00079
00080
00081
00082 int i;
00083
00084 const HitTower1 *hit=0;
00085 int hitSize=0;
00086
00087 hit =mEveStream_etow[token].get_hits();
00088 hitSize=mEveStream_etow[token].get_hitSize();
00089
00090 highestEt[token]=0;
00091 for(i=0;i< hitSize;i++,hit++)
00092 if (hit->et>highestEt[token]) highestEt[token]=hit->et;
00093 }
00094
00095
00096
00097
00098 bool
00099 L2wEemc2009::decisionUser(int token, int *myL2Result){
00100
00101
00102 float h=highestEt[token];
00103 highestEt[token]=0;
00104 hA[0]->fill((int)h);
00105
00106 if (h>par_EtThresh)
00107 {
00108 hA[1]->fill((int)h);
00109 return true;
00110 }
00111 return false;
00112 }
00113
00114
00115
00116
00117 void
00118 L2wEemc2009::finishRunUser() {
00119
00120
00121
00122
00123
00124
00125 }
00126
00127
00128
00129
00130 void
00131 L2wEemc2009::createHisto() {
00132 memset(hA,0,sizeof(hA));
00133
00134 hA[0]=new L2Histo(0,(char*)"L0triggered: highest endcap tower ET; x: tower ET; y: counts", 100);
00135 hA[1]=new L2Histo(1,(char*)"accepted: highest endcap tower ET; x: tower ET; y: counts", 100);
00136
00137
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153