StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
drawTables.C
1 /*------------------------------------------------------------------------------
2 |
3 | drawTables.C
4 | Macro that draws the content of tables saved in the database
5 |
6 |
7 | First argument is the table name
8 |
9 | Second and Third arguments correspond to the timestamp limits for the
10 | tables in the database
11 |
12 | Fourth argument is the maximum entry time in the database. It means that the
13 | table had to be *saved* before that time. Do not mistake this as the
14 | timestamp
15 |
16 | Fifth argument is the flavor the tables is save in the database
17 |
18 | author: Alex Suaide (c) 2006
19 |
20 |-----------------------------------------------------------------------------*/
21 
22 class StEmcDbHandler;
23 std::vector<std::string> list;
24 int index = -1;
25 StEmcDbHandler* dbHandler = NULL;
26 TString table;
27 
28 void drawTables(char* t = "bemcStatus",
29  char* TSi = "2001-01-01 00:00:00",
30  char* TSf = "2030-01-01 00:00:00",
31  char* MAX = "2030-01-01 00:00:00",
32  char* flavor = "ofl")
33 {
34  gROOT->Macro("loadMuDst.C");
35  gROOT->LoadMacro("$STAR/StRoot/StEmcUtil/macros/drawSingleTable.C");
36 
37  table = t;
38 
39  dbHandler=new StEmcDbHandler();
40  dbHandler->setTableName(t);
41  dbHandler->setMaxEntryTime(MAX);
42  dbHandler->setFlavor(flavor);
43  list = dbHandler->getTimeStampList(TSi,TSf);
44 
45  stats();
46  plot(0);
47 }
48 
49 void stats()
50 {
51  for(int i =0;i<list.size();i++)
52  {
53  dbHandler->setTimeStamp(list[i].c_str());
54  int nGood = 0;
55  int nEmpty = 0;
56  int nBad = 0;
58  if(!strcmp("bemcPed",table.Data()) || !strcmp("bprsPed",table.Data()))
59  {
60  emcPed = (emcPed_st*) dbHandler->getDbTable()->GetTable();
61  for(int j = 0;j<4800;j++)
62  if(emcPed->Status[j] == 1) nGood++;
63  else if(emcPed->Status[j] == 0) nEmpty++;
64  else nBad++;
65  }
66  if(!strcmp("bemcCalib",table.Data()) || !strcmp("bprsCalib",table.Data()))
67  {
68  emcCalib = (emcCalib_st*) dbHandler->getDbTable()->GetTable();
69  for(int j = 0;j<4800;j++)
70  if(emcCalib->Status[j] == 1) nGood++;
71  else if(emcCalib->Status[j] == 0) nEmpty++;
72  else nBad++;
73  }
74  if(!strcmp("bemcStatus",table.Data()) || !strcmp("bprsStatus",table.Data()))
75  {
76  emcStatus = (emcStatus_st*) dbHandler->getDbTable()->GetTable();
77  for(int j = 0;j<4800;j++)
78  if(emcStatus->Status[j] == 1) nGood++;
79  else if(emcStatus->Status[j] == 0) nEmpty++;
80  else nBad++;
81  }
82  if(!strcmp("bemcGain",table.Data()) || !strcmp("bprsGain",table.Data()))
83  {
84  emcGain = (emcGain_st*) dbHandler->getDbTable()->GetTable();
85  for(int j = 0;j<4800;j++)
86  if(emcGain->Status[j] == 1) nGood++;
87  else if(emcGain->Status[j] == 0) nEmpty++;
88  else nBad++;
89  }
91  if(!strcmp("bsmdePed",table.Data()) || !strcmp("bsmdpPed",table.Data()))
92  {
93  smdPed = (smdPed_st*) dbHandler->getDbTable()->GetTable();
94  for(int j = 0;j<18000;j++)
95  if (smdPed->Status[j] == 1) nGood++;
96  else if(smdPed->Status[j] == 0) nEmpty++;
97  else nBad++;
98  }
99  if(!strcmp("bsmdeCalib",table.Data()) || !strcmp("bsmdpCalib",table.Data()))
100  {
101  smdCalib = (smdCalib_st*) dbHandler->getDbTable()->GetTable();
102  for(int j = 0;j<18000;j++)
103  if (smdCalib->Status[j] == 1) nGood++;
104  else if(smdCalib->Status[j] == 0) nEmpty++;
105  else nBad++;
106  }
107  if(!strcmp("bsmdeStatus",table.Data()) || !strcmp("bsmdpStatus",table.Data()))
108  {
109  smdStatus = (smdStatus_st*) dbHandler->getDbTable()->GetTable();
110  for(int j = 0;j<18000;j++)
111  if (smdStatus->Status[j] == 1) nGood++;
112  else if(smdStatus->Status[j] == 0) nEmpty++;
113  else nBad++;
114  }
115  if(!strcmp("bsmdeGain",table.Data()) || !strcmp("bsmdpGain",table.Data()))
116  {
117  smdGain = (smdGain_st*) dbHandler->getDbTable()->GetTable();
118  for(int j = 0;j<18000;j++)
119  if (smdGain->Status[j] == 1) nGood++;
120  else if(smdGain->Status[j] == 0) nEmpty++;
121  else nBad++;
122  }
123  char line[200];
124  sprintf(line," %4d %s Good channels = %4d Empty = %5d BAD = %5d\n",i,list[i].c_str(),nGood,nEmpty,nBad);
125  cout <<line;
126  }
127  cout <<"List size = "<<list.size()<<endl<<endl;
128  cout <<"Type:\n";
129  cout <<" next() for the next plot in the list\n";
130  cout <<" previous() for the previous plot in the list\n";
131  cout <<" plot(i) for the i-entry in the list\n";
132  cout <<" stats() for this statistics\n";
133 }
134 void plot(int I)
135 {
136  if(I>=list.size() || I <0) return;
137  std::string a = list[I];
138  index = I;
139  dbHandler->setTimeStamp(a.c_str());
141  if(!strcmp("bemcPed",table.Data()) || !strcmp("bprsPed",table.Data())) draw((emcPed_st*) dbHandler->getDbTable()->GetTable());
142  if(!strcmp("bemcCalib",table.Data()) || !strcmp("bprsCalib",table.Data())) draw((emcCalib_st*) dbHandler->getDbTable()->GetTable());
143  if(!strcmp("bemcStatus",table.Data()) || !strcmp("bprsStatus",table.Data())) draw((emcStatus_st*) dbHandler->getDbTable()->GetTable());
144  if(!strcmp("bemcGain",table.Data()) || !strcmp("bprsGain",table.Data())) draw((emcGain_st*) dbHandler->getDbTable()->GetTable());
146  if(!strcmp("bsmdePed",table.Data()) || !strcmp("bsmdpPed",table.Data())) draw((smdPed_st*) dbHandler->getDbTable()->GetTable());
147  if(!strcmp("bsmdeCalib",table.Data()) || !strcmp("bsmdpCalib",table.Data())) draw((smdCalib_st*) dbHandler->getDbTable()->GetTable());
148  if(!strcmp("bsmdeStatus",table.Data()) || !strcmp("bsmdpStatus",table.Data())) draw((smdStatus_st*) dbHandler->getDbTable()->GetTable());
149  if(!strcmp("bsmdeGain",table.Data()) || !strcmp("bsmdpGain",table.Data())) draw((smdGain_st*) dbHandler->getDbTable()->GetTable());
151  if(!strcmp("bemcTriggerPed",table.Data())) draw((emcTriggerPed_st*) dbHandler->getDbTable()->GetTable());
152  if(!strcmp("bemcTriggerStatus",table.Data())) draw((emcTriggerStatus_st*) dbHandler->getDbTable()->GetTable());
153  if(!strcmp("bemcTriggerLUT",table.Data())) draw((emcTriggerLUT_st*) dbHandler->getDbTable()->GetTable());
154 
155  cout <<"Type:\n";
156  cout <<" next() for the next plot in the list\n";
157  cout <<" previous() for the previous plot in the list\n";
158  cout <<" plot(i) for the i-entry in the list\n";
159  cout <<" stats() for statistics\n";
160 }
161 void next()
162 {
163  if(list.size()==0) return;
164  index ++;
165  if(index>=list.size()) index = 0;
166  plot(index);
167 }
168 
169 void previous()
170 {
171  if(list.size()==0) return;
172  index --;
173  if(index<0) index = list.size()-1;
174  plot(index);
175 }
StEmcDbHandler()
Class ctor.
std::vector< std::string > getTimeStampList(const char *beginTime, const char *endTime)
StDbTable * getDbTable()