source: releases/Mars.2014.05.26/datacenter/macros/checkstardone.C@ 18066

Last change on this file since 18066 was 9062, checked in by tbretz, 16 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-2008
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// checkstardone.C
28// ===============
29//
30// check the availability of all star files for one dataset:
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+(1)
37//
38// The macro returns 0, if there's no connection to the database, 2 if
39// star is not done, and 1 if star done, 3 in case of error.
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#include <iostream>
46#include <iomanip>
47
48#include <TSQLRow.h>
49#include <TSQLResult.h>
50
51#include "MSQLServer.h"
52
53using namespace std;
54
55int checkstardone(Int_t num)
56{
57 MSQLServer serv("sql.rc");
58 if (!serv.IsConnected())
59 {
60 cout << "ERROR - Connection to database failed." << endl;
61 return 0;
62 }
63
64 cout << "checkstardone" << endl;
65 cout << "-------------" << endl;
66 cout << endl;
67 cout << "Connected to " << serv.GetName() << endl;
68 cout << endl;
69 cout << "Dataset: " << num << endl;
70 cout << endl;
71
72 // -------------------------------------------
73
74 TString query = "SELECT MIN(NOT ISNULL(fStar)) FROM SequenceProcessStatus "
75 "LEFT JOIN DataSetSequenceMapping USING (fTelescopeNumber,fSequenceFirst) ";
76 query += Form("WHERE fDataSetNumber=%d", num);
77
78 TSQLResult *res = serv.Query(query);
79 if (!res)
80 return 3;
81
82 if (res->GetRowCount()!=1)
83 {
84 cout << "ERROR - Unexpected number of returned rows (" << res->GetRowCount() << ")" << endl;
85 delete res;
86 return 3;
87 }
88
89 TSQLRow *row = res->Next();
90
91 if (!row || !(*row)[0])
92 {
93 cout << "ERROR - Unexpected result." << endl;
94 delete res;
95 return 3;
96 }
97
98 const Int_t rc = atoi((*row)[0]);
99
100 delete res;
101
102 return rc==1 ? 1 : 2;
103}
Note: See TracBrowser for help on using the repository browser.