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