FEDRA emulsion software from the OPERA Collaboration
o2root.cpp File Reference
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <TEnv.h>
#include "TOracleServerE2.h"
#include "EdbLog.h"
Include dependency graph for o2root.cpp:

Functions

int main (int argc, char *argv[])
 
void print_help_message ()
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)
42{
43 if (argc < 2) { print_help_message(); return 0; }
44
45 const char *dbname = gEnv->GetValue("o2root.dbname" , "dbname");
46 const char *user = gEnv->GetValue("o2root.username" , "username");
47 const char *password = gEnv->GetValue("o2root.password" , "password");
48 const char *rdb = gEnv->GetValue("o2root.rdb" , "");
49 const char *outdir = gEnv->GetValue("o2root.outdir" , "./");
50 gEDBDEBUGLEVEL = gEnv->GetValue("o2root.EdbDebugLevel" , 1);
51
52 bool do_volume = false;
53 bool do_processoperation = false;
54 bool do_parentprocessoperation = false;
55 bool do_scanback = false;
56 bool do_brickinfo = false;
57 ULong64_t id_volume = 0LL;
58 ULong64_t processoperation = 0LL;
59 ULong64_t parentprocessoperation = 0LL;
60 int major=0;
61 int minor=0;
62
63 Long_t id_brick=0;
64 Int_t path =0;
65
66 for(int i=1; i<argc; i++ ) {
67 char *key = argv[i];
68
69 if (!strncmp(key,"-v=",3))
70 {
71 if(strlen(key)>3) sscanf(key+3,"%lld",&id_volume);
72 do_volume=true;
73 }
74 else if(!strncmp(key,"-p=",3))
75 {
76 if(strlen(key)>3) sscanf(key+3,"%lld",&processoperation);
77 do_processoperation=true;
78 }
79 else if(!strncmp(key,"-P=",3))
80 {
81 if(strlen(key)>3) sscanf(key+3,"%lld",&parentprocessoperation);
82 do_parentprocessoperation=true;
83 }
84 else if(!strncmp(key,"-o=",3))
85 {
86 if(strlen(key)>3) outdir=key+3;
87 }
88 else if(!strncmp(key,"-ma=",4))
89 {
90 if(strlen(key)>4) major=atoi(key+4);
91 }
92 else if(!strncmp(key,"-mi=",4))
93 {
94 if(strlen(key)>4) minor=atoi(key+4);
95 }
96 else if(!strncmp(key,"-rdb=",5))
97 {
98 if(strlen(key)>5) rdb=key+5;
99 }
100 else if(!strncmp(key,"-brick=",7))
101 {
102 if(strlen(key)>7) id_brick=atol(key+7);
103 }
104 else if(!strncmp(key,"-sb=",4))
105 {
106 if(strlen(key)>4) path=atol(key+4);
107 do_scanback=true;
108 }
109 else if(!strncmp(key,"-info",5))
110 {
111 do_brickinfo=true;
112 }
113 }
114
115 if(!(do_volume||do_scanback||do_processoperation||do_parentprocessoperation||do_brickinfo)) { print_help_message(); return 0; }
116
117 TOracleServerE2 *db = new TOracleServerE2(dbname,user,password);
118 if(!db) { Log(1,"o2root","ERROR: the database connection is failed!"); return 0; }
119 db->eRTS=rdb;
120 if(do_volume) {
121 printf("\n----------------------------------------------------------------------------\n");
122 printf("Read volume: \t\t\t%lld \nfrom the database: \t\t%s%s \nand save into directory: \t%s \nwith versions: \t\t\t%d.%d\n",
123 id_volume, dbname, rdb, outdir, major,minor);
124 printf("----------------------------------------------------------------------------\n\n");
125 db->ConvertMicrotracksVolumeToEdb(id_volume, outdir, major, minor);
126 }
127 if(do_processoperation) {
128 printf("\n----------------------------------------------------------------------------\n");
129 printf("Read processoperation: \t\t\t%lld \nfrom the database: \t\t%s%s \nand save into directory: \t%s \nwith versions: \t\t\t%d.%d\n",
130 processoperation, dbname, rdb, outdir, major,minor);
131 printf("----------------------------------------------------------------------------\n\n");
132 db->ConvertMicrotracksProcessToEdb(processoperation, outdir, major, minor);
133 }
134 if(do_parentprocessoperation) {
135 printf("\n----------------------------------------------------------------------------\n");
136 printf("Read parentprocessoperation: \t\t\t%lld \nfrom the database: \t\t%s%s \nand save into directory: \t%s \nwith versions: \t\t\t%d.%d\n",
137 parentprocessoperation, dbname, rdb, outdir, major,minor);
138 printf("----------------------------------------------------------------------------\n\n");
139 db->ConvertMicrotracksParentProcessToEdb(parentprocessoperation, outdir, major, minor);
140 }
141 if(do_scanback) {
142 printf("\n----------------------------------------------------------------------------\n");
143 printf("Read scanback path: \t\t%d of brick %ld \nfrom the database: \t\t%s%s \nand save into directory: \t%s \nwith versions: \t\t\t%d.%d\n",
144 path, id_brick, dbname, rdb, outdir, major,minor);
145 printf("----------------------------------------------------------------------------\n\n");
146 db->ConvertScanbackPathToEdb(id_brick, path, outdir, major, minor);
147 }
148 if(do_brickinfo) {
149 printf("\n---------------------------------------------------------------------------------------------\n");
150 printf("Print info for brick: \t%ld from the database: \t\t%s%s\n",
151 id_brick, dbname, rdb);
152 printf("---------------------------------------------------------------------------------------------\n");
153 db->PrintBrickInfoFull(id_brick,0);
154 }
155 delete db;
156 return 1;
157}
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
Definition: TOracleServerE2.h:13
const char * outdir
Definition: emrec.cpp:37
gEDBDEBUGLEVEL
Definition: energy.C:7
TOracleServerE * db
Definition: test_oracle.C:8
void print_help_message()
Definition: o2root.cpp:12

◆ print_help_message()

void print_help_message ( )
13{
14 cout<< "\nUsage: \n\t o2root -v=VOLUME [-ma=MAJOR -mi=MINOR -o=OUTDIR -rdb=RDB] \n";
15 cout<< "\t o2root -p=PROCESSOPERATION [-ma=MAJOR -mi=MINOR -o=OUTDIR -rdb=RDB] \n";
16 cout<< "\t o2root -P=PARENTPROCESSOPERATION [-ma=MAJOR -mi=MINOR -o=OUTDIR -rdb=RDB] \n";
17 cout<< "\t o2root -sb=PATH -brick=BRICK [-ma=MAJOR -mi=MINOR -o=OUTDIR -rdb=RDB] \n";
18 cout<< "\t o2root -brick=BRICK -info \n\n";
19 cout<< "\t\t VOLUME - volume id as stored in database \n";
20 cout<< "\t\t PATH - the scanback path id \n";
21 cout<< "\t\t BRICK - the brick ID (if scanback path should be extracted)\n";
22 cout<< "\t\t MAJOR - major version (default is 0)\n";
23 cout<< "\t\t MINOR - minor version (default is 0)\n";
24 cout<< "\t\t OUTDIR - output directory - should exist and be writable (default is ./)\n";
25 cout<< "\t\t RDB - link to the remote database (default is \"\")\n";
26 cout<< "\nExample: \n";
27 cout<< "\t o2root -v=7000000000360012 -ma=20 -mi=10 -o=/scratch/BRICKS \n";
28 cout<< "\n\t the output of this example will be stored in the root files named as: \n";
29 cout<< "\t\t /scratch/BRICKS/b1029351/p042/1029351.42.20.10.raw.root\n";
30 cout<< "\t\t /scratch/BRICKS/b1029351/p043/1029351.43.20.10.raw.root\n";
31 cout<< "\t\t /scratch/BRICKS/b1029351/ ....\n";
32 cout<< "\nThe database connection parameters if not explicitly defined will be taken from .rootrc as: \n";
33 cout<< "\t o2root.dbname: oracle://my_server/my_database_service \n";
34 cout<< "\t o2root.username: db_username \n";
35 cout<< "\t o2root.password: db_password \n";
36 cout<< "\t o2root.rdb: @opita <- (define it if you connect via remote db link)\n";
37 cout<< "\t o2root.outdir: /scratch/BRICKS \n";
38 cout<<endl;
39}