source: tags/Mars-V0.9.6/datacenter/macros/insertcacofile.C

Last change on this file was 7460, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
File size: 3.3 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-2006
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// insertcacofiles.C
28// =================
29//
30// Macro to insert runnumber of the caco files, which contain the information
31// for a run, for which no caco file is available.
32//
33// Sometimes the DAQ aborts a run and starts itself a new one. In this cases
34// the camera controll doesn't start a new file, as the command to
35// start a new run was not sent by the central control. So the caco
36// information is stored in the previous caco file, which has a different
37// runnumber. To be able to merpp the information into the calibrated data
38// file, the runnumber of the file containing the information has to be found.
39// This is done by a script.
40// insertcacofiles.C inserts the runnumber of the file, that has been found,
41// into the column CaCoFileFound.
42//
43// Usage:
44// .x insertcacofile.C+("runnumber", "newrunnumber")
45// The first is the runnumber of which the cacofile is missing, the second is
46// the runnumber of the file in which the information probably can be found.
47//
48// Make sure, that database and password are corretly set in a resource
49// file called sql.rc and the resource file is found.
50//
51// Returns 0 in case of failure and 1 in case of success.
52//
53/////////////////////////////////////////////////////////////////////////////
54
55#include <iostream>
56#include <iomanip>
57#include <fstream>
58
59#include <TEnv.h>
60#include <TSystem.h>
61
62#include <MSQLServer.h>
63#include <TSQLRow.h>
64#include <TSQLResult.h>
65
66using namespace std;
67
68int insertcacofile(TString runnumber, TString newrunnumber)
69{
70 TEnv env("sql.rc");
71
72 MSQLServer serv(env);
73 if (!serv.IsConnected())
74 {
75 cout << "ERROR - Connection to database failed." << endl;
76 return 0;
77 }
78 cout << "insertcacofile" << endl;
79 cout << "--------------" << endl;
80 cout << endl;
81 cout << "Connected to " << serv.GetName() << endl;
82 cout << endl;
83
84 //get new runnumber
85 Int_t newrunno=atoi(newrunnumber.Data());
86 //build query and insert information
87 TString query(Form("UPDATE RunProcessStatus SET fCaCoFileAvail=Now(), fCaCoFileFound=%d WHERE fRunNumber=%s ",
88 newrunno, runnumber.Data()));
89 cout << "qu: " << query << endl;
90
91 TSQLResult *res = serv.Query(query);
92 if (!res)
93 {
94 cout << "Error - update didn't work." << endl;
95 return 0;
96 }
97
98 delete res;
99 return 1;
100}
101
102
Note: See TracBrowser for help on using the repository browser.