1 | /* ======================================================================== *\
|
---|
2 | ! $Name: not supported by cvs2svn $:$Id: plotrundb.C,v 1.9 2009-03-16 15:13:43 tbretz Exp $
|
---|
3 | ! --------------------------------------------------------------------------
|
---|
4 | !
|
---|
5 | ! *
|
---|
6 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
7 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
8 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
9 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
10 | ! *
|
---|
11 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
12 | ! * documentation for any purpose is hereby granted without fee,
|
---|
13 | ! * provided that the above copyright notice appear in all copies and
|
---|
14 | ! * that both that copyright notice and this permission notice appear
|
---|
15 | ! * in supporting documentation. It is provided "as is" without express
|
---|
16 | ! * or implied warranty.
|
---|
17 | ! *
|
---|
18 | !
|
---|
19 | !
|
---|
20 | ! Author(s): Thomas Bretz, 05/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
21 | ! Author(s): Daniela Dorner, 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
22 | !
|
---|
23 | ! Copyright: MAGIC Software Development, 2000-2008
|
---|
24 | !
|
---|
25 | !
|
---|
26 | \* ======================================================================== */
|
---|
27 |
|
---|
28 | /////////////////////////////////////////////////////////////////////////////
|
---|
29 | //
|
---|
30 | // plotundb.C
|
---|
31 | // ==========
|
---|
32 | //
|
---|
33 | // This macro is used to read quality parameters from the DB and plot them.
|
---|
34 | //
|
---|
35 | // The parameters are from the following files:
|
---|
36 | // calib*.root:mean conversion factor, mean arrival time, rms arrival time
|
---|
37 | // (each parameter for inner and outer camera)
|
---|
38 | // signal*.root: mean pedestal rms (for inner and outer camera)
|
---|
39 | // star*.root: PSF, # of Muons, Effective OnTime, Muon rate,
|
---|
40 | // Ratio MC/Data(MuonSize) and mean number of islands
|
---|
41 | //
|
---|
42 | // In the DB these values are stored in the tables Calibration and Star.
|
---|
43 | //
|
---|
44 | // Usage:
|
---|
45 | // .x plotundb.C --> all values in the DB are plotted
|
---|
46 | // You can chose are certain period:
|
---|
47 | // .x plotrundb.C(25) --> all values from period 25 are plotted
|
---|
48 | // or a time period from a certain date to a certain date
|
---|
49 | // .x plotrundb.C("2004-11-14 00:00:00", "2005-02-28 00:00:00")
|
---|
50 | // --> all values from 14.11.2004 0h to 28.2.2005 0h are plotted
|
---|
51 | // or all data, but with dataset data highlighted
|
---|
52 | // .x plotrundb.C("dataset.txt")
|
---|
53 | // --> the sequences defined in dataset.txt are highlighted (blue:on, red:off)
|
---|
54 | // --> You can also add a dataset-name as last argument to one of the
|
---|
55 | // calls above
|
---|
56 | //
|
---|
57 | // Make sure, that database and password are corretly set in a resource
|
---|
58 | // file called sql.rc and the resource file is found.
|
---|
59 | //
|
---|
60 | /////////////////////////////////////////////////////////////////////////////
|
---|
61 | #include "plotdb.C"
|
---|
62 |
|
---|
63 | void plotall(MPlot &plot, Int_t tel=0)
|
---|
64 | {
|
---|
65 | // plot.SetGroupBy(MPlot::kGroupByNight);
|
---|
66 |
|
---|
67 | plot.SetPrimaryDate("RunData.fRunStart");
|
---|
68 | plot.SetPrimaryNumber("RunData.fRunNumber");
|
---|
69 | plot.SetSecondary("RunData.fZenithDistance");
|
---|
70 |
|
---|
71 | MTime t(-1);
|
---|
72 | TString cond = "RunData.fExcludedFDAKEY=1 AND RunData.fRunStart BETWEEN '2004-01-01' AND '";
|
---|
73 | cond += t.GetSqlDateTime();
|
---|
74 | cond += "'";
|
---|
75 | if (tel>0)
|
---|
76 | {
|
---|
77 | cond += " AND fTelescopeNumber=";
|
---|
78 | cond += tel;
|
---|
79 | }
|
---|
80 |
|
---|
81 | //cond +=" AND (RunData.fSourceKEY=403 OR RunData.fSourceKEY=871) ";
|
---|
82 |
|
---|
83 | plot.SetCondition(cond);
|
---|
84 |
|
---|
85 | //inner camera
|
---|
86 | //from calib*.root
|
---|
87 | plot.SetDescription("DAQ Storage Rate;R_{DAQ,S} [Hz]", "StoreRate");
|
---|
88 | plot.Plot("RunData.fDaqStoreRate", -0.5, 999.5, 5);
|
---|
89 | plot.SetDescription("DAQ Trigger Rate;R_{DAQ,T} [Hz]", "TrigRate");
|
---|
90 | plot.Plot("RunData.fDaqTriggerRate", -0.5, 999.5, 5);
|
---|
91 | plot.SetDescription("Mean Trigger Rate;<R> [Hz]", "MeanTrig");
|
---|
92 | plot.Plot("RunData.fMeanTriggerRate", -0.5, 999.5, 5);
|
---|
93 | plot.SetDescription("L2 Trigger rate after prescaler;R_{L2,P}", "Presc");
|
---|
94 | plot.Plot("RunData.fL2RatePresc", -0.5, 999.5, 5);
|
---|
95 | plot.SetDescription("L2 Trigger rate before prescaler;R_{L2,U}", "Unpresc");
|
---|
96 | plot.Plot("RunData.fL2RateUnpresc", -0.5, 999.5, 5);
|
---|
97 |
|
---|
98 | plot.SetDescription("L1 trigger rate after cleaning;R_{L1}", "CleanL1");
|
---|
99 | plot.Plot("RunDataCheck.fRateCleanedTrig", -0.5, 399.5, 1);
|
---|
100 | plot.SetDescription("Sum trigger rate after cleaning;R_{sum}", "CleanSum");
|
---|
101 | plot.Plot("RunDataCheck.fRateCleanedSum", -0.5, 399.5, 1);
|
---|
102 | plot.SetDescription("Unknown events trigger rate after cleaning;R_{0}", "Clean0");
|
---|
103 | plot.Plot("RunDataCheck.fRateCleanedNull", -0.5, 399.5, 1);
|
---|
104 |
|
---|
105 | /*
|
---|
106 | //from signal*.root
|
---|
107 | plot.SetDescription("Signal Position;<T_{S}> [sl]", "PosMean");
|
---|
108 | plot.Plot("DataCheck.fPositionSignal", -0.5, 29.5, 1);
|
---|
109 | plot.SetDescription("Signal Position FWHM;\\sigma_{S} [sl]", "PosFWHM");
|
---|
110 | plot.Plot("DataCheck.fPositionFWHM", -0.5, 29.5, 1);
|
---|
111 | plot.SetDescription("Signal Height;<H_{s}> [counts]", "SigMean");
|
---|
112 | plot.Plot("DataCheck.fHeightSignal", -0.5, 256.5, 1);
|
---|
113 | plot.SetDescription("Signal Height FWHM;\\sigma_{H} [counts]", "SigFWHM");
|
---|
114 | plot.Plot("DataCheck.fHeightFWHM", -0.5, 155.5, 1);
|
---|
115 |
|
---|
116 | plot.SetDescription("Interleaved Signal Position;<T_{S}> [sl]", "IPosMean");
|
---|
117 | plot.Plot("DataCheck.fPositionSignalInterlaced", -0.5, 29.5, 1);
|
---|
118 | plot.SetDescription("Interleaved Signal Position FWHM;\\sigma_{S} [sl]", "IPosFWHM");
|
---|
119 | plot.Plot("DataCheck.fPositionFWHMInterlaced", -0.5, 29.5, 1);
|
---|
120 | plot.SetDescription("Interleaved Signal Height;<H_{s}> [counts]", "ISigMean");
|
---|
121 | plot.Plot("DataCheck.fHeightSignalInterlaced", -0.5, 256.5, 1);
|
---|
122 | plot.SetDescription("Interleaved Signal Height FWHM;\\sigma_{H} [counts]", "ISigFWHM");
|
---|
123 | plot.Plot("DataCheck.fHeightFWHMInterlaced", -0.5, 155.5, 1);
|
---|
124 | */
|
---|
125 | }
|
---|
126 |
|
---|
127 | int plotrundb(TString from, TString to, const char *dataset=0, UInt_t num=(UInt_t)-1)
|
---|
128 | {
|
---|
129 | MSQLMagic serv("sql.rc");
|
---|
130 | if (!serv.IsConnected())
|
---|
131 | {
|
---|
132 | cout << "ERROR - Connection to database failed." << endl;
|
---|
133 | return 0;
|
---|
134 | }
|
---|
135 |
|
---|
136 | cout << "plotrundb" << endl;
|
---|
137 | cout << "---------" << endl;
|
---|
138 | cout << endl;
|
---|
139 | cout << "Connected to " << serv.GetName() << endl;
|
---|
140 | cout << endl;
|
---|
141 |
|
---|
142 | MStatusDisplay *d = new MStatusDisplay;
|
---|
143 | d->SetWindowName(serv.GetName());
|
---|
144 | d->SetTitle(serv.GetName());
|
---|
145 |
|
---|
146 | MPlot plot(serv);
|
---|
147 | plot.SetDataSet(dataset, num);
|
---|
148 | plot.SetDisplay(d);
|
---|
149 | plot.SetRequestRange(from, to);
|
---|
150 | plotall(plot);
|
---|
151 | d->SaveAsRoot("plotrundb.root");
|
---|
152 | d->SaveAsPS("plotrundb.ps");
|
---|
153 |
|
---|
154 | return 1;
|
---|
155 | }
|
---|
156 |
|
---|
157 | int plotrundb(const char *ds, UInt_t num=(UInt_t)-1)
|
---|
158 | {
|
---|
159 | MSQLMagic serv("sql.rc");
|
---|
160 | if (!serv.IsConnected())
|
---|
161 | {
|
---|
162 | cout << "ERROR - Connection to database failed." << endl;
|
---|
163 | return 0;
|
---|
164 | }
|
---|
165 |
|
---|
166 | cout << "plotrundb" << endl;
|
---|
167 | cout << "---------" << endl;
|
---|
168 | cout << endl;
|
---|
169 | cout << "Connected to " << serv.GetName() << endl;
|
---|
170 | cout << endl;
|
---|
171 |
|
---|
172 | MStatusDisplay *d = new MStatusDisplay;
|
---|
173 | d->SetWindowName(serv.GetName());
|
---|
174 | d->SetTitle(serv.GetName());
|
---|
175 |
|
---|
176 | MPlot plot(serv);
|
---|
177 | plot.SetDataSet(ds, num);
|
---|
178 | plot.SetDisplay(d);
|
---|
179 | plot.SetRequestRange("", "");
|
---|
180 | plotall(plot);
|
---|
181 | d->SaveAsRoot("plotrundb.root");
|
---|
182 | d->SaveAsPS("plotrundb.ps");
|
---|
183 |
|
---|
184 | return 1;
|
---|
185 | }
|
---|
186 |
|
---|
187 | int plotrundb(Int_t period, const char *dataset="")
|
---|
188 | {
|
---|
189 | MSQLMagic serv("sql.rc");
|
---|
190 | if (!serv.IsConnected())
|
---|
191 | {
|
---|
192 | cout << "ERROR - Connection to database failed." << endl;
|
---|
193 | return 0;
|
---|
194 | }
|
---|
195 |
|
---|
196 | cout << "plotrundb" << endl;
|
---|
197 | cout << "---------" << endl;
|
---|
198 | cout << endl;
|
---|
199 | cout << "Connected to " << serv.GetName() << endl;
|
---|
200 | cout << endl;
|
---|
201 |
|
---|
202 | MStatusDisplay *d = new MStatusDisplay;
|
---|
203 | d->SetWindowName(serv.GetName());
|
---|
204 | d->SetTitle(serv.GetName());
|
---|
205 |
|
---|
206 | MPlot plot(serv);
|
---|
207 | plot.SetDataSet(dataset);
|
---|
208 | plot.SetDisplay(d);
|
---|
209 | plot.SetRequestPeriod(period);
|
---|
210 | plotall(plot);
|
---|
211 | d->SaveAsRoot("plotrundb.root");
|
---|
212 | d->SaveAsPS("plotrundb.ps");
|
---|
213 |
|
---|
214 | return 1;
|
---|
215 | }
|
---|
216 |
|
---|
217 | int plotrundb()
|
---|
218 | {
|
---|
219 | return plotrundb("", "");
|
---|
220 | }
|
---|