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 ///////////////////////////////////////////////////////////////////////////////
19 // GUI for displaying calibration entries over time //
21 // Authors: Marian Ivanov (Marian.Ivanov@cern.ch) //
22 // Jens Wiechula (Jens.Wiechula@cern.ch) //
23 // Ionut Arsene (iarsene@cern.ch) //
25 // Usage: AliCalibViewerGUItime::ShowGUI(TChain* chain) //
26 // AliCalibViewerGUItime::ShowGUI() //
27 ///////////////////////////////////////////////////////////////////////////////
33 #include <TDirectory.h>
37 #include <TVirtualPad.h>
39 #include <TObjArray.h>
40 #include <TObjString.h>
49 #include <TIterator.h>
52 #include <TTimeStamp.h>
56 #include <TGFileDialog.h>
57 #include <TGInputDialog.h>
60 #include <TGListBox.h>
61 #include <TGComboBox.h>
62 #include <TGNumberEntry.h>
64 #include <TRootEmbeddedCanvas.h>
65 #include <TGSplitter.h>
66 #include <TGButtonGroup.h>
73 #include "AliBaseCalibViewer.h"
74 #include "AliBaseCalibViewerGUI.h"
75 #include "AliCalibViewerGUItime.h"
78 ClassImp(AliCalibViewerGUItime)
80 //_______________________________________________________________________________________________________________
81 AliCalibViewerGUItime::AliCalibViewerGUItime(const TGWindow *p, UInt_t w, UInt_t h, const Char_t* det) :
82 TGCompositeFrame(p,w,h),
87 fCalibViewerGUItab(0x0),
90 fCurrentRunDetails(-1),
91 fOutputCacheDir("/tmp"),
93 fIsCustomDraw(kFALSE),
99 fGraphLimitEntries(10000),
100 fMapRefTrees(new TMap),
102 //main canvas Top part, bottom part
104 //top left, centre, right
109 fChkDrawOptSame(0x0),
110 fComboAddDrawOpt(0x0),
112 fContDrawSelSubRunTime(0x0),
133 fLblRunNumberVal(0x0),
142 fContConfigFile(0x0),
149 // extract information from OCDB
152 fContCustomCuts(0x0),
155 fComboCustomDraw(0x0),
156 fComboCustomCuts(0x0),
157 fTrashBox(new TObjArray)
163 fMapRefTrees->SetOwnerKeyValue();
164 fTrashBox->SetOwner();
166 gStyle->SetMarkerStyle(20);
167 gStyle->SetMarkerSize(0.5);
171 //______________________________________________________________________________
172 AliCalibViewerGUItime::~AliCalibViewerGUItime(){
176 // delete fConfigParser;
181 //______________________________________________________________________________
182 void AliCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) {
186 // ======================================================================
187 // ************************* Display everything *************************
188 // ======================================================================
190 SetCleanup(kDeepCleanup);
192 // *****************************************************************************
193 // ************************* content of this MainFrame *************************
194 // *****************************************************************************
195 // top level container with horizontal layout
196 fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
197 AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
199 fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
200 fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
202 // ***********************************************************************
203 // ************************* content of fContLCR *************************
204 // ***********************************************************************
206 fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
207 fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
209 // left vertical splitter
210 TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
211 splitLeft->SetFrame(fContLeft, kTRUE);
212 fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
215 fContRight = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
216 fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
219 fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
220 fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
222 // right vertical splitter
223 TGVSplitter *splitRight = new TGVSplitter(fContLCR);
224 splitRight->SetFrame(fContRight, kFALSE);
225 fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
228 // ========================================================================
229 // ************************* content of fContLeft *************************
230 // ========================================================================
231 // --- draw button and tabLeft ---
233 fContDrawOpt = new TGGroupFrame(fContLeft, "Draw options", kVerticalFrame | kFitWidth | kFitHeight);
234 fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
235 fChkDrawOptSame = new TGCheckButton(fContDrawOpt, "Same");
236 fContDrawOpt->AddFrame(fChkDrawOptSame, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
237 fChkDrawOptSame->SetToolTipText("Add draw option 'same'");
238 // additional draw options combo box
239 fComboAddDrawOpt = new TGComboBox(fContDrawOpt);
240 fComboAddDrawOpt->Resize(0, 22);
241 fComboAddDrawOpt->EnableTextInput(kTRUE);
242 fContDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
244 // draw selection group
245 fContDrawSel = new TGGroupFrame(fContLeft, "Draw selection", kVerticalFrame | kFitWidth | kFitHeight);
246 fContLeft->AddFrame(fContDrawSel, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
247 //x-axis variables selection, Run of Time
248 fContDrawSelSubRunTime = new TGCompositeFrame(fContDrawSel, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
249 fContDrawSel->AddFrame(fContDrawSelSubRunTime, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
251 // ------------------------- content of fContDrawOpt -------------------------
255 fRadioXhist = new TGRadioButton(fContDrawSelSubRunTime, "hist", kRadioXhist);
256 fContDrawSelSubRunTime->AddFrame(fRadioXhist, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
257 fRadioXhist->Connect("Clicked()", "AliCalibViewerGUItime", this, "HandleButtonsDrawSel()");
258 fRadioXhist->SetToolTipText("Draw the distribution of the variable");
260 fRadioXrun = new TGRadioButton(fContDrawSelSubRunTime, ":Run", kRadioXrun);
261 fContDrawSelSubRunTime->AddFrame(fRadioXrun, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
262 fRadioXrun->Connect("Clicked()", "AliCalibViewerGUItime", this, "HandleButtonsDrawSel()");
263 fRadioXrun->SetToolTipText("Use run number as x-value");
266 fRadioXtime = new TGRadioButton(fContDrawSelSubRunTime, ":Time", kRadioXtime);
267 fContDrawSelSubRunTime->AddFrame(fRadioXtime, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
268 fRadioXtime->Connect("Clicked()", "AliCalibViewerGUItime", this, "HandleButtonsDrawSel()");
269 fRadioXtime->SetToolTipText("Use time stamp number as x-value");
273 fListVariables = new TGListBox(fContDrawSel);
274 fContDrawSel->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
275 fListVariables->Connect("Selected(Int_t)", "AliCalibViewerGUItime", this, "DoNewSelection()");
278 //-------------------- run type selection ------------------------
280 fLblRunType = new TGLabel(fContDrawSel, "Run Type:");
281 fLblRunType->SetTextJustify(kTextLeft);
282 fContDrawSel->AddFrame(fLblRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
284 fComboRunType = new TGComboBox(fContDrawSel);
285 fComboRunType->EnableTextInput(kFALSE);
286 fContDrawSel->AddFrame(fComboRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
287 fComboRunType->Connect("Selected(Int_t)", "AliCalibViewerGUItime", this, "DoDraw()");
288 fComboRunType->Resize(0, 22);
290 //-------------------- parameter selection ------------------------
292 fLblPar = new TGLabel(fContDrawSel, "Parameter:");
293 fLblPar->SetTextJustify(kTextLeft);
294 fContDrawSel->AddFrame(fLblPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
296 fNmbPar = new TGNumberEntry(fContDrawSel, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
297 fContDrawSel->AddFrame(fNmbPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
298 fNmbPar->Connect("ValueSet(Long_t)", "AliCalibViewerGUItime", this, "DoParLimitChange()");
299 fNmbPar->SetState(kFALSE);
301 //-------------------- calibration type selection ------------------------
303 // draw selection group
304 fContCalibType = new TGGroupFrame(fContLeft, "Calib type selection", kVerticalFrame | kFitWidth | kFitHeight);
305 fContLeft->AddFrame(fContCalibType, new TGLayoutHints(kLHintsExpandX , 0, 0, 10, 0));
308 fListCalibType = new TGListBox(fContCalibType);
309 fContCalibType->AddFrame(fListCalibType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX , 0, 0, 0, 0));
310 fListCalibType->Connect("Selected(Int_t)", "AliCalibViewerGUItime", this, "DoChangeSelectionList()");
311 fListCalibType->Resize(0,88);
312 fListCalibType->SetMultipleSelections();
315 // ==========================================================================
316 // ************************* content of fContCenter *************************
317 // ========================================================================
318 // main drawing canvas
319 fCanvMain = new TRootEmbeddedCanvas("GUItime_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
320 fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
321 fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliCalibViewerGUItime", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
322 fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed.");
323 fCanvMain->GetCanvas()->SetRightMargin(0.062);
324 fCanvMain->GetCanvas()->SetLeftMargin(0.15);
326 // =========================================================================
327 // ************************* content of fContRight *************************
328 // ========================================================================
329 //group frame for value information
330 fContValues = new TGGroupFrame(fContRight, "Data point info", kVerticalFrame | kFitWidth | kFitHeight);
331 fContRight->AddFrame(fContValues, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
333 fContValues->SetLayoutManager(new TGMatrixLayout(fContValues, 0, 2, 4));
334 //value information labels
337 fLblRunNumber = new TGLabel(fContValues, "Run:");
338 fLblRunNumber->SetTextJustify(kTextLeft);
339 fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
341 fLblRunNumberVal = new TGLabel(fContValues, "0000000");
342 fLblRunNumberVal->SetTextJustify(kTextLeft);
343 fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
345 fLblRunTime = new TGLabel(fContValues, "Time:");
346 fLblRunTime->SetTextJustify(kTextLeft);
347 fContValues->AddFrame(fLblRunTime, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
349 fLblRunTimeVal = new TGLabel(fContValues, "00.00.0000\n00:00:00");
350 fLblRunTimeVal->SetTextJustify(kTextLeft);
351 fContValues->AddFrame(fLblRunTimeVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
353 fLblValueX = new TGLabel(fContValues, "x-Value:");
354 fLblValueX->SetTextJustify(kTextLeft);
355 fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
357 fLblValueXVal = new TGLabel(fContValues, "00.000e+00");
358 fLblValueXVal->SetTextJustify(kTextRight);
359 fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
361 fLblValueY = new TGLabel(fContValues, "y-Value:");
362 fLblValueY->SetTextJustify(kTextLeft);
363 fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
365 fLblValueYVal = new TGLabel(fContValues, "00.000e+00");
366 fLblValueYVal->SetTextJustify(kTextRight);
367 fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
369 fBtnDumpRuns = new TGTextButton(fContRight, "&Dump runs");
370 fContRight->AddFrame(fBtnDumpRuns, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
371 fBtnDumpRuns->Connect("Clicked()", "AliCalibViewerGUItime", this, "DoDumpRuns()");
372 fBtnDumpRuns->SetToolTipText("Press to dump the run numbers of the current selection.");
374 fBtnSave = new TGTextButton(fContRight, "&Save picture");
375 fContRight->AddFrame(fBtnSave, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
376 fBtnSave->SetToolTipText("Press to save the current picture in the canvas");
377 fBtnSave->Connect("Clicked()", "AliCalibViewerGUItime", this, "SavePicture()");
379 //group frame for loading a file
380 fContLoad = new TGGroupFrame(fContRight, "Load file", kVerticalFrame | kFitWidth | kFitHeight);
381 fContRight->AddFrame(fContLoad, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
383 fContFilename = new TGCompositeFrame(fContLoad, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
384 fContLoad->AddFrame(fContFilename, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0));
386 fTxtFilename = new TGTextEntry(fContFilename, "Input file", 100);
387 fContFilename->AddFrame(fTxtFilename, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
388 fTxtFilename->Connect("DoubleClicked()", "AliCalibViewerGUItime", this, "HandleLoadRunTextEntry()");
390 fContTreeName = new TGCompositeFrame(fContLoad, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
391 fContLoad->AddFrame(fContTreeName, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0));
393 fLblTreeName = new TGLabel(fContTreeName, "Tree Name:");
394 fLblTreeName->SetTextJustify(kTextLeft);
395 fContTreeName->AddFrame(fLblTreeName, new TGLayoutHints(kLHintsNormal | kLHintsCenterY, 0, 1, 0, 0));
397 fTxtTreeName = new TGTextEntry(fContTreeName, "trdTree");
398 if(fDetector.Contains("TPC")) fTxtTreeName->SetText("dcs");
399 fContTreeName->AddFrame(fTxtTreeName, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
401 fBtnLoadFile = new TGTextButton(fContLoad, "Load file", 100);
402 fContLoad->AddFrame(fBtnLoadFile, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
403 fBtnLoadFile->SetToolTipText("Load a file into viewer");
404 fBtnLoadFile->Connect("Clicked()", "AliCalibViewerGUItime", this, "HandleLoadRunButtons()");
406 // =========================================================================
407 // ****************** bottom content of fContTopBottom *********************
408 // =========================================================================
410 // custom options container
411 // --- fComboCustom --- the custom draw line on the very low
412 fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
413 fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
415 // ------------------------- content of fContCustom -------------------------
416 fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: ");
417 fLblCustomDraw->SetTextJustify(kTextLeft);
418 fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
419 // text field for custom draw command
420 fComboCustomDraw = new TGComboBox(fContCustom);
421 fComboCustomDraw->Resize(0, 22);
422 fComboCustomDraw->EnableTextInput(kTRUE);
423 fContCustom->AddFrame(fComboCustomDraw, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
424 fComboCustomDraw->Connect("ReturnPressed()", "AliCalibViewerGUItime", this, "DoCustomDraw()");
425 fComboCustomDraw->Connect("Selected(Int_t)", "AliCalibViewerGUItime", this, "DoCustomDraw()");
428 // additional cuts container
429 fContCustomCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
430 fContTopBottom->AddFrame(fContCustomCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
432 // ------------------------- content of fContCustomCuts -------------------------
433 fLblCustomCuts = new TGLabel(fContCustomCuts, "Custom cuts: ");
434 fLblCustomCuts->SetTextJustify(kTextLeft);
435 fContCustomCuts->AddFrame(fLblCustomCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
436 // combo text field for additional cuts
437 fComboCustomCuts = new TGComboBox(fContCustomCuts);
438 // fComboCustomCuts->Resize(0, fLblValueY->GetDefaultHeight());
439 fComboCustomCuts->Resize(0, 22);
440 fComboCustomCuts->EnableTextInput(kTRUE);
441 fContCustomCuts->AddFrame(fComboCustomCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
442 fComboCustomCuts->Connect("ReturnPressed()", "AliCalibViewerGUItime", this, "DoCustomCutsDraw()");
443 fComboCustomCuts->Connect("Selected(Int_t)", "AliCalibViewerGUItime", this, "DoCustomCutsDraw()");
445 if(fDetector.Contains("TPC")) SetWindowName("AliTPCCalibViewer GUI - Time");
446 else if (fDetector.Contains("TRD")) SetWindowName("AliTRDCalibViewer GUI - Time");
447 else SetWindowName("Unknown detector");
449 Resize(GetDefaultSize());
453 //______________________________________________________________________________
454 void AliCalibViewerGUItime::SetInitialValues(){
456 // Set inital selections of the gui
458 fRadioXrun->SetState(kButtonDown);
459 fRadioXtime->SetState(kButtonUp);
462 //______________________________________________________________________________
463 void AliCalibViewerGUItime::UseFile(const char* fileName, const char* treeName) {
465 // retrieve tree from file
468 TObjArray *arr=s.Tokenize(" ");
471 if (fTree) delete fTree;
472 fTree=new TChain(treeName);
473 while ( (o=next()) ){
474 TString tmpString(o->GetName());
475 std::cout << "Adding " << tmpString.Data() << " to the chain" << std::endl;
476 if(tmpString.Contains(".root"))
477 fTree->AddFile(tmpString.Data());
479 tmpString += "/*.root";
480 fTree->Add(tmpString.Data());
486 // UseConfigFile(fConfigFile.Data());
491 //______________________________________________________________________________
492 void AliCalibViewerGUItime::UseChain(TChain* chain)
499 std::cout << "AliCalibViewerGUItime::UseChain !checkchain OUT" << std::endl;
502 //set configuration file
503 // UseConfigFile(fConfigFile.Data());
508 //______________________________________________________________________________
509 Bool_t AliCalibViewerGUItime::CheckChain()
512 // check whether cahin has entries
513 // decide whether to draw graphs in 2D
519 Long64_t entries=fTree->GetEntries();
521 AliError("No entries found in chain");
524 //check whether to draw graphs
529 //______________________________________________________________________________
530 void AliCalibViewerGUItime::FillRunTypes()
533 //Loop over the tree entries and fill the run types
539 fComboRunType->RemoveAll();
540 fComboRunType->AddEntry("ALL",id++);
541 fComboRunType->Select(0,kFALSE);
542 if (!fTree->GetBranch("runType.")) {
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);
559 //______________________________________________________________________________
560 void AliCalibViewerGUItime::FillCalibTypes()
563 // loop over configuration and fill calibration types
566 fListCalibType->RemoveAll();
568 // fConfigParser->ResetIter();
569 TString type="UNSPECIFIED";
570 fListCalibType->AddEntry(type.Data(),id);
571 fListCalibType->Select(id++);
574 //______________________________________________________________________________
575 void AliCalibViewerGUItime::CheckDrawGraph()
578 // Check whether to draw graphs in 2D mode based on the number of entries in the chain
579 // GetEstimate() returns the maximum size of the arrays stored in GetV1()...
585 if (fTree->GetEntries()<fTree->GetEstimate()) fNoGraph=kFALSE;
588 //______________________________________________________________________________
589 void AliCalibViewerGUItime::Reload(Int_t first)
592 // reload the gui contents, this is needed after the input tree has changed
601 //activate all branches
602 fTree->SetBranchStatus("*",1);
603 //reset variables list
604 fListVariables->RemoveAll();
605 //get selected calibration types
607 fListCalibType->GetSelectedEntries(&calibTypes);
609 TObjArray *branchList = fTree->GetListOfBranches();
610 if ( !branchList ) return;
611 TIter nextBranch(branchList);
612 Int_t idCount=0,id=0;
613 TObject *objBranch=0;
614 while ( (objBranch=nextBranch()) ){
615 TString branchName(objBranch->GetName());
616 TString branchTitle(objBranch->GetName());
617 if (branchName == "run" || branchName == "time" || branchName == "runType.") continue;
619 TString 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;
631 TString s=branchName;
632 if (branchName.EndsWith(".")) s+="*";
633 fTree->SetBranchStatus(s.Data(),0);
636 fListVariables->AddEntry(SubstituteUnderscores(branchTitle.Data()),id);
637 //fListVariables->Select(id);
640 //trick to display modifications
641 fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight());
642 fListCalibType->Resize(fListCalibType->GetWidth()+1, fListCalibType->GetHeight());
645 //______________________________________________________________________________
646 void AliCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const char* refName)
649 // map of reference trees that should always be attached to the CalibViewerGUI
651 fMapRefTrees->Add(new TObjString(refName), new TObjString(treeFileName));
654 //______________________________________________________________________________
655 const char* AliCalibViewerGUItime::GetDrawString(){
657 // create draw string for ttree by combining the user requestsa
660 TString selectedVariable="";
662 if (!fListVariables->GetSelectedEntry()) {
665 selectedVariable = fListVariables->GetSelectedEntry()->GetTitle();
666 id=fListVariables->GetSelectedEntry()->EntryId();
667 TString branchName=selectedVariable;
668 // const TObject *key=(*fConfigParser)(id);
669 // if (key) branchName=(*fConfigParser)(id)->GetName();
670 //treat case of TVector
671 if (branchName.EndsWith(".")){
672 Int_t par = (Int_t)(fNmbPar->GetNumber());
673 branchName.Append(Form("fElements[%d]",par));
676 return branchName.Data();
678 //______________________________________________________________________________
679 const char* AliCalibViewerGUItime::GetDrawOption() const {
681 // get user selected draw options
684 if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle();
685 if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase))
687 return drawOpt.Data();
689 //______________________________________________________________________________
690 void AliCalibViewerGUItime::GetCutString(TString &cutStr){
694 TCut cuts(fComboCustomCuts->GetTextEntry()->GetText());
696 if (fComboRunType->GetSelectedEntry()) runType=fComboRunType->GetSelectedEntry()->GetTitle();
697 if (runType!="ALL"&&!runType.IsNull()) cuts+=Form("runType.String().Data()==\"%s\"",runType.Data());
698 cutStr=cuts.GetTitle();
700 //______________________________________________________________________________
701 void AliCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph)
704 // Update arrays of runs
707 fValuesX.ResizeTo(1);
708 fValuesY.ResizeTo(1);
709 fRunNumbers.ResizeTo(1);
710 fTimeStamps.ResizeTo(1);
712 fValuesX.ResizeTo(fTree->GetSelectedRows());
713 fValuesY.ResizeTo(fTree->GetSelectedRows());
714 fRunNumbers.ResizeTo(fTree->GetSelectedRows());
715 fTimeStamps.ResizeTo(fTree->GetSelectedRows());
716 fValuesY.SetElements(fTree->GetV3());
717 fRunNumbers.SetElements(fTree->GetV1());
718 fTimeStamps.SetElements(fTree->GetV2());
722 //______________________________________________________________________________
723 void AliCalibViewerGUItime::GetHistogramTitle(TString &title)
726 // Create string for histogram title
730 Int_t pos=title.First(">>");
731 if (pos>0) title=title(0,pos);
733 if (fRadioXrun->GetState()==kButtonDown){
735 } else if (fRadioXtime->GetState()==kButtonDown){
741 TObjArray *arr=title.Tokenize(":");
746 TIter next(arr,kIterBackward);
747 while ( (o=next()) ){
748 TString varName=o->GetName();
755 //______________________________________________________________________________
756 void AliCalibViewerGUItime::AdjustYRange()
759 // adjust the range of the Y axis
761 TIter nextGraphicObject(fTrashBox);
764 while ( (o=nextGraphicObject()) ){
765 if (o->IsA()==TGraph::Class()){
766 TGraph *gr=(TGraph*)o;
768 min=TMath::MinElement(gr->GetN(),gr->GetY());
769 max=TMath::MaxElement(gr->GetN(),gr->GetY());
771 Float_t currmin=TMath::MinElement(gr->GetN(),gr->GetY());
772 Float_t currmax=TMath::MaxElement(gr->GetN(),gr->GetY());
773 if (currmax>max) max=currmax;
774 if (currmin<min) min=currmin;
779 if (min!=0) min=min-(max-min)/10;
780 if (max!=0) max=max+(max-min)/10;
781 fCurrentHist->SetMinimum(min);
782 fCurrentHist->SetMaximum(max);
785 //______________________________________________________________________________
786 void AliCalibViewerGUItime::DoDraw() {
790 TString drawString=fDrawString;
792 GetCutString(cutString);
793 TString optString = GetDrawOption();
794 Bool_t graphOutput=!fNoGraph; //ttree buffer for V1, V2... too small
795 graphOutput&=(drawString.First(">>")<0); //histogram output in custom draw
796 graphOutput&=fRadioXhist->GetState()!=kButtonDown; //histogram drawing selected
797 graphOutput&=!(fIsCustomDraw&&!fDrawString.Contains(":")); //custom draw 1D
798 Bool_t drawSame=optString.Contains("same",TString::kIgnoreCase);
799 // optString+="goff";
801 drawString.Prepend("run:time:");
805 if (fRadioXrun->GetState()==kButtonDown){
807 } else if (fRadioXtime->GetState()==kButtonDown){
812 TVirtualPad *padsave=gPad;
813 fCanvMain->GetCanvas()->cd();
814 //delete old histograms and graphs
822 fTree->Draw(drawString.Data(),cutString.Data(),optString.Data());
823 if (fTree->GetSelectedRows()==-1) {
826 UpdateValueArrays(graphOutput);
828 GetHistogramTitle(title);
829 Bool_t drawGraph=kFALSE;
832 if (fDrawString.Contains(":")){
833 fValuesX.SetElements(fTree->GetV4());
840 if (fRadioXrun->GetState()==kButtonDown){
841 fValuesX.SetElements(fTree->GetV1());
842 } else if (fRadioXtime->GetState()==kButtonDown){
843 fValuesX.SetElements(fTree->GetV2());
848 }//create graph according to selection
850 TGraph *graph=new TGraph(fValuesX,fValuesY);
852 if (!drawSame) grDraw+="a";
853 if (!fIsCustomDraw) grDraw+="l";
854 graph->Draw(grDraw.Data());
855 graph->SetEditable(kFALSE);
856 TH1 *hist=graph->GetHistogram();
857 hist->SetTitle(title.Data());
858 fTrashBox->Add(graph);
859 graph->SetLineColor(fTrashBox->GetEntries());
860 graph->SetMarkerColor(fTrashBox->GetEntries());
866 TH1 *hist=fTree->GetHistogram();
867 hist->SetTitle(title.Data());
868 fTrashBox->Add(hist);
869 hist->SetLineColor(fTrashBox->GetEntries());
870 hist->SetMarkerColor(fTrashBox->GetEntries());
871 if (!drawSame) fCurrentHist=hist;
874 //Set time axis if choosen as x-variables
875 if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw&&!drawSame){
876 TAxis *xaxis=fCurrentHist->GetXaxis();
877 xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}");
878 xaxis->SetTimeDisplay(1);
879 xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3);
880 xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3);
884 fCurrentHist->GetYaxis()->SetTitleOffset(1.5);
894 //______________________________________________________________________________
895 void AliCalibViewerGUItime::DoDumpRuns()
898 // Dump the current run numbers to stdout
900 Int_t npoints=fRunNumbers.GetNrows();
901 Int_t *sortIndex = new Int_t[npoints];
902 TMath::Sort(npoints,fRunNumbers.GetMatrixArray(),sortIndex,kFALSE);
903 Int_t run=0, prevRun=-1;
905 for (Int_t irun=0;irun<npoints;++irun){
906 run=(Int_t)fRunNumbers.GetMatrixArray()[sortIndex[irun]];
907 if (run!=prevRun) std::cout << Form("%d",run) << std::endl;
913 //______________________________________________________________________________
914 void AliCalibViewerGUItime::DoParLimitChange()
917 // DoParLimitChange()
923 //______________________________________________________________________________
924 void AliCalibViewerGUItime::DoNewSelection() {
926 // decides whether to redraw if user makes another selection
929 fDrawString=GetDrawString();
930 fIsCustomDraw=kFALSE;
934 //______________________________________________________________________________
935 void AliCalibViewerGUItime::DoCustomDraw()
938 // Custom draw (TTree::Draw syntax)
940 fDrawString=fComboCustomDraw->GetTextEntry()->GetText();
941 fNmbPar->SetState(kFALSE);
946 //______________________________________________________________________________
947 void AliCalibViewerGUItime::DoCustomCutsDraw()
950 // Custom cuts (TTree::Draw syntax)
952 if (fIsCustomDraw) DoCustomDraw();
954 fDrawString=GetDrawString();
955 fIsCustomDraw=kFALSE;
960 //______________________________________________________________________________
961 void AliCalibViewerGUItime::HandleButtonsDrawSel(Int_t id)
964 // Draw selection button handling (x-variable)
968 TGButton *btn = (TGButton *) gTQSender;
969 id = btn->WidgetId();
972 Bool_t doDraw=kFALSE;
975 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
977 fRadioXrun->SetState(kButtonUp);
978 fRadioXtime->SetState(kButtonUp);
982 doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXhist->GetState()==kButtonDown);
984 fRadioXhist->SetState(kButtonUp);
985 fRadioXtime->SetState(kButtonUp);
989 doDraw=(fRadioXhist->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
991 fRadioXrun->SetState(kButtonUp);
992 fRadioXhist->SetState(kButtonUp);
996 if (doDraw) DoCustomCutsDraw();
998 //______________________________________________________________________________
999 void AliCalibViewerGUItime::UpdateParName()
1002 // change parameter name
1005 Int_t par = (Int_t)(fNmbPar->GetNumber());
1007 parName.Form("%d",par);
1008 fLblPar->SetText(Form("Parameter: %s",parName.Data()));
1009 fDrawString=GetDrawString();
1010 fIsCustomDraw=kFALSE;
1013 //______________________________________________________________________________
1014 void AliCalibViewerGUItime::UpdateParLimits()
1017 // Adjust limits for TVectorT based variables
1020 TString selectedVariableTitle="";
1022 if (!fListVariables->GetSelectedEntry()) return;
1023 selectedVariableTitle = fListVariables->GetSelectedEntry()->GetTitle();
1024 id=fListVariables->GetSelectedEntry()->EntryId();
1025 TString selectedVariable=selectedVariableTitle;
1026 // const TObject *key=(*fConfigParser)(id);
1027 // if (key) selectedVariable=(*fConfigParser)(id)->GetName();
1029 if (selectedVariable.IsNull()||!selectedVariable.EndsWith(".")) {
1030 fNmbPar->SetState(kFALSE);
1031 fLblPar->SetText("Parameter: none");
1038 TBranch *branch=fTree->GetTree()->GetBranch(selectedVariable.Data());
1039 TString branchClass=branch->GetClassName();
1041 if (branchClass=="TVectorT<double>"){
1042 // branch->SetAddress(&vD);
1043 fTree->SetBranchAddress(selectedVariable.Data(),&vD);
1044 while (maxPar<2&&event<fTree->GetEntries()){
1045 fTree->GetEntry(event++);
1046 maxPar=vD->GetNrows();
1048 } else if (branchClass=="TVectorT<float>"){
1049 // branch->SetAddress(&vF);
1050 fTree->SetBranchAddress(selectedVariable.Data(),&vF);
1051 while (maxPar<2&&event<fTree->GetEntries()){
1052 fTree->GetEntry(event++);
1053 maxPar=vF->GetNrows();
1057 fNmbPar->SetState(kFALSE);
1060 fTree->SetBranchAddress(selectedVariable.Data(),0x0);
1061 if (fNmbPar->GetNumMax()!=maxPar-1) fNmbPar->SetNumber(0);
1062 fNmbPar->SetLimitValues(0,maxPar-1);
1063 fNmbPar->SetState(kTRUE);
1066 //______________________________________________________________________________
1067 void AliCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/)
1070 // handle mouse events in the draw canvas
1072 UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0;
1073 Double_t valx=0.,valy=0.;
1074 if (!fCurrentGraph) {
1075 fLblRunNumberVal->SetText(Form("%07u",run));
1076 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS));
1077 fLblValueXVal->SetText(Form("%.3e", valx));
1078 fLblValueYVal->SetText(Form("%.3e", valy));
1081 TVirtualPad *padsave=gPad;
1082 fCanvMain->GetCanvas()->cd();
1083 Int_t n=fValuesY.GetNrows();
1085 arr=fValuesX.GetMatrixArray();
1087 Int_t minDist=1000000;
1089 for (Int_t i=0;i<n;++i){
1090 Int_t pxp = gPad->XtoAbsPixel(gPad->XtoPad(arr[i]));
1091 Int_t pyp = gPad->YtoAbsPixel(gPad->YtoPad(fValuesY[i]));
1092 Int_t d = TMath::Nint(TMath::Sqrt(TMath::Abs(pxp-x) + TMath::Abs(pyp-y)));
1099 TTimeStamp t((Int_t)fTimeStamps[minPoint]);
1100 t.GetDate(kTRUE,0,&yy,&mm,&dd);
1101 t.GetTime(kTRUE,0,&HH,&MM,&SS);
1102 run=(UInt_t)fRunNumbers[minPoint];
1103 valx=fValuesX[minPoint];
1104 valy=fValuesY[minPoint];
1106 dd=0;mm=0;yy=0;HH=0;MM=0;SS=0;run=0;
1110 fLblRunNumberVal->SetText(Form("%07u",run));
1111 fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS));
1113 fLblValueXVal->SetText(Form("%.3e", valx));
1115 if (fRadioXrun->GetState()==kButtonDown){
1116 fLblValueXVal->SetText("Run");
1117 } else if (fRadioXtime->GetState()==kButtonDown){
1118 fLblValueXVal->SetText("Time");
1121 fLblValueYVal->SetText(Form("%.3e", valy));
1126 if (event == kButton1Double ){
1129 //find closes point of current selection
1132 //______________________________________________________________________________
1133 void AliCalibViewerGUItime::SetGuiTree(Int_t run)
1136 // create the AliCalibViewerGUI tree for run
1137 // cache tree in directory fOutputCacheDir
1138 // retrieve file from this directory if it already exists
1141 //try to find file for run in fOutputCacheDir
1142 TString fileName=fOutputCacheDir;
1143 if (!fileName.EndsWith("/")) fileName+="/";
1144 if(fDetector.Contains("TPC")) fileName+=Form("guiTreeRun_%d.root",run);
1145 else if(fDetector.Contains("TRD")) fileName+=Form("trdOCDBDetails_run%d.root", run);
1148 TFile f(fileName.Data());
1150 if(fDetector.Contains("TRD"))
1151 load = fCalibViewerGUI->CreateDetailsTree(run, fileName.Data(), "nothing");
1152 if(fDetector.Contains("TPC"))
1153 load = fCalibViewerGUI->CreateDetailsTree(run, fileName.Data(), "nothing");
1156 fCalibViewerGUI->Reset();
1157 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX")));
1162 if(fDetector.Contains("TPC")) fCalibViewerGUI->Initialize(fileName.Data(), "calPads");
1163 else fCalibViewerGUI->Initialize(fileName.Data(), "TRDcalibDetails");
1164 if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %07d",run)));
1165 TIter nextRefTree(fMapRefTrees);
1167 while ( (o=nextRefTree()) ){
1168 if(fDetector.Contains("TPC"))
1169 fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"calPads",o->GetName());
1171 fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"TRDcalibDetails",o->GetName());
1173 //if(fDetector.Contains("TPC")) ((AliTPCCalibViewerGUI_new*)fCalibViewerGUI)->Reload();
1174 //else ((AliTRDCalibViewerGUI*)fCalibViewerGUI)->Reload();
1175 fCalibViewerGUI->Reload();
1178 //______________________________________________________________________________
1179 const char* AliCalibViewerGUItime::SubstituteUnderscores(const char* in)
1182 // Substitute underscores from the branch names
1185 s.ReplaceAll("_{","|{");
1186 s.ReplaceAll("_"," ");
1187 s.ReplaceAll("|{","_{");
1191 //______________________________________________________________________________
1192 void AliCalibViewerGUItime::SavePicture() {
1194 // saves the current picture
1197 const char *kSaveAsTypes[] = {
1198 "Postscript", "*.ps",
1199 "Encapsulated Postscript", "*.eps",
1208 "C++ macro", "*.cxx",
1209 "Macro file", "*.C",
1210 "ROOT file", "*.root",
1216 fi.fFileTypes = kSaveAsTypes;
1217 // fi.fIniDir = StrDup(dir);
1218 fi.fOverwrite = kFALSE;
1219 new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDSave, &fi);
1220 if (fi.fFilename && strlen(fi.fFilename)) {
1221 fCanvMain->GetCanvas()->Print(fi.fFilename);
1225 //______________________________________________________________________________
1226 void AliCalibViewerGUItime::HandleLoadRunButtons() {
1228 // Handle the buttons
1230 Int_t id = ((TGTextButton*)gTQSender)->WidgetId();
1232 UseFile(fTxtFilename->GetText(), fTxtTreeName->GetText());
1239 //______________________________________________________________________________
1240 void AliCalibViewerGUItime::HandleLoadRunTextEntry() {
1242 // Handle the text entries
1245 // 100 - fTxtFilename
1246 // 101 - fTxtConfigFile
1248 Int_t id = ((TGTextEntry*)gTQSender)->WidgetId();
1249 if(id>=100 && id<=103) {
1250 const char *kTypes[] = {
1256 fi.fFileTypes = kTypes;
1257 fi.fOverwrite = kFALSE;
1258 new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDOpen, &fi);
1259 if(fi.fFilename && strlen(fi.fFilename)) {
1261 fTxtFilename->SetText(fi.fFilename);
1264 // fTxtConfigFile->SetText(fi.fFilename);
1265 // fConfigFile=fi.fFilename;
1268 //fTxtRunList->SetText(fi.fFilename);
1271 //fTxtOutputOCDB->SetText(fi.fFilename);
1281 //__________________________________________________________________
1282 TObjArray* AliCalibViewerGUItime::ShowGUI(TChain* chain) {
1284 // Launch the time trending GUI. Load the TChain chain into the viewer
1286 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 650);
1287 frmMain->SetWindowName("Calib Viewer - time trend");
1288 frmMain->SetCleanup(kDeepCleanup);
1290 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1291 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1293 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1295 AliCalibViewerGUItime* calibViewerTime = new AliCalibViewerGUItime(tabCont1, 1000, 650);
1296 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1297 calibViewerTime->UseChain(chain);
1299 TObjArray *guiArray = new TObjArray();
1300 guiArray->Add(calibViewerTime);
1302 frmMain->MapSubwindows();
1304 frmMain->MapWindow();
1308 //__________________________________________________________________
1309 TObjArray* AliCalibViewerGUItime::ShowGUI() {
1311 // Launch the time trending GUI. The GUI will be empty but trees can be loaded by using the GUI interface
1313 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 650);
1314 frmMain->SetWindowName("Calib Viewer - time trend");
1315 frmMain->SetCleanup(kDeepCleanup);
1317 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
1318 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1320 TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
1322 AliCalibViewerGUItime* calibViewerTime = new AliCalibViewerGUItime(tabCont1, 1000, 650);
1323 tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
1325 TObjArray *guiArray = new TObjArray();
1326 guiArray->Add(calibViewerTime);
1328 frmMain->MapSubwindows();
1330 frmMain->MapWindow();