00001 class StChain;
00002 class StMuEmcCollection;
00003
00004 class StEEmcDbMaker;
00005 class StMuDstMaker;
00006 class TChain;
00007
00008 StEEmcDbMaker *myDb;
00009 StMuDstMaker* muMk;
00010 StChain *chain=0;
00011
00012
00013 int rdMu2spinTest( char* Rrun ="R6172038",
00014 Int_t nFiles = 20,
00015 char* inDir = "./lis/",
00016 int nEve=500)
00017 {
00018
00019 #define USE_DB
00020 char *outPath="iterX/";
00021
00022
00023 gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
00024 loadSharedLibraries();
00025 cout << " loading done " << endl;
00026
00027 TString fileL=Rrun; fileL+=".lis";
00028 int runNo=atoi(Rrun+1);
00029
00030
00031 inDir = "/star/data05/scratch/balewski/2006-prod-muDst/7097090/";
00032 fileL="st_physics_7097090_raw_1010001.MuDst.root";
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifdef USE_DB
00042 gSystem->Load("StDbLib");
00043 gSystem->Load("StDbBroker");
00044 gSystem->Load("St_db_Maker");
00045 gSystem->Load("StSpinDbMaker");
00046 #endif
00047
00048
00049 chain = new StChain("StChain");
00050
00051
00052
00053 printf("adding muDst from '%s' ....\n",fileL.Data());
00054
00055 muMk = new StMuDstMaker(0,0,inDir,fileL,"MuDst.root",nFiles);
00056 TChain* tree=muMk->chain(); assert(tree);
00057 int nEntries=(int)tree->GetEntries();
00058 printf("total eve in chain =%d\n",nEntries);
00059
00060 #ifdef USE_DB
00061 St_db_Maker *stDb = new St_db_Maker("StarDb", "MySQL:StarDb");
00062 spDb=new StSpinDbMaker("spinDb");
00063
00064 gMessMgr->SwitchOff("D");
00065 gMessMgr->SwitchOn("I");
00066 hbxI=new TH1F("bXI","Intended fill pattern vs. STAR bXing; bXing at STAR IP",120,-0.5,119.5);
00067 #endif
00068
00069 hbx48=new TH1F("bX48","Rate vs. raw bx48; bXing= raw bx48",120,-0.5,119.5);
00070 hbx7=new TH1F("bX7","Rate vs. raw bx7; bXing= raw bx7",120,-0.5,119.5);
00071 hbx748=new TH2F("bX748","BX ID correlation ; raw bx7; raw bx48",120,-0.5,119.5,120,-0.5,119.5);
00072
00073 hbx48c=new TH1F("bX48c","Rate vs. yellBX using bx48 ; bXing= bx48+offset",120,-0.5,119.5);
00074 hbx7c=new TH1F("bX7c","Rate vs. yellBX using bx7; bXing= bx7+offset",120,-0.5,119.5);
00075
00076 hbx48cm=new TH1F("bX48cm","Masking ON, Rate vs. STAR IP bXing(bx48) ; bXing= bx48+offset",120,-0.5,119.5);
00077
00078 int t1=time(0);
00079 chain->Init();
00080 int t2=time(0);
00081 printf("%d seconds used to Init() the chain\n",t2-t1);
00082
00083 chain->ls(3);
00084
00085 int eventCounter=0;
00086 int stat=0;
00087 t1=time(0);
00088
00089
00090 while ( 1 ) {
00091 if(eventCounter>=nEve) break;
00092 chain->Clear();
00093 stat = chain->Make();
00094 if(stat) break;
00095 eventCounter++;
00096
00097
00098
00099
00100 StMuEvent* muEve = muMk->muDst()->event();
00101 int nPrim = muMk->muDst()->primaryTracks()->GetEntries();
00102 StEventInfo &info=muEve->eventInfo();
00103
00104 StL0Trigger *trig=&(muEve->l0Trigger());
00105 int bx48=trig->bunchCrossingId();
00106 int bx7=trig->bunchCrossingId7bit(muEve->runId());
00107 hbx48->Fill(bx48);
00108 hbx7->Fill(bx7);
00109 hbx748->Fill(bx7,bx48);
00110
00111
00112 #ifdef USE_DB
00113 int bxStar48=spDb->BXyellowUsingBX48(bx48);
00114 int bxStar7=spDb->BXyellowUsingBX7(bx7);
00115
00116
00117 assert(spDb->offsetBX48minusBX7(bx48,bx7)==0);
00118 hbx48c->Fill(bxStar48);
00119 hbx7c->Fill(bxStar7);
00120 if(!spDb->isMaskedUsingBX48(bx48) ) hbx48cm->Fill(bxStar48);
00121 #endif
00122
00123 if(eventCounter%500==0) printf("\n\n ====================%d processing eventID %d nPrim=%d ==============\n", eventCounter++,info.id(),nPrim);
00124
00125 }
00126
00127 if(eventCounter>0) printf("sorting done, nEve=%d of :%d :%d :is missing\n",eventCounter, nEntries,-eventCounter+nEntries);
00128 t2=time(0);
00129 if(t2==t1) t2=t1+1;
00130 float rate=1.*eventCounter/(t2-t1);
00131 float nMnts=(t2-t1)/60.; printf("sorting done %d of nEve=%d, CPU rate=%.1f Hz tot %.1f minutes\n",eventCounter,nEntries,rate,nMnts);
00132
00133 TString fileH=outPath; fileH+=Rrun; fileH+=".hist.root";
00134 printf(" saving -->%s\n",fileH.Data());
00135 new TFile(fileH,"recreate");
00136 hbx48->Write();
00137 hbx7->Write();
00138 hbx748->Write();
00139 hbx48c->Write();
00140 hbx7c->Write();
00141 hbx48cm->Write();
00142
00143 #ifdef USE_DB
00144
00145
00146 const int * spin8bits=spDb->getSpin8bits();
00147 for(int bx=0;bx<120;bx++){
00148 bool isFilled=(spin8bits[bx] & 0x11)==0x11;
00149 if(isFilled) hbxI->Fill(bx);
00150 assert(isFilled==spDb->isBXfilledUsingBXyellow(bx));
00151
00152
00153
00154 }
00155 hbxI->Write();
00156 #endif
00157
00158
00159 chain->Finish();
00160
00161
00162
00163 }