]>
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), | |
133 | //content bottom | |
134 | fContCustom(0x0), | |
135 | fContCustomCuts(0x0), | |
136 | fLblCustomDraw(0x0), | |
137 | fLblCustomCuts(0x0), | |
138 | fComboCustomDraw(0x0), | |
6e7d7dc4 | 139 | fComboCustomCuts(0x0), |
140 | fTrashBox(new TObjArray) | |
5312f439 | 141 | { |
142 | // | |
143 | // ctor | |
144 | // | |
7390f655 | 145 | fMapRefTrees->SetOwnerKeyValue(); |
146 | fTrashBox->SetOwner(); | |
5312f439 | 147 | DrawGUI(p,w,h); |
6e7d7dc4 | 148 | gStyle->SetMarkerStyle(20); |
149 | gStyle->SetMarkerSize(0.5); | |
5312f439 | 150 | SetInitialValues(); |
151 | } | |
152 | //______________________________________________________________________________ | |
153 | AliTPCCalibViewerGUItime::~AliTPCCalibViewerGUItime(){ | |
154 | // | |
155 | // dtor | |
156 | // | |
6e7d7dc4 | 157 | delete fConfigParser; |
158 | delete fTrashBox; | |
7390f655 | 159 | delete fMapRefTrees; |
5312f439 | 160 | } |
161 | //______________________________________________________________________________ | |
6fb51ca4 | 162 | void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) { |
5312f439 | 163 | // |
164 | // draw the GUI | |
165 | // | |
166 | // ====================================================================== | |
167 | // ************************* Display everything ************************* | |
168 | // ====================================================================== | |
169 | ||
170 | SetCleanup(kDeepCleanup); | |
5312f439 | 171 | |
172 | // ***************************************************************************** | |
173 | // ************************* content of this MainFrame ************************* | |
174 | // ***************************************************************************** | |
175 | // top level container with horizontal layout | |
176 | fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight); | |
177 | AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
178 | ||
179 | fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight); | |
180 | fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
181 | ||
182 | // *********************************************************************** | |
183 | // ************************* content of fContLCR ************************* | |
184 | // *********************************************************************** | |
185 | // left container | |
186 | fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight); | |
187 | fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3)); | |
188 | ||
189 | // left vertical splitter | |
190 | TGVSplitter *splitLeft = new TGVSplitter(fContLCR); | |
191 | splitLeft->SetFrame(fContLeft, kTRUE); | |
192 | fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0)); | |
193 | ||
194 | // right container | |
195 | fContRight = new TGCompositeFrame(fContLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight); | |
196 | fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3)); | |
197 | ||
198 | // center container | |
199 | fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight); | |
200 | fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
201 | ||
202 | // right vertical splitter | |
203 | TGVSplitter *splitRight = new TGVSplitter(fContLCR); | |
204 | splitRight->SetFrame(fContRight, kFALSE); | |
205 | fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0)); | |
206 | ||
207 | ||
208 | // ======================================================================== | |
209 | // ************************* content of fContLeft ************************* | |
210 | // ======================================================================== | |
211 | // --- draw button and tabLeft --- | |
6e7d7dc4 | 212 | // draw options |
213 | fContDrawOpt = new TGGroupFrame(fContLeft, "Draw options", kVerticalFrame | kFitWidth | kFitHeight); | |
214 | fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); | |
215 | fChkDrawOptSame = new TGCheckButton(fContDrawOpt, "Same"); | |
216 | fContDrawOpt->AddFrame(fChkDrawOptSame, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0)); | |
217 | fChkDrawOptSame->SetToolTipText("Add draw option 'same'"); | |
218 | // additional draw options combo box | |
219 | fComboAddDrawOpt = new TGComboBox(fContDrawOpt); | |
220 | fComboAddDrawOpt->Resize(0, 22); | |
221 | fComboAddDrawOpt->EnableTextInput(kTRUE); | |
222 | fContDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
223 | // fComboAddDrawOpt->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral(=14)"); | |
224 | // fComboAddDrawOpt->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()"); | |
225 | ||
5312f439 | 226 | // draw selection group |
227 | fContDrawSel = new TGGroupFrame(fContLeft, "Draw selection", kVerticalFrame | kFitWidth | kFitHeight); | |
228 | fContLeft->AddFrame(fContDrawSel, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0)); | |
229 | //x-axis variables selection, Run of Time | |
230 | fContDrawSelSubRunTime = new TGCompositeFrame(fContDrawSel, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight); | |
231 | fContDrawSel->AddFrame(fContDrawSelSubRunTime, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0)); | |
232 | ||
233 | // ------------------------- content of fContDrawOpt ------------------------- | |
234 | // | |
235 | // Run radio button | |
236 | // Time radio button | |
237 | fRadioXhist = new TGRadioButton(fContDrawSelSubRunTime, "hist", kRadioXhist); | |
238 | fContDrawSelSubRunTime->AddFrame(fRadioXhist, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0)); | |
239 | fRadioXhist->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()"); | |
240 | fRadioXhist->SetToolTipText("Draw the distribution of the variable"); | |
241 | ||
242 | fRadioXrun = new TGRadioButton(fContDrawSelSubRunTime, ":Run", kRadioXrun); | |
243 | fContDrawSelSubRunTime->AddFrame(fRadioXrun, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0)); | |
244 | fRadioXrun->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()"); | |
245 | fRadioXrun->SetToolTipText("Use run number as x-value"); | |
246 | ||
247 | // Time radio button | |
248 | fRadioXtime = new TGRadioButton(fContDrawSelSubRunTime, ":Time", kRadioXtime); | |
249 | fContDrawSelSubRunTime->AddFrame(fRadioXtime, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0)); | |
250 | fRadioXtime->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()"); | |
251 | fRadioXtime->SetToolTipText("Use time stamp number as x-value"); | |
252 | ||
253 | ||
254 | // list of variables | |
255 | fListVariables = new TGListBox(fContDrawSel); | |
256 | fContDrawSel->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
257 | fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelection()"); | |
258 | ||
6fb51ca4 | 259 | |
260 | //-------------------- run type selection ------------------------ | |
5312f439 | 261 | // Parameter label |
262 | fLblRunType = new TGLabel(fContDrawSel, "Run Type:"); | |
263 | fLblRunType->SetTextJustify(kTextLeft); | |
264 | fContDrawSel->AddFrame(fLblRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
265 | ||
266 | fComboRunType = new TGComboBox(fContDrawSel); | |
267 | fComboRunType->EnableTextInput(kFALSE); | |
268 | fContDrawSel->AddFrame(fComboRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
269 | fComboRunType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoDraw()"); | |
270 | // fComboRunType->SetEnabled(kFALSE); | |
271 | fComboRunType->Resize(0, 22); | |
272 | ||
273 | //-------------------- parameter selection ------------------------ | |
274 | // Parameter label | |
275 | fLblPar = new TGLabel(fContDrawSel, "Parameter:"); | |
276 | fLblPar->SetTextJustify(kTextLeft); | |
277 | fContDrawSel->AddFrame(fLblPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
278 | ||
279 | fNmbPar = new TGNumberEntry(fContDrawSel, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71); | |
280 | fContDrawSel->AddFrame(fNmbPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
281 | fNmbPar->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUItime", this, "DoParLimitChange()"); | |
282 | fNmbPar->SetState(kFALSE); | |
283 | ||
6fb51ca4 | 284 | //-------------------- calibration type selection ------------------------ |
285 | // label | |
286 | // draw selection group | |
287 | fContCalibType = new TGGroupFrame(fContLeft, "Calib type selection", kVerticalFrame | kFitWidth | kFitHeight); | |
288 | fContLeft->AddFrame(fContCalibType, new TGLayoutHints(kLHintsExpandX , 0, 0, 10, 0)); | |
289 | ||
290 | // list of variables | |
291 | fListCalibType = new TGListBox(fContCalibType); | |
292 | fContCalibType->AddFrame(fListCalibType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX , 0, 0, 0, 0)); | |
293 | fListCalibType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoChangeSelectionList()"); | |
294 | fListCalibType->Resize(0,88); | |
295 | fListCalibType->SetMultipleSelections(); | |
296 | ||
5312f439 | 297 | |
298 | // ========================================================================== | |
299 | // ************************* content of fContCenter ************************* | |
300 | // ======================================================================== | |
301 | // main drawing canvas | |
302 | fCanvMain = new TRootEmbeddedCanvas("GUItime_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight); | |
303 | fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
304 | fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliTPCCalibViewerGUItime", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)"); | |
305 | // fCanvMain->GetCanvas()->Connect("RangeAxisChanged()", "AliTPCCalibViewerGUItime", this, "GetMinMax()"); | |
306 | fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed."); | |
6fb51ca4 | 307 | fCanvMain->GetCanvas()->SetRightMargin(0.062); |
308 | fCanvMain->GetCanvas()->SetLeftMargin(0.15); | |
5312f439 | 309 | |
310 | // ========================================================================= | |
311 | // ************************* content of fContRight ************************* | |
312 | // ======================================================================== | |
313 | //group frame for value information | |
314 | fContValues = new TGGroupFrame(fContRight, "Data point info", kVerticalFrame | kFitWidth | kFitHeight); | |
315 | fContRight->AddFrame(fContValues, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); | |
316 | //set layout manager | |
317 | fContValues->SetLayoutManager(new TGMatrixLayout(fContValues, 0, 2, 5)); | |
318 | //value information labels | |
319 | ||
320 | //run number label | |
321 | fLblRunNumber = new TGLabel(fContValues, "Run:"); | |
322 | fLblRunNumber->SetTextJustify(kTextLeft); | |
323 | fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); | |
324 | //run number | |
325 | fLblRunNumberVal = new TGLabel(fContValues, "00000"); | |
326 | fLblRunNumberVal->SetTextJustify(kTextLeft); | |
327 | fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0)); | |
328 | //time stamp label | |
329 | fLblRunTime = new TGLabel(fContValues, "Time:"); | |
330 | fLblRunTime->SetTextJustify(kTextLeft); | |
331 | fContValues->AddFrame(fLblRunTime, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); | |
332 | //run number | |
333 | fLblRunTimeVal = new TGLabel(fContValues, "00.00.0000\n00:00:00"); | |
334 | fLblRunTimeVal->SetTextJustify(kTextLeft); | |
335 | fContValues->AddFrame(fLblRunTimeVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0)); | |
336 | //value label x | |
337 | fLblValueX = new TGLabel(fContValues, "x-Value:"); | |
338 | fLblValueX->SetTextJustify(kTextLeft); | |
339 | fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); | |
340 | //value x | |
892226be | 341 | fLblValueXVal = new TGLabel(fContValues, "00.000e+00"); |
5312f439 | 342 | fLblValueXVal->SetTextJustify(kTextRight); |
343 | fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
344 | //value label y | |
345 | fLblValueY = new TGLabel(fContValues, "y-Value:"); | |
346 | fLblValueY->SetTextJustify(kTextLeft); | |
347 | fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0)); | |
348 | //value y | |
892226be | 349 | fLblValueYVal = new TGLabel(fContValues, "00.000e+00"); |
5312f439 | 350 | fLblValueYVal->SetTextJustify(kTextRight); |
351 | fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
352 | // draw button | |
353 | fBtnDumpRuns = new TGTextButton(fContRight, "&Dump runs"); | |
6fb51ca4 | 354 | fContRight->AddFrame(fBtnDumpRuns, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0)); |
5312f439 | 355 | fBtnDumpRuns->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDumpRuns()"); |
356 | fBtnDumpRuns->SetToolTipText("Press to dump the run numbers of the current selection."); | |
357 | ||
358 | // ========================================================================= | |
359 | // ****************** bottom content of fContTopBottom ********************* | |
360 | // ========================================================================= | |
361 | ||
362 | // custom options container | |
363 | // --- fComboCustom --- the custom draw line on the very low | |
364 | fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
365 | fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0)); | |
366 | ||
367 | // ------------------------- content of fContCustom ------------------------- | |
368 | fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: "); | |
369 | fLblCustomDraw->SetTextJustify(kTextLeft); | |
370 | fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0)); | |
371 | // text field for custom draw command | |
372 | fComboCustomDraw = new TGComboBox(fContCustom); | |
373 | // fComboCustomDraw->Resize(0, fLblValueY->GetDefaultHeight()); | |
374 | fComboCustomDraw->Resize(0, 22); | |
375 | fComboCustomDraw->EnableTextInput(kTRUE); | |
376 | fContCustom->AddFrame(fComboCustomDraw, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
377 | fComboCustomDraw->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()"); | |
378 | fComboCustomDraw->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()"); | |
379 | ||
380 | ||
381 | // additional cuts container | |
382 | fContCustomCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight); | |
383 | fContTopBottom->AddFrame(fContCustomCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0)); | |
384 | ||
385 | // ------------------------- content of fContCustomCuts ------------------------- | |
386 | fLblCustomCuts = new TGLabel(fContCustomCuts, "Custom cuts: "); | |
387 | fLblCustomCuts->SetTextJustify(kTextLeft); | |
388 | fContCustomCuts->AddFrame(fLblCustomCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0)); | |
389 | // combo text field for additional cuts | |
390 | fComboCustomCuts = new TGComboBox(fContCustomCuts); | |
391 | // fComboCustomCuts->Resize(0, fLblValueY->GetDefaultHeight()); | |
392 | fComboCustomCuts->Resize(0, 22); | |
393 | fComboCustomCuts->EnableTextInput(kTRUE); | |
394 | fContCustomCuts->AddFrame(fComboCustomCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0)); | |
6fb51ca4 | 395 | fComboCustomCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()"); |
396 | fComboCustomCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()"); | |
5312f439 | 397 | |
398 | SetWindowName("AliTPCCalibViewer GUI - Time"); | |
399 | MapSubwindows(); | |
400 | Resize(GetDefaultSize()); | |
401 | MapWindow(); | |
402 | } | |
403 | //______________________________________________________________________________ | |
404 | void AliTPCCalibViewerGUItime::SetInitialValues(){ | |
405 | // | |
406 | // Set inital selections of the gui | |
407 | // | |
408 | fRadioXrun->SetState(kButtonDown); | |
409 | fRadioXtime->SetState(kButtonUp); | |
410 | } | |
411 | ||
412 | //______________________________________________________________________________ | |
6e7d7dc4 | 413 | void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeName) { |
5312f439 | 414 | // |
415 | // retrieve tree from file | |
416 | // | |
6e7d7dc4 | 417 | TString s=gSystem->GetFromPipe(Form("ls %s",fileName)); |
418 | // TString s(fileName); | |
e6970ab5 | 419 | TObjArray *arr=s.Tokenize("\n"); |
420 | TIter next(arr); | |
421 | TObject *o=0; | |
422 | if (fTree) delete fTree; | |
6e7d7dc4 | 423 | fTree=new TChain(treeName); |
e6970ab5 | 424 | while ( (o=next()) ){ |
425 | fTree->AddFile(o->GetName()); | |
426 | } | |
427 | delete arr; | |
6e7d7dc4 | 428 | if (!CheckChain()) return; |
429 | UseConfigFile(fConfigFile.Data()); | |
430 | Reload(); | |
431 | ||
432 | } | |
433 | //______________________________________________________________________________ | |
434 | void AliTPCCalibViewerGUItime::UseChain(TChain* chain = 0) | |
435 | { | |
436 | // | |
437 | // | |
438 | // | |
439 | fTree=chain; | |
440 | if (!CheckChain()) return; | |
441 | //set configuration file | |
442 | UseConfigFile(fConfigFile.Data()); | |
443 | Reload(); | |
444 | } | |
445 | //______________________________________________________________________________ | |
446 | Bool_t AliTPCCalibViewerGUItime::CheckChain() | |
447 | { | |
448 | // | |
449 | // check whether cahin has entries | |
450 | // decide whether to draw graphs in 2D | |
451 | // | |
452 | if (!fTree) return kFALSE; | |
e6970ab5 | 453 | fTree->Lookup(); |
6e7d7dc4 | 454 | Long64_t entries=fTree->GetEntries(); |
455 | if (entries==0){ | |
e6970ab5 | 456 | AliError("No entries found in chain"); |
6e7d7dc4 | 457 | return kFALSE; |
6fb51ca4 | 458 | } |
6e7d7dc4 | 459 | //check whether to draw graphs |
460 | CheckDrawGraph(); | |
461 | return kTRUE; | |
462 | } | |
463 | //______________________________________________________________________________ | |
464 | void AliTPCCalibViewerGUItime::UseConfigFile(const char* file) | |
465 | { | |
466 | // | |
467 | // Use 'file' as configuration file | |
468 | // | |
469 | fConfigFile=file; | |
470 | fConfigParser->ParseConfigFileTxt(fConfigFile.Data()); | |
471 | FillCalibTypes(); | |
5312f439 | 472 | } |
473 | //______________________________________________________________________________ | |
6fb51ca4 | 474 | void AliTPCCalibViewerGUItime::FillRunTypes() |
475 | { | |
5312f439 | 476 | // |
6fb51ca4 | 477 | //Loop over the tree entries and fill the run types |
5312f439 | 478 | // |
6fb51ca4 | 479 | if (!fTree) return; |
5312f439 | 480 | Int_t id=0; |
5312f439 | 481 | fComboRunType->RemoveAll(); |
482 | fComboRunType->AddEntry("ALL",id++); | |
483 | fComboRunType->Select(0,kFALSE); | |
6e7d7dc4 | 484 | if (!fTree->GetBranch("runType.")) return; |
5312f439 | 485 | TObjString *runType=0x0; |
486 | Int_t nevets=fTree->GetEntries(); | |
5312f439 | 487 | fTree->SetBranchStatus("*",0); |
488 | fTree->SetBranchStatus("runType.*",1); | |
e6970ab5 | 489 | fTree->SetBranchAddress("runType.",&runType); |
5312f439 | 490 | for (Int_t iev=0;iev<nevets;++iev){ |
491 | fTree->GetEntry(iev); | |
492 | TString type=runType->String(); | |
493 | if (!type.IsNull()&&!fComboRunType->FindEntry(type)) fComboRunType->AddEntry(type,id++); | |
494 | } | |
e6970ab5 | 495 | fTree->ResetBranchAddresses(); |
5312f439 | 496 | fTree->SetBranchStatus("*",1); |
497 | } | |
498 | //______________________________________________________________________________ | |
6fb51ca4 | 499 | void AliTPCCalibViewerGUItime::FillCalibTypes() |
500 | { | |
501 | // | |
502 | // loop over configuration and fill calibration types | |
503 | // | |
6fb51ca4 | 504 | Int_t id=0; |
505 | fListCalibType->RemoveAll(); | |
506 | TObject *o=0x0; | |
507 | fConfigParser->ResetIter(); | |
508 | TString type; | |
509 | while ( (o=fConfigParser->NextKey()) ){ | |
510 | type=fConfigParser->GetData(o,kCalibType); | |
511 | //remove whitespcaces | |
512 | type.Remove(TString::kBoth,' '); | |
513 | type.Remove(TString::kBoth,'\t'); | |
514 | if (type.IsNull()) type="UNSPECIFIED"; | |
515 | // printf("CalibType: '%s'\n",type.Data()); | |
516 | if (!fListCalibType->FindEntry(type.Data())) { | |
517 | fListCalibType->AddEntry(type,id); | |
518 | fListCalibType->Select(id++); | |
519 | } | |
520 | } | |
521 | //add type for unspecified calibration type | |
522 | type="UNSPECIFIED"; | |
523 | if (!fListCalibType->FindEntry(type.Data())) { | |
524 | fListCalibType->AddEntry(SubstituteUnderscores(type.Data()),id); | |
525 | fListCalibType->Select(id++); | |
526 | } | |
527 | } | |
528 | //______________________________________________________________________________ | |
6e7d7dc4 | 529 | void AliTPCCalibViewerGUItime::CheckDrawGraph() |
530 | { | |
531 | // | |
532 | // Check whether to draw graphs in 2D mode based on the number of entries in the chain | |
533 | // GetEstimate() returns the maximum size of the arrays stored in GetV1()... | |
534 | // | |
535 | if (!fTree) return; | |
536 | fNoGraph=kTRUE; | |
537 | if (fTree->GetEntries()<fTree->GetEstimate()) fNoGraph=kFALSE; | |
538 | } | |
539 | //______________________________________________________________________________ | |
540 | void AliTPCCalibViewerGUItime::Reload(Int_t first) | |
541 | { | |
6fb51ca4 | 542 | // |
543 | // reload the gui contents, this is needed after the input tree has changed | |
544 | // | |
545 | ||
546 | if ( !fTree ) return; | |
547 | //in case of the first call create run type and calibration type entries | |
548 | if (first){ | |
549 | FillRunTypes(); | |
550 | FillCalibTypes(); | |
551 | } | |
552 | //activate all branches | |
553 | fTree->SetBranchStatus("*",1); | |
554 | //reset variables list | |
555 | fListVariables->RemoveAll(); | |
556 | //get selected calibration types | |
557 | TList calibTypes; | |
558 | fListCalibType->GetSelectedEntries(&calibTypes); | |
559 | ||
560 | TObjArray *branchList = fTree->GetListOfBranches(); | |
561 | if ( !branchList ) return; | |
562 | TIter nextBranch(branchList); | |
563 | Int_t idCount=0,id=0; | |
564 | TObject *objBranch=0; | |
565 | while ( (objBranch=nextBranch()) ){ | |
566 | TString branchName(objBranch->GetName()); | |
567 | TString branchTitle(objBranch->GetName()); | |
568 | if (branchName == "run" || branchName == "time" || branchName == "runType.") continue; | |
569 | Bool_t active=kTRUE; | |
570 | TString calibType="UNSPECIFIED"; | |
571 | if (fConfigParser){ | |
572 | const TObject *key=(*fConfigParser)(branchName.Data()); | |
573 | if (key){ | |
574 | //test if branch is active | |
575 | active=fConfigParser->GetValue(branchName.Data(),kBranchOnOff); | |
576 | id=(*fConfigParser)()->IndexOf(key); | |
892226be | 577 | // branchTitle=fConfigParser->GetData(key,kBranchTitle); |
6fb51ca4 | 578 | calibType=fConfigParser->GetData(key,kCalibType); |
579 | } | |
580 | else{ | |
581 | id=1000+idCount; | |
582 | } | |
583 | } else { | |
584 | id=idCount; | |
585 | } | |
e6970ab5 | 586 | if (calibType.IsNull()) calibType="UNSPECIFIED"; |
6fb51ca4 | 587 | //check if branch is in selected calibration types |
588 | //if not, don't show it in the list and deactivate the branch. | |
589 | Bool_t calibActive=kFALSE; | |
590 | TIter nextCalib(&calibTypes); | |
591 | TObject *objCalib=0; | |
e6970ab5 | 592 | while ( (objCalib=nextCalib()) ) |
6fb51ca4 | 593 | if (calibType==objCalib->GetTitle()) calibActive=kTRUE; |
594 | active&=calibActive; | |
595 | if (!active){ | |
596 | TString s=branchName; | |
597 | if (branchName.EndsWith(".")) s+="*"; | |
598 | fTree->SetBranchStatus(s.Data(),0); | |
599 | continue; | |
600 | } | |
601 | fListVariables->AddEntry(SubstituteUnderscores(branchTitle.Data()),id); | |
602 | ++idCount; | |
603 | } | |
604 | //trick to display modifications | |
605 | if (!first){ | |
606 | fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight()); | |
607 | fListVariables->Resize(fListVariables->GetWidth()+1, fListVariables->GetHeight()); | |
608 | } | |
609 | } | |
610 | //______________________________________________________________________________ | |
7390f655 | 611 | void AliTPCCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const char* refName) |
612 | { | |
613 | // | |
614 | // map of reference trees that should always be attached to the CalibViewerGUI | |
615 | // | |
616 | fMapRefTrees->Add(new TObjString(refName), new TObjString(treeFileName)); | |
617 | ||
618 | } | |
619 | //______________________________________________________________________________ | |
5312f439 | 620 | const char* AliTPCCalibViewerGUItime::GetDrawString(){ |
621 | // | |
622 | // create draw string for ttree by combining the user requestsa | |
623 | // | |
624 | ||
625 | TString selectedVariable=""; | |
6fb51ca4 | 626 | Int_t id=-1; |
627 | if (!fListVariables->GetSelectedEntry()) return ""; | |
628 | selectedVariable = fListVariables->GetSelectedEntry()->GetTitle(); | |
629 | id=fListVariables->GetSelectedEntry()->EntryId(); | |
630 | // printf("id: %d\n",id); | |
631 | TString branchName=selectedVariable; | |
632 | const TObject *key=(*fConfigParser)(id); | |
633 | if (key) branchName=(*fConfigParser)(id)->GetName(); | |
5312f439 | 634 | //treat case of TVector |
6fb51ca4 | 635 | if (branchName.EndsWith(".")){ |
5312f439 | 636 | Int_t par = (Int_t)(fNmbPar->GetNumber()); |
6fb51ca4 | 637 | branchName.Append(Form("fElements[%d]",par)); |
5312f439 | 638 | } |
639 | // if (fRadioXrun->GetState()==kButtonDown) | |
640 | // selectedVariable.Append(":run"); | |
641 | // if (fRadioXtime->GetState()==kButtonDown) | |
642 | // selectedVariable.Append(":time"); | |
643 | ||
6fb51ca4 | 644 | return branchName.Data(); |
5312f439 | 645 | } |
646 | //______________________________________________________________________________ | |
6e7d7dc4 | 647 | const char* AliTPCCalibViewerGUItime::GetDrawOption(){ |
648 | // | |
649 | // get user selected draw options | |
650 | // | |
651 | TString drawOpt; | |
652 | if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle(); | |
653 | if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase)) | |
654 | drawOpt+="same"; | |
655 | return drawOpt.Data(); | |
656 | } | |
657 | //______________________________________________________________________________ | |
658 | void AliTPCCalibViewerGUItime::GetCutString(TString &cutStr){ | |
5312f439 | 659 | // |
660 | // create cut string | |
661 | // | |
662 | TCut cuts(fComboCustomCuts->GetTextEntry()->GetText()); | |
663 | TString runType=""; | |
664 | if (fComboRunType->GetSelectedEntry()) runType=fComboRunType->GetSelectedEntry()->GetTitle(); | |
665 | if (runType!="ALL"&&!runType.IsNull()) cuts+=Form("runType.String().Data()==\"%s\"",runType.Data()); | |
6e7d7dc4 | 666 | cutStr=cuts.GetTitle(); |
667 | } | |
668 | //______________________________________________________________________________ | |
669 | void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph) | |
670 | { | |
671 | // | |
672 | // | |
673 | // | |
674 | if (!withGraph){ | |
675 | fValuesX.ResizeTo(1); | |
676 | fValuesY.ResizeTo(1); | |
677 | fRunNumbers.ResizeTo(1); | |
678 | fTimeStamps.ResizeTo(1); | |
679 | } else { | |
680 | fValuesX.ResizeTo(fTree->GetSelectedRows()); | |
681 | fValuesY.ResizeTo(fTree->GetSelectedRows()); | |
682 | fRunNumbers.ResizeTo(fTree->GetSelectedRows()); | |
683 | fTimeStamps.ResizeTo(fTree->GetSelectedRows()); | |
684 | fValuesY.SetElements(fTree->GetV3()); | |
685 | fRunNumbers.SetElements(fTree->GetV1()); | |
686 | fTimeStamps.SetElements(fTree->GetV2()); | |
687 | } | |
688 | } | |
689 | //______________________________________________________________________________ | |
690 | void AliTPCCalibViewerGUItime::GetHistogramTitle(TString &title) | |
691 | { | |
692 | // | |
693 | // Create string for histogram title | |
694 | // | |
695 | ||
696 | title=fDrawString; | |
697 | Int_t pos=title.First(">>"); | |
698 | if (pos>0) title=title(0,pos); | |
699 | if (!fIsCustomDraw){ | |
700 | if (fRadioXrun->GetState()==kButtonDown){ | |
701 | title+=":Run"; | |
702 | } else if (fRadioXtime->GetState()==kButtonDown){ | |
703 | title+=":Date"; | |
704 | } | |
705 | } | |
706 | TString cuts; | |
707 | GetCutString(cuts); | |
708 | TObjArray *arr=title.Tokenize(":"); | |
709 | TObject *o=0x0; | |
710 | title+=" {"; | |
711 | title+=cuts; | |
712 | title+="}"; | |
713 | TIter next(arr,kIterBackward); | |
714 | while ( (o=next()) ){ | |
715 | TString varName=o->GetName(); | |
716 | title+=";"; | |
717 | //substitue variable names with names in configuration file if available | |
718 | if ((*fConfigParser)()->GetEntries()){ | |
719 | TString branchName=varName; | |
720 | Int_t par=0; | |
721 | if (branchName.Contains('.')) branchName=branchName(0,branchName.First('.')+1); | |
722 | //chek if a configuration for that branch is available | |
723 | const TObject *oBranch=(*fConfigParser)(branchName.Data()); | |
724 | if (oBranch){ | |
725 | TString branchTitle=fConfigParser->GetData(oBranch,kBranchTitle); | |
726 | if (!branchTitle.IsNull()){ | |
727 | //check for TVectorT type branch | |
728 | //add parameter name if available | |
729 | if (varName.Contains("fElements")){ | |
730 | TString parStr=varName(varName.First('[')+1,varName.Length()-varName.First('[')-2); | |
731 | par=parStr.Atoi(); | |
732 | branchTitle+=": "; | |
733 | TString yparname=fConfigParser->GetData(oBranch,par+kParamNames); | |
734 | if (!yparname.IsNull()){ | |
735 | branchTitle+=yparname; | |
736 | } else { | |
737 | branchTitle+="["; | |
738 | branchTitle+=par; | |
739 | branchTitle+="]"; | |
740 | } | |
741 | } | |
742 | } | |
743 | varName=SubstituteUnderscores(branchTitle.Data()); | |
744 | } | |
745 | } | |
746 | title+=varName; | |
747 | } | |
748 | delete arr; | |
5312f439 | 749 | } |
750 | //______________________________________________________________________________ | |
7390f655 | 751 | void AliTPCCalibViewerGUItime::AdjustYRange() |
752 | { | |
753 | // | |
754 | // | |
755 | // | |
756 | TIter nextGraphicObject(fTrashBox); | |
757 | TObject *o=0x0; | |
758 | Float_t min=0,max=0; | |
759 | while ( (o=nextGraphicObject()) ){ | |
760 | if (o->IsA()==TGraph::Class()){ | |
761 | TGraph *gr=(TGraph*)o; | |
762 | if (min==max) { | |
763 | min=TMath::MinElement(gr->GetN(),gr->GetY()); | |
764 | max=TMath::MaxElement(gr->GetN(),gr->GetY()); | |
765 | } else { | |
766 | Float_t currmin=TMath::MinElement(gr->GetN(),gr->GetY()); | |
767 | Float_t currmax=TMath::MaxElement(gr->GetN(),gr->GetY()); | |
768 | if (currmax>max) max=currmax; | |
769 | if (currmin<min) min=currmin; | |
770 | } | |
771 | } | |
772 | } | |
773 | if (min!=max){ | |
774 | if (min!=0) min=min-(max-min)/10; | |
775 | if (max!=0) max=max+(max-min)/10; | |
776 | fCurrentHist->SetMinimum(min); | |
777 | fCurrentHist->SetMaximum(max); | |
778 | } | |
779 | } | |
780 | //______________________________________________________________________________ | |
5312f439 | 781 | void AliTPCCalibViewerGUItime::DoDraw() { |
7390f655 | 782 | // |
783 | // Draw graphics | |
784 | // | |
5312f439 | 785 | TString drawString=fDrawString; |
6e7d7dc4 | 786 | TString cutString; |
787 | GetCutString(cutString); | |
788 | TString optString = GetDrawOption(); | |
789 | Bool_t graphOutput=!fNoGraph; //ttree buffer for V1, V2... too small | |
790 | graphOutput&=(drawString.First(">>")<0); //histogram output in custom draw | |
791 | graphOutput&=fRadioXhist->GetState()!=kButtonDown; //histogram drawing selected | |
792 | graphOutput&=!(fIsCustomDraw&&!fDrawString.Contains(":")); //custom draw 1D | |
793 | Bool_t drawSame=optString.Contains("same",TString::kIgnoreCase); | |
794 | // optString+="goff"; | |
795 | if (graphOutput) { | |
796 | drawString.Prepend("run:time:"); | |
797 | optString="goff"; | |
798 | }else{ | |
799 | if (!fIsCustomDraw){ | |
800 | if (fRadioXrun->GetState()==kButtonDown){ | |
801 | drawString+=":run"; | |
802 | } else if (fRadioXtime->GetState()==kButtonDown){ | |
803 | drawString+=":time"; | |
804 | } | |
805 | } | |
806 | } | |
5312f439 | 807 | TVirtualPad *padsave=gPad; |
808 | fCanvMain->GetCanvas()->cd(); | |
6e7d7dc4 | 809 | //delete old histograms and graphs |
810 | if (!drawSame){ | |
811 | fTrashBox->Delete(); | |
5312f439 | 812 | fCurrentGraph=0x0; |
5312f439 | 813 | fCurrentHist=0x0; |
814 | } | |
6e7d7dc4 | 815 | // if (fCurrentGraph) { |
816 | // delete fCurrentGraph; | |
817 | // fCurrentGraph=0x0; | |
818 | // //fCurrentHist in case of graph is the interrnal histogram, | |
819 | // // which is deleted by the graph itself. | |
820 | // fCurrentHist=0x0; | |
821 | // } | |
822 | // if (fCurrentHist) { | |
823 | // delete fCurrentHist; | |
824 | // fCurrentHist=0x0; | |
825 | // } | |
5312f439 | 826 | //select data |
827 | fTree->Draw(drawString.Data(),cutString.Data(),optString.Data()); | |
828 | if (fTree->GetSelectedRows()==-1) return; | |
6e7d7dc4 | 829 | UpdateValueArrays(graphOutput); |
830 | TString title; | |
831 | GetHistogramTitle(title); | |
5312f439 | 832 | Bool_t drawGraph=kFALSE; |
6e7d7dc4 | 833 | if (graphOutput){ |
834 | if (fIsCustomDraw){ | |
835 | if (fDrawString.Contains(":")){ | |
836 | fValuesX.SetElements(fTree->GetV4()); | |
837 | drawGraph=kTRUE; | |
838 | } else { | |
839 | drawGraph=kFALSE; | |
840 | } | |
841 | }else{ | |
5312f439 | 842 | drawGraph=kTRUE; |
6e7d7dc4 | 843 | if (fRadioXrun->GetState()==kButtonDown){ |
844 | fValuesX.SetElements(fTree->GetV1()); | |
845 | } else if (fRadioXtime->GetState()==kButtonDown){ | |
846 | fValuesX.SetElements(fTree->GetV2()); | |
847 | } else { | |
848 | drawGraph=kFALSE; | |
6fb51ca4 | 849 | } |
850 | } | |
6e7d7dc4 | 851 | }//create graph according to selection |
5312f439 | 852 | if (drawGraph){ |
6e7d7dc4 | 853 | TGraph *graph=new TGraph(fValuesX,fValuesY); |
854 | TString grDraw="p"; | |
855 | if (!drawSame) grDraw+="a"; | |
856 | if (!fIsCustomDraw) grDraw+="l"; | |
857 | graph->Draw(grDraw.Data()); | |
858 | graph->SetEditable(kFALSE); | |
859 | TH1 *hist=graph->GetHistogram(); | |
860 | hist->SetTitle(title.Data()); | |
861 | fTrashBox->Add(graph); | |
862 | graph->SetLineColor(fTrashBox->GetEntries()); | |
863 | graph->SetMarkerColor(fTrashBox->GetEntries()); | |
864 | if (!drawSame) { | |
865 | fCurrentGraph=graph; | |
866 | fCurrentHist=hist; | |
867 | } | |
5312f439 | 868 | } else { |
6e7d7dc4 | 869 | TH1 *hist=fTree->GetHistogram(); |
870 | hist->SetTitle(title.Data()); | |
871 | // hist->Draw(optString.Data()); | |
872 | fTrashBox->Add(hist); | |
873 | hist->SetLineColor(fTrashBox->GetEntries()); | |
874 | hist->SetMarkerColor(fTrashBox->GetEntries()); | |
875 | if (!drawSame) fCurrentHist=hist; | |
5312f439 | 876 | } |
877 | ||
5312f439 | 878 | //Set time axis if choosen as x-variables |
7390f655 | 879 | if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw&&!drawSame){ |
5312f439 | 880 | TAxis *xaxis=fCurrentHist->GetXaxis(); |
881 | xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}"); | |
882 | xaxis->SetTimeDisplay(1); | |
883 | xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3); | |
884 | xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3); | |
885 | } | |
7390f655 | 886 | if (!drawSame) { |
6fb51ca4 | 887 | //Set title offset |
7390f655 | 888 | fCurrentHist->GetYaxis()->SetTitleOffset(1.5); |
889 | } else { | |
890 | //adjust y-range | |
891 | AdjustYRange(); | |
892 | } | |
5312f439 | 893 | gPad->Modified(); |
894 | gPad->Update(); | |
895 | padsave->cd(); | |
896 | } | |
897 | ||
898 | //______________________________________________________________________________ | |
899 | void AliTPCCalibViewerGUItime::DoDumpRuns() | |
900 | { | |
901 | // | |
902 | // Dump the current run numbers to stdout | |
903 | // | |
6fb51ca4 | 904 | Int_t npoints=fRunNumbers.GetNrows(); |
905 | Int_t *sortIndex = new Int_t[npoints]; | |
906 | TMath::Sort(npoints,fRunNumbers.GetMatrixArray(),sortIndex,kFALSE); | |
907 | Int_t run=0, prevRun=-1; | |
908 | ||
909 | for (Int_t irun=0;irun<npoints;++irun){ | |
910 | run=(Int_t)fRunNumbers.GetMatrixArray()[sortIndex[irun]]; | |
911 | if (run!=prevRun) std::cout << Form("%d",run) << std::endl; | |
912 | prevRun=run; | |
5312f439 | 913 | } |
6fb51ca4 | 914 | delete sortIndex; |
5312f439 | 915 | } |
916 | //______________________________________________________________________________ | |
917 | void AliTPCCalibViewerGUItime::DoParLimitChange() | |
918 | { | |
919 | // | |
920 | // | |
921 | // | |
6fb51ca4 | 922 | UpdateParName(); |
5312f439 | 923 | DoDraw(); |
924 | } | |
925 | //______________________________________________________________________________ | |
926 | void AliTPCCalibViewerGUItime::DoNewSelection() { | |
927 | // | |
928 | // decides whether to redraw if user makes another selection | |
929 | // | |
930 | UpdateParLimits(); | |
931 | fDrawString=GetDrawString(); | |
932 | fIsCustomDraw=kFALSE; | |
933 | DoDraw(); | |
934 | } | |
935 | //______________________________________________________________________________ | |
936 | void AliTPCCalibViewerGUItime::DoCustomDraw() | |
937 | { | |
938 | // | |
939 | // | |
940 | // | |
941 | fDrawString=fComboCustomDraw->GetTextEntry()->GetText(); | |
6e7d7dc4 | 942 | // if (fDrawString.Contains(">>")){ |
943 | // Warning("DoCustomDraw","Currently no user defined histograms allowed!"); | |
944 | // return; | |
945 | // } | |
946 | fNmbPar->SetState(kFALSE); | |
5312f439 | 947 | fIsCustomDraw=kTRUE; |
948 | DoDraw(); | |
949 | } | |
950 | //______________________________________________________________________________ | |
951 | void AliTPCCalibViewerGUItime::DoCustomCutsDraw() | |
952 | { | |
953 | // | |
954 | // | |
955 | // | |
956 | if (fIsCustomDraw) DoCustomDraw(); | |
957 | else { | |
958 | fDrawString=GetDrawString(); | |
959 | fIsCustomDraw=kFALSE; | |
960 | DoDraw(); | |
961 | } | |
962 | } | |
963 | //______________________________________________________________________________ | |
964 | void AliTPCCalibViewerGUItime::HandleButtonsDrawSel(Int_t id) | |
965 | { | |
966 | // | |
967 | // Draw selection button handling (x-variable) | |
968 | // | |
969 | ||
970 | if (id == -1) { | |
971 | TGButton *btn = (TGButton *) gTQSender; | |
972 | id = btn->WidgetId(); | |
973 | } | |
974 | ||
975 | Bool_t doDraw=kFALSE; | |
976 | switch (id) { | |
977 | case (kRadioXhist): | |
978 | doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown); | |
979 | if (doDraw){ | |
980 | fRadioXrun->SetState(kButtonUp); | |
981 | fRadioXtime->SetState(kButtonUp); | |
982 | } | |
983 | break; | |
984 | case (kRadioXrun): | |
985 | doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXhist->GetState()==kButtonDown); | |
986 | if (doDraw){ | |
987 | fRadioXhist->SetState(kButtonUp); | |
988 | fRadioXtime->SetState(kButtonUp); | |
989 | } | |
990 | break; | |
991 | case (kRadioXtime): | |
992 | doDraw=(fRadioXhist->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown); | |
993 | if (doDraw){ | |
994 | fRadioXrun->SetState(kButtonUp); | |
995 | fRadioXhist->SetState(kButtonUp); | |
996 | } | |
997 | break; | |
998 | } | |
6fb51ca4 | 999 | if (doDraw) DoCustomCutsDraw(); |
5312f439 | 1000 | } |
6fb51ca4 | 1001 | //______________________________________________________________________________ |
1002 | void AliTPCCalibViewerGUItime::UpdateParName() | |
1003 | { | |
1004 | // | |
1005 | // change parameter name | |
1006 | // | |
1007 | ||
1008 | Int_t par = (Int_t)(fNmbPar->GetNumber()); | |
7390f655 | 1009 | TString parName=""; |
6fb51ca4 | 1010 | Int_t id=fListVariables->GetSelectedEntry()->EntryId(); |
1011 | if (fConfigParser && (*fConfigParser)(id)) parName=fConfigParser->GetData((*fConfigParser)(id),par+kParamNames); | |
7390f655 | 1012 | if (parName=="") parName.Form("%d",par); |
6fb51ca4 | 1013 | fLblPar->SetText(Form("Parameter: %s",parName.Data())); |
1014 | fDrawString=GetDrawString(); | |
1015 | fIsCustomDraw=kFALSE; | |
1016 | } | |
1017 | ||
5312f439 | 1018 | //______________________________________________________________________________ |
1019 | void AliTPCCalibViewerGUItime::UpdateParLimits() | |
1020 | { | |
1021 | // | |
1022 | // Adjust limits for TVectorT based variables | |
1023 | // | |
1024 | if (!fTree) return; | |
6fb51ca4 | 1025 | TString selectedVariableTitle=""; |
1026 | Int_t id=-1; | |
1027 | if (!fListVariables->GetSelectedEntry()) return; | |
1028 | selectedVariableTitle = fListVariables->GetSelectedEntry()->GetTitle(); | |
1029 | id=fListVariables->GetSelectedEntry()->EntryId(); | |
1030 | // printf("id: %d\n",id); | |
1031 | TString selectedVariable=selectedVariableTitle; | |
1032 | const TObject *key=(*fConfigParser)(id); | |
1033 | if (key) selectedVariable=(*fConfigParser)(id)->GetName(); | |
1034 | ||
5312f439 | 1035 | if (selectedVariable.IsNull()||!selectedVariable.EndsWith(".")) { |
1036 | fNmbPar->SetState(kFALSE); | |
6fb51ca4 | 1037 | fLblPar->SetText("Parameter: none"); |
5312f439 | 1038 | return; |
1039 | } | |
1040 | TVectorD *vD=0x0; | |
1041 | TVectorF *vF=0x0; | |
1042 | Int_t maxPar=0; | |
e6970ab5 | 1043 | fTree->GetEntry(1); |
1044 | TBranch *branch=fTree->GetTree()->GetBranch(selectedVariable.Data()); | |
5312f439 | 1045 | TString branchClass=branch->GetClassName(); |
e6970ab5 | 1046 | Int_t event=0; |
5312f439 | 1047 | if (branchClass=="TVectorT<double>"){ |
e6970ab5 | 1048 | // branch->SetAddress(&vD); |
1049 | fTree->SetBranchAddress(selectedVariable.Data(),&vD); | |
1050 | while (maxPar<2&&event<fTree->GetEntries()){ | |
1051 | fTree->GetEntry(event++); | |
1052 | maxPar=vD->GetNrows(); | |
1053 | } | |
5312f439 | 1054 | } else if (branchClass=="TVectorT<float>"){ |
e6970ab5 | 1055 | // branch->SetAddress(&vF); |
1056 | fTree->SetBranchAddress(selectedVariable.Data(),&vF); | |
1057 | while (maxPar<2&&event<fTree->GetEntries()){ | |
1058 | fTree->GetEntry(event++); | |
1059 | maxPar=vF->GetNrows(); | |
1060 | } | |
5312f439 | 1061 | } else { |
1062 | //class not known | |
1063 | fNmbPar->SetState(kFALSE); | |
1064 | return; | |
1065 | } | |
e6970ab5 | 1066 | // branch->ResetAddress(); |
6e7d7dc4 | 1067 | fTree->SetBranchAddress(selectedVariable.Data(),0x0); |
7390f655 | 1068 | if (fNmbPar->GetNumMax()!=maxPar-1) fNmbPar->SetNumber(0); |
5312f439 | 1069 | fNmbPar->SetLimitValues(0,maxPar-1); |
1070 | fNmbPar->SetState(kTRUE); | |
6fb51ca4 | 1071 | UpdateParName(); |
5312f439 | 1072 | } |
1073 | //______________________________________________________________________________ | |
6fb51ca4 | 1074 | void AliTPCCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/) |
5312f439 | 1075 | { |
1076 | // | |
1077 | // handle mouse events in the draw canvas | |
1078 | // | |
5312f439 | 1079 | UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0; |
1080 | Double_t valx=0.,valy=0.; | |
1081 | if (!fCurrentGraph) { | |
1082 | fLblRunNumberVal->SetText(Form("%05u",run)); | |
e6970ab5 | 1083 | fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS)); |
892226be | 1084 | fLblValueXVal->SetText(Form("%.3e", valx)); |
1085 | fLblValueYVal->SetText(Form("%.3e", valy)); | |
5312f439 | 1086 | return; |
1087 | } | |
1088 | TVirtualPad *padsave=gPad; | |
1089 | fCanvMain->GetCanvas()->cd(); | |
1090 | Int_t n=fValuesY.GetNrows(); | |
1091 | Double_t *arr=0x0; | |
1092 | arr=fValuesX.GetMatrixArray(); | |
1093 | ||
1094 | Int_t minDist=1000000; | |
1095 | Int_t minPoint=-1; | |
1096 | for (Int_t i=0;i<n;++i){ | |
1097 | Int_t pxp = gPad->XtoAbsPixel(gPad->XtoPad(arr[i])); | |
1098 | Int_t pyp = gPad->YtoAbsPixel(gPad->YtoPad(fValuesY[i])); | |
e6970ab5 | 1099 | Int_t d = TMath::Nint(TMath::Sqrt(TMath::Abs(pxp-x) + TMath::Abs(pyp-y))); |
5312f439 | 1100 | if (d < minDist) { |
1101 | minDist = d; | |
1102 | minPoint = i; | |
1103 | } | |
1104 | } | |
1105 | if (minDist<2){ | |
1106 | TTimeStamp t((Int_t)fTimeStamps[minPoint]); | |
1107 | t.GetDate(kTRUE,0,&yy,&mm,&dd); | |
1108 | t.GetTime(kTRUE,0,&HH,&MM,&SS); | |
1109 | run=(UInt_t)fRunNumbers[minPoint]; | |
1110 | valx=fValuesX[minPoint]; | |
1111 | valy=fValuesY[minPoint]; | |
1112 | } else { | |
1113 | dd=0;mm=0;yy=0;HH=0;MM=0;SS=0;run=0; | |
1114 | valx=0.; | |
1115 | valy=0.; | |
1116 | } | |
1117 | fLblRunNumberVal->SetText(Form("%05u",run)); | |
1118 | fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS)); | |
1119 | if (fIsCustomDraw){ | |
892226be | 1120 | fLblValueXVal->SetText(Form("%.3e", valx)); |
5312f439 | 1121 | }else{ |
1122 | if (fRadioXrun->GetState()==kButtonDown){ | |
1123 | fLblValueXVal->SetText("Run"); | |
1124 | } else if (fRadioXtime->GetState()==kButtonDown){ | |
1125 | fLblValueXVal->SetText("Time"); | |
1126 | } | |
1127 | } | |
892226be | 1128 | fLblValueYVal->SetText(Form("%.3e", valy)); |
5312f439 | 1129 | padsave->cd(); |
1130 | if (run==0) return; | |
1131 | if (event == kButton1Double ){ | |
1132 | SetGuiTree(run); | |
1133 | } | |
1134 | //find closes point of current selection | |
1135 | } | |
1136 | //______________________________________________________________________________ | |
1137 | void AliTPCCalibViewerGUItime::SetGuiTree(Int_t run) | |
1138 | { | |
1139 | // | |
1140 | // create the AliTPCCalibViewerGUI tree for run | |
1141 | // cache tree in directory fOutputCacheDir | |
1142 | // retrieve file from this directory if it already exists | |
1143 | // | |
1144 | ||
1145 | //try to find file for run in fOutputCacheDir | |
1146 | TString fileName=fOutputCacheDir; | |
1147 | if (!fileName.EndsWith("/")) fileName+="/"; | |
1148 | fileName+=Form("guiTreeRun_%d.root",run); | |
7390f655 | 1149 | Bool_t load=kTRUE; |
5312f439 | 1150 | TFile f(fileName.Data()); |
7390f655 | 1151 | if (!f.IsOpen()){ |
1152 | load=AliTPCcalibDB::CreateGUITree(run,fileName.Data()); | |
1153 | if (!load){ | |
1154 | fCalibViewerGUI->Reset(); | |
1155 | if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX"))); | |
1156 | return; | |
1157 | } | |
5312f439 | 1158 | } |
1159 | f.Close(); | |
7390f655 | 1160 | fCalibViewerGUI->Initialize(fileName.Data()); |
1161 | if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run))); | |
1162 | TIter nextRefTree(fMapRefTrees); | |
1163 | TObject *o=0x0; | |
1164 | while ( (o=nextRefTree()) ){ | |
1165 | fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"calPads",o->GetName()); | |
5312f439 | 1166 | } |
7390f655 | 1167 | fCalibViewerGUI->Reload(); |
5312f439 | 1168 | } |
1169 | //______________________________________________________________________________ | |
6fb51ca4 | 1170 | const char* AliTPCCalibViewerGUItime::SubstituteUnderscores(const char* in) |
1171 | { | |
1172 | // | |
1173 | // | |
1174 | // | |
1175 | TString s(in); | |
1176 | s.ReplaceAll("_{","|{"); | |
1177 | s.ReplaceAll("_"," "); | |
1178 | s.ReplaceAll("|{","_{"); | |
1179 | return s.Data(); | |
1180 | } | |
1181 | //______________________________________________________________________________ | |
6e7d7dc4 | 1182 | TObjArray* AliTPCCalibViewerGUItime::ShowGUI(const char* fileName, const char* treeName) { |
5312f439 | 1183 | // |
1184 | // Initialize and show GUI for presentation for demonstration purposes | |
1185 | // or for fast standalone use | |
1186 | // | |
1187 | TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600); | |
1188 | frmMain->SetWindowName("AliTPCCalibViewer GUItime"); | |
1189 | frmMain->SetCleanup(kDeepCleanup); | |
1190 | ||
1191 | TGTab* tabMain = new TGTab(frmMain, 1000, 600); | |
1192 | frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
1193 | ||
1194 | TGCompositeFrame* tabCont1 = tabMain->AddTab("Time"); | |
1195 | TGCompositeFrame* tabCont2 = tabMain->AddTab("Detail - XXXXX"); | |
1196 | ||
1197 | AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600); | |
1198 | tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
6e7d7dc4 | 1199 | calibViewerTime->SetConfigFileName("$ALICE_ROOT/TPC/CalibMacros/calibVarDescription.txt"); |
1200 | calibViewerTime->UseFile(fileName, treeName); | |
5312f439 | 1201 | |
1202 | AliTPCCalibViewerGUI* calibViewer = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, 0); | |
1203 | tabCont2->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
1204 | calibViewerTime->SetCalibViewerGUI(calibViewer); | |
1205 | calibViewerTime->SetCalibViewerGUItab(tabMain->GetTabTab(1)); | |
1206 | ||
1207 | ||
1208 | TObjArray *guiArray = new TObjArray(); | |
1209 | guiArray->Add(calibViewerTime); | |
1210 | guiArray->Add(calibViewer); | |
1211 | ||
1212 | frmMain->MapSubwindows(); | |
1213 | frmMain->Resize(); | |
1214 | frmMain->MapWindow(); | |
1215 | ||
1216 | return guiArray; | |
1217 | } | |
1218 | ||
6e7d7dc4 | 1219 | //______________________________________________________________________________ |
1220 | TObjArray* AliTPCCalibViewerGUItime::ShowGUI(TChain *chain) { | |
1221 | // | |
1222 | // Initialize and show GUI for presentation for demonstration purposes | |
1223 | // or for fast standalone use | |
1224 | // | |
1225 | TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600); | |
1226 | frmMain->SetWindowName("AliTPCCalibViewer GUItime"); | |
1227 | frmMain->SetCleanup(kDeepCleanup); | |
1228 | ||
1229 | TGTab* tabMain = new TGTab(frmMain, 1000, 600); | |
1230 | frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
1231 | ||
1232 | TGCompositeFrame* tabCont1 = tabMain->AddTab("Time"); | |
1233 | ||
1234 | AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600); | |
1235 | tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0)); | |
1236 | calibViewerTime->UseChain(chain); | |
1237 | ||
1238 | TObjArray *guiArray = new TObjArray(); | |
1239 | guiArray->Add(calibViewerTime); | |
1240 | ||
1241 | frmMain->MapSubwindows(); | |
1242 | frmMain->Resize(); | |
1243 | frmMain->MapWindow(); | |
1244 | ||
1245 | return guiArray; | |
1246 | } |