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