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