00001 #include <StEEmcUtil/database/EEmcDbItem.h>
00002 class StChain;
00003 class StMuEmcCollection;
00004 class EEmcDbItem;
00005 class StEEmcDb;
00006 StEEmcDb *myDb;
00007 StChain *chain=0;
00008 TH1F * hx[8];
00009 TH1F * hr[8];
00010 TH1F * hd[8];
00011 TH1F * hs[24];
00012
00013 int rdMuDst2spec(
00014 char* file = "R50530.MuDst.root",
00015 Int_t nFiles = 1,
00016 char* inDir = "./",
00017 int nEve=5 ){
00018
00019 inDir = "/star/data39/reco/production62GeV/ReversedFullField/P04id/2004/089//";
00020 file="st_physics_5089006_raw_4040002.MuDst.root";
00021
00022 initHisto();
00023
00024 gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
00025 loadSharedLibraries();
00026 cout << " loading done " << endl;
00027 gSystem->Load("StDbLib");
00028 gSystem->Load("StDbBroker");
00029 gSystem->Load("St_db_Maker");
00030 gSystem->Load("StEEmcUtil");
00031 gSystem->Load("StEEmcDbMaker");
00032
00033
00034
00035
00036 chain = new StChain("StChain");
00037
00038
00039 muMk = new StMuDstMaker(0,0,inDir,file,"MuDst.root",nFiles);
00040
00041 St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb");
00042 new StEEmcDbMaker("eemcDb");
00043
00044
00045
00046
00047
00048
00049 chain->Init();
00050 chain->ls(3);
00051 myDb = (StEEmcDb*)chain->GetDataSet("StEEmcDb");
00052
00053 exit;
00054 int eventCounter=0;
00055 int stat=0;
00056
00057
00058 while ( stat==0 ) {
00059 if(eventCounter>=nEve) break;
00060 eventCounter++;
00061 chain->Clear();
00062 stat = chain->Make();
00063
00064
00065 StMuEvent* muEve = muMk->muDst()->event();
00066 int nPrim = muMk->muDst()->primaryTracks()->GetEntries();
00067 StEventInfo &info=muEve->eventInfo();
00068
00069
00070 printf("\n\n ====================%d processing eventID %d nPrim=%d ==============\n", eventCounter,info.id(),nPrim);
00071
00072 hx[0]->Fill(nPrim);
00073 StMuEmcCollection* emc = muMk->muDst()->emcCollection();
00074 if (!emc) {
00075 printf(" No EMC data for this event\n");
00076 return kStOK;
00077 }
00078 printEEtower(emc);
00079 printEEpre(emc);
00080 printEEsmd(emc);
00081
00082 }
00083
00084 }
00085
00086
00087
00088 printEEtower( StMuEmcCollection* emc ) {
00089 int sec,eta,sub,adc;
00090
00091
00092 int i, nh;
00093
00094 printf("\Total %d hits in Tower (only ADC>0)\n",emc->getNEndcapTowerADC());
00095 nh=0;
00096 for (i=0; i< emc->getNEndcapTowerADC(); i++) {
00097 emc->getEndcapTowerADC(i,adc,sec,sub,eta);
00098
00099
00100
00101
00102
00103
00104
00105 int irad=sub -1 + 5*(sec-1) +60 *(eta-1);
00106 EEmcDbItem *x=myDb->getTile(sec,'A'+sub-1,eta,'T');
00107 if(x==0) continue;
00108 if(x->fail) continue;
00109
00110 if(adc<x->thr) continue;
00111 nh++;
00112 adc-=x->ped;
00113 if(adc>20) hr[0]->Fill(irad);
00114 ((TH2F*) hd[0])->Fill(irad,adc);
00115 }
00116 printf(" Total %d towers with ADC>Thr & !fail \n",nh);
00117 }
00118
00119
00120
00121
00122 printEEpre( StMuEmcCollection* emc ) {
00123 int sec,eta,sub,pre,adc;
00124 StMuEmcHit *hit;
00125
00126 int i, nh;
00127 nh= emc->getNEndcapPrsHits();
00128 printf("\nTotal %d hits in pre1+2+post\n",nh);
00129 for (i=0; i<nh; i++) {
00130 hit=emc->getEndcapPrsHit(i,sec,sub,eta,pre);
00131 int ss=sub + 5*(pre-1);
00132 adc=hit->getAdc();
00133
00134
00135
00136 EEmcDbItem *x=myDb->getTile(sec,'A'+sub-1,eta,'P'+pre-1);
00137 if(x==0) continue;
00138 if(x->fail) continue;
00139 if(adc<x->thr) continue;
00140 adc-=x->ped;
00141 int irad=sub -1 + 5*(sec-1) +60 *(eta-1);
00142 if(adc>20) hr[pre]->Fill(irad);
00143 }
00144 }
00145
00146
00147
00148
00149 printEEsmd( StMuEmcCollection* emc ) {
00150 int sec,strip,adc;
00151 char uv='U';
00152
00153 for(uv='U'; uv<='V'; uv++) {
00154 int nh= emc->getNEndcapSmdHits(uv);
00155 printf("\nTotal %d hits in SMD-%c\n",nh,uv);
00156 for (int i=0; i<nh; i++) {
00157 hit=emc->getEndcapSmdHit(uv,i,sec,strip);
00158 adc=hit->getAdc();
00159
00160
00161
00162 EEmcDbItem *x=myDb->getByStrip(sec,uv,strip);
00163 if(x==0) continue;
00164 if(x->fail) continue;
00165 if(adc<x->thr) continue;
00166 adc-=x->ped;
00167
00168 int ip=2*(sec-1) +uv -'U';
00169 if(adc>20) hs[ip]->Fill(strip);
00170
00171 }
00172 }
00173 }
00174
00175
00176
00177 initHisto() {
00178 hx[0]=new TH1F("nPrim","no of prim tracks per event",200,0.,2000);
00179
00180 hr[0]=new TH1F("adcT","ADC-ped>20 vs Tower ID, spiral mode; X=iphi+60*ieta",720,-0.5,719.5);
00181 hr[1]=new TH1F("adcP","ADC-ped>20 vs pres-1 ID, spiral mode; X=iphi+60*ieta",720,-0.5,719.5);
00182 hr[2]=new TH1F("adcQ","ADC-ped>20 vs pres-2 ID, spiral mode; X=iphi+60*ieta",720,-0.5,719.5);
00183 hr[3]=new TH1F("adcR","ADC-ped>20 vs post ID, spiral mode; X=iphi+60*ieta",720,-0.5,719.5);
00184
00185 int ip;
00186 for(ip=0;ip<24;ip++) {
00187 char uv='U'+ip%2;
00188 int sec=1+ip/2;
00189 char tt1[100], tt2[100];
00190 sprintf(tt1,"adc%c%02d",uv,sec);
00191 sprintf(tt2,"ADC-ped>20 smd-%c%02d ; strip ID",uv,sec);
00192 hs[ip]=new TH1F(tt1,tt2,288,0.5,288.5);
00193 }
00194
00195
00196 TH2F *h2=new TH2F("adc2T","ADC-ped vs Tower ID, spiral mode; X=iphi+60*ieta",720,-0.5,719.5,50,0,300);
00197 hd[0]=(TH1F*) h2;
00198
00199 }
00200