StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdFeeTTreeUser1.C
1 class EEfeeDataBlock;
2 class EEfeeRawEvent;
3 class EEfeeRunDescr;
4 
5 TFile *f;
6 
7 void rdFeeTTreeUser1(int max=10000) {
8  gSystem->Load("StRoot/StEEmcUtil/EEfeeRaw/libEEfeeRaw.so");
9  gStyle->SetPalette(1,0);
10 
11  TH2F *h2[8];
12  initHisto(h2);
13 
14  TH2F *hd[8];
15  initHistoD(hd);
16 
17  TString fname="/star/u/eemcdb/miniDaq/Mar1/run01001.root";
18 
19  TFile *f = new TFile(fname);
20  TTree *t = (TTree *)f->Get("fee");
21  TBranch *bd = t->GetBranch("desc");
22  TBranch *be = t->GetBranch("evt");
23 
24  EEfeeRawEvent *eve = new EEfeeRawEvent();
25  EEfeeRunDescr *des = new EEfeeRunDescr();
26 
27  be->SetAddress(&eve);
28  bd->SetAddress(&des);
29 
30  Int_t nentries = (Int_t)t->GetEntries();
31  cout << nentries << endl;
32  Int_t nbe=0;
33  Int_t nbd=0;
34  int nAcc=0;
35  for(Int_t ieve=0; ieve<nentries && ieve<max; ieve++) {
36  nbe += be->GetEntry(ieve);
37  nbd += bd->GetEntry(ieve);
38  TClonesArray *block=eve->block;
39  if(ieve%20==0)printf("EfeeRawEvent ID=%d with DataBlock entered=%d of %d, accepted %d events of %d\n", eve->getID(),block->GetEntries(),block->GetSize(), nAcc,ieve);
40  int j;
41  // eve->print();
42 
43 
44  //===========================================================
45  // =========== verify consistency ==========================
46 
47  int token=-1;
48  int n256=0;
49  for(j=0;j<block->GetEntries();j++) {// loop over data blocks
50  EEfeeDataBlock *blk= (EEfeeDataBlock *)block->At(j);
51  if(j==0) token=blk->getToken();
52  if(token!=blk->getToken()){ token=-2; break;}
53  if(blk->getCrateID()<3 || blk->getCrateID()>5) { token =-3; break;}
54 
55  if(blk->getCrateID()!=j+3) {// expected cartes 3,4,5
56  //printf("\n\nStarnge crateID=%d, STOP\n",blk->getCrateID());
57  token=-4; break;
58  }
59 
60 
61  // eliminate n*256 events
62  for(int k=0;k<128;k++) {
63  int adc=blk->getData()[k];
64  if(adc==256)n256++;
65  }
66  if(n256>5){ token =-5; ;break;}
67  }
68 
69  if(token<0) {
70  //printf("skip eveID=%d corrupted token or crate ID\n",eve->getID());
71  continue;
72  }
73 
74  nAcc++;
75  //===========================================================
76  //=============== sort data ================================
77 
78  int x3_71=-1;
79  int x3_61=-1;
80  int x4_10=-1;
81  int x4_1=-1;
82  int x5_95=-1;
83  int x5_99=-1;
84 
85  for(j=0;j<block->GetEntries();j++) {// loop over data blocks
86  EEfeeDataBlock *blk= (EEfeeDataBlock *)block->At(j);
87 
88  for(int k=0;k<128;k++) {
89  int adc=blk->getData()[k];
90  h2[j]->Fill(adc,k); // increment histos
91  }
92 
93  switch( blk->getCrateID()) {
94  case 3: x3_71=blk->getData()[71];x3_61=blk->getData()[61]; break;
95  case 4: x4_10=blk->getData()[10];x4_1=blk->getData()[1]; break;
96  case 5: x5_95=blk->getData()[95];x5_99=blk->getData()[99]; break;
97  }
98  }// end of loop over blocks
99 
100  hd[0]->Fill(x4_10,x3_71);
101  hd[1]->Fill(x4_10,x5_95);
102  hd[2]->Fill(x4_10,x4_1);
103 
104  hd[3]->Fill(x3_61,x3_71);
105  hd[4]->Fill(x3_61,x4_1);
106  hd[5]->Fill(x5_99,x4_1);
107  hd[6]->Fill(x5_99,x5_95);
108  if(x4_10>40 && x4_1 >40 && x3_71>60 && x3_61>80 && x5_99>60 && x5_95>80 )
109  eve->print();
110  }
111 
112  //===========================================================
113  //=============== draw plots ================================
114 
115  c=new TCanvas();
116  c->Divide(1,3);
117  int i;
118  for (i=0;i<3;i++){
119  c->cd(i+1);
120  h2[i]->Draw("colz");
121  gPad->SetLogz();
122  }
123 
124  c=new TCanvas();
125  c->Divide(3,3);
126  for (i=0;i<7;i++){
127  c->cd(i+1);
128  hd[i]->Draw("colz");
129  gPad->SetLogz();
130  }
131 }
132 
133 //----------------------------------
134 void initHisto(TH2F **h2) {
135 
136  int i;
137  for(i=0;i<3;i++) { //
138  int crate=i+3;
139  char tt1[100], tt2[100];
140  sprintf(tt1,"cr%dspeR",crate);
141  sprintf(tt2,"chan vs. raw ADC , carte=%d",crate);
142  // h2[i]= new TH2F(tt1,tt2, 4048,-0.5,4097.5,129,-0.5,128.5);
143  h2[i]= new TH2F(tt1,tt2, 200,0.,400,129,-0.5,128.5);
144  }
145 }
146 
147 //----------------------------------
148 void initHistoD(TH2F **h2) {
149 
150  h2[0]= new TH2F("dd0"," cr3/ch71 vs. cr4/ch10", 100,0.,200,100,0.,200);
151  h2[1]= new TH2F("dd1"," cr5/ch95 vs. cr4/ch10", 100,0.,200,100,0.,200);
152  h2[2]= new TH2F("dd2"," cr4/ch1 vs. cr4/ch10", 100,0.,200,100,0.,200);
153  h2[3]= new TH2F("dd3"," cr3/ch71 vs. cr3/ch61", 100,0.,200,100,0.,200);
154  h2[4]= new TH2F("dd4"," cr4/ch1 vs. cr3/ch61", 100,0.,200,100,0.,200);
155  h2[5]= new TH2F("dd5"," cr4/ch1 vs. cr5/ch99", 100,0.,200,100,0.,200);
156  h2[6]= new TH2F("dd6"," cr5/ch95 vs. cr5/ch99", 100,0.,200,100,0.,200);
157 }
158