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 "AliTPCConfigParser.h"
71 #include "AliTPCCalibViewerGUItime.h"
73 ClassImp(AliTPCCalibViewerGUItime)
75 AliTPCCalibViewerGUItime::AliTPCCalibViewerGUItime(const TGWindow *p, UInt_t w, UInt_t h) :
76 TGCompositeFrame(p,w,h),
80 fCalibViewerGUItab(0x0),
83 fCurrentRunDetails(-1),
84 fOutputCacheDir("/tmp"),
87 fConfigParser(new AliTPCConfigParser),
88 fIsCustomDraw(kFALSE),
94 fGraphLimitEntries(10000),
95 fMapRefTrees(new TMap),
97 //main canvas Top part, bottom part
99 //top left, centre, right
104 fChkDrawOptSame(0x0),
105 fComboAddDrawOpt(0x0),
107 fContDrawSelSubRunTime(0x0),
128 fLblRunNumberVal(0x0),
137 fContCustomCuts(0x0),
140 fComboCustomDraw(0x0),
141 fComboCustomCuts(0x0),
142 fTrashBox(new TObjArray)
147 fMapRefTrees->SetOwnerKeyValue();
148 fTrashBox->SetOwner();
150 gStyle->SetMarkerStyle(20);
151 gStyle->SetMarkerSize(0.5);
154 //______________________________________________________________________________
155 AliTPCCalibViewerGUItime::~AliTPCCalibViewerGUItime(){
159 delete fConfigParser;
163 //______________________________________________________________________________
164 void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) {
168 // ======================================================================
169 // ************************* Display everything *************************
170 // ======================================================================
172 SetCleanup(kDeepCleanup);
174 // *****************************************************************************
175 // ************************* content of this MainFrame *************************
176 // *****************************************************************************
177 // top level container with horizontal layout
178 fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
179 AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
181 fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
182 fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
184 // ***********************************************************************
185 // ************************* content of fContLCR *************************
186 // ***********************************************************************
188 fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
189 fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
191 // left vertical splitter
192 TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
193 splitLeft->SetFrame(fContLeft, kTRUE);
194 fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
197 fContRight = new TGCompositeFrame(fContLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight);
198 fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
201 fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
202 fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
204 // right vertical splitter
205 TGVSplitter *splitRight = new TGVSplitter(fContLCR);
206 splitRight->SetFrame(fContRight, kFALSE);
207 fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
210 // ========================================================================
211 // ************************* content of fContLeft *************************
212 // ========================================================================
213 // --- draw button and tabLeft ---
215 fContDrawOpt = new TGGroupFrame(fContLeft, "Draw options", kVerticalFrame | kFitWidth | kFitHeight);
216 fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
217 fChkDrawOptSame = new TGCheckButton(fContDrawOpt, "Same");
218 fContDrawOpt->AddFrame(fChkDrawOptSame, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
219 fChkDrawOptSame->SetToolTipText("Add draw option 'same'");
220 // additional draw options combo box
221 fComboAddDrawOpt = new TGComboBox(fContDrawOpt);
222 fComboAddDrawOpt->Resize(0, 22);
223 fComboAddDrawOpt->EnableTextInput(kTRUE);
224 fContDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
225 // fComboAddDrawOpt->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral(=14)");
226 // fComboAddDrawOpt->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
228 // draw selection group
229 fContDrawSel = new TGGroupFrame(fContLeft, "Draw selection", kVerticalFrame | kFitWidth | kFitHeight);
230 fContLeft->AddFrame(fContDrawSel, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
231 //x-axis variables selection, Run of Time
232 fContDrawSelSubRunTime = new TGCompositeFrame(fContDrawSel, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
233 fContDrawSel->AddFrame(fContDrawSelSubRunTime, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
235 // ------------------------- content of fContDrawOpt -------------------------
239 fRadioXhist = new TGRadioButton(fContDrawSelSubRunTime, "hist", kRadioXhist);
240 fContDrawSelSubRunTime->AddFrame(fRadioXhist, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
241 fRadioXhist->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
242 fRadioXhist->SetToolTipText("Draw the distribution of the variable");
244 fRadioXrun = new TGRadioButton(fContDrawSelSubRunTime, ":Run", kRadioXrun);
245 fContDrawSelSubRunTime->AddFrame(fRadioXrun, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
246 fRadioXrun->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
247 fRadioXrun->SetToolTipText("Use run number as x-value");
250 fRadioXtime = new TGRadioButton(fContDrawSelSubRunTime, ":Time", kRadioXtime);
251 fContDrawSelSubRunTime->AddFrame(fRadioXtime, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
252 fRadioXtime->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
253 fRadioXtime->SetToolTipText("Use time stamp number as x-value");
257 fListVariables = new TGListBox(fContDrawSel);
258 fContDrawSel->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
259 fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelection()");
262 //-------------------- run type selection ------------------------
264 fLblRunType = new TGLabel(fContDrawSel, "Run Type:");
265 fLblRunType->SetTextJustify(kTextLeft);
266 fContDrawSel->AddFrame(fLblRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
268 fComboRunType = new TGComboBox(fContDrawSel);
269 fComboRunType->EnableTextInput(kFALSE);
270 fContDrawSel->AddFrame(fComboRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
271 fComboRunType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoDraw()");
272 // fComboRunType->SetEnabled(kFALSE);
273 fComboRunType->Resize(0, 22);
275 //-------------------- parameter selection ------------------------
277 fLblPar = new TGLabel(fContDrawSel, "Parameter:");
278 fLblPar->SetTextJustify(kTextLeft);
279 fContDrawSel->AddFrame(fLblPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
281 fNmbPar = new TGNumberEntry(fContDrawSel, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
282 fContDrawSel->AddFrame(fNmbPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
283 fNmbPar->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUItime", this, "DoParLimitChange()");
284 fNmbPar->SetState(kFALSE);
286 //-------------------- calibration type selection ------------------------
288 // draw selection group
289 fContCalibType = new TGGroupFrame(fContLeft, "Calib type selection", kVerticalFrame | kFitWidth | kFitHeight);
290 fContLeft->AddFrame(fContCalibType, new TGLayoutHints(kLHintsExpandX , 0, 0, 10, 0));
293 fListCalibType = new TGListBox(fContCalibType);
294 fContCalibType->AddFrame(fListCalibType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX , 0, 0, 0, 0));
295 fListCalibType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoChangeSelectionList()");
296 fListCalibType->Resize(0,88);
297 fListCalibType->SetMultipleSelections();
300 // ==========================================================================
301 // ************************* content of fContCenter *************************
302 // ========================================================================
303 // main drawing canvas
304 fCanvMain = new TRootEmbeddedCanvas("GUItime_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
305 fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
306 fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliTPCCalibViewerGUItime", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
307 // fCanvMain->GetCanvas()->Connect("RangeAxisChanged()", "AliTPCCalibViewerGUItime", this, "GetMinMax()");
308 fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed.");
309 fCanvMain->GetCanvas()->SetRightMargin(0.062);
310 fCanvMain->GetCanvas()->SetLeftMargin(0.15);
312 // =========================================================================
313 // ************************* content of fContRight *************************
314 // ========================================================================
315 //group frame for value information
316 fContValues = new TGGroupFrame(fContRight, "Data point info", kVerticalFrame | kFitWidth | kFitHeight);
317 fContRight->AddFrame(fContValues, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
319 fContValues->SetLayoutManager(new TGMatrixLayout(fContValues, 0, 2, 5));
320 //value information labels
323 fLblRunNumber = new TGLabel(fContValues, "Run:");
324 fLblRunNumber->SetTextJustify(kTextLeft);
325 fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
327 fLblRunNumberVal = new TGLabel(fContValues, "00000");
328 fLblRunNumberVal->SetTextJustify(kTextLeft);
329 fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
331 fLblRunTime = new TGLabel(fContValues, "Time:");
332 fLblRunTime->SetTextJustify(kTextLeft);
333 fContValues->AddFrame(fLblRunTime, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
335 fLblRunTimeVal = new TGLabel(fContValues, "00.00.0000\n00:00:00");
336 fLblRunTimeVal->SetTextJustify(kTextLeft);
337 fContValues->AddFrame(fLblRunTimeVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
339 fLblValueX = new TGLabel(fContValues, "x-Value:");
340 fLblValueX->SetTextJustify(kTextLeft);
341 fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
343 fLblValueXVal = new TGLabel(fContValues, "00.000e+00");
344 fLblValueXVal->SetTextJustify(kTextRight);
345 fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
347 fLblValueY = new TGLabel(fContValues, "y-Value:");
348 fLblValueY->SetTextJustify(kTextLeft);
349 fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
351 fLblValueYVal = new TGLabel(fContValues, "00.000e+00");
352 fLblValueYVal->SetTextJustify(kTextRight);
353 fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
355 fBtnDumpRuns = new TGTextButton(fContRight, "&Dump runs");
356 fContRight->AddFrame(fBtnDumpRuns, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
357 fBtnDumpRuns->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDumpRuns()");
358 fBtnDumpRuns->SetToolTipText("Press to dump the run numbers of the current selection.");
359 //group frame for value information
360 fContAliases = new TGGroupFrame(fContRight, "Aliases", kVerticalFrame | kFitWidth | kFitHeight);
361 fContRight->AddFrame(fContAliases, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
363 fListAliases = new TGListBox(fContAliases);
364 fContAliases->AddFrame(fListAliases, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
365 fListAliases->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelectionAliases()");
366 // fListAliases->Resize(0,88);
368 TGCompositeFrame *frame1 = new TGCompositeFrame(fContAliases, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
369 fContAliases->AddFrame(frame1, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
371 TGTextButton *btnAdd = new TGTextButton(frame1, "&Add");
372 frame1->AddFrame(btnAdd, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
373 btnAdd->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoAddAlias()");
374 btnAdd->SetToolTipText("Press to add an alias.");
375 btnAdd->Resize(0,22);
377 TGTextButton *btnDel = new TGTextButton(frame1, "&Del");
378 frame1->AddFrame(btnDel, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
379 btnDel->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDelAlias()");
380 btnDel->SetToolTipText("Press to delete the selected alias.");
381 btnDel->Resize(0,22);
383 TGTextButton *btnUp = new TGTextButton(frame1, "&Upd");
384 frame1->AddFrame(btnUp, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
385 btnUp->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "UpdateAliasList()");
386 btnUp->SetToolTipText("Press to update the alias list.");
391 // =========================================================================
392 // ****************** bottom content of fContTopBottom *********************
393 // =========================================================================
395 // custom options container
396 // --- fComboCustom --- the custom draw line on the very low
397 fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
398 fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
400 // ------------------------- content of fContCustom -------------------------
401 fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: ");
402 fLblCustomDraw->SetTextJustify(kTextLeft);
403 fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
404 // text field for custom draw command
405 fComboCustomDraw = new TGComboBox(fContCustom);
406 // fComboCustomDraw->Resize(0, fLblValueY->GetDefaultHeight());
407 fComboCustomDraw->Resize(0, 22);
408 fComboCustomDraw->EnableTextInput(kTRUE);
409 fContCustom->AddFrame(fComboCustomDraw, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
410 fComboCustomDraw->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
411 fComboCustomDraw->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
414 // additional cuts container
415 fContCustomCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
416 fContTopBottom->AddFrame(fContCustomCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
418 // ------------------------- content of fContCustomCuts -------------------------
419 fLblCustomCuts = new TGLabel(fContCustomCuts, "Custom cuts: ");
420 fLblCustomCuts->SetTextJustify(kTextLeft);
421 fContCustomCuts->AddFrame(fLblCustomCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
422 // combo text field for additional cuts
423 fComboCustomCuts = new TGComboBox(fContCustomCuts);
424 // fComboCustomCuts->Resize(0, fLblValueY->GetDefaultHeight());
425 fComboCustomCuts->Resize(0, 22);
426 fComboCustomCuts->EnableTextInput(kTRUE);
427 fContCustomCuts->AddFrame(fComboCustomCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
428 fComboCustomCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
429 fComboCustomCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
431 SetWindowName("AliTPCCalibViewer GUI - Time");
433 Resize(GetDefaultSize());
436 //______________________________________________________________________________
437 void AliTPCCalibViewerGUItime::SetInitialValues(){
439 // Set inital selections of the gui
441 fRadioXrun->SetState(kButtonDown);
442 fRadioXtime->SetState(kButtonUp);
445 //______________________________________________________________________________
446 void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeName) {
448 // retrieve tree from file
450 TString s=gSystem->GetFromPipe(Form("ls %s",fileName));
451 // TString s(fileName);
452 TObjArray *arr=s.Tokenize("\n");
455 if (fTree) delete fTree;
456 fTree=new TChain(treeName);
457 while ( (o=next()) ){
458 fTree->AddFile(o->GetName());
461 if (!CheckChain()) return;
462 UseConfigFile(fConfigFile.Data());
466 //______________________________________________________________________________
467 void AliTPCCalibViewerGUItime::UseChain(TChain* chain = 0)
473 if (!CheckChain()) return;
474 //set configuration file
475 UseConfigFile(fConfigFile.Data());
478 //______________________________________________________________________________
479 Bool_t AliTPCCalibViewerGUItime::CheckChain()
482 // check whether cahin has entries
483 // decide whether to draw graphs in 2D
485 if (!fTree) return kFALSE;
487 Long64_t entries=fTree->GetEntries();
489 AliError("No entries found in chain");
492 //check whether to draw graphs
496 //______________________________________________________________________________
497 void AliTPCCalibViewerGUItime::UseConfigFile(const char* file)
500 // Use 'file' as configuration file
503 fConfigParser->ParseConfigFileTxt(fConfigFile.Data());
506 //______________________________________________________________________________
507 void AliTPCCalibViewerGUItime::FillRunTypes()
510 //Loop over the tree entries and fill the run types
514 fComboRunType->RemoveAll();
515 fComboRunType->AddEntry("ALL",id++);
516 fComboRunType->Select(0,kFALSE);
517 if (!fTree->GetBranch("runType.")) return;
518 TObjString *runType=0x0;
519 Int_t nevets=fTree->GetEntries();
520 fTree->SetBranchStatus("*",0);
521 fTree->SetBranchStatus("runType.*",1);
522 fTree->SetBranchAddress("runType.",&runType);
523 for (Int_t iev=0;iev<nevets;++iev){
524 fTree->GetEntry(iev);
525 TString type=runType->String();
526 if (!type.IsNull()&&!fComboRunType->FindEntry(type)) fComboRunType->AddEntry(type,id++);
528 fTree->ResetBranchAddresses();
529 fTree->SetBranchStatus("*",1);
531 //______________________________________________________________________________
532 void AliTPCCalibViewerGUItime::FillCalibTypes()
535 // loop over configuration and fill calibration types
538 fListCalibType->RemoveAll();
540 fConfigParser->ResetIter();
542 while ( (o=fConfigParser->NextKey()) ){
543 type=fConfigParser->GetData(o,kCalibType);
544 //remove whitespcaces
545 type.Remove(TString::kBoth,' ');
546 type.Remove(TString::kBoth,'\t');
547 if (type.IsNull()) type="UNSPECIFIED";
548 // printf("CalibType: '%s'\n",type.Data());
549 if (!fListCalibType->FindEntry(type.Data())) {
550 fListCalibType->AddEntry(type,id);
551 fListCalibType->Select(id++);
554 //add type for unspecified calibration type
556 if (!fListCalibType->FindEntry(type.Data())) {
557 fListCalibType->AddEntry(SubstituteUnderscores(type.Data()),id);
558 fListCalibType->Select(id++);
561 //______________________________________________________________________________
562 void AliTPCCalibViewerGUItime::CheckDrawGraph()
565 // Check whether to draw graphs in 2D mode based on the number of entries in the chain
566 // GetEstimate() returns the maximum size of the arrays stored in GetV1()...
570 if (fTree->GetEntries()<fTree->GetEstimate()) fNoGraph=kFALSE;
572 //______________________________________________________________________________
573 void AliTPCCalibViewerGUItime::Reload(Int_t first)
576 // reload the gui contents, this is needed after the input tree has changed
579 if ( !fTree ) return;
580 //in case of the first call create run type and calibration type entries
585 //activate all branches
586 fTree->SetBranchStatus("*",1);
587 //reset variables list
588 fListVariables->RemoveAll();
589 //get selected calibration types
591 fListCalibType->GetSelectedEntries(&calibTypes);
593 TObjArray *branchList = fTree->GetListOfBranches();
594 if ( !branchList ) return;
595 TIter nextBranch(branchList);
596 Int_t idCount=0,id=0;
597 TObject *objBranch=0;
598 while ( (objBranch=nextBranch()) ){
599 TString branchName(objBranch->GetName());
600 TString branchTitle(objBranch->GetName());
601 if (branchName == "run" || branchName == "time" || branchName == "runType.") continue;
603 TString calibType="UNSPECIFIED";
605 const TObject *key=(*fConfigParser)(branchName.Data());
607 //test if branch is active
608 active=fConfigParser->GetValue(branchName.Data(),kBranchOnOff);
609 id=(*fConfigParser)()->IndexOf(key);
610 // branchTitle=fConfigParser->GetData(key,kBranchTitle);
611 calibType=fConfigParser->GetData(key,kCalibType);
619 if (calibType.IsNull()) calibType="UNSPECIFIED";
620 //check if branch is in selected calibration types
621 //if not, don't show it in the list and deactivate the branch.
622 Bool_t calibActive=kFALSE;
623 TIter nextCalib(&calibTypes);
625 while ( (objCalib=nextCalib()) )
626 if (calibType==objCalib->GetTitle()) calibActive=kTRUE;
629 TString s=branchName;
630 if (branchName.EndsWith(".")) s+="*";
631 fTree->SetBranchStatus(s.Data(),0);
634 // fListVariables->AddEntry(SubstituteUnderscores(branchTitle.Data()),id);
635 fListVariables->AddEntry(branchTitle.Data(),id);
638 //trick to display modifications
639 fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight());
640 fListVariables->Resize(fListVariables->GetWidth()+1, fListVariables->GetHeight());
642 //______________________________________________________________________________
643 void AliTPCCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const char* refName)
646 // map of reference trees that should always be attached to the CalibViewerGUI
648 fMapRefTrees->Add(new TObjString(refName), new TObjString(treeFileName));
651 //______________________________________________________________________________
652 const char* AliTPCCalibViewerGUItime::GetDrawString(){
654 // create draw string for ttree by combining the user requestsa
657 TString selectedVariable="";
659 if (!fListVariables->GetSelectedEntry()) return "";
660 selectedVariable = fListVariables->GetSelectedEntry()->GetTitle();
661 id=fListVariables->GetSelectedEntry()->EntryId();
662 // printf("id: %d\n",id);
663 TString branchName=selectedVariable;
664 const TObject *key=(*fConfigParser)(id);
665 if (key) branchName=(*fConfigParser)(id)->GetName();
666 //treat case of TVector
667 if (branchName.EndsWith(".")){
668 Int_t par = (Int_t)(fNmbPar->GetNumber());
669 branchName.Append(Form("fElements[%d]",par));
671 // if (fRadioXrun->GetState()==kButtonDown)
672 // selectedVariable.Append(":run");
673 // if (fRadioXtime->GetState()==kButtonDown)
674 // selectedVariable.Append(":time");
676 return branchName.Data();
678 //______________________________________________________________________________
679 const char* AliTPCCalibViewerGUItime::GetDrawOptionString(){
681 // get user selected draw options
684 if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle();
685 if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase))
687 return drawOpt.Data();
689 //______________________________________________________________________________
690 void AliTPCCalibViewerGUItime::GetCutString(TString &cutStr){
694 TCut cuts(fComboCustomCuts->GetTextEntry()->GetText());
696 if (fComboRunType->GetSelectedEntry()) runType=fComboRunType->GetSelectedEntry()->GetTitle();
697 if (runType!="ALL"&&!runType.IsNull()) cuts+=Form("runType.String().Data()==\"%s\"",runType.Data());
698 cutStr=cuts.GetTitle();
700 //______________________________________________________________________________
701 void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph)
707 fValuesX.ResizeTo(1);
708 fValuesY.ResizeTo(1);
709 fRunNumbers.ResizeTo(1);
710 fTimeStamps.ResizeTo(1);
712 fValuesX.ResizeTo(fTree->GetSelectedRows());
713 fValuesY.ResizeTo(fTree->GetSelectedRows());
714 fRunNumbers.ResizeTo(fTree->GetSelectedRows());
715 fTimeStamps.ResizeTo(fTree->GetSelectedRows());
716 fValuesY.SetElements(fTree->GetV3());
717 fRunNumbers.SetElements(fTree->GetV1());
718 fTimeStamps.SetElements(fTree->GetV2());
721 //______________________________________________________________________________
722 void AliTPCCalibViewerGUItime::GetHistogramTitle(TString &title)
725 // Create string for histogram title
729 Int_t pos=title.First(">>");
730 if (pos>0) title=title(0,pos);
731 // if (!fIsCustomDraw){
732 if (fRadioXrun->GetState()==kButtonDown){
734 } else if (fRadioXtime->GetState()==kButtonDown){
740 TObjArray *arr=title.Tokenize(":");
745 TIter next(arr,kIterBackward);
746 while ( (o=next()) ){
747 TString varName=o->GetName();
749 //substitue variable names with names in configuration file if available
750 if ((*fConfigParser)()->GetEntries()){
751 TString branchName=varName;
753 if (branchName.Contains('.')) branchName=branchName(0,branchName.First('.')+1);
754 //chek if a configuration for that branch is available
755 const TObject *oBranch=(*fConfigParser)(branchName.Data());
757 TString branchTitle=fConfigParser->GetData(oBranch,kBranchTitle);
758 if (!branchTitle.IsNull()){
759 //check for TVectorT type branch
760 //add parameter name if available
761 if (varName.Contains("fElements")){
762 TString parStr=varName(varName.First('[')+1,varName.Length()-varName.First('[')-2);
765 TString yparname=fConfigParser->GetData(oBranch,par+kParamNames);
766 if (!yparname.IsNull()){
767 branchTitle+=yparname;
775 varName=SubstituteUnderscores(branchTitle.Data());
782 //______________________________________________________________________________
783 void AliTPCCalibViewerGUItime::AdjustYRange()
788 TIter nextGraphicObject(fTrashBox);
791 while ( (o=nextGraphicObject()) ){
792 if (o->IsA()==TGraph::Class()){
793 TGraph *gr=(TGraph*)o;
795 min=TMath::MinElement(gr->GetN(),gr->GetY());
796 max=TMath::MaxElement(gr->GetN(),gr->GetY());
798 Float_t currmin=TMath::MinElement(gr->GetN(),gr->GetY());
799 Float_t currmax=TMath::MaxElement(gr->GetN(),gr->GetY());
800 if (currmax>max) max=currmax;
801 if (currmin<min) min=currmin;
806 if (min!=0) min=min-(max-min)/10;
807 if (max!=0) max=max+(max-min)/10;
808 fCurrentHist->SetMinimum(min);
809 fCurrentHist->SetMaximum(max);
812 //______________________________________________________________________________
813 void AliTPCCalibViewerGUItime::DoDraw() {
817 TString drawString=fDrawString;
819 GetCutString(cutString);
820 TString optString = GetDrawOptionString();
821 Bool_t graphOutput=!fNoGraph; //ttree buffer for V1, V2... too small
822 graphOutput&=(drawString.First(">>")<0); //histogram output in custom draw
823 graphOutput&=fRadioXhist->GetState()!=kButtonDown; //histogram drawing selected
824 // graphOutput&=!(fIsCustomDraw&&!fDrawString.Contains(":")); //custom draw 1D
825 // graphOutput&=fDrawString.CountChar(':')<2; //custom draw 1D
826 if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
827 if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
828 Bool_t drawSame=optString.Contains("same",TString::kIgnoreCase);
829 // optString+="goff";
831 drawString.Prepend("run:time:");
834 // if (!fIsCustomDraw){
835 if (fRadioXrun->GetState()==kButtonDown){
837 } else if (fRadioXtime->GetState()==kButtonDown){
842 TVirtualPad *padsave=gPad;
843 fCanvMain->GetCanvas()->cd();
844 //delete old histograms and graphs
851 fTree->Draw(drawString.Data(),cutString.Data(),optString.Data());
852 if (fTree->GetSelectedRows()==-1) return;
853 UpdateValueArrays(graphOutput);
855 GetHistogramTitle(title);
856 Bool_t drawGraph=kFALSE;
859 if (fIsCustomDraw&&fDrawString.Contains(":")){
860 fValuesX.SetElements(fTree->GetV4());
862 if (fRadioXrun->GetState()==kButtonDown){
863 fValuesX.SetElements(fTree->GetV1());
864 } else if (fRadioXtime->GetState()==kButtonDown){
865 fValuesX.SetElements(fTree->GetV2());
872 // if (fIsCustomDraw){
873 // if (fDrawString.Contains(":")){
874 // fValuesX.SetElements(fTree->GetV4());
881 // if (fRadioXrun->GetState()==kButtonDown){
882 // fValuesX.SetElements(fTree->GetV1());
883 // } else if (fRadioXtime->GetState()==kButtonDown){
884 // fValuesX.SetElements(fTree->GetV2());
890 //create graph according to selection
892 TGraph *graph=new TGraph(fValuesX,fValuesY);
894 if (!drawSame) grDraw+="a";
895 if (!fIsCustomDraw) grDraw+="l";
896 graph->Draw(grDraw.Data());
897 graph->SetEditable(kFALSE);
898 TH1 *hist=graph->GetHistogram();
899 hist->SetTitle(title.Data());
900 fTrashBox->Add(graph);
901 graph->SetLineColor(fTrashBox->GetEntries());
902 graph->SetMarkerColor(fTrashBox->GetEntries());
908 TH1 *hist=fTree->GetHistogram();
909 hist->SetTitle(title.Data());
910 // hist->Draw(optString.Data());
911 fTrashBox->Add(hist);
912 hist->SetLineColor(fTrashBox->GetEntries());
913 hist->SetMarkerColor(fTrashBox->GetEntries());
914 if (!drawSame) fCurrentHist=hist;
917 //Set time axis if choosen as x-variables
918 // if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw&&!drawSame){
919 if (fRadioXtime->GetState()==kButtonDown&&!drawSame){
920 TAxis *xaxis=fCurrentHist->GetXaxis();
921 xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}");
922 xaxis->SetTimeDisplay(1);
923 xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3);
924 xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3);
928 fCurrentHist->GetYaxis()->SetTitleOffset(1.5);
938 //______________________________________________________________________________
939 void AliTPCCalibViewerGUItime::DoDumpRuns()
942 // Dump the current run numbers to stdout
944 Int_t npoints=fRunNumbers.GetNrows();
945 Int_t *sortIndex = new Int_t[npoints];
946 TMath::Sort(npoints,fRunNumbers.GetMatrixArray(),sortIndex,kFALSE);
947 Int_t run=0, prevRun=-1;
949 for (Int_t irun=0;irun<npoints;++irun){
950 run=(Int_t)fRunNumbers.GetMatrixArray()[sortIndex[irun]];
951 if (run!=prevRun) std::cout << Form("%d",run) << std::endl;
956 //______________________________________________________________________________
957 void AliTPCCalibViewerGUItime::DoParLimitChange()
965 //______________________________________________________________________________
966 void AliTPCCalibViewerGUItime::DoNewSelection() {
968 // decides whether to redraw if user makes another selection
971 fDrawString=GetDrawString();
972 fIsCustomDraw=kFALSE;
975 //______________________________________________________________________________
976 void AliTPCCalibViewerGUItime::DoCustomDraw()
981 fDrawString=fComboCustomDraw->GetTextEntry()->GetText();
982 // if (fDrawString.Contains(">>")){
983 // Warning("DoCustomDraw","Currently no user defined histograms allowed!");
986 fNmbPar->SetState(kFALSE);
990 //______________________________________________________________________________
991 void AliTPCCalibViewerGUItime::DoCustomCutsDraw()
996 if (fIsCustomDraw) DoCustomDraw();
998 fDrawString=GetDrawString();
999 fIsCustomDraw=kFALSE;
1003 //______________________________________________________________________________
1004 void AliTPCCalibViewerGUItime::HandleButtonsDrawSel(Int_t id)
1007 // Draw selection button handling (x-variable)
1011 TGButton *btn = (TGButton *) gTQSender;
1012 id = btn->WidgetId();
1015 Bool_t doDraw=kFALSE;
1016 Bool_t noDraw=kFALSE;
1023 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
1025 fRadioXrun->SetState(kButtonUp);
1026 fRadioXtime->SetState(kButtonUp);
1027 fRadioXhist->SetState(kButtonDown);
1031 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXhist->GetState()==kButtonDown);
1033 fRadioXhist->SetState(kButtonUp);
1034 fRadioXtime->SetState(kButtonUp);
1035 fRadioXrun->SetState(kButtonDown);
1039 doDraw=(fRadioXhist->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
1041 fRadioXrun->SetState(kButtonUp);
1042 fRadioXhist->SetState(kButtonUp);
1043 fRadioXtime->SetState(kButtonDown);
1047 if (doDraw&&!noDraw) DoCustomCutsDraw();
1049 //______________________________________________________________________________
1050 void AliTPCCalibViewerGUItime::UpdateParName()
1053 // change parameter name
1056 Int_t par = (Int_t)(fNmbPar->GetNumber());
1058 Int_t id=fListVariables->GetSelectedEntry()->EntryId();
1059 if (fConfigParser && (*fConfigParser)(id)) parName=fConfigParser->GetData((*fConfigParser)(id),par+kParamNames);
1060 if (parName=="") parName.Form("%d",par);
1061 fLblPar->SetText(Form("Parameter: %s",parName.Data()));
1062 fDrawString=GetDrawString();
1063 fIsCustomDraw=kFALSE;
1066 //______________________________________________________________________________
1067 void AliTPCCalibViewerGUItime::UpdateParLimits()
1070 // Adjust limits for TVectorT based variables
1073 TString selectedVariableTitle="";
1075 if (!fListVariables->GetSelectedEntry()) return;
1076 selectedVariableTitle = fListVariables->GetSelectedEntry()->GetTitle();
1077 id=fListVariables->GetSelectedEntry()->EntryId();
1078 // printf("id: %d\n",id);
1079 TString selectedVariable=selectedVariableTitle;
1080 const TObject *key=(*fConfigParser)(id);
1081 if (key) selectedVariable=(*fConfigParser)(id)->GetName();
1083 if (selectedVariable.IsNull()||!selectedVariable.EndsWith(".")) {
1084 fNmbPar->SetState(kFALSE);
1085 fLblPar->SetText("Parameter: none");
1092 TBranch *branch=fTree->GetTree()->GetBranch(selectedVariable.Data());
1093 TString branchClass=branch->GetClassName();
1095 if (branchClass=="TVectorT<double>"){
1096 // branch->SetAddress(&vD);
1097 fTree->SetBranchAddress(selectedVariable.Data(),&vD);
1098 while (maxPar<2&&event<fTree->GetEntries()){
1099 fTree->GetEntry(event++);
1100 maxPar=vD->GetNrows();
1102 } else if (branchClass=="TVectorT<float>"){
1103 // branch->SetAddress(&vF);
1104 fTree->SetBranchAddress(selectedVariable.Data(),&vF);
1105 while (maxPar<2&&event<fTree->GetEntries()){
1106 fTree->GetEntry(event++);
1107 maxPar=vF->GetNrows();
1111 fNmbPar->SetState(kFALSE);
1114 // branch->ResetAddress();
1115 fTree->SetBranchAddress(selectedVariable.Data(),0x0);
1116 if (fNmbPar->GetNumMax()!=maxPar-1) fNmbPar->SetNumber(0);
1117 fNmbPar->SetLimitValues(0,maxPar-1);
1118 fNmbPar->SetState(kTRUE);
1121 //______________________________________________________________________________
1122 void AliTPCCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/)
1125 // handle mouse events in the draw canvas
1127 UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0;
1128 Double_t valx=0.,valy=0.;
1129 if (!fCurrentGraph) {
1130 fLblRunNumberVal->SetText(Form("%05u",run));
1131 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS));
1132 fLblValueXVal->SetText(Form("%.3e", valx));
1133 fLblValueYVal->SetText(Form("%.3e", valy));
1136 TVirtualPad *padsave=gPad;
1137 fCanvMain->GetCanvas()->cd();
1138 Int_t n=fValuesY.GetNrows();
1140 arr=fValuesX.GetMatrixArray();
1142 Int_t minDist=1000000;
1144 for (Int_t i=0;i<n;++i){
1145 Int_t pxp = gPad->XtoAbsPixel(gPad->XtoPad(arr[i]));
1146 Int_t pyp = gPad->YtoAbsPixel(gPad->YtoPad(fValuesY[i]));
1147 Int_t d = TMath::Nint(TMath::Sqrt(TMath::Abs(pxp-x) + TMath::Abs(pyp-y)));
1154 TTimeStamp t((Int_t)fTimeStamps[minPoint]);
1155 t.GetDate(kTRUE,0,&yy,&mm,&dd);
1156 t.GetTime(kTRUE,0,&HH,&MM,&SS);
1157 run=(UInt_t)fRunNumbers[minPoint];
1158 valx=fValuesX[minPoint];
1159 valy=fValuesY[minPoint];
1161 dd=0;mm=0;yy=0;HH=0;MM=0;SS=0;run=0;
1165 fLblRunNumberVal->SetText(Form("%05u",run));
1166 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS));
1168 fLblValueXVal->SetText(Form("%.3e", valx));
1170 if (fRadioXrun->GetState()==kButtonDown){
1171 fLblValueXVal->SetText("Run");
1172 } else if (fRadioXtime->GetState()==kButtonDown){
1173 fLblValueXVal->SetText("Time");
1176 fLblValueYVal->SetText(Form("%.3e", valy));
1179 if (event == kButton1Double ){
1182 //find closes point of current selection
1184 //______________________________________________________________________________
1185 void AliTPCCalibViewerGUItime::SetGuiTree(Int_t run)
1188 // create the AliTPCCalibViewerGUI tree for run
1189 // cache tree in directory fOutputCacheDir
1190 // retrieve file from this directory if it already exists
1193 //try to find file for run in fOutputCacheDir
1194 TString fileName=fOutputCacheDir;
1195 if (!fileName.EndsWith("/")) fileName+="/";
1196 fileName+=Form("guiTreeRun_%d.root",run);
1198 TFile f(fileName.Data());
1200 load=AliTPCcalibDB::CreateGUITree(run,fileName.Data());
1202 fCalibViewerGUI->Reset();
1203 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX")));
1208 fCalibViewerGUI->Initialize(fileName.Data());
1209 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run)));
1210 TIter nextRefTree(fMapRefTrees);
1212 while ( (o=nextRefTree()) ){
1213 fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"calPads",o->GetName());
1215 fCalibViewerGUI->Reload();
1217 //______________________________________________________________________________
1218 const char* AliTPCCalibViewerGUItime::SubstituteUnderscores(const char* in)
1224 s.ReplaceAll("_{","|{");
1225 s.ReplaceAll("_"," ");
1226 s.ReplaceAll("|{","_{");
1230 //______________________________________________________________________________
1231 void AliTPCCalibViewerGUItime::DoNewSelectionAliases()
1237 TList *l=fTree->GetListOfAliases();
1239 TString selectedVariable="";
1240 if (!fListAliases->GetSelectedEntry()) return;
1241 selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
1242 fDrawString=selectedVariable;
1243 fIsCustomDraw=kFALSE;
1246 //______________________________________________________________________________
1247 void AliTPCCalibViewerGUItime::DoAddAlias()
1252 new AliTPCCalibViewerGUItimeAddAliasFrame(gClient->GetRoot(), fContTopBottom, 400, 200, kVerticalFrame, this);
1254 //______________________________________________________________________________
1255 void AliTPCCalibViewerGUItime::DoDelAlias()
1261 TList *l=fTree->GetListOfAliases();
1263 TString selectedVariable="";
1264 if (!fListAliases->GetSelectedEntry()) return;
1265 selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
1266 l->Remove(l->FindObject(selectedVariable.Data()));
1270 //______________________________________________________________________________
1271 void AliTPCCalibViewerGUItime::UpdateAliasList()
1276 printf("UpdateAliasList\n");
1278 TList *l=fTree->GetListOfAliases();
1282 fListAliases->RemoveAll();
1284 while( (o=nextAlias()) ){
1285 fListAliases->AddEntry(o->GetName(),id++);
1287 fListAliases->Resize(fListAliases->GetWidth()-1, fListAliases->GetHeight());
1288 fListAliases->Resize(fListAliases->GetWidth()+1, fListAliases->GetHeight());
1290 //______________________________________________________________________________
1291 TObjArray* AliTPCCalibViewerGUItime::ShowGUI(const char* fileName, const char* treeName) {
1293 // Initialize and show GUI for presentation for demonstration purposes
1294 // or for fast standalone use
1296 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1297 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1298 frmMain->SetCleanup(kDeepCleanup);
1300 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1301 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1303 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1304 TGCompositeFrame* tabCont2 = tabMain->AddTab("Detail - XXXXX");
1306 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1307 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1308 calibViewerTime->SetConfigFileName("$ALICE_ROOT/TPC/CalibMacros/calibVarDescription.txt");
1309 calibViewerTime->UseFile(fileName, treeName);
1311 AliTPCCalibViewerGUI* calibViewer = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, 0);
1312 tabCont2->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1313 calibViewerTime->SetCalibViewerGUI(calibViewer);
1314 calibViewerTime->SetCalibViewerGUItab(tabMain->GetTabTab(1));
1317 TObjArray *guiArray = new TObjArray();
1318 guiArray->Add(calibViewerTime);
1319 guiArray->Add(calibViewer);
1321 frmMain->MapSubwindows();
1323 frmMain->MapWindow();
1328 //______________________________________________________________________________
1329 TObjArray* AliTPCCalibViewerGUItime::ShowGUI(TChain *chain) {
1331 // Initialize and show GUI for presentation for demonstration purposes
1332 // or for fast standalone use
1334 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1335 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1336 frmMain->SetCleanup(kDeepCleanup);
1338 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1339 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1341 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1343 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1344 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1345 calibViewerTime->UseChain(chain);
1347 TObjArray *guiArray = new TObjArray();
1348 guiArray->Add(calibViewerTime);
1350 frmMain->MapSubwindows();
1352 frmMain->MapWindow();
1358 ////////////////////////////////////////////////////////////////////////
1362 ////////////////////////////////////////////////////////////////////////
1365 ClassImp(AliTPCCalibViewerGUItimeAddAliasFrame)
1367 AliTPCCalibViewerGUItimeAddAliasFrame::AliTPCCalibViewerGUItimeAddAliasFrame(const TGWindow *p, const TGWindow *main,
1368 UInt_t w, UInt_t h, UInt_t options,
1369 AliTPCCalibViewerGUItime *gui, TString strAlias) :
1375 fMain = new TGTransientFrame(p, main, w, h, options);
1376 fMain->Connect("CloseWindow()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
1377 fMain->DontCallClose(); // to avoid double deletions.
1379 // use hierarchical cleaning
1380 fMain->SetCleanup(kDeepCleanup);
1383 TGLayoutHints *l1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
1384 TGLayoutHints *l2 = new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX, 2, 2, 0, 5);
1385 // TGLayoutHints *l3 = new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5);
1388 TGCompositeFrame *f1 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame);
1389 fMain->AddFrame(f1, l1);
1390 TGCompositeFrame *frameName = new TGCompositeFrame(f1);
1391 TGCompositeFrame *frameFormula = new TGCompositeFrame(f1);
1392 f1->AddFrame(frameName,l2);
1393 f1->AddFrame(frameFormula,l2);
1394 TGLabel *lblTxt1 = new TGLabel(frameName, "Name:");
1395 TGLabel *lblTxt2 = new TGLabel(frameFormula, "Formula:");
1396 fTxt1 = new TGTextEntry(frameName, new TGTextBuffer(1000));
1397 fTxt2 = new TGTextEntry(frameFormula, new TGTextBuffer(1000));
1399 frameName->AddFrame(lblTxt1, l2);
1400 frameName->AddFrame(fTxt1, l2);
1401 frameFormula->AddFrame(lblTxt2, l2);
1402 frameFormula->AddFrame(fTxt2, l2);
1404 fTxt1->Resize(350, fTxt1->GetDefaultHeight());
1405 fTxt2->Resize(350, fTxt2->GetDefaultHeight());
1407 //ok and cancel buttons
1408 TGHorizontalFrame *frame = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
1410 TGTextButton *okButton = new TGTextButton(frame, "&Ok", 1);
1411 okButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoOK()");
1412 TGTextButton *cancelButton = new TGTextButton(frame, "&Cancel", 2);
1413 cancelButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
1416 frame->AddFrame(okButton, l1);
1417 frame->AddFrame(cancelButton, l1);
1419 frame->Resize(150, okButton->GetDefaultHeight());
1421 fMain->AddFrame(frame, new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1));
1424 TString aliasName, alias;
1425 if (!strAlias.IsNull()){
1426 TChain *c=fGUI->GetChain();
1428 TList *l=c->GetListOfAliases();
1430 TNamed *d=(TNamed*)l->FindObject(strAlias);
1432 aliasName=d->GetName();
1433 alias=d->GetTitle();
1438 alias=fGUI->GetCustomDrawString();
1440 fTxt1->SetText(aliasName.Data(),kFALSE);
1441 fTxt2->SetText(alias.Data(),kFALSE);
1443 fMain->MapSubwindows();
1446 // position relative to the parent's window
1447 fMain->CenterOnParent();
1449 fMain->SetWindowName("Alias Editor");
1454 //______________________________________________________________________________
1455 AliTPCCalibViewerGUItimeAddAliasFrame::~AliTPCCalibViewerGUItimeAddAliasFrame()
1460 fMain->DeleteWindow(); // deletes fMain
1462 //______________________________________________________________________________
1463 void AliTPCCalibViewerGUItimeAddAliasFrame::DoOK()
1468 TString aliasName=fTxt1->GetText();
1469 TString alias=fTxt2->GetText();
1470 if (!aliasName.IsNull()&&!alias.IsNull()){
1471 TChain *c=fGUI->GetChain();
1473 c->SetAlias(aliasName.Data(),alias.Data());
1476 fGUI->UpdateAliasList();
1479 //______________________________________________________________________________
1480 void AliTPCCalibViewerGUItimeAddAliasFrame::DoCancel()