HARPO  5.1.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
getRunConfig.cxx
Go to the documentation of this file.
1 #include "HarpoRunConfig.h"
2 
3 #include <iostream>
4 #include <cstdlib>
5 
6 using namespace std;
7 
8 int main(int argc, char **argv)
9 {
10  Int_t run = 1111;
11 
12  Bool_t all = kFALSE, verbose = kFALSE;
13  Char_t field[128];
14 
15  for(int i = 1; i<argc; i++){
16  switch(argv[i][0]){
17  case '-':
18  switch(argv[i][1]){
19  case 'h':
20  printf("Access run configuration from database\n");
21  printf("-r <int>: run number\n");
22  printf("-f <str>: field\n");
23  printf("-a: show all available fields\n");
24  return 0;
25  case 'r':
26  i++;
27  run = strtol(argv[i],NULL,0);
28  break;
29  case 'f':
30  i++;
31  sprintf(field,"%s",argv[i]);
32  break;
33  case 'a':
34  all = kTRUE;
35  break;
36  case 'v':
37  verbose = kTRUE;
38  break;
39  default:
40  printf("unknown option: %s\n", argv[i]);
41  return 0;
42  }
43  break;
44  default:
45  printf("invalid parameter: %s\n", argv[i]);
46  return 0;
47  }
48  }
49 
50 
51  HarpoRunConfig* info = new HarpoRunConfig();
52  Bool_t found;
53  found = info->GetRunConfig(run);
54  if(!found) return 0;
55  if(all){
56  cout << "Available fields:" << endl;
57  cout << "------------------------------" << endl;
58  info->list();
59  }
60 
61 
62 
63  TString val,type;
64 
65  if (verbose ) cout << "Lookup for " << field << endl;
66 
67  if(info->GetVal(field,val))
68  cout << val.Data() << endl;
69  else
70  cout << "Field " << field << " not available" << endl;
71  return 0;
72 }
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...
Get Run Configuration info by run number. The class query MySQL databe use GetRunConfig Method Only t...
int main(int argc, char **argv)
Definition: getRunConfig.cxx:8
static int type
Bool_t GetVal(const TString field, TString &val)
Return value of existing field in Tstring.