StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdMu2spinTest.C
1 class StChain;
3 
4 class StEEmcDbMaker;
5 class StMuDstMaker;
6 class TChain;
7 
8 StEEmcDbMaker *myDb;
9 StMuDstMaker* muMk;
10 StChain *chain=0;
11 
12 
13 int rdMu2spinTest( char* Rrun ="R6172038",
14  Int_t nFiles = 20,
15  char* inDir = "./lis/",
16  int nEve=500)
17 {
18 
19  #define USE_DB
20  char *outPath="iterX/";
21 
22 
23  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
24  loadSharedLibraries();
25  cout << " loading done " << endl;
26 
27  TString fileL=Rrun; fileL+=".lis";
28  int runNo=atoi(Rrun+1);
29 
30  // tmp : 2006
31  inDir = "/star/data05/scratch/balewski/2006-prod-muDst/7097090/";
32  fileL="st_physics_7097090_raw_1010001.MuDst.root";
33 
34  // tmp : 2005
35  // inDir = "/star/data05/scratch/balewski/2005-prod-muDst/6174052/";
36  // fileL="st_physics_6174068_raw_2030018.MuDst.root";
37 
38 
39  // runNo=999; Rrun="R999";
40 
41 #ifdef USE_DB
42  gSystem->Load("StDbLib");
43  gSystem->Load("StDbBroker");
44  gSystem->Load("St_db_Maker");
45  gSystem->Load("StSpinDbMaker");
46 #endif
47 
48  // create chain
49  chain = new StChain("StChain");
50  // inDir ="/star/u/jwebb/work/2005/TEST/";
51  // fileL="test.lis";
52 
53  printf("adding muDst from '%s' ....\n",fileL.Data());
54  // Now we add Makers to the chain...
55  muMk = new StMuDstMaker(0,0,inDir,fileL,"MuDst.root",nFiles);
56  TChain* tree=muMk->chain(); assert(tree);
57  int nEntries=(int)tree->GetEntries();
58  printf("total eve in chain =%d\n",nEntries);
59 
60 #ifdef USE_DB
61  St_db_Maker *stDb = new St_db_Maker("StarDb", "MySQL:StarDb");
62  spDb=new StSpinDbMaker("spinDb");
63 
64  gMessMgr->SwitchOff("D");
65  gMessMgr->SwitchOn("I");
66  hbxI=new TH1F("bXI","Intended fill pattern vs. STAR bXing; bXing at STAR IP",120,-0.5,119.5);
67 #endif
68 
69  hbx48=new TH1F("bX48","Rate vs. raw bx48; bXing= raw bx48",120,-0.5,119.5);
70  hbx7=new TH1F("bX7","Rate vs. raw bx7; bXing= raw bx7",120,-0.5,119.5);
71  hbx748=new TH2F("bX748","BX ID correlation ; raw bx7; raw bx48",120,-0.5,119.5,120,-0.5,119.5);
72 
73  hbx48c=new TH1F("bX48c","Rate vs. yellBX using bx48 ; bXing= bx48+offset",120,-0.5,119.5);
74  hbx7c=new TH1F("bX7c","Rate vs. yellBX using bx7; bXing= bx7+offset",120,-0.5,119.5);
75 
76  hbx48cm=new TH1F("bX48cm","Masking ON, Rate vs. STAR IP bXing(bx48) ; bXing= bx48+offset",120,-0.5,119.5);
77 
78  int t1=time(0);
79  chain->Init();
80  int t2=time(0);
81  printf("%d seconds used to Init() the chain\n",t2-t1);
82 
83  chain->ls(3);
84  // return;
85  int eventCounter=0;
86  int stat=0;
87  t1=time(0);
88 
89  //---------------------------------------------------
90  while ( 1 ) {// loop over events
91  if(eventCounter>=nEve) break;
92  chain->Clear();
93  stat = chain->Make();
94  if(stat) break; // end of events
95  eventCounter++;
96  // dump spinDB only once:
97  // if(eventCounter==1) spDb->print(0); // 1-large printout, 0-smaler
98 
99  // Access to muDst .......................
100  StMuEvent* muEve = muMk->muDst()->event();
101  int nPrim = muMk->muDst()->primaryTracks()->GetEntries(); // get number of primary tracks
102  StEventInfo &info=muEve->eventInfo();
103 
104  StL0Trigger *trig=&(muEve->l0Trigger());
105  int bx48=trig->bunchCrossingId();
106  int bx7=trig->bunchCrossingId7bit(muEve->runId());
107  hbx48->Fill(bx48);
108  hbx7->Fill(bx7);
109  hbx748->Fill(bx7,bx48);
110  // printf("w/o DB bx7=%d bx48=%d del=%d \n", bx7, bx48,(bx7-bx48+120)%120);
111 
112 #ifdef USE_DB
113  int bxStar48=spDb->BXyellowUsingBX48(bx48);
114  int bxStar7=spDb->BXyellowUsingBX7(bx7);
115 
116  //printf("eveID=%d bx7=%d bx48=%d --> yellBX:=%d ? %d --> del=%d\n",info.id(),bx7,bx48, bxStar7,bxStar48, (bxStar7-bxStar48+120)%120);
117  assert(spDb->offsetBX48minusBX7(bx48,bx7)==0);
118  hbx48c->Fill(bxStar48);
119  hbx7c->Fill(bxStar7);
120  if(!spDb->isMaskedUsingBX48(bx48) ) hbx48cm->Fill(bxStar48);
121 #endif
122 
123  if(eventCounter%500==0) printf("\n\n ====================%d processing eventID %d nPrim=%d ==============\n", eventCounter++,info.id(),nPrim);
124 
125  }
126 
127  if(eventCounter>0) printf("sorting done, nEve=%d of :%d :%d :is missing\n",eventCounter, nEntries,-eventCounter+nEntries);
128  t2=time(0);
129  if(t2==t1) t2=t1+1;
130  float rate=1.*eventCounter/(t2-t1);
131  float nMnts=(t2-t1)/60.; printf("sorting done %d of nEve=%d, CPU rate=%.1f Hz tot %.1f minutes\n",eventCounter,nEntries,rate,nMnts);
132 
133  TString fileH=outPath; fileH+=Rrun; fileH+=".hist.root";
134  printf(" saving -->%s\n",fileH.Data());
135  new TFile(fileH,"recreate");
136  hbx48->Write();
137  hbx7->Write();
138  hbx748->Write();
139  hbx48c->Write();
140  hbx7c->Write();
141  hbx48cm->Write();
142 
143 #ifdef USE_DB
144  //play with spinDb information
145  // spDb->print(0); // 0=short, 1=huge
146  const int * spin8bits=spDb->getSpin8bits();
147  for(int bx=0;bx<120;bx++){
148  bool isFilled=(spin8bits[bx] & 0x11)==0x11;
149  if(isFilled) hbxI->Fill(bx);
150  assert(isFilled==spDb->isBXfilledUsingBXyellow(bx));
151  // spDb->isBXmaskedUsingBXyellow(bx);
152  // if(spDb->isBXfilledUsingBX48(bx48)) hbxI->Fill(bxStar);
153  //printf("bxStar=%3d bx48=%3d fill=%d\n",bxStar,bx48,spDb->isBXfilledUsingBX48(bx48));
154  }
155  hbxI->Write();
156 #endif
157 
158 
159  chain->Finish();
160 
161 
162 
163 }
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
virtual Int_t Make()
Definition: StChain.cxx:110