| 1 | /* ======================================================================== *\
|
|---|
| 2 | ! $Name: not supported by cvs2svn $:$Id: plotrundb.C,v 1.7 2008-07-20 14:21:40 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 | query[0] += " AND fTelescopeNumber=";
|
|---|
| 78 | query[0] += tel;
|
|---|
| 79 | }
|
|---|
| 80 | plot.SetCondition(cond);
|
|---|
| 81 |
|
|---|
| 82 | //inner camera
|
|---|
| 83 | //from calib*.root
|
|---|
| 84 | plot.SetDescription("DAQ Storage Rate;R_{DAQ,S} [Hz]", "StoreRate");
|
|---|
| 85 | plot.Plot("RunData.fDaqStoreRate", -0.5, 999.5, 5);
|
|---|
| 86 | plot.SetDescription("DAQ Trigger Rate;R_{DAQ,T} [Hz]", "TrigRate");
|
|---|
| 87 | plot.Plot("RunData.fDaqTriggerRate", -0.5, 999.5, 5);
|
|---|
| 88 | plot.SetDescription("Mean Trigger Rate;<R> [Hz]", "MeanTrig");
|
|---|
| 89 | plot.Plot("RunData.fMeanTriggerRate", -0.5, 999.5, 5);
|
|---|
| 90 | plot.SetDescription("L2 Trigger rate after prescaler;R_{L2,P}", "Presc");
|
|---|
| 91 | plot.Plot("RunData.fL2RatePresc", -0.5, 999.5, 5);
|
|---|
| 92 | plot.SetDescription("L2 Trigger rate before prescaler;R_{L2,U}", "Unpresc");
|
|---|
| 93 | plot.Plot("RunData.fL2RateUnpresc", -0.5, 999.5, 5);
|
|---|
| 94 | /*
|
|---|
| 95 | //from signal*.root
|
|---|
| 96 | plot.SetDescription("Signal Position;<T_{S}> [sl]", "PosMean");
|
|---|
| 97 | plot.Plot("DataCheck.fPositionSignal", -0.5, 29.5, 1);
|
|---|
| 98 | plot.SetDescription("Signal Position FWHM;\\sigma_{S} [sl]", "PosFWHM");
|
|---|
| 99 | plot.Plot("DataCheck.fPositionFWHM", -0.5, 29.5, 1);
|
|---|
| 100 | plot.SetDescription("Signal Height;<H_{s}> [counts]", "SigMean");
|
|---|
| 101 | plot.Plot("DataCheck.fHeightSignal", -0.5, 256.5, 1);
|
|---|
| 102 | plot.SetDescription("Signal Height FWHM;\\sigma_{H} [counts]", "SigFWHM");
|
|---|
| 103 | plot.Plot("DataCheck.fHeightFWHM", -0.5, 155.5, 1);
|
|---|
| 104 |
|
|---|
| 105 | plot.SetDescription("Interleaved Signal Position;<T_{S}> [sl]", "IPosMean");
|
|---|
| 106 | plot.Plot("DataCheck.fPositionSignalInterlaced", -0.5, 29.5, 1);
|
|---|
| 107 | plot.SetDescription("Interleaved Signal Position FWHM;\\sigma_{S} [sl]", "IPosFWHM");
|
|---|
| 108 | plot.Plot("DataCheck.fPositionFWHMInterlaced", -0.5, 29.5, 1);
|
|---|
| 109 | plot.SetDescription("Interleaved Signal Height;<H_{s}> [counts]", "ISigMean");
|
|---|
| 110 | plot.Plot("DataCheck.fHeightSignalInterlaced", -0.5, 256.5, 1);
|
|---|
| 111 | plot.SetDescription("Interleaved Signal Height FWHM;\\sigma_{H} [counts]", "ISigFWHM");
|
|---|
| 112 | plot.Plot("DataCheck.fHeightFWHMInterlaced", -0.5, 155.5, 1);
|
|---|
| 113 | */
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | int plotrundb(TString from, TString to, const char *dataset=0)
|
|---|
| 117 | {
|
|---|
| 118 | MSQLMagic serv("sql.rc");
|
|---|
| 119 | if (!serv.IsConnected())
|
|---|
| 120 | {
|
|---|
| 121 | cout << "ERROR - Connection to database failed." << endl;
|
|---|
| 122 | return 0;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | cout << "plotrundb" << endl;
|
|---|
| 126 | cout << "---------" << endl;
|
|---|
| 127 | cout << endl;
|
|---|
| 128 | cout << "Connected to " << serv.GetName() << endl;
|
|---|
| 129 | cout << endl;
|
|---|
| 130 |
|
|---|
| 131 | MStatusDisplay *d = new MStatusDisplay;
|
|---|
| 132 | d->SetWindowName(serv.GetName());
|
|---|
| 133 | d->SetTitle(serv.GetName());
|
|---|
| 134 |
|
|---|
| 135 | MPlot plot(serv);
|
|---|
| 136 | plot.SetDataSet(dataset);
|
|---|
| 137 | plot.SetDisplay(d);
|
|---|
| 138 | plot.SetRequestRange(from, to);
|
|---|
| 139 | plotall(plot);
|
|---|
| 140 | d->SaveAsRoot("plotrundb.root");
|
|---|
| 141 | d->SaveAsPS("plotrundb.ps");
|
|---|
| 142 |
|
|---|
| 143 | return 1;
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | int plotrundb(const char *ds)
|
|---|
| 147 | {
|
|---|
| 148 | MSQLMagic serv("sql.rc");
|
|---|
| 149 | if (!serv.IsConnected())
|
|---|
| 150 | {
|
|---|
| 151 | cout << "ERROR - Connection to database failed." << endl;
|
|---|
| 152 | return 0;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | cout << "plotrundb" << endl;
|
|---|
| 156 | cout << "---------" << endl;
|
|---|
| 157 | cout << endl;
|
|---|
| 158 | cout << "Connected to " << serv.GetName() << endl;
|
|---|
| 159 | cout << endl;
|
|---|
| 160 |
|
|---|
| 161 | MStatusDisplay *d = new MStatusDisplay;
|
|---|
| 162 | d->SetWindowName(serv.GetName());
|
|---|
| 163 | d->SetTitle(serv.GetName());
|
|---|
| 164 |
|
|---|
| 165 | MPlot plot(serv);
|
|---|
| 166 | plot.SetDataSet(ds);
|
|---|
| 167 | plot.SetDisplay(d);
|
|---|
| 168 | plot.SetRequestRange("", "");
|
|---|
| 169 | plotall(plot);
|
|---|
| 170 | d->SaveAsRoot("plotrundb.root");
|
|---|
| 171 | d->SaveAsPS("plotrundb.ps");
|
|---|
| 172 |
|
|---|
| 173 | return 1;
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | int plotrundb(Int_t period, const char *dataset="")
|
|---|
| 177 | {
|
|---|
| 178 | MSQLMagic serv("sql.rc");
|
|---|
| 179 | if (!serv.IsConnected())
|
|---|
| 180 | {
|
|---|
| 181 | cout << "ERROR - Connection to database failed." << endl;
|
|---|
| 182 | return 0;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | cout << "plotrundb" << endl;
|
|---|
| 186 | cout << "---------" << endl;
|
|---|
| 187 | cout << endl;
|
|---|
| 188 | cout << "Connected to " << serv.GetName() << endl;
|
|---|
| 189 | cout << endl;
|
|---|
| 190 |
|
|---|
| 191 | MStatusDisplay *d = new MStatusDisplay;
|
|---|
| 192 | d->SetWindowName(serv.GetName());
|
|---|
| 193 | d->SetTitle(serv.GetName());
|
|---|
| 194 |
|
|---|
| 195 | MPlot plot(serv);
|
|---|
| 196 | plot.SetDataSet(dataset);
|
|---|
| 197 | plot.SetDisplay(d);
|
|---|
| 198 | plot.SetRequestPeriod(period);
|
|---|
| 199 | plotall(plot);
|
|---|
| 200 | d->SaveAsRoot("plotrundb.root");
|
|---|
| 201 | d->SaveAsPS("plotrundb.ps");
|
|---|
| 202 |
|
|---|
| 203 | return 1;
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | int plotrundb()
|
|---|
| 207 | {
|
|---|
| 208 | return plotrundb("", "");
|
|---|
| 209 | }
|
|---|