00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <TH2.h>
00011 #include <StMessMgr.h>
00012
00013 #include "StEemcTriggerSimu.h"
00014 #include "EemcHttpInfo.h"
00015
00016 #include "StEvent/StEvent.h"
00017 #include "StEvent/StEventTypes.h"
00018 #include "StEvent/StEmcTriggerDetector.h"
00019 #include "StEvent/StL0Trigger.h"
00020
00021
00022
00023 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
00024 #include "StMuDSTMaker/COMMON/StMuDst.h"
00025 #include "StMuDSTMaker/COMMON/StMuEvent.h"
00026 #include "StMuDSTMaker/COMMON/StMuEmcCollection.h"
00027
00028 #include "St_db_Maker/St_db_Maker.h"
00029
00030
00031 #include <StEEmcUtil/database/StEEmcDb.h>
00032 #include <StEEmcUtil/database/EEmcDbCrate.h>
00033 #include <StEEmcUtil/database/EEmcDbItem.h>
00034 #include <StEEmcUtil/database/cstructs/eemcConstDB.hh>
00035
00036
00037 #include "EEfeeTPTree.h"
00038 #include "EEfeeTP.h"
00039 #include "EEdsm0Tree.h"
00040 #include "EEdsm1Tree.h"
00041 #include "EMCdsm2Tree.h"
00042 #include "EEdsm3.h"
00043 #include "EemcTrigUtil.h"
00044
00045
00046
00047 #include "StTriggerUtilities/StDSMUtilities/StDSM2009Utilities.hh"
00048
00049
00050
00051 ClassImp(StEemcTriggerSimu);
00052
00053
00054
00055
00056 StEemcTriggerSimu::StEemcTriggerSimu() {
00057
00058 mPedMode = kOffline;
00059 nInpEve=0;
00060 mHList=0;
00061 mDbE=0;
00062 mBemcEsum5bit=0;
00063 mExternDsmSetup=0;
00064 mSetupPath="wrong1";
00065
00066 feeTPTreeADC=new EEfeeTPTree("ADC",mxChan);
00067 dsm0TreeADC =new EEdsm0Tree("ADC");
00068 dsm1TreeADC =new EEdsm1Tree("ADC");
00069 dsm2TreeADC =new EMCdsm2Tree("ADC");
00070
00071
00072 dsm0TreeTRG =new EEdsm0Tree("TRG");
00073 dsm1TreeTRG =new EEdsm1Tree("TRG");
00074 dsm2TreeTRG =new EMCdsm2Tree("TRG");
00075 dsm3TRG =new EEdsm3();
00076
00077
00078 mE001 = new DSMLayer_E001_2009;
00079 mE101 = new DSMLayer_E101_2009;
00080
00081 LOG_INFO <<"Eemc::constructor"<<endm;
00082 }
00083
00084
00085
00086
00087 StEemcTriggerSimu::~StEemcTriggerSimu()
00088 {
00089 delete mE001; mE001 = 0;
00090 delete mE101; mE101 = 0;
00091 }
00092
00093
00094
00095 void
00096 StEemcTriggerSimu::Clear(){
00097
00098
00099 memset(rawAdc,0,sizeof(rawAdc));
00100 feeTPTreeADC->clear();
00101 dsm0TreeADC->clear();
00102 dsm1TreeADC->clear();
00103 dsm2TreeADC->clear();
00104
00105
00106 dsm0TreeTRG->clear();
00107 dsm1TreeTRG->clear();
00108 dsm2TreeTRG->clear();
00109 dsm3TRG->clear();
00110
00111 mTriggerIds.clear();
00112 }
00113
00114
00115
00116
00117 void
00118 StEemcTriggerSimu::Init(){
00119
00120 mYear=-888;
00121
00122 mDbE = (StEEmcDb*)StMaker::GetChain()->GetDataSet("StEEmcDb");
00123 assert(mDbE);
00124
00125 LOG_INFO <<Form("Eemc::Init() MC_flag=%d, config: flag=%d, path=%s=",mMCflag, mConfig,mSetupPath.Data())<<endm;
00126 assert(mConfig>=kOnlyAdc);
00127 assert(mConfig<=kAdcCompareTrig);
00128 }
00129
00130
00131
00132
00133 void
00134 StEemcTriggerSimu::addTriggerList(vector<int>& trgList){
00135 if(mYear==2006) {
00136
00137 if(dsm2TreeADC->getOutEndcapHTTP1bit()) {
00138
00139 trgList.push_back(117580);
00140 trgList.push_back(127580);
00141 trgList.push_back(137581);
00142 trgList.push_back(117641);
00143 trgList.push_back(127641);
00144 trgList.push_back(137641);
00145 trgList.push_back(117831);
00146 trgList.push_back(127831);
00147 trgList.push_back(137831);
00148 trgList.push_back(137832);
00149
00150 trgList.push_back(147580);
00151 trgList.push_back(147641);
00152 }
00153 if(dsm2TreeADC->getOutEndcapJP2bit()>=1) trgList.push_back(127551);
00154 if(dsm2TreeADC->getOutEndcapJP2bit()>=2) trgList.push_back(127271);
00155 if(dsm2TreeADC->getOutEndcapJP2bit()>=1 && dsm2TreeADC->getOutEtot1bit()) trgList.push_back(127652);
00156 }
00157
00158 else if( mYear == 2009 ){
00159 ;
00160 }
00161
00162
00163 }
00164
00165
00166
00167
00168 StTriggerSimuDecision
00169 StEemcTriggerSimu::triggerDecision(int trigId) {
00170 if (find(mTriggerIds.begin(),mTriggerIds.end(),trigId) == mTriggerIds.end()) return kDoNotCare;
00171 return kYes;
00172 }
00173
00174
00175
00176
00177 void
00178 StEemcTriggerSimu::InitRun(int runnumber){
00179
00180 memset(ped,0,sizeof(ped));
00181 memset(feePed,0,sizeof(feePed));
00182 memset(feeMask,0xff,sizeof(feeMask));
00183 getEemcFeeMask();
00184
00185 const TDatime& dbtime = StMaker::GetChain()->GetDBTime();
00186 mYear = dbtime.GetYear();
00187 int yyyymmdd = dbtime.GetDate();
00188 int hhmmss = dbtime.GetTime();
00189
00190 LOG_INFO<<Form("Eemc::InitRun() yyyymmdd=%d hhmmss=%06d\n", yyyymmdd, hhmmss )<<endm;
00191
00192 fill(highTowerMask,highTowerMask+90,1);
00193 fill(patchSumMask,patchSumMask+90,1);
00194
00195 EemcTrigUtil::getFeeOutMask(dbtime,highTowerMask,patchSumMask);
00196 EemcTrigUtil::getFeeBoardMask(dbtime,highTowerMask);
00197
00198 switch (mPedMode) {
00199 case kOnline:
00200 LOG_INFO << "Using EEMC ONLINE pedestals" << endm;
00201 EemcTrigUtil::getFeePed4(dbtime,mxChan,feePed);
00202 break;
00203
00204 case kOffline:
00205 LOG_INFO << "Using EEMC OFFLINE pedestals" << endm;
00206 assert(mDbE);
00207 for (int crate = 1; crate <= mxCr; ++crate) {
00208 for (int chan = 0; chan < mxChan; ++chan) {
00209 const EEmcDbItem* x = mDbE->getByCrate(crate,chan);
00210 if (!x) continue;
00211 int rdo = getRdo(crate,chan);
00212 ped[rdo] = x->ped;
00213 feePed[rdo] = computePed4(x->ped);
00214 }
00215 }
00216 break;
00217
00218 case kLocal:
00219 LOG_INFO << "Using EEMC LOCAL pedestals from file " << mPedFile << endm;
00220 ifstream pedfile(mPedFile);
00221 assert(pedfile);
00222 int crate, chan, iped;
00223 float fped;
00224 while (pedfile >> crate >> chan >> fped >> iped) {
00225 int rdo = getRdo(crate,chan);
00226 ped[rdo] = fped;
00227 feePed[rdo] = iped;
00228 }
00229 pedfile.close();
00230 break;
00231 }
00232
00233 LOG_INFO << "rdo\tcr\tchan\tsta\tped\tped4" << endm;
00234
00235 for (int crate = 1; crate <= mxCr; ++crate) {
00236 for (int chan = 0; chan < 120; ++chan) {
00237 int rdo = getRdo(crate,chan);
00238 LOG_INFO << rdo << '\t' << crate << '\t' << chan << '\t' << feeMask[rdo] << '\t' << ped[rdo] << '\t' << feePed[rdo] << endm;
00239 }
00240 }
00241
00242 if( mYear == 2006 ){
00243 DsmThreshold thresholds;
00244 if(!mExternDsmSetup) {
00245 EemcTrigUtil::getDsmThresholds( yyyymmdd, hhmmss, thresholds );
00246 } else {
00247 LOG_INFO<<Form("Eemc::InitRun() use externalDSM setup")<<endm;
00248 int i;
00249 for(i=0;i<nThr;i++) thresholds.HT[i]=mExternDsmSetup[0+i];
00250 for(i=0;i<nThr;i++) thresholds.TP[i]=mExternDsmSetup[3+i];
00251 for(i=0;i<nThr;i++) thresholds.JP[i]=mExternDsmSetup[6+i];
00252 thresholds.TPthrSelc =mExternDsmSetup[9];
00253 thresholds.HTTPselect =mExternDsmSetup[10];
00254 thresholds.JPSIthrSelc =mExternDsmSetup[11];
00255 thresholds.BarreSide =mExternDsmSetup[12];
00256 thresholds.BEsumthr =mExternDsmSetup[13];
00257 thresholds.EEsumthr =mExternDsmSetup[14];
00258 thresholds.EtotThr =mExternDsmSetup[15];
00259 }
00260
00261 LOG_INFO<<Form("Eemc::DSM setup HTthr: %d, %d, %d",thresholds.HT[0],thresholds.HT[1],thresholds.HT[2])<<endm;
00262 LOG_INFO<<Form("Eemc::DSM setup TPthr: %d, %d, %d",thresholds.TP[0],thresholds.TP[1],thresholds.TP[2])<<endm;
00263 LOG_INFO<<Form("Eemc::DSM setup JPthr: %d, %d, %d",thresholds.JP[0],thresholds.JP[1],thresholds.JP[2])<<endm;
00264 LOG_INFO<<Form("Eemc::DSM setup BEsumthr=%d, EEsumthr=%d, EtotThr=%d",thresholds.BEsumthr,thresholds.EEsumthr,thresholds.EtotThr)<<endm;
00265 LOG_INFO<<Form("Eemc::DSM setup TPthrSelc=%d, HTTPthrSelc=%d, JPSIthrSelc=%d, BarreSide=%d",thresholds.TPthrSelc,thresholds.HTTPselect,thresholds.JPSIthrSelc,thresholds.BarreSide)<<endm;
00266
00267 dsm0TreeADC->setYear(mYear,thresholds.HT,thresholds.TP);
00268 dsm0TreeTRG->setYear(mYear,thresholds.HT,thresholds.TP);
00269
00270 dsm1TreeADC->setYear(mYear,thresholds.JP,thresholds.TPthrSelc,thresholds.HTTPselect);
00271 dsm1TreeTRG->setYear(mYear,thresholds.JP,thresholds.TPthrSelc,thresholds.HTTPselect);
00272
00273 dsm2TreeTRG->setYear(mYear,thresholds.BEsumthr,thresholds.EEsumthr,thresholds.JPSIthrSelc,thresholds.BarreSide,thresholds.EtotThr);
00274 dsm2TreeADC->setYear(mYear,thresholds.BEsumthr,thresholds.EEsumthr,thresholds.JPSIthrSelc,thresholds.BarreSide,thresholds.EtotThr);
00275
00276 dsm3TRG->setYear(mYear);
00277
00278 initHisto();
00279 }
00280
00281 else if (mYear >= 2009) {
00282
00283 #if 0
00284 DsmThreshold thresholds;
00285 EemcTrigUtil::getDsmThresholds( yyyymmdd, hhmmss, thresholds );
00286
00287 LOG_INFO<<Form("Eemc::DSM setup HTthr: %d, %d, %d",thresholds.HT[0],thresholds.HT[1])<<endm;
00288 LOG_INFO<<Form("Eemc::DSM setup JPthr: %d, %d, %d",thresholds.JP[0],thresholds.JP[1],thresholds.JP[2])<<endm;
00289
00290 for (int i = 0; i < 2; ++i) mE001->setRegister(i,thresholds.HT[i]);
00291 for (int i = 0; i < 3; ++i) mE101->setRegister(i,thresholds.JP[i]);
00292 #endif
00293
00294 }
00295
00296 }
00297
00298
00299
00300
00301 void
00302 StEemcTriggerSimu::Make(){
00303 nInpEve++;
00304 mDumpEve=eveId%1==0;
00305
00306 #if 0
00307 assert(mMCflag==0);
00308 StEventInfo &info=StMuDst::event()->eventInfo();
00309
00310 eveId=info.id();
00311 StMuTriggerIdCollection *tic=&StMuDst::event()->triggerIdCollection();
00312 std::vector<unsigned int> trgL=(tic->nominal()).triggerIds();
00313
00314 uint ii;
00315 for(ii=0;ii<trgL.size();ii++){
00316 TString cID=Form("%d",trgL[ii]);
00317 hA[1]->Fill(cID.Data(),1.);
00318 }
00319 #endif
00320
00321
00322 getEemcAdc();
00323 feeTPTreeADC->compute(rawAdc,feePed,feeMask,highTowerMask,patchSumMask);
00324
00325
00326 LOG_DEBUG << "EEMC trigger patch format is HT/TPsum" << endm;
00327 for (int dsm = 0; dsm < 9; ++dsm) {
00328 TString line = Form("TP%d-%d: ",dsm*10,dsm*10+9);
00329 for (int ch = 0; ch < 10; ++ch) {
00330 int triggerPatch = dsm*10+ch;
00331 line += Form("%d/%d ",feeTPTreeADC->TP(triggerPatch)->getOutHT(),feeTPTreeADC->TP(triggerPatch)->getOutTPsum());
00332 }
00333 LOG_DEBUG << line << endm;
00334 }
00335
00336 if( mYear == 2006 ){
00337
00338
00339 int i;
00340
00341
00342
00343 for(i=0;i<EEfeeTPTree::mxTP;i++) {
00344 dsm0TreeADC->setInp12bit(i,feeTPTreeADC->TP(i)->getOut12bit());
00345 }
00346 dsm0TreeADC->compute();
00347
00348
00349 int j;
00350 for(j=0;j<EEdsm0Tree::Nee0out;j++) {
00351 int k = EEdsm1Tree::Nee1BoardInpCha;
00352 int brd = j/k+1;
00353 int cha = j%k;
00354 dsm1TreeADC->setInp16bit(brd, cha, dsm0TreeADC->getOut16bit(j));
00355 }
00356 dsm1TreeADC->compute();
00357
00358
00359 dsm2TreeADC->setInput16bit(0, 0, dsm1TreeADC->getOut16bit(0));
00360 dsm2TreeADC->setInput16bit(0, 1, dsm1TreeADC->getOut16bit(1));
00361
00362 #if 0 // waits for Renee's Etot from DSM
00363
00364 static const int kA[6]={3,4,5,0,1,2};
00365 for(j=0;j<6;j++) {
00366 ushort fakeInput=mBemcEsum5bit[kA[j]];
00367
00368 int ibr=j/2;
00369 int ich=j%2;
00370 dsm2TreeADC->setInput16bit(ibr+1, ich, fakeInput);
00371 }
00372 #endif
00373 dsm2TreeADC->compute();
00374
00375
00376
00377
00378
00379 if(mMCflag==0 && mConfig>=kAdcAndTrig){
00380
00381
00382 getDsm0123inputs();
00383 dsm0TreeTRG->compute();
00384 dsm1TreeTRG->compute();
00385 dsm2TreeTRG->compute();
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395 if(mConfig>= kAdcCompareTrig) {
00396 compareADCfee_TRG0();
00397 compareADC0_TRG1();
00398 compareADC1_TRG2();
00399 compareADC2_TRG3();
00400
00401 compareTRG0_TRG1();
00402 compareTRG1_TRG2();
00403 compareTRG2_TRG3();
00404 }
00405 }
00406
00407 DSM2EsumSpectra();
00408
00409 addTriggerList(mTriggerIds);
00410
00411
00412
00413
00414 }
00415
00416 else if( mYear >= 2009 ){
00417 get2009_DSMLayer0();
00418 get2009_DSMLayer1();
00419 }
00420
00421
00422 if (mMCflag) fillStEmcTriggerDetector();
00423 }
00424
00425
00426
00427
00428
00429
00430 bool StEemcTriggerSimu::isCorrupted() const {
00431 for (int rdo = 0; rdo < mxCr*mxChan; ++rdo)
00432 if (rawAdc[rdo]) return false;
00433 return true;
00434 }
00435
00436
00437
00438
00439 bool
00440 StEemcTriggerSimu::getHttpInfo(int tpId, EemcHttpInfo &httpInfo){
00441 httpInfo.clear();
00442 int ith=mHTTPthrSelc-1;
00443 assert(ith>=0 && ith<nThr);
00444 if(tpId<0 or tpId>=EEfeeTPTree::mxTP) return false;
00445 EEfeeTP *TP=feeTPTreeADC->TP(tpId); assert(TP);
00446 int TPsum6b=TP->getOutTPsum();
00447 if(TPsum6b<mTPthr[ith]) return false;
00448 int HT6bit=TP->getOutHT();
00449 if(HT6bit<mHTthr[ith]) return false;
00450 httpInfo.tpId=tpId;
00451 httpInfo.tpSumDsmAdc=TPsum6b;
00452 httpInfo.htwCh=TP->getTranHTchId();
00453 httpInfo.htwCr=TP->getCrateID();
00454 httpInfo.htwDsmAdc=HT6bit;
00455 return true;
00456
00457 }
00458
00459
00460
00461
00462 void
00463 StEemcTriggerSimu::getEemcAdc(){
00464
00465 if (mSource == "MuDst") {
00466 if (StMuEmcCollection* emc = StMuDst::muEmcCollection()) {
00467
00468
00469
00470 int i;
00471 for (i=0; i< emc->getNEndcapTowerADC(); i++) {
00472 int sec,eta,sub,AdcRead;
00473 emc->getEndcapTowerADC(i,AdcRead,sec,sub,eta);
00474
00475
00476 const EEmcDbItem *x=mDbE->getTile(sec,'A'+sub-1,eta,'T');
00477 assert(x);
00478
00479
00480 assert(x->crate >= 1 && x->crate <= 6);
00481 assert(x->chan >= 0 && x->chan < 120);
00482 int rdo = getRdo(x->crate,x->chan);
00483 rawAdc[rdo] = AdcRead;
00484
00485
00486
00487
00488
00489 }
00490 }
00491 }
00492 else if (mSource == "StEvent") {
00493 if (StEvent* event = (StEvent*)StMaker::GetChain()->GetDataSet("StEvent")) {
00494 if (StEmcCollection* emc = event->emcCollection()) {
00495 if (StEmcDetector* det = emc->detector(kEndcapEmcTowerId)) {
00496 int ntowers = 0;
00497 for (unsigned int sec = 1; sec <= det->numberOfModules(); ++sec) {
00498 const StSPtrVecEmcRawHit& hits = det->module(sec)->hits();
00499 ntowers += hits.size();
00500
00501 for (size_t i = 0; i < hits.size(); ++i) {
00502 const StEmcRawHit* hit = hits[i];
00503 char sub = hit->sub()-1+'A';
00504 int eta = hit->eta();
00505 int adc = hit->adc();
00506
00507 const EEmcDbItem* x = mDbE->getTile(sec,sub,eta,'T');
00508 if (!x) continue;
00509 int rdo = getRdo(x->crate,x->chan);
00510 rawAdc[rdo] = adc;
00511
00512 }
00513 }
00514 assert(ntowers == 720);
00515 }
00516 }
00517 }
00518 }
00519 else {
00520 LOG_ERROR << "StEemcTriggerSimu - Unknown source \"" << mSource << "\"" << endm;
00521 }
00522 }
00523
00524
00525
00526
00527 int StEemcTriggerSimu::computePed4(float ped)
00528 {
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565 ped += 0.5;
00566 if (ped > 24)
00567 ped = (22-int(ped))/4.0;
00568 else
00569 ped = (25-int(ped))/4.0;
00570 return int(ped);
00571 }
00572
00573
00574
00575
00576 void
00577 StEemcTriggerSimu::getDsm0123inputs(){
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 StEmcTriggerDetector &emcTrgDet=StMuDst::event()->emcTriggerDetector();
00592
00593 int i;
00594 for(i=0;i<EEfeeTPTree::mxTP;i++) {
00595 int HT=emcTrgDet.highTowerEndcap(i) &0x3f ;
00596 int TP=emcTrgDet.patchEndcap(i) &0x3f;
00597 dsm0TreeTRG->setInp12bit(i,((TP<<6)+HT));
00598 }
00599
00600
00601 #if 0
00602 int mNEemcLayer1 = 16, mNEmcLayer2 = 8;
00603
00604 for(i=0;i<mNEemcLayer1;i++) {
00605 unsigned short x=emcTrgDet.eemcLayer1(i);
00606 printf("DSM L1: i=%d val=%d \n",i,x);
00607 }
00608 for(i=0;i<mNEmcLayer2;i++) {
00609 unsigned short x=emcTrgDet.emcLayer2(i);
00610 printf("DSM L2: i=%d val=%d \n",i,x);
00611 }
00612 #endif
00613
00614
00615 for(i=0;i<dsm1TreeTRG->getNboards();i++) {
00616 dsm1TreeTRG->setInp16bit(i+1,0,emcTrgDet.eemcLayer1(3+i*8));
00617 dsm1TreeTRG->setInp16bit(i+1,1,emcTrgDet.eemcLayer1(2+i*8));
00618 dsm1TreeTRG->setInp16bit(i+1,2,emcTrgDet.eemcLayer1(1+i*8));
00619 dsm1TreeTRG->setInp16bit(i+1,3,emcTrgDet.eemcLayer1(0+i*8));
00620 dsm1TreeTRG->setInp16bit(i+1,4,emcTrgDet.eemcLayer1(7+i*8));
00621 dsm1TreeTRG->setInp16bit(i+1,5,emcTrgDet.eemcLayer1(6+i*8));
00622 }
00623
00624
00625 dsm2TreeTRG->setInput16bit(0,0,emcTrgDet.emcLayer2(5));
00626 dsm2TreeTRG->setInput16bit(0,1,emcTrgDet.emcLayer2(4));
00627
00628 dsm2TreeTRG->setInput16bit(1,0,emcTrgDet.emcLayer2(3));
00629 dsm2TreeTRG->setInput16bit(1,1,emcTrgDet.emcLayer2(2));
00630 dsm2TreeTRG->setInput16bit(2,0,emcTrgDet.emcLayer2(1));
00631 dsm2TreeTRG->setInput16bit(2,1,emcTrgDet.emcLayer2(0));
00632 dsm2TreeTRG->setInput16bit(3,0,emcTrgDet.emcLayer2(7));
00633 dsm2TreeTRG->setInput16bit(3,1,emcTrgDet.emcLayer2(6));
00634
00635
00636 StL0Trigger &L0trg=StMuDst::event()->l0Trigger();
00637 int L0Num;
00638 L0Num=L0trg.lastDsmArraySize();
00639 ushort L0word=L0trg.lastDsmArray(0);
00640 dsm3TRG->setWord(0, L0word);
00641
00642
00643
00644 #if 0
00645 printf("Dump of real DSM0 inputs, HT:");
00646 for(i=0;i<mxTP;i++) {
00647 if(i%10==0)
00648 printf("\nTPch=%2d ",i);
00649 else if(i%5==0)
00650 printf(" ");
00651 else
00652 printf(" ");
00653 printf("%3d ",dsm0inHT[i]);
00654 } printf("\n");
00655 printf("Dump of real DSM0 inputs, TPsum:");
00656 for(i=0;i<mxTP;i++) {
00657 if(i%10==0)
00658 printf("\nTPch=%2d ",i);
00659 else if(i%5==0)
00660 printf(" ");
00661 else
00662 printf(" ");
00663 printf("%3d ",dsm0inTPsum[i]);
00664 }
00665 printf("\n");
00666 #endif
00667 }
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706 void
00707 StEemcTriggerSimu::getEemcFeeMask() {
00708 assert(mDbE);
00709 for (int icr = 0; icr < 6; ++icr) {
00710 for(int ich = 0; ich < mxChan; ++ich) {
00711 const EEmcDbItem *x = mDbE->getByCrate(icr+1,ich);
00712 if (!x) continue;
00713 bool killIt = (x->stat & EEMCSTAT_HOTHT) || (x->fail & EEMCFAIL_GARBG);
00714 if (killIt) x->print();
00715 int rdo = getRdo(x->crate,ich);
00716 feeMask[rdo] = killIt;
00717 LOG_DEBUG << Form("crate=%d chan=%d rdo=%d name=%s tube=%s sec=%d sub=%c eta=%d stat=0x%04x fail=0x%04x killIt=%d ped=%f",
00718 x->crate,x->chan,rdo,x->name,x->tube,x->sec,x->sub,x->eta,x->stat,x->fail,killIt,x->ped) << endm;
00719 }
00720 }
00721 }
00722
00723
00724
00725
00726
00727
00728 void
00729 StEemcTriggerSimu::get2009_DSMLayer0(){
00730 for( size_t dsm = 0; dsm < mE001->size(); dsm++ ){
00731 TString line = (*mE001)[dsm].name + ": ";
00732 for( int ch = 0; ch < 10; ch++ ){
00733 Int_t tpid = dsm * 10 + ch;
00734 (*mE001)[dsm].channels[ch] = feeTPTreeADC->TP(tpid)->getOut12bit();
00735 line += Form("%04x ",(*mE001)[dsm].channels[ch]);
00736 }
00737 LOG_DEBUG << line << endm;
00738 }
00739
00740 mE001->run();
00741 }
00742
00743 void
00744 StEemcTriggerSimu::get2009_DSMLayer1(){
00745 mE001->write(*mE101);
00746
00747 for (size_t dsm = 0; dsm < mE101->size(); ++dsm) {
00748 TString line = (*mE101)[dsm].name + ": ";
00749 for (int ch = 0; ch < 8; ++ch) line += Form("%04x ",(*mE101)[dsm].channels[ch]);
00750 LOG_DEBUG << line << endm;
00751 }
00752
00753 mE101->run();
00754 }
00755
00756
00757
00758
00759
00760
00761 int StEemcTriggerSimu::endcapJetPatchTh(int i) const { return mE101->getRegister(i); }
00762 int StEemcTriggerSimu::endcapHighTowerTh(int i) const { return mE001->getRegister(i); }
00763
00764 int StEemcTriggerSimu::endcapJetPatchAdc(int jp) const { return (*mE101)[1-jp/3].info[jp%3]; }
00765
00766 int StEemcTriggerSimu::getOutHT(int tp) const { return feeTPTreeADC->TP(tp)->getOutHT(); }
00767 int StEemcTriggerSimu::getOutTPsum(int tp) const { return feeTPTreeADC->TP(tp)->getOutTPsum(); }
00768
00769
00770
00771
00772 void StEemcTriggerSimu::fillStEmcTriggerDetector()
00773 {
00774 if (StMuDst::event()) {
00775 StEmcTriggerDetector& emc = StMuDst::event()->emcTriggerDetector();
00776 for (int triggerPatch = 0; triggerPatch < 90; ++triggerPatch) {
00777 emc.setHighTowerEndcap(triggerPatch,feeTPTreeADC->TP(triggerPatch)->getOutHT());
00778 emc.setPatchEndcap(triggerPatch,feeTPTreeADC->TP(triggerPatch)->getOutTPsum());
00779 }
00780 }
00781 }
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927