35 |
printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
36 |
printf("\n -user username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n"); |
printf("\n -user username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n"); |
37 |
printf("\n -psw password for the DB [default = $PAM_DBPSW or \"\"]\n"); |
printf("\n -psw password for the DB [default = $PAM_DBPSW or \"\"]\n"); |
38 |
printf("\n -convert [ -tzone timezone -dbtime dbtime ] \n"); |
printf("\n -tzone timezone the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n"); |
39 |
printf("\n convert the dbtime given in seconds (from the DB) to a string for\n"); |
printf("\n -convert dbtime convert the dbtime given in seconds (from the DB) to a string\n"); |
40 |
printf("\n the given time zone (UTC,GMT,MSK,MSD,CET,CEST are accepted) \n"); |
printf("\n -runat time returns run number which contains the given date,\n"); |
41 |
printf("\n -runat [ -tzone timezone -time \"yyyy-mm-dd hh:mm:ss\" ] \n"); |
printf("\n for time use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n"); |
|
printf("\n returns run number which contains the given date in the given time zone \n"); |
|
42 |
printf("\nExamples: \n"); |
printf("\nExamples: \n"); |
43 |
printf("\n R2-D2 -idRun 1085 \n"); |
printf("\n R2-D2 -idRun 1085 \n"); |
44 |
printf("\n R2-D2 -filename DW_050208_00900.root \n"); |
printf("\n R2-D2 -filename DW_050208_00900.root \n"); |
66 |
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
67 |
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
68 |
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
69 |
|
if ( !pamdbhost ) pamdbhost = ""; |
70 |
|
if ( !pamdbuser ) pamdbuser = ""; |
71 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
72 |
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
73 |
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
74 |
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
75 |
// |
// |
76 |
printf(" host %s user %s psw %s \n",host.Data(),user.Data(),psw.Data()); |
// printf(" host %s user %s psw %s \n",host.Data(),user.Data(),psw.Data()); |
77 |
// |
// |
78 |
TString tzone = "MSK"; |
TString tzone = "MSK"; |
|
TString tzone2 = "MSK"; |
|
79 |
TString runtime = "1970-01-01 00:00:00"; |
TString runtime = "1970-01-01 00:00:00"; |
80 |
UInt_t dbti = 0; |
UInt_t dbti = 0; |
81 |
Bool_t convert = false; |
Bool_t convert = false; |
136 |
psw = (TString)inps[i+1]; |
psw = (TString)inps[i+1]; |
137 |
}; |
}; |
138 |
// |
// |
139 |
|
if ( !strcmp(inps[i],"-tzone") ) { |
140 |
|
if ( numinp-1 < i+1 ){ |
141 |
|
r2d2usage(); |
142 |
|
exit(-3); |
143 |
|
}; |
144 |
|
tzone = (TString)inps[i+1]; |
145 |
|
}; |
146 |
|
// |
147 |
if ( !strcmp(inps[i],"-convert") ) { |
if ( !strcmp(inps[i],"-convert") ) { |
148 |
convert = true; |
convert = true; |
149 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp-1 < i+1 ){ |
150 |
if ( numinp < i+2 ){ |
r2d2usage(); |
151 |
r2d2usage(); |
exit(-3); |
|
throw -3; |
|
|
}; |
|
|
i += 2; |
|
|
while ( strcmp(inps[i],"]") ){ |
|
|
if ( !strcmp(inps[i],"-tzone") ) { |
|
|
if ( numinp-1 < i+1 ){ |
|
|
r2d2usage(); |
|
|
exit(-3); |
|
|
}; |
|
|
tzone = (TString)inps[i+1]; |
|
|
}; |
|
|
if ( !strcmp(inps[i],"-dbtime") ) { |
|
|
if ( numinp-1 < i+1 ){ |
|
|
r2d2usage(); |
|
|
exit(-3); |
|
|
}; |
|
|
dbti = (UInt_t)atoll(inps[i+1]); |
|
|
}; |
|
|
i++; |
|
|
if ( i > numinp-1 ){ |
|
|
r2d2usage(); |
|
|
throw -3; |
|
|
}; |
|
|
}; |
|
152 |
}; |
}; |
153 |
|
dbti = (UInt_t)atoll(inps[i+1]); |
154 |
}; |
}; |
155 |
// |
// |
156 |
if ( !strcmp(inps[i],"-runat") ) { |
if ( !strcmp(inps[i],"-runat") ) { |
157 |
ruti = true; |
ruti = true; |
158 |
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
if ( numinp-1 < i+1 ){ |
159 |
if ( numinp < i+2 ){ |
r2d2usage(); |
160 |
r2d2usage(); |
exit(-3); |
|
throw -3; |
|
|
}; |
|
|
i += 2; |
|
|
while ( strcmp(inps[i],"]") ){ |
|
|
if ( !strcmp(inps[i],"-tzone") ) { |
|
|
if ( numinp-1 < i+1 ){ |
|
|
r2d2usage(); |
|
|
exit(-3); |
|
|
}; |
|
|
tzone2 = (TString)inps[i+1]; |
|
|
}; |
|
|
if ( !strcmp(inps[i],"-time") ) { |
|
|
if ( numinp-1 < i+1 ){ |
|
|
r2d2usage(); |
|
|
exit(-3); |
|
|
}; |
|
|
runtime = (TString)inps[i+1]; |
|
|
}; |
|
|
i++; |
|
|
if ( i > numinp-1 ){ |
|
|
r2d2usage(); |
|
|
throw -3; |
|
|
}; |
|
|
}; |
|
161 |
}; |
}; |
162 |
|
runtime = (TString)inps[i+1]; |
163 |
}; |
}; |
164 |
// |
// |
165 |
i++; |
i++; |
192 |
// At which date correspond the DB time "dbti"? |
// At which date correspond the DB time "dbti"? |
193 |
// |
// |
194 |
if ( convert ){ |
if ( convert ){ |
195 |
printf("\n DB time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone.Data(),dbti).Data(),tzone.Data()); |
printf("\n DB time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone,dbti).Data(),tzone.Data()); |
196 |
}; |
}; |
197 |
// |
// |
198 |
// Which run contains the date "runtime"? |
// Which run contains the date "runtime"? |
202 |
TDatime *time = new TDatime(runtime.Data()); |
TDatime *time = new TDatime(runtime.Data()); |
203 |
UInt_t dbti = time->Convert(); |
UInt_t dbti = time->Convert(); |
204 |
// |
// |
205 |
TString thetime = dbtime->UnConvertTime(tzone2.Data(),dbti); |
TString thetime = dbtime->UnConvertTime(tzone,dbti); |
206 |
// |
// |
207 |
TDatime *time2 = new TDatime(thetime.Data()); |
TDatime *time2 = new TDatime(thetime.Data()); |
208 |
UInt_t mytime = time2->Convert(); |
UInt_t mytime = time2->Convert(); |
217 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
218 |
Row = pResult->Next(); |
Row = pResult->Next(); |
219 |
if ( !r && !Row ){ |
if ( !r && !Row ){ |
220 |
printf("\n No run contains date %s %s (DB time %u )\n",runtime.Data(),tzone2.Data(),mytime); |
printf("\n No run contains date %s %s (DB time %u )\n",runtime.Data(),tzone.Data(),mytime); |
221 |
}; |
}; |
222 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
223 |
printf("\n Date %s %s (DB time %u ) is contained in run %u \n",runtime.Data(),tzone2.Data(),mytime,(UInt_t)atoll(Row->GetField(0))); |
printf("\n Date %s %s (DB time %u ) is contained in run %u \n",runtime.Data(),tzone.Data(),mytime,(UInt_t)atoll(Row->GetField(0))); |
224 |
}; |
}; |
225 |
}; |
}; |
226 |
// |
// |
231 |
error = glrun->Query_GL_RUN(run,dbc); |
error = glrun->Query_GL_RUN(run,dbc); |
232 |
glroot->Clear(); |
glroot->Clear(); |
233 |
error = glroot->Query_GL_ROOT(glrun->ID_ROOT_L0,dbc); |
error = glroot->Query_GL_ROOT(glrun->ID_ROOT_L0,dbc); |
234 |
if ( error ){ |
if ( !glrun->ID_ROOT_L0 ){ |
|
printf(" Error querying the DB! \n"); |
|
|
exit(-4); |
|
|
}; |
|
|
if ( !glrun->ID ){ |
|
235 |
printf("\n No run with ID=%u in the DB!\n",run); |
printf("\n No run with ID=%u in the DB!\n",run); |
236 |
} else { |
} else { |
237 |
|
if ( error ){ |
238 |
|
printf(" Error querying the DB! \n"); |
239 |
|
exit(-4); |
240 |
|
}; |
241 |
printf("\n Run %u belongs to file %s \n",run,(glroot->PATH+glroot->NAME).Data()); |
printf("\n Run %u belongs to file %s \n",run,(glroot->PATH+glroot->NAME).Data()); |
242 |
}; |
}; |
243 |
}; |
}; |
284 |
}; |
}; |
285 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
286 |
if ( !r ) printf("\n File %s contains the following runs: \n\n",filename.Data()); |
if ( !r ) printf("\n File %s contains the following runs: \n\n",filename.Data()); |
287 |
printf(" => ID = %i _-_-_ the run started at %s UTC ended at %s UTC \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime("UTC",(UInt_t)atoll(Row->GetField(1))).Data(),dbtime->ConvertTime("UTC",(UInt_t)atoll(Row->GetField(2))).Data()); |
TString UTC="UTC"; |
288 |
|
printf(" => ID = %i _-_-_ the run started at %s UTC ended at %s UTC \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(1))).Data(),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(2))).Data()); |
289 |
}; |
}; |
290 |
delete pResult; |
delete pResult; |
291 |
myquery.str(""); |
myquery.str(""); |