]>
Commit | Line | Data |
---|---|---|
5312f439 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | ||
17 | /////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
19 | // // | |
20 | /////////////////////////////////////////////////////////////////////////////// | |
21 | ||
6e7d7dc4 | 22 | |
5312f439 | 23 | #include <iostream> |
24 | //Root includes | |
25 | #include <TROOT.h> | |
26 | #include <TDirectory.h> | |
27 | #include <TStyle.h> | |
28 | #include <TCanvas.h> | |
29 | #include <TPad.h> | |
30 | #include <TVirtualPad.h> | |
31 | #include <TObject.h> | |
32 | #include <TObjArray.h> | |
33 | #include <TObjString.h> | |
6fb51ca4 | 34 | #include <TSystem.h> |
5312f439 | 35 | #include <TVector.h> |
36 | #include <TH1.h> | |
37 | #include <TCut.h> | |
38 | #include <TFile.h> | |
39 | #include <TTree.h> | |
e6970ab5 | 40 | #include <TChain.h> |
5312f439 | 41 | #include <TBranch.h> |
42 | #include <TIterator.h> | |
43 | #include <TGraph.h> | |
44 | #include <TAxis.h> | |
45 | #include <TTimeStamp.h> | |
46 | #include <TMath.h> | |
7390f655 | 47 | #include <TMap.h> |
5312f439 | 48 | // |
49 | #include <TGFileDialog.h> | |
50 | #include <TGInputDialog.h> | |
51 | // | |
52 | #include <TGButton.h> | |
53 | #include <TGListBox.h> | |
54 | #include <TGComboBox.h> | |
55 | #include <TGNumberEntry.h> | |
56 | #include <TGLayout.h> | |
57 | #include <TRootEmbeddedCanvas.h> | |
58 | #include <TGSplitter.h> | |
59 | #include <TGButtonGroup.h> | |
60 | #include <TGLabel.h> | |
61 | #include <TGTab.h> | |
62 | #include <TGString.h> | |
63 | ||
64 | //AliRoot includes | |
6fb51ca4 | 65 | #include <AliLog.h> |
5312f439 | 66 | #include "AliTPCCalibViewerGUI.h" |
7390f655 | 67 | #include "AliTPCCalibViewer.h" |
5312f439 | 68 | #include "AliTPCcalibDB.h" |
6fb51ca4 | 69 | #include "AliTPCConfigParser.h" |
5312f439 | 70 | |
71 | #include "AliTPCCalibViewerGUItime.h" | |
72 | ||
73 | ClassImp(AliTPCCalibViewerGUItime) | |
74 | ||
75 | AliTPCCalibViewerGUItime::AliTPCCalibViewerGUItime(const TGWindow *p, UInt_t w, UInt_t h) : | |
76 | TGCompositeFrame(p,w,h), | |
77 | fFile(0x0), | |
78 | fTree(0x0), | |
79 | fCalibViewerGUI(0x0), | |
80 | fCalibViewerGUItab(0x0), | |
81 | fCurrentHist(0x0), | |
82 | fCurrentGraph(0x0), | |
83 | fCurrentRunDetails(-1), | |
84 | fOutputCacheDir("/tmp"), | |
85 | fDrawString(""), | |
6e7d7dc4 | 86 | fConfigFile(""), |
87 | fConfigParser(new AliTPCConfigParser), | |
5312f439 | 88 | fIsCustomDraw(kFALSE), |
89 | fRunNumbers(10), | |
90 | fTimeStamps(10), | |
91 | fValuesX(10), | |
92 | fValuesY(10), | |
6e7d7dc4 | 93 | fNoGraph(kFALSE), |
94 | fGraphLimitEntries(10000), | |
7390f655 | 95 | fMapRefTrees(new TMap), |
5312f439 | 96 | //GUI elements |
97 | //main canvas Top part, bottom part | |
98 | fContTopBottom(0x0), | |
99 | //top left, centre, right | |
100 | fContLCR(0x0), | |
101 | //content left | |
102 | fContLeft(0x0), | |
6e7d7dc4 | 103 | fContDrawOpt(0x0), |
104 | fChkDrawOptSame(0x0), | |
105 | fComboAddDrawOpt(0x0), | |
5312f439 | 106 | fContDrawSel(0x0), |
107 | fContDrawSelSubRunTime(0x0), | |
108 | fRadioXhist(0x0), | |
109 | fRadioXrun(0x0), | |
110 | fRadioXtime(0x0), | |
111 | fListVariables(0x0), | |
112 | fComboRunType(0x0), | |
113 | fLblRunType(0x0), | |
114 | fNmbPar(0x0), | |
115 | fLblPar(0x0), | |
6fb51ca4 | 116 | fListCalibType(0x0), |
117 | fContCalibType(0x0), | |
5312f439 | 118 | //content centre |
119 | fContCenter(0x0), | |
120 | fCanvMain(0x0), | |
121 | //content right | |
122 | fContRight(0x0), | |
123 | fContValues(0x0), | |
124 | fLblRunNumber(0x0), | |
125 | fLblRunTime(0x0), | |
126 | fLblValueX(0x0), | |
127 | fLblValueY(0x0), | |
128 | fLblRunNumberVal(0x0), | |
129 | fLblRunTimeVal(0x0), | |
130 | fLblValueXVal(0x0), | |
131 | fLblValueYVal(0x0), | |
132 | fBtnDumpRuns(0x0), | |
514fcaf7 | 133 | fContAliases(0x0), |
134 | fListAliases(0x0), | |
5312f439 | 135 | //content bottom |
136 | fContCustom(0x0), | |
137 | fContCustomCuts(0x0), | |
138 | fLblCustomDraw(0x0), | |
139 | fLblCustomCuts(0x0), | |
140 | fComboCustomDraw(0x0), | |
6e7d7dc4 | 141 | fComboCustomCuts(0x0), |
142 | fTrashBox(new TObjArray) | |
5312f439 | 143 | { |
144 | // | |
145 | // ctor | |
146 | // | |
7390f655 | 147 | fMapRefTrees->SetOwnerKeyValue(); |
148 | fTrashBox->SetOwner(); | |
5312f439 | 149 | DrawGUI(p,w,h); |
6e7d7dc4 | 150 | gStyle->SetMarkerStyle(20); |
151 | gStyle->SetMarkerSize(0.5); | |
5312f439 | 152 | SetInitialValues(); |
153 | } | |
154 | //______________________________________________________________________________ | |
155 | AliTPCCalibViewerGUItime::~AliTPCCalibViewerGUItime(){ | |
156 | // | |
157 | // dtor | |
158 | // | |
6e7d7dc4 | 159 | delete fConfigParser; |
160 | delete fTrashBox; | |
7390f655 | 161 | delete fMapRefTrees; |
5312f439 | 162 | } |
163 | //______________________________________________________________________________ | |
6fb51ca4 | 164 | void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) { |
5312f439 | 165 | // |
166 | // draw the GUI | |
167 | // | |
168 | // ====================================================================== | |
169 | // ************************* Display everything ************************* | |
170 | // ====================================================================== | |
171 | ||
172 | SetCleanup(kDeepCleanup); | |
5312f439 | 173 | |
174 | // ***************************************************************************** | |
175 | // ************************* content of this MainFrame ************************* | |
176 | // ***************************************************************************** | |
177 | // top level container with horizontal layout | |
178 | fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight); | |
179 | AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
180 | ||
181 | fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight); | |
182 | fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
183 | ||
184 | // *********************************************************************** | |
185 | // ************************* content of fContLCR ************************* | |
186 | // *********************************************************************** | |
187 | // left container | |
188 | fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight); | |
189 | fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3)); | |
190 | ||
191 | // left vertical splitter | |
192 | TGVSplitter *splitLeft = new TGVSplitter(fContLCR); | |
193 | splitLeft->SetFrame(fContLeft, kTRUE); | |
194 | fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0)); | |
195 | ||
196 | // right container | |
197 | fContRight = new TGCompositeFrame(fContLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight); | |
198 | fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3)); | |
199 | ||
200 | // center container | |
201 | fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight); | |
202 | fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
203 | ||
204 | // right vertical splitter | |
205 | TGVSplitter *splitRight = new TGVSplitter(fContLCR); | |
206 | splitRight->SetFrame(fContRight, kFALSE); | |
207 | fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0)); | |
208 | ||
209 | ||
210 | // ======================================================================== | |
211 | // ************************* content of fContLeft ************************* | |
212 | // ======================================================================== | |
213 | // --- draw button and tabLeft --- | |
6e7d7dc4 | 214 | // draw options |
215 | fContDrawOpt = new TGGroupFrame(fContLeft, "Draw options", kVerticalFrame | kFitWidth | kFitHeight); | |
216 | fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); | |
217 | fChkDrawOptSame = new TGCheckButton(fContDrawOpt, "Same"); | |
218 | fContDrawOpt->AddFrame(fChkDrawOptSame, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0)); | |
219 | fChkDrawOptSame->SetToolTipText("Add draw option 'same'"); | |
220 | // additional draw options combo box | |
221 | fComboAddDrawOpt = new TGComboBox(fContDrawOpt); | |
222 | fComboAddDrawOpt->Resize(0, 22); | |
223 | fComboAddDrawOpt->EnableTextInput(kTRUE); | |
224 | fContDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
225 | // fComboAddDrawOpt->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral(=14)"); | |
226 | // fComboAddDrawOpt->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); | |
227 | ||
5312f439 | 228 | // draw selection group |
229 | fContDrawSel = new TGGroupFrame(fContLeft, "Draw selection", kVerticalFrame | kFitWidth | kFitHeight); | |
230 | fContLeft->AddFrame(fContDrawSel, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0)); | |
231 | //x-axis variables selection, Run of Time | |
232 | fContDrawSelSubRunTime = new TGCompositeFrame(fContDrawSel, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight); | |
233 | fContDrawSel->AddFrame(fContDrawSelSubRunTime, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0)); | |
234 | ||
235 | // ------------------------- content of fContDrawOpt ------------------------- | |
236 | // | |
237 | // Run radio button | |
238 | // Time radio button | |
239 | fRadioXhist = new TGRadioButton(fContDrawSelSubRunTime, "hist", kRadioXhist); | |
240 | fContDrawSelSubRunTime->AddFrame(fRadioXhist, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0)); | |
241 | fRadioXhist->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()"); | |
242 | fRadioXhist->SetToolTipText("Draw the distribution of the variable"); | |
243 | ||
244 | fRadioXrun = new TGRadioButton(fContDrawSelSubRunTime, ":Run", kRadioXrun); | |
245 | fContDrawSelSubRunTime->AddFrame(fRadioXrun, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0)); | |
246 | fRadioXrun->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()"); | |
247 | fRadioXrun->SetToolTipText("Use run number as x-value"); | |
248 | ||
249 | // Time radio button | |
250 | fRadioXtime = new TGRadioButton(fContDrawSelSubRunTime, ":Time", kRadioXtime); | |
251 | fContDrawSelSubRunTime->AddFrame(fRadioXtime, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0)); | |
252 | fRadioXtime->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()"); | |
253 | fRadioXtime->SetToolTipText("Use time stamp number as x-value"); | |
254 | ||
255 | ||
256 | // list of variables | |
257 | fListVariables = new TGListBox(fContDrawSel); | |
258 | fContDrawSel->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
259 | fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelection()"); | |
260 | ||
6fb51ca4 | 261 | |
262 | //-------------------- run type selection ------------------------ | |
5312f439 | 263 | // Parameter label |
264 | fLblRunType = new TGLabel(fContDrawSel, "Run Type:"); | |
265 | fLblRunType->SetTextJustify(kTextLeft); | |
266 | fContDrawSel->AddFrame(fLblRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
267 | ||
268 | fComboRunType = new TGComboBox(fContDrawSel); | |
269 | fComboRunType->EnableTextInput(kFALSE); | |
270 | fContDrawSel->AddFrame(fComboRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
271 | fComboRunType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoDraw()"); | |
272 | // fComboRunType->SetEnabled(kFALSE); | |
273 | fComboRunType->Resize(0, 22); | |
274 | ||
275 | //-------------------- parameter selection ------------------------ | |
276 | // Parameter label | |
277 | fLblPar = new TGLabel(fContDrawSel, "Parameter:"); | |
278 | fLblPar->SetTextJustify(kTextLeft); | |
279 | fContDrawSel->AddFrame(fLblPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
280 | ||
281 | fNmbPar = new TGNumberEntry(fContDrawSel, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71); | |
282 | fContDrawSel->AddFrame(fNmbPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
283 | fNmbPar->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUItime", this, "DoParLimitChange()"); | |
284 | fNmbPar->SetState(kFALSE); | |
285 | ||
6fb51ca4 | 286 | //-------------------- calibration type selection ------------------------ |
287 | // label | |
288 | // draw selection group | |
289 | fContCalibType = new TGGroupFrame(fContLeft, "Calib type selection", kVerticalFrame | kFitWidth | kFitHeight); | |
290 | fContLeft->AddFrame(fContCalibType, new TGLayoutHints(kLHintsExpandX , 0, 0, 10, 0)); | |
291 | ||
292 | // list of variables | |
293 | fListCalibType = new TGListBox(fContCalibType); | |
294 | fContCalibType->AddFrame(fListCalibType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX , 0, 0, 0, 0)); | |
295 | fListCalibType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoChangeSelectionList()"); | |
296 | fListCalibType->Resize(0,88); | |
297 | fListCalibType->SetMultipleSelections(); | |
298 | ||
5312f439 | 299 | |
300 | // ========================================================================== | |
301 | // ************************* content of fContCenter ************************* | |
302 | // ======================================================================== | |
303 | // main drawing canvas | |
304 | fCanvMain = new TRootEmbeddedCanvas("GUItime_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight); | |
305 | fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
306 | fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliTPCCalibViewerGUItime", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)"); | |
307 | // fCanvMain->GetCanvas()->Connect("RangeAxisChanged()", "AliTPCCalibViewerGUItime", this, "GetMinMax()"); | |
308 | fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed."); | |
6fb51ca4 | 309 | fCanvMain->GetCanvas()->SetRightMargin(0.062); |
310 | fCanvMain->GetCanvas()->SetLeftMargin(0.15); | |
5312f439 | 311 | |
312 | // ========================================================================= | |
313 | // ************************* content of fContRight ************************* | |
314 | // ======================================================================== | |
315 | //group frame for value information | |
316 | fContValues = new TGGroupFrame(fContRight, "Data point info", kVerticalFrame | kFitWidth | kFitHeight); | |
317 | fContRight->AddFrame(fContValues, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); | |
318 | //set layout manager | |
319 | fContValues->SetLayoutManager(new TGMatrixLayout(fContValues, 0, 2, 5)); | |
320 | //value information labels | |
321 | ||
322 | //run number label | |
323 | fLblRunNumber = new TGLabel(fContValues, "Run:"); | |
324 | fLblRunNumber->SetTextJustify(kTextLeft); | |
325 | fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); | |
326 | //run number | |
327 | fLblRunNumberVal = new TGLabel(fContValues, "00000"); | |
328 | fLblRunNumberVal->SetTextJustify(kTextLeft); | |
329 | fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0)); | |
330 | //time stamp label | |
331 | fLblRunTime = new TGLabel(fContValues, "Time:"); | |
332 | fLblRunTime->SetTextJustify(kTextLeft); | |
333 | fContValues->AddFrame(fLblRunTime, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); | |
334 | //run number | |
335 | fLblRunTimeVal = new TGLabel(fContValues, "00.00.0000\n00:00:00"); | |
336 | fLblRunTimeVal->SetTextJustify(kTextLeft); | |
337 | fContValues->AddFrame(fLblRunTimeVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0)); | |
338 | //value label x | |
339 | fLblValueX = new TGLabel(fContValues, "x-Value:"); | |
340 | fLblValueX->SetTextJustify(kTextLeft); | |
341 | fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); | |
342 | //value x | |
892226be | 343 | fLblValueXVal = new TGLabel(fContValues, "00.000e+00"); |
5312f439 | 344 | fLblValueXVal->SetTextJustify(kTextRight); |
345 | fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
346 | //value label y | |
347 | fLblValueY = new TGLabel(fContValues, "y-Value:"); | |
348 | fLblValueY->SetTextJustify(kTextLeft); | |
349 | fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); | |
350 | //value y | |
892226be | 351 | fLblValueYVal = new TGLabel(fContValues, "00.000e+00"); |
5312f439 | 352 | fLblValueYVal->SetTextJustify(kTextRight); |
353 | fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
354 | // draw button | |
355 | fBtnDumpRuns = new TGTextButton(fContRight, "&Dump runs"); | |
6fb51ca4 | 356 | fContRight->AddFrame(fBtnDumpRuns, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); |
5312f439 | 357 | fBtnDumpRuns->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDumpRuns()"); |
358 | fBtnDumpRuns->SetToolTipText("Press to dump the run numbers of the current selection."); | |
514fcaf7 | 359 | //group frame for value information |
360 | fContAliases = new TGGroupFrame(fContRight, "Aliases", kVerticalFrame | kFitWidth | kFitHeight); | |
361 | fContRight->AddFrame(fContAliases, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0)); | |
362 | // list of aliases | |
363 | fListAliases = new TGListBox(fContAliases); | |
364 | fContAliases->AddFrame(fListAliases, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
365 | fListAliases->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelectionAliases()"); | |
366 | // fListAliases->Resize(0,88); | |
367 | //buttons | |
368 | TGCompositeFrame *frame1 = new TGCompositeFrame(fContAliases, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight); | |
369 | fContAliases->AddFrame(frame1, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0)); | |
370 | // add button | |
371 | TGTextButton *btnAdd = new TGTextButton(frame1, "&Add"); | |
372 | frame1->AddFrame(btnAdd, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); | |
373 | btnAdd->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoAddAlias()"); | |
374 | btnAdd->SetToolTipText("Press to add an alias."); | |
375 | btnAdd->Resize(0,22); | |
376 | // del button | |
377 | TGTextButton *btnDel = new TGTextButton(frame1, "&Del"); | |
378 | frame1->AddFrame(btnDel, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); | |
379 | btnDel->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDelAlias()"); | |
380 | btnDel->SetToolTipText("Press to delete the selected alias."); | |
381 | btnDel->Resize(0,22); | |
382 | // update button | |
383 | TGTextButton *btnUp = new TGTextButton(frame1, "&Upd"); | |
384 | frame1->AddFrame(btnUp, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); | |
385 | btnUp->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "UpdateAliasList()"); | |
386 | btnUp->SetToolTipText("Press to update the alias list."); | |
387 | btnUp->Resize(0,22); | |
388 | ||
389 | ||
5312f439 | 390 | |
391 | // ========================================================================= | |
392 | // ****************** bottom content of fContTopBottom ********************* | |
393 | // ========================================================================= | |
394 | ||
395 | // custom options container | |
396 | // --- fComboCustom --- the custom draw line on the very low | |
397 | fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
398 | fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0)); | |
399 | ||
400 | // ------------------------- content of fContCustom ------------------------- | |
401 | fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: "); | |
402 | fLblCustomDraw->SetTextJustify(kTextLeft); | |
403 | fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0)); | |
404 | // text field for custom draw command | |
405 | fComboCustomDraw = new TGComboBox(fContCustom); | |
406 | // fComboCustomDraw->Resize(0, fLblValueY->GetDefaultHeight()); | |
407 | fComboCustomDraw->Resize(0, 22); | |
408 | fComboCustomDraw->EnableTextInput(kTRUE); | |
409 | fContCustom->AddFrame(fComboCustomDraw, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
410 | fComboCustomDraw->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()"); | |
411 | fComboCustomDraw->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()"); | |
412 | ||
413 | ||
414 | // additional cuts container | |
415 | fContCustomCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
416 | fContTopBottom->AddFrame(fContCustomCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0)); | |
417 | ||
418 | // ------------------------- content of fContCustomCuts ------------------------- | |
419 | fLblCustomCuts = new TGLabel(fContCustomCuts, "Custom cuts: "); | |
420 | fLblCustomCuts->SetTextJustify(kTextLeft); | |
421 | fContCustomCuts->AddFrame(fLblCustomCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0)); | |
422 | // combo text field for additional cuts | |
423 | fComboCustomCuts = new TGComboBox(fContCustomCuts); | |
424 | // fComboCustomCuts->Resize(0, fLblValueY->GetDefaultHeight()); | |
425 | fComboCustomCuts->Resize(0, 22); | |
426 | fComboCustomCuts->EnableTextInput(kTRUE); | |
427 | fContCustomCuts->AddFrame(fComboCustomCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
6fb51ca4 | 428 | fComboCustomCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()"); |
429 | fComboCustomCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()"); | |
5312f439 | 430 | |
431 | SetWindowName("AliTPCCalibViewer GUI - Time"); | |
432 | MapSubwindows(); | |
433 | Resize(GetDefaultSize()); | |
434 | MapWindow(); | |
435 | } | |
436 | //______________________________________________________________________________ | |
437 | void AliTPCCalibViewerGUItime::SetInitialValues(){ | |
438 | // | |
439 | // Set inital selections of the gui | |
440 | // | |
441 | fRadioXrun->SetState(kButtonDown); | |
442 | fRadioXtime->SetState(kButtonUp); | |
443 | } | |
444 | ||
445 | //______________________________________________________________________________ | |
6e7d7dc4 | 446 | void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeName) { |
5312f439 | 447 | // |
448 | // retrieve tree from file | |
449 | // | |
6e7d7dc4 | 450 | TString s=gSystem->GetFromPipe(Form("ls %s",fileName)); |
451 | // TString s(fileName); | |
e6970ab5 | 452 | TObjArray *arr=s.Tokenize("\n"); |
453 | TIter next(arr); | |
454 | TObject *o=0; | |
455 | if (fTree) delete fTree; | |
6e7d7dc4 | 456 | fTree=new TChain(treeName); |
e6970ab5 | 457 | while ( (o=next()) ){ |
458 | fTree->AddFile(o->GetName()); | |
459 | } | |
460 | delete arr; | |
6e7d7dc4 | 461 | if (!CheckChain()) return; |
462 | UseConfigFile(fConfigFile.Data()); | |
463 | Reload(); | |
464 | ||
465 | } | |
466 | //______________________________________________________________________________ | |
467 | void AliTPCCalibViewerGUItime::UseChain(TChain* chain = 0) | |
468 | { | |
469 | // | |
470 | // | |
471 | // | |
472 | fTree=chain; | |
473 | if (!CheckChain()) return; | |
474 | //set configuration file | |
475 | UseConfigFile(fConfigFile.Data()); | |
476 | Reload(); | |
477 | } | |
478 | //______________________________________________________________________________ | |
479 | Bool_t AliTPCCalibViewerGUItime::CheckChain() | |
480 | { | |
481 | // | |
482 | // check whether cahin has entries | |
483 | // decide whether to draw graphs in 2D | |
484 | // | |
485 | if (!fTree) return kFALSE; | |
e6970ab5 | 486 | fTree->Lookup(); |
6e7d7dc4 | 487 | Long64_t entries=fTree->GetEntries(); |
488 | if (entries==0){ | |
e6970ab5 | 489 | AliError("No entries found in chain"); |
6e7d7dc4 | 490 | return kFALSE; |
6fb51ca4 | 491 | } |
6e7d7dc4 | 492 | //check whether to draw graphs |
493 | CheckDrawGraph(); | |
494 | return kTRUE; | |
495 | } | |
496 | //______________________________________________________________________________ | |
497 | void AliTPCCalibViewerGUItime::UseConfigFile(const char* file) | |
498 | { | |
499 | // | |
500 | // Use 'file' as configuration file | |
501 | // | |
502 | fConfigFile=file; | |
503 | fConfigParser->ParseConfigFileTxt(fConfigFile.Data()); | |
504 | FillCalibTypes(); | |
5312f439 | 505 | } |
506 | //______________________________________________________________________________ | |
6fb51ca4 | 507 | void AliTPCCalibViewerGUItime::FillRunTypes() |
508 | { | |
5312f439 | 509 | // |
6fb51ca4 | 510 | //Loop over the tree entries and fill the run types |
5312f439 | 511 | // |
6fb51ca4 | 512 | if (!fTree) return; |
5312f439 | 513 | Int_t id=0; |
5312f439 | 514 | fComboRunType->RemoveAll(); |
515 | fComboRunType->AddEntry("ALL",id++); | |
516 | fComboRunType->Select(0,kFALSE); | |
6e7d7dc4 | 517 | if (!fTree->GetBranch("runType.")) return; |
5312f439 | 518 | TObjString *runType=0x0; |
519 | Int_t nevets=fTree->GetEntries(); | |
5312f439 | 520 | fTree->SetBranchStatus("*",0); |
521 | fTree->SetBranchStatus("runType.*",1); | |
e6970ab5 | 522 | fTree->SetBranchAddress("runType.",&runType); |
5312f439 | 523 | for (Int_t iev=0;iev<nevets;++iev){ |
524 | fTree->GetEntry(iev); | |
525 | TString type=runType->String(); | |
526 | if (!type.IsNull()&&!fComboRunType->FindEntry(type)) fComboRunType->AddEntry(type,id++); | |
527 | } | |
e6970ab5 | 528 | fTree->ResetBranchAddresses(); |
5312f439 | 529 | fTree->SetBranchStatus("*",1); |
530 | } | |
531 | //______________________________________________________________________________ | |
6fb51ca4 | 532 | void AliTPCCalibViewerGUItime::FillCalibTypes() |
533 | { | |
534 | // | |
535 | // loop over configuration and fill calibration types | |
536 | // | |
6fb51ca4 | 537 | Int_t id=0; |
538 | fListCalibType->RemoveAll(); | |
539 | TObject *o=0x0; | |
540 | fConfigParser->ResetIter(); | |
541 | TString type; | |
542 | while ( (o=fConfigParser->NextKey()) ){ | |
543 | type=fConfigParser->GetData(o,kCalibType); | |
544 | //remove whitespcaces | |
545 | type.Remove(TString::kBoth,' '); | |
546 | type.Remove(TString::kBoth,'\t'); | |
547 | if (type.IsNull()) type="UNSPECIFIED"; | |
548 | // printf("CalibType: '%s'\n",type.Data()); | |
549 | if (!fListCalibType->FindEntry(type.Data())) { | |
550 | fListCalibType->AddEntry(type,id); | |
551 | fListCalibType->Select(id++); | |
552 | } | |
553 | } | |
554 | //add type for unspecified calibration type | |
555 | type="UNSPECIFIED"; | |
556 | if (!fListCalibType->FindEntry(type.Data())) { | |
557 | fListCalibType->AddEntry(SubstituteUnderscores(type.Data()),id); | |
558 | fListCalibType->Select(id++); | |
559 | } | |
560 | } | |
561 | //______________________________________________________________________________ | |
6e7d7dc4 | 562 | void AliTPCCalibViewerGUItime::CheckDrawGraph() |
563 | { | |
564 | // | |
565 | // Check whether to draw graphs in 2D mode based on the number of entries in the chain | |
566 | // GetEstimate() returns the maximum size of the arrays stored in GetV1()... | |
567 | // | |
568 | if (!fTree) return; | |
569 | fNoGraph=kTRUE; | |
570 | if (fTree->GetEntries()<fTree->GetEstimate()) fNoGraph=kFALSE; | |
571 | } | |
572 | //______________________________________________________________________________ | |
573 | void AliTPCCalibViewerGUItime::Reload(Int_t first) | |
574 | { | |
6fb51ca4 | 575 | // |
576 | // reload the gui contents, this is needed after the input tree has changed | |
577 | // | |
578 | ||
579 | if ( !fTree ) return; | |
580 | //in case of the first call create run type and calibration type entries | |
581 | if (first){ | |
582 | FillRunTypes(); | |
583 | FillCalibTypes(); | |
584 | } | |
585 | //activate all branches | |
586 | fTree->SetBranchStatus("*",1); | |
587 | //reset variables list | |
588 | fListVariables->RemoveAll(); | |
589 | //get selected calibration types | |
590 | TList calibTypes; | |
591 | fListCalibType->GetSelectedEntries(&calibTypes); | |
592 | ||
593 | TObjArray *branchList = fTree->GetListOfBranches(); | |
594 | if ( !branchList ) return; | |
595 | TIter nextBranch(branchList); | |
596 | Int_t idCount=0,id=0; | |
597 | TObject *objBranch=0; | |
598 | while ( (objBranch=nextBranch()) ){ | |
599 | TString branchName(objBranch->GetName()); | |
600 | TString branchTitle(objBranch->GetName()); | |
601 | if (branchName == "run" || branchName == "time" || branchName == "runType.") continue; | |
602 | Bool_t active=kTRUE; | |
603 | TString calibType="UNSPECIFIED"; | |
604 | if (fConfigParser){ | |
605 | const TObject *key=(*fConfigParser)(branchName.Data()); | |
606 | if (key){ | |
607 | //test if branch is active | |
608 | active=fConfigParser->GetValue(branchName.Data(),kBranchOnOff); | |
609 | id=(*fConfigParser)()->IndexOf(key); | |
892226be | 610 | // branchTitle=fConfigParser->GetData(key,kBranchTitle); |
6fb51ca4 | 611 | calibType=fConfigParser->GetData(key,kCalibType); |
612 | } | |
613 | else{ | |
614 | id=1000+idCount; | |
615 | } | |
616 | } else { | |
617 | id=idCount; | |
618 | } | |
e6970ab5 | 619 | if (calibType.IsNull()) calibType="UNSPECIFIED"; |
6fb51ca4 | 620 | //check if branch is in selected calibration types |
621 | //if not, don't show it in the list and deactivate the branch. | |
622 | Bool_t calibActive=kFALSE; | |
623 | TIter nextCalib(&calibTypes); | |
624 | TObject *objCalib=0; | |
e6970ab5 | 625 | while ( (objCalib=nextCalib()) ) |
6fb51ca4 | 626 | if (calibType==objCalib->GetTitle()) calibActive=kTRUE; |
627 | active&=calibActive; | |
628 | if (!active){ | |
629 | TString s=branchName; | |
630 | if (branchName.EndsWith(".")) s+="*"; | |
631 | fTree->SetBranchStatus(s.Data(),0); | |
632 | continue; | |
633 | } | |
1d32f273 | 634 | // fListVariables->AddEntry(SubstituteUnderscores(branchTitle.Data()),id); |
635 | fListVariables->AddEntry(branchTitle.Data(),id); | |
6fb51ca4 | 636 | ++idCount; |
637 | } | |
638 | //trick to display modifications | |
1d32f273 | 639 | fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight()); |
640 | fListVariables->Resize(fListVariables->GetWidth()+1, fListVariables->GetHeight()); | |
6fb51ca4 | 641 | } |
642 | //______________________________________________________________________________ | |
7390f655 | 643 | void AliTPCCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const char* refName) |
644 | { | |
645 | // | |
646 | // map of reference trees that should always be attached to the CalibViewerGUI | |
647 | // | |
648 | fMapRefTrees->Add(new TObjString(refName), new TObjString(treeFileName)); | |
649 | ||
650 | } | |
651 | //______________________________________________________________________________ | |
5312f439 | 652 | const char* AliTPCCalibViewerGUItime::GetDrawString(){ |
653 | // | |
654 | // create draw string for ttree by combining the user requestsa | |
655 | // | |
656 | ||
657 | TString selectedVariable=""; | |
6fb51ca4 | 658 | Int_t id=-1; |
659 | if (!fListVariables->GetSelectedEntry()) return ""; | |
660 | selectedVariable = fListVariables->GetSelectedEntry()->GetTitle(); | |
661 | id=fListVariables->GetSelectedEntry()->EntryId(); | |
662 | // printf("id: %d\n",id); | |
663 | TString branchName=selectedVariable; | |
664 | const TObject *key=(*fConfigParser)(id); | |
665 | if (key) branchName=(*fConfigParser)(id)->GetName(); | |
5312f439 | 666 | //treat case of TVector |
6fb51ca4 | 667 | if (branchName.EndsWith(".")){ |
5312f439 | 668 | Int_t par = (Int_t)(fNmbPar->GetNumber()); |
6fb51ca4 | 669 | branchName.Append(Form("fElements[%d]",par)); |
5312f439 | 670 | } |
671 | // if (fRadioXrun->GetState()==kButtonDown) | |
672 | // selectedVariable.Append(":run"); | |
673 | // if (fRadioXtime->GetState()==kButtonDown) | |
674 | // selectedVariable.Append(":time"); | |
675 | ||
6fb51ca4 | 676 | return branchName.Data(); |
5312f439 | 677 | } |
678 | //______________________________________________________________________________ | |
514fcaf7 | 679 | const char* AliTPCCalibViewerGUItime::GetDrawOptionString(){ |
6e7d7dc4 | 680 | // |
681 | // get user selected draw options | |
682 | // | |
683 | TString drawOpt; | |
684 | if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle(); | |
685 | if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase)) | |
686 | drawOpt+="same"; | |
687 | return drawOpt.Data(); | |
688 | } | |
689 | //______________________________________________________________________________ | |
690 | void AliTPCCalibViewerGUItime::GetCutString(TString &cutStr){ | |
5312f439 | 691 | // |
692 | // create cut string | |
693 | // | |
694 | TCut cuts(fComboCustomCuts->GetTextEntry()->GetText()); | |
695 | TString runType=""; | |
696 | if (fComboRunType->GetSelectedEntry()) runType=fComboRunType->GetSelectedEntry()->GetTitle(); | |
697 | if (runType!="ALL"&&!runType.IsNull()) cuts+=Form("runType.String().Data()==\"%s\"",runType.Data()); | |
6e7d7dc4 | 698 | cutStr=cuts.GetTitle(); |
699 | } | |
700 | //______________________________________________________________________________ | |
701 | void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph) | |
702 | { | |
703 | // | |
704 | // | |
705 | // | |
706 | if (!withGraph){ | |
707 | fValuesX.ResizeTo(1); | |
708 | fValuesY.ResizeTo(1); | |
709 | fRunNumbers.ResizeTo(1); | |
710 | fTimeStamps.ResizeTo(1); | |
711 | } else { | |
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()); | |
719 | } | |
720 | } | |
721 | //______________________________________________________________________________ | |
722 | void AliTPCCalibViewerGUItime::GetHistogramTitle(TString &title) | |
723 | { | |
724 | // | |
725 | // Create string for histogram title | |
726 | // | |
727 | ||
728 | title=fDrawString; | |
729 | Int_t pos=title.First(">>"); | |
730 | if (pos>0) title=title(0,pos); | |
1d32f273 | 731 | // if (!fIsCustomDraw){ |
6e7d7dc4 | 732 | if (fRadioXrun->GetState()==kButtonDown){ |
733 | title+=":Run"; | |
734 | } else if (fRadioXtime->GetState()==kButtonDown){ | |
735 | title+=":Date"; | |
736 | } | |
1d32f273 | 737 | // } |
6e7d7dc4 | 738 | TString cuts; |
739 | GetCutString(cuts); | |
740 | TObjArray *arr=title.Tokenize(":"); | |
741 | TObject *o=0x0; | |
742 | title+=" {"; | |
743 | title+=cuts; | |
744 | title+="}"; | |
745 | TIter next(arr,kIterBackward); | |
746 | while ( (o=next()) ){ | |
747 | TString varName=o->GetName(); | |
748 | title+=";"; | |
749 | //substitue variable names with names in configuration file if available | |
750 | if ((*fConfigParser)()->GetEntries()){ | |
751 | TString branchName=varName; | |
752 | Int_t par=0; | |
753 | if (branchName.Contains('.')) branchName=branchName(0,branchName.First('.')+1); | |
754 | //chek if a configuration for that branch is available | |
755 | const TObject *oBranch=(*fConfigParser)(branchName.Data()); | |
756 | if (oBranch){ | |
757 | TString branchTitle=fConfigParser->GetData(oBranch,kBranchTitle); | |
758 | if (!branchTitle.IsNull()){ | |
759 | //check for TVectorT type branch | |
760 | //add parameter name if available | |
761 | if (varName.Contains("fElements")){ | |
762 | TString parStr=varName(varName.First('[')+1,varName.Length()-varName.First('[')-2); | |
763 | par=parStr.Atoi(); | |
764 | branchTitle+=": "; | |
765 | TString yparname=fConfigParser->GetData(oBranch,par+kParamNames); | |
766 | if (!yparname.IsNull()){ | |
767 | branchTitle+=yparname; | |
768 | } else { | |
769 | branchTitle+="["; | |
770 | branchTitle+=par; | |
771 | branchTitle+="]"; | |
772 | } | |
773 | } | |
774 | } | |
775 | varName=SubstituteUnderscores(branchTitle.Data()); | |
776 | } | |
777 | } | |
778 | title+=varName; | |
779 | } | |
780 | delete arr; | |
5312f439 | 781 | } |
782 | //______________________________________________________________________________ | |
7390f655 | 783 | void AliTPCCalibViewerGUItime::AdjustYRange() |
784 | { | |
785 | // | |
786 | // | |
787 | // | |
788 | TIter nextGraphicObject(fTrashBox); | |
789 | TObject *o=0x0; | |
790 | Float_t min=0,max=0; | |
791 | while ( (o=nextGraphicObject()) ){ | |
792 | if (o->IsA()==TGraph::Class()){ | |
793 | TGraph *gr=(TGraph*)o; | |
794 | if (min==max) { | |
795 | min=TMath::MinElement(gr->GetN(),gr->GetY()); | |
796 | max=TMath::MaxElement(gr->GetN(),gr->GetY()); | |
797 | } else { | |
798 | Float_t currmin=TMath::MinElement(gr->GetN(),gr->GetY()); | |
799 | Float_t currmax=TMath::MaxElement(gr->GetN(),gr->GetY()); | |
800 | if (currmax>max) max=currmax; | |
801 | if (currmin<min) min=currmin; | |
802 | } | |
803 | } | |
804 | } | |
805 | if (min!=max){ | |
806 | if (min!=0) min=min-(max-min)/10; | |
807 | if (max!=0) max=max+(max-min)/10; | |
808 | fCurrentHist->SetMinimum(min); | |
809 | fCurrentHist->SetMaximum(max); | |
810 | } | |
811 | } | |
812 | //______________________________________________________________________________ | |
5312f439 | 813 | void AliTPCCalibViewerGUItime::DoDraw() { |
7390f655 | 814 | // |
815 | // Draw graphics | |
816 | // | |
5312f439 | 817 | TString drawString=fDrawString; |
6e7d7dc4 | 818 | TString cutString; |
819 | GetCutString(cutString); | |
514fcaf7 | 820 | TString optString = GetDrawOptionString(); |
6e7d7dc4 | 821 | Bool_t graphOutput=!fNoGraph; //ttree buffer for V1, V2... too small |
822 | graphOutput&=(drawString.First(">>")<0); //histogram output in custom draw | |
823 | graphOutput&=fRadioXhist->GetState()!=kButtonDown; //histogram drawing selected | |
514fcaf7 | 824 | // graphOutput&=!(fIsCustomDraw&&!fDrawString.Contains(":")); //custom draw 1D |
825 | // graphOutput&=fDrawString.CountChar(':')<2; //custom draw 1D | |
826 | if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist); | |
1d32f273 | 827 | if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist); |
6e7d7dc4 | 828 | Bool_t drawSame=optString.Contains("same",TString::kIgnoreCase); |
829 | // optString+="goff"; | |
830 | if (graphOutput) { | |
831 | drawString.Prepend("run:time:"); | |
832 | optString="goff"; | |
833 | }else{ | |
1d32f273 | 834 | // if (!fIsCustomDraw){ |
6e7d7dc4 | 835 | if (fRadioXrun->GetState()==kButtonDown){ |
836 | drawString+=":run"; | |
837 | } else if (fRadioXtime->GetState()==kButtonDown){ | |
838 | drawString+=":time"; | |
839 | } | |
1d32f273 | 840 | // } |
6e7d7dc4 | 841 | } |
5312f439 | 842 | TVirtualPad *padsave=gPad; |
843 | fCanvMain->GetCanvas()->cd(); | |
6e7d7dc4 | 844 | //delete old histograms and graphs |
845 | if (!drawSame){ | |
846 | fTrashBox->Delete(); | |
5312f439 | 847 | fCurrentGraph=0x0; |
5312f439 | 848 | fCurrentHist=0x0; |
849 | } | |
5312f439 | 850 | //select data |
851 | fTree->Draw(drawString.Data(),cutString.Data(),optString.Data()); | |
852 | if (fTree->GetSelectedRows()==-1) return; | |
6e7d7dc4 | 853 | UpdateValueArrays(graphOutput); |
854 | TString title; | |
855 | GetHistogramTitle(title); | |
5312f439 | 856 | Bool_t drawGraph=kFALSE; |
6e7d7dc4 | 857 | if (graphOutput){ |
514fcaf7 | 858 | drawGraph=kTRUE; |
859 | if (fIsCustomDraw&&fDrawString.Contains(":")){ | |
6e7d7dc4 | 860 | fValuesX.SetElements(fTree->GetV4()); |
6e7d7dc4 | 861 | }else{ |
6e7d7dc4 | 862 | if (fRadioXrun->GetState()==kButtonDown){ |
863 | fValuesX.SetElements(fTree->GetV1()); | |
864 | } else if (fRadioXtime->GetState()==kButtonDown){ | |
865 | fValuesX.SetElements(fTree->GetV2()); | |
866 | } else { | |
867 | drawGraph=kFALSE; | |
6fb51ca4 | 868 | } |
869 | } | |
514fcaf7 | 870 | } |
871 | // if (graphOutput){ | |
872 | // if (fIsCustomDraw){ | |
873 | // if (fDrawString.Contains(":")){ | |
874 | // fValuesX.SetElements(fTree->GetV4()); | |
875 | // drawGraph=kTRUE; | |
876 | // } else { | |
877 | // drawGraph=kFALSE; | |
878 | // } | |
879 | // }else{ | |
880 | // drawGraph=kTRUE; | |
881 | // if (fRadioXrun->GetState()==kButtonDown){ | |
882 | // fValuesX.SetElements(fTree->GetV1()); | |
883 | // } else if (fRadioXtime->GetState()==kButtonDown){ | |
884 | // fValuesX.SetElements(fTree->GetV2()); | |
885 | // } else { | |
886 | // drawGraph=kFALSE; | |
887 | // } | |
888 | // } | |
889 | // } | |
890 | //create graph according to selection | |
5312f439 | 891 | if (drawGraph){ |
6e7d7dc4 | 892 | TGraph *graph=new TGraph(fValuesX,fValuesY); |
893 | TString grDraw="p"; | |
894 | if (!drawSame) grDraw+="a"; | |
895 | if (!fIsCustomDraw) grDraw+="l"; | |
896 | graph->Draw(grDraw.Data()); | |
897 | graph->SetEditable(kFALSE); | |
898 | TH1 *hist=graph->GetHistogram(); | |
899 | hist->SetTitle(title.Data()); | |
900 | fTrashBox->Add(graph); | |
901 | graph->SetLineColor(fTrashBox->GetEntries()); | |
902 | graph->SetMarkerColor(fTrashBox->GetEntries()); | |
903 | if (!drawSame) { | |
904 | fCurrentGraph=graph; | |
905 | fCurrentHist=hist; | |
906 | } | |
5312f439 | 907 | } else { |
6e7d7dc4 | 908 | TH1 *hist=fTree->GetHistogram(); |
909 | hist->SetTitle(title.Data()); | |
910 | // hist->Draw(optString.Data()); | |
911 | fTrashBox->Add(hist); | |
912 | hist->SetLineColor(fTrashBox->GetEntries()); | |
913 | hist->SetMarkerColor(fTrashBox->GetEntries()); | |
914 | if (!drawSame) fCurrentHist=hist; | |
5312f439 | 915 | } |
916 | ||
5312f439 | 917 | //Set time axis if choosen as x-variables |
1d32f273 | 918 | // if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw&&!drawSame){ |
919 | if (fRadioXtime->GetState()==kButtonDown&&!drawSame){ | |
5312f439 | 920 | TAxis *xaxis=fCurrentHist->GetXaxis(); |
921 | xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}"); | |
922 | xaxis->SetTimeDisplay(1); | |
923 | xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3); | |
924 | xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3); | |
925 | } | |
7390f655 | 926 | if (!drawSame) { |
6fb51ca4 | 927 | //Set title offset |
7390f655 | 928 | fCurrentHist->GetYaxis()->SetTitleOffset(1.5); |
929 | } else { | |
930 | //adjust y-range | |
931 | AdjustYRange(); | |
932 | } | |
5312f439 | 933 | gPad->Modified(); |
934 | gPad->Update(); | |
935 | padsave->cd(); | |
936 | } | |
937 | ||
938 | //______________________________________________________________________________ | |
939 | void AliTPCCalibViewerGUItime::DoDumpRuns() | |
940 | { | |
941 | // | |
942 | // Dump the current run numbers to stdout | |
943 | // | |
6fb51ca4 | 944 | Int_t npoints=fRunNumbers.GetNrows(); |
945 | Int_t *sortIndex = new Int_t[npoints]; | |
946 | TMath::Sort(npoints,fRunNumbers.GetMatrixArray(),sortIndex,kFALSE); | |
947 | Int_t run=0, prevRun=-1; | |
948 | ||
949 | for (Int_t irun=0;irun<npoints;++irun){ | |
950 | run=(Int_t)fRunNumbers.GetMatrixArray()[sortIndex[irun]]; | |
951 | if (run!=prevRun) std::cout << Form("%d",run) << std::endl; | |
952 | prevRun=run; | |
5312f439 | 953 | } |
6fb51ca4 | 954 | delete sortIndex; |
5312f439 | 955 | } |
956 | //______________________________________________________________________________ | |
957 | void AliTPCCalibViewerGUItime::DoParLimitChange() | |
958 | { | |
959 | // | |
960 | // | |
961 | // | |
6fb51ca4 | 962 | UpdateParName(); |
5312f439 | 963 | DoDraw(); |
964 | } | |
965 | //______________________________________________________________________________ | |
966 | void AliTPCCalibViewerGUItime::DoNewSelection() { | |
967 | // | |
968 | // decides whether to redraw if user makes another selection | |
969 | // | |
970 | UpdateParLimits(); | |
971 | fDrawString=GetDrawString(); | |
972 | fIsCustomDraw=kFALSE; | |
973 | DoDraw(); | |
974 | } | |
975 | //______________________________________________________________________________ | |
976 | void AliTPCCalibViewerGUItime::DoCustomDraw() | |
977 | { | |
978 | // | |
979 | // | |
980 | // | |
981 | fDrawString=fComboCustomDraw->GetTextEntry()->GetText(); | |
6e7d7dc4 | 982 | // if (fDrawString.Contains(">>")){ |
983 | // Warning("DoCustomDraw","Currently no user defined histograms allowed!"); | |
984 | // return; | |
985 | // } | |
986 | fNmbPar->SetState(kFALSE); | |
5312f439 | 987 | fIsCustomDraw=kTRUE; |
988 | DoDraw(); | |
989 | } | |
990 | //______________________________________________________________________________ | |
991 | void AliTPCCalibViewerGUItime::DoCustomCutsDraw() | |
992 | { | |
993 | // | |
994 | // | |
995 | // | |
996 | if (fIsCustomDraw) DoCustomDraw(); | |
997 | else { | |
998 | fDrawString=GetDrawString(); | |
999 | fIsCustomDraw=kFALSE; | |
1000 | DoDraw(); | |
1001 | } | |
1002 | } | |
1003 | //______________________________________________________________________________ | |
1004 | void AliTPCCalibViewerGUItime::HandleButtonsDrawSel(Int_t id) | |
1005 | { | |
1006 | // | |
1007 | // Draw selection button handling (x-variable) | |
1008 | // | |
1009 | ||
1010 | if (id == -1) { | |
1011 | TGButton *btn = (TGButton *) gTQSender; | |
1012 | id = btn->WidgetId(); | |
1013 | } | |
1014 | ||
1015 | Bool_t doDraw=kFALSE; | |
1d32f273 | 1016 | Bool_t noDraw=kFALSE; |
1017 | if (id<-1){ | |
1018 | noDraw=kTRUE; | |
1019 | id=TMath::Abs(id); | |
1020 | } | |
5312f439 | 1021 | switch (id) { |
1022 | case (kRadioXhist): | |
1023 | doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown); | |
1024 | if (doDraw){ | |
1025 | fRadioXrun->SetState(kButtonUp); | |
1026 | fRadioXtime->SetState(kButtonUp); | |
1d32f273 | 1027 | fRadioXhist->SetState(kButtonDown); |
5312f439 | 1028 | } |
1029 | break; | |
1030 | case (kRadioXrun): | |
1031 | doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXhist->GetState()==kButtonDown); | |
1032 | if (doDraw){ | |
1033 | fRadioXhist->SetState(kButtonUp); | |
1034 | fRadioXtime->SetState(kButtonUp); | |
1d32f273 | 1035 | fRadioXrun->SetState(kButtonDown); |
5312f439 | 1036 | } |
1037 | break; | |
1038 | case (kRadioXtime): | |
1039 | doDraw=(fRadioXhist->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown); | |
1040 | if (doDraw){ | |
1041 | fRadioXrun->SetState(kButtonUp); | |
1042 | fRadioXhist->SetState(kButtonUp); | |
1d32f273 | 1043 | fRadioXtime->SetState(kButtonDown); |
5312f439 | 1044 | } |
1045 | break; | |
1046 | } | |
1d32f273 | 1047 | if (doDraw&&!noDraw) DoCustomCutsDraw(); |
5312f439 | 1048 | } |
6fb51ca4 | 1049 | //______________________________________________________________________________ |
1050 | void AliTPCCalibViewerGUItime::UpdateParName() | |
1051 | { | |
1052 | // | |
1053 | // change parameter name | |
1054 | // | |
1055 | ||
1056 | Int_t par = (Int_t)(fNmbPar->GetNumber()); | |
7390f655 | 1057 | TString parName=""; |
6fb51ca4 | 1058 | Int_t id=fListVariables->GetSelectedEntry()->EntryId(); |
1059 | if (fConfigParser && (*fConfigParser)(id)) parName=fConfigParser->GetData((*fConfigParser)(id),par+kParamNames); | |
7390f655 | 1060 | if (parName=="") parName.Form("%d",par); |
6fb51ca4 | 1061 | fLblPar->SetText(Form("Parameter: %s",parName.Data())); |
1062 | fDrawString=GetDrawString(); | |
1063 | fIsCustomDraw=kFALSE; | |
1064 | } | |
1065 | ||
5312f439 | 1066 | //______________________________________________________________________________ |
1067 | void AliTPCCalibViewerGUItime::UpdateParLimits() | |
1068 | { | |
1069 | // | |
1070 | // Adjust limits for TVectorT based variables | |
1071 | // | |
1072 | if (!fTree) return; | |
6fb51ca4 | 1073 | TString selectedVariableTitle=""; |
1074 | Int_t id=-1; | |
1075 | if (!fListVariables->GetSelectedEntry()) return; | |
1076 | selectedVariableTitle = fListVariables->GetSelectedEntry()->GetTitle(); | |
1077 | id=fListVariables->GetSelectedEntry()->EntryId(); | |
1078 | // printf("id: %d\n",id); | |
1079 | TString selectedVariable=selectedVariableTitle; | |
1080 | const TObject *key=(*fConfigParser)(id); | |
1081 | if (key) selectedVariable=(*fConfigParser)(id)->GetName(); | |
1082 | ||
5312f439 | 1083 | if (selectedVariable.IsNull()||!selectedVariable.EndsWith(".")) { |
1084 | fNmbPar->SetState(kFALSE); | |
6fb51ca4 | 1085 | fLblPar->SetText("Parameter: none"); |
5312f439 | 1086 | return; |
1087 | } | |
1088 | TVectorD *vD=0x0; | |
1089 | TVectorF *vF=0x0; | |
1090 | Int_t maxPar=0; | |
e6970ab5 | 1091 | fTree->GetEntry(1); |
1092 | TBranch *branch=fTree->GetTree()->GetBranch(selectedVariable.Data()); | |
5312f439 | 1093 | TString branchClass=branch->GetClassName(); |
e6970ab5 | 1094 | Int_t event=0; |
5312f439 | 1095 | if (branchClass=="TVectorT<double>"){ |
e6970ab5 | 1096 | // branch->SetAddress(&vD); |
1097 | fTree->SetBranchAddress(selectedVariable.Data(),&vD); | |
1098 | while (maxPar<2&&event<fTree->GetEntries()){ | |
1099 | fTree->GetEntry(event++); | |
1100 | maxPar=vD->GetNrows(); | |
1101 | } | |
5312f439 | 1102 | } else if (branchClass=="TVectorT<float>"){ |
e6970ab5 | 1103 | // branch->SetAddress(&vF); |
1104 | fTree->SetBranchAddress(selectedVariable.Data(),&vF); | |
1105 | while (maxPar<2&&event<fTree->GetEntries()){ | |
1106 | fTree->GetEntry(event++); | |
1107 | maxPar=vF->GetNrows(); | |
1108 | } | |
5312f439 | 1109 | } else { |
1110 | //class not known | |
1111 | fNmbPar->SetState(kFALSE); | |
1112 | return; | |
1113 | } | |
e6970ab5 | 1114 | // branch->ResetAddress(); |
6e7d7dc4 | 1115 | fTree->SetBranchAddress(selectedVariable.Data(),0x0); |
7390f655 | 1116 | if (fNmbPar->GetNumMax()!=maxPar-1) fNmbPar->SetNumber(0); |
5312f439 | 1117 | fNmbPar->SetLimitValues(0,maxPar-1); |
1118 | fNmbPar->SetState(kTRUE); | |
6fb51ca4 | 1119 | UpdateParName(); |
5312f439 | 1120 | } |
1121 | //______________________________________________________________________________ | |
6fb51ca4 | 1122 | void AliTPCCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/) |
5312f439 | 1123 | { |
1124 | // | |
1125 | // handle mouse events in the draw canvas | |
1126 | // | |
5312f439 | 1127 | UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0; |
1128 | Double_t valx=0.,valy=0.; | |
1129 | if (!fCurrentGraph) { | |
1130 | fLblRunNumberVal->SetText(Form("%05u",run)); | |
e6970ab5 | 1131 | fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS)); |
892226be | 1132 | fLblValueXVal->SetText(Form("%.3e", valx)); |
1133 | fLblValueYVal->SetText(Form("%.3e", valy)); | |
5312f439 | 1134 | return; |
1135 | } | |
1136 | TVirtualPad *padsave=gPad; | |
1137 | fCanvMain->GetCanvas()->cd(); | |
1138 | Int_t n=fValuesY.GetNrows(); | |
1139 | Double_t *arr=0x0; | |
1140 | arr=fValuesX.GetMatrixArray(); | |
1141 | ||
1142 | Int_t minDist=1000000; | |
1143 | Int_t minPoint=-1; | |
1144 | for (Int_t i=0;i<n;++i){ | |
1145 | Int_t pxp = gPad->XtoAbsPixel(gPad->XtoPad(arr[i])); | |
1146 | Int_t pyp = gPad->YtoAbsPixel(gPad->YtoPad(fValuesY[i])); | |
e6970ab5 | 1147 | Int_t d = TMath::Nint(TMath::Sqrt(TMath::Abs(pxp-x) + TMath::Abs(pyp-y))); |
5312f439 | 1148 | if (d < minDist) { |
1149 | minDist = d; | |
1150 | minPoint = i; | |
1151 | } | |
1152 | } | |
1153 | if (minDist<2){ | |
1154 | TTimeStamp t((Int_t)fTimeStamps[minPoint]); | |
1155 | t.GetDate(kTRUE,0,&yy,&mm,&dd); | |
1156 | t.GetTime(kTRUE,0,&HH,&MM,&SS); | |
1157 | run=(UInt_t)fRunNumbers[minPoint]; | |
1158 | valx=fValuesX[minPoint]; | |
1159 | valy=fValuesY[minPoint]; | |
1160 | } else { | |
1161 | dd=0;mm=0;yy=0;HH=0;MM=0;SS=0;run=0; | |
1162 | valx=0.; | |
1163 | valy=0.; | |
1164 | } | |
1165 | fLblRunNumberVal->SetText(Form("%05u",run)); | |
1166 | fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS)); | |
1167 | if (fIsCustomDraw){ | |
892226be | 1168 | fLblValueXVal->SetText(Form("%.3e", valx)); |
5312f439 | 1169 | }else{ |
1170 | if (fRadioXrun->GetState()==kButtonDown){ | |
1171 | fLblValueXVal->SetText("Run"); | |
1172 | } else if (fRadioXtime->GetState()==kButtonDown){ | |
1173 | fLblValueXVal->SetText("Time"); | |
1174 | } | |
1175 | } | |
892226be | 1176 | fLblValueYVal->SetText(Form("%.3e", valy)); |
5312f439 | 1177 | padsave->cd(); |
1178 | if (run==0) return; | |
1179 | if (event == kButton1Double ){ | |
1180 | SetGuiTree(run); | |
1181 | } | |
1182 | //find closes point of current selection | |
1183 | } | |
1184 | //______________________________________________________________________________ | |
1185 | void AliTPCCalibViewerGUItime::SetGuiTree(Int_t run) | |
1186 | { | |
1187 | // | |
1188 | // create the AliTPCCalibViewerGUI tree for run | |
1189 | // cache tree in directory fOutputCacheDir | |
1190 | // retrieve file from this directory if it already exists | |
1191 | // | |
1192 | ||
1193 | //try to find file for run in fOutputCacheDir | |
1194 | TString fileName=fOutputCacheDir; | |
1195 | if (!fileName.EndsWith("/")) fileName+="/"; | |
1196 | fileName+=Form("guiTreeRun_%d.root",run); | |
7390f655 | 1197 | Bool_t load=kTRUE; |
5312f439 | 1198 | TFile f(fileName.Data()); |
7390f655 | 1199 | if (!f.IsOpen()){ |
1200 | load=AliTPCcalibDB::CreateGUITree(run,fileName.Data()); | |
1201 | if (!load){ | |
1202 | fCalibViewerGUI->Reset(); | |
1203 | if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX"))); | |
1204 | return; | |
1205 | } | |
5312f439 | 1206 | } |
1207 | f.Close(); | |
7390f655 | 1208 | fCalibViewerGUI->Initialize(fileName.Data()); |
1209 | if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run))); | |
1210 | TIter nextRefTree(fMapRefTrees); | |
1211 | TObject *o=0x0; | |
1212 | while ( (o=nextRefTree()) ){ | |
1213 | fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"calPads",o->GetName()); | |
5312f439 | 1214 | } |
7390f655 | 1215 | fCalibViewerGUI->Reload(); |
5312f439 | 1216 | } |
1217 | //______________________________________________________________________________ | |
6fb51ca4 | 1218 | const char* AliTPCCalibViewerGUItime::SubstituteUnderscores(const char* in) |
1219 | { | |
1220 | // | |
1221 | // | |
1222 | // | |
1223 | TString s(in); | |
1224 | s.ReplaceAll("_{","|{"); | |
1225 | s.ReplaceAll("_"," "); | |
1226 | s.ReplaceAll("|{","_{"); | |
1227 | return s.Data(); | |
1228 | } | |
514fcaf7 | 1229 | |
1230 | //______________________________________________________________________________ | |
1231 | void AliTPCCalibViewerGUItime::DoNewSelectionAliases() | |
1232 | { | |
1233 | // | |
1234 | // | |
1235 | // | |
1236 | if (!fTree) return; | |
1237 | TList *l=fTree->GetListOfAliases(); | |
1238 | if (!l) return; | |
1239 | TString selectedVariable=""; | |
1240 | if (!fListAliases->GetSelectedEntry()) return; | |
1241 | selectedVariable = fListAliases->GetSelectedEntry()->GetTitle(); | |
1242 | fDrawString=selectedVariable; | |
1243 | fIsCustomDraw=kFALSE; | |
1244 | DoDraw(); | |
1245 | } | |
1246 | //______________________________________________________________________________ | |
1247 | void AliTPCCalibViewerGUItime::DoAddAlias() | |
1248 | { | |
1249 | // | |
1250 | // | |
1251 | // | |
1252 | new AliTPCCalibViewerGUItimeAddAliasFrame(gClient->GetRoot(), fContTopBottom, 400, 200, kVerticalFrame, this); | |
1253 | } | |
1254 | //______________________________________________________________________________ | |
1255 | void AliTPCCalibViewerGUItime::DoDelAlias() | |
1256 | { | |
1257 | // | |
1258 | // | |
1259 | // | |
1260 | if (!fTree) return; | |
1261 | TList *l=fTree->GetListOfAliases(); | |
1262 | if (!l) return; | |
1263 | TString selectedVariable=""; | |
1264 | if (!fListAliases->GetSelectedEntry()) return; | |
1265 | selectedVariable = fListAliases->GetSelectedEntry()->GetTitle(); | |
1266 | l->Remove(l->FindObject(selectedVariable.Data())); | |
1267 | UpdateAliasList(); | |
1268 | } | |
1269 | ||
1270 | //______________________________________________________________________________ | |
1271 | void AliTPCCalibViewerGUItime::UpdateAliasList() | |
1272 | { | |
1273 | // | |
1274 | // | |
1275 | // | |
1276 | printf("UpdateAliasList\n"); | |
1277 | if (!fTree) return; | |
1278 | TList *l=fTree->GetListOfAliases(); | |
1279 | if (!l) return; | |
1280 | TIter nextAlias(l); | |
1281 | TObject *o; | |
1282 | fListAliases->RemoveAll(); | |
1283 | Int_t id=0; | |
1284 | while( (o=nextAlias()) ){ | |
1285 | fListAliases->AddEntry(o->GetName(),id++); | |
1286 | } | |
1287 | fListAliases->Resize(fListAliases->GetWidth()-1, fListAliases->GetHeight()); | |
1288 | fListAliases->Resize(fListAliases->GetWidth()+1, fListAliases->GetHeight()); | |
1289 | } | |
6fb51ca4 | 1290 | //______________________________________________________________________________ |
6e7d7dc4 | 1291 | TObjArray* AliTPCCalibViewerGUItime::ShowGUI(const char* fileName, const char* treeName) { |
5312f439 | 1292 | // |
1293 | // Initialize and show GUI for presentation for demonstration purposes | |
1294 | // or for fast standalone use | |
1295 | // | |
1296 | TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600); | |
1297 | frmMain->SetWindowName("AliTPCCalibViewer GUItime"); | |
1298 | frmMain->SetCleanup(kDeepCleanup); | |
1299 | ||
1300 | TGTab* tabMain = new TGTab(frmMain, 1000, 600); | |
1301 | frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
1302 | ||
1303 | TGCompositeFrame* tabCont1 = tabMain->AddTab("Time"); | |
1304 | TGCompositeFrame* tabCont2 = tabMain->AddTab("Detail - XXXXX"); | |
1305 | ||
1306 | AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600); | |
1307 | tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
6e7d7dc4 | 1308 | calibViewerTime->SetConfigFileName("$ALICE_ROOT/TPC/CalibMacros/calibVarDescription.txt"); |
1309 | calibViewerTime->UseFile(fileName, treeName); | |
5312f439 | 1310 | |
1311 | AliTPCCalibViewerGUI* calibViewer = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, 0); | |
1312 | tabCont2->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
1313 | calibViewerTime->SetCalibViewerGUI(calibViewer); | |
1314 | calibViewerTime->SetCalibViewerGUItab(tabMain->GetTabTab(1)); | |
1315 | ||
1316 | ||
1317 | TObjArray *guiArray = new TObjArray(); | |
1318 | guiArray->Add(calibViewerTime); | |
1319 | guiArray->Add(calibViewer); | |
1320 | ||
1321 | frmMain->MapSubwindows(); | |
1322 | frmMain->Resize(); | |
1323 | frmMain->MapWindow(); | |
1324 | ||
1325 | return guiArray; | |
1326 | } | |
1327 | ||
6e7d7dc4 | 1328 | //______________________________________________________________________________ |
1329 | TObjArray* AliTPCCalibViewerGUItime::ShowGUI(TChain *chain) { | |
1330 | // | |
1331 | // Initialize and show GUI for presentation for demonstration purposes | |
1332 | // or for fast standalone use | |
1333 | // | |
1334 | TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600); | |
1335 | frmMain->SetWindowName("AliTPCCalibViewer GUItime"); | |
1336 | frmMain->SetCleanup(kDeepCleanup); | |
1337 | ||
1338 | TGTab* tabMain = new TGTab(frmMain, 1000, 600); | |
1339 | frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
1340 | ||
1341 | TGCompositeFrame* tabCont1 = tabMain->AddTab("Time"); | |
1342 | ||
1343 | AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600); | |
1344 | tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
1345 | calibViewerTime->UseChain(chain); | |
1346 | ||
1347 | TObjArray *guiArray = new TObjArray(); | |
1348 | guiArray->Add(calibViewerTime); | |
1349 | ||
1350 | frmMain->MapSubwindows(); | |
1351 | frmMain->Resize(); | |
1352 | frmMain->MapWindow(); | |
1353 | ||
1354 | return guiArray; | |
1355 | } | |
514fcaf7 | 1356 | |
1357 | ||
1358 | //////////////////////////////////////////////////////////////////////// | |
1359 | // | |
1360 | // GUI Alias frame | |
1361 | // | |
1362 | //////////////////////////////////////////////////////////////////////// | |
1363 | ||
1364 | ||
1365 | ClassImp(AliTPCCalibViewerGUItimeAddAliasFrame) | |
1366 | ||
1367 | AliTPCCalibViewerGUItimeAddAliasFrame::AliTPCCalibViewerGUItimeAddAliasFrame(const TGWindow *p, const TGWindow *main, | |
1368 | UInt_t w, UInt_t h, UInt_t options, | |
1369 | AliTPCCalibViewerGUItime *gui, TString strAlias) : | |
1370 | fMain(0x0), | |
1371 | fTxt1(0x0), | |
1372 | fTxt2(0x0), | |
1373 | fGUI(0x0) | |
1374 | { | |
1375 | fMain = new TGTransientFrame(p, main, w, h, options); | |
1376 | fMain->Connect("CloseWindow()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()"); | |
1377 | fMain->DontCallClose(); // to avoid double deletions. | |
1378 | ||
1379 | // use hierarchical cleaning | |
1380 | fMain->SetCleanup(kDeepCleanup); | |
1381 | ||
1382 | //layout | |
1383 | TGLayoutHints *l1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2); | |
1384 | TGLayoutHints *l2 = new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX, 2, 2, 0, 5); | |
1385 | // TGLayoutHints *l3 = new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5); | |
1386 | ||
1387 | //input fields | |
1388 | TGCompositeFrame *f1 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame); | |
1389 | fMain->AddFrame(f1, l1); | |
1390 | TGCompositeFrame *frameName = new TGCompositeFrame(f1); | |
1391 | TGCompositeFrame *frameFormula = new TGCompositeFrame(f1); | |
1392 | f1->AddFrame(frameName,l2); | |
1393 | f1->AddFrame(frameFormula,l2); | |
1394 | TGLabel *lblTxt1 = new TGLabel(frameName, "Name:"); | |
1395 | TGLabel *lblTxt2 = new TGLabel(frameFormula, "Formula:"); | |
1396 | fTxt1 = new TGTextEntry(frameName, new TGTextBuffer(1000)); | |
1397 | fTxt2 = new TGTextEntry(frameFormula, new TGTextBuffer(1000)); | |
1398 | ||
1399 | frameName->AddFrame(lblTxt1, l2); | |
1400 | frameName->AddFrame(fTxt1, l2); | |
1401 | frameFormula->AddFrame(lblTxt2, l2); | |
1402 | frameFormula->AddFrame(fTxt2, l2); | |
1403 | ||
1404 | fTxt1->Resize(350, fTxt1->GetDefaultHeight()); | |
1405 | fTxt2->Resize(350, fTxt2->GetDefaultHeight()); | |
1406 | ||
1407 | //ok and cancel buttons | |
1408 | TGHorizontalFrame *frame = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth); | |
1409 | ||
1410 | TGTextButton *okButton = new TGTextButton(frame, "&Ok", 1); | |
1411 | okButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoOK()"); | |
1412 | TGTextButton *cancelButton = new TGTextButton(frame, "&Cancel", 2); | |
1413 | cancelButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()"); | |
1414 | ||
1415 | ||
1416 | frame->AddFrame(okButton, l1); | |
1417 | frame->AddFrame(cancelButton, l1); | |
1418 | ||
1419 | frame->Resize(150, okButton->GetDefaultHeight()); | |
1420 | ||
1421 | fMain->AddFrame(frame, new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1)); | |
1422 | ||
1423 | fGUI=gui; | |
1424 | TString aliasName, alias; | |
1425 | if (!strAlias.IsNull()){ | |
1426 | TChain *c=fGUI->GetChain(); | |
1427 | if (c){ | |
1428 | TList *l=c->GetListOfAliases(); | |
1429 | if (l){ | |
1430 | TNamed *d=(TNamed*)l->FindObject(strAlias); | |
1431 | if (d){ | |
1432 | aliasName=d->GetName(); | |
1433 | alias=d->GetTitle(); | |
1434 | } | |
1435 | } | |
1436 | } | |
1437 | }else{ | |
1438 | alias=fGUI->GetCustomDrawString(); | |
1439 | } | |
1440 | fTxt1->SetText(aliasName.Data(),kFALSE); | |
1441 | fTxt2->SetText(alias.Data(),kFALSE); | |
1442 | ||
1443 | fMain->MapSubwindows(); | |
1444 | fMain->Resize(); | |
1445 | ||
1446 | // position relative to the parent's window | |
1447 | fMain->CenterOnParent(); | |
1448 | ||
1449 | fMain->SetWindowName("Alias Editor"); | |
1450 | ||
1451 | fMain->MapWindow(); | |
1452 | ||
1453 | } | |
1454 | //______________________________________________________________________________ | |
1455 | AliTPCCalibViewerGUItimeAddAliasFrame::~AliTPCCalibViewerGUItimeAddAliasFrame() | |
1456 | { | |
1457 | // | |
1458 | // | |
1459 | // | |
1460 | fMain->DeleteWindow(); // deletes fMain | |
1461 | } | |
1462 | //______________________________________________________________________________ | |
1463 | void AliTPCCalibViewerGUItimeAddAliasFrame::DoOK() | |
1464 | { | |
1465 | // | |
1466 | // | |
1467 | // | |
1468 | TString aliasName=fTxt1->GetText(); | |
1469 | TString alias=fTxt2->GetText(); | |
1470 | if (!aliasName.IsNull()&&!alias.IsNull()){ | |
1471 | TChain *c=fGUI->GetChain(); | |
1472 | if (c){ | |
1473 | c->SetAlias(aliasName.Data(),alias.Data()); | |
1474 | } | |
1475 | } | |
1476 | fGUI->UpdateAliasList(); | |
1477 | delete this; | |
1478 | } | |
1479 | //______________________________________________________________________________ | |
1480 | void AliTPCCalibViewerGUItimeAddAliasFrame::DoCancel() | |
1481 | { | |
1482 | // | |
1483 | // | |
1484 | // | |
1485 | delete this; | |
1486 | } | |
1487 |