StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdDb.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 // override DB_time_stamp to retrieve some DB information
13 int rdDb( char *outH="F7327", int idat=20050624, int itim=91958 ) {
14 
15  // provide any input file to make the chain exec InitRun()
16  char* inDir = "/star/data05/scratch/balewski/2005-bXing-muDst4/171/";
17  char* Rrun ="st_physics_6171021_raw_2020001.MuDst.root";
18  Int_t nFiles = 1;
19  int nEve=1;
20 
21  char *outPath="iterF/";
22 
23  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
24  loadSharedLibraries();
25  cout << " loading done " << endl;
26 
27  gSystem->Load("StDbLib");
28  gSystem->Load("StDbBroker");
29  gSystem->Load("St_db_Maker");
30  gSystem->Load("StSpinDbMaker");
31 
32  // create chain
33  chain = new StChain("StChain");
34 
35  printf("adding muDst from '%s' ....\n",Rrun);
36  // Now we add Makers to the chain...
37  muMk = new StMuDstMaker(0,0,inDir,Rrun,"MuDst.root",nFiles);
38  TChain* tree=muMk->chain(); assert(tree);
39  int nEntries=(int)tree->GetEntries();
40  printf("total eve in chain =%d\n",nEntries);
41 
42  St_db_Maker *stDb = new St_db_Maker("StarDb", "MySQL:StarDb");
43 
44  stDb->SetDateTime(idat,itim);
45 
46  spDb=new StSpinDbMaker("spinDb");
47 
48  gMessMgr->SwitchOff("D");
49  gMessMgr->SwitchOn("I");
50  hbxI=new TH1F("bXI","Intended fill pattern vs. STAR bXing; bXing at STAR IP",120,-0.5,119.5);
51 
52 
53  int t1=time(0);
54  chain->Init();
55  int t2=time(0);
56  printf("%d seconds used to Init() the chain\n",t2-t1);
57 
58  chain->ls(3);
59  // return;
60  int eventCounter=0;
61  int stat=0;
62  t1=time(0);
63 
64  //---------------------------------------------------
65  while ( 1 ) {// loop over events
66  if(eventCounter>=nEve) break;
67  chain->Clear();
68  stat = chain->Make();
69  if(stat) break; // end of events
70  eventCounter++;
71  }
72 
73  if(eventCounter>0) printf("sorting done, nEve=%d of :%d :%d :is missing\n",eventCounter, nEntries,-eventCounter+nEntries);
74  t2=time(0);
75  if(t2==t1) t2=t1+1;
76  float rate=1.*eventCounter/(t2-t1);
77  float nMnts=(t2-t1)/60.; printf("sorting done %d of nEve=%d, CPU rate=%.1f Hz tot %.1f minutes\n",eventCounter,nEntries,rate,nMnts);
78 
79  TString fileH=outPath; fileH+=outH; fileH+=".hist.root";
80  printf(" saving -->%s\n",fileH.Data());
81  new TFile(fileH,"recreate");
82 
83  //play with spinDb information
84  // spDb->print(0); // 0=short, 1=huge
85  const int * spin8bits=spDb->getSpin8bits();
86  for(int bx=0;bx<120;bx++){
87  bool isFilled=(spin8bits[bx] & 0x11)==0x11;
88  if(isFilled) hbxI->Fill(bx);
89  }
90  hbxI->Write();
91 
92  chain->Finish();
93 
94 
95 }
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
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
Definition: StMuDstMaker.h:426