| 20 |
void usage(){ |
void usage(){ |
| 21 |
printf("\nUsage:\n"); |
printf("\nUsage:\n"); |
| 22 |
printf("\n MyDetector2Level2 [-v] [-h] [--version] -idRun ID_RUN [-processFile filename] [-processFolder folder]\n"); |
printf("\n MyDetector2Level2 [-v] [-h] [--version] -idRun ID_RUN [-processFile filename] [-processFolder folder]\n"); |
| 23 |
|
printf("\n [-host host] [-user username] [-psw password]\n"); |
| 24 |
printf("\n --version print informations about compilation and exit\n"); |
printf("\n --version print informations about compilation and exit\n"); |
| 25 |
printf("\n -h | --help print this help and exit \n"); |
printf("\n -h | --help print this help and exit \n"); |
| 26 |
printf("\n -v | --verbose be verbose [default: print nothing on STDOUT]\n"); |
printf("\n -v | --verbose be verbose [default: print nothing on STDOUT]\n"); |
| 27 |
printf("\n -idRun ID_RUN: ID number of the run to be processed \n"); |
printf("\n -idRun ID_RUN: ID number of the run to be processed \n"); |
| 28 |
printf("\n -processFile filename : output filename [default ID_RUN.Level2.root]\n"); |
printf("\n -processFile filename : output filename [default ID_RUN.Level2.root]\n"); |
| 29 |
printf("\n -processFolder not used [default \"\"]\n"); |
printf("\n -processFolder default \"mydetector2Folder\"\n"); |
| 30 |
|
printf("\n -host name for the host [default = mysql://localhost/pamelaprod]\n"); |
| 31 |
|
printf("\n -user username for the DB [default = anonymous] \n"); |
| 32 |
|
printf("\n -psw password for the DB [default = \"\"]\n"); |
| 33 |
printf("\n Notice that parameter order does not matter. \n"); |
printf("\n Notice that parameter order does not matter. \n"); |
| 34 |
printf("\nExample: \n\nMyDetector2Level2 -idRun 1085 -processFile nomefile.root\n\n"); |
printf("\nExample: \n\nMyDetector2Level2 -idRun 1085 -processFile nomefile.root\n\n"); |
| 35 |
}; |
}; |
| 36 |
// |
// |
| 37 |
|
bool debug = false; |
| 38 |
|
// |
| 39 |
// Here the main |
// Here the main |
| 40 |
// |
// |
| 41 |
int main(int numinp, char *inps[]){ |
int main(int numinp, char *inps[]){ |
| 49 |
TString filename; |
TString filename; |
| 50 |
TSQLServer *dbc = 0; |
TSQLServer *dbc = 0; |
| 51 |
Bool_t givenid = false; |
Bool_t givenid = false; |
| 52 |
|
TString processFolder = "mydetector2Folder"; |
| 53 |
|
// |
| 54 |
|
TString host = "mysql://localhost/pamelaprod"; |
| 55 |
|
TString user = "anonymous"; |
| 56 |
|
TString psw = ""; |
| 57 |
// |
// |
| 58 |
// Checking input parameters |
// Checking input parameters |
| 59 |
// |
// |
| 68 |
exit(0); |
exit(0); |
| 69 |
}; |
}; |
| 70 |
if ( !strcmp(inps[i],"-idRun") ) { |
if ( !strcmp(inps[i],"-idRun") ) { |
| 71 |
if ( numinp-1 < i+1 ) exit(-3); |
if ( numinp-1 < i+1 ){ |
| 72 |
|
usage(); |
| 73 |
|
exit(-3); |
| 74 |
|
}; |
| 75 |
givenid = true; |
givenid = true; |
| 76 |
char *pEnd; |
char *pEnd; |
| 77 |
run = strtoull(inps[i+1],&pEnd,0); |
run = strtoull(inps[i+1],&pEnd,0); |
| 78 |
}; |
}; |
| 79 |
if ( !strcmp(inps[i],"-processFile") ) { |
if ( !strcmp(inps[i],"-processFile") ) { |
| 80 |
if ( numinp-1 < i+1 ) exit(-3); |
if ( numinp-1 < i+1 ){ |
| 81 |
|
usage(); |
| 82 |
|
exit(-3); |
| 83 |
|
}; |
| 84 |
filename = (TString)inps[i+1]; |
filename = (TString)inps[i+1]; |
| 85 |
}; |
}; |
| 86 |
|
if ( !strcmp(inps[i],"-processFolder") ) { |
| 87 |
|
if ( numinp-1 < i+1 ){ |
| 88 |
|
usage(); |
| 89 |
|
exit(-3); |
| 90 |
|
}; |
| 91 |
|
processFolder = (TString)inps[i+1]; |
| 92 |
|
}; |
| 93 |
|
if ( !strcmp(inps[i],"-host") ) { |
| 94 |
|
if ( numinp-1 < i+1 ){ |
| 95 |
|
usage(); |
| 96 |
|
exit(-3); |
| 97 |
|
}; |
| 98 |
|
host = (TString)inps[i+1]; |
| 99 |
|
}; |
| 100 |
|
if ( !strcmp(inps[i],"-user") ) { |
| 101 |
|
if ( numinp-1 < i+1 ){ |
| 102 |
|
usage(); |
| 103 |
|
exit(-3); |
| 104 |
|
}; |
| 105 |
|
user = (TString)inps[i+1]; |
| 106 |
|
}; |
| 107 |
|
if ( !strcmp(inps[i],"-psw") ) { |
| 108 |
|
if ( numinp-1 < i+1 ){ |
| 109 |
|
usage(); |
| 110 |
|
exit(-3); |
| 111 |
|
}; |
| 112 |
|
psw = (TString)inps[i+1]; |
| 113 |
|
}; |
| 114 |
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; |
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; |
| 115 |
}; |
}; |
| 116 |
} else { |
} else { |
| 146 |
// |
// |
| 147 |
printf("\nConnecting to database... \n"); |
printf("\nConnecting to database... \n"); |
| 148 |
// |
// |
| 149 |
dbc = TSQLServer::Connect("mysql://localhost/pamelaprod","anonymous",""); |
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
| 150 |
if( !dbc ) { |
if( !dbc ) { |
| 151 |
printf(" MYDETECTOR2 - ERROR: problems connecting to the DB (check username and passwd), exiting...\n\n"); |
printf(" MYDETECTOR2 - ERROR: problems connecting to the DB (check username and passwd), exiting...\n\n"); |
| 152 |
exit(-2); |
exit(-2); |
| 161 |
// |
// |
| 162 |
// Run the core program, put any output error in the "error" variable |
// Run the core program, put any output error in the "error" variable |
| 163 |
// |
// |
| 164 |
error = MyDect2Core(run,filename,dbc); |
error = MyDect2Core(run,filename,processFolder,dbc); |
| 165 |
// |
// |
| 166 |
// Close the DB connection |
// Close the DB connection |
| 167 |
// |
// |