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()");
229 // draw selection group
230 fContDrawSel = new TGGroupFrame(fContLeft, "Draw selection", kVerticalFrame | kFitWidth | kFitHeight);
231 fContLeft->AddFrame(fContDrawSel, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
232 //x-axis variables selection, Run of Time
233 fContDrawSelSubRunTime = new TGCompositeFrame(fContDrawSel, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
234 fContDrawSel->AddFrame(fContDrawSelSubRunTime, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
236 // ------------------------- content of fContDrawOpt -------------------------
240 fRadioXhist = new TGRadioButton(fContDrawSelSubRunTime, "hist", kRadioXhist);
241 fContDrawSelSubRunTime->AddFrame(fRadioXhist, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
242 fRadioXhist->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
243 fRadioXhist->SetToolTipText("Draw the distribution of the variable");
245 fRadioXrun = new TGRadioButton(fContDrawSelSubRunTime, ":Run", kRadioXrun);
246 fContDrawSelSubRunTime->AddFrame(fRadioXrun, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
247 fRadioXrun->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
248 fRadioXrun->SetToolTipText("Use run number as x-value");
251 fRadioXtime = new TGRadioButton(fContDrawSelSubRunTime, ":Time", kRadioXtime);
252 fContDrawSelSubRunTime->AddFrame(fRadioXtime, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
253 fRadioXtime->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
254 fRadioXtime->SetToolTipText("Use time stamp number as x-value");
258 fListVariables = new TGListBox(fContDrawSel);
259 fContDrawSel->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
260 fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelection()");
263 //-------------------- run type selection ------------------------
265 fLblRunType = new TGLabel(fContDrawSel, "Run Type:");
266 fLblRunType->SetTextJustify(kTextLeft);
267 fContDrawSel->AddFrame(fLblRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
269 fComboRunType = new TGComboBox(fContDrawSel);
270 fComboRunType->EnableTextInput(kFALSE);
271 fContDrawSel->AddFrame(fComboRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
272 fComboRunType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoDraw()");
273 // fComboRunType->SetEnabled(kFALSE);
274 fComboRunType->Resize(0, 22);
276 //-------------------- parameter selection ------------------------
278 fLblPar = new TGLabel(fContDrawSel, "Parameter:");
279 fLblPar->SetTextJustify(kTextLeft);
280 fContDrawSel->AddFrame(fLblPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
282 fNmbPar = new TGNumberEntry(fContDrawSel, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
283 fContDrawSel->AddFrame(fNmbPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
284 fNmbPar->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUItime", this, "DoParLimitChange()");
285 fNmbPar->SetState(kFALSE);
287 //-------------------- calibration type selection ------------------------
289 // draw selection group
290 fContCalibType = new TGGroupFrame(fContLeft, "Calib type selection", kVerticalFrame | kFitWidth | kFitHeight);
291 fContLeft->AddFrame(fContCalibType, new TGLayoutHints(kLHintsExpandX , 0, 0, 10, 0));
294 fListCalibType = new TGListBox(fContCalibType);
295 fContCalibType->AddFrame(fListCalibType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX , 0, 0, 0, 0));
296 fListCalibType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoChangeSelectionList()");
297 fListCalibType->Resize(0,88);
298 fListCalibType->SetMultipleSelections();
301 // ==========================================================================
302 // ************************* content of fContCenter *************************
303 // ========================================================================
304 // main drawing canvas
305 fCanvMain = new TRootEmbeddedCanvas("GUItime_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
306 fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
307 fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliTPCCalibViewerGUItime", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
308 // fCanvMain->GetCanvas()->Connect("RangeAxisChanged()", "AliTPCCalibViewerGUItime", this, "GetMinMax()");
309 fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed.");
310 fCanvMain->GetCanvas()->SetRightMargin(0.062);
311 fCanvMain->GetCanvas()->SetLeftMargin(0.15);
313 // =========================================================================
314 // ************************* content of fContRight *************************
315 // ========================================================================
316 //group frame for value information
317 fContValues = new TGGroupFrame(fContRight, "Data point info", kVerticalFrame | kFitWidth | kFitHeight);
318 fContRight->AddFrame(fContValues, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
320 fContValues->SetLayoutManager(new TGMatrixLayout(fContValues, 0, 2, 5));
321 //value information labels
324 fLblRunNumber = new TGLabel(fContValues, "Run:");
325 fLblRunNumber->SetTextJustify(kTextLeft);
326 fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
328 fLblRunNumberVal = new TGLabel(fContValues, "000000");
329 fLblRunNumberVal->SetTextJustify(kTextLeft);
330 fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
332 fLblRunTime = new TGLabel(fContValues, "Time:");
333 fLblRunTime->SetTextJustify(kTextLeft);
334 fContValues->AddFrame(fLblRunTime, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
336 fLblRunTimeVal = new TGLabel(fContValues, "00.00.0000\n00:00:00");
337 fLblRunTimeVal->SetTextJustify(kTextLeft);
338 fContValues->AddFrame(fLblRunTimeVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
340 fLblValueX = new TGLabel(fContValues, "x-Value:");
341 fLblValueX->SetTextJustify(kTextLeft);
342 fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
344 fLblValueXVal = new TGLabel(fContValues, "00.000e+00");
345 fLblValueXVal->SetTextJustify(kTextRight);
346 fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
348 fLblValueY = new TGLabel(fContValues, "y-Value:");
349 fLblValueY->SetTextJustify(kTextLeft);
350 fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
352 fLblValueYVal = new TGLabel(fContValues, "00.000e+00");
353 fLblValueYVal->SetTextJustify(kTextRight);
354 fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
356 fBtnDumpRuns = new TGTextButton(fContRight, "&Dump runs");
357 fContRight->AddFrame(fBtnDumpRuns, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
358 fBtnDumpRuns->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDumpRuns()");
359 fBtnDumpRuns->SetToolTipText("Press to dump the run numbers of the current selection.");
360 //group frame for value information
361 fContAliases = new TGGroupFrame(fContRight, "Aliases", kVerticalFrame | kFitWidth | kFitHeight);
362 fContRight->AddFrame(fContAliases, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
364 fListAliases = new TGListBox(fContAliases);
365 fContAliases->AddFrame(fListAliases, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
366 fListAliases->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelectionAliases()");
367 // fListAliases->Resize(0,88);
369 TGCompositeFrame *frame1 = new TGCompositeFrame(fContAliases, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
370 fContAliases->AddFrame(frame1, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
372 TGTextButton *btnAdd = new TGTextButton(frame1, "&Add");
373 frame1->AddFrame(btnAdd, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
374 btnAdd->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoAddAlias()");
375 btnAdd->SetToolTipText("Press to add an alias.");
376 btnAdd->Resize(0,22);
378 TGTextButton *btnDel = new TGTextButton(frame1, "&Del");
379 frame1->AddFrame(btnDel, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
380 btnDel->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDelAlias()");
381 btnDel->SetToolTipText("Press to delete the selected alias.");
382 btnDel->Resize(0,22);
384 TGTextButton *btnUp = new TGTextButton(frame1, "&Upd");
385 frame1->AddFrame(btnUp, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
386 btnUp->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "UpdateAliasList()");
387 btnUp->SetToolTipText("Press to update the alias list.");
392 // =========================================================================
393 // ****************** bottom content of fContTopBottom *********************
394 // =========================================================================
396 // custom options container
397 // --- fComboCustom --- the custom draw line on the very low
398 fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
399 fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
401 // ------------------------- content of fContCustom -------------------------
402 fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: ");
403 fLblCustomDraw->SetTextJustify(kTextLeft);
404 fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
405 // text field for custom draw command
406 fComboCustomDraw = new TGComboBox(fContCustom);
407 // fComboCustomDraw->Resize(0, fLblValueY->GetDefaultHeight());
408 fComboCustomDraw->Resize(0, 22);
409 fComboCustomDraw->EnableTextInput(kTRUE);
410 fContCustom->AddFrame(fComboCustomDraw, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
411 fComboCustomDraw->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
412 fComboCustomDraw->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
415 // additional cuts container
416 fContCustomCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
417 fContTopBottom->AddFrame(fContCustomCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
419 // ------------------------- content of fContCustomCuts -------------------------
420 fLblCustomCuts = new TGLabel(fContCustomCuts, "Custom cuts: ");
421 fLblCustomCuts->SetTextJustify(kTextLeft);
422 fContCustomCuts->AddFrame(fLblCustomCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
423 // combo text field for additional cuts
424 fComboCustomCuts = new TGComboBox(fContCustomCuts);
425 // fComboCustomCuts->Resize(0, fLblValueY->GetDefaultHeight());
426 fComboCustomCuts->Resize(0, 22);
427 fComboCustomCuts->EnableTextInput(kTRUE);
428 fContCustomCuts->AddFrame(fComboCustomCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
429 fComboCustomCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
430 fComboCustomCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
432 SetWindowName("AliTPCCalibViewer GUI - Time");
434 Resize(GetDefaultSize());
437 //______________________________________________________________________________
438 void AliTPCCalibViewerGUItime::SetInitialValues(){
440 // Set inital selections of the gui
442 fRadioXrun->SetState(kButtonDown);
443 fRadioXtime->SetState(kButtonUp);
446 //______________________________________________________________________________
447 void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeName) {
449 // retrieve tree from file
451 TString s=gSystem->GetFromPipe(Form("ls %s",fileName));
452 // TString s(fileName);
453 TObjArray *arr=s.Tokenize("\n");
456 if (fTree) delete fTree;
457 fTree=new TChain(treeName);
458 while ( (o=next()) ){
459 fTree->AddFile(o->GetName());
462 if (!CheckChain()) return;
463 UseConfigFile(fConfigFile.Data());
467 //______________________________________________________________________________
468 void AliTPCCalibViewerGUItime::UseChain(TChain *const chain = 0)
474 if (!CheckChain()) return;
475 //set configuration file
476 UseConfigFile(fConfigFile.Data());
479 //______________________________________________________________________________
480 Bool_t AliTPCCalibViewerGUItime::CheckChain()
483 // check whether cahin has entries
484 // decide whether to draw graphs in 2D
486 if (!fTree) return kFALSE;
488 Long64_t entries=fTree->GetEntries();
490 AliError("No entries found in chain");
493 //check whether to draw graphs
497 //______________________________________________________________________________
498 void AliTPCCalibViewerGUItime::UseConfigFile(const char* file)
501 // Use 'file' as configuration file
504 fConfigParser->ParseConfigFileTxt(fConfigFile.Data());
507 //______________________________________________________________________________
508 void AliTPCCalibViewerGUItime::FillRunTypes()
511 //Loop over the tree entries and fill the run types
515 fComboRunType->RemoveAll();
516 fComboRunType->AddEntry("ALL",id++);
517 fComboRunType->Select(0,kFALSE);
518 if (!fTree->GetBranch("runType.")) return;
519 TObjString *runType=0x0;
520 Int_t nevets=fTree->GetEntries();
521 fTree->SetBranchStatus("*",0);
522 fTree->SetBranchStatus("runType.*",1);
523 fTree->SetBranchAddress("runType.",&runType);
524 for (Int_t iev=0;iev<nevets;++iev){
525 fTree->GetEntry(iev);
526 TString type=runType->String();
527 if (!type.IsNull()&&!fComboRunType->FindEntry(type)) fComboRunType->AddEntry(type,id++);
529 fTree->ResetBranchAddresses();
530 fTree->SetBranchStatus("*",1);
532 //______________________________________________________________________________
533 void AliTPCCalibViewerGUItime::FillCalibTypes()
536 // loop over configuration and fill calibration types
539 fListCalibType->RemoveAll();
541 fConfigParser->ResetIter();
543 while ( (o=fConfigParser->NextKey()) ){
544 type=fConfigParser->GetData(o,kCalibType);
545 //remove whitespcaces
546 type.Remove(TString::kBoth,' ');
547 type.Remove(TString::kBoth,'\t');
548 if (type.IsNull()) type="UNSPECIFIED";
549 // printf("CalibType: '%s'\n",type.Data());
550 if (!fListCalibType->FindEntry(type.Data())) {
551 fListCalibType->AddEntry(type,id);
552 fListCalibType->Select(id++);
555 //add type for unspecified calibration type
557 if (!fListCalibType->FindEntry(type.Data())) {
558 fListCalibType->AddEntry(SubstituteUnderscores(type.Data()),id);
559 fListCalibType->Select(id++);
562 //______________________________________________________________________________
563 void AliTPCCalibViewerGUItime::CheckDrawGraph()
566 // Check whether to draw graphs in 2D mode based on the number of entries in the chain
567 // GetEstimate() returns the maximum size of the arrays stored in GetV1()...
571 if (fTree->GetEntries()<fTree->GetEstimate()) fNoGraph=kFALSE;
573 //______________________________________________________________________________
574 void AliTPCCalibViewerGUItime::Reload(Int_t first)
577 // reload the gui contents, this is needed after the input tree has changed
580 if ( !fTree ) return;
581 //in case of the first call create run type and calibration type entries
586 //activate all branches
587 fTree->SetBranchStatus("*",1);
588 //reset variables list
589 fListVariables->RemoveAll();
590 //get selected calibration types
592 fListCalibType->GetSelectedEntries(&calibTypes);
594 TObjArray *branchList = fTree->GetListOfBranches();
595 if ( !branchList ) return;
596 TIter nextBranch(branchList);
597 Int_t idCount=0,id=0;
598 TObject *objBranch=0;
599 while ( (objBranch=nextBranch()) ){
600 TString branchName(objBranch->GetName());
601 TString branchTitle(objBranch->GetName());
602 if (branchName == "run" || branchName == "time" || branchName == "runType.") continue;
604 TString calibType="UNSPECIFIED";
606 const TObject *key=(*fConfigParser)(branchName.Data());
608 //test if branch is active
609 active=fConfigParser->GetValue(branchName.Data(),kBranchOnOff);
610 id=(*fConfigParser)()->IndexOf(key);
611 // branchTitle=fConfigParser->GetData(key,kBranchTitle);
612 calibType=fConfigParser->GetData(key,kCalibType);
620 if (calibType.IsNull()) calibType="UNSPECIFIED";
621 //check if branch is in selected calibration types
622 //if not, don't show it in the list and deactivate the branch.
623 Bool_t calibActive=kFALSE;
624 TIter nextCalib(&calibTypes);
626 while ( (objCalib=nextCalib()) )
627 if (calibType==objCalib->GetTitle()) calibActive=kTRUE;
630 TString s=branchName;
631 if (branchName.EndsWith(".")) s+="*";
632 // fTree->SetBranchStatus(s.Data(),0);
635 // fListVariables->AddEntry(SubstituteUnderscores(branchTitle.Data()),id);
636 fListVariables->AddEntry(branchTitle.Data(),id);
639 //trick to display modifications
640 fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight());
641 fListVariables->Resize(fListVariables->GetWidth()+1, fListVariables->GetHeight());
643 //______________________________________________________________________________
644 void AliTPCCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const char* refName)
647 // map of reference trees that should always be attached to the CalibViewerGUI
649 fMapRefTrees->Add(new TObjString(refName), new TObjString(treeFileName));
652 //______________________________________________________________________________
653 const char* AliTPCCalibViewerGUItime::GetDrawString(){
655 // create draw string for ttree by combining the user requestsa
658 TString selectedVariable="";
660 if (!fListVariables->GetSelectedEntry()) return "";
661 selectedVariable = fListVariables->GetSelectedEntry()->GetTitle();
662 id=fListVariables->GetSelectedEntry()->EntryId();
663 // printf("id: %d\n",id);
664 TString branchName=selectedVariable;
666 const TObject *key=(*fConfigParser)(id);
667 if (key) branchName=(*fConfigParser)(id)->GetName();
669 //treat case of TVector
670 if (branchName.EndsWith(".")){
671 Int_t par = (Int_t)(fNmbPar->GetNumber());
672 branchName.Append(Form("fElements[%d]",par));
674 // if (fRadioXrun->GetState()==kButtonDown)
675 // selectedVariable.Append(":run");
676 // if (fRadioXtime->GetState()==kButtonDown)
677 // selectedVariable.Append(":time");
679 return branchName.Data();
681 //______________________________________________________________________________
682 const char* AliTPCCalibViewerGUItime::GetDrawOptionString(){
684 // get user selected draw options
687 if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle();
688 if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase))
690 return drawOpt.Data();
692 //______________________________________________________________________________
693 void AliTPCCalibViewerGUItime::GetCutString(TString &cutStr){
697 TCut cuts(fComboCustomCuts->GetTextEntry()->GetText());
699 if (fComboRunType->GetSelectedEntry()) runType=fComboRunType->GetSelectedEntry()->GetTitle();
700 if (runType!="ALL"&&!runType.IsNull()) cuts+=Form("runType.String().Data()==\"%s\"",runType.Data());
701 cutStr=cuts.GetTitle();
703 //______________________________________________________________________________
704 void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph, const Double_t *xArr)
710 fValuesX.ResizeTo(1);
711 fValuesY.ResizeTo(1);
712 fRunNumbers.ResizeTo(1);
713 fTimeStamps.ResizeTo(1);
715 const Long64_t nrows=fTree->GetSelectedRows();
716 fValuesX.ResizeTo(nrows);
717 fValuesY.ResizeTo(nrows);
718 fRunNumbers.ResizeTo(nrows);
719 fTimeStamps.ResizeTo(nrows);
720 long long *index=new long long[nrows];
721 TMath::Sort(nrows,fTree->GetV2(),index,kFALSE);
722 for (Long64_t i=0; i<nrows; ++i){
723 fValuesX.GetMatrixArray()[i]=xArr[index[i]];
724 fValuesY.GetMatrixArray()[i]=fTree->GetV3()[index[i]];
725 fRunNumbers.GetMatrixArray()[i]=fTree->GetV1()[index[i]];
726 fTimeStamps.GetMatrixArray()[i]=fTree->GetV2()[index[i]];
731 //______________________________________________________________________________
732 void AliTPCCalibViewerGUItime::GetHistogramTitle(TString &title)
735 // Create string for histogram title
739 Int_t pos=title.First(">>");
740 if (pos>0) title=title(0,pos);
741 // if (!fIsCustomDraw){
742 if (fRadioXrun->GetState()==kButtonDown){
744 } else if (fRadioXtime->GetState()==kButtonDown){
750 TObjArray *arr=title.Tokenize(":");
755 TIter next(arr,kIterBackward);
756 while ( (o=next()) ){
757 TString varName=o->GetName();
759 //substitue variable names with names in configuration file if available
760 if ((*fConfigParser)()->GetEntries()){
761 TString branchName=varName;
763 if (branchName.Contains('.')) branchName=branchName(0,branchName.First('.')+1);
764 //chek if a configuration for that branch is available
765 const TObject *oBranch=(*fConfigParser)(branchName.Data());
767 TString branchTitle=fConfigParser->GetData(oBranch,kBranchTitle);
768 if (!branchTitle.IsNull()){
769 //check for TVectorT type branch
770 //add parameter name if available
771 if (varName.Contains("fElements")){
772 TString parStr=varName(varName.First('[')+1,varName.Length()-varName.First('[')-2);
775 TString yparname=fConfigParser->GetData(oBranch,par+kParamNames);
776 if (!yparname.IsNull()){
777 branchTitle+=yparname;
785 varName=SubstituteUnderscores(branchTitle.Data());
792 //______________________________________________________________________________
793 void AliTPCCalibViewerGUItime::AdjustYRange()
798 TIter nextGraphicObject(fTrashBox);
801 while ( (o=nextGraphicObject()) ){
802 if (o->IsA()==TGraph::Class()){
803 TGraph *gr=(TGraph*)o;
805 min=TMath::MinElement(gr->GetN(),gr->GetY());
806 max=TMath::MaxElement(gr->GetN(),gr->GetY());
808 Float_t currmin=TMath::MinElement(gr->GetN(),gr->GetY());
809 Float_t currmax=TMath::MaxElement(gr->GetN(),gr->GetY());
810 if (currmax>max) max=currmax;
811 if (currmin<min) min=currmin;
816 if (min!=0) min=min-(max-min)/10;
817 if (max!=0) max=max+(max-min)/10;
818 fCurrentHist->SetMinimum(min);
819 fCurrentHist->SetMaximum(max);
822 //______________________________________________________________________________
823 void AliTPCCalibViewerGUItime::DoDraw() {
827 TString drawString=fDrawString;
829 GetCutString(cutString);
830 TString optString = GetDrawOptionString();
831 Bool_t graphOutput=!fNoGraph; //ttree buffer for V1, V2... too small
832 graphOutput&=(drawString.First(">>")<0); //histogram output in custom draw
833 graphOutput&=fRadioXhist->GetState()!=kButtonDown; //histogram drawing selected
834 // graphOutput&=!(fIsCustomDraw&&!fDrawString.Contains(":")); //custom draw 1D
835 // graphOutput&=fDrawString.CountChar(':')<2; //custom draw 1D
836 if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
837 if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
838 Bool_t drawSame=optString.Contains("same",TString::kIgnoreCase);
839 // optString+="goff";
841 drawString.Prepend("run:time:");
844 // if (!fIsCustomDraw){
845 if (fRadioXrun->GetState()==kButtonDown){
847 } else if (fRadioXtime->GetState()==kButtonDown){
852 TVirtualPad *padsave=gPad;
853 fCanvMain->GetCanvas()->cd();
854 //delete old histograms and graphs
861 fTree->Draw(drawString.Data(),cutString.Data(),optString.Data());
862 if (fTree->GetSelectedRows()==-1) return;
865 GetHistogramTitle(title);
866 Bool_t drawGraph=kFALSE;
870 if (fIsCustomDraw&&fDrawString.Contains(":")){
871 // fValuesX.SetElements(fTree->GetV4());
874 if (fRadioXrun->GetState()==kButtonDown){
875 // fValuesX.SetElements(fTree->GetV1());
877 } else if (fRadioXtime->GetState()==kButtonDown){
878 // fValuesX.SetElements(fTree->GetV2());
885 if (xArr) UpdateValueArrays(graphOutput, xArr);
887 // if (fIsCustomDraw){
888 // if (fDrawString.Contains(":")){
889 // fValuesX.SetElements(fTree->GetV4());
896 // if (fRadioXrun->GetState()==kButtonDown){
897 // fValuesX.SetElements(fTree->GetV1());
898 // } else if (fRadioXtime->GetState()==kButtonDown){
899 // fValuesX.SetElements(fTree->GetV2());
905 //create graph according to selection
907 TGraph *graph=new TGraph(fValuesX,fValuesY);
909 if (!drawSame) grDraw+="a";
910 if (!fIsCustomDraw) grDraw+="l";
911 graph->Draw(grDraw.Data());
912 graph->SetEditable(kFALSE);
913 TH1 *hist=graph->GetHistogram();
914 hist->SetTitle(title.Data());
915 fTrashBox->Add(graph);
916 graph->SetLineColor(fTrashBox->GetEntries());
917 graph->SetMarkerColor(fTrashBox->GetEntries());
923 TH1 *hist=fTree->GetHistogram();
924 hist->SetTitle(title.Data());
925 // hist->Draw(optString.Data());
926 fTrashBox->Add(hist);
927 hist->SetLineColor(fTrashBox->GetEntries());
928 hist->SetMarkerColor(fTrashBox->GetEntries());
929 if (!drawSame) fCurrentHist=hist;
932 //Set time axis if choosen as x-variables
933 // if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw&&!drawSame){
934 if (fRadioXtime->GetState()==kButtonDown&&!drawSame){
935 TAxis *xaxis=fCurrentHist->GetXaxis();
936 xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}");
937 xaxis->SetTimeDisplay(1);
938 xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3);
939 xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3);
943 fCurrentHist->GetYaxis()->SetTitleOffset(1.5);
953 //______________________________________________________________________________
954 void AliTPCCalibViewerGUItime::DoDumpRuns()
957 // Dump the current run numbers to stdout
959 Int_t npoints=fRunNumbers.GetNrows();
960 Int_t *sortIndex = new Int_t[npoints];
961 TMath::Sort(npoints,fRunNumbers.GetMatrixArray(),sortIndex,kFALSE);
962 Int_t run=0, prevRun=-1;
964 for (Int_t irun=0;irun<npoints;++irun){
965 run=(Int_t)fRunNumbers.GetMatrixArray()[sortIndex[irun]];
966 if (run!=prevRun) std::cout << Form("%d",run) << std::endl;
971 //______________________________________________________________________________
972 void AliTPCCalibViewerGUItime::DoParLimitChange()
980 //______________________________________________________________________________
981 void AliTPCCalibViewerGUItime::DoNewSelection() {
983 // decides whether to redraw if user makes another selection
986 fDrawString=GetDrawString();
987 fIsCustomDraw=kFALSE;
990 //______________________________________________________________________________
991 void AliTPCCalibViewerGUItime::DoCustomDraw()
996 fDrawString=fComboCustomDraw->GetTextEntry()->GetText();
997 // if (fDrawString.Contains(">>")){
998 // Warning("DoCustomDraw","Currently no user defined histograms allowed!");
1001 fNmbPar->SetState(kFALSE);
1002 fIsCustomDraw=kTRUE;
1005 //______________________________________________________________________________
1006 void AliTPCCalibViewerGUItime::DoCustomCutsDraw()
1011 if (fIsCustomDraw) DoCustomDraw();
1013 fDrawString=GetDrawString();
1014 fIsCustomDraw=kFALSE;
1018 //______________________________________________________________________________
1019 void AliTPCCalibViewerGUItime::HandleButtonsDrawSel(Int_t id)
1022 // Draw selection button handling (x-variable)
1026 TGButton *btn = (TGButton *) gTQSender;
1027 id = btn->WidgetId();
1030 Bool_t doDraw=kFALSE;
1031 Bool_t noDraw=kFALSE;
1038 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
1040 fRadioXrun->SetState(kButtonUp);
1041 fRadioXtime->SetState(kButtonUp);
1042 fRadioXhist->SetState(kButtonDown);
1046 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXhist->GetState()==kButtonDown);
1048 fRadioXhist->SetState(kButtonUp);
1049 fRadioXtime->SetState(kButtonUp);
1050 fRadioXrun->SetState(kButtonDown);
1054 doDraw=(fRadioXhist->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
1056 fRadioXrun->SetState(kButtonUp);
1057 fRadioXhist->SetState(kButtonUp);
1058 fRadioXtime->SetState(kButtonDown);
1062 if (doDraw&&!noDraw) DoCustomCutsDraw();
1064 //______________________________________________________________________________
1065 void AliTPCCalibViewerGUItime::UpdateParName()
1068 // change parameter name
1071 Int_t par = (Int_t)(fNmbPar->GetNumber());
1073 Int_t id=fListVariables->GetSelectedEntry()->EntryId();
1074 if (fConfigParser && (*fConfigParser)(id)) parName=fConfigParser->GetData((*fConfigParser)(id),par+kParamNames);
1075 if (parName=="") parName.Form("%d",par);
1076 fLblPar->SetText(Form("Parameter: %s",parName.Data()));
1077 fDrawString=GetDrawString();
1078 fIsCustomDraw=kFALSE;
1081 //______________________________________________________________________________
1082 void AliTPCCalibViewerGUItime::UpdateParLimits()
1085 // Adjust limits for TVectorT based variables
1088 TString selectedVariableTitle="";
1090 if (!fListVariables->GetSelectedEntry()) return;
1091 selectedVariableTitle = fListVariables->GetSelectedEntry()->GetTitle();
1092 id=fListVariables->GetSelectedEntry()->EntryId();
1093 // printf("id: %d\n",id);
1094 TString selectedVariable=selectedVariableTitle;
1095 const TObject *key=(*fConfigParser)(id);
1096 if (key) selectedVariable=(*fConfigParser)(id)->GetName();
1098 if (selectedVariable.IsNull()||!selectedVariable.EndsWith(".")) {
1099 fNmbPar->SetState(kFALSE);
1100 fLblPar->SetText("Parameter: none");
1107 TBranch *branch=fTree->GetTree()->GetBranch(selectedVariable.Data());
1108 TString branchClass=branch->GetClassName();
1110 if (branchClass=="TVectorT<double>"){
1111 // branch->SetAddress(&vD);
1112 fTree->SetBranchAddress(selectedVariable.Data(),&vD);
1113 while (maxPar<2&&event<fTree->GetEntries()){
1114 fTree->GetEntry(event++);
1115 maxPar=vD->GetNrows();
1117 } else if (branchClass=="TVectorT<float>"){
1118 // branch->SetAddress(&vF);
1119 fTree->SetBranchAddress(selectedVariable.Data(),&vF);
1120 while (maxPar<2&&event<fTree->GetEntries()){
1121 fTree->GetEntry(event++);
1122 maxPar=vF->GetNrows();
1126 fNmbPar->SetState(kFALSE);
1129 // branch->ResetAddress();
1130 fTree->SetBranchAddress(selectedVariable.Data(),0x0);
1131 if (fNmbPar->GetNumMax()!=maxPar-1) fNmbPar->SetNumber(0);
1132 fNmbPar->SetLimitValues(0,maxPar-1);
1133 fNmbPar->SetState(kTRUE);
1136 //______________________________________________________________________________
1137 void AliTPCCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/)
1140 // handle mouse events in the draw canvas
1142 UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0;
1143 Double_t valx=0.,valy=0.;
1144 if (!fCurrentGraph) {
1145 fLblRunNumberVal->SetText(Form("%06u",run));
1146 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS));
1147 fLblValueXVal->SetText(Form("%.3e", valx));
1148 fLblValueYVal->SetText(Form("%.3e", valy));
1151 TVirtualPad *padsave=gPad;
1152 fCanvMain->GetCanvas()->cd();
1153 Int_t n=fValuesY.GetNrows();
1155 arr=fValuesX.GetMatrixArray();
1157 Int_t minDist=1000000;
1159 for (Int_t i=0;i<n;++i){
1160 Int_t pxp = gPad->XtoAbsPixel(gPad->XtoPad(arr[i]));
1161 Int_t pyp = gPad->YtoAbsPixel(gPad->YtoPad(fValuesY[i]));
1162 Int_t d = TMath::Nint(TMath::Sqrt(TMath::Abs(pxp-x) + TMath::Abs(pyp-y)));
1169 TTimeStamp t((Int_t)fTimeStamps[minPoint]);
1170 t.GetDate(kTRUE,0,&yy,&mm,&dd);
1171 t.GetTime(kTRUE,0,&HH,&MM,&SS);
1172 run=(UInt_t)fRunNumbers[minPoint];
1173 valx=fValuesX[minPoint];
1174 valy=fValuesY[minPoint];
1176 dd=0;mm=0;yy=0;HH=0;MM=0;SS=0;run=0;
1180 fLblRunNumberVal->SetText(Form("%06u",run));
1181 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS));
1183 fLblValueXVal->SetText(Form("%.3e", valx));
1185 if (fRadioXrun->GetState()==kButtonDown){
1186 fLblValueXVal->SetText("Run");
1187 } else if (fRadioXtime->GetState()==kButtonDown){
1188 fLblValueXVal->SetText("Time");
1191 fLblValueYVal->SetText(Form("%.3e", valy));
1194 if (event == kButton1Double ){
1197 //find closes point of current selection
1199 //______________________________________________________________________________
1200 void AliTPCCalibViewerGUItime::SetGuiTree(Int_t run)
1203 // create the AliTPCCalibViewerGUI tree for run
1204 // cache tree in directory fOutputCacheDir
1205 // retrieve file from this directory if it already exists
1209 //Create and set GUI tree
1211 //try to find file for run in fOutputCacheDir
1212 TString fileName=fOutputCacheDir;
1213 if (!fileName.EndsWith("/")) fileName+="/";
1214 fileName+=Form("guiTreeRun_%d.root",run);
1216 if (gSystem->AccessPathName(fileName.Data())){
1217 load=AliTPCcalibDB::CreateGUITree(run,fileName.Data());
1219 fCalibViewerGUI->Reset();
1220 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX")));
1224 fCalibViewerGUI->Initialize(fileName.Data());
1225 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run)));
1228 //Create and set Reference GUI tree
1230 AliTPCcalibDButil util;
1231 util.SetReferenceRun(run);
1232 fileName=fOutputCacheDir;
1233 if (!fileName.EndsWith("/")) fileName+="/";
1234 fileName+=util.GetGUIRefTreeDefaultName();
1235 //only update if file does not exist
1236 if (gSystem->AccessPathName(fileName.Data())){
1237 util.UpdateRefDataFromOCDB();
1238 util.CreateGUIRefTree(fileName.Data());
1241 fCalibViewerGUI->GetViewer()->AddReferenceTree(fileName.Data(),"calPads","Ref");
1244 // Process additional reference trees
1246 TIter nextRefTree(fMapRefTrees);
1248 //Set static reference data
1249 while ( (o=nextRefTree()) ){
1250 fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"calPads",o->GetName());
1252 fCalibViewerGUI->Reload();
1254 //______________________________________________________________________________
1255 const char* AliTPCCalibViewerGUItime::SubstituteUnderscores(const char* in)
1261 s.ReplaceAll("_{","|{");
1262 s.ReplaceAll("_"," ");
1263 s.ReplaceAll("|{","_{");
1267 //______________________________________________________________________________
1268 void AliTPCCalibViewerGUItime::DoNewSelectionAliases()
1274 TList *l=fTree->GetListOfAliases();
1276 TString selectedVariable="";
1277 if (!fListAliases->GetSelectedEntry()) return;
1278 selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
1279 fDrawString=selectedVariable;
1280 fIsCustomDraw=kFALSE;
1283 //______________________________________________________________________________
1284 void AliTPCCalibViewerGUItime::DoAddAlias()
1289 new AliTPCCalibViewerGUItimeAddAliasFrame(gClient->GetRoot(), fContTopBottom, 400, 200, kVerticalFrame, this);
1291 //______________________________________________________________________________
1292 void AliTPCCalibViewerGUItime::DoDelAlias()
1298 TList *l=fTree->GetListOfAliases();
1300 TString selectedVariable="";
1301 if (!fListAliases->GetSelectedEntry()) return;
1302 selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
1303 l->Remove(l->FindObject(selectedVariable.Data()));
1307 //______________________________________________________________________________
1308 void AliTPCCalibViewerGUItime::UpdateAliasList()
1313 printf("UpdateAliasList\n");
1315 TList *l=fTree->GetListOfAliases();
1319 fListAliases->RemoveAll();
1321 while( (o=nextAlias()) ){
1322 fListAliases->AddEntry(o->GetName(),id++);
1324 fListAliases->Resize(fListAliases->GetWidth()-1, fListAliases->GetHeight());
1325 fListAliases->Resize(fListAliases->GetWidth()+1, fListAliases->GetHeight());
1327 //______________________________________________________________________________
1328 TObjArray* AliTPCCalibViewerGUItime::ShowGUI(const char* fileName, const char* treeName) {
1330 // Initialize and show GUI for presentation for demonstration purposes
1331 // or for fast standalone use
1333 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1334 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1335 frmMain->SetCleanup(kDeepCleanup);
1337 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1338 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1340 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1341 TGCompositeFrame* tabCont2 = tabMain->AddTab("Detail - XXXXX");
1343 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1344 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1345 calibViewerTime->SetConfigFileName("$ALICE_ROOT/TPC/CalibMacros/calibVarDescription.txt");
1346 calibViewerTime->UseFile(fileName, treeName);
1348 AliTPCCalibViewerGUI* calibViewer = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, 0);
1349 tabCont2->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1350 calibViewerTime->SetCalibViewerGUI(calibViewer);
1351 calibViewerTime->SetCalibViewerGUItab(tabMain->GetTabTab(1));
1354 TObjArray *guiArray = new TObjArray();
1355 guiArray->Add(calibViewerTime);
1356 guiArray->Add(calibViewer);
1358 frmMain->MapSubwindows();
1360 frmMain->MapWindow();
1365 //______________________________________________________________________________
1366 TObjArray* AliTPCCalibViewerGUItime::ShowGUI(TChain *chain) {
1368 // Initialize and show GUI for presentation for demonstration purposes
1369 // or for fast standalone use
1371 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1372 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1373 frmMain->SetCleanup(kDeepCleanup);
1375 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1376 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1378 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1380 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1381 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1382 calibViewerTime->UseChain(chain);
1384 TObjArray *guiArray = new TObjArray();
1385 guiArray->Add(calibViewerTime);
1387 frmMain->MapSubwindows();
1389 frmMain->MapWindow();
1395 ////////////////////////////////////////////////////////////////////////
1399 ////////////////////////////////////////////////////////////////////////
1402 ClassImp(AliTPCCalibViewerGUItimeAddAliasFrame)
1404 AliTPCCalibViewerGUItimeAddAliasFrame::AliTPCCalibViewerGUItimeAddAliasFrame(const TGWindow *p, const TGWindow *main,
1405 UInt_t w, UInt_t h, UInt_t options,
1406 AliTPCCalibViewerGUItime *gui, TString strAlias) :
1412 fMain = new TGTransientFrame(p, main, w, h, options);
1413 fMain->Connect("CloseWindow()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
1414 fMain->DontCallClose(); // to avoid double deletions.
1416 // use hierarchical cleaning
1417 fMain->SetCleanup(kDeepCleanup);
1420 TGLayoutHints *l1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
1421 TGLayoutHints *l2 = new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX, 2, 2, 0, 5);
1422 // TGLayoutHints *l3 = new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5);
1425 TGCompositeFrame *f1 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame);
1426 fMain->AddFrame(f1, l1);
1427 TGCompositeFrame *frameName = new TGCompositeFrame(f1);
1428 TGCompositeFrame *frameFormula = new TGCompositeFrame(f1);
1429 f1->AddFrame(frameName,l2);
1430 f1->AddFrame(frameFormula,l2);
1431 TGLabel *lblTxt1 = new TGLabel(frameName, "Name:");
1432 TGLabel *lblTxt2 = new TGLabel(frameFormula, "Formula:");
1433 fTxt1 = new TGTextEntry(frameName, new TGTextBuffer(1000));
1434 fTxt2 = new TGTextEntry(frameFormula, new TGTextBuffer(1000));
1436 frameName->AddFrame(lblTxt1, l2);
1437 frameName->AddFrame(fTxt1, l2);
1438 frameFormula->AddFrame(lblTxt2, l2);
1439 frameFormula->AddFrame(fTxt2, l2);
1441 fTxt1->Resize(350, fTxt1->GetDefaultHeight());
1442 fTxt2->Resize(350, fTxt2->GetDefaultHeight());
1444 //ok and cancel buttons
1445 TGHorizontalFrame *frame = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
1447 TGTextButton *okButton = new TGTextButton(frame, "&Ok", 1);
1448 okButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoOK()");
1449 TGTextButton *cancelButton = new TGTextButton(frame, "&Cancel", 2);
1450 cancelButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
1453 frame->AddFrame(okButton, l1);
1454 frame->AddFrame(cancelButton, l1);
1456 frame->Resize(150, okButton->GetDefaultHeight());
1458 fMain->AddFrame(frame, new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1));
1461 TString aliasName, alias;
1462 if (!strAlias.IsNull()){
1463 TChain *c=fGUI->GetChain();
1465 TList *l=c->GetListOfAliases();
1467 TNamed *d=(TNamed*)l->FindObject(strAlias);
1469 aliasName=d->GetName();
1470 alias=d->GetTitle();
1475 alias=fGUI->GetCustomDrawString();
1477 fTxt1->SetText(aliasName.Data(),kFALSE);
1478 fTxt2->SetText(alias.Data(),kFALSE);
1480 fMain->MapSubwindows();
1483 // position relative to the parent's window
1484 fMain->CenterOnParent();
1486 fMain->SetWindowName("Alias Editor");
1491 //______________________________________________________________________________
1492 AliTPCCalibViewerGUItimeAddAliasFrame::~AliTPCCalibViewerGUItimeAddAliasFrame()
1497 fMain->DeleteWindow(); // deletes fMain
1499 //______________________________________________________________________________
1500 void AliTPCCalibViewerGUItimeAddAliasFrame::DoOK()
1505 TString aliasName=fTxt1->GetText();
1506 TString alias=fTxt2->GetText();
1507 if (!aliasName.IsNull()&&!alias.IsNull()){
1508 TChain *c=fGUI->GetChain();
1510 c->SetAlias(aliasName.Data(),alias.Data());
1513 fGUI->UpdateAliasList();
1516 //______________________________________________________________________________
1517 void AliTPCCalibViewerGUItimeAddAliasFrame::DoCancel()