00001
00002 class StEmcDetector;
00003 class StChain;
00004 class StEmcRawData;
00005 class EEfeeDataBlock;
00006 class Collection;
00007 class StSPtrVecTrackNodeIterator ;
00008 class StTriggerIdCollection;
00009
00010 StChain *chain=0;
00011
00012 int trigB[5]={96211,96233,96201,96222,0};
00013 int trigE[5]={96261,96282,96251,96272,0};
00014 int trigZ[2]={96300,0};
00015 int trigM[2]={96011,0};
00016 int trigJ[2]={20,0};
00017
00018 void rdSt2print(char * fname="aa.event.root", Int_t nevents=10){
00019
00020 fname="outPPV-G/st_physics_6151011_raw_2020001.event.root";
00021 char * fname="/star/institutions/iucf/balewski/2006-ppv-eval/test10/st_physics_adc_7118049_raw_1070001.event.root";
00022
00023 char *outF="res.dat";
00024 FILE *fd=fopen(outF,"w"); assert(fd);
00025
00026 gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
00027 loadSharedLibraries();
00028 assert( !gSystem->Load("StEEmcUtil.so"));
00029
00030 cout << " loading done " << endl;
00031
00032
00033
00034
00035 chain = new StChain("bfc");
00036
00037
00038
00039
00040
00041 StIOMaker* ioMaker = new StIOMaker();
00042
00043 ioMaker->SetFile(fname);
00044
00045 ioMaker->SetIOMode("r");
00046 ioMaker->SetBranch("*",0,"0");
00047 ioMaker->SetBranch("geantBranch",0,"r");
00048 ioMaker->SetBranch("eventBranch",0,"r");
00049 ioMaker->SetIOMode("r");
00050
00051
00052
00053
00054
00055
00056
00057
00058 chain->PrintInfo();
00059 chain->ls(3);
00060 Int_t initStat = chain->Init();
00061 if (initStat) chain->Fatal(initStat, "during Init()");
00062
00063 int istat=0,iev=0;
00064
00065
00066 while(1) {
00067 if (iev>=nevents) break;
00068 chain->Clear();
00069 istat = chain->Make();
00070 iev++;
00071 if(istat) break;
00072 cout << "---------------------- Processing Event : " << iev << " ---------------------- " << istat<<endl;
00073
00074
00075
00076 if (istat == kStEOF || istat == kStFatal) break;
00077
00078 StEvent* mEvent = (StEvent*)chain->GetInputDS("StEvent");
00079 assert(mEvent);
00080 StTriggerIdCollection *tic=mEvent->triggerIdCollection();
00081 assert(tic);
00082
00083
00084 isTrig(tic,trigB);
00085 isTrig(tic,trigE);
00086 isTrig(tic,trigZ);
00087 isTrig(tic,trigM);
00088 isTrig(tic,trigJ);
00089 int nV=mEvent->numberOfPrimaryVertices();
00090 int iv;
00091 if(nV>1) printf("######\n");
00092 printf("eveID=%d nPrimVert=%d\n", mEvent->id(),nV);
00093 fprintf(fd,"%5d %5d %d%d%d%d%d %2d ",iev,mEvent->id(),
00094 isTrig(tic,trigB),isTrig(tic,trigE),isTrig(tic,trigZ),
00095 isTrig(tic,trigM), isTrig(tic,trigJ), nV);
00096
00097 for(iv=0;iv<nV;iv++) {
00098 StPrimaryVertex *V=mEvent->primaryVertex(iv);
00099 assert(V);
00100 StThreeVectorF &r=V->position();
00101 StThreeVectorF &er=V->positionError();
00102 printf("iv=%d Vz=%.2f +/-%.2f \n",iv,r.z(),er.z() );
00103 fprintf(fd,"%.1f %d ",r.z(),V->numberOfDaughters());
00104 printf(" nPrimTr=%d , VFid=%d:: ntrVF=%d nCtb=%d nBemc=%d nEEmc=%d nTpc=%d sumPt=%.1f rank=%g\n"
00105 ,V->numberOfDaughters(), V->vertexFinderId() ,V->numTracksUsedInFinder() ,
00106 V->numMatchesWithCTB() ,V-> numMatchesWithBEMC() ,V->numMatchesWithEEMC() ,
00107 V->numTracksCrossingCentralMembrane() ,V->sumOfTrackPt() ,V->ranking());
00108
00109 continue;
00110 int nPrTr=0;
00111
00112 int itr;
00113 for(itr=0; itr<V->numberOfDaughters(); itr++) {
00114 StTrack *track=V-> daughter(itr);
00115 if(track==0) continue;
00116 if (track->flag() <0 ) continue;
00117 printf("itr=%d pT=%.1f eta=%.2f nFitP=%d DCA=%.1f\n",itr,
00118 track->geometry()->momentum().mag(),
00119 track->geometry()->momentum().pseudoRapidity(),
00120 track->fitTraits().numberOfFitPoints(),
00121 track->geometry()->helix().distance(V->position()));
00122 nPrTr++;
00123 }
00124
00125 printf(" counted nPrimTr=%d \n",nPrTr);
00126 }
00127 fprintf(fd,"\n");
00128 StEmcCollection* emcC =(StEmcCollection*)mEvent->emcCollection(); assert(emcC);
00129
00130
00131
00132
00133
00134
00135 printRaw(emcC->eemcRawData());
00136
00137 printRawBEMC(emcC->bemcRawData());
00138
00139
00140
00141 }
00142 chain->Finish();
00143
00144 fclose(fd);
00145
00146 }
00147
00148
00149
00150 void printRawBEMC(StEmcRawData *raw) {
00151
00152
00153 if(!raw) return;
00154
00155
00156
00157
00158
00159
00160
00161
00162 int NBANK = 13;
00163
00164 int tot=0;
00165
00166
00167 for(int i = 0; i<NBANK;i++) {
00168 if(raw->header(i)) {
00169 int size = raw->sizeHeader(i);
00170 printf("======BTOW BANK=%d size: head=%d, data=%d\n",i,size,raw->sizeData(i));
00171 continue;
00172 for(int j = 0;j<size;j++) {
00173 if(j%16==0) printf("\n");
00174 printf("0x%04x ",raw->header(i,j));
00175 }
00176 }
00177
00178 if(raw->data(i)) {
00179 int size = raw->sizeData(i);
00180 printf("\nBANK=%d data size=%d",i,size);
00181 for(int j = 0;j<size;j++) {
00182 if(j%16==0) printf("\n");
00183 printf("0x%04x ",raw->data(i,j));
00184 tot++;
00185 }
00186 }
00187 printf("\n bank=%d tot=%d\n",i,tot);
00188 }
00189 }
00190
00191
00192
00193
00194
00195
00196
00197 printRaw( StEmcRawData* raw) {
00198
00199 printf("printRaw(%p)\n",raw);
00200
00201 assert(raw);
00202 int icr;
00203 printf("nBlocks=%d\n",raw->getNBlocks());
00204 EEfeeDataBlock block;
00205 for(icr=0; icr<raw->getNBlocks();icr++) {
00206 if(raw->sizeData(icr)<=0) continue;
00207
00208 const UShort_t* head=raw->header(icr);
00209 const UShort_t* data=raw->data(icr);
00210 assert(head);
00211 printf("icr=%d, size: head=%d data=%d\n",icr,raw->sizeHeader(icr),raw->sizeData(icr));
00212
00213 int i;
00214 block.clear();
00215 block.setHead(raw->header(icr));
00216 block.setDataArray(raw->data(icr),raw->sizeData(icr));
00217 continue;
00218 if(icr>=6) continue;
00219 block.print(0);
00220
00221 }
00222
00223 }
00224
00225
00226
00227
00228 printETOW( StEmcDetector* det) {
00229
00230 printf("printTw(%p)\n",det);
00231 assert(det);
00232 printf("towers nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
00233 int nPos=0;
00234 for(int mod=1;mod<=det->numberOfModules();mod++) {
00235 StEmcModule* module=det->module(mod);
00236 printf("ETOW sector=%d nHit=%d\n",mod,module->numberOfHits());
00237 StSPtrVecEmcRawHit& hit= module->hits();
00238 int ih;
00239 for(ih=0;ih<hit.size();ih++){
00240 StEmcRawHit *x=hit[ih];
00241 int sec=x->module();
00242 char sub='A'+x->sub()-1;
00243 int eta=x->eta();
00244 int adc=x->adc();
00245
00246 printf("ih=%d %02dT%c%02d -->adc=%d ener=%f\n",ih,sec,sub,eta,adc, x->energy());
00247 if(adc>0) nPos++;
00248 int adcX=1000+ (eta-1) + (sub-'A')*12 +(sec-1)*60;
00249
00250
00251
00252 }
00253 printf("nPos=%d\n",nPos);
00254 }
00255 printf("total nPos=%d\n",nPos);
00256 printf("nPos=%d of %d \n",nPos,det->numberOfHits());
00257
00258 }
00259
00260
00261
00262
00263
00264
00265 printEPRE( StEmcDetector* det) {
00266
00267 printf("printPre/post(%p)\n",det);
00268 assert(det);
00269 printf("pre/post nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
00270 int nPos=0;
00271 for(int imod=1;imod<=det->numberOfModules();imod++) {
00272 StEmcModule* module=det->module(imod);
00273 printf("EPRE sect=%d nHit=%d\n",imod, module->numberOfHits());
00274 StSPtrVecEmcRawHit& hit= module->hits();
00275 int ih;
00276 for(ih=0;ih<hit.size();ih++){
00277 StEmcRawHit *x=hit[ih];
00278 int sec=x->module();
00279 int ss=x->sub()-1;
00280 char sub='A'+ss%5;
00281 char preL='P'+ss/5;
00282 int eta=x->eta();
00283 int adc=x->adc();
00284 printf("ih=%d %02d%c%c%02d ss=%d -->adc=%d ener=%f ss=%d\n",ih,sec,preL,sub,eta,ss,adc, x->energy(),ss);
00285 if(adc>0) nPos++;
00286 int adcX= (eta-1) + (sub-'A')*12 +(sec-1)*60 + 1000*(preL-'P'+1);
00287
00288 }
00289 printf("nPos=%d\n",nPos);
00290 }
00291
00292 printf("nPos=%d of %d \n",nPos,det->numberOfHits());
00293
00294 }
00295
00296
00297
00298
00299
00300
00301
00302 printESMD( StEmcDetector* det) {
00303
00304 printf("printSMD/post(%p)\n",det);
00305 assert(det);
00306 printf("U-SMD nHit=%d nMod=%d\n",det->numberOfHits(),det->numberOfModules());
00307 int nPos=0;
00308 for(int imod=1;imod<=det->numberOfModules();imod++) {
00309 StEmcModule* module=det->module(imod);
00310 printf("ESMD sector=%d nHit=%d\n",imod, module->numberOfHits());
00311 StSPtrVecEmcRawHit& hit= module->hits();
00312 int ih;
00313 for(ih=0;ih<hit.size();ih++){
00314 StEmcRawHit *x=hit[ih];
00315 int sec=x->module();
00316 int strip=x->eta();
00317 int adc=x->adc();
00318 printf("ih=%d %02dU%03d -->adc=%d ener=%f\n",ih,sec,strip,adc, x->energy());
00319 if(adc>0) nPos++;
00320 int adcX= 1000+(strip -1) +(sec-1)*300;
00321
00322 }
00323 printf(" nPos=%d\n",nPos);
00324 }
00325 printf("nPos=%d of %d \n",nPos,det->numberOfHits());
00326
00327
00328 }
00329
00330
00331 bool isTrig(StTriggerIdCollection *tic,int *trigL){
00332 int i;
00333 const StTriggerId *l1=tic->l1();
00334
00335 for(i=0;trigL[i]>0;i++) {
00336
00337 if(l1->isTrigger(trigL[i])) return true;
00338 }
00339 return false;
00340 }
00341
00342
00343
00344
00345