1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
20 ///////////////////////////////////////////////////////////////////////////////
26 #include <TDirectory.h>
30 #include <TVirtualPad.h>
32 #include <TObjArray.h>
33 #include <TObjString.h>
42 #include <TIterator.h>
45 #include <TTimeStamp.h>
49 #include <TGFileDialog.h>
50 #include <TGInputDialog.h>
53 #include <TGListBox.h>
54 #include <TGComboBox.h>
55 #include <TGNumberEntry.h>
57 #include <TRootEmbeddedCanvas.h>
58 #include <TGSplitter.h>
59 #include <TGButtonGroup.h>
66 #include "AliTPCCalibViewerGUI.h"
67 #include "AliTPCCalibViewer.h"
68 #include "AliTPCcalibDB.h"
69 #include "AliTPCcalibDButil.h"
70 #include "AliTPCConfigParser.h"
72 #include "AliTPCCalibViewerGUItime.h"
74 ClassImp(AliTPCCalibViewerGUItime)
76 AliTPCCalibViewerGUItime::AliTPCCalibViewerGUItime(const TGWindow *p, UInt_t w, UInt_t h) :
77 TGCompositeFrame(p,w,h),
81 fCalibViewerGUItab(0x0),
84 fCurrentRunDetails(-1),
85 fOutputCacheDir("/tmp"),
88 fConfigParser(new AliTPCConfigParser),
89 fIsCustomDraw(kFALSE),
95 fGraphLimitEntries(10000),
96 fMapRefTrees(new TMap),
98 //main canvas Top part, bottom part
100 //top left, centre, right
105 fChkDrawOptSame(0x0),
106 fComboAddDrawOpt(0x0),
108 fContDrawSelSubRunTime(0x0),
129 fLblRunNumberVal(0x0),
138 fContCustomCuts(0x0),
141 fComboCustomDraw(0x0),
142 fComboCustomCuts(0x0),
143 fTrashBox(new TObjArray)
148 fMapRefTrees->SetOwnerKeyValue();
149 fTrashBox->SetOwner();
151 gStyle->SetMarkerStyle(20);
152 gStyle->SetMarkerSize(0.5);
155 //______________________________________________________________________________
156 AliTPCCalibViewerGUItime::~AliTPCCalibViewerGUItime(){
160 delete fConfigParser;
164 //______________________________________________________________________________
165 void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) {
169 // ======================================================================
170 // ************************* Display everything *************************
171 // ======================================================================
173 SetCleanup(kDeepCleanup);
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));
182 fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
183 fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
185 // ***********************************************************************
186 // ************************* content of fContLCR *************************
187 // ***********************************************************************
189 fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
190 fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
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));
198 fContRight = new TGCompositeFrame(fContLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight);
199 fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
202 fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
203 fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
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));
211 // ========================================================================
212 // ************************* content of fContLeft *************************
213 // ========================================================================
214 // --- draw button and tabLeft ---
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()");
228 fComboAddDrawOpt->GetTextEntry()->SetText("",kFALSE);
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));
237 // ------------------------- content of fContDrawOpt -------------------------
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");
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");
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");
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()");
264 //-------------------- run type selection ------------------------
266 fLblRunType = new TGLabel(fContDrawSel, "Run Type:");
267 fLblRunType->SetTextJustify(kTextLeft);
268 fContDrawSel->AddFrame(fLblRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
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);
277 //-------------------- parameter selection ------------------------
279 fLblPar = new TGLabel(fContDrawSel, "Parameter:");
280 fLblPar->SetTextJustify(kTextLeft);
281 fContDrawSel->AddFrame(fLblPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
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);
288 //-------------------- calibration type selection ------------------------
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));
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();
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.");
311 fCanvMain->GetCanvas()->SetRightMargin(0.062);
312 fCanvMain->GetCanvas()->SetLeftMargin(0.15);
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));
321 fContValues->SetLayoutManager(new TGMatrixLayout(fContValues, 0, 2, 5));
322 //value information labels
325 fLblRunNumber = new TGLabel(fContValues, "Run:");
326 fLblRunNumber->SetTextJustify(kTextLeft);
327 fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
329 fLblRunNumberVal = new TGLabel(fContValues, "000000");
330 fLblRunNumberVal->SetTextJustify(kTextLeft);
331 fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
333 fLblRunTime = new TGLabel(fContValues, "Time:");
334 fLblRunTime->SetTextJustify(kTextLeft);
335 fContValues->AddFrame(fLblRunTime, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
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));
341 fLblValueX = new TGLabel(fContValues, "x-Value:");
342 fLblValueX->SetTextJustify(kTextLeft);
343 fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
345 fLblValueXVal = new TGLabel(fContValues, "00.000e+00");
346 fLblValueXVal->SetTextJustify(kTextRight);
347 fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
349 fLblValueY = new TGLabel(fContValues, "y-Value:");
350 fLblValueY->SetTextJustify(kTextLeft);
351 fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
353 fLblValueYVal = new TGLabel(fContValues, "00.000e+00");
354 fLblValueYVal->SetTextJustify(kTextRight);
355 fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
357 fBtnDumpRuns = new TGTextButton(fContRight, "&Dump runs");
358 fContRight->AddFrame(fBtnDumpRuns, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
359 fBtnDumpRuns->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDumpRuns()");
360 fBtnDumpRuns->SetToolTipText("Press to dump the run numbers of the current selection.");
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));
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);
370 TGCompositeFrame *frame1 = new TGCompositeFrame(fContAliases, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
371 fContAliases->AddFrame(frame1, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
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);
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);
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.");
393 // =========================================================================
394 // ****************** bottom content of fContTopBottom *********************
395 // =========================================================================
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));
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()");
414 fComboCustomDraw->GetTextEntry()->SetText("",kFALSE);
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));
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));
430 fComboCustomCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
431 fComboCustomCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
432 fComboCustomCuts->GetTextEntry()->SetText("",kFALSE);
434 SetWindowName("AliTPCCalibViewer GUI - Time");
436 Resize(GetDefaultSize());
439 //______________________________________________________________________________
440 void AliTPCCalibViewerGUItime::SetInitialValues(){
442 // Set inital selections of the gui
444 fRadioXrun->SetState(kButtonDown);
445 fRadioXtime->SetState(kButtonUp);
448 //______________________________________________________________________________
449 void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeName) {
451 // retrieve tree from file
453 TString s=gSystem->GetFromPipe(Form("ls %s",fileName));
454 // TString s(fileName);
455 TObjArray *arr=s.Tokenize("\n");
458 if (fTree) delete fTree;
459 fTree=new TChain(treeName);
460 while ( (o=next()) ){
461 fTree->AddFile(o->GetName());
464 if (!CheckChain()) return;
465 UseConfigFile(fConfigFile.Data());
469 //______________________________________________________________________________
470 void AliTPCCalibViewerGUItime::UseChain(TChain *const chain = 0)
476 if (!CheckChain()) return;
477 //set configuration file
478 UseConfigFile(fConfigFile.Data());
481 //______________________________________________________________________________
482 Bool_t AliTPCCalibViewerGUItime::CheckChain()
485 // check whether cahin has entries
486 // decide whether to draw graphs in 2D
488 if (!fTree) return kFALSE;
490 Long64_t entries=fTree->GetEntries();
492 AliError("No entries found in chain");
495 //check whether to draw graphs
499 //______________________________________________________________________________
500 void AliTPCCalibViewerGUItime::UseConfigFile(const char* file)
503 // Use 'file' as configuration file
506 fConfigParser->ParseConfigFileTxt(fConfigFile.Data());
509 //______________________________________________________________________________
510 void AliTPCCalibViewerGUItime::FillRunTypes()
513 //Loop over the tree entries and fill the run types
517 fComboRunType->RemoveAll();
518 fComboRunType->AddEntry("ALL",id++);
519 fComboRunType->Select(0,kFALSE);
520 if (!fTree->GetBranch("runType.")) return;
521 TObjString *runType=0x0;
522 Int_t nevets=fTree->GetEntries();
523 fTree->SetBranchStatus("*",0);
524 fTree->SetBranchStatus("runType.*",1);
525 fTree->SetBranchAddress("runType.",&runType);
526 for (Int_t iev=0;iev<nevets;++iev){
527 fTree->GetEntry(iev);
528 TString type=runType->String();
529 if (!type.IsNull()&&!fComboRunType->FindEntry(type)) fComboRunType->AddEntry(type,id++);
531 fTree->ResetBranchAddresses();
532 fTree->SetBranchStatus("*",1);
534 //______________________________________________________________________________
535 void AliTPCCalibViewerGUItime::FillCalibTypes()
538 // loop over configuration and fill calibration types
541 fListCalibType->RemoveAll();
543 fConfigParser->ResetIter();
545 while ( (o=fConfigParser->NextKey()) ){
546 type=fConfigParser->GetData(o,kCalibType);
547 //remove whitespcaces
548 type.Remove(TString::kBoth,' ');
549 type.Remove(TString::kBoth,'\t');
550 if (type.IsNull()) type="UNSPECIFIED";
551 // printf("CalibType: '%s'\n",type.Data());
552 if (!fListCalibType->FindEntry(type.Data())) {
553 fListCalibType->AddEntry(type.Data(),id);
554 fListCalibType->Select(id++);
557 //add type for unspecified calibration type
559 if (!fListCalibType->FindEntry(type.Data())) {
560 fListCalibType->AddEntry(type.Data(),id);
561 fListCalibType->Select(id++);
564 //______________________________________________________________________________
565 void AliTPCCalibViewerGUItime::CheckDrawGraph()
568 // Check whether to draw graphs in 2D mode based on the number of entries in the chain
569 // GetEstimate() returns the maximum size of the arrays stored in GetV1()...
573 if (fTree->GetEntries()<fTree->GetEstimate()) fNoGraph=kFALSE;
575 //______________________________________________________________________________
576 void AliTPCCalibViewerGUItime::Reload(Int_t first)
579 // reload the gui contents, this is needed after the input tree has changed
582 if ( !fTree ) return;
583 //in case of the first call create run type and calibration type entries
588 //activate all branches
589 fTree->SetBranchStatus("*",1);
590 //reset variables list
591 fListVariables->RemoveAll();
592 //get selected calibration types
594 fListCalibType->GetSelectedEntries(&calibTypes);
596 TObjArray *branchList = fTree->GetListOfBranches();
597 if ( !branchList ) return;
598 TIter nextBranch(branchList);
599 Int_t idCount=0,id=0;
600 TObject *objBranch=0;
601 while ( (objBranch=nextBranch()) ){
602 TString branchName(objBranch->GetName());
603 TString branchTitle(objBranch->GetName());
604 if (branchName == "run" || branchName == "time" || branchName == "runType.") continue;
606 TString calibType="UNSPECIFIED";
608 const TObject *key=(*fConfigParser)(branchName.Data());
610 //test if branch is active
611 active=fConfigParser->GetValue(branchName.Data(),kBranchOnOff);
612 id=(*fConfigParser)()->IndexOf(key);
613 // branchTitle=fConfigParser->GetData(key,kBranchTitle);
614 calibType=fConfigParser->GetData(key,kCalibType);
622 if (calibType.IsNull()) calibType="UNSPECIFIED";
623 //check if branch is in selected calibration types
624 //if not, don't show it in the list and deactivate the branch.
625 Bool_t calibActive=kFALSE;
626 TIter nextCalib(&calibTypes);
628 while ( (objCalib=nextCalib()) )
629 if (calibType==objCalib->GetTitle()) calibActive=kTRUE;
632 TString s=branchName;
633 if (branchName.EndsWith(".")) s+="*";
634 // fTree->SetBranchStatus(s.Data(),0);
637 // fListVariables->AddEntry(SubstituteUnderscores(branchTitle.Data()),id);
638 fListVariables->AddEntry(branchTitle.Data(),id);
641 //trick to display modifications
642 fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight());
643 fListVariables->Resize(fListVariables->GetWidth()+1, fListVariables->GetHeight());
645 //______________________________________________________________________________
646 void AliTPCCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const char* refName)
649 // map of reference trees that should always be attached to the CalibViewerGUI
651 fMapRefTrees->Add(new TObjString(refName), new TObjString(treeFileName));
654 //______________________________________________________________________________
655 const TString AliTPCCalibViewerGUItime::GetDrawString(){
657 // create draw string for ttree by combining the user requestsa
660 TString selectedVariable="";
662 if (!fListVariables->GetSelectedEntry()) return "";
663 selectedVariable = fListVariables->GetSelectedEntry()->GetTitle();
664 id=fListVariables->GetSelectedEntry()->EntryId();
665 // printf("id: %d\n",id);
666 TString branchName=selectedVariable;
668 const TObject *key=(*fConfigParser)(id);
669 if (key) branchName=(*fConfigParser)(id)->GetName();
671 //treat case of TVector
672 if (branchName.EndsWith(".")){
673 Int_t par = (Int_t)(fNmbPar->GetNumber());
674 branchName.Append(Form("fElements[%d]",par));
676 // if (fRadioXrun->GetState()==kButtonDown)
677 // selectedVariable.Append(":run");
678 // if (fRadioXtime->GetState()==kButtonDown)
679 // selectedVariable.Append(":time");
683 //______________________________________________________________________________
684 const TString AliTPCCalibViewerGUItime::GetDrawOptionString(){
686 // get user selected draw options
689 if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle();
690 if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase))
694 //______________________________________________________________________________
695 void AliTPCCalibViewerGUItime::GetCutString(TString &cutStr){
699 TCut cuts(fComboCustomCuts->GetTextEntry()->GetText());
701 if (fComboRunType->GetSelectedEntry()) runType=fComboRunType->GetSelectedEntry()->GetTitle();
702 if (runType!="ALL"&&!runType.IsNull()) cuts+=Form("runType.String().Data()==\"%s\"",runType.Data());
703 cutStr=cuts.GetTitle();
705 //______________________________________________________________________________
706 void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph, const Double_t *xArr)
712 fValuesX.ResizeTo(1);
713 fValuesY.ResizeTo(1);
714 fRunNumbers.ResizeTo(1);
715 fTimeStamps.ResizeTo(1);
717 const Long64_t nrows=fTree->GetSelectedRows();
718 fValuesX.ResizeTo(nrows);
719 fValuesY.ResizeTo(nrows);
720 fRunNumbers.ResizeTo(nrows);
721 fTimeStamps.ResizeTo(nrows);
722 long long *index=new long long[nrows];
723 TMath::Sort(nrows,fTree->GetV2(),index,kFALSE);
724 for (Long64_t i=0; i<nrows; ++i){
725 fValuesX.GetMatrixArray()[i]=xArr[index[i]];
726 fValuesY.GetMatrixArray()[i]=fTree->GetV3()[index[i]];
727 fRunNumbers.GetMatrixArray()[i]=fTree->GetV1()[index[i]];
728 fTimeStamps.GetMatrixArray()[i]=fTree->GetV2()[index[i]];
733 //______________________________________________________________________________
734 void AliTPCCalibViewerGUItime::GetHistogramTitle(TString &title)
737 // Create string for histogram title
741 Int_t pos=title.First(">>");
742 if (pos>0) title=title(0,pos);
743 // if (!fIsCustomDraw){
744 if (fRadioXrun->GetState()==kButtonDown){
746 } else if (fRadioXtime->GetState()==kButtonDown){
752 TObjArray *arr=title.Tokenize(":");
757 TIter next(arr,kIterBackward);
758 while ( (o=next()) ){
759 TString varName=o->GetName();
761 //substitue variable names with names in configuration file if available
762 if ((*fConfigParser)()->GetEntries()){
763 TString branchName=varName;
765 if (branchName.Contains('.')) branchName=branchName(0,branchName.First('.')+1);
766 //chek if a configuration for that branch is available
767 const TObject *oBranch=(*fConfigParser)(branchName.Data());
769 TString branchTitle=fConfigParser->GetData(oBranch,kBranchTitle);
770 if (!branchTitle.IsNull()){
771 //check for TVectorT type branch
772 //add parameter name if available
773 if (varName.Contains("fElements")){
774 TString parStr=varName(varName.First('[')+1,varName.Length()-varName.First('[')-2);
777 TString yparname=fConfigParser->GetData(oBranch,par+kParamNames);
778 if (!yparname.IsNull()){
779 branchTitle+=yparname;
788 SubstituteUnderscores(varName);
795 //______________________________________________________________________________
796 void AliTPCCalibViewerGUItime::AdjustYRange()
801 TIter nextGraphicObject(fTrashBox);
804 while ( (o=nextGraphicObject()) ){
805 if (o->IsA()==TGraph::Class()){
806 TGraph *gr=(TGraph*)o;
808 min=TMath::MinElement(gr->GetN(),gr->GetY());
809 max=TMath::MaxElement(gr->GetN(),gr->GetY());
811 Float_t currmin=TMath::MinElement(gr->GetN(),gr->GetY());
812 Float_t currmax=TMath::MaxElement(gr->GetN(),gr->GetY());
813 if (currmax>max) max=currmax;
814 if (currmin<min) min=currmin;
819 if (min!=0) min=min-(max-min)/10;
820 if (max!=0) max=max+(max-min)/10;
821 fCurrentHist->SetMinimum(min);
822 fCurrentHist->SetMaximum(max);
825 //______________________________________________________________________________
826 void AliTPCCalibViewerGUItime::DoDraw() {
830 TString drawString=fDrawString;
832 GetCutString(cutString);
833 TString optString = GetDrawOptionString();
834 Bool_t graphOutput=!fNoGraph; //ttree buffer for V1, V2... too small
835 graphOutput&=(drawString.First(">>")<0); //histogram output in custom draw
836 graphOutput&=fRadioXhist->GetState()!=kButtonDown; //histogram drawing selected
837 // graphOutput&=!(fIsCustomDraw&&!fDrawString.Contains(":")); //custom draw 1D
838 // graphOutput&=fDrawString.CountChar(':')<2; //custom draw 1D
839 if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
840 if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
841 Bool_t drawSame=optString.Contains("same",TString::kIgnoreCase);
842 // optString+="goff";
844 drawString.Prepend("run:time:");
847 // if (!fIsCustomDraw){
848 if (fRadioXrun->GetState()==kButtonDown){
850 } else if (fRadioXtime->GetState()==kButtonDown){
855 TVirtualPad *padsave=gPad;
856 fCanvMain->GetCanvas()->cd();
857 //delete old histograms and graphs
863 // printf("%s (%s) [%s]\n",drawString.Data(), cutString.Data(), optString.Data());
865 fTree->Draw(drawString.Data(),cutString.Data(),optString.Data());
866 if (fTree->GetSelectedRows()==-1) return;
869 GetHistogramTitle(title);
870 Bool_t drawGraph=kFALSE;
874 if (fIsCustomDraw&&fDrawString.Contains(":")){
875 // fValuesX.SetElements(fTree->GetV4());
878 if (fRadioXrun->GetState()==kButtonDown){
879 // fValuesX.SetElements(fTree->GetV1());
881 } else if (fRadioXtime->GetState()==kButtonDown){
882 // fValuesX.SetElements(fTree->GetV2());
889 if (xArr) UpdateValueArrays(graphOutput, xArr);
891 // if (fIsCustomDraw){
892 // if (fDrawString.Contains(":")){
893 // fValuesX.SetElements(fTree->GetV4());
900 // if (fRadioXrun->GetState()==kButtonDown){
901 // fValuesX.SetElements(fTree->GetV1());
902 // } else if (fRadioXtime->GetState()==kButtonDown){
903 // fValuesX.SetElements(fTree->GetV2());
909 //create graph according to selection
911 TGraph *graph=new TGraph(fValuesX,fValuesY);
913 if (!drawSame) grDraw+="a";
914 if (!fIsCustomDraw) grDraw+="l";
915 graph->Draw(grDraw.Data());
916 graph->SetEditable(kFALSE);
917 TH1 *hist=graph->GetHistogram();
918 hist->SetTitle(title.Data());
919 fTrashBox->Add(graph);
920 graph->SetLineColor(fTrashBox->GetEntries());
921 graph->SetMarkerColor(fTrashBox->GetEntries());
927 TH1 *hist=fTree->GetHistogram();
928 hist->SetTitle(title.Data());
929 // hist->Draw(optString.Data());
930 fTrashBox->Add(hist);
931 hist->SetLineColor(fTrashBox->GetEntries());
932 hist->SetMarkerColor(fTrashBox->GetEntries());
933 if (!drawSame) fCurrentHist=hist;
936 //Set time axis if choosen as x-variables
937 // if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw&&!drawSame){
938 if (fRadioXtime->GetState()==kButtonDown&&!drawSame){
939 TAxis *xaxis=fCurrentHist->GetXaxis();
940 xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}");
941 xaxis->SetTimeDisplay(1);
942 xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3);
943 xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3);
947 fCurrentHist->GetYaxis()->SetTitleOffset(1.5);
957 //______________________________________________________________________________
958 void AliTPCCalibViewerGUItime::DoDumpRuns()
961 // Dump the current run numbers to stdout
963 Int_t npoints=fRunNumbers.GetNrows();
964 Int_t *sortIndex = new Int_t[npoints];
965 TMath::Sort(npoints,fRunNumbers.GetMatrixArray(),sortIndex,kFALSE);
966 Int_t run=0, prevRun=-1;
968 for (Int_t irun=0;irun<npoints;++irun){
969 run=(Int_t)fRunNumbers.GetMatrixArray()[sortIndex[irun]];
970 if (run!=prevRun) std::cout << Form("%d",run) << std::endl;
975 //______________________________________________________________________________
976 void AliTPCCalibViewerGUItime::DoParLimitChange()
984 //______________________________________________________________________________
985 void AliTPCCalibViewerGUItime::DoNewSelection() {
987 // decides whether to redraw if user makes another selection
990 fDrawString=GetDrawString();
991 fIsCustomDraw=kFALSE;
994 //______________________________________________________________________________
995 void AliTPCCalibViewerGUItime::DoCustomDraw()
1000 fDrawString=fComboCustomDraw->GetTextEntry()->GetText();
1001 // if (fDrawString.Contains(">>")){
1002 // Warning("DoCustomDraw","Currently no user defined histograms allowed!");
1005 fNmbPar->SetState(kFALSE);
1006 fIsCustomDraw=kTRUE;
1009 //______________________________________________________________________________
1010 void AliTPCCalibViewerGUItime::DoCustomCutsDraw()
1015 if (fIsCustomDraw) DoCustomDraw();
1017 fDrawString=GetDrawString();
1018 fIsCustomDraw=kFALSE;
1022 //______________________________________________________________________________
1023 void AliTPCCalibViewerGUItime::HandleButtonsDrawSel(Int_t id)
1026 // Draw selection button handling (x-variable)
1030 TGButton *btn = (TGButton *) gTQSender;
1031 id = btn->WidgetId();
1034 Bool_t doDraw=kFALSE;
1035 Bool_t noDraw=kFALSE;
1042 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
1044 fRadioXrun->SetState(kButtonUp);
1045 fRadioXtime->SetState(kButtonUp);
1046 fRadioXhist->SetState(kButtonDown);
1050 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXhist->GetState()==kButtonDown);
1052 fRadioXhist->SetState(kButtonUp);
1053 fRadioXtime->SetState(kButtonUp);
1054 fRadioXrun->SetState(kButtonDown);
1058 doDraw=(fRadioXhist->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
1060 fRadioXrun->SetState(kButtonUp);
1061 fRadioXhist->SetState(kButtonUp);
1062 fRadioXtime->SetState(kButtonDown);
1066 if (doDraw&&!noDraw) DoCustomCutsDraw();
1068 //______________________________________________________________________________
1069 void AliTPCCalibViewerGUItime::UpdateParName()
1072 // change parameter name
1075 Int_t par = (Int_t)(fNmbPar->GetNumber());
1077 Int_t id=fListVariables->GetSelectedEntry()->EntryId();
1078 if (fConfigParser && (*fConfigParser)(id)) parName=fConfigParser->GetData((*fConfigParser)(id),par+kParamNames);
1079 if (parName=="") parName.Form("%d",par);
1080 fLblPar->SetText(Form("Parameter: %s",parName.Data()));
1081 fDrawString=GetDrawString();
1082 fIsCustomDraw=kFALSE;
1085 //______________________________________________________________________________
1086 void AliTPCCalibViewerGUItime::UpdateParLimits()
1089 // Adjust limits for TVectorT based variables
1092 TString selectedVariableTitle="";
1094 if (!fListVariables->GetSelectedEntry()) return;
1095 selectedVariableTitle = fListVariables->GetSelectedEntry()->GetTitle();
1096 id=fListVariables->GetSelectedEntry()->EntryId();
1097 // printf("id: %d\n",id);
1098 TString selectedVariable=selectedVariableTitle;
1099 const TObject *key=(*fConfigParser)(id);
1100 if (key) selectedVariable=(*fConfigParser)(id)->GetName();
1102 if (selectedVariable.IsNull()||!selectedVariable.EndsWith(".")) {
1103 fNmbPar->SetState(kFALSE);
1104 fLblPar->SetText("Parameter: none");
1111 TBranch *branch=fTree->GetTree()->GetBranch(selectedVariable.Data());
1112 TString branchClass=branch->GetClassName();
1114 if (branchClass=="TVectorT<double>"){
1115 // branch->SetAddress(&vD);
1116 fTree->SetBranchAddress(selectedVariable.Data(),&vD);
1117 while (maxPar<2&&event<fTree->GetEntries()){
1118 fTree->GetEntry(event++);
1119 maxPar=vD->GetNrows();
1121 } else if (branchClass=="TVectorT<float>"){
1122 // branch->SetAddress(&vF);
1123 fTree->SetBranchAddress(selectedVariable.Data(),&vF);
1124 while (maxPar<2&&event<fTree->GetEntries()){
1125 fTree->GetEntry(event++);
1126 maxPar=vF->GetNrows();
1130 fNmbPar->SetState(kFALSE);
1133 // branch->ResetAddress();
1134 fTree->SetBranchAddress(selectedVariable.Data(),0x0);
1135 if (fNmbPar->GetNumMax()!=maxPar-1) fNmbPar->SetNumber(0);
1136 fNmbPar->SetLimitValues(0,maxPar-1);
1137 fNmbPar->SetState(kTRUE);
1140 //______________________________________________________________________________
1141 void AliTPCCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/)
1144 // handle mouse events in the draw canvas
1146 UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0;
1147 Double_t valx=0.,valy=0.;
1148 if (!fCurrentGraph) {
1149 fLblRunNumberVal->SetText(Form("%06u",run));
1150 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS));
1151 fLblValueXVal->SetText(Form("%.3e", valx));
1152 fLblValueYVal->SetText(Form("%.3e", valy));
1155 TVirtualPad *padsave=gPad;
1156 fCanvMain->GetCanvas()->cd();
1157 Int_t n=fValuesY.GetNrows();
1159 arr=fValuesX.GetMatrixArray();
1161 Int_t minDist=1000000;
1163 for (Int_t i=0;i<n;++i){
1164 Int_t pxp = gPad->XtoAbsPixel(gPad->XtoPad(arr[i]));
1165 Int_t pyp = gPad->YtoAbsPixel(gPad->YtoPad(fValuesY[i]));
1166 Int_t d = TMath::Nint(TMath::Sqrt(TMath::Abs(pxp-x) + TMath::Abs(pyp-y)));
1173 TTimeStamp t((Int_t)fTimeStamps[minPoint]);
1174 t.GetDate(kTRUE,0,&yy,&mm,&dd);
1175 t.GetTime(kTRUE,0,&HH,&MM,&SS);
1176 run=(UInt_t)fRunNumbers[minPoint];
1177 valx=fValuesX[minPoint];
1178 valy=fValuesY[minPoint];
1180 dd=0;mm=0;yy=0;HH=0;MM=0;SS=0;run=0;
1184 fLblRunNumberVal->SetText(Form("%06u",run));
1185 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS));
1187 fLblValueXVal->SetText(Form("%.3e", valx));
1189 if (fRadioXrun->GetState()==kButtonDown){
1190 fLblValueXVal->SetText("Run");
1191 } else if (fRadioXtime->GetState()==kButtonDown){
1192 fLblValueXVal->SetText("Time");
1195 fLblValueYVal->SetText(Form("%.3e", valy));
1198 if (event == kButton1Double ){
1201 //find closes point of current selection
1203 //______________________________________________________________________________
1204 void AliTPCCalibViewerGUItime::SetGuiTree(Int_t run)
1207 // create the AliTPCCalibViewerGUI tree for run
1208 // cache tree in directory fOutputCacheDir
1209 // retrieve file from this directory if it already exists
1213 //Create and set GUI tree
1215 //try to find file for run in fOutputCacheDir
1216 TString fileName=fOutputCacheDir;
1217 if (!fileName.EndsWith("/")) fileName+="/";
1218 fileName+=Form("guiTreeRun_%d.root",run);
1220 if (gSystem->AccessPathName(fileName.Data())){
1221 load=AliTPCcalibDB::CreateGUITree(run,fileName.Data());
1223 fCalibViewerGUI->Reset();
1224 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX")));
1228 fCalibViewerGUI->Initialize(fileName.Data());
1229 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run)));
1232 //Create and set Reference GUI tree
1234 AliTPCcalibDButil util;
1235 util.SetReferenceRun(run);
1236 fileName=fOutputCacheDir;
1237 if (!fileName.EndsWith("/")) fileName+="/";
1238 fileName+=util.GetGUIRefTreeDefaultName();
1239 //only update if file does not exist
1240 if (gSystem->AccessPathName(fileName.Data())){
1241 util.UpdateRefDataFromOCDB();
1242 util.CreateGUIRefTree(fileName.Data());
1245 fCalibViewerGUI->GetViewer()->AddReferenceTree(fileName.Data(),"calPads","Ref");
1248 // Process additional reference trees
1250 TIter nextRefTree(fMapRefTrees);
1252 //Set static reference data
1253 while ( (o=nextRefTree()) ){
1254 fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"calPads",o->GetName());
1256 fCalibViewerGUI->Reload();
1258 //______________________________________________________________________________
1259 void AliTPCCalibViewerGUItime::SubstituteUnderscores(TString &s)
1264 s.ReplaceAll("_{","|{");
1265 s.ReplaceAll("_"," ");
1266 s.ReplaceAll("|{","_{");
1269 //______________________________________________________________________________
1270 void AliTPCCalibViewerGUItime::DoNewSelectionAliases()
1276 TList *l=fTree->GetListOfAliases();
1278 TString selectedVariable="";
1279 if (!fListAliases->GetSelectedEntry()) return;
1280 selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
1281 fDrawString=selectedVariable;
1282 fIsCustomDraw=kFALSE;
1285 //______________________________________________________________________________
1286 void AliTPCCalibViewerGUItime::DoAddAlias()
1291 new AliTPCCalibViewerGUItimeAddAliasFrame(gClient->GetRoot(), fContTopBottom, 400, 200, kVerticalFrame, this);
1293 //______________________________________________________________________________
1294 void AliTPCCalibViewerGUItime::DoDelAlias()
1300 TList *l=fTree->GetListOfAliases();
1302 TString selectedVariable="";
1303 if (!fListAliases->GetSelectedEntry()) return;
1304 selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
1305 l->Remove(l->FindObject(selectedVariable.Data()));
1309 //______________________________________________________________________________
1310 void AliTPCCalibViewerGUItime::UpdateAliasList()
1315 printf("UpdateAliasList\n");
1317 TList *l=fTree->GetListOfAliases();
1321 fListAliases->RemoveAll();
1323 while( (o=nextAlias()) ){
1324 fListAliases->AddEntry(o->GetName(),id++);
1326 fListAliases->Resize(fListAliases->GetWidth()-1, fListAliases->GetHeight());
1327 fListAliases->Resize(fListAliases->GetWidth()+1, fListAliases->GetHeight());
1329 //______________________________________________________________________________
1330 TObjArray* AliTPCCalibViewerGUItime::ShowGUI(const char* fileName, const char* treeName) {
1332 // Initialize and show GUI for presentation for demonstration purposes
1333 // or for fast standalone use
1335 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1336 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1337 frmMain->SetCleanup(kDeepCleanup);
1339 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1340 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1342 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1343 TGCompositeFrame* tabCont2 = tabMain->AddTab("Detail - XXXXX");
1345 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1346 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1347 calibViewerTime->SetConfigFileName("$ALICE_ROOT/TPC/CalibMacros/calibVarDescription.txt");
1348 calibViewerTime->UseFile(fileName, treeName);
1350 AliTPCCalibViewerGUI* calibViewer = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, 0);
1351 tabCont2->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1352 calibViewerTime->SetCalibViewerGUI(calibViewer);
1353 calibViewerTime->SetCalibViewerGUItab(tabMain->GetTabTab(1));
1356 TObjArray *guiArray = new TObjArray();
1357 guiArray->Add(calibViewerTime);
1358 guiArray->Add(calibViewer);
1360 frmMain->MapSubwindows();
1362 frmMain->MapWindow();
1367 //______________________________________________________________________________
1368 TObjArray* AliTPCCalibViewerGUItime::ShowGUI(TChain *chain) {
1370 // Initialize and show GUI for presentation for demonstration purposes
1371 // or for fast standalone use
1373 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1374 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1375 frmMain->SetCleanup(kDeepCleanup);
1377 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1378 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1380 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1382 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1383 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1384 calibViewerTime->UseChain(chain);
1386 TObjArray *guiArray = new TObjArray();
1387 guiArray->Add(calibViewerTime);
1389 frmMain->MapSubwindows();
1391 frmMain->MapWindow();
1397 ////////////////////////////////////////////////////////////////////////
1401 ////////////////////////////////////////////////////////////////////////
1404 ClassImp(AliTPCCalibViewerGUItimeAddAliasFrame)
1406 AliTPCCalibViewerGUItimeAddAliasFrame::AliTPCCalibViewerGUItimeAddAliasFrame(const TGWindow *p, const TGWindow *main,
1407 UInt_t w, UInt_t h, UInt_t options,
1408 AliTPCCalibViewerGUItime *gui, TString strAlias) :
1414 fMain = new TGTransientFrame(p, main, w, h, options);
1415 fMain->Connect("CloseWindow()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
1416 fMain->DontCallClose(); // to avoid double deletions.
1418 // use hierarchical cleaning
1419 fMain->SetCleanup(kDeepCleanup);
1422 TGLayoutHints *l1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
1423 TGLayoutHints *l2 = new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX, 2, 2, 0, 5);
1424 // TGLayoutHints *l3 = new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5);
1427 TGCompositeFrame *f1 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame);
1428 fMain->AddFrame(f1, l1);
1429 TGCompositeFrame *frameName = new TGCompositeFrame(f1);
1430 TGCompositeFrame *frameFormula = new TGCompositeFrame(f1);
1431 f1->AddFrame(frameName,l2);
1432 f1->AddFrame(frameFormula,l2);
1433 TGLabel *lblTxt1 = new TGLabel(frameName, "Name:");
1434 TGLabel *lblTxt2 = new TGLabel(frameFormula, "Formula:");
1435 fTxt1 = new TGTextEntry(frameName, new TGTextBuffer(1000));
1436 fTxt2 = new TGTextEntry(frameFormula, new TGTextBuffer(1000));
1438 frameName->AddFrame(lblTxt1, l2);
1439 frameName->AddFrame(fTxt1, l2);
1440 frameFormula->AddFrame(lblTxt2, l2);
1441 frameFormula->AddFrame(fTxt2, l2);
1443 fTxt1->Resize(350, fTxt1->GetDefaultHeight());
1444 fTxt2->Resize(350, fTxt2->GetDefaultHeight());
1446 //ok and cancel buttons
1447 TGHorizontalFrame *frame = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
1449 TGTextButton *okButton = new TGTextButton(frame, "&Ok", 1);
1450 okButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoOK()");
1451 TGTextButton *cancelButton = new TGTextButton(frame, "&Cancel", 2);
1452 cancelButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
1455 frame->AddFrame(okButton, l1);
1456 frame->AddFrame(cancelButton, l1);
1458 frame->Resize(150, okButton->GetDefaultHeight());
1460 fMain->AddFrame(frame, new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1));
1463 TString aliasName, alias;
1464 if (!strAlias.IsNull()){
1465 TChain *c=fGUI->GetChain();
1467 TList *l=c->GetListOfAliases();
1469 TNamed *d=(TNamed*)l->FindObject(strAlias);
1471 aliasName=d->GetName();
1472 alias=d->GetTitle();
1477 alias=fGUI->GetCustomDrawString();
1479 fTxt1->SetText(aliasName.Data(),kFALSE);
1480 fTxt2->SetText(alias.Data(),kFALSE);
1482 fMain->MapSubwindows();
1485 // position relative to the parent's window
1486 fMain->CenterOnParent();
1488 fMain->SetWindowName("Alias Editor");
1493 //______________________________________________________________________________
1494 AliTPCCalibViewerGUItimeAddAliasFrame::~AliTPCCalibViewerGUItimeAddAliasFrame()
1499 fMain->DeleteWindow(); // deletes fMain
1501 //______________________________________________________________________________
1502 void AliTPCCalibViewerGUItimeAddAliasFrame::DoOK()
1507 TString aliasName=fTxt1->GetText();
1508 TString alias=fTxt2->GetText();
1509 if (!aliasName.IsNull()&&!alias.IsNull()){
1510 TChain *c=fGUI->GetChain();
1512 c->SetAlias(aliasName.Data(),alias.Data());
1515 fGUI->UpdateAliasList();
1518 //______________________________________________________________________________
1519 void AliTPCCalibViewerGUItimeAddAliasFrame::DoCancel()