source: trunk/MagicSoft/Mars/datacenter/macros/checkfileavail.C@ 7353

Last change on this file since 7353 was 7112, checked in by Daniela Dorner, 20 years ago
*** empty log message ***
File size: 3.3 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, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2005
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// checkfileavail.C
28// ================
29//
30/////////////////////////////////////////////////////////////////////////////
31
32#include <iostream>
33#include <iomanip>
34#include <fstream>
35
36#include <TEnv.h>
37
38#include <MSQLServer.h>
39#include <TSQLRow.h>
40#include <TSQLResult.h>
41
42using namespace std;
43
44
45TString GetStatus(MSQLServer &serv, TEnv &rc, TString primary, TString table, TString column)
46{
47 TString query(Form("SELECT %s FROM %s WHERE %s=%s",
48 column.Data(), table.Data(),
49 rc.GetValue(table+".Primary", ""),
50 primary.Data()));
51
52 cout << "Query: " << query << endl;
53
54 TSQLResult *res = serv.Query(query);
55 if (!res)
56 {
57 cout << "Error - no run to check" << endl;
58 return "";
59 }
60
61 TSQLRow *row=0;
62 while ((row = res->Next()))
63 {
64// TString entry=(*row)[0];
65// if (entry=="1970-01-01 00:00:00")
66// return "";
67 return (*row)[0];
68 }
69
70 return "";
71}
72
73int checkfileavail(TString sequenceno)
74{
75 TEnv env("sql.rc");
76
77 MSQLServer serv(env);
78 if (!serv.IsConnected())
79 {
80 cout << "ERROR - Connection to database failed." << endl;
81 return 0;
82 }
83 cout << "checkfileavail" << endl;
84 cout << "--------------" << endl;
85 cout << endl;
86 cout << "Connected to " << serv.GetName() << endl;
87 cout << endl;
88
89 TEnv rc("steps.rc");
90
91 cout << "sequ: " << sequenceno.Data() << endl;
92 TString query(Form("SELECT fRunNumber FROM RunData WHERE fSequenceFirst=%s",
93 sequenceno.Data()));
94
95 TSQLResult *res = serv.Query(query);
96 if (!res)
97 cout << "Error - no run to check" << endl;
98
99 TSQLRow *row=0;
100 while ((row = res->Next()))
101 {
102 TString runno=(*row)[0];
103 cout << "run#: " << runno << endl;
104 if (GetStatus(serv, rc, runno, "RunProcessStatus", "fCCFileAvail")==""
105 || GetStatus(serv, rc, runno, "RunProcessStatus", "fCaCoFileAvail")==""
106 || GetStatus(serv, rc, runno, "RunProcessStatus", "fCaCoFileFound")==""
107 || GetStatus(serv, rc, runno, "RunProcessStatus", "fTimingCorrection")==""
108// || GetStatus(serv, rc, runno, "RunProcessStatus", "fTimingCorrection")=="1970-01-01 00:00:00"
109 || GetStatus(serv, rc, runno, "RunProcessStatus", "fRawFileAvail")=="")
110 return 0;
111 }
112 return 1;
113
114}
115
Note: See TracBrowser for help on using the repository browser.