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 fChkDrawOptSparse(0x0),
107 fComboAddDrawOpt(0x0),
109 fContDrawSelSubRunTime(0x0),
130 fLblRunNumberVal(0x0),
139 fContCustomCuts(0x0),
142 fComboCustomDraw(0x0),
143 fComboCustomCuts(0x0),
144 fTrashBox(new TObjArray)
149 fMapRefTrees->SetOwnerKeyValue();
150 fTrashBox->SetOwner();
152 gStyle->SetMarkerStyle(20);
153 gStyle->SetMarkerSize(0.5);
156 //______________________________________________________________________________
157 AliTPCCalibViewerGUItime::~AliTPCCalibViewerGUItime(){
161 delete fConfigParser;
165 //______________________________________________________________________________
166 void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) {
170 // ======================================================================
171 // ************************* Display everything *************************
172 // ======================================================================
174 SetCleanup(kDeepCleanup);
176 // *****************************************************************************
177 // ************************* content of this MainFrame *************************
178 // *****************************************************************************
179 // top level container with horizontal layout
180 fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
181 AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
183 fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
184 fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
186 // ***********************************************************************
187 // ************************* content of fContLCR *************************
188 // ***********************************************************************
190 fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
191 fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
193 // left vertical splitter
194 TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
195 splitLeft->SetFrame(fContLeft, kTRUE);
196 fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
199 fContRight = new TGCompositeFrame(fContLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight);
200 fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
203 fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
204 fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
206 // right vertical splitter
207 TGVSplitter *splitRight = new TGVSplitter(fContLCR);
208 splitRight->SetFrame(fContRight, kFALSE);
209 fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
212 // ========================================================================
213 // ************************* content of fContLeft *************************
214 // ========================================================================
215 // --- draw button and tabLeft ---
217 fContDrawOpt = new TGGroupFrame(fContLeft, "Draw options", kVerticalFrame | kFitWidth | kFitHeight);
218 fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
220 TGCompositeFrame *cfr = new TGCompositeFrame(fContDrawOpt, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
221 fContDrawOpt->AddFrame(cfr, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
223 fChkDrawOptSame = new TGCheckButton(cfr, "Same");
224 cfr->AddFrame(fChkDrawOptSame, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
225 fChkDrawOptSame->SetToolTipText("Add draw option 'same'");
227 fChkDrawOptSparse = new TGCheckButton(cfr, "Sparse");
228 cfr->AddFrame(fChkDrawOptSparse, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
229 fChkDrawOptSparse->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoNewSelection()");
230 fChkDrawOptSparse->SetToolTipText("In case of run trending only plot runs with information");
232 // additional draw options combo box
233 fComboAddDrawOpt = new TGComboBox(fContDrawOpt);
234 fComboAddDrawOpt->Resize(0, 22);
235 fComboAddDrawOpt->EnableTextInput(kTRUE);
236 fContDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
237 // fComboAddDrawOpt->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral(=14)");
238 // fComboAddDrawOpt->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
239 fComboAddDrawOpt->GetTextEntry()->SetText("",kFALSE);
241 // draw selection group
242 fContDrawSel = new TGGroupFrame(fContLeft, "Draw selection", kVerticalFrame | kFitWidth | kFitHeight);
243 fContLeft->AddFrame(fContDrawSel, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
244 //x-axis variables selection, Run of Time
245 fContDrawSelSubRunTime = new TGCompositeFrame(fContDrawSel, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
246 fContDrawSel->AddFrame(fContDrawSelSubRunTime, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
248 // ------------------------- content of fContDrawOpt -------------------------
252 fRadioXhist = new TGRadioButton(fContDrawSelSubRunTime, "hist", kRadioXhist);
253 fContDrawSelSubRunTime->AddFrame(fRadioXhist, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
254 fRadioXhist->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
255 fRadioXhist->SetToolTipText("Draw the distribution of the variable");
257 fRadioXrun = new TGRadioButton(fContDrawSelSubRunTime, ":Run", kRadioXrun);
258 fContDrawSelSubRunTime->AddFrame(fRadioXrun, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
259 fRadioXrun->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
260 fRadioXrun->SetToolTipText("Use run number as x-value");
263 fRadioXtime = new TGRadioButton(fContDrawSelSubRunTime, ":Time", kRadioXtime);
264 fContDrawSelSubRunTime->AddFrame(fRadioXtime, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
265 fRadioXtime->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
266 fRadioXtime->SetToolTipText("Use time stamp number as x-value");
270 fListVariables = new TGListBox(fContDrawSel);
271 fContDrawSel->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
272 fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelection()");
275 //-------------------- run type selection ------------------------
277 fLblRunType = new TGLabel(fContDrawSel, "Run Type:");
278 fLblRunType->SetTextJustify(kTextLeft);
279 fContDrawSel->AddFrame(fLblRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
281 fComboRunType = new TGComboBox(fContDrawSel);
282 fComboRunType->EnableTextInput(kFALSE);
283 fContDrawSel->AddFrame(fComboRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
284 fComboRunType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoDraw()");
285 // fComboRunType->SetEnabled(kFALSE);
286 fComboRunType->Resize(0, 22);
288 //-------------------- parameter selection ------------------------
290 fLblPar = new TGLabel(fContDrawSel, "Parameter:");
291 fLblPar->SetTextJustify(kTextLeft);
292 fContDrawSel->AddFrame(fLblPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
294 fNmbPar = new TGNumberEntry(fContDrawSel, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
295 fContDrawSel->AddFrame(fNmbPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
296 fNmbPar->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUItime", this, "DoParLimitChange()");
297 fNmbPar->SetState(kFALSE);
299 //-------------------- calibration type selection ------------------------
301 // draw selection group
302 fContCalibType = new TGGroupFrame(fContLeft, "Calib type selection", kVerticalFrame | kFitWidth | kFitHeight);
303 fContLeft->AddFrame(fContCalibType, new TGLayoutHints(kLHintsExpandX , 0, 0, 10, 0));
306 fListCalibType = new TGListBox(fContCalibType);
307 fContCalibType->AddFrame(fListCalibType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX , 0, 0, 0, 0));
308 fListCalibType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoChangeSelectionList()");
309 fListCalibType->Resize(0,88);
310 fListCalibType->SetMultipleSelections();
313 // ==========================================================================
314 // ************************* content of fContCenter *************************
315 // ========================================================================
316 // main drawing canvas
317 fCanvMain = new TRootEmbeddedCanvas("GUItime_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
318 fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
319 fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliTPCCalibViewerGUItime", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
320 // fCanvMain->GetCanvas()->Connect("RangeAxisChanged()", "AliTPCCalibViewerGUItime", this, "GetMinMax()");
321 fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed.");
322 fCanvMain->GetCanvas()->SetRightMargin(0.062);
323 fCanvMain->GetCanvas()->SetLeftMargin(0.15);
325 // =========================================================================
326 // ************************* content of fContRight *************************
327 // ========================================================================
328 //group frame for value information
329 fContValues = new TGGroupFrame(fContRight, "Data point info", kVerticalFrame | kFitWidth | kFitHeight);
330 fContRight->AddFrame(fContValues, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
332 fContValues->SetLayoutManager(new TGMatrixLayout(fContValues, 0, 2, 5));
333 //value information labels
336 fLblRunNumber = new TGLabel(fContValues, "Run:");
337 fLblRunNumber->SetTextJustify(kTextLeft);
338 fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
340 fLblRunNumberVal = new TGLabel(fContValues, "000000");
341 fLblRunNumberVal->SetTextJustify(kTextLeft);
342 fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
344 fLblRunTime = new TGLabel(fContValues, "Time:");
345 fLblRunTime->SetTextJustify(kTextLeft);
346 fContValues->AddFrame(fLblRunTime, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
348 fLblRunTimeVal = new TGLabel(fContValues, "00.00.0000\n00:00:00");
349 fLblRunTimeVal->SetTextJustify(kTextLeft);
350 fContValues->AddFrame(fLblRunTimeVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
352 fLblValueX = new TGLabel(fContValues, "x-Value:");
353 fLblValueX->SetTextJustify(kTextLeft);
354 fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
356 fLblValueXVal = new TGLabel(fContValues, "00.000e+00");
357 fLblValueXVal->SetTextJustify(kTextRight);
358 fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
360 fLblValueY = new TGLabel(fContValues, "y-Value:");
361 fLblValueY->SetTextJustify(kTextLeft);
362 fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
364 fLblValueYVal = new TGLabel(fContValues, "00.000e+00");
365 fLblValueYVal->SetTextJustify(kTextRight);
366 fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
368 fBtnDumpRuns = new TGTextButton(fContRight, "&Dump runs");
369 fContRight->AddFrame(fBtnDumpRuns, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
370 fBtnDumpRuns->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDumpRuns()");
371 fBtnDumpRuns->SetToolTipText("Press to dump the run numbers of the current selection.");
372 //group frame for value information
373 fContAliases = new TGGroupFrame(fContRight, "Aliases", kVerticalFrame | kFitWidth | kFitHeight);
374 fContRight->AddFrame(fContAliases, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
376 fListAliases = new TGListBox(fContAliases);
377 fContAliases->AddFrame(fListAliases, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
378 fListAliases->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelectionAliases()");
379 // fListAliases->Resize(0,88);
381 TGCompositeFrame *frame1 = new TGCompositeFrame(fContAliases, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
382 fContAliases->AddFrame(frame1, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
384 TGTextButton *btnAdd = new TGTextButton(frame1, "&Add");
385 frame1->AddFrame(btnAdd, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
386 btnAdd->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoAddAlias()");
387 btnAdd->SetToolTipText("Press to add an alias.");
388 btnAdd->Resize(0,22);
390 TGTextButton *btnDel = new TGTextButton(frame1, "&Del");
391 frame1->AddFrame(btnDel, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
392 btnDel->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDelAlias()");
393 btnDel->SetToolTipText("Press to delete the selected alias.");
394 btnDel->Resize(0,22);
396 TGTextButton *btnUp = new TGTextButton(frame1, "&Upd");
397 frame1->AddFrame(btnUp, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
398 btnUp->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "UpdateAliasList()");
399 btnUp->SetToolTipText("Press to update the alias list.");
404 // =========================================================================
405 // ****************** bottom content of fContTopBottom *********************
406 // =========================================================================
408 // custom options container
409 // --- fComboCustom --- the custom draw line on the very low
410 fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
411 fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
413 // ------------------------- content of fContCustom -------------------------
414 fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: ");
415 fLblCustomDraw->SetTextJustify(kTextLeft);
416 fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
417 // text field for custom draw command
418 fComboCustomDraw = new TGComboBox(fContCustom);
419 // fComboCustomDraw->Resize(0, fLblValueY->GetDefaultHeight());
420 fComboCustomDraw->Resize(0, 22);
421 fComboCustomDraw->EnableTextInput(kTRUE);
422 fContCustom->AddFrame(fComboCustomDraw, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
423 fComboCustomDraw->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
424 fComboCustomDraw->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
425 fComboCustomDraw->GetTextEntry()->SetText("",kFALSE);
427 // additional cuts container
428 fContCustomCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
429 fContTopBottom->AddFrame(fContCustomCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
431 // ------------------------- content of fContCustomCuts -------------------------
432 fLblCustomCuts = new TGLabel(fContCustomCuts, "Custom cuts: ");
433 fLblCustomCuts->SetTextJustify(kTextLeft);
434 fContCustomCuts->AddFrame(fLblCustomCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
435 // combo text field for additional cuts
436 fComboCustomCuts = new TGComboBox(fContCustomCuts);
437 // fComboCustomCuts->Resize(0, fLblValueY->GetDefaultHeight());
438 fComboCustomCuts->Resize(0, 22);
439 fComboCustomCuts->EnableTextInput(kTRUE);
440 fContCustomCuts->AddFrame(fComboCustomCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
441 fComboCustomCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
442 fComboCustomCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
443 fComboCustomCuts->GetTextEntry()->SetText("",kFALSE);
445 SetWindowName("AliTPCCalibViewer GUI - Time");
447 Resize(GetDefaultSize());
450 //______________________________________________________________________________
451 void AliTPCCalibViewerGUItime::SetInitialValues(){
453 // Set inital selections of the gui
455 fRadioXrun->SetState(kButtonDown);
456 fRadioXtime->SetState(kButtonUp);
459 //______________________________________________________________________________
460 void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeName) {
462 // retrieve tree from file
465 TString file(fileName);
466 if (file.Contains("://")) {
467 if (file.Contains(";")) {
468 arr=file.Tokenize(";");
471 arr->Add(new TObjString(fileName));
474 TString s=gSystem->GetFromPipe(Form("ls %s",fileName));
475 arr=s.Tokenize("\n");
481 if (fTree) delete fTree;
482 fTree=new TChain(treeName);
483 while ( (o=next()) ){
484 fTree->AddFile(o->GetName());
488 if (!CheckChain()) return;
489 UseConfigFile(fConfigFile.Data());
493 //______________________________________________________________________________
494 void AliTPCCalibViewerGUItime::UseChain(TChain *const chain = 0)
500 if (!CheckChain()) return;
501 //set configuration file
502 UseConfigFile(fConfigFile.Data());
505 //______________________________________________________________________________
506 Bool_t AliTPCCalibViewerGUItime::CheckChain()
509 // check whether cahin has entries
510 // decide whether to draw graphs in 2D
512 if (!fTree) return kFALSE;
514 Long64_t entries=fTree->GetEntries();
516 AliError("No entries found in chain");
519 //check whether to draw graphs
523 //______________________________________________________________________________
524 void AliTPCCalibViewerGUItime::UseConfigFile(const char* file)
527 // Use 'file' as configuration file
530 fConfigParser->ParseConfigFileTxt(fConfigFile.Data());
533 //______________________________________________________________________________
534 void AliTPCCalibViewerGUItime::FillRunTypes()
537 //Loop over the tree entries and fill the run types
541 fComboRunType->RemoveAll();
542 fComboRunType->AddEntry("ALL",id++);
543 fComboRunType->Select(0,kFALSE);
544 if (!fTree->GetBranch("runType.")) return;
545 TObjString *runType=0x0;
546 Int_t nevets=fTree->GetEntries();
547 fTree->SetBranchStatus("*",0);
548 fTree->SetBranchStatus("runType.*",1);
549 fTree->SetBranchAddress("runType.",&runType);
550 for (Int_t iev=0;iev<nevets;++iev){
551 fTree->GetEntry(iev);
552 TString type=runType->String();
553 if (!type.IsNull()&&!fComboRunType->FindEntry(type)) fComboRunType->AddEntry(type,id++);
555 fTree->ResetBranchAddresses();
556 fTree->SetBranchStatus("*",1);
558 //______________________________________________________________________________
559 void AliTPCCalibViewerGUItime::FillCalibTypes()
562 // loop over configuration and fill calibration types
565 fListCalibType->RemoveAll();
567 fConfigParser->ResetIter();
569 while ( (o=fConfigParser->NextKey()) ){
570 type=fConfigParser->GetData(o,kCalibType);
571 //remove whitespcaces
572 type.Remove(TString::kBoth,' ');
573 type.Remove(TString::kBoth,'\t');
574 if (type.IsNull()) type="UNSPECIFIED";
575 // printf("CalibType: '%s'\n",type.Data());
576 if (!fListCalibType->FindEntry(type.Data())) {
577 fListCalibType->AddEntry(type.Data(),id);
578 fListCalibType->Select(id++);
581 //add type for unspecified calibration type
583 if (!fListCalibType->FindEntry(type.Data())) {
584 fListCalibType->AddEntry(type.Data(),id);
585 fListCalibType->Select(id++);
588 //______________________________________________________________________________
589 void AliTPCCalibViewerGUItime::CheckDrawGraph()
592 // Check whether to draw graphs in 2D mode based on the number of entries in the chain
593 // GetEstimate() returns the maximum size of the arrays stored in GetV1()...
597 if (fTree->GetEntries()<fTree->GetEstimate()) fNoGraph=kFALSE;
599 //______________________________________________________________________________
600 void AliTPCCalibViewerGUItime::Reload(Int_t first)
603 // reload the gui contents, this is needed after the input tree has changed
606 if ( !fTree ) return;
607 //in case of the first call create run type and calibration type entries
612 //activate all branches
613 fTree->SetBranchStatus("*",1);
614 //reset variables list
615 fListVariables->RemoveAll();
616 //get selected calibration types
618 fListCalibType->GetSelectedEntries(&calibTypes);
620 TObjArray *branchList = fTree->GetListOfBranches();
621 if ( !branchList ) return;
622 TIter nextBranch(branchList);
623 Int_t idCount=0,id=0;
624 TObject *objBranch=0;
625 while ( (objBranch=nextBranch()) ){
626 TString branchName(objBranch->GetName());
627 TString branchTitle(objBranch->GetName());
628 if (branchName == "run" || branchName == "time" || branchName == "runType.") continue;
630 TString calibType="UNSPECIFIED";
632 const TObject *key=(*fConfigParser)(branchName.Data());
634 //test if branch is active
635 active=fConfigParser->GetValue(branchName.Data(),kBranchOnOff);
636 id=(*fConfigParser)()->IndexOf(key);
637 // branchTitle=fConfigParser->GetData(key,kBranchTitle);
638 calibType=fConfigParser->GetData(key,kCalibType);
646 if (calibType.IsNull()) calibType="UNSPECIFIED";
647 //check if branch is in selected calibration types
648 //if not, don't show it in the list and deactivate the branch.
649 Bool_t calibActive=kFALSE;
650 TIter nextCalib(&calibTypes);
652 while ( (objCalib=nextCalib()) )
653 if (calibType==objCalib->GetTitle()) calibActive=kTRUE;
656 TString s=branchName;
657 if (branchName.EndsWith(".")) s+="*";
658 // fTree->SetBranchStatus(s.Data(),0);
661 // fListVariables->AddEntry(SubstituteUnderscores(branchTitle.Data()),id);
662 fListVariables->AddEntry(branchTitle.Data(),id);
665 //trick to display modifications
666 fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight());
667 fListVariables->Resize(fListVariables->GetWidth()+1, fListVariables->GetHeight());
669 //______________________________________________________________________________
670 void AliTPCCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const char* refName)
673 // map of reference trees that should always be attached to the CalibViewerGUI
675 fMapRefTrees->Add(new TObjString(refName), new TObjString(treeFileName));
678 //______________________________________________________________________________
679 const TString AliTPCCalibViewerGUItime::GetDrawString(){
681 // create draw string for ttree by combining the user requestsa
684 TString selectedVariable="";
686 if (!fListVariables->GetSelectedEntry()) return "";
687 selectedVariable = fListVariables->GetSelectedEntry()->GetTitle();
688 id=fListVariables->GetSelectedEntry()->EntryId();
689 // printf("id: %d\n",id);
690 TString branchName=selectedVariable;
692 const TObject *key=(*fConfigParser)(id);
693 if (key) branchName=(*fConfigParser)(id)->GetName();
695 //treat case of TVector
696 if (branchName.EndsWith(".")){
697 Int_t par = (Int_t)(fNmbPar->GetNumber());
698 branchName.Append(Form("fElements[%d]",par));
700 // if (fRadioXrun->GetState()==kButtonDown)
701 // selectedVariable.Append(":run");
702 // if (fRadioXtime->GetState()==kButtonDown)
703 // selectedVariable.Append(":time");
707 //______________________________________________________________________________
708 const TString AliTPCCalibViewerGUItime::GetDrawOptionString(){
710 // get user selected draw options
713 if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle();
714 if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase))
718 //______________________________________________________________________________
719 void AliTPCCalibViewerGUItime::GetCutString(TString &cutStr){
723 TCut cuts(fComboCustomCuts->GetTextEntry()->GetText());
725 if (fComboRunType->GetSelectedEntry()) runType=fComboRunType->GetSelectedEntry()->GetTitle();
726 if (runType!="ALL"&&!runType.IsNull()) cuts+=Form("runType.String().Data()==\"%s\"",runType.Data());
727 cutStr=cuts.GetTitle();
729 //______________________________________________________________________________
730 void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph, const Double_t *xArr)
736 fValuesX.ResizeTo(1);
737 fValuesY.ResizeTo(1);
738 fRunNumbers.ResizeTo(1);
739 fTimeStamps.ResizeTo(1);
741 const Long64_t nrows=fTree->GetSelectedRows();
742 fValuesX.ResizeTo(nrows);
743 fValuesY.ResizeTo(nrows);
744 fRunNumbers.ResizeTo(nrows);
745 fTimeStamps.ResizeTo(nrows);
746 long long *index=new long long[nrows];
750 for (Int_t i=0;i<fTree->GetSelectedRows();++i){
751 if (fTree->GetV2()[i]<1) ++nTime0;
754 if (nTime0==fTree->GetSelectedRows()){
755 TMath::Sort(nrows,fTree->GetV1(),index,kFALSE);
757 TMath::Sort(nrows,fTree->GetV2(),index,kFALSE);
760 Double_t lastRun=-1.;
762 const Bool_t drawSparse=(fRadioXrun->GetState()==kButtonDown && fChkDrawOptSparse->GetState()==kButtonDown);
763 for (Long64_t i=0; i<nrows; ++i){
764 // in case of sparse drawing only use the first entry per run
765 Double_t run = fTree->GetV1()[index[i]];
766 Double_t xval = xArr[index[i]];
769 if (TMath::Abs(lastRun-run)<.1) {
775 fValuesX.GetMatrixArray()[entries]=xval;
776 fValuesY.GetMatrixArray()[entries]=fTree->GetV3()[index[i]];
777 fRunNumbers.GetMatrixArray()[entries]=run;
778 fTimeStamps.GetMatrixArray()[entries]=fTree->GetV2()[index[i]];
784 fValuesX.ResizeTo(entries);
785 fValuesY.ResizeTo(entries);
786 fRunNumbers.ResizeTo(entries);
787 fTimeStamps.ResizeTo(entries);
788 // printf("entries: %d\n",entries);
794 //______________________________________________________________________________
795 void AliTPCCalibViewerGUItime::GetHistogramTitle(TString &title)
798 // Create string for histogram title
802 Int_t pos=title.First(">>");
803 if (pos>0) title=title(0,pos);
804 // if (!fIsCustomDraw){
805 if (fRadioXrun->GetState()==kButtonDown){
807 } else if (fRadioXtime->GetState()==kButtonDown){
813 TObjArray *arr=title.Tokenize(":");
818 TIter next(arr,kIterBackward);
819 while ( (o=next()) ){
820 TString varName=o->GetName();
822 //substitue variable names with names in configuration file if available
823 if ((*fConfigParser)()->GetEntries()){
824 TString branchName=varName;
826 if (branchName.Contains('.')) branchName=branchName(0,branchName.First('.')+1);
827 //chek if a configuration for that branch is available
828 const TObject *oBranch=(*fConfigParser)(branchName.Data());
830 TString branchTitle=fConfigParser->GetData(oBranch,kBranchTitle);
831 if (!branchTitle.IsNull()){
832 //check for TVectorT type branch
833 //add parameter name if available
834 if (varName.Contains("fElements")){
835 TString parStr=varName(varName.First('[')+1,varName.Length()-varName.First('[')-2);
838 TString yparname=fConfigParser->GetData(oBranch,par+kParamNames);
839 if (!yparname.IsNull()){
840 branchTitle+=yparname;
849 SubstituteUnderscores(varName);
856 //______________________________________________________________________________
857 void AliTPCCalibViewerGUItime::AdjustYRange()
862 TIter nextGraphicObject(fTrashBox);
865 while ( (o=nextGraphicObject()) ){
866 if (o->IsA()==TGraph::Class()){
867 TGraph *gr=(TGraph*)o;
869 min=TMath::MinElement(gr->GetN(),gr->GetY());
870 max=TMath::MaxElement(gr->GetN(),gr->GetY());
872 Float_t currmin=TMath::MinElement(gr->GetN(),gr->GetY());
873 Float_t currmax=TMath::MaxElement(gr->GetN(),gr->GetY());
874 if (currmax>max) max=currmax;
875 if (currmin<min) min=currmin;
880 if (min!=0) min=min-(max-min)/10;
881 if (max!=0) max=max+(max-min)/10;
882 fCurrentHist->SetMinimum(min);
883 fCurrentHist->SetMaximum(max);
886 //______________________________________________________________________________
887 void AliTPCCalibViewerGUItime::DoDraw() {
891 TString drawString=fDrawString;
893 GetCutString(cutString);
894 TString optString = GetDrawOptionString();
895 Bool_t graphOutput=!fNoGraph; //ttree buffer for V1, V2... too small
896 graphOutput&=(drawString.First(">>")<0); //histogram output in custom draw
897 graphOutput&=fRadioXhist->GetState()!=kButtonDown; //histogram drawing selected
898 // graphOutput&=!(fIsCustomDraw&&!fDrawString.Contains(":")); //custom draw 1D
899 // graphOutput&=fDrawString.CountChar(':')<2; //custom draw 1D
900 if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
901 if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
902 Bool_t drawSame=optString.Contains("same",TString::kIgnoreCase);
903 // optString+="goff";
905 drawString.Prepend("run:time:");
908 // if (!fIsCustomDraw){
909 if (fRadioXrun->GetState()==kButtonDown){
911 } else if (fRadioXtime->GetState()==kButtonDown){
916 TVirtualPad *padsave=gPad;
917 fCanvMain->GetCanvas()->cd();
918 //delete old histograms and graphs
924 // printf("%s (%s) [%s]\n",drawString.Data(), cutString.Data(), optString.Data());
926 fTree->Draw(drawString.Data(),cutString.Data(),optString.Data());
927 if (fTree->GetSelectedRows()==-1) return;
930 GetHistogramTitle(title);
931 Bool_t drawGraph=kFALSE;
935 if (fIsCustomDraw&&fDrawString.Contains(":")){
936 // fValuesX.SetElements(fTree->GetV4());
939 if (fRadioXrun->GetState()==kButtonDown){
940 // fValuesX.SetElements(fTree->GetV1());
942 } else if (fRadioXtime->GetState()==kButtonDown){
943 // fValuesX.SetElements(fTree->GetV2());
950 if (xArr) UpdateValueArrays(graphOutput, xArr);
952 // if (fIsCustomDraw){
953 // if (fDrawString.Contains(":")){
954 // fValuesX.SetElements(fTree->GetV4());
961 // if (fRadioXrun->GetState()==kButtonDown){
962 // fValuesX.SetElements(fTree->GetV1());
963 // } else if (fRadioXtime->GetState()==kButtonDown){
964 // fValuesX.SetElements(fTree->GetV2());
970 //create graph according to selection
972 TGraph *graph=new TGraph(fValuesX,fValuesY);
975 if (!drawSame) grDraw+="a";
976 if (!fIsCustomDraw) grDraw+="l";
977 // sparse drawing, set bin labels
978 if (fRadioXrun->GetState()==kButtonDown && fChkDrawOptSparse->GetState()==kButtonDown){
979 Int_t nrows=fValuesX.GetNrows();
980 Double_t *newBins = new Double_t[nrows+1];
981 for (Int_t ibin=0; ibin<nrows+1; ++ibin) newBins[ibin]=ibin;
982 graph->GetXaxis()->Set(nrows,newBins);
983 graph->GetXaxis()->LabelsOption("v");
984 for (Int_t i=0; i<nrows;++i)
985 graph->GetXaxis()->SetBinLabel(i+1,Form("%.0f",fRunNumbers.GetMatrixArray()[i]));
988 graph->Draw(grDraw.Data());
989 graph->SetEditable(kFALSE);
990 TH1 *hist=graph->GetHistogram();
991 hist->SetTitle(title.Data());
992 fTrashBox->Add(graph);
993 graph->SetLineColor(fTrashBox->GetEntries());
994 graph->SetMarkerColor(fTrashBox->GetEntries());
1000 TH1 *hist=fTree->GetHistogram();
1001 hist->SetTitle(title.Data());
1002 // hist->Draw(optString.Data());
1003 fTrashBox->Add(hist);
1004 hist->SetLineColor(fTrashBox->GetEntries());
1005 hist->SetMarkerColor(fTrashBox->GetEntries());
1006 if (!drawSame) fCurrentHist=hist;
1009 //Set time axis if choosen as x-variables
1010 // if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw&&!drawSame){
1011 if (fRadioXtime->GetState()==kButtonDown&&!drawSame){
1012 TAxis *xaxis=fCurrentHist->GetXaxis();
1013 xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}");
1014 xaxis->SetTimeDisplay(1);
1015 xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3);
1016 xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3);
1020 fCurrentHist->GetYaxis()->SetTitleOffset(1.5);
1030 //______________________________________________________________________________
1031 void AliTPCCalibViewerGUItime::DoDumpRuns()
1034 // Dump the current run numbers to stdout
1036 Int_t npoints=fRunNumbers.GetNrows();
1037 Int_t *sortIndex = new Int_t[npoints];
1038 TMath::Sort(npoints,fRunNumbers.GetMatrixArray(),sortIndex,kFALSE);
1039 Int_t run=0, prevRun=-1;
1041 for (Int_t irun=0;irun<npoints;++irun){
1042 run=(Int_t)fRunNumbers.GetMatrixArray()[sortIndex[irun]];
1043 if (run!=prevRun) std::cout << Form("%d",run) << std::endl;
1046 delete [] sortIndex;
1048 //______________________________________________________________________________
1049 void AliTPCCalibViewerGUItime::DoParLimitChange()
1057 //______________________________________________________________________________
1058 void AliTPCCalibViewerGUItime::DoNewSelection() {
1060 // decides whether to redraw if user makes another selection
1063 fDrawString=GetDrawString();
1064 fIsCustomDraw=kFALSE;
1067 //______________________________________________________________________________
1068 void AliTPCCalibViewerGUItime::DoCustomDraw()
1073 fDrawString=fComboCustomDraw->GetTextEntry()->GetText();
1074 // if (fDrawString.Contains(">>")){
1075 // Warning("DoCustomDraw","Currently no user defined histograms allowed!");
1078 fNmbPar->SetState(kFALSE);
1079 fIsCustomDraw=kTRUE;
1082 //______________________________________________________________________________
1083 void AliTPCCalibViewerGUItime::DoCustomCutsDraw()
1088 if (fIsCustomDraw) DoCustomDraw();
1090 fDrawString=GetDrawString();
1091 fIsCustomDraw=kFALSE;
1095 //______________________________________________________________________________
1096 void AliTPCCalibViewerGUItime::HandleButtonsDrawSel(Int_t id)
1099 // Draw selection button handling (x-variable)
1103 TGButton *btn = (TGButton *) gTQSender;
1104 id = btn->WidgetId();
1107 Bool_t doDraw=kFALSE;
1108 Bool_t noDraw=kFALSE;
1115 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
1117 fRadioXrun->SetState(kButtonUp);
1118 fRadioXtime->SetState(kButtonUp);
1119 fRadioXhist->SetState(kButtonDown);
1123 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXhist->GetState()==kButtonDown);
1125 fRadioXhist->SetState(kButtonUp);
1126 fRadioXtime->SetState(kButtonUp);
1127 fRadioXrun->SetState(kButtonDown);
1131 doDraw=(fRadioXhist->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
1133 fRadioXrun->SetState(kButtonUp);
1134 fRadioXhist->SetState(kButtonUp);
1135 fRadioXtime->SetState(kButtonDown);
1139 if (doDraw&&!noDraw) DoCustomCutsDraw();
1141 //______________________________________________________________________________
1142 void AliTPCCalibViewerGUItime::UpdateParName()
1145 // change parameter name
1148 Int_t par = (Int_t)(fNmbPar->GetNumber());
1150 Int_t id=fListVariables->GetSelectedEntry()->EntryId();
1151 if (fConfigParser && (*fConfigParser)(id)) parName=fConfigParser->GetData((*fConfigParser)(id),par+kParamNames);
1152 if (parName=="") parName.Form("%d",par);
1153 fLblPar->SetText(Form("Parameter: %s",parName.Data()));
1154 fDrawString=GetDrawString();
1155 fIsCustomDraw=kFALSE;
1158 //______________________________________________________________________________
1159 void AliTPCCalibViewerGUItime::UpdateParLimits()
1162 // Adjust limits for TVectorT based variables
1165 TString selectedVariableTitle="";
1167 if (!fListVariables->GetSelectedEntry()) return;
1168 selectedVariableTitle = fListVariables->GetSelectedEntry()->GetTitle();
1169 id=fListVariables->GetSelectedEntry()->EntryId();
1170 // printf("id: %d\n",id);
1171 TString selectedVariable=selectedVariableTitle;
1172 const TObject *key=(*fConfigParser)(id);
1173 if (key) selectedVariable=(*fConfigParser)(id)->GetName();
1175 if (selectedVariable.IsNull()||!selectedVariable.EndsWith(".")) {
1176 fNmbPar->SetState(kFALSE);
1177 fLblPar->SetText("Parameter: none");
1184 TBranch *branch=fTree->GetTree()->GetBranch(selectedVariable.Data());
1185 TString branchClass=branch->GetClassName();
1187 if (branchClass=="TVectorT<double>"){
1188 // branch->SetAddress(&vD);
1189 fTree->SetBranchAddress(selectedVariable.Data(),&vD);
1190 while (maxPar<2&&event<fTree->GetEntries()){
1191 fTree->GetEntry(event++);
1192 maxPar=vD->GetNrows();
1194 } else if (branchClass=="TVectorT<float>"){
1195 // branch->SetAddress(&vF);
1196 fTree->SetBranchAddress(selectedVariable.Data(),&vF);
1197 while (maxPar<2&&event<fTree->GetEntries()){
1198 fTree->GetEntry(event++);
1199 maxPar=vF->GetNrows();
1203 fNmbPar->SetState(kFALSE);
1206 // branch->ResetAddress();
1207 fTree->SetBranchAddress(selectedVariable.Data(),0x0);
1208 if (fNmbPar->GetNumMax()!=maxPar-1) fNmbPar->SetNumber(0);
1209 fNmbPar->SetLimitValues(0,maxPar-1);
1210 fNmbPar->SetState(kTRUE);
1213 //______________________________________________________________________________
1214 void AliTPCCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/)
1217 // handle mouse events in the draw canvas
1219 UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0;
1220 Double_t valx=0.,valy=0.;
1221 if (!fCurrentGraph) {
1222 fLblRunNumberVal->SetText(Form("%06u",run));
1223 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS));
1224 fLblValueXVal->SetText(Form("%.3e", valx));
1225 fLblValueYVal->SetText(Form("%.3e", valy));
1228 TVirtualPad *padsave=gPad;
1229 fCanvMain->GetCanvas()->cd();
1230 Int_t n=fValuesY.GetNrows();
1232 arr=fValuesX.GetMatrixArray();
1234 Int_t minDist=1000000;
1236 for (Int_t i=0;i<n;++i){
1237 Int_t pxp = gPad->XtoAbsPixel(gPad->XtoPad(arr[i]));
1238 Int_t pyp = gPad->YtoAbsPixel(gPad->YtoPad(fValuesY[i]));
1239 Int_t d = TMath::Nint(TMath::Sqrt(TMath::Abs(pxp-x) + TMath::Abs(pyp-y)));
1246 TTimeStamp t((Int_t)fTimeStamps[minPoint]);
1247 t.GetDate(kTRUE,0,&yy,&mm,&dd);
1248 t.GetTime(kTRUE,0,&HH,&MM,&SS);
1249 run=(UInt_t)fRunNumbers[minPoint];
1250 valx=fValuesX[minPoint];
1251 valy=fValuesY[minPoint];
1253 dd=0;mm=0;yy=0;HH=0;MM=0;SS=0;run=0;
1257 fLblRunNumberVal->SetText(Form("%06u",run));
1258 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS));
1260 fLblValueXVal->SetText(Form("%.3e", valx));
1262 if (fRadioXrun->GetState()==kButtonDown){
1263 fLblValueXVal->SetText("Run");
1264 } else if (fRadioXtime->GetState()==kButtonDown){
1265 fLblValueXVal->SetText("Time");
1268 fLblValueYVal->SetText(Form("%.3e", valy));
1271 if (event == kButton1Double ){
1274 //find closes point of current selection
1276 //______________________________________________________________________________
1277 void AliTPCCalibViewerGUItime::SetGuiTree(Int_t run)
1280 // create the AliTPCCalibViewerGUI tree for run
1281 // cache tree in directory fOutputCacheDir
1282 // retrieve file from this directory if it already exists
1286 //Create and set GUI tree
1288 //try to find file for run in fOutputCacheDir
1289 TString fileName=fOutputCacheDir;
1290 if (!fileName.EndsWith("/")) fileName+="/";
1291 fileName+=Form("guiTreeRun_%d.root",run);
1293 if (gSystem->AccessPathName(fileName.Data())){
1294 load=AliTPCcalibDB::CreateGUITree(run,fileName.Data());
1296 fCalibViewerGUI->Reset();
1297 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX")));
1301 fCalibViewerGUI->Initialize(fileName.Data());
1302 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run)));
1305 //Create and set Reference GUI tree
1307 AliTPCcalibDButil util;
1308 util.SetReferenceRun(run);
1309 fileName=fOutputCacheDir;
1310 if (!fileName.EndsWith("/")) fileName+="/";
1311 fileName+=util.GetGUIRefTreeDefaultName();
1312 //only update if file does not exist
1313 if (gSystem->AccessPathName(fileName.Data())){
1314 util.UpdateRefDataFromOCDB();
1315 util.CreateGUIRefTree(fileName.Data());
1318 fCalibViewerGUI->GetViewer()->AddReferenceTree(fileName.Data(),"calPads","Ref");
1321 // Process additional reference trees
1323 TIter nextRefTree(fMapRefTrees);
1325 //Set static reference data
1326 while ( (o=nextRefTree()) ){
1327 fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"calPads",o->GetName());
1329 fCalibViewerGUI->Reload();
1331 //______________________________________________________________________________
1332 void AliTPCCalibViewerGUItime::SubstituteUnderscores(TString &s)
1337 s.ReplaceAll("_{","|{");
1338 s.ReplaceAll("_"," ");
1339 s.ReplaceAll("|{","_{");
1342 //______________________________________________________________________________
1343 void AliTPCCalibViewerGUItime::DoNewSelectionAliases()
1349 TList *l=fTree->GetListOfAliases();
1351 TString selectedVariable="";
1352 if (!fListAliases->GetSelectedEntry()) return;
1353 selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
1354 fDrawString=selectedVariable;
1355 fIsCustomDraw=kFALSE;
1358 //______________________________________________________________________________
1359 void AliTPCCalibViewerGUItime::DoAddAlias()
1364 new AliTPCCalibViewerGUItimeAddAliasFrame(gClient->GetRoot(), fContTopBottom, 400, 200, kVerticalFrame, this);
1366 //______________________________________________________________________________
1367 void AliTPCCalibViewerGUItime::DoDelAlias()
1373 TList *l=fTree->GetListOfAliases();
1375 TString selectedVariable="";
1376 if (!fListAliases->GetSelectedEntry()) return;
1377 selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
1378 l->Remove(l->FindObject(selectedVariable.Data()));
1382 //______________________________________________________________________________
1383 void AliTPCCalibViewerGUItime::UpdateAliasList()
1388 printf("UpdateAliasList\n");
1390 TList *l=fTree->GetListOfAliases();
1394 fListAliases->RemoveAll();
1396 while( (o=nextAlias()) ){
1397 fListAliases->AddEntry(o->GetName(),id++);
1399 fListAliases->Resize(fListAliases->GetWidth()-1, fListAliases->GetHeight());
1400 fListAliases->Resize(fListAliases->GetWidth()+1, fListAliases->GetHeight());
1402 //______________________________________________________________________________
1403 TObjArray* AliTPCCalibViewerGUItime::ShowGUI(const char* fileName, const char* treeName) {
1405 // Initialize and show GUI for presentation for demonstration purposes
1406 // or for fast standalone use
1408 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1409 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1410 frmMain->SetCleanup(kDeepCleanup);
1412 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1413 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1415 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1416 TGCompositeFrame* tabCont2 = tabMain->AddTab("Detail - XXXXX");
1418 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1419 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1420 calibViewerTime->SetConfigFileName("$ALICE_ROOT/TPC/CalibMacros/calibVarDescription.txt");
1421 calibViewerTime->UseFile(fileName, treeName);
1423 AliTPCCalibViewerGUI* calibViewer = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, 0);
1424 tabCont2->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1425 calibViewerTime->SetCalibViewerGUI(calibViewer);
1426 calibViewerTime->SetCalibViewerGUItab(tabMain->GetTabTab(1));
1429 TObjArray *guiArray = new TObjArray();
1430 guiArray->Add(calibViewerTime);
1431 guiArray->Add(calibViewer);
1433 frmMain->MapSubwindows();
1435 frmMain->MapWindow();
1440 //______________________________________________________________________________
1441 TObjArray* AliTPCCalibViewerGUItime::ShowGUI(TChain *chain) {
1443 // Initialize and show GUI for presentation for demonstration purposes
1444 // or for fast standalone use
1446 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1447 frmMain->SetWindowName("AliTPCCalibViewer GUItime");
1448 frmMain->SetCleanup(kDeepCleanup);
1450 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1451 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1453 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1455 AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
1456 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1457 calibViewerTime->UseChain(chain);
1459 TObjArray *guiArray = new TObjArray();
1460 guiArray->Add(calibViewerTime);
1462 frmMain->MapSubwindows();
1464 frmMain->MapWindow();
1470 ////////////////////////////////////////////////////////////////////////
1474 ////////////////////////////////////////////////////////////////////////
1477 ClassImp(AliTPCCalibViewerGUItimeAddAliasFrame)
1479 AliTPCCalibViewerGUItimeAddAliasFrame::AliTPCCalibViewerGUItimeAddAliasFrame(const TGWindow *p, const TGWindow *main,
1480 UInt_t w, UInt_t h, UInt_t options,
1481 AliTPCCalibViewerGUItime *gui, TString strAlias) :
1487 fMain = new TGTransientFrame(p, main, w, h, options);
1488 fMain->Connect("CloseWindow()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
1489 fMain->DontCallClose(); // to avoid double deletions.
1491 // use hierarchical cleaning
1492 fMain->SetCleanup(kDeepCleanup);
1495 TGLayoutHints *l1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
1496 TGLayoutHints *l2 = new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX, 2, 2, 0, 5);
1497 // TGLayoutHints *l3 = new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5);
1500 TGCompositeFrame *f1 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame);
1501 fMain->AddFrame(f1, l1);
1502 TGCompositeFrame *frameName = new TGCompositeFrame(f1);
1503 TGCompositeFrame *frameFormula = new TGCompositeFrame(f1);
1504 f1->AddFrame(frameName,l2);
1505 f1->AddFrame(frameFormula,l2);
1506 TGLabel *lblTxt1 = new TGLabel(frameName, "Name:");
1507 TGLabel *lblTxt2 = new TGLabel(frameFormula, "Formula:");
1508 fTxt1 = new TGTextEntry(frameName, new TGTextBuffer(1000));
1509 fTxt2 = new TGTextEntry(frameFormula, new TGTextBuffer(1000));
1511 frameName->AddFrame(lblTxt1, l2);
1512 frameName->AddFrame(fTxt1, l2);
1513 frameFormula->AddFrame(lblTxt2, l2);
1514 frameFormula->AddFrame(fTxt2, l2);
1516 fTxt1->Resize(350, fTxt1->GetDefaultHeight());
1517 fTxt2->Resize(350, fTxt2->GetDefaultHeight());
1519 //ok and cancel buttons
1520 TGHorizontalFrame *frame = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
1522 TGTextButton *okButton = new TGTextButton(frame, "&Ok", 1);
1523 okButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoOK()");
1524 TGTextButton *cancelButton = new TGTextButton(frame, "&Cancel", 2);
1525 cancelButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
1528 frame->AddFrame(okButton, l1);
1529 frame->AddFrame(cancelButton, l1);
1531 frame->Resize(150, okButton->GetDefaultHeight());
1533 fMain->AddFrame(frame, new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1));
1536 TString aliasName, alias;
1537 if (!strAlias.IsNull()){
1538 TChain *c=fGUI->GetChain();
1540 TList *l=c->GetListOfAliases();
1542 TNamed *d=(TNamed*)l->FindObject(strAlias);
1544 aliasName=d->GetName();
1545 alias=d->GetTitle();
1550 alias=fGUI->GetCustomDrawString();
1552 fTxt1->SetText(aliasName.Data(),kFALSE);
1553 fTxt2->SetText(alias.Data(),kFALSE);
1555 fMain->MapSubwindows();
1558 // position relative to the parent's window
1559 fMain->CenterOnParent();
1561 fMain->SetWindowName("Alias Editor");
1566 //______________________________________________________________________________
1567 AliTPCCalibViewerGUItimeAddAliasFrame::~AliTPCCalibViewerGUItimeAddAliasFrame()
1572 fMain->DeleteWindow(); // deletes fMain
1574 //______________________________________________________________________________
1575 void AliTPCCalibViewerGUItimeAddAliasFrame::DoOK()
1580 TString aliasName=fTxt1->GetText();
1581 TString alias=fTxt2->GetText();
1582 if (!aliasName.IsNull()&&!alias.IsNull()){
1583 TChain *c=fGUI->GetChain();
1585 c->SetAlias(aliasName.Data(),alias.Data());
1588 fGUI->UpdateAliasList();
1591 //______________________________________________________________________________
1592 void AliTPCCalibViewerGUItimeAddAliasFrame::DoCancel()