]>
Commit | Line | Data |
---|---|---|
9bf458e3 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id: AliTRDCalibViewerGUI.cxx 40390 2010-04-14 09:43:23Z cblume $ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // GUI for the AliTRDCalibViewerGUI // | |
21 | // used for the calibration monitor // | |
22 | // All functionalities of the AliTRDCalibViewer are here available // | |
23 | // // | |
24 | // Authors: Marian Ivanov (Marian.Ivanov@cern.ch) // | |
25 | // Jens Wiechula (Jens.Wiechula@cern.ch) // | |
26 | // Ionut Arsene (iarsene@cern.ch) // | |
27 | // // | |
28 | // Example usage: // | |
29 | /* | |
30 | aliroot | |
31 | AliTRDCalibViewerGUI::ShowGUI() | |
32 | ||
33 | */ | |
34 | // // | |
35 | // // | |
36 | /////////////////////////////////////////////////////////////////////////////// | |
37 | ||
38 | ||
39 | #include "AliTRDCalibViewerGUI.h" | |
40 | #include <iostream> | |
41 | #include <string.h> | |
42 | ||
43 | #include <TCanvas.h> | |
44 | #include <TPad.h> | |
45 | #include <TVirtualPad.h> | |
46 | ||
47 | #include <TROOT.h> | |
48 | #include <TObjArray.h> | |
49 | #include <TObjString.h> | |
50 | #include <TVector.h> | |
51 | #include <TH1.h> | |
52 | #include <TMath.h> | |
53 | #include <TStyle.h> | |
54 | #include <TGFileDialog.h> | |
55 | #include <TGInputDialog.h> | |
56 | #include "AliBaseCalibViewer.h" | |
57 | #include "AliCalibViewerGUItime.h" | |
58 | #include "AliTRDCalibViewer.h" | |
59 | #include "AliCDBManager.h" | |
60 | #include "AliCDBStorage.h" | |
61 | ||
62 | ClassImp(AliTRDCalibViewerGUI) | |
63 | ||
64 | //________________________________________________________________________________________________ | |
65 | AliTRDCalibViewerGUI::AliTRDCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h, char* fileName) | |
66 | : AliBaseCalibViewerGUI(p, w, h), | |
67 | fContLayer(0), | |
68 | fContSector(0), | |
69 | fContStack(0), | |
70 | fLblLayer(0), | |
71 | fLblSector(0), | |
72 | fLblStack(0), | |
73 | fNmbLayer(0), | |
74 | fNmbSector(0), | |
75 | fNmbStack(0), | |
76 | fContLoad(0), | |
77 | fContRun(0), | |
78 | fLblRun(0), | |
79 | fNmbRun(0), | |
80 | fContStorage(0), | |
81 | fLblStorage(0), | |
82 | fTxtStorage(0), | |
83 | fContVersion(0), | |
84 | fLblVersion(0), | |
85 | fNmbVersion(0), | |
86 | fContSubVersion(0), | |
87 | fLblSubVersion(0), | |
88 | fNmbSubVersion(0), | |
89 | fContChecks(0), | |
90 | fChkCalibs(0), | |
91 | fChkDCS(0), | |
92 | fChkAlign(0), | |
93 | fBtnLoad(0), | |
94 | fContLoadCalibObjects(0), | |
95 | fContCalibInput(0), | |
96 | fLblCalibInputFilename(0), | |
97 | fTxtCalibInputFilename(0), | |
98 | fContCalibOutput(0), | |
99 | fLblCalibOutputFilename(0), | |
100 | fTxtCalibOutputFilename(0), | |
101 | fBtnLoadCalibObjects(0) | |
102 | { | |
103 | // | |
104 | // AliTRDCalibViewerGUI constructor; fileName specifies the ROOT tree used for drawing | |
105 | // | |
106 | // draw the GUI: | |
107 | DrawGUI(p, w, h); | |
108 | // initialize | |
109 | if (fileName) Initialize(fileName, "TRDcalibDetails"); | |
110 | // set default button states: | |
111 | SetInitialValues(); | |
112 | // do first drawing: | |
113 | if (fileName) DoDraw(); | |
114 | } | |
115 | ||
116 | //________________________________________________________________________________________________ | |
117 | AliTRDCalibViewerGUI::AliTRDCalibViewerGUI(const AliTRDCalibViewerGUI &c) | |
118 | :AliBaseCalibViewerGUI(c), | |
119 | fContLayer(0), | |
120 | fContSector(0), | |
121 | fContStack(0), | |
122 | fLblLayer(0), | |
123 | fLblSector(0), | |
124 | fLblStack(0), | |
125 | fNmbLayer(0), | |
126 | fNmbSector(0), | |
127 | fNmbStack(0), | |
128 | fContLoad(0), | |
129 | fContRun(0), | |
130 | fLblRun(0), | |
131 | fNmbRun(0), | |
132 | fContStorage(0), | |
133 | fLblStorage(0), | |
134 | fTxtStorage(0), | |
135 | fContVersion(0), | |
136 | fLblVersion(0), | |
137 | fNmbVersion(0), | |
138 | fContSubVersion(0), | |
139 | fLblSubVersion(0), | |
140 | fNmbSubVersion(0), | |
141 | fContChecks(0), | |
142 | fChkCalibs(0), | |
143 | fChkDCS(0), | |
144 | fChkAlign(0), | |
145 | fBtnLoad(0), | |
146 | fContLoadCalibObjects(0), | |
147 | fContCalibInput(0), | |
148 | fLblCalibInputFilename(0), | |
149 | fTxtCalibInputFilename(0), | |
150 | fContCalibOutput(0), | |
151 | fLblCalibOutputFilename(0), | |
152 | fTxtCalibOutputFilename(0), | |
153 | fBtnLoadCalibObjects(0) | |
154 | { | |
155 | // | |
156 | // dummy AliTPCCalibViewerGUI_new copy constructor | |
157 | // | |
158 | } | |
159 | ||
160 | //________________________________________________________________________________________________ | |
161 | AliTRDCalibViewerGUI & AliTRDCalibViewerGUI::operator =(const AliTRDCalibViewerGUI & /*param*/) { | |
162 | // | |
163 | // dummy assignment operator | |
164 | // | |
165 | return (*this); | |
166 | } | |
167 | ||
168 | //________________________________________________________________________________________________ | |
169 | AliTRDCalibViewerGUI::~AliTRDCalibViewerGUI() { | |
170 | // | |
171 | // Destructor | |
172 | // | |
173 | /* | |
174 | if (fCanvMain && fCanvMain->GetCanvas()) { | |
175 | for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) { | |
176 | if (strcmp(fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->ClassName(), "TFrame") != 0) | |
177 | fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->Delete(); | |
178 | } | |
179 | } */ | |
180 | Cleanup(); | |
181 | if (fViewer) fViewer->Delete(); | |
182 | } | |
183 | ||
184 | //________________________________________________________________________________________________ | |
185 | Bool_t AliTRDCalibViewerGUI::CreateDetailsTree(Int_t run, const Char_t* outFile, const Char_t* ocdbStorage) { | |
186 | // | |
187 | // Get pad level info from OCDB for a given run and dump it into a tree | |
188 | // | |
189 | ocdbStorage = ocdbStorage; // to avoid warnings | |
190 | if(!AliCDBManager::Instance()->GetDefaultStorage()){ | |
191 | std::cout << "AliTRDCalibViewerGUI::CreateDetailsTree(): Default Storage not set. Cannot create Calibration Tree!" << std::endl; | |
192 | return kFALSE; | |
193 | } | |
194 | TString storage = AliCDBManager::Instance()->GetDefaultStorage()->GetURI(); | |
195 | return ((AliTRDCalibViewer*)fViewer)->DumpOCDBtoTreeDetails("", outFile, run, run, storage.Data()); | |
196 | } | |
197 | ||
198 | //________________________________________________________________________________________________ | |
199 | void AliTRDCalibViewerGUI::DrawGUI(const TGWindow *p, UInt_t w, UInt_t h) { | |
200 | // | |
201 | // draw the GUI | |
202 | // | |
203 | ||
204 | // draw most of the GUI (all common stuff) | |
205 | AliBaseCalibViewerGUI::DrawGUI(p, w, h); | |
206 | ||
207 | // remove some frames from the virtual class | |
208 | fTabRight1->RemoveFrame(fContExport); | |
209 | fTabRight1->RemoveFrame(fContTree); | |
210 | fTabRight1->RemoveFrame(fContFit); | |
211 | ||
212 | // draw and connect slots specific to TRD | |
213 | // **************************** content of tabLeft0 ******************************* | |
214 | // layer options container | |
215 | fContLayer = new TGCompositeFrame(fContCuts, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
216 | fContCuts->AddFrame(fContLayer, new TGLayoutHints(kLHintsExpandX, 5, 0, 0, 0)); | |
217 | ||
218 | // layer number label | |
219 | fLblLayer = new TGLabel(fContLayer, "Layer"); | |
220 | fLblLayer->SetTextJustify(kTextLeft); | |
221 | fContLayer->AddFrame(fLblLayer, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 5, 0, 0, 0)); | |
222 | // layer number entry | |
223 | fNmbLayer = new TGNumberEntry(fContLayer, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, 0, 5); | |
224 | fContLayer->AddFrame(fNmbLayer, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
225 | fNmbLayer->SetNumber(0); | |
226 | fNmbLayer->Connect("ValueSet(Long_t)", "AliTRDCalibViewerGUI", this, "DoNewSelection()"); | |
227 | ||
228 | // sector options container | |
229 | fContSector = new TGCompositeFrame(fContCuts, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
230 | fContCuts->AddFrame(fContSector, new TGLayoutHints(kLHintsExpandX, 5, 0, 0, 0)); | |
231 | ||
232 | // sector number label | |
233 | fLblSector = new TGLabel(fContSector, "SM"); | |
234 | fLblSector->SetTextJustify(kTextLeft); | |
235 | fContSector->AddFrame(fLblSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 5, 0, 0, 0)); | |
236 | // sector number entry | |
237 | fNmbSector = new TGNumberEntry(fContSector, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -1, 17); | |
238 | fContSector->AddFrame(fNmbSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
239 | fNmbSector->SetNumber(-1); | |
240 | fNmbSector->Connect("ValueSet(Long_t)", "AliTRDCalibViewerGUI", this, "DoNewSelection()"); | |
241 | ||
242 | // stack options container | |
243 | fContStack = new TGCompositeFrame(fContCuts, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
244 | fContCuts->AddFrame(fContStack, new TGLayoutHints(kLHintsExpandX, 5, 0, 0, 0)); | |
245 | ||
246 | // stack number label | |
247 | fLblStack = new TGLabel(fContStack, "Stack"); | |
248 | fLblStack->SetTextJustify(kTextLeft); | |
249 | fContStack->AddFrame(fLblStack, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 5, 0, 0, 0)); | |
250 | // stack number entry | |
251 | fNmbStack = new TGNumberEntry(fContStack, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -1, 4); | |
252 | fContStack->AddFrame(fNmbStack, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
253 | fNmbStack->SetNumber(-1); | |
254 | fNmbStack->Connect("ValueSet(Long_t)", "AliTRDCalibViewerGUI", this, "DoNewSelection()"); | |
255 | ||
256 | // Load run frame | |
257 | fContLoad = new TGGroupFrame(fTabRight1, "Load run", kVerticalFrame | kFitWidth | kFitHeight); | |
258 | fTabRight1->AddFrame(fContLoad, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); | |
259 | // Storage | |
260 | fContStorage = new TGCompositeFrame(fContLoad, 400, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
261 | fContLoad->AddFrame(fContStorage, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); | |
262 | // label | |
263 | fLblStorage = new TGLabel(fContStorage, "OCDB:"); | |
264 | fLblStorage->SetTextJustify(kTextLeft); | |
265 | fContStorage->AddFrame(fLblStorage, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
266 | // text entry | |
267 | fTxtStorage = new TGTextEntry(fContStorage, "alien://folder=/alice/data/2010/OCDB/", 111); | |
268 | fContStorage->AddFrame(fTxtStorage, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
269 | // fTxtStorage->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtons1D(=111)"); | |
270 | fTxtStorage->SetToolTipText("Enter the OCDB storage location"); | |
271 | // Run entry | |
272 | fContRun = new TGCompositeFrame(fContLoad, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
273 | fContLoad->AddFrame(fContRun, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); | |
274 | // label | |
275 | fLblRun = new TGLabel(fContRun, "Run:"); | |
276 | fLblRun->SetTextJustify(kTextLeft); | |
277 | fContRun->AddFrame(fLblRun, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
278 | // run number entry | |
279 | fNmbRun = new TGNumberEntry(fContRun, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELNoLimits); | |
280 | fContRun->AddFrame(fNmbRun, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
281 | fNmbRun->SetNumber(-1); | |
282 | //fNmbRun->SetToolTipText("Enter the run number"); | |
283 | // Version entry | |
284 | fContVersion = new TGCompositeFrame(fContLoad, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
285 | fContLoad->AddFrame(fContVersion, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); | |
286 | // label | |
287 | fLblVersion = new TGLabel(fContVersion, "Version:"); | |
288 | fLblVersion->SetTextJustify(kTextLeft); | |
289 | fContVersion->AddFrame(fLblVersion, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
290 | // run number entry | |
291 | fNmbVersion = new TGNumberEntry(fContVersion, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELNoLimits); | |
292 | fContVersion->AddFrame(fNmbVersion, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
293 | fNmbVersion->SetNumber(-1); | |
294 | // SubVersion entry | |
295 | fContSubVersion = new TGCompositeFrame(fContLoad, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
296 | fContLoad->AddFrame(fContSubVersion, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); | |
297 | // label | |
298 | fLblSubVersion = new TGLabel(fContSubVersion, "SubVersion:"); | |
299 | fLblSubVersion->SetTextJustify(kTextLeft); | |
300 | fContSubVersion->AddFrame(fLblSubVersion, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
301 | // run number entry | |
302 | fNmbSubVersion = new TGNumberEntry(fContSubVersion, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELNoLimits); | |
303 | fContSubVersion->AddFrame(fNmbSubVersion, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
304 | fNmbSubVersion->SetNumber(-1); | |
305 | ||
306 | // Calib & DCS & Align check boxes frame | |
307 | fContChecks = new TGCompositeFrame(fContLoad, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
308 | fContLoad->AddFrame(fContChecks, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); | |
309 | // Calibs check box | |
310 | fChkCalibs = new TGCheckButton(fContChecks, "Calib"); | |
311 | fContChecks->AddFrame(fChkCalibs, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); | |
312 | fChkCalibs->SetToolTipText("Get calibration info (gain, pedestal, vdrift, T0 and status)"); | |
313 | fChkCalibs->SetState(kButtonDown); | |
314 | // DCS check box | |
315 | fChkDCS = new TGCheckButton(fContChecks, "DCS"); | |
316 | fContChecks->AddFrame(fChkDCS, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); | |
317 | fChkDCS->SetToolTipText("Get DCS info"); | |
318 | fChkDCS->SetState(kButtonDown); | |
319 | // Calibs check box | |
320 | fChkAlign = new TGCheckButton(fContChecks, "Align"); | |
321 | fContChecks->AddFrame(fChkAlign, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); | |
322 | fChkAlign->SetToolTipText("Get alingment info"); | |
323 | fChkAlign->SetState(kButtonDown); | |
324 | // Load button | |
325 | fBtnLoad = new TGTextButton(fContLoad, "&Load run"); | |
326 | fBtnLoad->SetName("loadOCDB"); | |
327 | fContLoad->AddFrame(fBtnLoad, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); | |
328 | fBtnLoad->SetToolTipText("Load run from OCDB"); | |
329 | fBtnLoad->Connect("Clicked()", "AliTRDCalibViewerGUI", this, "SetTree()"); | |
330 | ||
331 | // Load a file with AliTRDCalPad objects | |
332 | // main frame | |
333 | fContLoadCalibObjects = new TGGroupFrame(fTabRight1, "Load CalPad from file", kVerticalFrame | kFitWidth | kFitHeight); | |
334 | fTabRight1->AddFrame(fContLoadCalibObjects, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); | |
335 | // container for the input file | |
336 | fContCalibInput = new TGCompositeFrame(fContLoadCalibObjects, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
337 | fContLoadCalibObjects->AddFrame(fContCalibInput, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0)); | |
338 | // label | |
339 | fLblCalibInputFilename = new TGLabel(fContCalibInput, "Input:"); | |
340 | fLblCalibInputFilename->SetTextJustify(kTextLeft); | |
341 | fContCalibInput->AddFrame(fLblCalibInputFilename, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
342 | // text entry | |
343 | fTxtCalibInputFilename = new TGTextEntry(fContCalibInput, "Input file", 200); | |
344 | fContCalibInput->AddFrame(fTxtCalibInputFilename, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
345 | fTxtCalibInputFilename->Connect("DoubleClicked()", "AliTRDCalibViewerGUI", this, "HandleFilesystem()"); | |
346 | // container for the output file | |
347 | fContCalibOutput = new TGCompositeFrame(fContLoadCalibObjects, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
348 | fContLoadCalibObjects->AddFrame(fContCalibOutput, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0)); | |
349 | // label | |
350 | fLblCalibOutputFilename = new TGLabel(fContCalibOutput, "Output:"); | |
351 | fLblCalibOutputFilename->SetTextJustify(kTextLeft); | |
352 | fContCalibOutput->AddFrame(fLblCalibOutputFilename, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
353 | // text entry | |
354 | fTxtCalibOutputFilename = new TGTextEntry(fContCalibOutput, "/tmp/output.root", 201); | |
355 | fContCalibOutput->AddFrame(fTxtCalibOutputFilename, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
356 | fTxtCalibOutputFilename->Connect("DoubleClicked()", "AliTRDCalibViewerGUI", this, "HandleFilesystem()"); | |
357 | // Load button | |
358 | fBtnLoadCalibObjects = new TGTextButton(fContLoadCalibObjects, "L&oad calib"); | |
359 | fBtnLoadCalibObjects->SetName("loadCalPad"); | |
360 | fContLoadCalibObjects->AddFrame(fBtnLoadCalibObjects, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0)); | |
361 | fBtnLoadCalibObjects->SetToolTipText("Extract a tree from an array of AliTRDCalPad objects,\nand load it into this application"); | |
362 | fBtnLoadCalibObjects->Connect("Clicked()", "AliTRDCalibViewerGUI", this, "SetTree()"); | |
363 | ||
364 | SetWindowName("AliTRDCalibViewer GUI"); | |
365 | MapSubwindows(); | |
366 | Resize(GetDefaultSize()); | |
367 | MapWindow(); | |
368 | } | |
369 | ||
370 | //___________________________________________________________________________________ | |
371 | void AliTRDCalibViewerGUI::SetTree() { | |
372 | // | |
373 | // handles the loading of a new tree and updates the GUI | |
374 | // | |
375 | TString fileName; | |
376 | TGTextButton *button = ((TGTextButton*)gTQSender); | |
377 | TString name=button->GetName(); | |
378 | if(name.Contains("OCDB")) { | |
379 | Int_t run = (Int_t)fNmbRun->GetNumber(); | |
380 | TString storage(fTxtStorage->GetText()); | |
381 | Bool_t getCalibs = (fChkCalibs->GetState()==kButtonDown ? kTRUE : kFALSE); | |
382 | Bool_t getDCS = (fChkDCS->GetState()==kButtonDown ? kTRUE : kFALSE); | |
383 | Bool_t getAlign = (fChkAlign->GetState()==kButtonDown ? kTRUE : kFALSE); | |
384 | Int_t version = (Int_t)fNmbVersion->GetNumber(); | |
385 | Int_t subVersion = (Int_t)fNmbSubVersion->GetNumber(); | |
386 | ||
387 | fileName = Form("trdOCDBDetails_run%d.root", run); | |
388 | Bool_t load=kTRUE; | |
389 | load=((AliTRDCalibViewer*)fViewer)->DumpOCDBtoTreeDetails("", fileName.Data(), run, run, storage.Data(), | |
390 | version, subVersion, getCalibs, getDCS, getAlign); | |
391 | if(!load) { | |
392 | Reset(); | |
393 | return; | |
394 | } | |
395 | } | |
396 | if(name.Contains("CalPad")) { | |
397 | ((AliTRDCalibViewer*)fViewer)->DumpCalibToTree(fTxtCalibInputFilename->GetText(), | |
398 | fTxtCalibOutputFilename->GetText()); | |
399 | fileName = fTxtCalibOutputFilename->GetText(); | |
400 | } | |
401 | Initialize(fileName.Data(), "TRDcalibDetails"); | |
402 | Reload(); | |
403 | DoDraw(); | |
404 | } | |
405 | ||
406 | //________________________________________________________________________________________________ | |
407 | void AliTRDCalibViewerGUI::HandleFilesystem() { | |
408 | // | |
409 | // Slot used by the text buttons to trigger the file system dialog | |
410 | // | |
411 | Int_t id = ((TGTextEntry*)gTQSender)->WidgetId(); | |
412 | const char *kTypes[] = { | |
413 | "All files", "*", | |
414 | 0, 0}; | |
415 | TString dir("."); | |
416 | TGFileInfo fi; | |
417 | fi.fFileTypes = kTypes; | |
418 | fi.fOverwrite = kFALSE; | |
419 | new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDOpen, &fi); | |
420 | if(fi.fFilename && strlen(fi.fFilename)) { | |
421 | if(id==200) | |
422 | fTxtCalibInputFilename->SetText(fi.fFilename); | |
423 | if(id==201) | |
424 | fTxtCalibOutputFilename->SetText(fi.fFilename); | |
425 | } | |
426 | return; | |
427 | } | |
428 | ||
429 | //________________________________________________________________________________________________ | |
430 | void AliTRDCalibViewerGUI::Initialize(const char* fileName, const char* treeName) { | |
431 | // | |
432 | // initialize the GUI with a calibrationTree from fileName | |
433 | // | |
434 | // create AliTRDCalibViewer object, which will be used for generating all drawings | |
435 | if (fViewer) delete fViewer; | |
436 | fViewer = new AliTRDCalibViewer(fileName, treeName); | |
437 | Initialize(fViewer); | |
438 | } | |
439 | ||
440 | //________________________________________________________________________________________________ | |
441 | void AliTRDCalibViewerGUI::Initialize(AliBaseCalibViewer *viewer) { | |
442 | // | |
443 | // initializes the GUI with default settings and opens tree for drawing | |
444 | // | |
445 | fViewer = viewer; | |
446 | TString selectedVariable(""); | |
447 | TString selectedNormalization(""); | |
448 | Int_t variableId = -1; | |
449 | Int_t normalizationId = -1; | |
450 | if (fInitialized) { | |
451 | // remember the selected entry | |
452 | if (fListVariables->GetSelectedEntry()) selectedVariable = fListVariables->GetSelectedEntry()->GetTitle(); | |
453 | if (fListNormalization->GetSelectedEntry()) selectedNormalization = fListNormalization->GetSelectedEntry()->GetTitle(); | |
454 | } | |
455 | ||
456 | // fill fListVariables, list of drawable variables: | |
457 | TObjArray* arr = ((AliTRDCalibViewer*)fViewer)->GetListOfVariables(1); | |
458 | if (!arr) { | |
459 | return; | |
460 | } | |
461 | TIterator* iter = arr->MakeIterator(); | |
462 | iter->Reset(); | |
463 | TObjString* currentStr = 0; | |
464 | Int_t id = 0; | |
465 | fListVariables->RemoveAll(); | |
466 | while ((currentStr = (TObjString*)(iter->Next()))) { | |
467 | fListVariables->AddEntry(currentStr->GetString().Data(), id); | |
468 | if (fInitialized && currentStr->GetString() == selectedVariable) variableId = id; | |
469 | id++; | |
470 | } | |
471 | ||
472 | // fill fListNorm, list of normalization variables: | |
473 | TObjArray *arrNorm = ((AliTRDCalibViewer*)fViewer)->GetListOfNormalizationVariables(); | |
474 | TIterator *iterNorm = arrNorm->MakeIterator(); | |
475 | iterNorm->Reset(); | |
476 | currentStr = 0; | |
477 | id = 0; | |
478 | fListNormalization->RemoveAll(); | |
479 | while ((currentStr = (TObjString*)(iterNorm->Next()))) { | |
480 | fListNormalization->AddEntry(currentStr->GetString().Data(), id); | |
481 | if (fInitialized && currentStr->GetString() == selectedNormalization) normalizationId = id; | |
482 | id++; | |
483 | } | |
484 | currentStr = 0; | |
485 | iter->Reset(); | |
486 | //Add draw variables to the list of normalisation | |
487 | while ((currentStr = (TObjString*)(iter->Next()))) { | |
488 | if (currentStr->GetString().BeginsWith("Map")) continue; //don't add mapping information | |
489 | fListNormalization->AddEntry(currentStr->GetString().Data(), id); | |
490 | if (fInitialized && currentStr->GetString() == selectedNormalization) normalizationId = id; | |
491 | id++; | |
492 | } | |
493 | ||
494 | delete iterNorm; | |
495 | arrNorm->Delete(); | |
496 | delete arrNorm; | |
497 | ||
498 | delete iter; | |
499 | arr->Delete(); | |
500 | delete arr; | |
501 | ||
502 | // trick do display the entries corectly after reinitialization | |
503 | // otherwise all the entries would appear as one kryptic entry | |
504 | // resizing the listbox somehow fixes the problem... | |
505 | if (fInitialized) fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight()); | |
506 | if (fInitialized) fListVariables->Resize(fListVariables->GetWidth()+1, fListVariables->GetHeight()); | |
507 | if (fInitialized) fListNormalization->Resize(fListNormalization->GetWidth()-1, fListNormalization->GetHeight()); | |
508 | if (fInitialized) fListNormalization->Resize(fListNormalization->GetWidth()+1, fListNormalization->GetHeight()); | |
509 | ||
510 | // select the last selected variable and normalization | |
511 | if (fInitialized && variableId != -1) fListVariables->Select(variableId); | |
512 | if (fInitialized && normalizationId != -1)fListVariables->Select(normalizationId); | |
513 | ||
514 | if (fInitialized) Info("Initialize", "AliTRDCalibViewerGUI new initialized."); | |
515 | fInitialized = kTRUE; | |
516 | } | |
517 | ||
518 | //________________________________________________________________________________________________ | |
519 | void AliTRDCalibViewerGUI::Reset(){ | |
520 | // | |
521 | // reset variables, delete calib viewer | |
522 | // | |
523 | if (fViewer) delete fViewer; | |
524 | fListVariables->RemoveAll(); | |
525 | fListNormalization->RemoveAll(); | |
526 | fInitialized = kFALSE; | |
527 | } | |
528 | ||
529 | //________________________________________________________________________________________________ | |
530 | TString* AliTRDCalibViewerGUI::GetDrawString() { | |
531 | // | |
532 | // create the draw string out of selection | |
533 | // | |
534 | ||
535 | // specify data to plot | |
536 | TString desiredData(""); | |
537 | if (!fListVariables->GetSelectedEntry()) return 0; | |
538 | desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle(); | |
539 | desiredData += fViewer->GetAbbreviation(); | |
540 | ||
541 | // specify normalization | |
542 | if (fRadioPredefined->GetState() == kButtonDown && fRadioNormalized->GetState() == kButtonDown) { | |
543 | TString op(""); | |
544 | switch (fComboMethod->GetSelected()) { | |
545 | case 0: // subtraction | |
546 | op += "-"; | |
547 | break; | |
548 | case 1: // division | |
549 | op += "/"; | |
550 | break; | |
551 | } | |
552 | TString normalizationData(""); | |
553 | if (!fListNormalization->GetSelectedEntry()) return 0; | |
554 | normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle(); | |
555 | ||
556 | desiredData += op; | |
557 | if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit")) | |
558 | if ( normalizationData.BeginsWith("_") ) desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle(); | |
559 | if ( fListVariables->FindEntry(normalizationData.Data()) ) | |
560 | normalizationData+="~"; | |
561 | desiredData += normalizationData; | |
562 | } | |
563 | else if (fRadioCustom->GetState() == kButtonDown) { | |
564 | desiredData = fComboCustom->GetTextEntry()->GetText(); | |
565 | if (desiredData == "") return 0; | |
566 | ReplacePlaceHolders(desiredData); | |
567 | } | |
568 | ||
569 | // try to add forgotten '~' | |
570 | if (fChkAutoAppend->GetState() == kButtonDown) | |
571 | desiredData = TString(((AliTRDCalibViewer*)fViewer)->AddAbbreviations((char*)desiredData.Data())); | |
572 | return new TString(desiredData.Data()); | |
573 | } | |
574 | ||
575 | //________________________________________________________________________________________________ | |
576 | TString* AliTRDCalibViewerGUI::GetCutString() { | |
577 | // | |
578 | // create the cut string out of selection | |
579 | // | |
580 | ||
581 | TString cutsStr(""); | |
582 | ||
583 | // try to add forgotten '~' | |
584 | if(fChkAutoAppend->GetState() == kButtonDown) | |
585 | cutsStr = TString(((AliTRDCalibViewer*)fViewer)->AddAbbreviations((char*)cutsStr.Data())); | |
586 | return new TString(cutsStr.Data()); | |
587 | } | |
588 | ||
589 | //________________________________________________________________________________________________ | |
590 | TString* AliTRDCalibViewerGUI::GetSectorString() { | |
591 | // | |
592 | // create the sector string out of selection | |
593 | // | |
594 | ||
595 | Int_t layerNo = (Int_t)(fNmbLayer->GetNumber()); | |
596 | Int_t sectorNo = (Int_t)(fNmbSector->GetNumber()); | |
597 | Int_t stackNo = (Int_t)(fNmbStack->GetNumber()); | |
598 | ||
599 | TString sectorStr(""); | |
600 | sectorStr = Form("Layer%dSector%dStack%d", layerNo, sectorNo, stackNo); | |
601 | ||
602 | return new TString(sectorStr.Data()); | |
603 | } | |
604 | ||
605 | //________________________________________________________________________________________________ | |
606 | void AliTRDCalibViewerGUI::DoDraw() { | |
607 | // | |
608 | // main method for drawing according to user selection | |
609 | // | |
610 | ||
611 | // specify data to plot: | |
612 | if (!GetDrawString()) return; | |
613 | TString desiredData(GetDrawString()->Data()); | |
614 | // specify sector: | |
615 | TString sectorStr(GetSectorString()->Data()); | |
616 | // specify cuts: | |
617 | TString cutsStr(GetCutString()->Data()); | |
618 | ||
619 | TString addDrawOpt(""); | |
620 | if (fChkAddDrawOpt->GetState() == kButtonDown) | |
621 | addDrawOpt += fComboAddDrawOpt->GetTextEntry()->GetText(); | |
622 | ||
623 | // remove last picture | |
624 | if (!addDrawOpt.Contains("same")) | |
625 | for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) { | |
626 | if (strcmp(fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->ClassName(), "TFrame") != 0) | |
627 | fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->Delete(); | |
628 | } | |
629 | //fCanvMain->GetCanvas()->Clear(); | |
630 | fCanvMain->GetCanvas()->cd(); | |
631 | Int_t entries = -1; | |
632 | // draw finally | |
633 | if (fRadio1D->GetState() == kButtonDown){ | |
634 | // 1D-Drawing | |
635 | TString strSigmaMax(fTxtSigmaMax->GetText()); // get sigmaMax from text enty | |
636 | Double_t sigmaMax = (strSigmaMax.IsFloat()) ? strSigmaMax.Atof() : 5; // convert to double, if not convertable, set to 5 | |
637 | Bool_t plotMean = fChkMean->GetState() == kButtonDown; | |
638 | Bool_t plotMedian = fChkMedian->GetState() == kButtonDown; | |
639 | Bool_t plotLTM = fChkLTM->GetState() == kButtonDown; | |
640 | if (fRadioNorm->GetState() == kButtonDown) // normal 1D drawing | |
641 | entries = ((AliTRDCalibViewer*)fViewer)->EasyDraw1D(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), addDrawOpt.Data()); | |
642 | if (fRadioSigma->GetState() == kButtonDown) // sigma 1D drawing | |
643 | entries = fViewer->DrawHisto1D(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), // | |
644 | fTxtSigmas->GetText(), plotMean, plotMedian, plotLTM); | |
645 | if (fRadioCumulative->GetState() == kButtonDown) // cumulative 1D drawing | |
646 | entries = fViewer->SigmaCut(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), // | |
647 | sigmaMax, plotMean, plotMedian, plotLTM, // | |
648 | fCheckCumulativePM->GetState() == kButtonDown, fTxtSigmas->GetText(), /* Float_t sigmaStep =*/ -1); | |
649 | if (fRadioIntegrate->GetState() == kButtonDown) // integral 1D drawing | |
650 | entries = fViewer->Integrate(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), // | |
651 | sigmaMax, plotMean, plotMedian, plotLTM, // | |
652 | fTxtSigmas->GetText(), /* Float_t sigmaStep =*/ -1); | |
653 | } | |
654 | else if (fRadio2D->GetState() == kButtonDown) { | |
655 | // 2D-Drawing | |
656 | entries = ((AliTRDCalibViewer*)fViewer)->EasyDraw(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), addDrawOpt.Data()); | |
657 | } | |
658 | if (entries == -1) return; // nothing was drawn, there is no histogram to get min and max | |
659 | ||
660 | SetMinMaxLabel(); | |
661 | fCanvMain->GetCanvas()->Update(); | |
662 | } | |
663 | ||
664 | //________________________________________________________________________________________________ | |
665 | void AliTRDCalibViewerGUI::MouseMove(Int_t event, Int_t x, Int_t y, TObject *selectedObject) { | |
666 | // | |
667 | // mouse move | |
668 | // zoom to chamber works ONLY in 2D mode | |
669 | // | |
670 | if(event != kButton1Double ) | |
671 | return; | |
672 | if(!selectedObject->InheritsFrom("TH2")) return; | |
673 | ||
fc2125de | 674 | //Int_t layerNo = (Int_t)(fNmbLayer->GetNumber()); |
9bf458e3 | 675 | Int_t sectorNo = (Int_t)(fNmbSector->GetNumber()); |
676 | Int_t stackNo = (Int_t)(fNmbStack->GetNumber()); | |
677 | ||
678 | // zoom out to the current layer if a chamber is viewed now | |
679 | if(sectorNo!=-1 && stackNo!=-1) { | |
680 | fNmbSector->SetNumber(-1); | |
681 | fNmbStack->SetNumber(-1); | |
682 | DoNewSelection(); | |
683 | return; | |
684 | } | |
685 | ||
686 | // check what kind of parameter we visualize | |
687 | TString drawStr(GetDrawString()->Data()); | |
688 | Int_t viewedParamClass = -1; // -1 nothing, 0 calibration, 1 FEE params | |
689 | if(drawStr.Contains("Status") || drawStr.Contains("Gain") || drawStr.Contains("Noise") || | |
690 | drawStr.Contains("Vdrift") || drawStr.Contains("T0") || | |
691 | drawStr.Contains("gain") || drawStr.Contains("chiSquare")) | |
692 | viewedParamClass = 0; | |
693 | if(drawStr.Contains("SORandEOR") || | |
694 | drawStr.Contains("gsmSOR") || drawStr.Contains("gsmDelta") || | |
695 | drawStr.Contains("nimSOR") || drawStr.Contains("nimDelta") || | |
696 | drawStr.Contains("nevSOR") || drawStr.Contains("nevDelta") || | |
697 | drawStr.Contains("nptSOR") || drawStr.Contains("nptDelta")) { | |
698 | viewedParamClass = 1; | |
699 | } | |
700 | if(viewedParamClass==-1) return; | |
701 | ||
702 | // some constants refering to the TRD geometry | |
703 | const Int_t gkNRows[ 5] = {16, 16, 12, 16, 16}; // number of pad rows in the chambers from each of the 5 stacks | |
704 | const Int_t gkNCols = 144; // number of pad cols per chamber | |
705 | ||
706 | // get the coordinate of the clicked point in physical coordinates | |
707 | Float_t upy = gPad->AbsPixeltoY(y); | |
708 | Float_t upx = gPad->AbsPixeltoX(x); | |
709 | Float_t gy = gPad->PadtoY(upy); | |
710 | Float_t gx = gPad->PadtoX(upx); | |
711 | Int_t selectedStack = -1; | |
712 | Int_t selectedSector = -1; | |
713 | ||
714 | // retrieve the double-clicked chamber | |
715 | if(sectorNo==-1 && stackNo==-1) { | |
716 | // get the selected stack | |
717 | Float_t rowLowBound = -0.5; | |
718 | Float_t rowHighBound = -0.5; | |
719 | for(Int_t i=0; i<5; i++) { | |
720 | if(i>0) rowLowBound += gkNRows[i-1]; | |
721 | rowHighBound += gkNRows[i]; | |
722 | if(gx>=rowLowBound && gx<=rowHighBound) | |
723 | selectedStack = i; | |
724 | } | |
725 | // get the selected sector | |
726 | if(viewedParamClass==0) { // calibration params | |
727 | selectedSector = (Int_t)TMath::Floor((gy+0.5)/Float_t(gkNCols)); | |
728 | } | |
729 | if(viewedParamClass==1) { // FEE params | |
730 | selectedSector = (Int_t)TMath::Floor((gy+0.5)/8.0); // 8 MCMs per chamber in pad cols direction | |
731 | } | |
732 | } | |
733 | if(sectorNo!=-1 && stackNo==-1) { | |
734 | // get the selected stack | |
735 | Float_t rowLowBound = -0.5; | |
736 | Float_t rowHighBound = -0.5; | |
737 | for(Int_t i=0; i<5; i++) { | |
738 | if(i>0) rowLowBound += gkNRows[i-1]; | |
739 | rowHighBound += gkNRows[i]; | |
740 | if(gx>=rowLowBound && gx<=rowHighBound) | |
741 | selectedStack = i; | |
742 | } | |
743 | // get the selected sector | |
744 | selectedSector = sectorNo; | |
745 | } | |
746 | if(sectorNo==-1 && stackNo!=-1) { | |
747 | // get the selected stack | |
748 | selectedStack = stackNo; | |
749 | // get the selected sector | |
750 | if(viewedParamClass==0) { // calibration params | |
751 | selectedSector = (Int_t)TMath::Floor((gy+0.5)/144.0); | |
752 | } | |
753 | if(viewedParamClass==1) { // FEE params | |
754 | selectedSector = (Int_t)TMath::Floor((gy+0.5)/8.0); | |
755 | } | |
756 | } | |
757 | ||
758 | fNmbSector->SetNumber(selectedSector); | |
759 | fNmbStack->SetNumber(selectedStack); | |
760 | DoNewSelection(); | |
761 | return; | |
762 | } | |
763 | ||
764 | //___________________________________________________________________________ | |
765 | void AliTRDCalibViewerGUI::ShowGUI() { | |
766 | // | |
767 | // Draw the graphical user interface | |
768 | // | |
769 | TGMainFrame* mainWindow = new TGMainFrame(gClient->GetRoot(), 1000, 700); | |
770 | mainWindow->SetWindowName("Run OCDB details"); | |
771 | mainWindow->SetCleanup(kDeepCleanup); | |
772 | AliTRDCalibViewerGUI *calibViewer = new AliTRDCalibViewerGUI(mainWindow, 1000, 650, 0); | |
773 | mainWindow->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
774 | mainWindow->MapSubwindows(); | |
775 | mainWindow->Resize(); | |
776 | mainWindow->MapWindow(); | |
777 | } | |
778 | ||
779 | //___________________________________________________________________________ | |
780 | void AliTRDCalibViewerGUI::ShowGUI(const Char_t* treeFile, const Char_t* treeName) { | |
781 | // | |
782 | // Draw the graphical user interface | |
783 | // | |
784 | TGMainFrame* mainWindow = new TGMainFrame(gClient->GetRoot(), 1000, 700); | |
785 | mainWindow->SetWindowName("Run OCDB details"); | |
786 | mainWindow->SetCleanup(kDeepCleanup); | |
787 | AliBaseCalibViewerGUI *calibViewer = new AliTRDCalibViewerGUI(mainWindow, 1000, 650, 0); | |
788 | mainWindow->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
789 | ||
790 | calibViewer->Initialize(treeFile, treeName); | |
791 | calibViewer->Reload(); | |
792 | calibViewer->DoDraw(); | |
793 | ||
794 | mainWindow->MapSubwindows(); | |
795 | mainWindow->Resize(); | |
796 | mainWindow->MapWindow(); | |
797 | } | |
798 | ||
799 | //___________________________________________________________________________ | |
800 | void AliTRDCalibViewerGUI::ShowGUIwithTrending() { | |
801 | // | |
802 | // Draw a GUI application containing 2 tabs: | |
803 | // -- tab for time/run trending | |
804 | // -- tab for run details | |
805 | TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 700); | |
806 | frmMain->SetCleanup(kDeepCleanup); | |
807 | ||
808 | TGTab* tabMain = new TGTab(frmMain, 1000, 700); | |
809 | frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
810 | TGCompositeFrame* tabCont1 = tabMain->AddTab("Time"); | |
811 | TGCompositeFrame* tabCont2 = tabMain->AddTab("Detail - XXXXX"); | |
812 | ||
813 | AliCalibViewerGUItime* calibViewerTime = new AliCalibViewerGUItime(tabCont1, 1000, 650, "TRD"); | |
814 | tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
815 | ||
816 | AliTRDCalibViewerGUI *calibViewer = new AliTRDCalibViewerGUI(tabCont2, 1000, 700, 0); | |
817 | tabCont2->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
818 | calibViewerTime->SetCalibViewerGUI(calibViewer); | |
819 | calibViewerTime->SetCalibViewerGUItab(tabMain->GetTabTab(1)); | |
820 | ||
821 | frmMain->MapSubwindows(); | |
822 | frmMain->Resize(); | |
823 | frmMain->MapWindow(); | |
824 | } |