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