1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Daniela Dorner, 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
19 | ! Author(s): Thomas Bretz, 08/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2008
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 | //
|
---|
28 | // filldotrun.C
|
---|
29 | // ============
|
---|
30 | //
|
---|
31 | // This macro is used in the datacenter to automatically fill the run-database
|
---|
32 | // with the information stored in the .run-files written by the central
|
---|
33 | // control.
|
---|
34 | //
|
---|
35 | // To following Arehucas versions are Currently supported:
|
---|
36 | // 040505-0, 040514-0,
|
---|
37 | // 040518-0, 040727-0,
|
---|
38 | // 041113-0, 041209-0, 041221-0
|
---|
39 | // 050224-0, 050317-0, 050322-0, 050401-0, 050413-0, 050415-0, 050714-0,
|
---|
40 | // 050719-0, 050829-0, 051025-0,
|
---|
41 | // 060330-0, 060401-0, 060808-0
|
---|
42 | // 070416-0,
|
---|
43 | // 080220-0
|
---|
44 | // 080519-0
|
---|
45 | //
|
---|
46 | // Usage:
|
---|
47 | // .x filldotrun.C+("/data/MAGIC/Period019/ccdata", kTRUE)
|
---|
48 | //
|
---|
49 | // While the first argument is the directory in which all subdirectories where
|
---|
50 | // searches for CC_*.run files. All these files were analysed and the run
|
---|
51 | // info will be put into the DB, eg:
|
---|
52 | // "/magic/subsystemdata/cc" would do it for all data
|
---|
53 | // "/magic/subsystemdata/cc/2005" for one year
|
---|
54 | // "/magic/subsystemdata/cc/2005/11" for one month
|
---|
55 | // "/magic/subsystemdata/cc/2005/11/11" for a single day
|
---|
56 | // "/magic/subsystemdata/cc/2005/11/11/file.run" for a single file
|
---|
57 | //
|
---|
58 | // The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
|
---|
59 | // switched on and nothing will be written into the database. Instead
|
---|
60 | // informations about the subtables are displayed. This is usefull for tests
|
---|
61 | // when adding a new arehucas version support. If it is kFALSE the information
|
---|
62 | // are written into the subtables and the runs info is written into the
|
---|
63 | // rundatabase.
|
---|
64 | //
|
---|
65 | // In the automatic case it makes sense to check the logfiles to make sure
|
---|
66 | // that everything is fine...
|
---|
67 | //
|
---|
68 | // Make sure, that database and password are corretly set in a resource
|
---|
69 | // file called sql.rc and the resource file is found.
|
---|
70 | //
|
---|
71 | // Remark: Running it from the commandline looks like this:
|
---|
72 | // root -q -l -b filldotrun.C+\(\"path\"\,kFALSE\) 2>&1 | tee filldotrun.log
|
---|
73 | //
|
---|
74 | // Returns 0 in case of failure and 1 in case of success.
|
---|
75 | //
|
---|
76 | /////////////////////////////////////////////////////////////////////////////
|
---|
77 | #include <iostream>
|
---|
78 | #include <iomanip>
|
---|
79 | #include <fstream>
|
---|
80 |
|
---|
81 | #include <TMath.h>
|
---|
82 | #include <TRegexp.h>
|
---|
83 |
|
---|
84 | #include "MTime.h"
|
---|
85 | #include "MDirIter.h"
|
---|
86 | #include "MSQLMagic.h"
|
---|
87 |
|
---|
88 | using namespace std;
|
---|
89 |
|
---|
90 |
|
---|
91 | Int_t insert(MSQLMagic &serv, Bool_t dummy, TString filename)
|
---|
92 | {
|
---|
93 | ifstream fin(filename);
|
---|
94 | if (!fin)
|
---|
95 | {
|
---|
96 | cout << "Could not open file " << filename << endl;
|
---|
97 | return -1;
|
---|
98 | }
|
---|
99 |
|
---|
100 | TString strng;
|
---|
101 | strng.ReadLine(fin);
|
---|
102 | if (strng!=TString("[CC Plain Run Summary File]"))
|
---|
103 | {
|
---|
104 | cout << filename << ": No Plain Run Summary File" << endl;
|
---|
105 | cout << "First Line: " << strng << endl;
|
---|
106 | cout << endl;
|
---|
107 | return -1;
|
---|
108 | }
|
---|
109 |
|
---|
110 | strng.ReadLine(fin);
|
---|
111 | TRegexp reg("[0-9][0-9][0-9][0-9][0-9][0-9]-[0-9]");
|
---|
112 | TString arehucas = strng(reg);
|
---|
113 | arehucas.Prepend("20");
|
---|
114 | arehucas.ReplaceAll("-", "");
|
---|
115 |
|
---|
116 | Int_t version = atoi(arehucas.Data());
|
---|
117 | if (version!=200405050 && version!=200405140 && version!=200405180 &&
|
---|
118 | version!=200407270 && version!=200411130 && version!=200412090 &&
|
---|
119 | version!=200412210 &&
|
---|
120 | version!=200502240 && version!=200503170 && version!=200503220 &&
|
---|
121 | version!=200504010 && version!=200504130 && version!=200504150 &&
|
---|
122 | version!=200507140 && version!=200507190 && version!=200508290 &&
|
---|
123 | version!=200510250 &&
|
---|
124 | version!=200603300 && version!=200604010 && version!=200608080 &&
|
---|
125 | version!=200704160 &&
|
---|
126 | version!=200802200 &&
|
---|
127 | version!=200805190)
|
---|
128 | {
|
---|
129 | cout << filename << ": File Version unknown - please update the macro!" << endl;
|
---|
130 | cout << "Second Line: " << strng << endl;
|
---|
131 | cout << endl;
|
---|
132 | return -1;
|
---|
133 | }
|
---|
134 |
|
---|
135 | cout << " V" << version << " " << flush;
|
---|
136 |
|
---|
137 | Int_t cnt=0;
|
---|
138 | while (1)
|
---|
139 | {
|
---|
140 | Int_t telnumber = 1; // FIXME: "NULL"?
|
---|
141 | if (version >=200805190)
|
---|
142 | {
|
---|
143 | strng.ReadToDelim(fin, ' ');
|
---|
144 | if (!fin)
|
---|
145 | break;
|
---|
146 | if (strng[0]!='M')
|
---|
147 | {
|
---|
148 | cout << "First character is not an M." << endl;
|
---|
149 | cout << strng << endl;
|
---|
150 | strng.ReadLine(fin);
|
---|
151 | continue;
|
---|
152 | }
|
---|
153 | if (strng[1]!='1')
|
---|
154 | {
|
---|
155 | cout << "Only MAGIC 1 implemented so far." << endl;
|
---|
156 | cout << strng << endl;
|
---|
157 | strng.ReadLine(fin);
|
---|
158 | continue;
|
---|
159 | }
|
---|
160 |
|
---|
161 | telnumber = atoi(strng.Data()+1);
|
---|
162 | }
|
---|
163 |
|
---|
164 | // ========== Col 1: Run Number =========
|
---|
165 | //Reading the line
|
---|
166 | //and converting some strings to ints/floats
|
---|
167 | strng.ReadToDelim(fin, ' ');
|
---|
168 | if (!fin)
|
---|
169 | break;
|
---|
170 |
|
---|
171 | Int_t runnumber = atoi(strng.Data());
|
---|
172 |
|
---|
173 | //runnumber=0 means no valid dataset
|
---|
174 | //-> continue
|
---|
175 | if (runnumber == 0)
|
---|
176 | {
|
---|
177 | strng.ReadLine(fin);
|
---|
178 | cout << "Runnumber == 0" << endl;
|
---|
179 | continue;
|
---|
180 | }
|
---|
181 |
|
---|
182 | Int_t filenumber = 0; // FIXME: "NULL"?
|
---|
183 | if (version >=200805190)
|
---|
184 | {
|
---|
185 | strng.ReadToDelim(fin, ' ');
|
---|
186 | filenumber = atoi(strng.Data());
|
---|
187 | }
|
---|
188 |
|
---|
189 | TString where = Form("((fTelescopeNumber=%d AND fFileNumber=%d) OR"
|
---|
190 | "(ISNULL(fTelescopeNumber) AND ISNULL(fFileNumber)))",
|
---|
191 | telnumber, filenumber);
|
---|
192 | if (serv.ExistStr("fRunNumber", "RunData", strng, where))
|
---|
193 | {
|
---|
194 | // FIXME: Maybe we can implement a switch to update mode?
|
---|
195 | cout << "Entry M" << telnumber << ":" << runnumber << "/" << filenumber << " already existing... skipped." << endl;
|
---|
196 | strng.ReadLine(fin);
|
---|
197 | continue;
|
---|
198 | }
|
---|
199 |
|
---|
200 | // ========== Col 2: Run Type =========
|
---|
201 | strng.ReadToDelim(fin, ' ');
|
---|
202 | if (strng.Contains("???"))
|
---|
203 | strng="n/a";
|
---|
204 |
|
---|
205 | Int_t runtype = serv.QueryKeyOfName("RunType", strng, kFALSE);
|
---|
206 | if (runtype<0)
|
---|
207 | {
|
---|
208 | cout << "ERROR - RunType " << strng << " not available." << endl;
|
---|
209 | strng.ReadLine(fin);
|
---|
210 | continue;
|
---|
211 | }
|
---|
212 |
|
---|
213 | //cout << runtype << " ";
|
---|
214 |
|
---|
215 | // ========== Col 3,4: Start Time =========
|
---|
216 | TString startdate, starttime;
|
---|
217 | startdate.ReadToDelim(fin, ' ');
|
---|
218 | starttime.ReadToDelim(fin, ' ');
|
---|
219 | //cout << startdate << " " << starttime << " ";
|
---|
220 |
|
---|
221 | // ========== Col 5,6: Stop Time =========
|
---|
222 | TString stopdate, stoptime;
|
---|
223 | stopdate.ReadToDelim(fin, ' ');
|
---|
224 | stoptime.ReadToDelim(fin, ' ');
|
---|
225 | //cout << stopdate << " " << stoptime << " ";
|
---|
226 |
|
---|
227 | if (startdate.Contains("???"))
|
---|
228 | startdate="0000-00-00";
|
---|
229 | if (starttime.Contains("???"))
|
---|
230 | starttime="00:00:00";
|
---|
231 | if (stopdate.Contains("???"))
|
---|
232 | stopdate="0000-00-00";
|
---|
233 | if (stoptime.Contains("???"))
|
---|
234 | stoptime="00:00:00";
|
---|
235 |
|
---|
236 | // ========== Col 7: Source Name =========
|
---|
237 | strng.ReadToDelim(fin, ' ');
|
---|
238 | if (strng.Contains("???"))
|
---|
239 | strng="Unavailable";
|
---|
240 |
|
---|
241 | Int_t sourcekey = serv.QueryKeyOfName("Source", strng.Data());
|
---|
242 | if (sourcekey<0)
|
---|
243 | {
|
---|
244 | strng.ReadLine(fin);
|
---|
245 | continue;
|
---|
246 | }
|
---|
247 | //cout << sourcekey << " ";
|
---|
248 |
|
---|
249 | // ========== Col 8,9: Local source position =========
|
---|
250 | strng.ReadToDelim(fin, ' ');
|
---|
251 | Float_t zd = atof(strng.Data());
|
---|
252 |
|
---|
253 | strng.ReadToDelim(fin, ' ');
|
---|
254 | Float_t az = atof(strng.Data());
|
---|
255 |
|
---|
256 | //cout << zd << " " << az << " ";
|
---|
257 |
|
---|
258 | // ========== Col 10: Number of Events =========
|
---|
259 | strng.ReadToDelim(fin, ' ');
|
---|
260 | Int_t evtno = atoi(strng.Data());
|
---|
261 |
|
---|
262 | //cout << evtno << " ";
|
---|
263 |
|
---|
264 | // ========== Col 11: Project Name =========
|
---|
265 | strng.ReadToDelim(fin, ' ');
|
---|
266 | if (strng.Contains("???"))
|
---|
267 | strng="Unavailable";
|
---|
268 |
|
---|
269 | Int_t projkey = serv.QueryKeyOfName("Project", strng);
|
---|
270 | if (projkey<0)
|
---|
271 | {
|
---|
272 | strng.ReadLine(fin);
|
---|
273 | continue;
|
---|
274 | }
|
---|
275 | //cout << projkey << " ";
|
---|
276 |
|
---|
277 | // ========== Col 12: Trigger Table Name =========
|
---|
278 | // starting from version 200411130: Col 12,13: Trigger Table Name =========
|
---|
279 | strng.ReadToDelim(fin, ' ');
|
---|
280 | if (strng.Contains("???"))
|
---|
281 | strng="n/a";
|
---|
282 |
|
---|
283 | Int_t l1triggerkey=1;
|
---|
284 | Int_t l2triggerkey=1;
|
---|
285 | if (version >=200411130)
|
---|
286 | {
|
---|
287 | l1triggerkey = serv.QueryKeyOfName("L1TriggerTable", strng);
|
---|
288 | if (l1triggerkey<0)
|
---|
289 | {
|
---|
290 | strng.ReadLine(fin);
|
---|
291 | continue;
|
---|
292 | }
|
---|
293 |
|
---|
294 | strng.ReadToDelim(fin, ' ');
|
---|
295 | if (strng.Contains("???"))
|
---|
296 | strng="n/a";
|
---|
297 |
|
---|
298 | l2triggerkey = serv.QueryKeyOfName("L2TriggerTable", strng);
|
---|
299 | if (l2triggerkey<0)
|
---|
300 | {
|
---|
301 | strng.ReadLine(fin);
|
---|
302 | continue;
|
---|
303 | }
|
---|
304 | }
|
---|
305 | else
|
---|
306 | {
|
---|
307 | Int_t c=0;
|
---|
308 |
|
---|
309 | if (strng.Contains(":"))
|
---|
310 | c=1;
|
---|
311 |
|
---|
312 | if (strng.Contains("L1_") && !(strng.Contains(":")))
|
---|
313 | c=2;
|
---|
314 |
|
---|
315 | if (strng.Contains("n/a"))
|
---|
316 | c=3;
|
---|
317 |
|
---|
318 | switch (c)
|
---|
319 | {
|
---|
320 | case 0:
|
---|
321 | {
|
---|
322 | l2triggerkey = serv.QueryKeyOfName("L2TriggerTable", strng);
|
---|
323 | if (l2triggerkey<0)
|
---|
324 | {
|
---|
325 | strng.ReadLine(fin);
|
---|
326 | continue;
|
---|
327 | }
|
---|
328 |
|
---|
329 | strng="n/a";
|
---|
330 | l1triggerkey = 1;
|
---|
331 |
|
---|
332 | break;
|
---|
333 | }
|
---|
334 | case 1:
|
---|
335 | {
|
---|
336 | TString L1TT, L2TT;
|
---|
337 | L2TT=strng(7,12);
|
---|
338 | L1TT=strng(0,6);
|
---|
339 |
|
---|
340 | l1triggerkey = serv.QueryKeyOfName("L1TriggerTable", L1TT);
|
---|
341 | if (l1triggerkey<0)
|
---|
342 | {
|
---|
343 | strng.ReadLine(fin);
|
---|
344 | continue;
|
---|
345 | }
|
---|
346 |
|
---|
347 | l2triggerkey = serv.QueryKeyOfName("L2TriggerTable", L2TT);
|
---|
348 | if (l2triggerkey<0)
|
---|
349 | {
|
---|
350 | strng.ReadLine(fin);
|
---|
351 | continue;
|
---|
352 | }
|
---|
353 |
|
---|
354 | break;
|
---|
355 | }
|
---|
356 | case 2:
|
---|
357 | {
|
---|
358 | l1triggerkey = serv.QueryKeyOfName("L1TriggerTable", strng);
|
---|
359 | if (l1triggerkey<0)
|
---|
360 | {
|
---|
361 | strng.ReadLine(fin);
|
---|
362 | continue;
|
---|
363 | }
|
---|
364 |
|
---|
365 | strng="n/a";
|
---|
366 | l2triggerkey = 1;
|
---|
367 |
|
---|
368 | break;
|
---|
369 | }
|
---|
370 | case 3:
|
---|
371 | {
|
---|
372 | l1triggerkey = 1;
|
---|
373 | l2triggerkey = 1;
|
---|
374 | break;
|
---|
375 | }
|
---|
376 | default:
|
---|
377 | {
|
---|
378 | cout << "WARNING: neither L1 nor L2 Trigger table - please check what is happening." << strng << endl;
|
---|
379 | break;
|
---|
380 | }
|
---|
381 | }
|
---|
382 | }
|
---|
383 |
|
---|
384 | // ========== Col 13-15: TrigRate, L2 UnPresc Rate, L2 Presc Rate ==========
|
---|
385 | strng.ReadToDelim(fin, ' ');
|
---|
386 | Float_t trigrate = atof(strng.Data());
|
---|
387 |
|
---|
388 | strng.ReadToDelim(fin, ' ');
|
---|
389 | Float_t l2uprate = atof(strng.Data());
|
---|
390 |
|
---|
391 | strng.ReadToDelim(fin, ' ');
|
---|
392 | Float_t l2prrate = atof(strng.Data());
|
---|
393 |
|
---|
394 | // ========== Col 16,17: DaqRate, Storage Rate ==========
|
---|
395 | strng.ReadToDelim(fin, ' ');
|
---|
396 | Float_t daqrate = atof(strng.Data());
|
---|
397 |
|
---|
398 | strng.ReadToDelim(fin, ' ');
|
---|
399 | Float_t storerate = atof(strng.Data());
|
---|
400 |
|
---|
401 | // ========== Col 18: HV table =========
|
---|
402 | if (version==200405050 || version==200405140)
|
---|
403 | strng.ReadToDelim(fin, '\n');
|
---|
404 | else
|
---|
405 | strng.ReadToDelim(fin, ' ');
|
---|
406 | if (strng.Contains("???"))
|
---|
407 | strng="n/a";
|
---|
408 |
|
---|
409 | Int_t hvkey = serv.QueryKeyOfName("HvSettings", strng);
|
---|
410 | if (hvkey<0)
|
---|
411 | {
|
---|
412 | //strng.ReadLine(fin);
|
---|
413 | continue;
|
---|
414 | }
|
---|
415 |
|
---|
416 | if (version==200405180 || version==200407270)
|
---|
417 | strng.ReadLine(fin);
|
---|
418 |
|
---|
419 | Int_t testflagkey=1;
|
---|
420 | Int_t lightcondkey=1;
|
---|
421 | Int_t dttablekey=1;
|
---|
422 | Int_t triggerdelaytablekey=1;
|
---|
423 | Int_t calibrationscriptkey=1;
|
---|
424 | if (version>=200411130)
|
---|
425 | {
|
---|
426 | // ========== Col 19-35: DC and HV-values, mjd =========
|
---|
427 | for (int i=0 ; i<17 ; i++)
|
---|
428 | {
|
---|
429 | strng.ReadToDelim(fin, ' ');
|
---|
430 | }
|
---|
431 |
|
---|
432 | // ========== Col 36: test-flag =========
|
---|
433 | strng.ReadToDelim(fin, ' ');
|
---|
434 | if (strng.Contains("???"))
|
---|
435 | strng="n/a";
|
---|
436 |
|
---|
437 | testflagkey = serv.QueryKeyOfName("TestFlag", strng);
|
---|
438 | if (testflagkey<0)
|
---|
439 | {
|
---|
440 | strng.ReadLine(fin);
|
---|
441 | continue;
|
---|
442 | }
|
---|
443 |
|
---|
444 | // ========== Col 37: light conditions =========
|
---|
445 | strng.ReadToDelim(fin, ' ');
|
---|
446 | if (strng.Contains("???"))
|
---|
447 | strng="n/a";
|
---|
448 |
|
---|
449 | lightcondkey = serv.QueryKeyOfName("LightConditions", strng);
|
---|
450 | if (lightcondkey<0)
|
---|
451 | {
|
---|
452 | strng.ReadLine(fin);
|
---|
453 | continue;
|
---|
454 | }
|
---|
455 |
|
---|
456 | // ========== Col 38: discriminator threshold table =========
|
---|
457 | strng.ReadToDelim(fin, ' ');
|
---|
458 | if (strng.Contains("???"))
|
---|
459 | strng="n/a";
|
---|
460 |
|
---|
461 | dttablekey = serv.QueryKeyOfName("DiscriminatorThresholdTable", strng);
|
---|
462 | if (dttablekey<0)
|
---|
463 | {
|
---|
464 | strng.ReadLine(fin);
|
---|
465 | continue;
|
---|
466 | }
|
---|
467 |
|
---|
468 | // ========== Col 39: trigger delay table =========
|
---|
469 | strng.ReadToDelim(fin, ' ');
|
---|
470 | if (strng.Contains("???"))
|
---|
471 | strng="n/a";
|
---|
472 |
|
---|
473 | triggerdelaytablekey = serv.QueryKeyOfName("TriggerDelayTable", strng);
|
---|
474 | if (triggerdelaytablekey<0)
|
---|
475 | {
|
---|
476 | strng.ReadLine(fin);
|
---|
477 | continue;
|
---|
478 | }
|
---|
479 |
|
---|
480 | // ========== Col 40,41: Telescope RA and Dec sent to drive =========
|
---|
481 | strng.ReadToDelim(fin, ' ');
|
---|
482 | strng.ReadToDelim(fin, ' ');
|
---|
483 |
|
---|
484 | // ========== Col 42: Calibration Script =========
|
---|
485 | if (version>=200411130 && version<=200510250)
|
---|
486 | strng.ReadToDelim(fin, '\n');
|
---|
487 | else
|
---|
488 | strng.ReadToDelim(fin, ' ');
|
---|
489 | if (strng.Contains("???"))
|
---|
490 | strng="n/a";
|
---|
491 |
|
---|
492 | calibrationscriptkey = serv.QueryKeyOfName("CalibrationScript", strng);
|
---|
493 | if (calibrationscriptkey<0)
|
---|
494 | {
|
---|
495 | strng.ReadLine(fin);
|
---|
496 | continue;
|
---|
497 | }
|
---|
498 |
|
---|
499 | }
|
---|
500 |
|
---|
501 | Int_t observationmodekey=1;
|
---|
502 | if (version>=200603300)
|
---|
503 | {
|
---|
504 | // ========== Col 43: Observation Mode =========
|
---|
505 | strng.ReadToDelim(fin, ' ');
|
---|
506 | if (strng.Contains("???"))
|
---|
507 | strng="n/a";
|
---|
508 |
|
---|
509 | observationmodekey = serv.QueryKeyOfName("ObservationMode", strng);
|
---|
510 | if (observationmodekey<0)
|
---|
511 | {
|
---|
512 | strng.ReadLine(fin);
|
---|
513 | continue;
|
---|
514 | }
|
---|
515 |
|
---|
516 | // ========== Col 44-51: Source RA and Dec, DT's and IPR =========
|
---|
517 | for (int i=0 ; i<7 ; i++)
|
---|
518 | {
|
---|
519 | strng.ReadToDelim(fin, ' ');
|
---|
520 | }
|
---|
521 | strng.ReadToDelim(fin, '\n');
|
---|
522 | }
|
---|
523 |
|
---|
524 |
|
---|
525 | // ================================================================
|
---|
526 | // ========== Data read from file now access the database =========
|
---|
527 | // ================================================================
|
---|
528 |
|
---|
529 | //assemlbe the query that is needed to insert the values of this run
|
---|
530 | TString query;
|
---|
531 | query += Form("fTelescopeNumber=%d, ", telnumber);
|
---|
532 | query += Form("fRunNumber=%d, ", runnumber);
|
---|
533 | query += Form("fFileNumber=%d, ", filenumber);
|
---|
534 | query += Form("fRunTypeKEY=%d, ", runtype);
|
---|
535 | query += Form("fProjectKEY=%d, ", projkey);
|
---|
536 | query += Form("fSourceKEY=%d, ", sourcekey);
|
---|
537 | query += Form("fNumEvents=%d, ", evtno);
|
---|
538 | query += Form("fRunStart=\"%s %s\", ", startdate.Data(), starttime.Data());
|
---|
539 | query += Form("fRunStop=\"%s %s\", ", stopdate.Data(), stoptime.Data());
|
---|
540 | query += Form("fL1TriggerTableKEY=%d, ", l1triggerkey);
|
---|
541 | query += Form("fL2TriggerTableKEY=%d, ", l2triggerkey);
|
---|
542 | query += Form("fTestFlagKEY=%d, ", testflagkey);
|
---|
543 | query += Form("fCalibrationScriptKEY=%d, ", calibrationscriptkey);
|
---|
544 | query += Form("fTriggerDelayTableKEY=%d, ", triggerdelaytablekey);
|
---|
545 | query += Form("fDiscriminatorThresholdTableKEY=%d, ", dttablekey);
|
---|
546 | query += Form("fLightConditionsKEY=%d, ", lightcondkey);
|
---|
547 | query += Form("fHvSettingsKEY=%d, ", hvkey);
|
---|
548 | query += Form("fObservationModeKEY=%d, ", observationmodekey);
|
---|
549 | if (!TMath::IsNaN(zd) && TMath::Finite(zd))
|
---|
550 | query += Form("fZenithDistance=%d, ", TMath::Nint(zd));
|
---|
551 | if (!TMath::IsNaN(az) && TMath::Finite(az))
|
---|
552 | query += Form("fAzimuth=%d, ", TMath::Nint(az));
|
---|
553 | if (!TMath::IsNaN(storerate) && TMath::Finite(storerate))
|
---|
554 | query += Form("fDaqStoreRate=%d, ", TMath::Nint(storerate));
|
---|
555 | if (!TMath::IsNaN(daqrate) && TMath::Finite(daqrate))
|
---|
556 | query += Form("fDaqTriggerRate=%d, ", TMath::Nint(daqrate));
|
---|
557 | if (!TMath::IsNaN(trigrate) && TMath::Finite(trigrate))
|
---|
558 | query += Form("fMeanTriggerRate=%d, ", TMath::Nint(trigrate));
|
---|
559 | if (!TMath::IsNaN(l2prrate) && TMath::Finite(l2prrate))
|
---|
560 | query += Form("fL2RatePresc=%d, ", TMath::Nint(l2prrate));
|
---|
561 | if (!TMath::IsNaN(l2uprate) && TMath::Finite(l2uprate))
|
---|
562 | query += Form("fL2RateUnpresc=%d, ", TMath::Nint(l2uprate));
|
---|
563 | query += "fMagicNumberKEY=1, fExcludedFDAKEY=1";
|
---|
564 |
|
---|
565 | cnt++;
|
---|
566 |
|
---|
567 | //send query, add dataset to DB
|
---|
568 | if (serv.Insert("RunData", query)==kFALSE)
|
---|
569 | return -1;
|
---|
570 |
|
---|
571 | TString query2=Form("fRunNumber=%d, fTimingCorrection='1970-01-01 00:00:00', fCompmux='1970-01-01 00:00:00'",
|
---|
572 | runnumber);
|
---|
573 | if (testflagkey==3)
|
---|
574 | query2+=" , fDataCheckDone='1970-01-01 00:00:00'";
|
---|
575 |
|
---|
576 | //create entry in table RunProcessStatus for this runnumber
|
---|
577 | if (serv.Insert("RunProcessStatus", query2)==kFALSE)
|
---|
578 | return -1;
|
---|
579 | }
|
---|
580 |
|
---|
581 | return cnt;
|
---|
582 |
|
---|
583 | }
|
---|
584 |
|
---|
585 | // This tool will work from Period017 (2004_05_17) on...
|
---|
586 | int filldotrun(const TString path="/data/MAGIC/Period018/ccdata", Bool_t dummy=kTRUE)
|
---|
587 | {
|
---|
588 | MSQLMagic serv("sql.rc");
|
---|
589 | if (!serv.IsConnected())
|
---|
590 | {
|
---|
591 | cout << "ERROR - Connection to database failed." << endl;
|
---|
592 | return 0;
|
---|
593 | }
|
---|
594 | cout << "filldotrun" << endl;
|
---|
595 | cout << "----------" << endl;
|
---|
596 | cout << endl;
|
---|
597 | cout << "Connected to " << serv.GetName() << endl;
|
---|
598 | cout << "Search Path: " << path << endl;
|
---|
599 | cout << endl;
|
---|
600 |
|
---|
601 | serv.SetIsDummy(dummy);
|
---|
602 |
|
---|
603 | if (path.EndsWith(".run"))
|
---|
604 | {
|
---|
605 | cout << path(TRegexp("CC_.*.run", kFALSE)) << flush;
|
---|
606 | Int_t n = insert(serv, dummy, path);
|
---|
607 | cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl;
|
---|
608 |
|
---|
609 | return n<0 ? 2 : 1;
|
---|
610 | }
|
---|
611 |
|
---|
612 | MDirIter Next(path, "CC_*.run", -1);
|
---|
613 | while (1)
|
---|
614 | {
|
---|
615 | TString name = Next();
|
---|
616 | if (name.IsNull())
|
---|
617 | break;
|
---|
618 |
|
---|
619 | cout << name(TRegexp("CC_.*.run", kFALSE)) << flush;
|
---|
620 | Int_t n = insert(serv, dummy, name);
|
---|
621 | cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl;
|
---|
622 |
|
---|
623 | if (n<0)
|
---|
624 | return 2;
|
---|
625 | }
|
---|
626 |
|
---|
627 | return 1;
|
---|
628 | }
|
---|