source: tags/Mars-V0.9.5/datacenter/macros/checkstardone.C

Last change on this file was 7528, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
File size: 3.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, 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2006
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// checkstardone.C
28// ===============
29//
30// check the availability of the star files for one sequence:
31// if star has been executed successfully, this information has been inserted
32// into the database (SequenceProcessStatus) with this macro this information
33// is checked
34//
35// executing the macro:
36// .x checkstardone.C+("sequencenumber")
37//
38// the macro returns 0, if there's no connection to the database, 2, if a
39// file is missing, and 1 if all files are there
40// the return value is checked by the script, that executes the macro
41//
42// this macro is very similar to the macro checkfileavail.C
43//
44/////////////////////////////////////////////////////////////////////////////
45
46#include <iostream>
47#include <iomanip>
48#include <fstream>
49
50#include <TEnv.h>
51
52#include <MSQLServer.h>
53#include <TSQLRow.h>
54#include <TSQLResult.h>
55
56using namespace std;
57
58
59//check the value of a column for a sequence
60TString GetStatus(MSQLServer &serv, TEnv &rc, TString primary, TString table, TString column)
61{
62 TString query(Form("SELECT %s FROM %s WHERE %s=%s",
63 column.Data(), table.Data(),
64 rc.GetValue(table+".Primary", ""),
65 primary.Data()));
66
67 cout << "Query: " << query << endl;
68
69 TSQLResult *res = serv.Query(query);
70 if (!res)
71 {
72 cout << "Error - no sequence to check" << endl;
73 return "";
74 }
75
76 TSQLRow *row=0;
77 while ((row = res->Next()))
78 return (*row)[0];
79
80 return "";
81}
82
83int checkstardone(TString datasetno)
84{
85 TEnv env("sql.rc");
86
87 MSQLServer serv(env);
88 if (!serv.IsConnected())
89 {
90 cout << "ERROR - Connection to database failed." << endl;
91 return 0;
92 }
93 cout << "checkstardone" << endl;
94 cout << "-------------" << endl;
95 cout << endl;
96 cout << "Connected to " << serv.GetName() << endl;
97 cout << endl;
98
99 TEnv rc("steps.rc");
100
101 //check if fStar not NULL for sequence
102 if (GetStatus(serv, rc, datasetno, "SequenceProcessStatus", "fStar")=="")
103 return 2;
104
105 return 1;
106}
107
Note: See TracBrowser for help on using the repository browser.