]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Reve/V0Editors.cxx
Missing initialization; fiddle with the track marker-style a bit more.
[u/mrichter/AliRoot.git] / EVE / Reve / V0Editors.cxx
CommitLineData
661eeab1 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 This editor appears in the Reve window when v0 are visualize.
19It allows to select the v0 as a function of some useful parameters.
20
21Ludovic Gaudichet (gaudichet@to.infn.it)
22************************************************************************/
23
24
25#include "V0Editors.h"
26#include <Reve/V0.h>
27
28#include <Reve/RGValuators.h>
29
30#include <TVirtualPad.h>
31#include <TColor.h>
32
33#include <TGLabel.h>
34#include <TGButton.h>
35#include <TGNumberEntry.h>
36#include <TGColorSelect.h>
37#include <TGDoubleSlider.h>
38
39#include <TGTab.h>
40#include <TRootEmbeddedCanvas.h>
41#include <TCanvas.h>
42#include <TH1.h>
43#include <TH1F.h>
44#include <TH2F.h>
45
46
47using namespace Reve;
48
49//______________________________________________________________________
50// V0ListEditor
51//
52
53ClassImp(V0ListEditor)
54
55V0ListEditor::V0ListEditor(const TGWindow *p,
56 Int_t width, Int_t height,
57 UInt_t options, Pixel_t back) :
58 TGedFrame(p, width, height, options | kVerticalFrame, back),
59 fMList(0),
60 fRnrV0sDaugh(0),
61 fRnrV0vtx(0),
62 fRnrV0path(0),
63 fMainTabA(0),
64 fMainTabB(0)
65{
66 MakeTitle("V0List");
67
68 //TGHorizontalFrame* frame = new TGHorizontalFrame(this);
69
70 // --- Rendering control
71
72 fRnrV0path = new TGCheckButton(this, "Render v0 path");
73 AddFrame(fRnrV0path, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
74 fRnrV0path->Connect("Toggled(Bool_t)",
75 "Reve::V0ListEditor", this, "DoRnrV0path()");
76
77 fRnrV0vtx = new TGCheckButton(this, "Render v0 vertices");
78 AddFrame(fRnrV0vtx, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
79 fRnrV0vtx->Connect("Toggled(Bool_t)",
80 "Reve::V0ListEditor", this, "DoRnrV0vtx()");
81
82 fRnrV0sDaugh = new TGCheckButton(this, "Render v0 daughters");
83 AddFrame(fRnrV0sDaugh, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
84 fRnrV0sDaugh->Connect("Toggled(Bool_t)",
85 "Reve::V0ListEditor", this, "DoRnrDaughters()");
86
87 for (Int_t i=0; i<fgkNRange; i++) fRange[i]=0;
88 for (Int_t i=0; i<fgkNCanvas; i++) fCanvasA[i]=0;
89
90 AddSelectTab();
91 AddSeeTab();
92
8f14e54c 93 TGTextButton* resetCutsButton = new TGTextButton(this, "Reset all cuts", 40);
661eeab1 94 resetCutsButton->Connect("Clicked()", "Reve::V0ListEditor", this, "ResetCuts()");
95 AddFrame(resetCutsButton, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
96}
97
98V0ListEditor::~V0ListEditor() {}
99
100
101//_________________________________________________________________________
102void V0ListEditor::SetModel(TObject* obj)
103{
104 fMList = dynamic_cast<V0List*>(obj);
105
106 for (Int_t i=0; i<fgkNRange; i++)
107 if (fRange[i]) {
108 fRange[i]->SetValues( fMList->GetMin(i), fMList->GetMax(i) );
109 }
110 fRnrV0sDaugh->SetState(fMList->GetRnrDaughters() ? kButtonDown : kButtonUp);
111 fRnrV0vtx->SetState(fMList->GetRnrV0vtx() ? kButtonDown : kButtonUp);
112 fRnrV0path->SetState(fMList->GetRnrV0path() ? kButtonDown : kButtonUp);
113
114 FillCanvas();
115}
116
117
118//_________________________________________________________________________
119TGCompositeFrame* V0ListEditor::AddTab(TGTab* tab, Int_t i, Int_t can,
120 char *name) {
121
122 TGCompositeFrame* frameTab = tab->AddTab(name);
123 frameTab->SetLayoutManager(new TGVerticalLayout( frameTab ));
124
125 TRootEmbeddedCanvas** embeddedCanvas = 0;
126
127 if (can==1) embeddedCanvas = &fCanvasA[i];
128 else if (can==2) embeddedCanvas = &fCanvasB[i];
129
130 *embeddedCanvas = new TRootEmbeddedCanvas("EmbeddedCanvas", frameTab, 200, 200);
131 TCanvas *c1 = (*embeddedCanvas)->GetCanvas();
132 c1->SetBorderMode(0);
133 c1->SetTicks(1,0);
134 c1->SetGrid();
135 c1->SetBorderMode(0);
136
137 frameTab->AddFrame(*embeddedCanvas, new TGLayoutHints(kLHintsTop|kLHintsExpandX,
138 0, 0, 0, 0));
139 return frameTab;
140}
141
142
143//_________________________________________________________________________
144TGCompositeFrame** V0ListEditor::CreateTab(TGTab **pMainTab, TGTab **ptab, Int_t can) {
145
146 //------
147 // tab widget
148 pMainTab[0] = new TGTab(this,0,0);
149 pMainTab[0]->Connect("Selected(Int_t)", "Reve::V0ListEditor", this, "UpdateSelectedTab()");
150 this->AddFrame(pMainTab[0], new TGLayoutHints( kLHintsTop | kLHintsExpandX,2,2,2,2));
151
152
153 //------
154 // container of "Tab1"
155 TGCompositeFrame *frameTab1 = pMainTab[0]->AddTab("ident.");
156 frameTab1->SetLayoutManager(new TGVerticalLayout(frameTab1));
157
158 // tab widget
159
160 ptab[0] = new TGTab(frameTab1,2,2);
161 ptab[0]->Resize(ptab[0]->GetDefaultSize());
162 // The following is for updating the canvas of a tab if this one is selected
163 // (it updates every canvas)
164 ptab[0]->Connect("Selected(Int_t)", "Reve::V0ListEditor", this, "UpdateSelectedTab()");
165 frameTab1->AddFrame(ptab[0], new TGLayoutHints(kLHintsLeft| kLHintsExpandX,0,0,0,0));
166
167 //------
168 // container of "Tab2"
169 TGCompositeFrame *frameTab2 = pMainTab[0]->AddTab("v0");
170 frameTab2->SetLayoutManager(new TGVerticalLayout(frameTab2));
171
172 // tab widget
173 ptab[1] = new TGTab(frameTab2,440,299);
174 ptab[1]->Resize(ptab[1]->GetDefaultSize());
175 ptab[1]->Connect("Selected(Int_t)", "Reve::V0ListEditor", this, "UpdateSelectedTab()");
176 frameTab2->AddFrame(ptab[1], new TGLayoutHints(kLHintsLeft| kLHintsExpandX ,0,0,0,0));
177
178 //------
179 // container of "Tab3"
180 TGCompositeFrame *frameTab3 = pMainTab[0]->AddTab("daughters");
181 frameTab3->SetLayoutManager(new TGVerticalLayout(frameTab3));
182
183 // tab widget
184 ptab[2] = new TGTab(frameTab3,440,299);
185 ptab[2]->Resize(ptab[2]->GetDefaultSize());
186 ptab[2]->Connect("Selected(Int_t)", "Reve::V0ListEditor", this, "UpdateSelectedTab()");
187 frameTab3->AddFrame(ptab[2], new TGLayoutHints(kLHintsLeft| kLHintsExpandX ,0,0,0,0));
188
189 //------
190 TGCompositeFrame **frameTab = new TGCompositeFrame*[fgkNCanvas];
191
192 frameTab[0] = AddTab(ptab[0], 0, can, "K0s");
193 frameTab[1] = AddTab(ptab[0], 1, can, "Lambda");
194 frameTab[2] = AddTab(ptab[0], 2, can, "Anti-Lambda");
195 frameTab[3] = AddTab(ptab[0], 3, can, "Arm-Podo");
196 frameTab[4] = AddTab(ptab[0], 4, can, "Index");
197 frameTab[5] = AddTab(ptab[1], 5, can, "cosPointing");
198 frameTab[6] = AddTab(ptab[1], 6, can, "daughterDCA");
199 frameTab[7] = AddTab(ptab[1], 7, can, "radius");
200 frameTab[8] = AddTab(ptab[1], 8, can, "Pt");
201 frameTab[9] = AddTab(ptab[1], 9, can, "eta");
202 frameTab[10] = AddTab(ptab[2], 10, can, "neg Pt");
203 frameTab[11] = AddTab(ptab[2], 11, can, "neg eta");
204 frameTab[12] = AddTab(ptab[2], 12, can, "pos Pt");
205 frameTab[13] = AddTab(ptab[2], 13, can, "pos eta");
206
207 pMainTab[0]->SetTab(0);
208 ptab[0]->SetTab(0);
209 ptab[1]->SetTab(0);
210 ptab[2]->SetTab(0);
211
212 Pixel_t darkgrey;
213 gClient->GetColorByName("grey50", darkgrey);
214 ptab[0]->SetBackgroundColor(darkgrey);
215 ptab[1]->SetBackgroundColor(darkgrey);
216 ptab[2]->SetBackgroundColor(darkgrey);
217
218 return frameTab;
219}
220
221
222//_________________________________________________________________________
223void V0ListEditor::AddValuator(TGCompositeFrame* frame, char *name,
224 Float_t min, Float_t max, Int_t pres,
225 char *func, Int_t iHist) {
226
227 TGCompositeFrame* downFrame = new TGCompositeFrame(frame,
228 60, 60, kHorizontalFrame);
229
230 // --- Selectors
231 fRange[iHist] = new RGDoubleValuator(downFrame, name, 200, 0);
232 fRange[iHist]->SetNELength(6);
233 fRange[iHist]->Build();
234 fRange[iHist]->GetSlider()->SetWidth(200);
235
236 fRange[iHist]->SetLimits(min, max, TGNumberFormat::kNESRealTwo);
237 if (pres==0)
238 fRange[iHist]->SetLimits(min, max, TGNumberFormat::kNESInteger);
239 else if (pres==3)
240 fRange[iHist]->SetLimits(min, max, TGNumberFormat::kNESRealThree);
241 else if (pres==4)
242 fRange[iHist]->SetLimits(min, max, TGNumberFormat::kNESRealFour);
243 else if (pres==5)
244 fRange[iHist]->SetLimits(min, max, TGNumberFormat::kNESReal);
245
246 fRange[iHist]->Connect("ValueSet()",
247 "Reve::V0ListEditor", this, func);
248 downFrame->AddFrame(fRange[iHist], new TGLayoutHints(kLHintsLeft,
249 0, 0, 0, 0));
250
251 TGTextButton* adjustButton = new TGTextButton(downFrame, "Adjust Hist", 40);
252
253 char ch[40];
254 sprintf(ch,"AdjustHist(=%i)",iHist);
255 adjustButton->Connect("Clicked()", "Reve::V0ListEditor", this, ch);
256 downFrame->AddFrame(adjustButton, new TGLayoutHints(kLHintsTop, 0, 0, 0, 0));
257
258 frame->AddFrame(downFrame, new TGLayoutHints(kLHintsTop| kLHintsExpandY,
259 0, 0, 0, 0));
260}
261
262
263//_________________________________________________________________________
264void V0ListEditor::AddSelectTab() {
265
266 TGCompositeFrame** tab = CreateTab(&fMainTabA, fTabA, 1);
267
268 AddValuator(tab[0], "mass K0s", 0, 5, 3, "MassK0sRange()", 1);
269 AddValuator(tab[1], "mass Lambda", 0, 5, 3, "MassLamRange()", 2);
270 AddValuator(tab[2], "mass Anti-Lambda", 0, 5, 3, "MassAntiLamRange()", 3);
271 AddValuator(tab[4], "ESD v0 index", 0,1e5, 0, "ESDv0IndexRange()", 12);
272 AddValuator(tab[5], "cos pointing angle", 0.8,1, 5, "CosPointingRange()", 5);
273 AddValuator(tab[6], "daughter DCA", 0, 10, 2, "DaughterDcaRange()", 4);
274 AddValuator(tab[7], "radius", 0,100, 2, "RadiusRange()", 6);
275 AddValuator(tab[8], "Pt range", 0, 10, 2, "PtRange()", 0);
276 AddValuator(tab[9], "eta", -2, 2, 2, "EtaRange()", 7);
277 AddValuator(tab[10], "neg Pt", 0, 10, 2, "NegPtRange()", 8);
278 AddValuator(tab[11], "neg eta", -2, 2, 2, "NegEtaRange()", 9);
279 AddValuator(tab[12], "pos Pt", 0, 10, 2, "PosPtRange()", 10);
280 AddValuator(tab[13], "pos eta", -2, 2, 2, "PosEtaRange()", 11);
281
282 delete[] tab;
283}
284
285
286//_________________________________________________________________________
287void V0ListEditor::AddSeeTab() {
288
289 TGCompositeFrame** tab = CreateTab(&fMainTabB, fTabB, 2);
290 delete[] tab;
291}
292
293
294//_________________________________________________________________________
295void V0ListEditor::AdjustHist(Int_t iHist) {
296
297 if (! fMList) return;
298 fMList->AdjustHist(iHist);
299
300 FillCanvas();
301}
302
303//_________________________________________________________________________
304void V0ListEditor::ResetCuts() {
305
306 if (! fMList) return;
307
8f14e54c 308 Float_t min,max;
309
310 for (Int_t i=0; i<fgkNRange;i++) {
311
312 if (i==12) continue;
313 min = fRange[i]->GetLimitMin();
314 max = fRange[i]->GetLimitMax();
315 fMList->SetMin(i, min);
316 fMList->SetMax(i, max);
317 fRange[i]->SetValues(min, max);
318 fMList->AdjustHist(i);
319 }
320
321 // for the Index we scan its actual range
661eeab1 322 Int_t imin, imax;
323 fMList->GetV0IndexRange(imin, imax);
324 if (imin<imax) {
8f14e54c 325 Int_t minH = imin - (imax-imin)/20;
326 Int_t maxH = imax + (imax-imin)/20;
661eeab1 327 fMList->SetMin(12, minH);
328 fMList->SetMax(12, maxH);
329 fRange[12]->SetLimits(minH, maxH, TGNumberFormat::kNESInteger);
330 fRange[12]->SetValues(minH, maxH);
8f14e54c 331 fMList->AdjustHist(12);
661eeab1 332
333 }
334 FillCanvas();
8f14e54c 335 Update();
661eeab1 336}
337
338
339
340//_________________________________________________________________________
341void V0ListEditor::FillCanvas() {
342
343 fMList->FilterAll();
344
345 TCanvas *c1, *c1b;
346 TH1F *hist = 0;
347 TH2F *hist2D = 0;
348 Bool_t is2D;
349
350 Int_t canvasMap[fgkNCanvas]={1,2,3,1000,12,5,4,6,0, 7,8,9,10,11};
351
352 for (Int_t i=0; i<fgkNCanvas; i++)
353 if (fCanvasA[i]) {
354
355 is2D = canvasMap[i]>999;
356
357 if (is2D) hist2D = fMList->GetHist2D(canvasMap[i]-1000);
358 else hist = fMList->GetHist(canvasMap[i]);
359
360 c1 = fCanvasA[i]->GetCanvas();
361 c1->cd();
362 if (is2D) hist2D->Draw("colz"); else hist->Draw();
363 c1->Modified();
364 c1->Update();
365
366 c1b = fCanvasB[i]->GetCanvas();
367 c1b->cd();
368 if (is2D) hist2D->Draw("colz"); else hist->Draw();
369 c1b->Modified();
370 c1b->Update();
371 }
372 UpdateSelectedTab();
373}
374
375
376//_________________________________________________________________________
377void V0ListEditor::UpdateSelectedTab() {
378
379 Pixel_t yellow;
380 Pixel_t grey;
381 gClient->GetColorByName("yellow", yellow);
382 gClient->GetColorByName("grey", grey);
383
384 TGTabElement *tabElem;
385 for (Int_t i=0; i<fMainTabA->GetNumberOfTabs(); i++) {
386
387 tabElem = fMainTabA->GetTabTab(i);
388 tabElem->ChangeBackground(grey);
389
390 for (Int_t j=0; j<fTabA[i]->GetNumberOfTabs();j++) {
391 tabElem = fTabA[i]->GetTabTab(j);
392 tabElem->ChangeBackground(grey);
393 }
394 }
395
396 Int_t currentTab = fMainTabA->GetCurrent();
397 Int_t currentSubTab = fTabA[currentTab]->GetCurrent();
398 tabElem = fMainTabA->GetTabTab(currentTab);
399 tabElem->ChangeBackground(yellow);
400 tabElem = fTabA[currentTab]->GetTabTab(currentSubTab);
401 tabElem->ChangeBackground(yellow);
402
403 TCanvas *c1;
404 Int_t iCan = 0;
405 Int_t i=0;
406
407 while (currentTab>i) {
408 iCan += fTabA[i]->GetNumberOfTabs();
409 i++;
410 }
411 iCan += currentSubTab;
412 c1 = fCanvasA[iCan]->GetCanvas();
413 c1->GetCanvas()->Modified();
414 c1->GetCanvas()->Update();
415
416 //---
417
418 for (Int_t i=0; i<fMainTabB->GetNumberOfTabs(); i++) {
419
420 tabElem = fMainTabB->GetTabTab(i);
421 tabElem->ChangeBackground(grey);
422
423 for (Int_t j=0; j<fTabB[i]->GetNumberOfTabs();j++) {
424 tabElem = fTabB[i]->GetTabTab(j);
425 tabElem->ChangeBackground(grey);
426 }
427 }
428
429 currentTab = fMainTabB->GetCurrent();
430 currentSubTab = fTabB[currentTab]->GetCurrent();
431 tabElem = fMainTabB->GetTabTab(currentTab);
432 tabElem->ChangeBackground(yellow);
433 tabElem = fTabB[currentTab]->GetTabTab(currentSubTab);
434 tabElem->ChangeBackground(yellow);
435
436 iCan = 0;
437 i=0;
438
439 while (currentTab>i) {
440 iCan += fTabB[i]->GetNumberOfTabs();
441 i++;
442 }
443 iCan += currentSubTab;
444 c1 = fCanvasB[iCan]->GetCanvas();
445 c1->GetCanvas()->Modified();
446 c1->GetCanvas()->Update();
447}
448
449
450//_________________________________________________________________________
451void V0ListEditor::UpdateAll(Int_t iCanA) {
452
453 TCanvas *c1 = fCanvasA[iCanA]->GetCanvas();
454 c1->Modified();
455 c1->Update();
456
457 static Int_t iCan, i;
458 iCan=0;
459 i=0;
460 while (fMainTabB->GetCurrent()>i) {
461 iCan += fTabB[i]->GetNumberOfTabs();
462 i++;
463 }
464 iCan += fTabB[i]->GetCurrent();
465 c1 = fCanvasB[iCan]->GetCanvas();
466 c1->GetCanvas()->Modified();
467 c1->GetCanvas()->Update();
468
469 Update();
470}
471
472
473//_________________________________________________________________________
474
475void V0ListEditor::DoRnrV0vtx()
476{
477 fMList->SetRnrV0vtx(fRnrV0vtx->IsOn());
478 Update();
479}
480
481void V0ListEditor::DoRnrV0path()
482{
483 fMList->SetRnrV0path(fRnrV0path->IsOn());
484 Update();
485}
486
487void V0ListEditor::DoRnrDaughters()
488{
489 fMList->SetRnrDaughters(fRnrV0sDaugh->IsOn());
490 Update();
491}
492
493
494//_________________________________________________________________________
495void V0ListEditor::MassK0sRange() {
496
497 fMList->K0sMFilter(fRange[1]->GetMin(), fRange[1]->GetMax());
498 UpdateAll(0);
499}
500
501//_________________________________________________________________________
502 void V0ListEditor::MassLamRange() {
503 fMList->LamMFilter(fRange[2]->GetMin(), fRange[2]->GetMax());
504 UpdateAll(1);
505}
506
507//_________________________________________________________________________
508 void V0ListEditor::MassAntiLamRange() {
509 fMList->ALamMFilter(fRange[3]->GetMin(), fRange[3]->GetMax());
510 UpdateAll(2);
511}
512
513//_________________________________________________________________________
514void V0ListEditor::ESDv0IndexRange() {
515 fMList->IndexFilter(fRange[12]->GetMin(), fRange[12]->GetMax());
516 UpdateAll(4);
517}
518
519//_________________________________________________________________________
520 void V0ListEditor::CosPointingRange() {
521 fMList->CosPointingFilter(fRange[5]->GetMin(), fRange[5]->GetMax());
522 UpdateAll(5);
523}
524
525//_________________________________________________________________________
526 void V0ListEditor::DaughterDcaRange() {
527 fMList->DaughterDCAFilter(fRange[4]->GetMin(), fRange[4]->GetMax());
528 UpdateAll(6);
529}
530
531//_________________________________________________________________________
532 void V0ListEditor::RadiusRange() {
533 fMList->RadiusFilter(fRange[6]->GetMin(), fRange[6]->GetMax());
534 UpdateAll(7);
535}
536
537//_________________________________________________________________________
538void V0ListEditor::PtRange()
539{
540 fMList->PtFilter(fRange[0]->GetMin(), fRange[0]->GetMax());
541 UpdateAll(8);
542}
543
544//_________________________________________________________________________
545 void V0ListEditor::EtaRange() {
546 fMList->EtaFilter(fRange[7]->GetMin(), fRange[7]->GetMax());
547 UpdateAll(9);
548}
549
550//_________________________________________________________________________
551 void V0ListEditor::NegPtRange() {
552 fMList->NegPtFilter(fRange[8]->GetMin(), fRange[8]->GetMax());
553 UpdateAll(10);
554}
555
556//_________________________________________________________________________
557 void V0ListEditor::NegEtaRange() {
558 fMList->NegEtaFilter(fRange[9]->GetMin(), fRange[9]->GetMax());
559 UpdateAll(11);
560}
561
562//_________________________________________________________________________
563 void V0ListEditor::PosPtRange() {
564 fMList->PosPtFilter(fRange[10]->GetMin(), fRange[10]->GetMax());
565 UpdateAll(12);
566}
567
568//_________________________________________________________________________
569 void V0ListEditor::PosEtaRange() {
570 fMList->PosEtaFilter(fRange[11]->GetMin(), fRange[11]->GetMax());
8f14e54c 571 UpdateAll(13);
661eeab1 572}
573