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