source: tags/Mars-V0.9.2/datacenter/macros/findcacofiles.C

Last change on this file was 6933, checked in by Daniela Dorner, 20 years ago
*** empty log message ***
File size: 2.4 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)
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 fRunNumber FROM MyMagic.RunProcessStatus WHERE IsNull(fCaCoFileFound) ";
63 query+=" and fRunNumber > 10000 and not IsNull(fCCFileAvail)";
64
65 TSQLResult *res = serv.Query(query);
66 if (!res)
67 {
68 cout << "Error." << endl;
69 return 0;
70 }
71
72 Int_t idx = date.First('-');
73 TString year = date(0, idx);
74 cout << "year: " << year << endl;
75
76 ofstream fout("/magic/datacenter/autologs/filesondisk/"+year+"/findcacofiles-"+date+".txt");
77 if (!fout)
78 {
79 cout << "ERROR - Cannot open file." << endl;
80 return kFALSE;
81 }
82 TString runnumber=0;
83 TSQLRow *row=0;
84 while ((row = res->Next()))
85 fout << (*row)[0] << endl;
86
87 delete res;
88 return 1;
89}
90
91
Note: See TracBrowser for help on using the repository browser.