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/L2EmcDb2012.h"
00017
00018 #include "L2wEemc2012.h"
00019
00020
00021
00022 L2wEemc2012::L2wEemc2012(const char* name, const char *uid, L2EmcDb2012* db, L2EmcGeom2012 *geoX, char* outDir, int resOff) : L2VirtualAlgo2012( name, uid, db, outDir, false,true, resOff ) {
00023
00024
00025
00026
00027
00028
00029 setMaxHist(4);
00030 createHisto();
00031
00032 }
00033
00034
00035
00036 int
00037 L2wEemc2012::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
00060
00061 char txt[1000];
00062
00063 sprintf(txt,"highest endcap tower ET; x: tower ET; y: counts");
00064 hA[1]->setTitle(txt);
00065
00066 return 0;
00067 }
00068
00069
00070
00071
00072
00073 void
00074 L2wEemc2012::computeUser(int token){
00075
00076
00077
00078 int i;
00079
00080 const HitTower1 *hit=0;
00081 int hitSize=0;
00082
00083 hit =mEveStream_etow[token].get_hits();
00084 hitSize=mEveStream_etow[token].get_hitSize();
00085
00086 float highestEt=0.;
00087 unsigned short highestRDO=8888;
00088 for(i=0;i< hitSize;i++,hit++) {
00089 if (hit->et>highestEt) {
00090 highestEt=hit->et;
00091 highestRDO=hit->rdo;
00092 }
00093 }
00094
00095 resultBlob[token].trigger=0;
00096 resultBlob[token].highestEt=(unsigned char)(highestEt*256.0/60.0);
00097 resultBlob[token].highestRDO=highestRDO;
00098 hA[1]->fill((int)highestEt);
00099 if (highestEt>par_EtThresh) {
00100 hA[2]->fill((int)highestRDO);
00101 resultBlob[token].trigger+=2;
00102 }
00103
00104 }
00105
00106
00107
00108
00109 bool
00110 L2wEemc2012::decisionUser(int token, int *myL2Result){
00111
00112
00113 if (mRandomAccept) resultBlob[token].trigger+=1;
00114
00115 memcpy(myL2Result,&(resultBlob[token]),sizeof( L2weResult2012));
00116 return resultBlob[token].trigger&2;
00117 }
00118
00119
00120
00121
00122 void
00123 L2wEemc2012::finishRunUser() {
00124
00125
00126
00127
00128
00129
00130 }
00131
00132
00133
00134
00135 void
00136 L2wEemc2012::createHisto() {
00137
00138
00139 hA[1]=new L2Histo(1,(char*)"Highest endcap tower ET; x: tower ET; y: counts", 100);
00140 hA[2]=new L2Histo(2,(char*)"ETOW: Seed Tower RDO", 720);
00141
00142
00143
00144
00145 }
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172