source: trunk/Mars/datacenter/macros/filldotrun.C@ 10305

Last change on this file since 10305 was 9487, checked in by hoehne, 15 years ago
*** empty log message ***
File size: 27.0 KB
Line 
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, 080519-0, 080912-0, 081204-0, 081214-0,
44// 090203-0, 090221-0, 090522-0, 090525-0, 090616-0, 090625-0, 090702-0,
45// 090706-0, 090731-0
46//
47// Usage:
48// .x filldotrun.C+("/data/MAGIC/Period019/ccdata", kTRUE)
49//
50// While the first argument is the directory in which all subdirectories where
51// searches for CC_*.run files. All these files were analysed and the run
52// info will be put into the DB, eg:
53// "/magic/subsystemdata/cc" would do it for all data
54// "/magic/subsystemdata/cc/2005" for one year
55// "/magic/subsystemdata/cc/2005/11" for one month
56// "/magic/subsystemdata/cc/2005/11/11" for a single day
57// "/magic/subsystemdata/cc/2005/11/11/file.run" for a single file
58//
59// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
60// switched on and nothing will be written into the database. Instead
61// informations about the subtables are displayed. This is usefull for tests
62// when adding a new arehucas version support. If it is kFALSE the information
63// are written into the subtables and the runs info is written into the
64// rundatabase.
65//
66// In the automatic case it makes sense to check the logfiles to make sure
67// that everything is fine...
68//
69// Make sure, that database and password are corretly set in a resource
70// file called sql.rc and the resource file is found.
71//
72// Remark: Running it from the commandline looks like this:
73// root -q -l -b filldotrun.C+\(\"path\"\,kFALSE\) 2>&1 | tee filldotrun.log
74//
75// Returns 0 in case of failure and 1 in case of success.
76//
77/////////////////////////////////////////////////////////////////////////////
78#include <iostream>
79#include <iomanip>
80#include <fstream>
81
82#include <TMath.h>
83#include <TRegexp.h>
84
85#include "MTime.h"
86#include "MDirIter.h"
87#include "MSQLMagic.h"
88
89using namespace std;
90
91Int_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 TObjArray *array = new TObjArray();
102 Int_t check=0;
103
104 strng.ReadLine(fin);
105 if (strng!=TString("[CC Plain Run Summary File]"))
106 {
107 cout << filename << ": No Plain Run Summary File" << endl;
108 cout << "First Line: " << strng << endl;
109 cout << endl;
110 return -1;
111 }
112
113 strng.ReadLine(fin);
114 TRegexp reg("[0-9][0-9][0-9][0-9][0-9][0-9]-[0-9]");
115 TString arehucas = strng(reg);
116 arehucas.Prepend("20");
117 arehucas.ReplaceAll("-", "");
118
119 Int_t version = atoi(arehucas.Data());
120 if (version!=200405050 && version!=200405140 && version!=200405180 &&
121 version!=200407270 && version!=200411130 && version!=200412090 &&
122 version!=200412210 &&
123 version!=200502240 && version!=200503170 && version!=200503220 &&
124 version!=200504010 && version!=200504130 && version!=200504150 &&
125 version!=200507140 && version!=200507190 && version!=200508290 &&
126 version!=200510250 &&
127 version!=200603300 && version!=200604010 && version!=200608080 &&
128 version!=200704160 &&
129 version!=200802200 && version!=200805190 && version!=200809120 &&
130 version!=200812040 && version!=200812140 &&
131 version!=200902030 && version!=200902210 && version!=200905220 &&
132 version!=200905250 && version!=200906160 && version!=200906250 &&
133 version!=200907020 && version!=200907060 && version!=200907310)
134 {
135 cout << filename << ": File Version unknown - please update the macro!" << endl;
136 cout << "Second Line: " << strng << endl;
137 cout << endl;
138 return -1;
139 }
140
141 Int_t telcheck=1;
142 TString tcheck;
143 if (version >= 200805190)
144 {
145 strng.ReadLine(fin);
146 if (!strng.BeginsWith("Telescope M"))
147 {
148 cout << "WARNING - Line 3 doesn't start with 'Telescope M'." << endl;
149 cout << strng << endl;
150 }
151 telcheck = atoi(strng.Data()+11);
152
153 if (telcheck != 1 && telcheck != 2)
154 {
155 cout << filename << ": Telescope declaration wrong!" << endl;
156 cout << "Third Line: " << strng << endl;
157 cout << endl;
158 return -1;
159 }
160 }
161
162 if (version >= 200411130)
163 {
164 strng.ReadLine(fin);
165 if (strng[0]!='#')
166 {
167 cout << "WARNING - '#' expected." << endl;
168 cout << strng << endl;
169 }
170 }
171
172 cout << " * V" << version << " " << endl;
173
174 Int_t cnt=0;
175 while (1)
176 {
177 // ===== Check for number of columns in file =====
178 // different arehucas versions provide a different number of columns:
179 // 200405050 - 200405140: 18 columns
180 // 200405180 - 200407270: 35 columns
181 // 200411130 - 200510250: 43 columns
182 // 200603300 - 200802200: 52 columns
183 // 200805190 - 200809120: 54 columns
184 // 200812040 - 200906160: 55 columns
185 // >= 200906250: 61 columns
186 //
187 strng.ReadLine(fin);
188 //fill an array with the values separated by ' '. Advantage: In contrast to ReadToDelim(' ') objects 'between'
189 //two whitespaces are not written to the array. In case of a missing column the error is detected by comparison
190 //with the number of default columns. In case of an 'accidental' double(triple)-whitespace the columns are treated
191 //in the right way, only a warning is released to edit the file, if necessary.
192 array = strng.Tokenize(" ");
193 check = array->GetEntries();
194
195 if (strng.Contains(" ") || strng. Contains(" "))
196 {
197 cout << "WARNING - Multiple whitespaces found, please check the file:" << endl;
198 cout << filename << endl;
199 }
200
201 /*
202 for (int n=0; n< array->GetEntries(); n++)
203 {
204 cout << (*array)[n]->GetName() << endl;
205 }
206 */
207 //check the number of columns for the different versions, if there is an empty line (check=0), do nothing
208 if (check != 0)
209 {
210 if ((version <= 200405140 && check != 18) ||
211 (version > 200405140 && version <= 200407270 && check != 35) ||
212 (version > 200407270 && version <= 200510250 && check != 43) ||
213 (version > 200510250 && version <= 200802200 && check != 52) ||
214 (version > 200802200 && version <= 200809120 && check != 54) ||
215 (version > 200809120 && version <= 200906160 && check != 55) ||
216 (version > 200906160 && ((telcheck == 1 && check != 61) || (telcheck == 2 && check != 63))))
217 {
218 cout << "ERROR - Number of columns (" << check << ") doesn't match number of required columns, please check the file:" << endl;
219 cout << filename << endl;
220 delete array;
221 continue;
222 }
223 }
224
225 //when reaching the end of the file...
226 if (!fin)
227 break;
228
229 // count variable for the columns
230 Int_t i = 0;
231
232 // ========== Col 1: Telescope Number =========
233 Int_t telnumber = 1; // FIXME: "NULL"?
234 if (version >=200805190)
235 {
236 strng = (*array)[i++]->GetName();
237
238 if (strng[0]!='M')
239 {
240 cout << "WARNING - First character is not an M." << endl;
241 cout << strng << endl;
242 delete array;
243 continue;
244 }
245 telnumber = atoi(strng.Data()+1);
246
247 }
248
249 // ========== Col 2: Run Number =========
250 //Reading the line
251 //and converting some strings to ints/floats
252 strng = (*array)[i++]->GetName();
253
254 Int_t runnumber = atoi(strng.Data());
255
256 //runnumber=0 means no valid dataset
257 //-> continue
258 if (runnumber == 0)
259 {
260 delete array;
261 cout << "WARNING - Runnumber == 0" << endl;
262 continue;
263 }
264
265 //cout << runnumber << " ";
266
267 // ========== Col 3: Subrun Number ========= starting with version 200805190
268 Int_t filenumber = 0; // FIXME: "NULL"?
269 if (version >=200805190)
270 {
271 strng = (*array)[i++]->GetName();
272 filenumber = atoi(strng.Data());
273 }
274
275 TString where = Form("fTelescopeNumber=%d AND fFileNumber=%d",
276 telnumber, filenumber);
277 if (serv.ExistStr("fRunNumber", "RunData", Form("%d", runnumber), where))
278 {
279 // FIXME: Maybe we can implement a switch to update mode?
280 cout << "WARNING - Entry M" << telnumber << ":" << runnumber << "/" << filenumber << " already existing... skipped." << endl;
281 delete array;
282 continue;
283 }
284
285
286 // ========== Col 4: Run Type =========
287 strng = (*array)[i++]->GetName();
288 if (strng.Contains("???"))
289 strng="n/a";
290
291 Int_t runtype = serv.QueryKeyOfName("RunType", strng, kFALSE);
292 if (runtype<0)
293 {
294 cout << "ERROR - RunType " << strng << " not available." << endl;
295 delete array;
296 continue;
297 }
298
299
300 // ========== Col 5,6: Start Time =========
301 TString startdate, starttime;
302 startdate = (*array)[i++]->GetName();
303 starttime = (*array)[i++]->GetName();
304 //cout << startdate << " " << starttime << " ";
305
306 // ========== Col 7,8: Stop Time =========
307 TString stopdate, stoptime;
308 stopdate = (*array)[i++]->GetName();
309 stoptime = (*array)[i++]->GetName();
310 //cout << stopdate << " " << stoptime << " ";
311
312 if (startdate.Contains("???"))
313 startdate="0000-00-00";
314 if (starttime.Contains("???"))
315 starttime="00:00:00";
316 if (stopdate.Contains("???"))
317 stopdate="0000-00-00";
318 if (stoptime.Contains("???"))
319 stoptime="00:00:00";
320
321 // ========== Col 9: Source Name =========
322 strng = (*array)[i++]->GetName();
323 if (strng.Contains("???"))
324 strng="Unavailable";
325
326 Int_t sourcekey = serv.QueryKeyOfName("Source", strng.Data());
327 if (sourcekey<0)
328 {
329 delete array;
330 continue;
331 }
332
333 //cout << sourcekey << " ";
334
335 // ========== Col 10,11: Local source position =========
336 strng = (*array)[i++]->GetName();
337 Float_t zd = atof(strng.Data());
338
339 strng = (*array)[i++]->GetName();
340 Float_t az = atof(strng.Data());
341
342 //cout << zd << " " << az << " ";
343
344 // ========== Col 12: Number of Events =========
345 strng = (*array)[i++]->GetName();
346 Int_t evtno = atoi(strng.Data());
347
348 //cout << evtno << " ";
349
350 // ========== Col 13: Project Name =========
351 strng = (*array)[i++]->GetName();
352 if (strng.Contains("???"))
353 strng="Unavailable";
354
355 Int_t projkey = serv.QueryKeyOfName("Project", strng);
356 if (projkey<0)
357 {
358 delete array;
359 continue;
360 }
361 //cout << projkey << " ";
362
363 // ========== Col 14: Trigger Table Name =========
364 // starting from version 200411130: Col 14,15: Trigger Table Name =========
365 strng = (*array)[i++]->GetName();
366 if (strng.Contains("???"))
367 strng="n/a";
368
369 Int_t l1triggerkey=1;
370 Int_t l2triggerkey=1;
371 if (version >=200411130)
372 {
373 l1triggerkey = serv.QueryKeyOfName("L1TriggerTable", strng);
374 if (l1triggerkey<0)
375 {
376 delete array;
377 continue;
378 }
379
380 strng = (*array)[i++]->GetName();
381 if (strng.Contains("???"))
382 strng="n/a";
383
384 l2triggerkey = serv.QueryKeyOfName("L2TriggerTable", strng);
385 if (l2triggerkey<0)
386 {
387 delete array;
388 continue;
389 }
390 }
391 else
392 {
393 Int_t c=0;
394
395 if (strng.Contains(":"))
396 c=1;
397
398 if (strng.Contains("L1_") && !(strng.Contains(":")))
399 c=2;
400
401 if (strng.Contains("n/a"))
402 c=3;
403
404 switch (c)
405 {
406 case 0:
407 {
408 l2triggerkey = serv.QueryKeyOfName("L2TriggerTable", strng);
409 if (l2triggerkey<0)
410 {
411 delete array;
412 continue;
413 }
414
415 strng="n/a";
416 l1triggerkey = 1;
417
418 break;
419 }
420 case 1:
421 {
422 TString L1TT, L2TT;
423 L2TT=strng(7,12);
424 L1TT=strng(0,6);
425
426 l1triggerkey = serv.QueryKeyOfName("L1TriggerTable", L1TT);
427 if (l1triggerkey<0)
428 {
429 delete array;
430 continue;
431 }
432
433 l2triggerkey = serv.QueryKeyOfName("L2TriggerTable", L2TT);
434 if (l2triggerkey<0)
435 {
436 delete array;
437 continue;
438 }
439
440 break;
441 }
442 case 2:
443 {
444 l1triggerkey = serv.QueryKeyOfName("L1TriggerTable", strng);
445 if (l1triggerkey<0)
446 {
447 delete array;
448 continue;
449 }
450
451 strng="n/a";
452 l2triggerkey = 1;
453
454 break;
455 }
456 case 3:
457 {
458 l1triggerkey = 1;
459 l2triggerkey = 1;
460 break;
461 }
462 default:
463 {
464 cout << "WARNING: neither L1 nor L2 Trigger table - please check what is happening." << strng << endl;
465 break;
466 }
467 }
468 }
469
470 // ========== Col 16-18: TrigRate, L2 UnPresc Rate, L2 Presc Rate ==========
471 strng = (*array)[i++]->GetName();
472 Float_t trigrate = atof(strng.Data());
473
474 strng = (*array)[i++]->GetName();
475 Float_t l2uprate = atof(strng.Data());
476
477 strng = (*array)[i++]->GetName();
478 Float_t l2prrate = atof(strng.Data());
479
480 // ========== Col 19,20: DaqRate, Storage Rate ==========
481 strng = (*array)[i++]->GetName();
482 Float_t daqrate = atof(strng.Data());
483
484 strng = (*array)[i++]->GetName();
485 Float_t storerate = atof(strng.Data());
486
487 // ========== Col 21: HV table =========
488 strng = (*array)[i++]->GetName();
489 if (version==200405050 || version==200405140)
490 {
491 delete array;
492 continue;
493 }
494 if (strng.Contains("???"))
495 strng="n/a";
496
497 Int_t hvkey = serv.QueryKeyOfName("HvSettings", strng);
498 if (hvkey<0)
499 {
500 delete array;
501 continue;
502 }
503
504 if (version==200405180 || version==200407270)
505 {
506 delete array;
507 continue;
508 }
509
510 Int_t testflagkey=1;
511 Int_t lightcondkey=1;
512 Int_t dttablekey=1;
513 Int_t triggerdelaytablekey=1;
514 Int_t calibrationscriptkey=1;
515 if (version>=200411130)
516 {
517 // ========== Col 22-38: DC and HV-values, mjd =========
518 for (int n=0 ; n<17 ; n++)
519 {
520 i++;
521 }
522
523 // ========== Col 39: test-flag =========
524 strng = (*array)[i++]->GetName();
525 if (strng.Contains("???"))
526 strng="n/a";
527
528 testflagkey = serv.QueryKeyOfName("TestFlag", strng);
529 if (testflagkey<0)
530 {
531 delete array;
532 continue;
533 }
534
535 // ========== Col 40: light conditions =========
536 strng = (*array)[i++]->GetName();
537 if (strng.Contains("???"))
538 strng="n/a";
539
540 lightcondkey = serv.QueryKeyOfName("LightConditions", strng);
541 if (lightcondkey<0)
542 {
543 delete array;
544 continue;
545 }
546
547 // ========== Col 41: discriminator threshold table =========
548 strng = (*array)[i++]->GetName();
549 if (strng.Contains("???"))
550 strng="n/a";
551
552 dttablekey = serv.QueryKeyOfName("DiscriminatorThresholdTable", strng);
553 if (dttablekey<0)
554 {
555 delete array;
556 continue;
557 }
558
559 // ========== Col 42: trigger delay table =========
560 strng = (*array)[i++]->GetName();
561 if (strng.Contains("???"))
562 strng="n/a";
563
564 triggerdelaytablekey = serv.QueryKeyOfName("TriggerDelayTable", strng);
565 if (triggerdelaytablekey<0)
566 {
567 delete array;
568 continue;
569 }
570
571 // ========== Col 43,44: Telescope RA and Dec sent to drive =========
572 i++;
573 i++;
574
575 // ========== Col 45: Calibration Script =========
576 strng = (*array)[i++]->GetName();
577 if (version>=200411130 && version<=200510250)
578 {
579 delete array;
580 continue;
581 }
582 if (strng.Contains("???"))
583 strng="n/a";
584
585 calibrationscriptkey = serv.QueryKeyOfName("CalibrationScript", strng);
586 if (calibrationscriptkey<0)
587 {
588 delete array;
589 continue;
590 }
591
592 }
593
594 Int_t observationmodekey=1;
595 if (version>=200603300)
596 {
597 // ========== Col 46: Observation Mode =========
598 strng = (*array)[i++]->GetName();
599 if (strng.Contains("???"))
600 strng="n/a";
601
602 observationmodekey = serv.QueryKeyOfName("ObservationMode", strng);
603 if (observationmodekey<0)
604 {
605 delete array;
606 continue;
607 }
608
609 // ========== Col 47-54: Source RA and Dec, DT's and IPR =========
610 for (int n=0 ; n<7 ; n++)
611 {
612 i++;
613 }
614 strng = (*array)[i++]->GetName();
615 if (version<=200809120)
616 {
617 delete array;
618 continue;
619 }
620 }
621
622 Int_t sumtriggerflagkey=1;
623 if (version>=200812040)
624 {
625 // ========= Col 55: SumTrigger flag =========
626 strng = (*array)[i++]->GetName();
627 if (version<=200906160)
628 {
629 delete array;
630 continue;
631 }
632 if (strng.Contains("???"))
633 strng="n/a";
634
635 sumtriggerflagkey = serv.QueryKeyOfName("SumTriggerFlag", strng);
636 if (sumtriggerflagkey<0)
637 {
638 delete array;
639 continue;
640 }
641 }
642
643 Int_t l3triggerkey=1;
644 Int_t cyclekey=1;
645 Int_t pikey=1;
646 Int_t workinggroupkey=1;
647 Int_t proposalkey=1;
648 Float_t l3trigrate=0;
649 TString wheelpos1 = "NULL";
650 TString wheelpos2 = "NULL";
651 if (version>=200906250)
652 {
653 // for MAGIC 2: additional columns wheel_pos1 and ~2
654
655 if (telnumber == 2)
656 {
657 strng = (*array)[i++]->GetName();
658 wheelpos1 = strng.Data();
659 strng = (*array)[i++]->GetName();
660 wheelpos2 = strng.Data();
661 }
662
663 // ========= Col 56: L3 trigger table =========
664 strng = (*array)[i++]->GetName();
665 if (strng.Contains("???") || strng.Contains("na") || strng.Contains("Unknown"))
666 strng="n/a";
667
668 l3triggerkey = serv.QueryKeyOfName("L3TriggerTable", strng);
669 if (l3triggerkey<0)
670 {
671 delete array;
672 continue;
673 }
674
675 // ========= Col 57: L3 trigger rate =========
676 strng = (*array)[i++]->GetName();
677 l3trigrate = atof(strng.Data());
678
679 // ========= Col 58: Cycle =========
680 strng = (*array)[i++]->GetName();
681 if (strng.Contains("???") || strng.Contains("na"))
682 strng="n/a";
683
684 cyclekey = serv.QueryKeyOfName("Cycle", strng);
685 if (cyclekey<0)
686 {
687 delete array;
688 continue;
689 }
690
691 // ========= Col 59: PI =========
692 strng = (*array)[i++]->GetName();
693 if (strng.Contains("???") || strng.Contains("na"))
694 strng="n/a";
695
696 pikey = serv.QueryKeyOfName("PI", strng);
697 if (pikey<0)
698 {
699 delete array;
700 continue;
701 }
702
703 // ========= Col 60: Working group =========
704 strng = (*array)[i++]->GetName();
705 if (strng.Contains("???") || strng.Contains("na"))
706 strng="n/a";
707
708 workinggroupkey = serv.QueryKeyOfName("WorkingGroup", strng);
709 if (workinggroupkey<0)
710 {
711 delete array;
712 continue;
713 }
714
715 // ========= Col 61: Proposal =========
716 strng = (*array)[i++]->GetName();
717 if (strng.Contains("???") || strng.Contains("na"))
718 strng="n/a";
719
720 proposalkey = serv.QueryKeyOfName("Proposal", strng);
721 if (proposalkey<0)
722 {
723 delete array;
724 continue;
725 }
726 }
727 delete array;
728
729
730 // ================================================================
731 // ========== Data read from file now access the database =========
732 // ================================================================
733
734 //assemble the query that is needed to insert the values of this run
735 TString query;
736 query += Form("fTelescopeNumber=%d, ", telnumber);
737 query += Form("fRunNumber=%d, ", runnumber);
738 query += Form("fFileNumber=%d, ", filenumber);
739 query += Form("fRunTypeKEY=%d, ", runtype);
740 query += Form("fProjectKEY=%d, ", projkey);
741 query += Form("fSourceKEY=%d, ", sourcekey);
742 query += Form("fNumEvents=%d, ", evtno);
743 query += Form("fRunStart=\"%s %s\", ", startdate.Data(), starttime.Data());
744 query += Form("fRunStop=\"%s %s\", ", stopdate.Data(), stoptime.Data());
745 query += Form("fL1TriggerTableKEY=%d, ", l1triggerkey);
746 query += Form("fL2TriggerTableKEY=%d, ", l2triggerkey);
747 query += Form("fTestFlagKEY=%d, ", testflagkey);
748 query += Form("fCalibrationScriptKEY=%d, ", calibrationscriptkey);
749 query += Form("fTriggerDelayTableKEY=%d, ", triggerdelaytablekey);
750 query += Form("fDiscriminatorThresholdTableKEY=%d, ", dttablekey);
751 query += Form("fLightConditionsKEY=%d, ", lightcondkey);
752 query += Form("fHvSettingsKEY=%d, ", hvkey);
753 query += Form("fObservationModeKEY=%d, ", observationmodekey);
754 query += Form("fSumTriggerFlagKEY=%d, ", sumtriggerflagkey);
755 query += Form("fL3TriggerTableKEY=%d, ", l3triggerkey);
756 query += Form("fCycleKEY=%d, ", cyclekey);
757 query += Form("fPIKEY=%d, ", pikey);
758 query += Form("fWorkingGroupKEY=%d, ", workinggroupkey);
759 query += Form("fProposalKEY=%d, ", proposalkey);
760 if (!TMath::IsNaN(zd) && TMath::Finite(zd))
761 query += Form("fZenithDistance=%d, ", TMath::Nint(zd));
762 if (!TMath::IsNaN(az) && TMath::Finite(az))
763 query += Form("fAzimuth=%d, ", TMath::Nint(az));
764 if (!TMath::IsNaN(storerate) && TMath::Finite(storerate))
765 query += Form("fDaqStoreRate=%d, ", TMath::Nint(storerate));
766 if (!TMath::IsNaN(daqrate) && TMath::Finite(daqrate))
767 query += Form("fDaqTriggerRate=%d, ", TMath::Nint(daqrate));
768 if (!TMath::IsNaN(trigrate) && TMath::Finite(trigrate))
769 query += Form("fMeanTriggerRate=%d, ", TMath::Nint(trigrate));
770 if (!TMath::IsNaN(l2prrate) && TMath::Finite(l2prrate))
771 query += Form("fL2RatePresc=%d, ", TMath::Nint(l2prrate));
772 if (!TMath::IsNaN(l2uprate) && TMath::Finite(l2uprate))
773 query += Form("fL2RateUnpresc=%d, ", TMath::Nint(l2uprate));
774 if (!TMath::IsNaN(l3trigrate) && TMath::Finite(l3trigrate))
775 query += Form("fL3TriggerRate=%d, ", TMath::Nint(l3trigrate));
776 query += Form("fWheelPos1=%s, ", wheelpos1.Data());
777 query += Form("fWheelPos2=%s, ", wheelpos2.Data());
778 query += "fMagicNumberKEY=1, fExcludedFDAKEY=1";
779
780 cnt++;
781
782 //send query, add dataset to DB
783 if (serv.Insert("RunData", query)==kFALSE)
784 return -1;
785
786 TString query2=Form("fTelescopeNumber=%d, fRunNumber=%d, fFileNumber=%d, "
787 "fPriority=%d, fTimingCorrection='1970-01-01 00:00:00', fCompmux='1970-01-01 00:00:00'",
788 telnumber, runnumber, filenumber, runnumber);
789 if (testflagkey==3)
790 query2+=" , fDataCheckDone='1970-01-01 00:00:00'";
791
792 //create entry in table RunProcessStatus for this runnumber
793 if (serv.Insert("RunProcessStatus", query2)==kFALSE)
794 return -1;
795 }
796
797 return cnt;
798}
799
800// This tool will work from Period017 (2004_05_17) on...
801int filldotrun(const TString path="/home/lapalma/transfer/ccdata", Bool_t dummy=kTRUE)
802{
803 MSQLMagic serv("sql.rc");
804 if (!serv.IsConnected())
805 {
806 cout << "ERROR - Connection to database failed." << endl;
807 return 0;
808 }
809
810 cout << "filldotrun" << endl;
811 cout << "----------" << endl;
812 cout << endl;
813 cout << "Connected to " << serv.GetName() << endl;
814 cout << "Search Path: " << path << endl;
815 cout << endl;
816
817 serv.SetIsDummy(dummy);
818
819 if (path.EndsWith(".run"))
820 {
821 cout << path(TRegexp("CC_.*.run", kFALSE)) << flush;
822 Int_t n = insert(serv, dummy, path);
823 cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl;
824
825 return n<0 ? 2 : 1;
826 }
827
828 MDirIter Next(path, "CC_*.run", -1);
829 while (1)
830 {
831 TString name = Next();
832 if (name.IsNull())
833 break;
834
835 cout << " * " << name(TRegexp("CC_.*.run", kFALSE)) << endl;
836 Int_t n = insert(serv, dummy, name);
837 cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl;
838
839 if (n<0)
840 return 2;
841 }
842
843 return 1;
844}
Note: See TracBrowser for help on using the repository browser.