| 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 |
|
|---|
| 56 | using namespace std;
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | //check the value of a column for a sequence
|
|---|
| 60 | TString GetStatus(MSQLServer &serv, TEnv &env, TString primary, TString table, TString column)
|
|---|
| 61 | {
|
|---|
| 62 | TString query(Form("SELECT %s FROM %s WHERE %s=%s",
|
|---|
| 63 | column.Data(), table.Data(),
|
|---|
| 64 | env.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 = res->Next();
|
|---|
| 77 |
|
|---|
| 78 | TString rc = row ? (*row)[0] : "";
|
|---|
| 79 |
|
|---|
| 80 | delete res;
|
|---|
| 81 |
|
|---|
| 82 | return rc;
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | int checkstardone(TString datasetno)
|
|---|
| 86 | {
|
|---|
| 87 | TEnv env("sql.rc");
|
|---|
| 88 |
|
|---|
| 89 | MSQLServer serv(env);
|
|---|
| 90 | if (!serv.IsConnected())
|
|---|
| 91 | {
|
|---|
| 92 | cout << "ERROR - Connection to database failed." << endl;
|
|---|
| 93 | return 0;
|
|---|
| 94 | }
|
|---|
| 95 | cout << "checkstardone" << endl;
|
|---|
| 96 | cout << "-------------" << endl;
|
|---|
| 97 | cout << endl;
|
|---|
| 98 | cout << "Connected to " << serv.GetName() << endl;
|
|---|
| 99 | cout << endl;
|
|---|
| 100 |
|
|---|
| 101 | TEnv rc("steps.rc");
|
|---|
| 102 |
|
|---|
| 103 | //check if fStar not NULL for sequence
|
|---|
| 104 | if (GetStatus(serv, rc, datasetno, "SequenceProcessStatus", "fStar").IsNull())
|
|---|
| 105 | return 2;
|
|---|
| 106 |
|
|---|
| 107 | return 1;
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|