Small fixes
[u/mrichter/AliRoot.git] / FMD / scripts / DrawCalib.C
CommitLineData
ee13fa25 1#ifndef __CINT__
2#include <AliCDBManager.h>
3#include <AliFMDCalibDrawer.h>
4#include <TSystem.h>
5#include <TGFrame.h>
6#include <TGButton.h>
7#include <TGLayout.h>
8#include <TGButtonGroup.h>
9#include <TGNumberEntry.h>
10#include <TGTextEntry.h>
11#include <TCanvas.h>
12#include <TError.h>
13#include <TGLabel.h>
14#else
15class TGMainFrame;
16class TGNumberEntry;
17class TGTextEntry;
18class TGHButtonGroup;
19class TGCheckButton;
20class TGTextButton;
21class TGLayoutHints;
22class TCanvas;
23class TGLabel;
24class TGHorizontalFrame;
25class AliFMDCalibDrawer;
26class TGGroupFrame;
27#endif
28
29
30class Menu
31{
32public:
33 TGMainFrame fMain;
34 TGGroupFrame fSetup;
35 TGLabel fLRun;
36 TGNumberEntry fRun;
37 TGLabel fLOCDB;
38 TGTextEntry fOCDB;
39 TGTextButton fInit;
40 TGHorizontalFrame fFDet;
41 TGLabel fLDet;
42 TGNumberEntry fDet;
43 TGHorizontalFrame fFRing;
44 TGLabel fLRing;
45 TGTextEntry fRing;
46 TGHorizontalFrame fFSec;
47 TGLabel fLSec;
48 TGNumberEntry fSec;
49 TGHorizontalFrame fFStr;
50 TGLabel fLStr;
51 TGNumberEntry fStr;
52 TGHButtonGroup fSelection;
53 TGCheckButton fPedestal;
54 TGCheckButton fNoise;
55 TGCheckButton fGain;
56 TGCheckButton fDead;
57 TGCheckButton fRate;
58 TGCheckButton fRange;
59 TGCheckButton fThreshold;
60 TGTextButton fDraw;
61 TGLayoutHints fLayout;
62
63 AliFMDCalibDrawer fCD;
64 TCanvas* fCPedestal;
65 TCanvas* fCNoise;
66 TCanvas* fCGain;
67 TCanvas* fCDead;
68 TCanvas* fCRate;
69 TCanvas* fCRange;
70 TCanvas* fCThreshold;
71
72 Menu(Int_t runNo)
73 : fMain(gClient->GetRoot()),
74 fSetup(&fMain, "Setup", kHorizontalFrame),
75 fLRun(&fSetup, "Run: "),
76 fRun(&fSetup, runNo, 8, -1, TGNumberFormat::kNESInteger,
77 TGNumberFormat::kNEAAnyNumber),
78 fLOCDB(&fSetup, "OCDB:"),
79 fOCDB(&fSetup, ""),
80 fInit(&fSetup, "Init"),
81 fFDet(&fMain),
82 fLDet(&fFDet, "Detector:"),
83 fDet(&fFDet, -1, 1, -1, TGNumberFormat::kNESInteger,
84 TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax,
85 -1, 3),
86 fFRing(&fMain),
87 fLRing(&fFRing,"Ring:"),
88 fRing(&fFRing, ""),
89 fFSec(&fMain),
90 fLSec(&fFSec,"Sector:"),
91 fSec(&fFSec, -1, 1, -1, TGNumberFormat::kNESInteger,
92 TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax,
93 -1, 39),
94 fFStr(&fMain),
95 fLStr(&fFStr,"Strip:"),
96 fStr(&fFStr, -1, 1, -1, TGNumberFormat::kNESInteger,
97 TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax,
98 -1, 511),
99 fSelection(&fMain, "what"),
100 fPedestal(&fSelection, "Pedestal"),
101 fNoise(&fSelection, "Noise"),
102 fGain(&fSelection, "Gain"),
103 fDead(&fSelection, "Dead"),
104 fRate(&fSelection, "Rate"),
105 fRange(&fSelection, "Range"),
106 fThreshold(&fSelection, "Threshold"),
107 fDraw(&fMain, "Draw"),
108 fLayout(kLHintsExpandX, 2, 2, 2, 2)
109 {
110 fSetup.AddFrame(&fLRun, &fLayout);
111 fSetup.AddFrame(&fRun, &fLayout);
112 fSetup.AddFrame(&fLOCDB, &fLayout);
113 fSetup.AddFrame(&fOCDB, &fLayout);
114 fSetup.AddFrame(&fInit, &fLayout);
115
116 fFDet.AddFrame(&fLDet, &fLayout);
117 fFDet.AddFrame(&fDet, &fLayout);
118 fFRing.AddFrame(&fLRing,&fLayout);
119 fFRing.AddFrame(&fRing, &fLayout);
120 fFSec.AddFrame(&fLSec, &fLayout);
121 fFSec.AddFrame(&fSec, &fLayout);
122 fFStr.AddFrame(&fLStr, &fLayout);
123 fFStr.AddFrame(&fStr, &fLayout);
124
125 fMain.AddFrame(&fSetup, &fLayout);
126 fMain.AddFrame(&fFDet, &fLayout);
127 fMain.AddFrame(&fFRing, &fLayout);
128 fMain.AddFrame(&fFSec, &fLayout);
129 fMain.AddFrame(&fFStr, &fLayout);
130 fMain.AddFrame(&fSelection, &fLayout);
131 fMain.AddFrame(&fDraw, &fLayout);
132
133 fRing.SetAlignment(kTextRight);
134 fRing.SetInsertMode(TGTextEntry::kReplace);
135 fRing.SetMaxLength(1);
136
137 fMain.MapSubwindows();
138 fMain.Resize(fMain.GetDefaultSize());
139 fMain.MapWindow();
140
141 fDraw.Connect("Clicked()", "Menu", this, "Handle()");
142 fInit.Connect("Clicked()", "Menu", this, "Init()");
143
144 fCD.Init(runNo);
145 }
146 TCanvas* MakeCanvas(const char* name, const char* title)
147 {
148 TCanvas* ret = new TCanvas(name, title, 1200, 900);
149 ret->SetFillColor(0);
150 ret->SetFillStyle(0);
151 ret->SetBorderMode(0);
152 ret->SetBorderSize(0);
153 return ret;
154 }
155 void ClearCanvas(TCanvas* c)
156 {
157 c->Clear();
158 c->SetTopMargin(0.02);
159 c->SetRightMargin(0.02);
160 c->SetBottomMargin(0.10);
161 c->SetLeftMargin(0.10);
162 c->cd();
163 }
164 void Init()
165 {
166 const Char_t* ocdb = fOCDB.GetText();
167 Int_t run = fRun.GetIntNumber();
168 Info("Init", "Initialising for run %d, OCDB @ %s", run, ocdb);
169 fCD.Init(run, ocdb);
170 }
171 void Handle()
172 {
173 static Short_t oD;
174 static Char_t oR;
175 static Short_t oS;
176 static Short_t oT;
177 Short_t d = fDet.GetIntNumber();
178 Char_t r = fRing.GetText()[0];
179 Short_t s = fSec.GetIntNumber();
180 Short_t t = fStr.GetIntNumber();
181 Info("Handle", "D=%d, R=%c, S=%d, T=%d", d, (r == '\0' ? '-' : r), s, t);
182 if (fPedestal.IsOn()) {
183 Info("Handle", "Will draw pedestals");
184 if (!fCPedestal) fCPedestal = MakeCanvas("peds", "Pedestals");
185 ClearCanvas(fCPedestal);
186 fCD.DrawPedestals(d, r, s, t);
187 }
188 if (fNoise.IsOn()) {
189 Info("Handle", "Will draw noises");
190 if (!fCNoise) fCNoise = MakeCanvas("noises", "Noises");
191 ClearCanvas(fCNoise);
192 fCD.DrawNoise(d, r, s, t);
193 }
194 if (fGain.IsOn()) {
195 Info("Handle", "Will draw gains");
196 if (!fCGain) fCGain = MakeCanvas("gains", "Gains");
197 ClearCanvas(fCGain);
198 fCD.DrawGains(d, r, s, t);
199 }
200 if (fDead.IsOn()) {
201 Info("Handle", "Will draw deads");
202 if (!fCDead) fCDead = MakeCanvas("deads", "Deads");
203 ClearCanvas(fCDead);
204 fCD.DrawDead(d, r, s, t);
205 }
206 if (fRate.IsOn()) {
207 Info("Handle", "Will draw rates");
208 if (!fCRate) fCRate = MakeCanvas("rates", "Rates");
209 fCRate->Clear();
210 fCRate->cd();
211 fCD.DrawRates(d, r, s, t);
212 }
213 if (fRange.IsOn()) {
214 Info("Handle", "Will draw ranges");
215 if (!fCRange) fCRange = MakeCanvas("ranges", "Ranges");
216 fCRange->Clear();
217 fCRange->cd();
218 fCD.DrawRanges(d, r, s, t);
219 }
220 if (fThreshold.IsOn()) {
221 Info("Handle", "Will draw thresholds");
222 if (!fCThreshold) fCThreshold = MakeCanvas("thresholds", "Thresholds");
223 fCThreshold->Clear();
224 fCThreshold->cd();
225 fCD.DrawThresholds(d, r, s, t);
226 }
227 }
228};
229
230
231void
232DrawCalib()
233{
234#ifdef __CINT__
235 gSystem->Load("libFMDutil");
236#endif
237
238 AliCDBManager* cdb = AliCDBManager::Instance();
239 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
240 cdb->SetSpecificStorage("FMD/Calib/Pedestal", "local:///mnt/hitachi/ocdb/2011");
241 cdb->SetSpecificStorage("FMD/Calib/PulseGain", "local:///mnt/hitachi/ocdb/2011");
242
243 Menu* m = new Menu(145167);
244 // cd->DrawPedestals(d,r,s,t);
245}