adding libAliHLTTRD.so as dependency for libAliHLTTrigger.so
[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>
47//
48#include <TGFileDialog.h>
49#include <TGInputDialog.h>
50//
51#include <TGButton.h>
52#include <TGListBox.h>
53#include <TGComboBox.h>
54#include <TGNumberEntry.h>
55#include <TGLayout.h>
56#include <TRootEmbeddedCanvas.h>
57#include <TGSplitter.h>
58#include <TGButtonGroup.h>
59#include <TGLabel.h>
60#include <TGTab.h>
61#include <TGString.h>
62
63//AliRoot includes
6fb51ca4 64#include <AliLog.h>
5312f439 65#include "AliTPCCalibViewerGUI.h"
66#include "AliTPCcalibDB.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),
5312f439 93 //GUI elements
94 //main canvas Top part, bottom part
95 fContTopBottom(0x0),
96 //top left, centre, right
97 fContLCR(0x0),
98 //content left
99 fContLeft(0x0),
6e7d7dc4 100 fContDrawOpt(0x0),
101 fChkDrawOptSame(0x0),
102 fComboAddDrawOpt(0x0),
5312f439 103 fContDrawSel(0x0),
104 fContDrawSelSubRunTime(0x0),
105 fRadioXhist(0x0),
106 fRadioXrun(0x0),
107 fRadioXtime(0x0),
108 fListVariables(0x0),
109 fComboRunType(0x0),
110 fLblRunType(0x0),
111 fNmbPar(0x0),
112 fLblPar(0x0),
6fb51ca4 113 fListCalibType(0x0),
114 fContCalibType(0x0),
5312f439 115 //content centre
116 fContCenter(0x0),
117 fCanvMain(0x0),
118 //content right
119 fContRight(0x0),
120 fContValues(0x0),
121 fLblRunNumber(0x0),
122 fLblRunTime(0x0),
123 fLblValueX(0x0),
124 fLblValueY(0x0),
125 fLblRunNumberVal(0x0),
126 fLblRunTimeVal(0x0),
127 fLblValueXVal(0x0),
128 fLblValueYVal(0x0),
129 fBtnDumpRuns(0x0),
130 //content bottom
131 fContCustom(0x0),
132 fContCustomCuts(0x0),
133 fLblCustomDraw(0x0),
134 fLblCustomCuts(0x0),
135 fComboCustomDraw(0x0),
6e7d7dc4 136 fComboCustomCuts(0x0),
137 fTrashBox(new TObjArray)
5312f439 138{
139 //
140 // ctor
141 //
142 DrawGUI(p,w,h);
6e7d7dc4 143 gStyle->SetMarkerStyle(20);
144 gStyle->SetMarkerSize(0.5);
5312f439 145 SetInitialValues();
146}
147//______________________________________________________________________________
148AliTPCCalibViewerGUItime::~AliTPCCalibViewerGUItime(){
149 //
150 // dtor
151 //
6e7d7dc4 152 delete fConfigParser;
153 delete fTrashBox;
5312f439 154}
155//______________________________________________________________________________
6fb51ca4 156void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) {
5312f439 157 //
158 // draw the GUI
159 //
160 // ======================================================================
161 // ************************* Display everything *************************
162 // ======================================================================
163
164 SetCleanup(kDeepCleanup);
5312f439 165
166 // *****************************************************************************
167 // ************************* content of this MainFrame *************************
168 // *****************************************************************************
169 // top level container with horizontal layout
170 fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
171 AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
172
173 fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
174 fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
175
176 // ***********************************************************************
177 // ************************* content of fContLCR *************************
178 // ***********************************************************************
179 // left container
180 fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
181 fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
182
183 // left vertical splitter
184 TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
185 splitLeft->SetFrame(fContLeft, kTRUE);
186 fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
187
188 // right container
189 fContRight = new TGCompositeFrame(fContLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight);
190 fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
191
192 // center container
193 fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
194 fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
195
196 // right vertical splitter
197 TGVSplitter *splitRight = new TGVSplitter(fContLCR);
198 splitRight->SetFrame(fContRight, kFALSE);
199 fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
200
201
202 // ========================================================================
203 // ************************* content of fContLeft *************************
204 // ========================================================================
205 // --- draw button and tabLeft ---
6e7d7dc4 206 // draw options
207 fContDrawOpt = new TGGroupFrame(fContLeft, "Draw options", kVerticalFrame | kFitWidth | kFitHeight);
208 fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
209 fChkDrawOptSame = new TGCheckButton(fContDrawOpt, "Same");
210 fContDrawOpt->AddFrame(fChkDrawOptSame, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
211 fChkDrawOptSame->SetToolTipText("Add draw option 'same'");
212 // additional draw options combo box
213 fComboAddDrawOpt = new TGComboBox(fContDrawOpt);
214 fComboAddDrawOpt->Resize(0, 22);
215 fComboAddDrawOpt->EnableTextInput(kTRUE);
216 fContDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
217// fComboAddDrawOpt->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral(=14)");
218// fComboAddDrawOpt->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
219
5312f439 220 // draw selection group
221 fContDrawSel = new TGGroupFrame(fContLeft, "Draw selection", kVerticalFrame | kFitWidth | kFitHeight);
222 fContLeft->AddFrame(fContDrawSel, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
223 //x-axis variables selection, Run of Time
224 fContDrawSelSubRunTime = new TGCompositeFrame(fContDrawSel, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
225 fContDrawSel->AddFrame(fContDrawSelSubRunTime, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
226
227 // ------------------------- content of fContDrawOpt -------------------------
228 //
229 // Run radio button
230 // Time radio button
231 fRadioXhist = new TGRadioButton(fContDrawSelSubRunTime, "hist", kRadioXhist);
232 fContDrawSelSubRunTime->AddFrame(fRadioXhist, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
233 fRadioXhist->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
234 fRadioXhist->SetToolTipText("Draw the distribution of the variable");
235
236 fRadioXrun = new TGRadioButton(fContDrawSelSubRunTime, ":Run", kRadioXrun);
237 fContDrawSelSubRunTime->AddFrame(fRadioXrun, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
238 fRadioXrun->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
239 fRadioXrun->SetToolTipText("Use run number as x-value");
240
241 // Time radio button
242 fRadioXtime = new TGRadioButton(fContDrawSelSubRunTime, ":Time", kRadioXtime);
243 fContDrawSelSubRunTime->AddFrame(fRadioXtime, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
244 fRadioXtime->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
245 fRadioXtime->SetToolTipText("Use time stamp number as x-value");
246
247
248 // list of variables
249 fListVariables = new TGListBox(fContDrawSel);
250 fContDrawSel->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
251 fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelection()");
252
6fb51ca4 253
254//-------------------- run type selection ------------------------
5312f439 255 // Parameter label
256 fLblRunType = new TGLabel(fContDrawSel, "Run Type:");
257 fLblRunType->SetTextJustify(kTextLeft);
258 fContDrawSel->AddFrame(fLblRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
259
260 fComboRunType = new TGComboBox(fContDrawSel);
261 fComboRunType->EnableTextInput(kFALSE);
262 fContDrawSel->AddFrame(fComboRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
263 fComboRunType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoDraw()");
264// fComboRunType->SetEnabled(kFALSE);
265 fComboRunType->Resize(0, 22);
266
267 //-------------------- parameter selection ------------------------
268 // Parameter label
269 fLblPar = new TGLabel(fContDrawSel, "Parameter:");
270 fLblPar->SetTextJustify(kTextLeft);
271 fContDrawSel->AddFrame(fLblPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
272
273 fNmbPar = new TGNumberEntry(fContDrawSel, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
274 fContDrawSel->AddFrame(fNmbPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
275 fNmbPar->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUItime", this, "DoParLimitChange()");
276 fNmbPar->SetState(kFALSE);
277
6fb51ca4 278 //-------------------- calibration type selection ------------------------
279 // label
280 // draw selection group
281 fContCalibType = new TGGroupFrame(fContLeft, "Calib type selection", kVerticalFrame | kFitWidth | kFitHeight);
282 fContLeft->AddFrame(fContCalibType, new TGLayoutHints(kLHintsExpandX , 0, 0, 10, 0));
283
284 // list of variables
285 fListCalibType = new TGListBox(fContCalibType);
286 fContCalibType->AddFrame(fListCalibType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX , 0, 0, 0, 0));
287 fListCalibType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoChangeSelectionList()");
288 fListCalibType->Resize(0,88);
289 fListCalibType->SetMultipleSelections();
290
5312f439 291
292 // ==========================================================================
293 // ************************* content of fContCenter *************************
294 // ========================================================================
295 // main drawing canvas
296 fCanvMain = new TRootEmbeddedCanvas("GUItime_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
297 fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
298 fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliTPCCalibViewerGUItime", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
299// fCanvMain->GetCanvas()->Connect("RangeAxisChanged()", "AliTPCCalibViewerGUItime", this, "GetMinMax()");
300 fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed.");
6fb51ca4 301 fCanvMain->GetCanvas()->SetRightMargin(0.062);
302 fCanvMain->GetCanvas()->SetLeftMargin(0.15);
5312f439 303
304 // =========================================================================
305 // ************************* content of fContRight *************************
306 // ========================================================================
307 //group frame for value information
308 fContValues = new TGGroupFrame(fContRight, "Data point info", kVerticalFrame | kFitWidth | kFitHeight);
309 fContRight->AddFrame(fContValues, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
310 //set layout manager
311 fContValues->SetLayoutManager(new TGMatrixLayout(fContValues, 0, 2, 5));
312 //value information labels
313
314 //run number label
315 fLblRunNumber = new TGLabel(fContValues, "Run:");
316 fLblRunNumber->SetTextJustify(kTextLeft);
317 fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
318 //run number
319 fLblRunNumberVal = new TGLabel(fContValues, "00000");
320 fLblRunNumberVal->SetTextJustify(kTextLeft);
321 fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
322 //time stamp label
323 fLblRunTime = new TGLabel(fContValues, "Time:");
324 fLblRunTime->SetTextJustify(kTextLeft);
325 fContValues->AddFrame(fLblRunTime, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
326 //run number
327 fLblRunTimeVal = new TGLabel(fContValues, "00.00.0000\n00:00:00");
328 fLblRunTimeVal->SetTextJustify(kTextLeft);
329 fContValues->AddFrame(fLblRunTimeVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
330 //value label x
331 fLblValueX = new TGLabel(fContValues, "x-Value:");
332 fLblValueX->SetTextJustify(kTextLeft);
333 fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
334 //value x
892226be 335 fLblValueXVal = new TGLabel(fContValues, "00.000e+00");
5312f439 336 fLblValueXVal->SetTextJustify(kTextRight);
337 fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
338 //value label y
339 fLblValueY = new TGLabel(fContValues, "y-Value:");
340 fLblValueY->SetTextJustify(kTextLeft);
341 fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
342 //value y
892226be 343 fLblValueYVal = new TGLabel(fContValues, "00.000e+00");
5312f439 344 fLblValueYVal->SetTextJustify(kTextRight);
345 fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
346 // draw button
347 fBtnDumpRuns = new TGTextButton(fContRight, "&Dump runs");
6fb51ca4 348 fContRight->AddFrame(fBtnDumpRuns, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
5312f439 349 fBtnDumpRuns->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDumpRuns()");
350 fBtnDumpRuns->SetToolTipText("Press to dump the run numbers of the current selection.");
351
352 // =========================================================================
353 // ****************** bottom content of fContTopBottom *********************
354 // =========================================================================
355
356 // custom options container
357 // --- fComboCustom --- the custom draw line on the very low
358 fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
359 fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
360
361 // ------------------------- content of fContCustom -------------------------
362 fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: ");
363 fLblCustomDraw->SetTextJustify(kTextLeft);
364 fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
365 // text field for custom draw command
366 fComboCustomDraw = new TGComboBox(fContCustom);
367// fComboCustomDraw->Resize(0, fLblValueY->GetDefaultHeight());
368 fComboCustomDraw->Resize(0, 22);
369 fComboCustomDraw->EnableTextInput(kTRUE);
370 fContCustom->AddFrame(fComboCustomDraw, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
371 fComboCustomDraw->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
372 fComboCustomDraw->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
373
374
375 // additional cuts container
376 fContCustomCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
377 fContTopBottom->AddFrame(fContCustomCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
378
379 // ------------------------- content of fContCustomCuts -------------------------
380 fLblCustomCuts = new TGLabel(fContCustomCuts, "Custom cuts: ");
381 fLblCustomCuts->SetTextJustify(kTextLeft);
382 fContCustomCuts->AddFrame(fLblCustomCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
383 // combo text field for additional cuts
384 fComboCustomCuts = new TGComboBox(fContCustomCuts);
385// fComboCustomCuts->Resize(0, fLblValueY->GetDefaultHeight());
386 fComboCustomCuts->Resize(0, 22);
387 fComboCustomCuts->EnableTextInput(kTRUE);
388 fContCustomCuts->AddFrame(fComboCustomCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
6fb51ca4 389 fComboCustomCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
390 fComboCustomCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
5312f439 391
392 SetWindowName("AliTPCCalibViewer GUI - Time");
393 MapSubwindows();
394 Resize(GetDefaultSize());
395 MapWindow();
396}
397//______________________________________________________________________________
398void AliTPCCalibViewerGUItime::SetInitialValues(){
399 //
400 // Set inital selections of the gui
401 //
402 fRadioXrun->SetState(kButtonDown);
403 fRadioXtime->SetState(kButtonUp);
404}
405
406//______________________________________________________________________________
6e7d7dc4 407void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeName) {
5312f439 408 //
409 // retrieve tree from file
410 //
6e7d7dc4 411 TString s=gSystem->GetFromPipe(Form("ls %s",fileName));
412// TString s(fileName);
e6970ab5 413 TObjArray *arr=s.Tokenize("\n");
414 TIter next(arr);
415 TObject *o=0;
416 if (fTree) delete fTree;
6e7d7dc4 417 fTree=new TChain(treeName);
e6970ab5 418 while ( (o=next()) ){
419 fTree->AddFile(o->GetName());
420 }
421 delete arr;
6e7d7dc4 422 if (!CheckChain()) return;
423 UseConfigFile(fConfigFile.Data());
424 Reload();
425
426}
427//______________________________________________________________________________
428void AliTPCCalibViewerGUItime::UseChain(TChain* chain = 0)
429{
430 //
431 //
432 //
433 fTree=chain;
434 if (!CheckChain()) return;
435 //set configuration file
436 UseConfigFile(fConfigFile.Data());
437 Reload();
438}
439//______________________________________________________________________________
440Bool_t AliTPCCalibViewerGUItime::CheckChain()
441{
442 //
443 // check whether cahin has entries
444 // decide whether to draw graphs in 2D
445 //
446 if (!fTree) return kFALSE;
e6970ab5 447 fTree->Lookup();
6e7d7dc4 448 Long64_t entries=fTree->GetEntries();
449 if (entries==0){
e6970ab5 450 AliError("No entries found in chain");
6e7d7dc4 451 return kFALSE;
6fb51ca4 452 }
6e7d7dc4 453 //check whether to draw graphs
454 CheckDrawGraph();
455 return kTRUE;
456}
457//______________________________________________________________________________
458void AliTPCCalibViewerGUItime::UseConfigFile(const char* file)
459{
460 //
461 // Use 'file' as configuration file
462 //
463 fConfigFile=file;
464 fConfigParser->ParseConfigFileTxt(fConfigFile.Data());
465 FillCalibTypes();
5312f439 466}
467//______________________________________________________________________________
6fb51ca4 468void AliTPCCalibViewerGUItime::FillRunTypes()
469{
5312f439 470 //
6fb51ca4 471 //Loop over the tree entries and fill the run types
5312f439 472 //
6fb51ca4 473 if (!fTree) return;
5312f439 474 Int_t id=0;
5312f439 475 fComboRunType->RemoveAll();
476 fComboRunType->AddEntry("ALL",id++);
477 fComboRunType->Select(0,kFALSE);
6e7d7dc4 478 if (!fTree->GetBranch("runType.")) return;
5312f439 479 TObjString *runType=0x0;
480 Int_t nevets=fTree->GetEntries();
5312f439 481 fTree->SetBranchStatus("*",0);
482 fTree->SetBranchStatus("runType.*",1);
e6970ab5 483 fTree->SetBranchAddress("runType.",&runType);
5312f439 484 for (Int_t iev=0;iev<nevets;++iev){
485 fTree->GetEntry(iev);
486 TString type=runType->String();
487 if (!type.IsNull()&&!fComboRunType->FindEntry(type)) fComboRunType->AddEntry(type,id++);
488 }
e6970ab5 489 fTree->ResetBranchAddresses();
5312f439 490 fTree->SetBranchStatus("*",1);
491}
492//______________________________________________________________________________
6fb51ca4 493void AliTPCCalibViewerGUItime::FillCalibTypes()
494{
495 //
496 // loop over configuration and fill calibration types
497 //
6fb51ca4 498 Int_t id=0;
499 fListCalibType->RemoveAll();
500 TObject *o=0x0;
501 fConfigParser->ResetIter();
502 TString type;
503 while ( (o=fConfigParser->NextKey()) ){
504 type=fConfigParser->GetData(o,kCalibType);
505 //remove whitespcaces
506 type.Remove(TString::kBoth,' ');
507 type.Remove(TString::kBoth,'\t');
508 if (type.IsNull()) type="UNSPECIFIED";
509// printf("CalibType: '%s'\n",type.Data());
510 if (!fListCalibType->FindEntry(type.Data())) {
511 fListCalibType->AddEntry(type,id);
512 fListCalibType->Select(id++);
513 }
514 }
515 //add type for unspecified calibration type
516 type="UNSPECIFIED";
517 if (!fListCalibType->FindEntry(type.Data())) {
518 fListCalibType->AddEntry(SubstituteUnderscores(type.Data()),id);
519 fListCalibType->Select(id++);
520 }
521}
522//______________________________________________________________________________
6e7d7dc4 523void AliTPCCalibViewerGUItime::CheckDrawGraph()
524{
525 //
526 // Check whether to draw graphs in 2D mode based on the number of entries in the chain
527 // GetEstimate() returns the maximum size of the arrays stored in GetV1()...
528 //
529 if (!fTree) return;
530 fNoGraph=kTRUE;
531 if (fTree->GetEntries()<fTree->GetEstimate()) fNoGraph=kFALSE;
532}
533//______________________________________________________________________________
534void AliTPCCalibViewerGUItime::Reload(Int_t first)
535{
6fb51ca4 536 //
537 // reload the gui contents, this is needed after the input tree has changed
538 //
539
540 if ( !fTree ) return;
541 //in case of the first call create run type and calibration type entries
542 if (first){
543 FillRunTypes();
544 FillCalibTypes();
545 }
546 //activate all branches
547 fTree->SetBranchStatus("*",1);
548 //reset variables list
549 fListVariables->RemoveAll();
550 //get selected calibration types
551 TList calibTypes;
552 fListCalibType->GetSelectedEntries(&calibTypes);
553
554 TObjArray *branchList = fTree->GetListOfBranches();
555 if ( !branchList ) return;
556 TIter nextBranch(branchList);
557 Int_t idCount=0,id=0;
558 TObject *objBranch=0;
559 while ( (objBranch=nextBranch()) ){
560 TString branchName(objBranch->GetName());
561 TString branchTitle(objBranch->GetName());
562 if (branchName == "run" || branchName == "time" || branchName == "runType.") continue;
563 Bool_t active=kTRUE;
564 TString calibType="UNSPECIFIED";
565 if (fConfigParser){
566 const TObject *key=(*fConfigParser)(branchName.Data());
567 if (key){
568 //test if branch is active
569 active=fConfigParser->GetValue(branchName.Data(),kBranchOnOff);
570 id=(*fConfigParser)()->IndexOf(key);
892226be 571// branchTitle=fConfigParser->GetData(key,kBranchTitle);
6fb51ca4 572 calibType=fConfigParser->GetData(key,kCalibType);
573 }
574 else{
575 id=1000+idCount;
576 }
577 } else {
578 id=idCount;
579 }
e6970ab5 580 if (calibType.IsNull()) calibType="UNSPECIFIED";
6fb51ca4 581 //check if branch is in selected calibration types
582 //if not, don't show it in the list and deactivate the branch.
583 Bool_t calibActive=kFALSE;
584 TIter nextCalib(&calibTypes);
585 TObject *objCalib=0;
e6970ab5 586 while ( (objCalib=nextCalib()) )
6fb51ca4 587 if (calibType==objCalib->GetTitle()) calibActive=kTRUE;
588 active&=calibActive;
589 if (!active){
590 TString s=branchName;
591 if (branchName.EndsWith(".")) s+="*";
592 fTree->SetBranchStatus(s.Data(),0);
593 continue;
594 }
595 fListVariables->AddEntry(SubstituteUnderscores(branchTitle.Data()),id);
596 ++idCount;
597 }
598 //trick to display modifications
599 if (!first){
600 fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight());
601 fListVariables->Resize(fListVariables->GetWidth()+1, fListVariables->GetHeight());
602 }
603}
604//______________________________________________________________________________
5312f439 605const char* AliTPCCalibViewerGUItime::GetDrawString(){
606 //
607 // create draw string for ttree by combining the user requestsa
608 //
609
610 TString selectedVariable="";
6fb51ca4 611 Int_t id=-1;
612 if (!fListVariables->GetSelectedEntry()) return "";
613 selectedVariable = fListVariables->GetSelectedEntry()->GetTitle();
614 id=fListVariables->GetSelectedEntry()->EntryId();
615// printf("id: %d\n",id);
616 TString branchName=selectedVariable;
617 const TObject *key=(*fConfigParser)(id);
618 if (key) branchName=(*fConfigParser)(id)->GetName();
5312f439 619 //treat case of TVector
6fb51ca4 620 if (branchName.EndsWith(".")){
5312f439 621 Int_t par = (Int_t)(fNmbPar->GetNumber());
6fb51ca4 622 branchName.Append(Form("fElements[%d]",par));
5312f439 623 }
624// if (fRadioXrun->GetState()==kButtonDown)
625// selectedVariable.Append(":run");
626// if (fRadioXtime->GetState()==kButtonDown)
627// selectedVariable.Append(":time");
628
6fb51ca4 629 return branchName.Data();
5312f439 630}
631//______________________________________________________________________________
6e7d7dc4 632const char* AliTPCCalibViewerGUItime::GetDrawOption(){
633 //
634 // get user selected draw options
635 //
636 TString drawOpt;
637 if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle();
638 if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase))
639 drawOpt+="same";
640 return drawOpt.Data();
641}
642//______________________________________________________________________________
643void AliTPCCalibViewerGUItime::GetCutString(TString &cutStr){
5312f439 644 //
645 // create cut string
646 //
647 TCut cuts(fComboCustomCuts->GetTextEntry()->GetText());
648 TString runType="";
649 if (fComboRunType->GetSelectedEntry()) runType=fComboRunType->GetSelectedEntry()->GetTitle();
650 if (runType!="ALL"&&!runType.IsNull()) cuts+=Form("runType.String().Data()==\"%s\"",runType.Data());
6e7d7dc4 651 cutStr=cuts.GetTitle();
652}
653//______________________________________________________________________________
654void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph)
655{
656 //
657 //
658 //
659 if (!withGraph){
660 fValuesX.ResizeTo(1);
661 fValuesY.ResizeTo(1);
662 fRunNumbers.ResizeTo(1);
663 fTimeStamps.ResizeTo(1);
664 } else {
665 fValuesX.ResizeTo(fTree->GetSelectedRows());
666 fValuesY.ResizeTo(fTree->GetSelectedRows());
667 fRunNumbers.ResizeTo(fTree->GetSelectedRows());
668 fTimeStamps.ResizeTo(fTree->GetSelectedRows());
669 fValuesY.SetElements(fTree->GetV3());
670 fRunNumbers.SetElements(fTree->GetV1());
671 fTimeStamps.SetElements(fTree->GetV2());
672 }
673}
674//______________________________________________________________________________
675void AliTPCCalibViewerGUItime::GetHistogramTitle(TString &title)
676{
677 //
678 // Create string for histogram title
679 //
680
681 title=fDrawString;
682 Int_t pos=title.First(">>");
683 if (pos>0) title=title(0,pos);
684 if (!fIsCustomDraw){
685 if (fRadioXrun->GetState()==kButtonDown){
686 title+=":Run";
687 } else if (fRadioXtime->GetState()==kButtonDown){
688 title+=":Date";
689 }
690 }
691 TString cuts;
692 GetCutString(cuts);
693 TObjArray *arr=title.Tokenize(":");
694 TObject *o=0x0;
695 title+=" {";
696 title+=cuts;
697 title+="}";
698 TIter next(arr,kIterBackward);
699 while ( (o=next()) ){
700 TString varName=o->GetName();
701 title+=";";
702 //substitue variable names with names in configuration file if available
703 if ((*fConfigParser)()->GetEntries()){
704 TString branchName=varName;
705 Int_t par=0;
706 if (branchName.Contains('.')) branchName=branchName(0,branchName.First('.')+1);
707 //chek if a configuration for that branch is available
708 const TObject *oBranch=(*fConfigParser)(branchName.Data());
709 if (oBranch){
710 TString branchTitle=fConfigParser->GetData(oBranch,kBranchTitle);
711 if (!branchTitle.IsNull()){
712 //check for TVectorT type branch
713 //add parameter name if available
714 if (varName.Contains("fElements")){
715 TString parStr=varName(varName.First('[')+1,varName.Length()-varName.First('[')-2);
716 par=parStr.Atoi();
717 branchTitle+=": ";
718 TString yparname=fConfigParser->GetData(oBranch,par+kParamNames);
719 if (!yparname.IsNull()){
720 branchTitle+=yparname;
721 } else {
722 branchTitle+="[";
723 branchTitle+=par;
724 branchTitle+="]";
725 }
726 }
727 }
728 varName=SubstituteUnderscores(branchTitle.Data());
729 }
730 }
731 title+=varName;
732 }
733 delete arr;
5312f439 734}
735//______________________________________________________________________________
736void AliTPCCalibViewerGUItime::DoDraw() {
737 TString drawString=fDrawString;
6e7d7dc4 738 TString cutString;
739 GetCutString(cutString);
740 TString optString = GetDrawOption();
741 Bool_t graphOutput=!fNoGraph; //ttree buffer for V1, V2... too small
742 graphOutput&=(drawString.First(">>")<0); //histogram output in custom draw
743 graphOutput&=fRadioXhist->GetState()!=kButtonDown; //histogram drawing selected
744 graphOutput&=!(fIsCustomDraw&&!fDrawString.Contains(":")); //custom draw 1D
745 Bool_t drawSame=optString.Contains("same",TString::kIgnoreCase);
746// optString+="goff";
747 if (graphOutput) {
748 drawString.Prepend("run:time:");
749 optString="goff";
750 }else{
751 if (!fIsCustomDraw){
752 if (fRadioXrun->GetState()==kButtonDown){
753 drawString+=":run";
754 } else if (fRadioXtime->GetState()==kButtonDown){
755 drawString+=":time";
756 }
757 }
758 }
5312f439 759 TVirtualPad *padsave=gPad;
760 fCanvMain->GetCanvas()->cd();
6e7d7dc4 761 //delete old histograms and graphs
762 if (!drawSame){
763 fTrashBox->Delete();
5312f439 764 fCurrentGraph=0x0;
5312f439 765 fCurrentHist=0x0;
766 }
6e7d7dc4 767// if (fCurrentGraph) {
768// delete fCurrentGraph;
769// fCurrentGraph=0x0;
770// //fCurrentHist in case of graph is the interrnal histogram,
771// // which is deleted by the graph itself.
772// fCurrentHist=0x0;
773// }
774// if (fCurrentHist) {
775// delete fCurrentHist;
776// fCurrentHist=0x0;
777// }
5312f439 778 //select data
779 fTree->Draw(drawString.Data(),cutString.Data(),optString.Data());
780 if (fTree->GetSelectedRows()==-1) return;
6e7d7dc4 781 UpdateValueArrays(graphOutput);
782 TString title;
783 GetHistogramTitle(title);
5312f439 784 Bool_t drawGraph=kFALSE;
6e7d7dc4 785 if (graphOutput){
786 if (fIsCustomDraw){
787 if (fDrawString.Contains(":")){
788 fValuesX.SetElements(fTree->GetV4());
789 drawGraph=kTRUE;
790 } else {
791 drawGraph=kFALSE;
792 }
793 }else{
5312f439 794 drawGraph=kTRUE;
6e7d7dc4 795 if (fRadioXrun->GetState()==kButtonDown){
796 fValuesX.SetElements(fTree->GetV1());
797 } else if (fRadioXtime->GetState()==kButtonDown){
798 fValuesX.SetElements(fTree->GetV2());
799 } else {
800 drawGraph=kFALSE;
6fb51ca4 801 }
802 }
6e7d7dc4 803 }//create graph according to selection
5312f439 804 if (drawGraph){
6e7d7dc4 805 TGraph *graph=new TGraph(fValuesX,fValuesY);
806 TString grDraw="p";
807 if (!drawSame) grDraw+="a";
808 if (!fIsCustomDraw) grDraw+="l";
809 graph->Draw(grDraw.Data());
810 graph->SetEditable(kFALSE);
811 TH1 *hist=graph->GetHistogram();
812 hist->SetTitle(title.Data());
813 fTrashBox->Add(graph);
814 graph->SetLineColor(fTrashBox->GetEntries());
815 graph->SetMarkerColor(fTrashBox->GetEntries());
816 if (!drawSame) {
817 fCurrentGraph=graph;
818 fCurrentHist=hist;
819 }
5312f439 820 } else {
6e7d7dc4 821 TH1 *hist=fTree->GetHistogram();
822 hist->SetTitle(title.Data());
823// hist->Draw(optString.Data());
824 fTrashBox->Add(hist);
825 hist->SetLineColor(fTrashBox->GetEntries());
826 hist->SetMarkerColor(fTrashBox->GetEntries());
827 if (!drawSame) fCurrentHist=hist;
5312f439 828 }
829
5312f439 830 //Set time axis if choosen as x-variables
831 if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw){
832 TAxis *xaxis=fCurrentHist->GetXaxis();
833 xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}");
834 xaxis->SetTimeDisplay(1);
835 xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3);
836 xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3);
837 }
6fb51ca4 838 //Set title offset
6e7d7dc4 839 if (!drawSame) fCurrentHist->GetYaxis()->SetTitleOffset(1.5);
5312f439 840 gPad->Modified();
841 gPad->Update();
842 padsave->cd();
843}
844
845//______________________________________________________________________________
846void AliTPCCalibViewerGUItime::DoDumpRuns()
847{
848 //
849 // Dump the current run numbers to stdout
850 //
6fb51ca4 851 Int_t npoints=fRunNumbers.GetNrows();
852 Int_t *sortIndex = new Int_t[npoints];
853 TMath::Sort(npoints,fRunNumbers.GetMatrixArray(),sortIndex,kFALSE);
854 Int_t run=0, prevRun=-1;
855
856 for (Int_t irun=0;irun<npoints;++irun){
857 run=(Int_t)fRunNumbers.GetMatrixArray()[sortIndex[irun]];
858 if (run!=prevRun) std::cout << Form("%d",run) << std::endl;
859 prevRun=run;
5312f439 860 }
6fb51ca4 861 delete sortIndex;
5312f439 862}
863//______________________________________________________________________________
864void AliTPCCalibViewerGUItime::DoParLimitChange()
865{
866 //
867 //
868 //
6fb51ca4 869 UpdateParName();
5312f439 870 DoDraw();
871}
872//______________________________________________________________________________
873void AliTPCCalibViewerGUItime::DoNewSelection() {
874 //
875 // decides whether to redraw if user makes another selection
876 //
877 UpdateParLimits();
878 fDrawString=GetDrawString();
879 fIsCustomDraw=kFALSE;
880 DoDraw();
881}
882//______________________________________________________________________________
883void AliTPCCalibViewerGUItime::DoCustomDraw()
884{
885 //
886 //
887 //
888 fDrawString=fComboCustomDraw->GetTextEntry()->GetText();
6e7d7dc4 889// if (fDrawString.Contains(">>")){
890// Warning("DoCustomDraw","Currently no user defined histograms allowed!");
891// return;
892// }
893 fNmbPar->SetState(kFALSE);
5312f439 894 fIsCustomDraw=kTRUE;
895 DoDraw();
896}
897//______________________________________________________________________________
898void AliTPCCalibViewerGUItime::DoCustomCutsDraw()
899{
900 //
901 //
902 //
903 if (fIsCustomDraw) DoCustomDraw();
904 else {
905 fDrawString=GetDrawString();
906 fIsCustomDraw=kFALSE;
907 DoDraw();
908 }
909}
910//______________________________________________________________________________
911void AliTPCCalibViewerGUItime::HandleButtonsDrawSel(Int_t id)
912{
913 //
914 // Draw selection button handling (x-variable)
915 //
916
917 if (id == -1) {
918 TGButton *btn = (TGButton *) gTQSender;
919 id = btn->WidgetId();
920 }
921
922 Bool_t doDraw=kFALSE;
923 switch (id) {
924 case (kRadioXhist):
925 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
926 if (doDraw){
927 fRadioXrun->SetState(kButtonUp);
928 fRadioXtime->SetState(kButtonUp);
929 }
930 break;
931 case (kRadioXrun):
932 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXhist->GetState()==kButtonDown);
933 if (doDraw){
934 fRadioXhist->SetState(kButtonUp);
935 fRadioXtime->SetState(kButtonUp);
936 }
937 break;
938 case (kRadioXtime):
939 doDraw=(fRadioXhist->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
940 if (doDraw){
941 fRadioXrun->SetState(kButtonUp);
942 fRadioXhist->SetState(kButtonUp);
943 }
944 break;
945 }
6fb51ca4 946 if (doDraw) DoCustomCutsDraw();
5312f439 947}
948//______________________________________________________________________________
6fb51ca4 949void AliTPCCalibViewerGUItime::UpdateParName()
950{
951 //
952 // change parameter name
953 //
954
955 Int_t par = (Int_t)(fNmbPar->GetNumber());
956 TString parName=par;
957 Int_t id=fListVariables->GetSelectedEntry()->EntryId();
958 if (fConfigParser && (*fConfigParser)(id)) parName=fConfigParser->GetData((*fConfigParser)(id),par+kParamNames);
959 fLblPar->SetText(Form("Parameter: %s",parName.Data()));
960 fDrawString=GetDrawString();
961 fIsCustomDraw=kFALSE;
962}
963
964//______________________________________________________________________________
5312f439 965void AliTPCCalibViewerGUItime::UpdateParLimits()
966{
967 //
968 // Adjust limits for TVectorT based variables
969 //
970 if (!fTree) return;
6fb51ca4 971 TString selectedVariableTitle="";
972 Int_t id=-1;
973 if (!fListVariables->GetSelectedEntry()) return;
974 selectedVariableTitle = fListVariables->GetSelectedEntry()->GetTitle();
975 id=fListVariables->GetSelectedEntry()->EntryId();
976// printf("id: %d\n",id);
977 TString selectedVariable=selectedVariableTitle;
978 const TObject *key=(*fConfigParser)(id);
979 if (key) selectedVariable=(*fConfigParser)(id)->GetName();
980
5312f439 981 if (selectedVariable.IsNull()||!selectedVariable.EndsWith(".")) {
982 fNmbPar->SetState(kFALSE);
6fb51ca4 983 fLblPar->SetText("Parameter: none");
5312f439 984 return;
985 }
986 TVectorD *vD=0x0;
987 TVectorF *vF=0x0;
988 Int_t maxPar=0;
e6970ab5 989 fTree->GetEntry(1);
990 TBranch *branch=fTree->GetTree()->GetBranch(selectedVariable.Data());
5312f439 991 TString branchClass=branch->GetClassName();
e6970ab5 992 Int_t event=0;
5312f439 993 if (branchClass=="TVectorT<double>"){
e6970ab5 994// branch->SetAddress(&vD);
995 fTree->SetBranchAddress(selectedVariable.Data(),&vD);
996 while (maxPar<2&&event<fTree->GetEntries()){
997 fTree->GetEntry(event++);
998 maxPar=vD->GetNrows();
999 }
5312f439 1000 } else if (branchClass=="TVectorT<float>"){
e6970ab5 1001// branch->SetAddress(&vF);
1002 fTree->SetBranchAddress(selectedVariable.Data(),&vF);
1003 while (maxPar<2&&event<fTree->GetEntries()){
1004 fTree->GetEntry(event++);
1005 maxPar=vF->GetNrows();
1006 }
5312f439 1007 } else {
1008 //class not known
1009 fNmbPar->SetState(kFALSE);
1010 return;
1011 }
e6970ab5 1012// branch->ResetAddress();
6e7d7dc4 1013 fTree->SetBranchAddress(selectedVariable.Data(),0x0);
5312f439 1014 fNmbPar->SetNumber(0);
1015 fNmbPar->SetLimitValues(0,maxPar-1);
1016 fNmbPar->SetState(kTRUE);
6fb51ca4 1017 UpdateParName();
5312f439 1018}
1019//______________________________________________________________________________
6fb51ca4 1020void AliTPCCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/)
5312f439 1021{
1022 //
1023 // handle mouse events in the draw canvas
1024 //
5312f439 1025 UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0;
1026 Double_t valx=0.,valy=0.;
1027 if (!fCurrentGraph) {
1028 fLblRunNumberVal->SetText(Form("%05u",run));
e6970ab5 1029 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS));
892226be 1030 fLblValueXVal->SetText(Form("%.3e", valx));
1031 fLblValueYVal->SetText(Form("%.3e", valy));
5312f439 1032 return;
1033 }
1034 TVirtualPad *padsave=gPad;
1035 fCanvMain->GetCanvas()->cd();
1036 Int_t n=fValuesY.GetNrows();
1037 Double_t *arr=0x0;
1038 arr=fValuesX.GetMatrixArray();
1039
1040 Int_t minDist=1000000;
1041 Int_t minPoint=-1;
1042 for (Int_t i=0;i<n;++i){
1043 Int_t pxp = gPad->XtoAbsPixel(gPad->XtoPad(arr[i]));
1044 Int_t pyp = gPad->YtoAbsPixel(gPad->YtoPad(fValuesY[i]));
e6970ab5 1045 Int_t d = TMath::Nint(TMath::Sqrt(TMath::Abs(pxp-x) + TMath::Abs(pyp-y)));
5312f439 1046 if (d < minDist) {
1047 minDist = d;
1048 minPoint = i;
1049 }
1050 }
1051 if (minDist<2){
1052 TTimeStamp t((Int_t)fTimeStamps[minPoint]);
1053 t.GetDate(kTRUE,0,&yy,&mm,&dd);
1054 t.GetTime(kTRUE,0,&HH,&MM,&SS);
1055 run=(UInt_t)fRunNumbers[minPoint];
1056 valx=fValuesX[minPoint];
1057 valy=fValuesY[minPoint];
1058 } else {
1059 dd=0;mm=0;yy=0;HH=0;MM=0;SS=0;run=0;
1060 valx=0.;
1061 valy=0.;
1062 }
1063 fLblRunNumberVal->SetText(Form("%05u",run));
1064 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS));
1065 if (fIsCustomDraw){
892226be 1066 fLblValueXVal->SetText(Form("%.3e", valx));
5312f439 1067 }else{
1068 if (fRadioXrun->GetState()==kButtonDown){
1069 fLblValueXVal->SetText("Run");
1070 } else if (fRadioXtime->GetState()==kButtonDown){
1071 fLblValueXVal->SetText("Time");
1072 }
1073 }
892226be 1074 fLblValueYVal->SetText(Form("%.3e", valy));
5312f439 1075 padsave->cd();
1076 if (run==0) return;
1077 if (event == kButton1Double ){
1078 SetGuiTree(run);
1079 }
1080 //find closes point of current selection
1081}
1082//______________________________________________________________________________
1083void AliTPCCalibViewerGUItime::SetGuiTree(Int_t run)
1084{
1085 //
1086 // create the AliTPCCalibViewerGUI tree for run
1087 // cache tree in directory fOutputCacheDir
1088 // retrieve file from this directory if it already exists
1089 //
1090
1091 //try to find file for run in fOutputCacheDir
1092 TString fileName=fOutputCacheDir;
1093 if (!fileName.EndsWith("/")) fileName+="/";
1094 fileName+=Form("guiTreeRun_%d.root",run);
1095 TFile f(fileName.Data());
1096 if (f.IsOpen()){
1097 f.Close();
1098 fCalibViewerGUI->Initialize(fileName.Data());
6e7d7dc4 1099 fCalibViewerGUI->Reload();
5312f439 1100 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run)));
1101 return;
1102 }
1103 f.Close();
1104 Bool_t sucess=AliTPCcalibDB::CreateGUITree(run,fileName.Data());
1105 if (sucess){
1106 fCalibViewerGUI->Initialize(fileName.Data());
6e7d7dc4 1107 fCalibViewerGUI->Reload();
5312f439 1108 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run)));
1109 }else{
1110 fCalibViewerGUI->Reset();
1111 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX")));
1112 }
1113}
1114//______________________________________________________________________________
6fb51ca4 1115const char* AliTPCCalibViewerGUItime::SubstituteUnderscores(const char* in)
1116{
1117 //
1118 //
1119 //
1120 TString s(in);
1121 s.ReplaceAll("_{","|{");
1122 s.ReplaceAll("_"," ");
1123 s.ReplaceAll("|{","_{");
1124 return s.Data();
1125}
1126//______________________________________________________________________________
6e7d7dc4 1127TObjArray* AliTPCCalibViewerGUItime::ShowGUI(const char* fileName, const char* treeName) {
5312f439 1128 //
1129 // Initialize and show GUI for presentation for demonstration purposes
1130 // or for fast standalone use
1131 //
1132 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1133 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1134 frmMain->SetCleanup(kDeepCleanup);
1135
1136 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1137 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1138
1139 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1140 TGCompositeFrame* tabCont2 = tabMain->AddTab("Detail - XXXXX");
1141
1142 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1143 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
6e7d7dc4 1144 calibViewerTime->SetConfigFileName("$ALICE_ROOT/TPC/CalibMacros/calibVarDescription.txt");
1145 calibViewerTime->UseFile(fileName, treeName);
5312f439 1146
1147 AliTPCCalibViewerGUI* calibViewer = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, 0);
1148 tabCont2->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1149 calibViewerTime->SetCalibViewerGUI(calibViewer);
1150 calibViewerTime->SetCalibViewerGUItab(tabMain->GetTabTab(1));
1151
1152
1153 TObjArray *guiArray = new TObjArray();
1154 guiArray->Add(calibViewerTime);
1155 guiArray->Add(calibViewer);
1156
1157 frmMain->MapSubwindows();
1158 frmMain->Resize();
1159 frmMain->MapWindow();
1160
1161 return guiArray;
1162}
1163
6e7d7dc4 1164//______________________________________________________________________________
1165TObjArray* AliTPCCalibViewerGUItime::ShowGUI(TChain *chain) {
1166 //
1167 // Initialize and show GUI for presentation for demonstration purposes
1168 // or for fast standalone use
1169 //
1170 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1171 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1172 frmMain->SetCleanup(kDeepCleanup);
1173
1174 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1175 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1176
1177 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1178
1179 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1180 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1181 calibViewerTime->UseChain(chain);
1182
1183 TObjArray *guiArray = new TObjArray();
1184 guiArray->Add(calibViewerTime);
1185
1186 frmMain->MapSubwindows();
1187 frmMain->Resize();
1188 frmMain->MapWindow();
1189
1190 return guiArray;
1191}