| 1 | // ==========================================================================
|
|---|
| 2 | // ============= see ratescan function at the end of the file ===============
|
|---|
| 3 | // ==========================================================================
|
|---|
| 4 |
|
|---|
| 5 | MStatusDisplay *d = new MStatusDisplay;
|
|---|
| 6 | TList list[11];
|
|---|
| 7 |
|
|---|
| 8 | void plot(const char *tab, const char *title="")
|
|---|
| 9 | {
|
|---|
| 10 | gROOT->SetSelectedPad(0);
|
|---|
| 11 | d->AddTab(tab);
|
|---|
| 12 |
|
|---|
| 13 | gPad->SetGrid();
|
|---|
| 14 | gPad->SetLogy();
|
|---|
| 15 |
|
|---|
| 16 | TH1D h0("frame", title, 1000, 0, 1000);
|
|---|
| 17 | h0.SetStats(kFALSE);
|
|---|
| 18 | h0.SetXTitle("Threshold [dac]");
|
|---|
| 19 | h0.SetYTitle("Trigger rate [Hz]");
|
|---|
| 20 | h0.SetDirectory(0);
|
|---|
| 21 | h0.SetMaximum(1e8);
|
|---|
| 22 | h0.SetMinimum(0.01);
|
|---|
| 23 | h0.DrawCopy();
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | void same(const char *id, const char *fmt, bool boards=true, bool patches=true)
|
|---|
| 27 | {
|
|---|
| 28 | for (int i=0; i<8; i++)
|
|---|
| 29 | {
|
|---|
| 30 | TGraph *g = (TGraph*)list[i+3].FindObject(id);
|
|---|
| 31 | if (!g)
|
|---|
| 32 | {
|
|---|
| 33 | cout << "==W==> " << id << " not found in i=" << i+3 << endl;
|
|---|
| 34 | return;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | g->SetMarkerStyle(kFullDotSmall);
|
|---|
| 38 | g->SetMarkerColor(kGreen+2);
|
|---|
| 39 | g->SetLineColor(kGreen+2);
|
|---|
| 40 | if (patches)
|
|---|
| 41 | g->DrawClone(fmt);
|
|---|
| 42 |
|
|---|
| 43 | if (g->Eval(400)>10)
|
|---|
| 44 | cout << "Patch " << setw(3) << i << ": C" << i/40 << " B" << (i%40)/4 << " P" << (i%40)%4 << ": " << g->Eval(400) << "Hz @ th=400" << endl;
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | for (int i=0; i<2; i++)
|
|---|
| 48 | {
|
|---|
| 49 | TGraph *g = (TGraph*)list[i+1].FindObject(id);
|
|---|
| 50 | if (!g)
|
|---|
| 51 | {
|
|---|
| 52 | cout << "==W==> " << id << " not found in i=" << i+1 << endl;
|
|---|
| 53 | return;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | g->SetMarkerStyle(kFullDotSmall);
|
|---|
| 57 | g->SetMarkerColor(kBlue);
|
|---|
| 58 | g->SetLineColor(kBlue);
|
|---|
| 59 | if (boards)
|
|---|
| 60 | g->DrawClone(fmt);
|
|---|
| 61 |
|
|---|
| 62 | if (g->Eval(400)>10)
|
|---|
| 63 | cout << "Board " << setw(3) << i << ": C" << i/10 << " B" << i%10 << ": " << g->Eval(400) << "Hz @ th=400" << endl;
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 | TGraph *g001 = (TGraph*)list[0].FindObject(id);
|
|---|
| 68 | if (!g001)
|
|---|
| 69 | {
|
|---|
| 70 | cout << "==W==> " << id << " not found in i=0" << endl;
|
|---|
| 71 | return;
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | g001->SetMarkerStyle(boards||patches?kFullDotMedium:kFullDotSmall);
|
|---|
| 75 | g001->DrawClone(fmt);
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | void read(const char *filename)
|
|---|
| 79 | {
|
|---|
| 80 | fits fin(filename);
|
|---|
| 81 | if (!fin)
|
|---|
| 82 | return;
|
|---|
| 83 |
|
|---|
| 84 | cout << '\n' << filename << '\n';
|
|---|
| 85 | cout << setfill('-') <<setw(strlen(filename)) << '-' << setfill(' ') << endl;
|
|---|
| 86 |
|
|---|
| 87 | //fin.PrintColumns();
|
|---|
| 88 |
|
|---|
| 89 | ULong64_t start;
|
|---|
| 90 | UInt_t threshold;
|
|---|
| 91 | Float_t time;
|
|---|
| 92 | Float_t ontime;
|
|---|
| 93 | Float_t Rc;
|
|---|
| 94 | Float_t Rb[2];
|
|---|
| 95 | Float_t Rp[8];
|
|---|
| 96 |
|
|---|
| 97 | fin.SetPtrAddress("Id", &start);
|
|---|
| 98 | fin.SetPtrAddress("Threshold", &threshold);
|
|---|
| 99 | fin.SetPtrAddress("ElapsedTime", &time);
|
|---|
| 100 | fin.SetPtrAddress("RelOnTime", &ontime);
|
|---|
| 101 | fin.SetPtrAddress("TriggerRate", &Rc);
|
|---|
| 102 | fin.SetPtrAddress("BoardRate", Rb);
|
|---|
| 103 | fin.SetPtrAddress("PatchRate", Rp);
|
|---|
| 104 |
|
|---|
| 105 | ULong_t first = 0;
|
|---|
| 106 |
|
|---|
| 107 | TGraph *g[11];
|
|---|
| 108 |
|
|---|
| 109 | while (fin.GetNextRow())
|
|---|
| 110 | {
|
|---|
| 111 | if (first==0 || first!=start)
|
|---|
| 112 | {
|
|---|
| 113 | first = start;
|
|---|
| 114 |
|
|---|
| 115 | MTime t;
|
|---|
| 116 | t.SetUnixTime(start);
|
|---|
| 117 |
|
|---|
| 118 | TString name = t.GetString();
|
|---|
| 119 | name = name(0, 19);
|
|---|
| 120 |
|
|---|
| 121 | cout << name << endl;
|
|---|
| 122 |
|
|---|
| 123 | for (int i=0; i<11; i++)
|
|---|
| 124 | {
|
|---|
| 125 | g[i] = new TGraph;
|
|---|
| 126 | g[i]->SetMarkerStyle(kFullDotMedium);
|
|---|
| 127 | g[i]->SetName(name);
|
|---|
| 128 | g[i]->SetTitle(t.GetStringFmt("%H:%M:%S"));
|
|---|
| 129 |
|
|---|
| 130 | list[i].Add(g[i]);
|
|---|
| 131 | }
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | g[0]->SetPoint(g[0]->GetN(), threshold, Rc/ontime);
|
|---|
| 135 | for (int i=0; i<2; i++)
|
|---|
| 136 | g[i+1]->SetPoint(g[i+1]->GetN(), threshold, Rb[i]);
|
|---|
| 137 | for (int i=0; i<8; i++)
|
|---|
| 138 | g[i+3]->SetPoint(g[i+3]->GetN(), threshold, Rp[i]);
|
|---|
| 139 | }
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | // ==========================================================================
|
|---|
| 143 | //
|
|---|
| 144 | // Run the macro with
|
|---|
| 145 | //
|
|---|
| 146 | // root hawc/ratescan.C
|
|---|
| 147 | //
|
|---|
| 148 | // If you do not need graphical output (e.g. for batch processing), do
|
|---|
| 149 | //
|
|---|
| 150 | // root -b -q hawc/ratescan.C
|
|---|
| 151 | //
|
|---|
| 152 | // ==========================================================================
|
|---|
| 153 |
|
|---|
| 154 | void ratescan()
|
|---|
| 155 | {
|
|---|
| 156 | cout << setprecision(4);
|
|---|
| 157 |
|
|---|
| 158 | // ----------------------------------------------------------------------
|
|---|
| 159 | // Read a fits with ratescan data. You can read more than one file if
|
|---|
| 160 | // you want to plot data from more than one day.
|
|---|
| 161 | read("20191003.RATE_SCAN_DATA.fits");
|
|---|
| 162 | //read("20191004.RATE_SCAN_DATA.fits");
|
|---|
| 163 |
|
|---|
| 164 | // This produces an output like this printing all IDs of ratescans
|
|---|
| 165 | // contained on the files
|
|---|
| 166 | //
|
|---|
| 167 | // ==================================
|
|---|
| 168 | // 20191003.RATE_SCAN_DATA.fits
|
|---|
| 169 | // ----------------------------
|
|---|
| 170 | // 03.10.2019 22:34:01
|
|---|
| 171 | // 03.10.2019 22:40:53
|
|---|
| 172 | // 03.10.2019 22:47:51
|
|---|
| 173 | // 03.10.2019 22:50:28
|
|---|
| 174 | // ==================================
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 | // ----------------------------------------------------------------------
|
|---|
| 178 | // The plot-function adds a tab to the display. The first argument is
|
|---|
| 179 | // the name of the tab. The second argument can be omitted and is
|
|---|
| 180 | // displayed in the statusline
|
|---|
| 181 |
|
|---|
| 182 | plot("Scan1", "Scan with good weather");
|
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 | // ----------------------------------------------------------------------
|
|---|
| 186 | // The same-function allows to plot a ratescan from the file into the
|
|---|
| 187 | // just opened tab. More than one ratescan can be plotted in the same
|
|---|
| 188 | // tab.
|
|---|
| 189 | //
|
|---|
| 190 | // The first argument is the ID of the ratescan as listed above. The
|
|---|
| 191 | // second argument is the option given to the TGraph (see ROOT's
|
|---|
| 192 | // TGraph::Paint documentation for details). "LP" is a good start. It
|
|---|
| 193 | // plots markers ('P') and connects them by a straight line ('L').
|
|---|
| 194 | //
|
|---|
| 195 | // The thirs and fourth argument can be omitted. They are booleans
|
|---|
| 196 | // (true, false) and define whether also the patch and board rates
|
|---|
| 197 | // shall be plotted.
|
|---|
| 198 |
|
|---|
| 199 | same("03.10.2019 22:34:01", "LP");
|
|---|
| 200 | //same("03.10.2019 22:40:53", "LP");
|
|---|
| 201 |
|
|---|
| 202 | //plot("Tab2", "Same with Patch and Baord rates");
|
|---|
| 203 | //same("03.10.2019 22:34:01", "LP");
|
|---|
| 204 |
|
|---|
| 205 | // ----------------------------------------------------------------------
|
|---|
| 206 | // To write the output to a files, use the following line. This can be
|
|---|
| 207 | // a root-file, a pdf-file, png-files, ... Root files can be read back
|
|---|
| 208 | // with showplot or simply with ROOT's TBrowser.
|
|---|
| 209 |
|
|---|
| 210 | // d->SaveAs("ratescan.root");
|
|---|
| 211 | }
|
|---|