Fixes for wrong use of const causing PW.CAST_TO_QUALIFIED_TYPE defect in Coverity
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibViewerGUItime.cxx
CommitLineData
5312f439 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
17///////////////////////////////////////////////////////////////////////////////
18// //
19// //
20///////////////////////////////////////////////////////////////////////////////
21
6e7d7dc4 22
5312f439 23#include <iostream>
24//Root includes
25#include <TROOT.h>
26#include <TDirectory.h>
27#include <TStyle.h>
28#include <TCanvas.h>
29#include <TPad.h>
30#include <TVirtualPad.h>
31#include <TObject.h>
32#include <TObjArray.h>
33#include <TObjString.h>
6fb51ca4 34#include <TSystem.h>
5312f439 35#include <TVector.h>
36#include <TH1.h>
37#include <TCut.h>
38#include <TFile.h>
39#include <TTree.h>
e6970ab5 40#include <TChain.h>
5312f439 41#include <TBranch.h>
42#include <TIterator.h>
43#include <TGraph.h>
44#include <TAxis.h>
45#include <TTimeStamp.h>
46#include <TMath.h>
7390f655 47#include <TMap.h>
5312f439 48//
49#include <TGFileDialog.h>
50#include <TGInputDialog.h>
51//
52#include <TGButton.h>
53#include <TGListBox.h>
54#include <TGComboBox.h>
55#include <TGNumberEntry.h>
56#include <TGLayout.h>
57#include <TRootEmbeddedCanvas.h>
58#include <TGSplitter.h>
59#include <TGButtonGroup.h>
60#include <TGLabel.h>
61#include <TGTab.h>
62#include <TGString.h>
63
64//AliRoot includes
6fb51ca4 65#include <AliLog.h>
5312f439 66#include "AliTPCCalibViewerGUI.h"
7390f655 67#include "AliTPCCalibViewer.h"
5312f439 68#include "AliTPCcalibDB.h"
949d8707 69#include "AliTPCcalibDButil.h"
6fb51ca4 70#include "AliTPCConfigParser.h"
5312f439 71
72#include "AliTPCCalibViewerGUItime.h"
73
74ClassImp(AliTPCCalibViewerGUItime)
75
76AliTPCCalibViewerGUItime::AliTPCCalibViewerGUItime(const TGWindow *p, UInt_t w, UInt_t h) :
77TGCompositeFrame(p,w,h),
78 fFile(0x0),
79 fTree(0x0),
80 fCalibViewerGUI(0x0),
81 fCalibViewerGUItab(0x0),
82 fCurrentHist(0x0),
83 fCurrentGraph(0x0),
84 fCurrentRunDetails(-1),
85 fOutputCacheDir("/tmp"),
86 fDrawString(""),
6e7d7dc4 87 fConfigFile(""),
88 fConfigParser(new AliTPCConfigParser),
5312f439 89 fIsCustomDraw(kFALSE),
90 fRunNumbers(10),
91 fTimeStamps(10),
92 fValuesX(10),
93 fValuesY(10),
6e7d7dc4 94 fNoGraph(kFALSE),
95 fGraphLimitEntries(10000),
7390f655 96 fMapRefTrees(new TMap),
5312f439 97 //GUI elements
98 //main canvas Top part, bottom part
99 fContTopBottom(0x0),
100 //top left, centre, right
101 fContLCR(0x0),
102 //content left
103 fContLeft(0x0),
6e7d7dc4 104 fContDrawOpt(0x0),
105 fChkDrawOptSame(0x0),
f416ad83 106 fChkDrawOptSparse(0x0),
6e7d7dc4 107 fComboAddDrawOpt(0x0),
5312f439 108 fContDrawSel(0x0),
109 fContDrawSelSubRunTime(0x0),
110 fRadioXhist(0x0),
111 fRadioXrun(0x0),
112 fRadioXtime(0x0),
113 fListVariables(0x0),
114 fComboRunType(0x0),
115 fLblRunType(0x0),
116 fNmbPar(0x0),
117 fLblPar(0x0),
6fb51ca4 118 fListCalibType(0x0),
119 fContCalibType(0x0),
5312f439 120 //content centre
121 fContCenter(0x0),
122 fCanvMain(0x0),
123 //content right
124 fContRight(0x0),
125 fContValues(0x0),
126 fLblRunNumber(0x0),
127 fLblRunTime(0x0),
128 fLblValueX(0x0),
129 fLblValueY(0x0),
130 fLblRunNumberVal(0x0),
131 fLblRunTimeVal(0x0),
132 fLblValueXVal(0x0),
133 fLblValueYVal(0x0),
134 fBtnDumpRuns(0x0),
514fcaf7 135 fContAliases(0x0),
136 fListAliases(0x0),
5312f439 137 //content bottom
138 fContCustom(0x0),
139 fContCustomCuts(0x0),
140 fLblCustomDraw(0x0),
141 fLblCustomCuts(0x0),
142 fComboCustomDraw(0x0),
6e7d7dc4 143 fComboCustomCuts(0x0),
144 fTrashBox(new TObjArray)
5312f439 145{
146 //
147 // ctor
148 //
7390f655 149 fMapRefTrees->SetOwnerKeyValue();
150 fTrashBox->SetOwner();
5312f439 151 DrawGUI(p,w,h);
6e7d7dc4 152 gStyle->SetMarkerStyle(20);
153 gStyle->SetMarkerSize(0.5);
5312f439 154 SetInitialValues();
155}
156//______________________________________________________________________________
157AliTPCCalibViewerGUItime::~AliTPCCalibViewerGUItime(){
158 //
159 // dtor
160 //
6e7d7dc4 161 delete fConfigParser;
162 delete fTrashBox;
7390f655 163 delete fMapRefTrees;
5312f439 164}
165//______________________________________________________________________________
6fb51ca4 166void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) {
5312f439 167 //
168 // draw the GUI
169 //
170 // ======================================================================
171 // ************************* Display everything *************************
172 // ======================================================================
173
174 SetCleanup(kDeepCleanup);
5312f439 175
176 // *****************************************************************************
177 // ************************* content of this MainFrame *************************
178 // *****************************************************************************
179 // top level container with horizontal layout
180 fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
181 AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
182
183 fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
184 fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
185
186 // ***********************************************************************
187 // ************************* content of fContLCR *************************
188 // ***********************************************************************
189 // left container
190 fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
191 fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
192
193 // left vertical splitter
194 TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
195 splitLeft->SetFrame(fContLeft, kTRUE);
196 fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
197
198 // right container
199 fContRight = new TGCompositeFrame(fContLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight);
200 fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
201
202 // center container
203 fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
204 fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
205
206 // right vertical splitter
207 TGVSplitter *splitRight = new TGVSplitter(fContLCR);
208 splitRight->SetFrame(fContRight, kFALSE);
209 fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
210
211
212 // ========================================================================
213 // ************************* content of fContLeft *************************
214 // ========================================================================
215 // --- draw button and tabLeft ---
6e7d7dc4 216 // draw options
217 fContDrawOpt = new TGGroupFrame(fContLeft, "Draw options", kVerticalFrame | kFitWidth | kFitHeight);
218 fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
f416ad83 219
220 TGCompositeFrame *cfr = new TGCompositeFrame(fContDrawOpt, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
221 fContDrawOpt->AddFrame(cfr, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
222
223 fChkDrawOptSame = new TGCheckButton(cfr, "Same");
224 cfr->AddFrame(fChkDrawOptSame, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
6e7d7dc4 225 fChkDrawOptSame->SetToolTipText("Add draw option 'same'");
f416ad83 226
227 fChkDrawOptSparse = new TGCheckButton(cfr, "Sparse");
228 cfr->AddFrame(fChkDrawOptSparse, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
229 fChkDrawOptSparse->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoNewSelection()");
230 fChkDrawOptSparse->SetToolTipText("In case of run trending only plot runs with information");
231
6e7d7dc4 232 // additional draw options combo box
233 fComboAddDrawOpt = new TGComboBox(fContDrawOpt);
234 fComboAddDrawOpt->Resize(0, 22);
235 fComboAddDrawOpt->EnableTextInput(kTRUE);
236 fContDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
237// fComboAddDrawOpt->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral(=14)");
238// fComboAddDrawOpt->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
bf05fdb7 239 fComboAddDrawOpt->GetTextEntry()->SetText("",kFALSE);
6e7d7dc4 240
5312f439 241 // draw selection group
242 fContDrawSel = new TGGroupFrame(fContLeft, "Draw selection", kVerticalFrame | kFitWidth | kFitHeight);
243 fContLeft->AddFrame(fContDrawSel, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
244 //x-axis variables selection, Run of Time
245 fContDrawSelSubRunTime = new TGCompositeFrame(fContDrawSel, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
246 fContDrawSel->AddFrame(fContDrawSelSubRunTime, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
247
248 // ------------------------- content of fContDrawOpt -------------------------
249 //
250 // Run radio button
251 // Time radio button
252 fRadioXhist = new TGRadioButton(fContDrawSelSubRunTime, "hist", kRadioXhist);
253 fContDrawSelSubRunTime->AddFrame(fRadioXhist, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
254 fRadioXhist->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
255 fRadioXhist->SetToolTipText("Draw the distribution of the variable");
256
257 fRadioXrun = new TGRadioButton(fContDrawSelSubRunTime, ":Run", kRadioXrun);
258 fContDrawSelSubRunTime->AddFrame(fRadioXrun, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
259 fRadioXrun->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
260 fRadioXrun->SetToolTipText("Use run number as x-value");
261
262 // Time radio button
263 fRadioXtime = new TGRadioButton(fContDrawSelSubRunTime, ":Time", kRadioXtime);
264 fContDrawSelSubRunTime->AddFrame(fRadioXtime, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
265 fRadioXtime->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
266 fRadioXtime->SetToolTipText("Use time stamp number as x-value");
267
268
269 // list of variables
270 fListVariables = new TGListBox(fContDrawSel);
271 fContDrawSel->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
272 fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelection()");
273
6fb51ca4 274
275//-------------------- run type selection ------------------------
5312f439 276 // Parameter label
277 fLblRunType = new TGLabel(fContDrawSel, "Run Type:");
278 fLblRunType->SetTextJustify(kTextLeft);
279 fContDrawSel->AddFrame(fLblRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
280
281 fComboRunType = new TGComboBox(fContDrawSel);
282 fComboRunType->EnableTextInput(kFALSE);
283 fContDrawSel->AddFrame(fComboRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
284 fComboRunType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoDraw()");
285// fComboRunType->SetEnabled(kFALSE);
286 fComboRunType->Resize(0, 22);
287
288 //-------------------- parameter selection ------------------------
289 // Parameter label
290 fLblPar = new TGLabel(fContDrawSel, "Parameter:");
291 fLblPar->SetTextJustify(kTextLeft);
292 fContDrawSel->AddFrame(fLblPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
293
294 fNmbPar = new TGNumberEntry(fContDrawSel, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
295 fContDrawSel->AddFrame(fNmbPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
296 fNmbPar->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUItime", this, "DoParLimitChange()");
297 fNmbPar->SetState(kFALSE);
298
6fb51ca4 299 //-------------------- calibration type selection ------------------------
300 // label
301 // draw selection group
302 fContCalibType = new TGGroupFrame(fContLeft, "Calib type selection", kVerticalFrame | kFitWidth | kFitHeight);
303 fContLeft->AddFrame(fContCalibType, new TGLayoutHints(kLHintsExpandX , 0, 0, 10, 0));
304
305 // list of variables
306 fListCalibType = new TGListBox(fContCalibType);
307 fContCalibType->AddFrame(fListCalibType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX , 0, 0, 0, 0));
308 fListCalibType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoChangeSelectionList()");
309 fListCalibType->Resize(0,88);
310 fListCalibType->SetMultipleSelections();
311
5312f439 312
313 // ==========================================================================
314 // ************************* content of fContCenter *************************
315 // ========================================================================
316 // main drawing canvas
317 fCanvMain = new TRootEmbeddedCanvas("GUItime_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
318 fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
319 fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliTPCCalibViewerGUItime", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
320// fCanvMain->GetCanvas()->Connect("RangeAxisChanged()", "AliTPCCalibViewerGUItime", this, "GetMinMax()");
321 fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed.");
6fb51ca4 322 fCanvMain->GetCanvas()->SetRightMargin(0.062);
323 fCanvMain->GetCanvas()->SetLeftMargin(0.15);
5312f439 324
325 // =========================================================================
326 // ************************* content of fContRight *************************
327 // ========================================================================
328 //group frame for value information
329 fContValues = new TGGroupFrame(fContRight, "Data point info", kVerticalFrame | kFitWidth | kFitHeight);
330 fContRight->AddFrame(fContValues, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
331 //set layout manager
332 fContValues->SetLayoutManager(new TGMatrixLayout(fContValues, 0, 2, 5));
333 //value information labels
334
335 //run number label
336 fLblRunNumber = new TGLabel(fContValues, "Run:");
337 fLblRunNumber->SetTextJustify(kTextLeft);
338 fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
339 //run number
909c8c99 340 fLblRunNumberVal = new TGLabel(fContValues, "000000");
5312f439 341 fLblRunNumberVal->SetTextJustify(kTextLeft);
342 fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
343 //time stamp label
344 fLblRunTime = new TGLabel(fContValues, "Time:");
345 fLblRunTime->SetTextJustify(kTextLeft);
346 fContValues->AddFrame(fLblRunTime, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
347 //run number
348 fLblRunTimeVal = new TGLabel(fContValues, "00.00.0000\n00:00:00");
349 fLblRunTimeVal->SetTextJustify(kTextLeft);
350 fContValues->AddFrame(fLblRunTimeVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
351 //value label x
352 fLblValueX = new TGLabel(fContValues, "x-Value:");
353 fLblValueX->SetTextJustify(kTextLeft);
354 fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
355 //value x
892226be 356 fLblValueXVal = new TGLabel(fContValues, "00.000e+00");
5312f439 357 fLblValueXVal->SetTextJustify(kTextRight);
358 fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
359 //value label y
360 fLblValueY = new TGLabel(fContValues, "y-Value:");
361 fLblValueY->SetTextJustify(kTextLeft);
362 fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
363 //value y
892226be 364 fLblValueYVal = new TGLabel(fContValues, "00.000e+00");
5312f439 365 fLblValueYVal->SetTextJustify(kTextRight);
366 fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
367 // draw button
368 fBtnDumpRuns = new TGTextButton(fContRight, "&Dump runs");
6fb51ca4 369 fContRight->AddFrame(fBtnDumpRuns, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
5312f439 370 fBtnDumpRuns->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDumpRuns()");
371 fBtnDumpRuns->SetToolTipText("Press to dump the run numbers of the current selection.");
514fcaf7 372 //group frame for value information
373 fContAliases = new TGGroupFrame(fContRight, "Aliases", kVerticalFrame | kFitWidth | kFitHeight);
374 fContRight->AddFrame(fContAliases, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
375 // list of aliases
376 fListAliases = new TGListBox(fContAliases);
377 fContAliases->AddFrame(fListAliases, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
378 fListAliases->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelectionAliases()");
379// fListAliases->Resize(0,88);
380 //buttons
381 TGCompositeFrame *frame1 = new TGCompositeFrame(fContAliases, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
382 fContAliases->AddFrame(frame1, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
383 // add button
384 TGTextButton *btnAdd = new TGTextButton(frame1, "&Add");
385 frame1->AddFrame(btnAdd, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
386 btnAdd->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoAddAlias()");
387 btnAdd->SetToolTipText("Press to add an alias.");
388 btnAdd->Resize(0,22);
389 // del button
390 TGTextButton *btnDel = new TGTextButton(frame1, "&Del");
391 frame1->AddFrame(btnDel, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
392 btnDel->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDelAlias()");
393 btnDel->SetToolTipText("Press to delete the selected alias.");
394 btnDel->Resize(0,22);
395 // update button
396 TGTextButton *btnUp = new TGTextButton(frame1, "&Upd");
397 frame1->AddFrame(btnUp, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
398 btnUp->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "UpdateAliasList()");
399 btnUp->SetToolTipText("Press to update the alias list.");
400 btnUp->Resize(0,22);
401
402
5312f439 403
404 // =========================================================================
405 // ****************** bottom content of fContTopBottom *********************
406 // =========================================================================
407
408 // custom options container
409 // --- fComboCustom --- the custom draw line on the very low
410 fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
411 fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
412
413 // ------------------------- content of fContCustom -------------------------
414 fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: ");
415 fLblCustomDraw->SetTextJustify(kTextLeft);
416 fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
417 // text field for custom draw command
418 fComboCustomDraw = new TGComboBox(fContCustom);
419// fComboCustomDraw->Resize(0, fLblValueY->GetDefaultHeight());
420 fComboCustomDraw->Resize(0, 22);
421 fComboCustomDraw->EnableTextInput(kTRUE);
422 fContCustom->AddFrame(fComboCustomDraw, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
423 fComboCustomDraw->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
424 fComboCustomDraw->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
bf05fdb7 425 fComboCustomDraw->GetTextEntry()->SetText("",kFALSE);
5312f439 426
427 // additional cuts container
428 fContCustomCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
429 fContTopBottom->AddFrame(fContCustomCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
430
431 // ------------------------- content of fContCustomCuts -------------------------
432 fLblCustomCuts = new TGLabel(fContCustomCuts, "Custom cuts: ");
433 fLblCustomCuts->SetTextJustify(kTextLeft);
434 fContCustomCuts->AddFrame(fLblCustomCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
435 // combo text field for additional cuts
436 fComboCustomCuts = new TGComboBox(fContCustomCuts);
437// fComboCustomCuts->Resize(0, fLblValueY->GetDefaultHeight());
438 fComboCustomCuts->Resize(0, 22);
439 fComboCustomCuts->EnableTextInput(kTRUE);
440 fContCustomCuts->AddFrame(fComboCustomCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
6fb51ca4 441 fComboCustomCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
442 fComboCustomCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
bf05fdb7 443 fComboCustomCuts->GetTextEntry()->SetText("",kFALSE);
444
5312f439 445 SetWindowName("AliTPCCalibViewer GUI - Time");
446 MapSubwindows();
447 Resize(GetDefaultSize());
448 MapWindow();
449}
450//______________________________________________________________________________
451void AliTPCCalibViewerGUItime::SetInitialValues(){
452 //
453 // Set inital selections of the gui
454 //
455 fRadioXrun->SetState(kButtonDown);
456 fRadioXtime->SetState(kButtonUp);
457}
458
459//______________________________________________________________________________
6e7d7dc4 460void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeName) {
5312f439 461 //
462 // retrieve tree from file
463 //
5d0d653f 464 TObjArray *arr=0x0;
465 TString file(fileName);
466 if (file.Contains("://")) {
467 if (file.Contains(";")) {
468 arr=file.Tokenize(";");
469 } else {
470 arr=new TObjArray;
471 arr->Add(new TObjString(fileName));
472 }
473 } else {
474 TString s=gSystem->GetFromPipe(Form("ls %s",fileName));
475 arr=s.Tokenize("\n");
476 }
477
478 if (!arr) return;
e6970ab5 479 TIter next(arr);
480 TObject *o=0;
481 if (fTree) delete fTree;
6e7d7dc4 482 fTree=new TChain(treeName);
e6970ab5 483 while ( (o=next()) ){
484 fTree->AddFile(o->GetName());
485 }
5d0d653f 486 arr->SetOwner();
e6970ab5 487 delete arr;
6e7d7dc4 488 if (!CheckChain()) return;
489 UseConfigFile(fConfigFile.Data());
490 Reload();
491
492}
493//______________________________________________________________________________
798017c7 494void AliTPCCalibViewerGUItime::UseChain(TChain *const chain = 0)
6e7d7dc4 495{
496 //
497 //
498 //
499 fTree=chain;
500 if (!CheckChain()) return;
501 //set configuration file
502 UseConfigFile(fConfigFile.Data());
503 Reload();
504}
505//______________________________________________________________________________
506Bool_t AliTPCCalibViewerGUItime::CheckChain()
507{
508 //
509 // check whether cahin has entries
510 // decide whether to draw graphs in 2D
511 //
512 if (!fTree) return kFALSE;
e6970ab5 513 fTree->Lookup();
6e7d7dc4 514 Long64_t entries=fTree->GetEntries();
515 if (entries==0){
e6970ab5 516 AliError("No entries found in chain");
6e7d7dc4 517 return kFALSE;
6fb51ca4 518 }
6e7d7dc4 519 //check whether to draw graphs
520 CheckDrawGraph();
521 return kTRUE;
522}
523//______________________________________________________________________________
524void AliTPCCalibViewerGUItime::UseConfigFile(const char* file)
525{
526 //
527 // Use 'file' as configuration file
528 //
529 fConfigFile=file;
530 fConfigParser->ParseConfigFileTxt(fConfigFile.Data());
531 FillCalibTypes();
5312f439 532}
533//______________________________________________________________________________
6fb51ca4 534void AliTPCCalibViewerGUItime::FillRunTypes()
535{
5312f439 536 //
6fb51ca4 537 //Loop over the tree entries and fill the run types
5312f439 538 //
6fb51ca4 539 if (!fTree) return;
5312f439 540 Int_t id=0;
5312f439 541 fComboRunType->RemoveAll();
542 fComboRunType->AddEntry("ALL",id++);
543 fComboRunType->Select(0,kFALSE);
6e7d7dc4 544 if (!fTree->GetBranch("runType.")) return;
5312f439 545 TObjString *runType=0x0;
546 Int_t nevets=fTree->GetEntries();
5312f439 547 fTree->SetBranchStatus("*",0);
548 fTree->SetBranchStatus("runType.*",1);
e6970ab5 549 fTree->SetBranchAddress("runType.",&runType);
5312f439 550 for (Int_t iev=0;iev<nevets;++iev){
551 fTree->GetEntry(iev);
552 TString type=runType->String();
553 if (!type.IsNull()&&!fComboRunType->FindEntry(type)) fComboRunType->AddEntry(type,id++);
554 }
e6970ab5 555 fTree->ResetBranchAddresses();
5312f439 556 fTree->SetBranchStatus("*",1);
557}
558//______________________________________________________________________________
6fb51ca4 559void AliTPCCalibViewerGUItime::FillCalibTypes()
560{
561 //
562 // loop over configuration and fill calibration types
563 //
6fb51ca4 564 Int_t id=0;
565 fListCalibType->RemoveAll();
566 TObject *o=0x0;
567 fConfigParser->ResetIter();
568 TString type;
569 while ( (o=fConfigParser->NextKey()) ){
570 type=fConfigParser->GetData(o,kCalibType);
571 //remove whitespcaces
572 type.Remove(TString::kBoth,' ');
573 type.Remove(TString::kBoth,'\t');
574 if (type.IsNull()) type="UNSPECIFIED";
575// printf("CalibType: '%s'\n",type.Data());
576 if (!fListCalibType->FindEntry(type.Data())) {
bf05fdb7 577 fListCalibType->AddEntry(type.Data(),id);
6fb51ca4 578 fListCalibType->Select(id++);
579 }
580 }
581 //add type for unspecified calibration type
582 type="UNSPECIFIED";
583 if (!fListCalibType->FindEntry(type.Data())) {
bf05fdb7 584 fListCalibType->AddEntry(type.Data(),id);
6fb51ca4 585 fListCalibType->Select(id++);
586 }
587}
588//______________________________________________________________________________
6e7d7dc4 589void AliTPCCalibViewerGUItime::CheckDrawGraph()
590{
591 //
592 // Check whether to draw graphs in 2D mode based on the number of entries in the chain
593 // GetEstimate() returns the maximum size of the arrays stored in GetV1()...
594 //
595 if (!fTree) return;
596 fNoGraph=kTRUE;
597 if (fTree->GetEntries()<fTree->GetEstimate()) fNoGraph=kFALSE;
598}
599//______________________________________________________________________________
600void AliTPCCalibViewerGUItime::Reload(Int_t first)
601{
6fb51ca4 602 //
603 // reload the gui contents, this is needed after the input tree has changed
604 //
605
606 if ( !fTree ) return;
607 //in case of the first call create run type and calibration type entries
608 if (first){
609 FillRunTypes();
610 FillCalibTypes();
611 }
612 //activate all branches
613 fTree->SetBranchStatus("*",1);
614 //reset variables list
615 fListVariables->RemoveAll();
616 //get selected calibration types
617 TList calibTypes;
618 fListCalibType->GetSelectedEntries(&calibTypes);
619
620 TObjArray *branchList = fTree->GetListOfBranches();
621 if ( !branchList ) return;
622 TIter nextBranch(branchList);
623 Int_t idCount=0,id=0;
624 TObject *objBranch=0;
625 while ( (objBranch=nextBranch()) ){
626 TString branchName(objBranch->GetName());
627 TString branchTitle(objBranch->GetName());
628 if (branchName == "run" || branchName == "time" || branchName == "runType.") continue;
629 Bool_t active=kTRUE;
630 TString calibType="UNSPECIFIED";
631 if (fConfigParser){
632 const TObject *key=(*fConfigParser)(branchName.Data());
633 if (key){
634 //test if branch is active
635 active=fConfigParser->GetValue(branchName.Data(),kBranchOnOff);
636 id=(*fConfigParser)()->IndexOf(key);
892226be 637// branchTitle=fConfigParser->GetData(key,kBranchTitle);
6fb51ca4 638 calibType=fConfigParser->GetData(key,kCalibType);
639 }
640 else{
641 id=1000+idCount;
642 }
643 } else {
644 id=idCount;
645 }
e6970ab5 646 if (calibType.IsNull()) calibType="UNSPECIFIED";
6fb51ca4 647 //check if branch is in selected calibration types
648 //if not, don't show it in the list and deactivate the branch.
649 Bool_t calibActive=kFALSE;
650 TIter nextCalib(&calibTypes);
651 TObject *objCalib=0;
e6970ab5 652 while ( (objCalib=nextCalib()) )
6fb51ca4 653 if (calibType==objCalib->GetTitle()) calibActive=kTRUE;
654 active&=calibActive;
655 if (!active){
656 TString s=branchName;
657 if (branchName.EndsWith(".")) s+="*";
949d8707 658// fTree->SetBranchStatus(s.Data(),0);
6fb51ca4 659 continue;
660 }
1d32f273 661// fListVariables->AddEntry(SubstituteUnderscores(branchTitle.Data()),id);
662 fListVariables->AddEntry(branchTitle.Data(),id);
6fb51ca4 663 ++idCount;
664 }
665 //trick to display modifications
1d32f273 666 fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight());
667 fListVariables->Resize(fListVariables->GetWidth()+1, fListVariables->GetHeight());
6fb51ca4 668}
669//______________________________________________________________________________
7390f655 670void AliTPCCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const char* refName)
671{
672 //
673 // map of reference trees that should always be attached to the CalibViewerGUI
674 //
675 fMapRefTrees->Add(new TObjString(refName), new TObjString(treeFileName));
676
677}
678//______________________________________________________________________________
bf05fdb7 679const TString AliTPCCalibViewerGUItime::GetDrawString(){
5312f439 680 //
681 // create draw string for ttree by combining the user requestsa
682 //
683
684 TString selectedVariable="";
6fb51ca4 685 Int_t id=-1;
686 if (!fListVariables->GetSelectedEntry()) return "";
687 selectedVariable = fListVariables->GetSelectedEntry()->GetTitle();
688 id=fListVariables->GetSelectedEntry()->EntryId();
689// printf("id: %d\n",id);
690 TString branchName=selectedVariable;
a3b590cf 691 if (fConfigParser){
692 const TObject *key=(*fConfigParser)(id);
693 if (key) branchName=(*fConfigParser)(id)->GetName();
694 }
5312f439 695 //treat case of TVector
6fb51ca4 696 if (branchName.EndsWith(".")){
5312f439 697 Int_t par = (Int_t)(fNmbPar->GetNumber());
6fb51ca4 698 branchName.Append(Form("fElements[%d]",par));
5312f439 699 }
700// if (fRadioXrun->GetState()==kButtonDown)
701// selectedVariable.Append(":run");
702// if (fRadioXtime->GetState()==kButtonDown)
703// selectedVariable.Append(":time");
704
bf05fdb7 705 return branchName;
5312f439 706}
707//______________________________________________________________________________
bf05fdb7 708const TString AliTPCCalibViewerGUItime::GetDrawOptionString(){
6e7d7dc4 709 //
710 // get user selected draw options
711 //
712 TString drawOpt;
713 if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle();
714 if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase))
715 drawOpt+="same";
bf05fdb7 716 return drawOpt;
6e7d7dc4 717}
718//______________________________________________________________________________
719void AliTPCCalibViewerGUItime::GetCutString(TString &cutStr){
5312f439 720 //
721 // create cut string
722 //
723 TCut cuts(fComboCustomCuts->GetTextEntry()->GetText());
724 TString runType="";
725 if (fComboRunType->GetSelectedEntry()) runType=fComboRunType->GetSelectedEntry()->GetTitle();
726 if (runType!="ALL"&&!runType.IsNull()) cuts+=Form("runType.String().Data()==\"%s\"",runType.Data());
6e7d7dc4 727 cutStr=cuts.GetTitle();
728}
729//______________________________________________________________________________
93425263 730void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph, const Double_t *xArr)
6e7d7dc4 731{
732 //
733 //
734 //
735 if (!withGraph){
736 fValuesX.ResizeTo(1);
737 fValuesY.ResizeTo(1);
738 fRunNumbers.ResizeTo(1);
739 fTimeStamps.ResizeTo(1);
740 } else {
93425263 741 const Long64_t nrows=fTree->GetSelectedRows();
742 fValuesX.ResizeTo(nrows);
743 fValuesY.ResizeTo(nrows);
744 fRunNumbers.ResizeTo(nrows);
745 fTimeStamps.ResizeTo(nrows);
746 long long *index=new long long[nrows];
f416ad83 747
748 //sort data
749 Int_t nTime0=0;
750 for (Int_t i=0;i<fTree->GetSelectedRows();++i){
751 if (fTree->GetV2()[i]<1) ++nTime0;
752 }
753
754 if (nTime0==fTree->GetSelectedRows()){
755 TMath::Sort(nrows,fTree->GetV1(),index,kFALSE);
756 } else {
757 TMath::Sort(nrows,fTree->GetV2(),index,kFALSE);
758 }
759
760 Double_t lastRun=-1.;
761 Int_t entries=0;
762 const Bool_t drawSparse=(fRadioXrun->GetState()==kButtonDown && fChkDrawOptSparse->GetState()==kButtonDown);
93425263 763 for (Long64_t i=0; i<nrows; ++i){
f416ad83 764 // in case of sparse drawing only use the first entry per run
765 Double_t run = fTree->GetV1()[index[i]];
766 Double_t xval = xArr[index[i]];
767
768 if (drawSparse){
769 if (TMath::Abs(lastRun-run)<.1) {
770 lastRun=run;
771 continue;
772 }
773 xval=entries+0.5;
774 }
775 fValuesX.GetMatrixArray()[entries]=xval;
776 fValuesY.GetMatrixArray()[entries]=fTree->GetV3()[index[i]];
777 fRunNumbers.GetMatrixArray()[entries]=run;
778 fTimeStamps.GetMatrixArray()[entries]=fTree->GetV2()[index[i]];
779 lastRun=run;
780 ++entries;
93425263 781 }
f416ad83 782
783 if (drawSparse){
784 fValuesX.ResizeTo(entries);
785 fValuesY.ResizeTo(entries);
786 fRunNumbers.ResizeTo(entries);
787 fTimeStamps.ResizeTo(entries);
788 // printf("entries: %d\n",entries);
789 }
790
93425263 791 delete [] index;
6e7d7dc4 792 }
793}
794//______________________________________________________________________________
795void AliTPCCalibViewerGUItime::GetHistogramTitle(TString &title)
796{
797 //
798 // Create string for histogram title
799 //
800
801 title=fDrawString;
802 Int_t pos=title.First(">>");
803 if (pos>0) title=title(0,pos);
1d32f273 804// if (!fIsCustomDraw){
6e7d7dc4 805 if (fRadioXrun->GetState()==kButtonDown){
806 title+=":Run";
807 } else if (fRadioXtime->GetState()==kButtonDown){
808 title+=":Date";
809 }
1d32f273 810// }
6e7d7dc4 811 TString cuts;
812 GetCutString(cuts);
813 TObjArray *arr=title.Tokenize(":");
814 TObject *o=0x0;
815 title+=" {";
816 title+=cuts;
817 title+="}";
818 TIter next(arr,kIterBackward);
819 while ( (o=next()) ){
820 TString varName=o->GetName();
821 title+=";";
822 //substitue variable names with names in configuration file if available
823 if ((*fConfigParser)()->GetEntries()){
824 TString branchName=varName;
825 Int_t par=0;
826 if (branchName.Contains('.')) branchName=branchName(0,branchName.First('.')+1);
827 //chek if a configuration for that branch is available
828 const TObject *oBranch=(*fConfigParser)(branchName.Data());
829 if (oBranch){
830 TString branchTitle=fConfigParser->GetData(oBranch,kBranchTitle);
831 if (!branchTitle.IsNull()){
832 //check for TVectorT type branch
833 //add parameter name if available
834 if (varName.Contains("fElements")){
835 TString parStr=varName(varName.First('[')+1,varName.Length()-varName.First('[')-2);
836 par=parStr.Atoi();
837 branchTitle+=": ";
838 TString yparname=fConfigParser->GetData(oBranch,par+kParamNames);
839 if (!yparname.IsNull()){
840 branchTitle+=yparname;
841 } else {
842 branchTitle+="[";
843 branchTitle+=par;
844 branchTitle+="]";
845 }
846 }
847 }
bf05fdb7 848 varName=branchTitle;
849 SubstituteUnderscores(varName);
6e7d7dc4 850 }
851 }
852 title+=varName;
853 }
854 delete arr;
5312f439 855}
856//______________________________________________________________________________
7390f655 857void AliTPCCalibViewerGUItime::AdjustYRange()
858{
859 //
860 //
861 //
862 TIter nextGraphicObject(fTrashBox);
863 TObject *o=0x0;
661f340b 864 Float_t min=1,max=0;
7390f655 865 while ( (o=nextGraphicObject()) ){
866 if (o->IsA()==TGraph::Class()){
867 TGraph *gr=(TGraph*)o;
661f340b 868 if (min>max) {
7390f655 869 min=TMath::MinElement(gr->GetN(),gr->GetY());
870 max=TMath::MaxElement(gr->GetN(),gr->GetY());
871 } else {
872 Float_t currmin=TMath::MinElement(gr->GetN(),gr->GetY());
873 Float_t currmax=TMath::MaxElement(gr->GetN(),gr->GetY());
874 if (currmax>max) max=currmax;
875 if (currmin<min) min=currmin;
876 }
877 }
878 }
879 if (min!=max){
880 if (min!=0) min=min-(max-min)/10;
881 if (max!=0) max=max+(max-min)/10;
882 fCurrentHist->SetMinimum(min);
883 fCurrentHist->SetMaximum(max);
884 }
885}
886//______________________________________________________________________________
5312f439 887void AliTPCCalibViewerGUItime::DoDraw() {
7390f655 888 //
889 // Draw graphics
890 //
5312f439 891 TString drawString=fDrawString;
6e7d7dc4 892 TString cutString;
893 GetCutString(cutString);
514fcaf7 894 TString optString = GetDrawOptionString();
6e7d7dc4 895 Bool_t graphOutput=!fNoGraph; //ttree buffer for V1, V2... too small
896 graphOutput&=(drawString.First(">>")<0); //histogram output in custom draw
897 graphOutput&=fRadioXhist->GetState()!=kButtonDown; //histogram drawing selected
514fcaf7 898// graphOutput&=!(fIsCustomDraw&&!fDrawString.Contains(":")); //custom draw 1D
899// graphOutput&=fDrawString.CountChar(':')<2; //custom draw 1D
900 if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
1d32f273 901 if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
6e7d7dc4 902 Bool_t drawSame=optString.Contains("same",TString::kIgnoreCase);
903// optString+="goff";
904 if (graphOutput) {
905 drawString.Prepend("run:time:");
906 optString="goff";
907 }else{
1d32f273 908// if (!fIsCustomDraw){
6e7d7dc4 909 if (fRadioXrun->GetState()==kButtonDown){
910 drawString+=":run";
911 } else if (fRadioXtime->GetState()==kButtonDown){
912 drawString+=":time";
913 }
1d32f273 914// }
6e7d7dc4 915 }
5312f439 916 TVirtualPad *padsave=gPad;
917 fCanvMain->GetCanvas()->cd();
6e7d7dc4 918 //delete old histograms and graphs
919 if (!drawSame){
920 fTrashBox->Delete();
5312f439 921 fCurrentGraph=0x0;
5312f439 922 fCurrentHist=0x0;
923 }
bf05fdb7 924// printf("%s (%s) [%s]\n",drawString.Data(), cutString.Data(), optString.Data());
5312f439 925 //select data
926 fTree->Draw(drawString.Data(),cutString.Data(),optString.Data());
927 if (fTree->GetSelectedRows()==-1) return;
93425263 928
6e7d7dc4 929 TString title;
930 GetHistogramTitle(title);
5312f439 931 Bool_t drawGraph=kFALSE;
93425263 932 Double_t *xArr=0;
6e7d7dc4 933 if (graphOutput){
514fcaf7 934 drawGraph=kTRUE;
935 if (fIsCustomDraw&&fDrawString.Contains(":")){
93425263 936// fValuesX.SetElements(fTree->GetV4());
937 xArr=fTree->GetV4();
6e7d7dc4 938 }else{
6e7d7dc4 939 if (fRadioXrun->GetState()==kButtonDown){
93425263 940// fValuesX.SetElements(fTree->GetV1());
941 xArr=fTree->GetV1();
6e7d7dc4 942 } else if (fRadioXtime->GetState()==kButtonDown){
93425263 943// fValuesX.SetElements(fTree->GetV2());
944 xArr=fTree->GetV2();
6e7d7dc4 945 } else {
946 drawGraph=kFALSE;
6fb51ca4 947 }
948 }
514fcaf7 949 }
a3b590cf 950 if (xArr) UpdateValueArrays(graphOutput, xArr);
514fcaf7 951// if (graphOutput){
952// if (fIsCustomDraw){
953// if (fDrawString.Contains(":")){
954// fValuesX.SetElements(fTree->GetV4());
955// drawGraph=kTRUE;
956// } else {
957// drawGraph=kFALSE;
958// }
959// }else{
960// drawGraph=kTRUE;
961// if (fRadioXrun->GetState()==kButtonDown){
962// fValuesX.SetElements(fTree->GetV1());
963// } else if (fRadioXtime->GetState()==kButtonDown){
964// fValuesX.SetElements(fTree->GetV2());
965// } else {
966// drawGraph=kFALSE;
967// }
968// }
969// }
970//create graph according to selection
5312f439 971 if (drawGraph){
6e7d7dc4 972 TGraph *graph=new TGraph(fValuesX,fValuesY);
f416ad83 973// graph->Sort();
6e7d7dc4 974 TString grDraw="p";
975 if (!drawSame) grDraw+="a";
976 if (!fIsCustomDraw) grDraw+="l";
f416ad83 977 // sparse drawing, set bin labels
978 if (fRadioXrun->GetState()==kButtonDown && fChkDrawOptSparse->GetState()==kButtonDown){
979 Int_t nrows=fValuesX.GetNrows();
980 Double_t *newBins = new Double_t[nrows+1];
981 for (Int_t ibin=0; ibin<nrows+1; ++ibin) newBins[ibin]=ibin;
982 graph->GetXaxis()->Set(nrows,newBins);
983 graph->GetXaxis()->LabelsOption("v");
984 for (Int_t i=0; i<nrows;++i)
985 graph->GetXaxis()->SetBinLabel(i+1,Form("%.0f",fRunNumbers.GetMatrixArray()[i]));
986 delete [] newBins;
987 }
6e7d7dc4 988 graph->Draw(grDraw.Data());
989 graph->SetEditable(kFALSE);
990 TH1 *hist=graph->GetHistogram();
991 hist->SetTitle(title.Data());
992 fTrashBox->Add(graph);
993 graph->SetLineColor(fTrashBox->GetEntries());
994 graph->SetMarkerColor(fTrashBox->GetEntries());
995 if (!drawSame) {
996 fCurrentGraph=graph;
997 fCurrentHist=hist;
998 }
5312f439 999 } else {
6e7d7dc4 1000 TH1 *hist=fTree->GetHistogram();
1001 hist->SetTitle(title.Data());
1002// hist->Draw(optString.Data());
1003 fTrashBox->Add(hist);
1004 hist->SetLineColor(fTrashBox->GetEntries());
1005 hist->SetMarkerColor(fTrashBox->GetEntries());
1006 if (!drawSame) fCurrentHist=hist;
5312f439 1007 }
1008
5312f439 1009 //Set time axis if choosen as x-variables
1d32f273 1010// if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw&&!drawSame){
1011 if (fRadioXtime->GetState()==kButtonDown&&!drawSame){
5312f439 1012 TAxis *xaxis=fCurrentHist->GetXaxis();
1013 xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}");
1014 xaxis->SetTimeDisplay(1);
1015 xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3);
1016 xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3);
1017 }
7390f655 1018 if (!drawSame) {
6fb51ca4 1019 //Set title offset
7390f655 1020 fCurrentHist->GetYaxis()->SetTitleOffset(1.5);
1021 } else {
1022 //adjust y-range
1023 AdjustYRange();
1024 }
5312f439 1025 gPad->Modified();
1026 gPad->Update();
1027 padsave->cd();
1028}
1029
1030//______________________________________________________________________________
1031void AliTPCCalibViewerGUItime::DoDumpRuns()
1032{
1033 //
1034 // Dump the current run numbers to stdout
1035 //
6fb51ca4 1036 Int_t npoints=fRunNumbers.GetNrows();
1037 Int_t *sortIndex = new Int_t[npoints];
1038 TMath::Sort(npoints,fRunNumbers.GetMatrixArray(),sortIndex,kFALSE);
1039 Int_t run=0, prevRun=-1;
1040
1041 for (Int_t irun=0;irun<npoints;++irun){
1042 run=(Int_t)fRunNumbers.GetMatrixArray()[sortIndex[irun]];
1043 if (run!=prevRun) std::cout << Form("%d",run) << std::endl;
1044 prevRun=run;
5312f439 1045 }
4ce766eb 1046 delete [] sortIndex;
5312f439 1047}
1048//______________________________________________________________________________
1049void AliTPCCalibViewerGUItime::DoParLimitChange()
1050{
1051 //
1052 //
1053 //
6fb51ca4 1054 UpdateParName();
5312f439 1055 DoDraw();
1056}
1057//______________________________________________________________________________
1058void AliTPCCalibViewerGUItime::DoNewSelection() {
1059 //
1060 // decides whether to redraw if user makes another selection
1061 //
1062 UpdateParLimits();
1063 fDrawString=GetDrawString();
1064 fIsCustomDraw=kFALSE;
1065 DoDraw();
1066}
1067//______________________________________________________________________________
1068void AliTPCCalibViewerGUItime::DoCustomDraw()
1069{
1070 //
1071 //
1072 //
1073 fDrawString=fComboCustomDraw->GetTextEntry()->GetText();
6e7d7dc4 1074// if (fDrawString.Contains(">>")){
1075// Warning("DoCustomDraw","Currently no user defined histograms allowed!");
1076// return;
1077// }
1078 fNmbPar->SetState(kFALSE);
5312f439 1079 fIsCustomDraw=kTRUE;
1080 DoDraw();
1081}
1082//______________________________________________________________________________
1083void AliTPCCalibViewerGUItime::DoCustomCutsDraw()
1084{
1085 //
1086 //
1087 //
1088 if (fIsCustomDraw) DoCustomDraw();
1089 else {
1090 fDrawString=GetDrawString();
1091 fIsCustomDraw=kFALSE;
1092 DoDraw();
1093 }
1094}
1095//______________________________________________________________________________
1096void AliTPCCalibViewerGUItime::HandleButtonsDrawSel(Int_t id)
1097{
1098 //
1099 // Draw selection button handling (x-variable)
1100 //
1101
1102 if (id == -1) {
1103 TGButton *btn = (TGButton *) gTQSender;
1104 id = btn->WidgetId();
1105 }
1106
1107 Bool_t doDraw=kFALSE;
1d32f273 1108 Bool_t noDraw=kFALSE;
1109 if (id<-1){
1110 noDraw=kTRUE;
1111 id=TMath::Abs(id);
1112 }
5312f439 1113 switch (id) {
1114 case (kRadioXhist):
1115 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
1116 if (doDraw){
1117 fRadioXrun->SetState(kButtonUp);
1118 fRadioXtime->SetState(kButtonUp);
1d32f273 1119 fRadioXhist->SetState(kButtonDown);
5312f439 1120 }
1121 break;
1122 case (kRadioXrun):
1123 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXhist->GetState()==kButtonDown);
1124 if (doDraw){
1125 fRadioXhist->SetState(kButtonUp);
1126 fRadioXtime->SetState(kButtonUp);
1d32f273 1127 fRadioXrun->SetState(kButtonDown);
5312f439 1128 }
1129 break;
1130 case (kRadioXtime):
1131 doDraw=(fRadioXhist->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
1132 if (doDraw){
1133 fRadioXrun->SetState(kButtonUp);
1134 fRadioXhist->SetState(kButtonUp);
1d32f273 1135 fRadioXtime->SetState(kButtonDown);
5312f439 1136 }
1137 break;
1138 }
1d32f273 1139 if (doDraw&&!noDraw) DoCustomCutsDraw();
5312f439 1140}
1141//______________________________________________________________________________
6fb51ca4 1142void AliTPCCalibViewerGUItime::UpdateParName()
1143{
1144 //
1145 // change parameter name
1146 //
1147
1148 Int_t par = (Int_t)(fNmbPar->GetNumber());
7390f655 1149 TString parName="";
6fb51ca4 1150 Int_t id=fListVariables->GetSelectedEntry()->EntryId();
1151 if (fConfigParser && (*fConfigParser)(id)) parName=fConfigParser->GetData((*fConfigParser)(id),par+kParamNames);
7390f655 1152 if (parName=="") parName.Form("%d",par);
6fb51ca4 1153 fLblPar->SetText(Form("Parameter: %s",parName.Data()));
1154 fDrawString=GetDrawString();
1155 fIsCustomDraw=kFALSE;
1156}
1157
1158//______________________________________________________________________________
5312f439 1159void AliTPCCalibViewerGUItime::UpdateParLimits()
1160{
1161 //
1162 // Adjust limits for TVectorT based variables
1163 //
1164 if (!fTree) return;
6fb51ca4 1165 TString selectedVariableTitle="";
1166 Int_t id=-1;
1167 if (!fListVariables->GetSelectedEntry()) return;
1168 selectedVariableTitle = fListVariables->GetSelectedEntry()->GetTitle();
1169 id=fListVariables->GetSelectedEntry()->EntryId();
1170// printf("id: %d\n",id);
1171 TString selectedVariable=selectedVariableTitle;
1172 const TObject *key=(*fConfigParser)(id);
1173 if (key) selectedVariable=(*fConfigParser)(id)->GetName();
1174
5312f439 1175 if (selectedVariable.IsNull()||!selectedVariable.EndsWith(".")) {
1176 fNmbPar->SetState(kFALSE);
6fb51ca4 1177 fLblPar->SetText("Parameter: none");
5312f439 1178 return;
1179 }
1180 TVectorD *vD=0x0;
1181 TVectorF *vF=0x0;
1182 Int_t maxPar=0;
e6970ab5 1183 fTree->GetEntry(1);
1184 TBranch *branch=fTree->GetTree()->GetBranch(selectedVariable.Data());
5312f439 1185 TString branchClass=branch->GetClassName();
e6970ab5 1186 Int_t event=0;
5312f439 1187 if (branchClass=="TVectorT<double>"){
e6970ab5 1188// branch->SetAddress(&vD);
1189 fTree->SetBranchAddress(selectedVariable.Data(),&vD);
1190 while (maxPar<2&&event<fTree->GetEntries()){
1191 fTree->GetEntry(event++);
1192 maxPar=vD->GetNrows();
1193 }
5312f439 1194 } else if (branchClass=="TVectorT<float>"){
e6970ab5 1195// branch->SetAddress(&vF);
1196 fTree->SetBranchAddress(selectedVariable.Data(),&vF);
1197 while (maxPar<2&&event<fTree->GetEntries()){
1198 fTree->GetEntry(event++);
1199 maxPar=vF->GetNrows();
1200 }
5312f439 1201 } else {
1202 //class not known
1203 fNmbPar->SetState(kFALSE);
1204 return;
1205 }
e6970ab5 1206// branch->ResetAddress();
6e7d7dc4 1207 fTree->SetBranchAddress(selectedVariable.Data(),0x0);
7390f655 1208 if (fNmbPar->GetNumMax()!=maxPar-1) fNmbPar->SetNumber(0);
5312f439 1209 fNmbPar->SetLimitValues(0,maxPar-1);
1210 fNmbPar->SetState(kTRUE);
6fb51ca4 1211 UpdateParName();
5312f439 1212}
1213//______________________________________________________________________________
6fb51ca4 1214void AliTPCCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/)
5312f439 1215{
1216 //
1217 // handle mouse events in the draw canvas
1218 //
5312f439 1219 UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0;
1220 Double_t valx=0.,valy=0.;
1221 if (!fCurrentGraph) {
909c8c99 1222 fLblRunNumberVal->SetText(Form("%06u",run));
e6970ab5 1223 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS));
892226be 1224 fLblValueXVal->SetText(Form("%.3e", valx));
1225 fLblValueYVal->SetText(Form("%.3e", valy));
5312f439 1226 return;
1227 }
1228 TVirtualPad *padsave=gPad;
1229 fCanvMain->GetCanvas()->cd();
1230 Int_t n=fValuesY.GetNrows();
1231 Double_t *arr=0x0;
1232 arr=fValuesX.GetMatrixArray();
1233
1234 Int_t minDist=1000000;
1235 Int_t minPoint=-1;
1236 for (Int_t i=0;i<n;++i){
1237 Int_t pxp = gPad->XtoAbsPixel(gPad->XtoPad(arr[i]));
1238 Int_t pyp = gPad->YtoAbsPixel(gPad->YtoPad(fValuesY[i]));
e6970ab5 1239 Int_t d = TMath::Nint(TMath::Sqrt(TMath::Abs(pxp-x) + TMath::Abs(pyp-y)));
5312f439 1240 if (d < minDist) {
1241 minDist = d;
1242 minPoint = i;
1243 }
1244 }
1245 if (minDist<2){
1246 TTimeStamp t((Int_t)fTimeStamps[minPoint]);
1247 t.GetDate(kTRUE,0,&yy,&mm,&dd);
1248 t.GetTime(kTRUE,0,&HH,&MM,&SS);
1249 run=(UInt_t)fRunNumbers[minPoint];
1250 valx=fValuesX[minPoint];
1251 valy=fValuesY[minPoint];
1252 } else {
1253 dd=0;mm=0;yy=0;HH=0;MM=0;SS=0;run=0;
1254 valx=0.;
1255 valy=0.;
1256 }
909c8c99 1257 fLblRunNumberVal->SetText(Form("%06u",run));
5312f439 1258 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS));
1259 if (fIsCustomDraw){
892226be 1260 fLblValueXVal->SetText(Form("%.3e", valx));
5312f439 1261 }else{
1262 if (fRadioXrun->GetState()==kButtonDown){
1263 fLblValueXVal->SetText("Run");
1264 } else if (fRadioXtime->GetState()==kButtonDown){
1265 fLblValueXVal->SetText("Time");
1266 }
1267 }
892226be 1268 fLblValueYVal->SetText(Form("%.3e", valy));
5312f439 1269 padsave->cd();
1270 if (run==0) return;
1271 if (event == kButton1Double ){
1272 SetGuiTree(run);
1273 }
1274 //find closes point of current selection
1275}
1276//______________________________________________________________________________
1277void AliTPCCalibViewerGUItime::SetGuiTree(Int_t run)
1278{
1279 //
1280 // create the AliTPCCalibViewerGUI tree for run
1281 // cache tree in directory fOutputCacheDir
1282 // retrieve file from this directory if it already exists
1283 //
1284
949d8707 1285 //
1286 //Create and set GUI tree
1287 //
5312f439 1288 //try to find file for run in fOutputCacheDir
1289 TString fileName=fOutputCacheDir;
1290 if (!fileName.EndsWith("/")) fileName+="/";
1291 fileName+=Form("guiTreeRun_%d.root",run);
7390f655 1292 Bool_t load=kTRUE;
949d8707 1293 if (gSystem->AccessPathName(fileName.Data())){
7390f655 1294 load=AliTPCcalibDB::CreateGUITree(run,fileName.Data());
1295 if (!load){
1296 fCalibViewerGUI->Reset();
1297 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX")));
1298 return;
1299 }
5312f439 1300 }
7390f655 1301 fCalibViewerGUI->Initialize(fileName.Data());
1302 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run)));
949d8707 1303
1304 //
1305 //Create and set Reference GUI tree
1306 //
1307 AliTPCcalibDButil util;
1308 util.SetReferenceRun(run);
1309 fileName=fOutputCacheDir;
1310 if (!fileName.EndsWith("/")) fileName+="/";
1311 fileName+=util.GetGUIRefTreeDefaultName();
1312 //only update if file does not exist
1313 if (gSystem->AccessPathName(fileName.Data())){
1314 util.UpdateRefDataFromOCDB();
1315 util.CreateGUIRefTree(fileName.Data());
1316 }
1317
1318 fCalibViewerGUI->GetViewer()->AddReferenceTree(fileName.Data(),"calPads","Ref");
1319
1320 //
1321 // Process additional reference trees
1322 //
7390f655 1323 TIter nextRefTree(fMapRefTrees);
1324 TObject *o=0x0;
949d8707 1325 //Set static reference data
7390f655 1326 while ( (o=nextRefTree()) ){
1327 fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"calPads",o->GetName());
5312f439 1328 }
7390f655 1329 fCalibViewerGUI->Reload();
5312f439 1330}
1331//______________________________________________________________________________
bf05fdb7 1332void AliTPCCalibViewerGUItime::SubstituteUnderscores(TString &s)
6fb51ca4 1333{
1334 //
1335 //
1336 //
6fb51ca4 1337 s.ReplaceAll("_{","|{");
1338 s.ReplaceAll("_"," ");
1339 s.ReplaceAll("|{","_{");
6fb51ca4 1340}
514fcaf7 1341
1342//______________________________________________________________________________
1343void AliTPCCalibViewerGUItime::DoNewSelectionAliases()
1344{
1345 //
1346 //
1347 //
1348 if (!fTree) return;
1349 TList *l=fTree->GetListOfAliases();
1350 if (!l) return;
1351 TString selectedVariable="";
1352 if (!fListAliases->GetSelectedEntry()) return;
1353 selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
1354 fDrawString=selectedVariable;
1355 fIsCustomDraw=kFALSE;
1356 DoDraw();
1357}
1358//______________________________________________________________________________
1359void AliTPCCalibViewerGUItime::DoAddAlias()
1360{
1361 //
1362 //
1363 //
1364 new AliTPCCalibViewerGUItimeAddAliasFrame(gClient->GetRoot(), fContTopBottom, 400, 200, kVerticalFrame, this);
1365}
1366//______________________________________________________________________________
1367void AliTPCCalibViewerGUItime::DoDelAlias()
1368{
1369 //
1370 //
1371 //
1372 if (!fTree) return;
1373 TList *l=fTree->GetListOfAliases();
1374 if (!l) return;
1375 TString selectedVariable="";
1376 if (!fListAliases->GetSelectedEntry()) return;
1377 selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
1378 l->Remove(l->FindObject(selectedVariable.Data()));
1379 UpdateAliasList();
1380}
1381
1382//______________________________________________________________________________
1383void AliTPCCalibViewerGUItime::UpdateAliasList()
1384{
1385 //
1386 //
1387 //
1388 printf("UpdateAliasList\n");
1389 if (!fTree) return;
1390 TList *l=fTree->GetListOfAliases();
1391 if (!l) return;
1392 TIter nextAlias(l);
1393 TObject *o;
1394 fListAliases->RemoveAll();
1395 Int_t id=0;
1396 while( (o=nextAlias()) ){
1397 fListAliases->AddEntry(o->GetName(),id++);
1398 }
1399 fListAliases->Resize(fListAliases->GetWidth()-1, fListAliases->GetHeight());
1400 fListAliases->Resize(fListAliases->GetWidth()+1, fListAliases->GetHeight());
1401}
6fb51ca4 1402//______________________________________________________________________________
6e7d7dc4 1403TObjArray* AliTPCCalibViewerGUItime::ShowGUI(const char* fileName, const char* treeName) {
5312f439 1404 //
1405 // Initialize and show GUI for presentation for demonstration purposes
1406 // or for fast standalone use
1407 //
1408 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1409 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1410 frmMain->SetCleanup(kDeepCleanup);
1411
1412 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1413 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1414
1415 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1416 TGCompositeFrame* tabCont2 = tabMain->AddTab("Detail - XXXXX");
1417
1418 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1419 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
6e7d7dc4 1420 calibViewerTime->SetConfigFileName("$ALICE_ROOT/TPC/CalibMacros/calibVarDescription.txt");
1421 calibViewerTime->UseFile(fileName, treeName);
5312f439 1422
1423 AliTPCCalibViewerGUI* calibViewer = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, 0);
1424 tabCont2->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1425 calibViewerTime->SetCalibViewerGUI(calibViewer);
1426 calibViewerTime->SetCalibViewerGUItab(tabMain->GetTabTab(1));
1427
1428
1429 TObjArray *guiArray = new TObjArray();
1430 guiArray->Add(calibViewerTime);
1431 guiArray->Add(calibViewer);
1432
1433 frmMain->MapSubwindows();
1434 frmMain->Resize();
1435 frmMain->MapWindow();
1436
1437 return guiArray;
1438}
1439
6e7d7dc4 1440//______________________________________________________________________________
1441TObjArray* AliTPCCalibViewerGUItime::ShowGUI(TChain *chain) {
1442 //
1443 // Initialize and show GUI for presentation for demonstration purposes
1444 // or for fast standalone use
1445 //
1446 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1447 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1448 frmMain->SetCleanup(kDeepCleanup);
1449
1450 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1451 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1452
1453 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1454
1455 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1456 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1457 calibViewerTime->UseChain(chain);
1458
1459 TObjArray *guiArray = new TObjArray();
1460 guiArray->Add(calibViewerTime);
1461
1462 frmMain->MapSubwindows();
1463 frmMain->Resize();
1464 frmMain->MapWindow();
1465
1466 return guiArray;
1467}
514fcaf7 1468
1469
1470////////////////////////////////////////////////////////////////////////
1471//
1472// GUI Alias frame
1473//
1474////////////////////////////////////////////////////////////////////////
1475
1476
1477ClassImp(AliTPCCalibViewerGUItimeAddAliasFrame)
1478
1479AliTPCCalibViewerGUItimeAddAliasFrame::AliTPCCalibViewerGUItimeAddAliasFrame(const TGWindow *p, const TGWindow *main,
1480 UInt_t w, UInt_t h, UInt_t options,
1481 AliTPCCalibViewerGUItime *gui, TString strAlias) :
1482 fMain(0x0),
1483 fTxt1(0x0),
1484 fTxt2(0x0),
1485 fGUI(0x0)
1486{
1487 fMain = new TGTransientFrame(p, main, w, h, options);
1488 fMain->Connect("CloseWindow()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
1489 fMain->DontCallClose(); // to avoid double deletions.
1490
1491 // use hierarchical cleaning
1492 fMain->SetCleanup(kDeepCleanup);
1493
1494 //layout
1495 TGLayoutHints *l1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
1496 TGLayoutHints *l2 = new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX, 2, 2, 0, 5);
1497// TGLayoutHints *l3 = new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5);
1498
1499 //input fields
1500 TGCompositeFrame *f1 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame);
1501 fMain->AddFrame(f1, l1);
1502 TGCompositeFrame *frameName = new TGCompositeFrame(f1);
1503 TGCompositeFrame *frameFormula = new TGCompositeFrame(f1);
1504 f1->AddFrame(frameName,l2);
1505 f1->AddFrame(frameFormula,l2);
1506 TGLabel *lblTxt1 = new TGLabel(frameName, "Name:");
1507 TGLabel *lblTxt2 = new TGLabel(frameFormula, "Formula:");
1508 fTxt1 = new TGTextEntry(frameName, new TGTextBuffer(1000));
1509 fTxt2 = new TGTextEntry(frameFormula, new TGTextBuffer(1000));
1510
1511 frameName->AddFrame(lblTxt1, l2);
1512 frameName->AddFrame(fTxt1, l2);
1513 frameFormula->AddFrame(lblTxt2, l2);
1514 frameFormula->AddFrame(fTxt2, l2);
1515
1516 fTxt1->Resize(350, fTxt1->GetDefaultHeight());
1517 fTxt2->Resize(350, fTxt2->GetDefaultHeight());
1518
1519 //ok and cancel buttons
1520 TGHorizontalFrame *frame = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
1521
1522 TGTextButton *okButton = new TGTextButton(frame, "&Ok", 1);
1523 okButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoOK()");
1524 TGTextButton *cancelButton = new TGTextButton(frame, "&Cancel", 2);
1525 cancelButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
1526
1527
1528 frame->AddFrame(okButton, l1);
1529 frame->AddFrame(cancelButton, l1);
1530
1531 frame->Resize(150, okButton->GetDefaultHeight());
1532
1533 fMain->AddFrame(frame, new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1));
1534
1535 fGUI=gui;
1536 TString aliasName, alias;
1537 if (!strAlias.IsNull()){
1538 TChain *c=fGUI->GetChain();
1539 if (c){
1540 TList *l=c->GetListOfAliases();
1541 if (l){
1542 TNamed *d=(TNamed*)l->FindObject(strAlias);
1543 if (d){
1544 aliasName=d->GetName();
1545 alias=d->GetTitle();
1546 }
1547 }
1548 }
1549 }else{
1550 alias=fGUI->GetCustomDrawString();
1551 }
1552 fTxt1->SetText(aliasName.Data(),kFALSE);
1553 fTxt2->SetText(alias.Data(),kFALSE);
1554
1555 fMain->MapSubwindows();
1556 fMain->Resize();
1557
1558 // position relative to the parent's window
1559 fMain->CenterOnParent();
1560
1561 fMain->SetWindowName("Alias Editor");
1562
1563 fMain->MapWindow();
1564
1565}
1566//______________________________________________________________________________
1567AliTPCCalibViewerGUItimeAddAliasFrame::~AliTPCCalibViewerGUItimeAddAliasFrame()
1568{
1569 //
1570 //
1571 //
1572 fMain->DeleteWindow(); // deletes fMain
1573}
1574//______________________________________________________________________________
1575void AliTPCCalibViewerGUItimeAddAliasFrame::DoOK()
1576{
1577 //
1578 //
1579 //
1580 TString aliasName=fTxt1->GetText();
1581 TString alias=fTxt2->GetText();
1582 if (!aliasName.IsNull()&&!alias.IsNull()){
1583 TChain *c=fGUI->GetChain();
1584 if (c){
1585 c->SetAlias(aliasName.Data(),alias.Data());
1586 }
1587 }
1588 fGUI->UpdateAliasList();
1589 delete this;
1590}
1591//______________________________________________________________________________
1592void AliTPCCalibViewerGUItimeAddAliasFrame::DoCancel()
1593{
1594 //
1595 //
1596 //
1597 delete this;
1598}
1599