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

Last change on this file since 7222 was 7182, checked in by Daniela Dorner, 20 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)
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 Int_t idx = date.First('-');
75 TString year = date(0, idx);
76 cout << "year: " << year << endl;
77
78 ofstream fout("/magic/datacenter/autologs/filesondisk/"+year+"/findcacofiles-"+date+".txt");
79 if (!fout)
80 {
81 cout << "ERROR - Cannot open file." << endl;
82 return kFALSE;
83 }
84 TString runnumber=0;
85 TSQLRow *row=0;
86 while ((row = res->Next()))
87 fout << (*row)[0] << endl;
88
89 delete res;
90 return 1;
91}
92
93
Note: See TracBrowser for help on using the repository browser.