]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/V0Editors.cxx
Getting rid of effC++ warnings about missing copy constructor and assignment operator.
[u/mrichter/AliRoot.git] / EVE / Reve / 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 <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
47 using namespace Reve;
48
49 //______________________________________________________________________
50 // V0ListEditor
51 //
52
53 ClassImp(V0ListEditor)
54
55 V0ListEditor::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
93   TGTextButton* resetCutsButton = new TGTextButton(this, "Reset all cuts", 40);
94   resetCutsButton->Connect("Clicked()", "Reve::V0ListEditor", this, "ResetCuts()");
95   AddFrame(resetCutsButton, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
96 }
97
98 V0ListEditor::~V0ListEditor() {}
99
100
101 //_________________________________________________________________________
102 void 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 //_________________________________________________________________________
119 TGCompositeFrame* 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 //_________________________________________________________________________
144 TGCompositeFrame** 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 //_________________________________________________________________________
223 void 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 //_________________________________________________________________________
264 void 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 //_________________________________________________________________________
287 void V0ListEditor::AddSeeTab() {
288
289   TGCompositeFrame** tab = CreateTab(&fMainTabB, fTabB, 2);
290   delete[] tab;
291 }
292
293
294 //_________________________________________________________________________
295 void V0ListEditor::AdjustHist(Int_t iHist) {
296
297   if (! fMList) return;
298   fMList->AdjustHist(iHist);
299
300   FillCanvas();
301 }
302
303 //_________________________________________________________________________
304 void V0ListEditor::ResetCuts() {
305
306   if (! fMList) return;
307
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
322   Int_t imin, imax;
323   fMList->GetV0IndexRange(imin, imax);
324   if (imin<imax) {
325     Int_t minH = imin - (imax-imin)/20;
326     Int_t maxH = imax + (imax-imin)/20;
327     fMList->SetMin(12, minH);
328     fMList->SetMax(12, maxH);
329     fRange[12]->SetLimits(minH, maxH, TGNumberFormat::kNESInteger);
330     fRange[12]->SetValues(minH, maxH);
331     fMList->AdjustHist(12);
332
333   }
334   FillCanvas();
335   Update();
336 }
337
338
339
340 //_________________________________________________________________________
341 void 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 //_________________________________________________________________________
377 void V0ListEditor::UpdateSelectedTab() {
378
379   Int_t i, j;
380   Pixel_t yellow;
381   Pixel_t grey;
382   gClient->GetColorByName("yellow", yellow);
383   gClient->GetColorByName("grey", grey);
384
385   TGTabElement *tabElem; 
386   for (i=0; i<fMainTabA->GetNumberOfTabs(); i++) {
387
388     tabElem = fMainTabA->GetTabTab(i);
389     tabElem->ChangeBackground(grey);
390
391     for (j=0; j<fTabA[i]->GetNumberOfTabs();j++) {
392       tabElem = fTabA[i]->GetTabTab(j);
393       tabElem->ChangeBackground(grey);
394     }
395   }
396
397   Int_t currentTab = fMainTabA->GetCurrent();
398   Int_t currentSubTab = fTabA[currentTab]->GetCurrent();
399   tabElem = fMainTabA->GetTabTab(currentTab);
400   tabElem->ChangeBackground(yellow);
401   tabElem = fTabA[currentTab]->GetTabTab(currentSubTab);
402   tabElem->ChangeBackground(yellow);
403
404   TCanvas *c1;
405   Int_t iCan = 0;
406   i=0;
407
408   while (currentTab>i) {
409     iCan += fTabA[i]->GetNumberOfTabs();
410     i++;
411   }
412   iCan += currentSubTab;
413   c1 = fCanvasA[iCan]->GetCanvas();
414   c1->GetCanvas()->Modified();
415   c1->GetCanvas()->Update();
416
417   //---
418
419   for (i=0; i<fMainTabB->GetNumberOfTabs(); i++) {
420
421     tabElem = fMainTabB->GetTabTab(i);
422     tabElem->ChangeBackground(grey);
423
424     for (j=0; j<fTabB[i]->GetNumberOfTabs();j++) {
425       tabElem = fTabB[i]->GetTabTab(j);
426       tabElem->ChangeBackground(grey);
427     }
428   }
429
430   currentTab = fMainTabB->GetCurrent();
431   currentSubTab = fTabB[currentTab]->GetCurrent();
432   tabElem = fMainTabB->GetTabTab(currentTab);
433   tabElem->ChangeBackground(yellow);
434   tabElem = fTabB[currentTab]->GetTabTab(currentSubTab);
435   tabElem->ChangeBackground(yellow);
436
437   iCan = 0;
438   i=0;
439
440   while (currentTab>i) {
441     iCan += fTabB[i]->GetNumberOfTabs();
442     i++;
443   }
444   iCan += currentSubTab;
445   c1 = fCanvasB[iCan]->GetCanvas();
446   c1->GetCanvas()->Modified();
447   c1->GetCanvas()->Update();
448 }
449
450
451 //_________________________________________________________________________
452 void V0ListEditor::UpdateAll(Int_t iCanA) {
453
454   TCanvas *c1 = fCanvasA[iCanA]->GetCanvas();
455   c1->Modified();
456   c1->Update();
457
458   static Int_t iCan, i;
459   iCan=0;
460   i=0;
461   while (fMainTabB->GetCurrent()>i) {
462     iCan += fTabB[i]->GetNumberOfTabs();
463     i++;
464   }
465   iCan += fTabB[i]->GetCurrent();
466   c1 = fCanvasB[iCan]->GetCanvas();
467   c1->GetCanvas()->Modified();
468   c1->GetCanvas()->Update();
469
470   Update();
471 }
472
473
474 //_________________________________________________________________________
475
476 void V0ListEditor::DoRnrV0vtx()
477 {
478   fMList->SetRnrV0vtx(fRnrV0vtx->IsOn());
479   Update();
480 }
481
482 void V0ListEditor::DoRnrV0path()
483 {
484   fMList->SetRnrV0path(fRnrV0path->IsOn());
485   Update();
486 }
487
488 void V0ListEditor::DoRnrDaughters()
489 {
490   fMList->SetRnrDaughters(fRnrV0sDaugh->IsOn());
491   Update();
492 }
493
494
495 //_________________________________________________________________________
496 void V0ListEditor::MassK0sRange() {
497
498   fMList->K0sMFilter(fRange[1]->GetMin(), fRange[1]->GetMax());
499   UpdateAll(0);
500 }
501
502 //_________________________________________________________________________
503   void V0ListEditor::MassLamRange() {
504   fMList->LamMFilter(fRange[2]->GetMin(), fRange[2]->GetMax());
505   UpdateAll(1);
506 }
507
508 //_________________________________________________________________________
509   void V0ListEditor::MassAntiLamRange() {
510   fMList->ALamMFilter(fRange[3]->GetMin(), fRange[3]->GetMax());
511   UpdateAll(2);
512 }
513
514 //_________________________________________________________________________
515 void V0ListEditor::ESDv0IndexRange() {
516   fMList->IndexFilter(fRange[12]->GetMin(), fRange[12]->GetMax());
517   UpdateAll(4);
518 }
519
520 //_________________________________________________________________________
521   void V0ListEditor::CosPointingRange() {
522   fMList->CosPointingFilter(fRange[5]->GetMin(), fRange[5]->GetMax());
523   UpdateAll(5);
524 }
525
526 //_________________________________________________________________________
527   void V0ListEditor::DaughterDcaRange() {
528   fMList->DaughterDCAFilter(fRange[4]->GetMin(), fRange[4]->GetMax());
529   UpdateAll(6);
530 }
531
532 //_________________________________________________________________________
533   void V0ListEditor::RadiusRange() {
534   fMList->RadiusFilter(fRange[6]->GetMin(), fRange[6]->GetMax());
535   UpdateAll(7);
536 }
537
538 //_________________________________________________________________________
539 void V0ListEditor::PtRange()
540 {
541   fMList->PtFilter(fRange[0]->GetMin(), fRange[0]->GetMax());
542   UpdateAll(8);
543 }
544
545 //_________________________________________________________________________
546   void V0ListEditor::EtaRange() {
547   fMList->EtaFilter(fRange[7]->GetMin(), fRange[7]->GetMax());
548   UpdateAll(9);
549 }
550
551 //_________________________________________________________________________
552   void V0ListEditor::NegPtRange() {
553   fMList->NegPtFilter(fRange[8]->GetMin(), fRange[8]->GetMax());
554   UpdateAll(10);
555 }
556
557 //_________________________________________________________________________
558   void V0ListEditor::NegEtaRange() {
559   fMList->NegEtaFilter(fRange[9]->GetMin(), fRange[9]->GetMax());
560   UpdateAll(11);
561 }
562
563 //_________________________________________________________________________
564   void V0ListEditor::PosPtRange() {
565   fMList->PosPtFilter(fRange[10]->GetMin(), fRange[10]->GetMax());
566   UpdateAll(12);
567 }
568
569 //_________________________________________________________________________
570   void V0ListEditor::PosEtaRange() {
571   fMList->PosEtaFilter(fRange[11]->GetMin(), fRange[11]->GetMax());
572   UpdateAll(13);
573 }
574