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

Last change on this file since 7353 was 7232, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
File size: 2.5 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// FindCaCoFiles.C
28// ===============
29//
30/////////////////////////////////////////////////////////////////////////////
31
32#include <iostream>
33#include <iomanip>
34#include <fstream>
35
36#include <TEnv.h>
37#include <TSystem.h>
38
39#include <MSQLServer.h>
40#include <TSQLRow.h>
41#include <TSQLResult.h>
42
43using namespace std;
44
45
46int findcacofiles(TString date, TString logpath)
47{
48 TEnv env("sql.rc");
49
50 MSQLServer serv(env);
51 if (!serv.IsConnected())
52 {
53 cout << "ERROR - Connection to database failed." << endl;
54 return 0;
55 }
56 cout << "findcacofiles" << endl;
57 cout << "-------------" << endl;
58 cout << endl;
59 cout << "Connected to " << serv.GetName() << endl;
60 cout << endl;
61
62 TString query="SELECT RunProcessStatus.fRunNumber FROM RunProcessStatus ";
63 query+=" LEFT JOIN RunData on RunData.fRunNumber=RunProcessStatus.fRunNumber ";
64 query+=" WHERE IsNull(fCaCoFileFound) and fExcludedFDAKEY=1 ";
65 query+=" and RunProcessStatus.fRunNumber > 10000 and not IsNull(fCCFileAvail)";
66
67 TSQLResult *res = serv.Query(query);
68 if (!res)
69 {
70 cout << "Error." << endl;
71 return 0;
72 }
73
74 TString filename(Form("%s/findcacofiles-%s.txt", logpath.Data(), date.Data()));
75 ofstream fout(filename, ios::app);
76 if (!fout)
77 {
78 cout << "ERROR - Cannot open file " << filename << endl;
79 return 0;
80 }
81
82 TSQLRow *row=0;
83 while ((row = res->Next()))
84 fout << (*row)[0] << endl;
85
86 delete res;
87 return 1;
88}
89
90
Note: See TracBrowser for help on using the repository browser.