00001
00002
00003
00004
00005
00006
00007 #include <StMuDSTMaker/COMMON/StMuDstMaker.h>
00008 #include <StMuDSTMaker/COMMON/StMuDst.h>
00009 #include <StMuDSTMaker/COMMON/StMuTriggerIdCollection.h>
00010 #include <StMuDSTMaker/COMMON/StMuEvent.h>
00011 #include <StMuDSTMaker/COMMON/StMuTrack.h>
00012 #include <StMuDSTMaker/COMMON/StMuPrimaryVertex.h>
00013
00014
00015
00016
00017 #include "StEEmcUtil/database/StEEmcDb.h"
00018 #include "StEEmcUtil/database/EEmcDbItem.h"
00019
00020 #include "St2011WMaker.h"
00021
00022
00023
00024 int
00025 St2011WMaker::accessEndcapTrig(){
00026 if (isMC){
00027 if(wEve->etow.maxAdc<10./60.*4096) return -1;
00028 hE[0]->Fill("L2ewET",1.);
00029 wEve->l2EbitET=true;
00030 return 0;
00031 }
00032
00033 StMuEvent* muEve = mMuDstMaker->muDst()->event();
00034 StMuTriggerIdCollection *tic=&(muEve->triggerIdCollection());
00035 assert(tic);
00036 const StTriggerId &l1=tic->l1();
00037 vector<unsigned int> idL=l1.triggerIds();
00038
00039
00040 for(unsigned int i=0;i<idL.size(); i++){
00041 char txt[100];
00042 sprintf(txt,"%d",idL[i]);
00043 hE[1]->Fill(txt,1.);
00044 }
00045
00046
00047 if(!tic->nominal().isTrigger(parE_l2ewTrgID)) return -2;
00048 hE[0]->Fill("L2ewId",1.);
00049
00050
00051 struct L2weResult2011 {
00052 unsigned char trigger;
00053 unsigned char highestEt;
00054 unsigned short highestRDO;
00055 };
00056
00057 TArrayI& l2Array = muEve->L2Result();
00058 LOG_DEBUG <<Form("AccessL2Decision() from regular muDst: L2Ar-size=%d",l2Array.GetSize())<<endm;
00059 unsigned int *l2res=(unsigned int *)l2Array.GetArray();
00060 const int EEMCW_off=35;
00061
00062 L2weResult2011 *l2algo= ( L2weResult2011 *) &l2res[EEMCW_off];
00063 wEve->l2EbitET=(l2algo->trigger&2)>0;
00064 wEve->l2EbitRnd=(l2algo->trigger&1)>0;
00065
00066 #if 0
00067 if(l2algo->trigger==0) return -3;
00068 printf(" L2-jet online results below:\n");
00069 for (int k=0;k<64;k++)
00070 if(l2res[k]) printf("k=%2d val=0x%04x\n",k,l2res[k]);
00071 printf("L2WE_Result 4-bytes: trg bitET=%d, bitRnd=%d, highets: ET/GeV=%.2f, RDO=%d hex=0x%08x\n",wEve->l2EbitET,wEve->l2EbitRnd,l2algo->highestEt/256.*60,l2algo->highestRDO,l2res[EEMCW_off]);
00072
00073 #endif
00074
00075
00076
00077 if (mRunNo<11000111) {
00078 wEve->l2EbitET=1;
00079 wEve->l2EbitRnd=1;
00080 }
00081
00082 if( (wEve->l2EbitRnd || wEve->l2EbitET)==0) return -3;
00083 hE[0]->Fill("L2ewBits",1.);
00084
00085 if(wEve->l2EbitRnd) {
00086 hE[0]->Fill("L2ewRnd",1.);
00087 for (int m=0;m<90;m++){
00088 int val=muEve->emcTriggerDetector().highTowerEndcap(m);
00089 hE[7]->Fill(val);
00090 }
00091 hE[61]->Fill(wEve->bx7);
00092 }
00093
00094 if(!wEve->l2EbitET) return -3;
00095 if(wEve->l2EbitET) hE[0]->Fill("L2ewET",1.);
00096
00097
00098 hE[2]->Fill(wEve->bx48);
00099 hE[3]->Fill(wEve->bx7);
00100
00101
00102 for (int m=0;m<90;m++) {
00103 int val=muEve->emcTriggerDetector().highTowerEndcap(m);
00104 if(wEve->l2EbitET) hE[6]->Fill(val);
00105 if(val<parE_DsmThres) continue;
00106 if(wEve->l2EbitET) hE[8]->Fill(m);
00107
00108 }
00109
00110 return 0;
00111 }
00112
00113
00114
00115 int
00116 St2011WMaker::accessETOW(){
00117
00118 StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
00119 if (!emc) {
00120 LOG_WARN <<"No EMC data for this event"<<endm; return -4;
00121 }
00122
00123 wEve->etow.etowIn=1;
00124 const char *maxIdName=0;
00125 double maxADC=0,adcSum=0;
00126
00127
00128 for (int i=0; i< emc->getNEndcapTowerADC(); i++) {
00129 int sec,eta,sub,rawAdc;
00130 emc->getEndcapTowerADC(i,rawAdc,sec,sub,eta);
00131
00132 const EEmcDbItem *x=mDbE->getTile(sec,'A'+sub-1,eta,'T');
00133 assert(x);
00134 if(x->fail ) continue;
00135 int isec=x->sec-1;
00136 int isub=x->sub-'A';
00137 int ieta=x->eta-1;
00138
00139 assert(isec>=0 && isec<mxEtowSec);
00140 assert(isub>=0 && isub<mxEtowSub);
00141 assert(ieta>=0 && ieta<mxEtowEta);
00142
00143 float adc=rawAdc-x->ped;
00144 if(adc<par_kSigPed*x->sigPed) continue;
00145
00146 wEve->etow.adc[isec*mxEtowSub+isub][ieta]=adc;
00147
00148 if(x->gain<=0) continue;
00149 float ene=adc/x->gain;
00150
00151
00152 ene*=par_etowScale;
00153 wEve->etow.ene[isec*mxEtowSub+isub][ieta]=ene;
00154 wEve->etow.stat[isec*mxEtowSub+isub][ieta]=0;
00155
00156 if(maxADC<adc) { maxIdName=x->name; maxADC=adc;}
00157 adcSum+=adc;
00158
00159 }
00160
00161 wEve->etow.maxAdc=maxADC;
00162 hE[31]->Fill(maxADC);
00163 hE[32]->Fill(adcSum);
00164
00165 if(maxADC<par_maxADC) return -2 ;
00166
00167 return 0;
00168 }
00169
00170
00171
00172 void
00173 St2011WMaker::accessEPRS(){
00174 StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
00175 if (!emc) {
00176 LOG_WARN <<"No EMC data for this event"<<endm;
00177 }
00178
00179 int i ;
00180 int pNh= emc->getNEndcapPrsHits();
00181 for (i=0; i < pNh; i++) {
00182 int pre,sec,eta,sub;
00183
00184 StMuEmcHit *hit=emc->getEndcapPrsHit(i,sec,sub,eta,pre);
00185 float rawAdc=hit->getAdc();
00186
00187 const EEmcDbItem *x=mDbE->getTile(sec,sub-1+'A',eta,pre-1+'P');
00188 assert(x);
00189 if(x->fail ) continue;
00190
00191 int isec=x->sec-1;
00192 int isub=x->sub-'A';
00193 int ieta=x->eta-1;
00194 int ipre=pre-1;
00195 int iphi=isec*mxEtowSub+isub;
00196
00197 assert(isec>=0 && isec<mxEtowSec);
00198 assert(isub>=0 && isub<mxEtowSub);
00199 assert(ieta>=0 && ieta<mxEtowEta);
00200
00201 float adc=rawAdc-x->ped;
00202 if(adc<par_kSigPed*x->sigPed) continue;
00203
00204 wEve->eprs.adc[iphi][ieta][ipre]=adc;
00205
00206 if(x->gain<=0) continue;
00207
00208 wEve->eprs.ene[isec*mxEtowSub+isub][ieta][ipre]=adc/x->gain;
00209 wEve->eprs.stat[isec*mxEtowSub+isub][ieta][ipre]=0;
00210
00211 }
00212 }
00213
00214
00215
00216 void
00217 St2011WMaker::accessESMD(){
00218 StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
00219 if (!emc) {
00220 LOG_WARN <<"No EMC data for this event"<<endm;
00221 }
00222
00223 char uv='U';
00224 for(uv='U'; uv <='V'; uv++) {
00225 int sec,strip;
00226 int nh= emc->getNEndcapSmdHits(uv);
00227 int i;
00228 for (i=0; i < nh; i++) {
00229 StMuEmcHit *hit=emc->getEndcapSmdHit(uv,i,sec,strip);
00230 float rawAdc=hit->getAdc();
00231 const EEmcDbItem *x=mDbE->getByStrip(sec,uv,strip);
00232 assert(x);
00233
00234 if(x->fail ) continue;
00235 if(x->ped<0) continue;
00236
00237 float adc=rawAdc-x->ped;
00238
00239 float sigPed=x->sigPed;
00240
00241 int isec=sec-1;
00242 int iuv=x->plane-'U';
00243 int istr=x->strip -1;
00244
00245 assert(isec>=0 && isec<mxEtowSec);
00246 assert(iuv>=0 && iuv<mxEsmdPlane);
00247 assert(istr>=0 && istr<mxEsmdStrip);
00248 if(x->gain<=0)continue;
00249 if(adc<par_kSigPed*sigPed) continue;
00250
00251 wEve->esmd.adc[isec][iuv][istr]=adc;
00252 wEve->esmd.ene[isec][iuv][istr]=adc/x->gain;
00253 }
00254 }
00255 }
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267