1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // GUI for the AliTPCCalibViewer //
20 // used for the calibration monitor //
24 AliTPCCalibViewerGUI::showGUI("allInOne22.root")
26 // - Resize windows - (BUG to BE FIXED -> ROOT bug) //
28 ///////////////////////////////////////////////////////////////////////////////
31 #include "AliTPCCalibViewerGUI.h"
35 #include <TVirtualPad.h>
37 #include <TObjArray.h>
38 #include <TObjString.h>
44 ClassImp(AliTPCCalibViewerGUI)
46 AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h, char* fileName)
47 : TGCompositeFrame(p, w, h),
56 fContDrawOptSub1D2D(0),
70 fBtnAddFitFunction(0),
85 fListNormalization(0),
98 // AliTPCCalibViewerGUI constructor; fileName specifies the ROOT tree used for drawing
101 SetCleanup(kDeepCleanup);
103 // ************************* content of this MainFrame *************************
104 // top level container with horizontal layout
105 fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
106 AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
108 fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
109 fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
112 // ************************* content of fContLCR *************************
114 fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
115 fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
117 // left vertical splitter
118 TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
119 splitLeft->SetFrame(fContLeft, kTRUE);
120 fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
123 fContRight = new TGCompositeFrame(fContLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight);
124 fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
127 fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
128 fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
130 // right vertical splitter
131 TGVSplitter *splitRight = new TGVSplitter(fContLCR);
132 splitRight->SetFrame(fContRight, kFALSE);
133 fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
135 // ************************* content of fContLeft *************************
137 fBtnDraw = new TGTextButton(fContLeft, "&Draw");
138 fContLeft->AddFrame(fBtnDraw, new TGLayoutHints(kLHintsExpandX, 10, 10, 0, 0));
139 //fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoTest(=\"fBtnDraw clicked\")");
140 fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoDraw()");
142 // draw options container
143 fContDrawOpt = new TGGroupFrame(fContLeft, "Plot options", kVerticalFrame | kFitWidth | kFitHeight);
144 fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
145 fContDrawOptSub1D2D = new TGCompositeFrame(fContDrawOpt, 200, 20, kHorizontalFrame | kFitWidth | kFixedHeight);
146 fContDrawOpt->AddFrame(fContDrawOptSub1D2D, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
149 // predefined radio button
150 fRadioPredefined = new TGRadioButton(fContLeft, "Predefined: ", 13);
151 fContLeft->AddFrame(fRadioPredefined, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
152 fRadioPredefined->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
155 fListVariables = new TGListBox(fContLeft);
156 fContLeft->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0));
157 fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
159 // plot options container
160 //fContPlotOpt = new TGCompositeFrame(fContLeft, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
161 fContPlotOpt = new TGGroupFrame(fContLeft, "Normalization options", kVerticalFrame | kFitWidth | kFitHeight);
162 fContLeft->AddFrame(fContPlotOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0));
164 // custom radio button
165 fRadioCustom = new TGRadioButton(fContLeft, "Custom: ", 12);
166 fContLeft->AddFrame(fRadioCustom, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
167 fRadioCustom->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
169 // custom options container
170 fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
171 fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
173 // ************************* content of fContRight *************************
174 // cut options container
175 //fContCuts = new TGCompositeFrame(fContRight, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
176 fContCuts = new TGGroupFrame(fContRight, "Cuts", kVerticalFrame | kFitWidth | kFitHeight);
177 fContRight->AddFrame(fContCuts, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
179 // Fit options container
180 fContFit = new TGGroupFrame(fContRight, "Custom Fit", kVerticalFrame | kFitWidth | kFitHeight);
181 fContRight->AddFrame(fContFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
183 // Scaling options container
184 fContScaling = new TGGroupFrame(fContRight, "Scaling", kVerticalFrame | kFitWidth | kFitHeight);
185 fContRight->AddFrame(fContScaling, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
187 // ************************* content of fContCenter *************************
188 // main drawing canvas
189 fCanvMain = new TRootEmbeddedCanvas("Main Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
190 fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
193 // ************************* content of fContPlotOpt *************************
194 //TGButtonGroup *fBtngrpPlotOpt = new TGButtonGroup(fContPlotOpt, "Plot options",
196 fRadioRaw = new TGRadioButton(fContPlotOpt, "Raw", 10);
197 fContPlotOpt->AddFrame(fRadioRaw, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
198 fRadioRaw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
200 // normalized radio button
201 fRadioNormalized = new TGRadioButton(fContPlotOpt, "Normalized", 11);
202 fContPlotOpt->AddFrame(fRadioNormalized, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
203 fRadioNormalized->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
205 //fContPlotOpt->Show();
207 // normalized options container
208 fContNormalized = new TGCompositeFrame(fContPlotOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
209 fContPlotOpt->AddFrame(fContNormalized, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 15, 0, 0, 0));
211 // ************************* content of fContDrawOpt *************************
213 fRadio1D = new TGRadioButton(fContDrawOptSub1D2D, "1D", 30);
214 // fContDrawOpt->AddFrame(fRadio1D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
215 fContDrawOptSub1D2D->AddFrame(fRadio1D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
216 fRadio1D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
219 fRadio2D = new TGRadioButton(fContDrawOptSub1D2D, "2D", 31);
220 fContDrawOptSub1D2D->AddFrame(fRadio2D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
221 fRadio2D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
223 // automatic redraw check button
224 fChkAuto = new TGCheckButton(fContDrawOpt, "auto redraw");
225 fContDrawOpt->AddFrame(fChkAuto, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
227 // ************************* content of fContCuts *************************
229 fRadioTPC = new TGRadioButton(fContCuts, "whole TPC", 20);
230 fContCuts->AddFrame(fRadioTPC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
231 fRadioTPC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
233 // side A radio button
234 fRadioSideA = new TGRadioButton(fContCuts, "side A", 21);
235 fContCuts->AddFrame(fRadioSideA, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
236 fRadioSideA->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
238 // side C radio button
239 fRadioSideC = new TGRadioButton(fContCuts, "side C", 22);
240 fContCuts->AddFrame(fRadioSideC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
241 fRadioSideC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
243 // sector radio button
244 fRadioSector = new TGRadioButton(fContCuts, "sector", 23);
245 fContCuts->AddFrame(fRadioSector, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
246 fRadioSector->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
248 // sector options container
249 fContSector = new TGCompositeFrame(fContCuts, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
250 fContCuts->AddFrame(fContSector, new TGLayoutHints(kLHintsExpandX, 5, 0, 0, 0));
252 // additional cuts check button
253 fChkAddCuts = new TGCheckButton(fContCuts, "additional cuts");
254 fContCuts->AddFrame(fChkAddCuts, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
255 fChkAddCuts->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
257 // additional cuts container
258 fContAddCuts = new TGCompositeFrame(fContCuts, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
259 fContCuts->AddFrame(fContAddCuts, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0));
261 // ************************* content of fContNormalized *************************
262 // method drop down combo box
263 fComboMethod = new TGComboBox(fContNormalized);
264 fComboMethod->Resize(0, fBtnDraw->GetDefaultHeight());
265 fContNormalized->AddFrame(fComboMethod, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
266 fComboMethod->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
268 // list of normalization variables
269 fListNormalization = new TGListBox(fContNormalized);
270 fContNormalized->AddFrame(fListNormalization, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
271 fListNormalization->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
273 // ************************* content of fContCustom *************************
274 // text field for custom draw command
275 fComboCustom = new TGComboBox(fContCustom);
276 fComboCustom->Resize(0, fBtnDraw->GetDefaultHeight());
277 fComboCustom->EnableTextInput(kTRUE);
278 fContCustom->AddFrame(fComboCustom, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
279 fComboCustom->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons(=42)");
280 fComboCustom->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
282 // ************************* content of fContSector *************************
283 // sector number entry
284 fNmbSector = new TGNumberEntry(fContSector, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
285 fContSector->AddFrame(fNmbSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
286 fNmbSector->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUI", this, "ChangeSector()");
288 // sector number label
289 fLblSector = new TGLabel(fContSector, "IROC, A");
290 fContSector->AddFrame(fLblSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
292 // ************************* content of fContAddCuts *************************
293 // combo text field for additional cuts
294 fComboAddCuts = new TGComboBox(fContAddCuts);
295 fComboAddCuts->Resize(0, fBtnDraw->GetDefaultHeight());
296 fComboAddCuts->EnableTextInput(kTRUE);
297 fContAddCuts->AddFrame(fComboAddCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
298 fComboAddCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
299 fComboAddCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
301 // ************************* content of fContFit *************************
302 // container for additional fits
303 fContAddFit = new TGCompositeFrame(fContFit, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
304 fContFit->AddFrame(fContAddFit, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0));
306 // ************************* content of fContAddFit *************************
307 // text field for custom fit
308 fComboCustomFit = new TGComboBox(fContAddFit);
309 fComboCustomFit->Resize(0, fBtnDraw->GetDefaultHeight());
310 fComboCustomFit->EnableTextInput(kTRUE);
311 fContAddFit->AddFrame(fComboCustomFit, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
312 fComboCustomFit->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoFit()");
313 fComboCustomFit->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoFit()");
316 fBtnFit = new TGTextButton(fContAddFit, "&Fit");
317 fContAddFit->AddFrame(fBtnFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
318 fBtnFit->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoFit()");
320 // add fit function button
321 //fBtnAddFitFunction = new TGTextButton(fContAddFit, "&Add fit function to normalization");
322 //fContAddFit->AddFrame(fBtnAddFitFunction, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
323 //fBtnAddFitFunction->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "AddFitFunction()");
325 // ************************* content of fContScaling *************************
326 // SetMaximum container
327 fContSetMax = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
328 fContScaling->AddFrame(fContSetMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
330 // SetMinimum container
331 fContSetMin = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
332 fContScaling->AddFrame(fContSetMin, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
334 // get Min & Max from Plot - button
335 fBtnGetMinMax = new TGTextButton(fContScaling, "&Get scale from plot");
336 fContScaling->AddFrame(fBtnGetMinMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
337 fBtnGetMinMax->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "GetMinMax()");
339 // GetMinMaxAuto - checkbox
340 fChkGetMinMaxAuto = new TGCheckButton(fContScaling, "Get Min + Max auto.");
341 fContScaling->AddFrame(fChkGetMinMaxAuto, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
342 fChkGetMinMaxAuto->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
345 // ************************* content of fContSetMax *************************
346 // SetMaximum - checkbox
347 fChkSetMax = new TGCheckButton(fContSetMax, "Set fixed max.");
348 fContSetMax->AddFrame(fChkSetMax, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
349 fChkSetMax->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
351 // text field for maximum value
352 fTxtSetMax = new TGTextEntry(fContSetMax, "", 41);
353 fContSetMax->AddFrame(fTxtSetMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
354 fTxtSetMax->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
356 // ************************* content of fContSetMin *************************
357 // SetMinimum - checkbox
358 fChkSetMin = new TGCheckButton(fContSetMin, "Set fixed min.");
359 fContSetMin->AddFrame(fChkSetMin, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
360 fChkSetMin->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
362 // text field for minimum value
363 fTxtSetMin = new TGTextEntry(fContSetMin, "", 40);
364 fContSetMin->AddFrame(fTxtSetMin, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
365 fTxtSetMin->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
368 // Display everything
369 Initialize(fileName);
370 SetWindowName("AliTPCCalibViewer GUI");
372 Resize(GetDefaultSize());
376 AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const AliTPCCalibViewerGUI &c)
377 : TGCompositeFrame(c.fParent, c.fWidth, c.fHeight),
386 fContDrawOptSub1D2D(0),
400 fBtnAddFitFunction(0),
415 fListNormalization(0),
424 fChkGetMinMaxAuto(0),
429 // dummy AliTPCCalibViewerGUI copy constructor
433 AliTPCCalibViewerGUI & AliTPCCalibViewerGUI::operator =(const AliTPCCalibViewerGUI & param) {
435 // dummy assignment operator
440 AliTPCCalibViewerGUI::~AliTPCCalibViewerGUI() {
441 if (fCanvMain && fCanvMain->GetCanvas()) {
442 for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) {
443 if (strcmp(fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->ClassName(), "TFrame") != 0)
444 fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->Delete();
448 if (fViewer) fViewer->Delete();
452 void AliTPCCalibViewerGUI::CloseWindow() {
457 void AliTPCCalibViewerGUI::Initialize(char* fileName) {
459 // initializes the GUI with default settings and opens tree for drawing
462 // create AliTPCCalibViewer object, which will be used for generating all drawings
463 if (fViewer) delete fViewer;
464 fViewer = new AliTPCCalibViewer(fileName);
466 // fill fListVariables
467 TObjArray* arr = fViewer->GetListOfVariables();
468 TIterator* iter = arr->MakeIterator();
470 TObjString* currentStr = 0;
472 while ((currentStr = (TObjString*)(iter->Next()))) {
473 fListVariables->AddEntry(currentStr->GetString().Data(), id);
481 fComboMethod->AddEntry("subtract", 0);
482 fComboMethod->AddEntry("divide by", 1);
485 arr = fViewer->GetListOfNormalizationVariables();
486 iter = arr->MakeIterator();
490 while ((currentStr = (TObjString*)(iter->Next()))) {
491 fListNormalization->AddEntry(currentStr->GetString().Data(), id);
498 // set default button states
499 fRadioPredefined->SetState(kButtonDown);
500 fRadioRaw->SetState(kButtonDown);
501 fRadioTPC->SetState(kButtonDown);
502 fRadio1D->SetState(kButtonDown);
503 fChkAuto->SetState(kButtonDown);
504 fChkAddCuts->SetState(kButtonUp);
505 fListVariables->Select(0);
506 fListNormalization->Select(0);
507 fComboMethod->Select(0);
508 fChkGetMinMaxAuto->SetState(kButtonDown);
509 fChkSetMin->SetState(kButtonUp);
510 fChkSetMax->SetState(kButtonUp);
512 //fCanvMain->GetCanvas()->ToggleEventStatus(); // klappt nicht
513 //fCanvMain->GetCanvas()->GetCanvasImp()->ShowStatusBar(kTRUE); // klappt auch nicht
514 fListVariables->IntegralHeight(kFALSE); // naja
515 fListNormalization->IntegralHeight(kFALSE); // naja
519 void AliTPCCalibViewerGUI::HandleButtons(Int_t id) {
521 // handles mutual radio button exclusions
524 TGButton *btn = (TGButton *) gTQSender;
525 id = btn->WidgetId();
529 case 10: // fRadioRaw
530 fRadioNormalized->SetState(kButtonUp);
531 fRadioPredefined->SetState(kButtonDown);
532 fRadioCustom->SetState(kButtonUp);
533 //fComboMethod->UnmapWindow();
534 //fListNormalization->UnmapWindow();
536 case 11: // fRadioNormalized
537 fRadioRaw->SetState(kButtonUp);
538 fRadioPredefined->SetState(kButtonDown);
539 fRadioCustom->SetState(kButtonUp);
541 case 12: // fRadioCustom
542 fRadioPredefined->SetState(kButtonUp);
543 //fRadioNormalized->SetState(kButtonUp);
545 case 13: // fRadioPredefined
546 fRadioCustom->SetState(kButtonUp);
547 //fRadioNormalized->SetState(kButtonUp);
550 case 20: // fRadioTPC
551 fRadioSideA->SetState(kButtonUp);
552 fRadioSideC->SetState(kButtonUp);
553 fRadioSector->SetState(kButtonUp);
555 case 21: // fRadioSideA
556 fRadioTPC->SetState(kButtonUp);
557 fRadioSideC->SetState(kButtonUp);
558 fRadioSector->SetState(kButtonUp);
560 case 22: // fRadioSideC
561 fRadioTPC->SetState(kButtonUp);
562 fRadioSideA->SetState(kButtonUp);
563 fRadioSector->SetState(kButtonUp);
565 case 23: // fRadioSector
566 fRadioTPC->SetState(kButtonUp);
567 fRadioSideA->SetState(kButtonUp);
568 fRadioSideC->SetState(kButtonUp);
572 fRadio2D->SetState(kButtonUp);
575 fRadio1D->SetState(kButtonUp);
578 case 40: // fTxtSetMin
579 fChkSetMin->SetState(kButtonDown);
581 case 41: // fTxtSetMax
582 fChkSetMax->SetState(kButtonDown);
584 case 42: // fComboCustom
585 fRadioCustom->SetState(kButtonDown);
586 fRadioPredefined->SetState(kButtonUp);
592 void AliTPCCalibViewerGUI::DoNewSelection() {
594 // decides whether to redraw if user makes another selection
597 if (fChkAuto->GetState() == kButtonDown) DoDraw();
600 void AliTPCCalibViewerGUI::DoDraw() {
602 // main method for drawing according to user selection
605 // specify data to plot
606 TString desiredData("");
607 if (!fListVariables->GetSelectedEntry()) return;
608 desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
609 desiredData += ".fElements";
611 // specify normalization
612 if (fRadioPredefined->GetState() == kButtonDown && fRadioNormalized->GetState() == kButtonDown) {
614 switch (fComboMethod->GetSelected()) {
615 case 0: // subtraction
622 TString normalizationData("");
623 if (!fListNormalization->GetSelectedEntry()) return;
624 normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle();
626 if ( normalizationData.BeginsWith("Fit")) {
627 // create fit formula, evaluate it an replace normalizationData-String
628 // ********** create cut string **********
630 if (fRadioTPC->GetState() == kButtonDown)
631 cutStr += ""; // whole TPC is used for fitting
632 if (fRadioSideA->GetState() == kButtonDown)
633 cutStr += "(sector/18)%2==0"; // side A
634 if (fRadioSideC->GetState() == kButtonDown)
635 cutStr+= "(sector/18)%2==1"; // side C
636 if (fRadioSector->GetState() == kButtonDown) {
637 Int_t sector = (Int_t)(fNmbSector->GetNumber());
638 cutStr += "sector==";
641 if (fChkAddCuts->GetState() == kButtonDown && strcmp(fComboAddCuts->GetTextEntry()->GetText(), "") != 0){
642 if (fRadioTPC->GetState() != kButtonDown) cutStr += " && ";
643 cutStr += fComboAddCuts->GetTextEntry()->GetText();
646 TVectorD fitParam(0);
647 TMatrixD covMatrix(0,0);
648 TString formulaStr("");
649 if (normalizationData.CompareTo("FitLinLocal") == 0)
650 formulaStr = "lx~ ++ ly~";
651 if (normalizationData.CompareTo("FitLinGlobal") == 0)
652 formulaStr = "gx~ ++ gy~";
653 normalizationData = *fViewer->Fit(desiredData.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix);
657 if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit"))
658 desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
659 desiredData += normalizationData;
661 else if (fRadioCustom->GetState() == kButtonDown) {
662 desiredData = fComboCustom->GetTextEntry()->GetText();
663 if (desiredData == "") return;
667 TString sectorStr("");
668 if (fRadioTPC->GetState() == kButtonDown)
670 if (fRadioSideA->GetState() == kButtonDown)
671 sectorStr += "A"; //cuts += "(sector/18)%2==0";
672 if (fRadioSideC->GetState() == kButtonDown)
673 sectorStr+= "C"; //cuts += "(sector/18)%2==1";
674 if (fRadioSector->GetState() == kButtonDown) {
675 Int_t sector = (Int_t)(fNmbSector->GetNumber());
676 sectorStr += sector; //cuts += "sector==";
679 if (fChkAddCuts->GetState() == kButtonDown)
680 cutsStr += fComboAddCuts->GetTextEntry()->GetText();
683 for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) {
684 if (strcmp(fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->ClassName(), "TFrame") != 0)
685 fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->Delete();
687 //fCanvMain->GetCanvas()->Clear();
688 fCanvMain->GetCanvas()->cd();
690 if (fRadio1D->GetState() == kButtonDown)
691 entries = fViewer->EasyDraw1D(desiredData.Data(), sectorStr.Data(), cutsStr.Data());
692 else if (fRadio2D->GetState() == kButtonDown)
693 entries = fViewer->EasyDraw(desiredData.Data(), sectorStr.Data(), cutsStr.Data());
694 if (entries == -1) return;
696 TList* listOfPrimitives = fCanvMain->GetCanvas()->GetListOfPrimitives();
698 for (Int_t i = 0; i < listOfPrimitives->GetEntries(); i++) {
699 ptr = listOfPrimitives->At(i);
700 if ( ptr->InheritsFrom("TH1") ) break;
702 if ( ptr != 0 && !ptr->InheritsFrom("TH1") ) return; // if the loop did not find a TH1
703 TH1 *hist = (TH1*)ptr;
704 TString minTxt(fTxtSetMin->GetText());
705 TString maxTxt(fTxtSetMax->GetText());
706 if (fChkSetMax->GetState() == kButtonDown && (maxTxt.IsDigit() || maxTxt.IsFloat()) )
707 hist->SetMaximum(maxTxt.Atof());
708 if (fChkSetMin->GetState() == kButtonDown && (minTxt.IsDigit() || minTxt.IsFloat()) )
709 hist->SetMinimum(minTxt.Atof());
711 if (fChkGetMinMaxAuto->GetState() == kButtonDown) {
712 if (fChkSetMax->GetState() == kButtonUp)
713 fTxtSetMax->SetText(Form("%f", hist->GetMaximum()));
714 if (fChkSetMin->GetState() == kButtonUp)
715 fTxtSetMin->SetText(Form("%f", hist->GetMinimum()));
718 fCanvMain->GetCanvas()->Update();
722 void AliTPCCalibViewerGUI::DoFit() {
724 // main method for fitting
728 TVectorD fitParam(0);
729 TMatrixD covMatrix(0,0);
732 TString formulaStr("");
733 TString *returnStr = new TString("");
736 // ******** create draw string *********
737 if (fRadioCustom->GetState() == kButtonDown) {
738 // take custom text as draw string
739 drawStr = fComboCustom->GetTextEntry()->GetText();
740 if (drawStr == "") return;
742 else if (fRadioPredefined->GetState() == kButtonDown) {
743 // create drawStr out of selection
744 drawStr += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
745 drawStr += ".fElements";
746 if (fRadioNormalized->GetState() == kButtonDown) {
747 // normalize data by selection
749 switch (fComboMethod->GetSelected()) {
750 case 0: // subtraction
757 TString normalizationData("");
758 normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle();
760 drawStr += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
761 drawStr += normalizationData;
765 // ********** create cut string **********
766 if (fRadioTPC->GetState() == kButtonDown)
767 cutStr += ""; // whole TPC is used for fitting
768 if (fRadioSideA->GetState() == kButtonDown)
769 cutStr += "(sector/18)%2==0"; // side A
770 if (fRadioSideC->GetState() == kButtonDown)
771 cutStr+= "(sector/18)%2==1"; // side C
772 if (fRadioSector->GetState() == kButtonDown) {
773 Int_t sector = (Int_t)(fNmbSector->GetNumber());
774 cutStr += "sector==";
777 if (fChkAddCuts->GetState() == kButtonDown && strcmp(fComboAddCuts->GetTextEntry()->GetText(), "") != 0){
778 if (fRadioTPC->GetState() != kButtonDown) cutStr += " && ";
779 cutStr += fComboAddCuts->GetTextEntry()->GetText();
782 // ********** get formula string **********
783 formulaStr += fComboCustomFit->GetTextEntry()->GetText();
785 // ********** call AliTPCCalibViewer's fit-function
786 returnStr = fViewer->Fit(drawStr.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix);
788 std::cout << std::endl;
789 std::cout << "Your fit formula reads as follows:" << std::endl;
790 std::cout << returnStr->Data() << std::endl;
791 std::cout << "chi2 = " << chi2 << std::endl;
794 void AliTPCCalibViewerGUI::GetMinMax() {
796 // Read current Min & Max from the plot and set it to fTxtSetMin & fTxtSetMax
798 TList* listOfPrimitives = fCanvMain->GetCanvas()->GetListOfPrimitives();
800 for (Int_t i = 0; i < listOfPrimitives->GetEntries(); i++) {
801 ptr = listOfPrimitives->At(i);
802 if ( ptr->InheritsFrom("TH1") ) break;
804 if ( ptr != 0 && !ptr->InheritsFrom("TH1") ) return; // if the loop did not find a TH1
805 TH1 *hist = (TH1*)ptr;
806 Double_t histMax = hist->GetMaximum();
807 Double_t histMin = hist->GetMinimum();
808 fTxtSetMax->SetText(Form("%f",histMax));
809 fTxtSetMin->SetText(Form("%f",histMin));
812 void AliTPCCalibViewerGUI::ChangeSector(){
814 // function that is called, when the number of the sector is changed
815 // to change the sector label
817 Int_t sector = (Int_t)(fNmbSector->GetNumber());
819 if (sector >= 0 && sector <= 17) // IROC, Side A
820 secLabel = "IROC, A";
821 if (sector >= 18 && sector <= 35) // IROC, Side C
822 secLabel = "IROC, C";
823 if (sector >= 36 && sector <= 53) // OROC, Side A
824 secLabel = "OROC, A";
825 if (sector >= 54 && sector <= 71) // OROC, Side C
826 secLabel = "OROC, C";
827 fLblSector->SetText(secLabel);
831 void AliTPCCalibViewerGUI::AddFitFunction(){
833 // adds the last fit function to the normalization list
835 std::cout << "Not yet implemented." << std::endl;
839 void AliTPCCalibViewerGUI::ShowGUI(const char* fileName) {
841 // initialize and show GUI for presentation
843 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
844 frmMain->SetWindowName("AliTPCCalibViewer GUI");
845 frmMain->SetCleanup(kDeepCleanup);
847 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
848 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
850 TGCompositeFrame* tabCont1 = tabMain->AddTab("Viewer 1");
851 TGCompositeFrame* tabCont2 = tabMain->AddTab("Viewer 2");
853 AliTPCCalibViewerGUI* calibViewer1 = new AliTPCCalibViewerGUI(tabCont1, 1000, 600, (char*)fileName);
854 tabCont1->AddFrame(calibViewer1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
856 AliTPCCalibViewerGUI* calibViewer2 = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, (char*)fileName);
857 tabCont2->AddFrame(calibViewer2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
859 frmMain->MapSubwindows();
861 frmMain->MapWindow();