00001
00002
00003
00004
00005
00006
00007
00009
00010 #include "StEventTypes.h"
00011 #include "StEvent/StEvent.h"
00012
00013
00014 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
00015 #include "StMuDSTMaker/COMMON/StMuDst.h"
00016 #include "StMuDSTMaker/COMMON/StMuTriggerIdCollection.h"
00017 #include "StMuDSTMaker/COMMON/StMuEvent.h"
00018
00019
00020 #include "StTriggerData2005.h"
00021 #include "StDaqLib/TRG/L2jetResults2006.h"
00022 #include "StDaqLib/TRG/trgStructures2005.h"
00023 #include "StDaqLib/TRG/trgStructures.h"
00024
00025
00026 #include "L2algoUtil/L2EmcDb.h"
00027 #include "L2jetAlgo/L2jetAlgo2006.h"
00028 #include "L2pedAlgo/L2pedAlgo.h"
00029 #include "L2gammaAlgo/L2gammaAlgo.h"
00030 #include "L2upsilon/L2upsilon2006.hh"
00031
00032 #include "StL2_2006EmulatorMaker.h"
00033
00034 ClassImp(StL2_2006EmulatorMaker)
00035
00036 StL2_2006EmulatorMaker::StL2_2006EmulatorMaker(const char *name):StMaker(name) {
00037 mL2pedAlgo=0;
00038 mL2jetAlgo2006=0;
00039 mL2gammaEEmc=mL2gammaBEmc=0;
00040 mL2upsilon2006=0;
00041 }
00042
00043
00044 StL2_2006EmulatorMaker::~StL2_2006EmulatorMaker(){
00045 }
00046
00047
00048
00049
00050 Int_t
00051 StL2_2006EmulatorMaker::InitRun(int runNo){
00052
00053
00054
00055 initRun1();
00056 LOG_INFO << Form("::setupL2Algos2006(), dbDate=%d ", mYearMonthDay)<<endm;
00057
00058
00059 assert(mYearMonthDay>20060000);
00060 assert(mYearMonthDay<20060700);
00061
00062 mL2algoN=5;
00063 mL2algo =new L2VirtualAlgo *[mL2algoN];
00064 memset(mL2algo,0,mL2algoN*sizeof(void*));
00065
00066
00067
00068 mL2algo[0]=mL2pedAlgo=new L2pedAlgo("ped-algo",mL2EmcDb,mL2EmcDb->logPath,L2RESULTS_OFFSET_EMC_PED);
00069
00070
00071
00072 assert( mYearMonthDay>20060316);
00073 assert( mYearMonthDay<20060620);
00074
00075 mL2algo[1]=mL2jetAlgo2006=new L2jetAlgo2006("jet06-algo",mL2EmcDb,mL2EmcDb->logPath,L2RESULTS_OFFSET_DIJET);
00076
00077
00078 assert( mYearMonthDay >= 20060406 );
00079 assert( mYearMonthDay <= 20060607 );
00080
00081 mL2algo[2]=mL2gammaEEmc=new L2gammaAlgo("etow_gamma",mL2EmcDb,mL2EmcDb->logPath,L2RESULTS_OFFSET_PIG+2);
00082 mL2algo[3]=mL2gammaBEmc=new L2gammaAlgo("btow_gamma",mL2EmcDb,mL2EmcDb->logPath,L2RESULTS_OFFSET_PIG);
00083
00084
00085 assert( mYearMonthDay >= 20060406 );
00086 assert( mYearMonthDay <= 20060607 );
00087
00088 mL2algo[4]=mL2upsilon2006=new L2upsilon2006("upsilon", mL2EmcDb, mL2EmcDb->logPath,L2RESULTS_OFFSET_UPS);
00089 TString fullPath=Form("%sL2/%d/algos/btowXYZ.dat", mSetupPath.Data(), mYear);
00090 mL2upsilon2006->readGeomXYZ(fullPath.Data());
00091
00092
00093
00094
00095 initRun2(runNo);
00096
00097 LOG_INFO << "::InitRun() done, run=" <<runNo<<" isMC="<<mMCflag<<endm;
00098 return kStOK;
00099 }
00100
00101
00102
00103 Int_t
00104 StL2_2006EmulatorMaker::Init() {
00105 init();
00106 LOG_INFO <<Form("Init()")<<endm;
00107
00108
00109 return StMaker::Init();
00110 }
00111
00112
00113 void
00114 StL2_2006EmulatorMaker::Clear(const Option_t*){
00115 clear();
00116
00117 }
00118
00119
00120
00121 Int_t
00122 StL2_2006EmulatorMaker::Make(){
00123 if( mMCflag==0) getTriggerData();
00124
00125 make();
00126
00127
00128 #if 0
00129
00130 int l2jetOff=-1;
00131 if(mYear==2006) l2jetOff=L2RESULTS_OFFSET_DIJET;
00132
00133 const unsigned int *l2res=( (TrgDataType*)mTrigData)->TrgSum.L2Result;
00134 printf(" L2-jet off-line results below:\n");
00135
00136 L2jetResults2006 *out1= ( L2jetResults2006 *) &l2res[l2jetOff];
00137
00138 L2jetResults2006_print(out1);
00139 unsigned char cSum=L2jetResults2006_doCheckSum(out1);
00140 assert(cSum==0);
00141
00142 #endif // end of debuging
00143
00144 return kStOK;
00145 }
00146
00147
00148 Int_t
00149 StL2_2006EmulatorMaker::Finish(){
00150 finish();
00151 return kStOK;
00152 }
00153
00154
00155
00156
00157
00158
00159 bool
00160 StL2_2006EmulatorMaker::getTriggerData(){
00161 const StTriggerId *L1=0;
00162
00163
00164 int runId=0;
00165 int l2jetOff=0;
00166 if(mYear==2006) l2jetOff=L2RESULTS_OFFSET_DIJET;
00167
00168 const unsigned int *l2res=0;
00169
00170 if(mUseMuDst) {
00171 StMuDstMaker *muMk = (StMuDstMaker*)StMaker::GetChain()-> GetMaker("MuDst");
00172 assert(muMk);
00173
00174 StMuEvent *muEve = muMk -> muDst() -> event();
00175 assert(muEve);
00176 StMuTriggerIdCollection ticB = muEve -> triggerIdCollection();
00177 L1 = &ticB.nominal();
00178 StEventInfo &info=muEve->eventInfo();
00179 runId=info.runId();
00180
00181 #if 0 // read ezTree
00182 printf("AccessL2Decision() from ezTree:\n");
00183 EztTrigBlob *eTrig=muMk->muDst()->eztTrig();
00184 assert(eTrig);
00185 const TrgDataType2005 * trgDB=(TrgDataType2005 *)eTrig->trgd->GetArray();
00186
00187 StTriggerData2005 trgAkio5(trgDB , runId);
00188 l2jetOff=trgAkio5.L2ResultsOffset(idJ);
00189 l2res=trgDB->TrgSum.L2Result;
00190 #endif
00191
00192
00193 if(mMCflag==0) {
00194 TArrayI& l2Array = muMk->muDst()->event()->L2Result();
00195 LOG_DEBUG <<Form("AccessL2Decision() from regular muDst: L2Ar-size=%d",l2Array.GetSize())<<endm;
00196 l2res=(unsigned int *)l2Array.GetArray();
00197 }
00198
00199 } else {
00200 StEvent *mEvent = (StEvent *)StMaker::GetChain()-> GetInputDS("StEvent");
00201 assert(mEvent);
00202 StTriggerIdCollection *ticA=mEvent->triggerIdCollection();
00203 assert(ticA); L1=ticA->nominal();
00204 StEventInfo *info=mEvent->info();
00205 runId=info->runId();
00206
00207
00208 assert(1==2);
00209 }
00210
00211 #if 0
00212 if( !(L1->isTrigger(127622) || L1->isTrigger(127652)) ) {
00213 printf("Discard none-L2jet triggered events\n");
00214 return false;
00215 }
00216 #endif
00217
00218 #if 0 // just debugging & cross check
00219 if(mMCflag==0) {
00220 printf(" L2-jet online results below:\n");
00221
00222 L2jetResults2006 *out1= ( L2jetResults2006 *) &l2res[l2jetOff];
00223
00224 L2jetResults2006_print(out1);
00225 unsigned char cSum=L2jetResults2006_doCheckSum(out1);
00226 assert(cSum==0);
00227 }
00228 #endif // end of debugging
00229
00230 #if 0
00231 vector<unsigned int> trgL=L1->triggerIds();
00232 printf("trigL len=%d totEve=%d\n",trgL.size(),mTotInpEve);
00233 uint ii;
00234 for(ii=0;ii<trgL.size();ii++){
00235 printf("ii=%d trigID=%d\n",ii,trgL[ii]);
00236 }
00237 #endif
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250 return true;
00251
00252 }
00253
00254
00255
00256
00257
00258
00259 #if 0
00260
00261 void
00262 StL2_2006EmulatorMaker::initHistoA(TString core) {
00263 LOG_INFO <<Form("initHistoA(),")<<endm;
00264
00265 assert(mHList);
00266 memset(hA,0,sizeof(hA));
00267
00268 hA[0]=0;
00269 hA[1]=new TH1F(core+"trgID", "event counter for Jan",10,1,11);
00270
00271
00272 int i;
00273 for(i=0;i<mxAH;i++) {
00274 if( hA[i]==0) continue;
00275 mHList->Add( hA[i]);
00276 }
00277 }
00278 #endif