HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
runconfig.cxx
Go to the documentation of this file.
1 //
2 // Demo code for harpo analyse framework in C++ and Root
3 //
4 
5 #include <iostream>
6 #include <stdlib.h>
7 #include <TString.h>
8 
9 #include "HarpoRunConfig.h"
10 
11 int main(int argc, char **argv)
12 {
13  Bool_t found;
14  HarpoRunConfig *info;
15  Long_t run;
16  if (argc == 2) {
17  // Lookup for given run
18  run = atol(argv[1]);
19 
20  info = new HarpoRunConfig;
21  found = info->GetRunConfig(run);
22 
23  std::cout << " --Run " << run << std::endl << "inDataBase = "
24  << std::boolalpha << found
25  << std::noboolalpha << std::endl;
26 
27  if (found) {
28  info->print();
29  }
30  delete info;
31  return 0;
32  }
33 
34  // do tests
35  // Not existing run
36  std::cout << "******** runconfig ************" << std::endl;
37  run = 2;
38 
39  info = new HarpoRunConfig;
40  found = info->GetRunConfig(run);
41 
42  std::cout << std::endl;
43  std::cout << " Run " << run << " found " << found << std::endl;
44  std::cout << std::endl;
45 
46  delete info;
47 
48  std::cout << "******** No Beam ************" << std::endl;
49  run = 1025;
50 
51  info = new HarpoRunConfig;
52  found = info->GetRunConfig(run);
53 
54  std::cout << " Run " << run << " found " << found << std::endl;
55  std::cout << std::endl;
56 
57  if (found) {
58  std::cout << "RunConfig Type of Variable " << std::endl;
59  std::cout << std::endl;
60  info->list();
61  std::cout << "RunConfig Values " << std::endl;
62  std::cout << std::endl;
63  info->print();
64  // single varible which not exist
65  std::cout << "--------------------------------" << std::endl;
66 
67  if (info->Lookup("dummy")) {
68  TString val,type;
69  if (info->GetVal("dummy",val)) {
70  std::cout << "dummy val " << val << std::endl;
71  } else {
72  std::cout << "dummy value not found" << std::endl;
73  }
74 
75  if (info->GetType("dummy",type)) {
76  std::cout << "dummy type " << type << std::endl;
77  } else {
78  std::cout<< "dummy type not found" << std::endl;
79  }
80  }
81  else
82  std::cout << "dummy not found" << std::endl;
83 
84  // Temperature varible
85 
86  if (info->Lookup("Temperature")) {
87  TString val,type;
88  if (info->GetVal("Temperature",val)) {
89  std::cout << "Temperature val " << val << std::endl;
90  } else {
91  std::cout << "Temperature value not found" << std::endl;
92  }
93 
94  if (info->GetType("Temperature",type)) {
95  std::cout << "Temperature type " << type << std::endl;
96  } else {
97  std::cout<< "Temperature type not found" << std::endl;
98  }
99  }
100  else
101  std::cout << "Temperature not found" << std::endl;
102 
103  }
104 
105  delete info;
106 
107  std::cout << "******** In DataBase ************" << std::endl;
108  // Run 1112
109  run = 1675;
110 
111  info = new HarpoRunConfig;
112  found = info->GetRunConfig(run);
113 
114  std::cout << " Run " << run << " found " << found << std::endl;
115  std::cout << std::endl;
116 
117  if (found) {
118  std::cout << "RunConfig Type of Variable " << std::endl;
119  std::cout << std::endl;
120  info->list();
121  std::cout << "RunConfig Values " << std::endl;
122  std::cout << std::endl;
123  info->print();
124  // single varible which not exist
125 
126  std::cout << "--------------------------------" << std::endl;
127  if (info->Lookup("dummy")) {
128  TString val,type;
129  if (info->GetVal("dummy",val)) {
130  std::cout << "dummy val " << val << std::endl;
131  } else {
132  std::cout << "dummy value not found" << std::endl;
133  }
134 
135  if (info->GetType("dummy",type)) {
136  std::cout << "dummy type " << type << std::endl;
137  } else {
138  std::cout<< "dummy type not found" << std::endl;
139  }
140  }
141  else
142  std::cout << "dummy not found" << std::endl;
143 
144  // Temperature varible
145 
146  if (info->Lookup("Temperature")) {
147  TString val,type;
148  if (info->GetVal("Temperature",val)) {
149  std::cout << "Temperature val " << val << std::endl;
150  } else {
151  std::cout << "Temperature value not found" << std::endl;
152  }
153 
154  if (info->GetType("Temperature",type)) {
155  std::cout << "Temperature type " << type << std::endl;
156  } else {
157  std::cout<< "Temperature type not found" << std::endl;
158  }
159  }
160  else
161  std::cout << "Temperature not found" << std::endl;
162 
163  }
164  delete info;
165  std::cout << "******** NSBeam ************" << std::endl;
166  // Run 1112
167  run = 1172;
168 
169  TString db;
170 
171  info = new HarpoRunConfig;
172  db = "";
173  found = info->GetRunConfig(run,&db);
174 
175  std::cout << " Run " << run << " found " << found << std::endl;
176  std::cout << std::endl;
177 
178  if (found) {
179  std::cout << "RunConfig Type of Variable " << std::endl;
180  std::cout << std::endl;
181  info->list();
182  std::cout << "RunConfig Values " << std::endl;
183  std::cout << std::endl;
184  info->print();
185  std::cout << "--------------------------------" << std::endl;
186  // single varible which not exist
187 
188  if (info->Lookup("dummy")) {
189  TString val,type;
190  if (info->GetVal("dummy",val)) {
191  std::cout << "dummy val " << val << std::endl;
192  } else {
193  std::cout << "dummy value not found" << std::endl;
194  }
195 
196  if (info->GetType("dummy",type)) {
197  std::cout << "dummy type " << type << std::endl;
198  } else {
199  std::cout<< "dummy type not found" << std::endl;
200  }
201  }
202  else
203  std::cout << "dummy not found" << std::endl;
204 
205  // LaserElem varible
206 
207  if (info->Lookup("LaserElem")) {
208  TString val,type;
209  if (info->GetVal("LaserElem",val)) {
210  std::cout << "LaserElem val " << val << std::endl;
211  } else {
212  std::cout << "LaserElem value not found" << std::endl;
213  }
214 
215  if (info->GetType("LaserElem",type)) {
216  std::cout << "LaserElem type " << type << std::endl;
217  } else {
218  std::cout<< "LaserElem type not found" << std::endl;
219  }
220  }
221  else
222  std::cout << "LaserElem not found" << std::endl;
223 
224  }
225  delete info;
226 
227 
228  return 0;
229 }
230 
231 
232 
void list()
list all filds found which his types
Bool_t GetRunConfig(Long_t nrun, const TString *dbUrl=NULL)
Query Db for given run Only this function in class interact wich DataBase. Must be called in HarpoRaw...
int main(int argc, char **argv)
Definition: runconfig.cxx:11
Get Run Configuration info by run number. The class query MySQL databe use GetRunConfig Method Only t...
void print()
Print values of all founded fields.
static int type
Bool_t Lookup(const TString field)
Lookup filed exist.
Bool_t GetVal(const TString field, TString &val)
Return value of existing field in Tstring.
Bool_t GetType(const TString field, TString &type)
Return Type of field in Tstring.