StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdSt2spinTest.C
1 
2 class StChain;
3 StChain *chain=0;
4 TH1F *hbx=0, *hfb=0;
5 TH2F *hs8ev=0,*hs8db=0, *hs4db=0, *hdbx=0;
6 TFile *hf=0;
7 
8 void rdSt2spinTest( Int_t nevents=10){
9 
10  char * fname="/star/data03/daq/2005/janMisc/st_physics_6156028_raw_2040010.event.root";
11  //char * fname="/star/data03/daq/2005/janMisc/st_physics_5135068_raw_2020006.event.root";
12  initHisto();
13 
14  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
15  loadSharedLibraries();
16  cout << " loading done " << endl;
17  gSystem->Load("StDbLib");
18  gSystem->Load("StDbBroker");
19  gSystem->Load("St_db_Maker");
20  gSystem->Load("StSpinDbMaker");
21 
22  // create chain
23  chain = new StChain("bfc");
24 
25  // StIOMaker - to read files ...
26  StIOMaker* ioMaker = new StIOMaker();
27  ioMaker->SetFile(fname);
28  ioMaker->SetIOMode("r");
29  ioMaker->SetBranch("*",0,"0"); //deactivate all branches
30  ioMaker->SetBranch("eventBranch",0,"r"); //activate Event Branch
31  ioMaker->SetIOMode("r");
32 
33  St_db_Maker *stDb = new St_db_Maker("StarDb", "MySQL:StarDb");
34  spDb=new StSpinDbMaker("spinDb");
35 
36  gMessMgr->SwitchOff("D");
37  gMessMgr->SwitchOn("I");
38 
39  chain->ls(3);
40  Int_t initStat = chain->Init();
41  if (initStat) chain->Fatal(initStat, "during Init()");
42 
43  int istat=0,iev=0;
44 
45  // Do the event loop
46  while(1) {
47  if (iev>=nevents) break;
48  chain->Clear();
49  istat = chain->Make();
50  iev++;
51  if(istat) break;
52  cout << "---------------------- Processing Event : " << iev << " ---------------------- " << istat<<endl;
53 
54  if(iev==1){// fill pattern acquired for first event
55  // spDb->print(0);
56  for(int bx48=0;bx48<120;bx48++){
57  int bxStar=spDb->BXstarUsingBX48(bx48);
58  if(spDb->isBXfilledUsingBX48(bx48)) hfb->Fill(bxStar);
59  //printf("bxStar=%3d bx48=%3d fill=%d\n",bxStar,bx48,spDb->isBXfilledUsingBX48(bx48));
60  }
61  }
62  if (istat == kStEOF || istat == kStFatal) break;
63 
64  StEvent* mEvent = (StEvent*)chain->GetInputDS("StEvent");
65  assert(mEvent);// fix your chain or open the right event file
66  StTriggerIdCollection *tic=mEvent->triggerIdCollection();
67  assert(tic);
68 
69  StTriggerData* trgD= mEvent->triggerData(); assert(trgD);
70  int bx48=trgD->bunchId48Bit();
71  int bx7=trgD->bunchId7Bit();
72  int bxStar48=spDb->BXstarUsingBX48(bx48);
73  int bxStar7=spDb->BXstarUsingBX7(bx7);
74  int bxPhase=spDb->offsetBX48minusBX7(bx48,bx7);
75  int spin8ev=trgD->spinBit();
76  int spin8db=spDb->spin8usingBX48(bx48);
77  int spin4db=spDb->spin4usingBX48(bx48);
78  //.... do histo
79  hbx->Fill(bxStar48);
80  hdbx->Fill(bxStar48,bxStar7);
81  hs8ev->Fill(bxStar48,spin8ev);
82  if(spDb->isBXfilledUsingBX48(bx48)){
83  hs8db->Fill(bxStar48,spin8db);
84  hs4db->Fill(bxStar48,spin4db);
85  }
86  int nV=mEvent->numberOfPrimaryVertices();
87  printf("eveID=%d nPrimVert=%d ", mEvent->id(),nV);
88  printf("bx48=%3d bx7= %3d bxPhase=%3d spin8: ev=0x%02x : 0x%02x=db bxStar48=%3d \n",bx48,bx7,bxPhase,spin8ev,spin8db,bxStar48);
89  // assert(spin8ev>10);
90  } // Event Loop
91  hf->Write();
92 
93 }
94 
95 
96 //========================
97 void initHisto() {
98  hf=new TFile("outx.hist.root","recreate");
99  hbx=new TH1F("bx","Rate vs. true bXing from bx48; bXing at STAR IP",120,-0.5,119.5);
100  hfb=new TH1F("fb","Intended fill pattern; bXing at STAR IP",120,-0.5,119.5);
101 
102  hs8ev=new TH2F("s8ev","spin8(eve) vs. true bXing from bx48; bXing at STAR; spin8 from event",120,-0.5,119.5,100,-0.5,99.5);
103  hs8db=new TH2F("s8db","spin8(db) vs. true bXing from bx48; bXing at STAR; spin8 from DB",120,-0.5,119.5,100,-0.5,99.5);
104 
105  hs4db=new TH2F("s4db","spin4(db) vs. true bXing from bx48; bXing at STAR; spin4 from DB",120,-0.5,119.5,100,-0.5,15.5);
106 
107  hdbx=new TH2F("dbx","bx7 vs. true bXing from bx48; bXing at STAR;bx7",120,-0.5,119.5,120,-0.5,119.5);
108 }
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
Collection of trigger ids as stored in StEvent.
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Definition: Stypes.h:43
virtual Int_t Make()
Definition: StChain.cxx:110