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