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