AliRoot Core  edcc906 (edcc906)
AliMUONVPainter.cxx
Go to the documentation of this file.
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 // $Id$
17 
18 #include "AliMUONVPainter.h"
19 
20 #include "AliLog.h"
21 #include "AliMUON2DMap.h"
22 #include "AliMUONCalibParamND.h"
23 #include "AliMUONContour.h"
24 #include "AliMUONContourPainter.h"
25 #include "AliMUONObjectPair.h"
26 #include "AliMUONPainterGroup.h"
27 #include "AliMUONPainterHelper.h"
30 #include "AliMUONVTrackerData.h"
31 #include "AliMpManuUID.h"
32 #include <Riostream.h>
33 #include <TCanvas.h>
34 #include <TClass.h>
35 #include <TClassMenuItem.h>
36 #include <TH1.h>
37 #include <TList.h>
38 #include <TMap.h>
39 #include <TMath.h>
40 #include <TMethodCall.h>
41 #include <TObjArray.h>
42 #include <TObjString.h>
43 #include <TROOT.h>
44 #include <TVirtualPad.h>
45 #include <cassert>
46 #include <float.h>
47 
94 
95 using std::cout;
96 using std::endl;
98 ClassImp(AliMUONVPainter)
100 
101 //_____________________________________________________________________________
102 AliMUONVPainter::AliMUONVPainter(TRootIOCtor*) : TObject(),
103 TQObject(),
104 fHistogram(0x0),
105 fPainterGroups(0x0),
106 fResponderGroup(0x0),
107 fName(""),
108 fPathName(""),
109 fType(""),
110 fMother(0x0),
111 fGroup(0x0),
112 fContour(0x0),
113 fChildren(0x0),
114 fPlotterGroup(0x0),
115 fBorderFactor(1.1),
116 fPad(0x0),
117 fAttributes(),
118 fLineColor(1),
119 fLineWidth(1),
120 fIsValid(kTRUE)
121 {
123  SetID(-1,-1);
124 }
125 
126 //_____________________________________________________________________________
128 : TObject(),
129  TQObject(),
130  fHistogram(0x0),
131  fPainterGroups(0x0),
132  fResponderGroup(0x0),
133  fName(""),
134  fPathName(""),
135  fType(type),
136  fMother(0x0),
137  fGroup(0x0),
138  fContour(0x0),
139  fChildren(0x0),
140  fPlotterGroup(0x0),
141  fBorderFactor(1.1),
142  fPad(0x0),
143  fAttributes(),
144  fLineColor(1),
145  fLineWidth(1),
146  fIsValid(kTRUE)
147 {
149  SetID(-1,-1);
150 }
151 
152 //_____________________________________________________________________________
154 : TObject(rhs),
155 TQObject(),
156 fHistogram(0x0),
157 fPainterGroups(0x0),
158 fResponderGroup(0x0),
159 fName(""),
160 fPathName(""),
161 fType(""),
162 fMother(0x0),
163 fGroup(0x0),
164 fContour(0x0),
165 fChildren(0x0),
166 fPlotterGroup(0x0),
167 fBorderFactor(1.0),
168 fPad(0x0),
169 fAttributes(),
170 fLineColor(-1),
171 fLineWidth(-1),
172 fIsValid(kTRUE)
173 {
175  rhs.Copy(*this);
176 }
177 
178 //_____________________________________________________________________________
181 {
183  if ( this != &rhs )
184  {
185  rhs.Copy(*this);
186  }
187  return *this;
188 }
189 
190 //_____________________________________________________________________________
192 {
194  delete fChildren;
195  delete fHistogram;
196 }
197 
198 //_____________________________________________________________________________
199 AliMpArea
201 {
203  if ( fContour )
204  {
205  return fContour->Area();
206  }
207  else
208  {
209  AliWarning("Returning an invalid area, as contour is not defined");
210  return AliMpArea();
211  }
212 }
213 
214 //_____________________________________________________________________________
215 void
217 {
219  if (!fChildren) fChildren = new TObjArray;
220  assert(painter->Mother()==0x0);
221  fChildren->Add(painter);
222  painter->SetMother(this);
223 }
224 
225 //_____________________________________________________________________________
226 TCollection*
228 {
230  return fChildren;
231 }
232 
233 //_____________________________________________________________________________
234 void
235 AliMUONVPainter::Clicked(AliMUONVPainter* painter, Double_t* values)
236 {
239 
240  if ( Mother() )
241  {
242  Mother()->Clicked(painter,values);
243  }
244  else
245  {
246  Long_t param[] = { (Long_t)painter,(Long_t)values };
247 
248  Emit("Clicked(AliMUONVPainter*,Double_t*)",param);
249  }
250 }
251 
252 //_____________________________________________________________________________
253 void
255 {
258 
259  if ( Mother() )
260  {
261  Mother()->ShiftClicked(painter,values);
262  }
263  else
264  {
265  Long_t param[] = { (Long_t)painter,(Long_t)values };
266 
267  Emit("ShiftClicked(AliMUONVPainter*,Double_t*)",param);
268  }
269 }
270 
271 //_____________________________________________________________________________
272 void
274  Double_t&, Double_t&) const
275 {
277  AliError("Not implemented. Please fixe me");
278 }
279 
280 //_____________________________________________________________________________
281 TString
283 {
285 
286  TString name(PathName());
287 
288  name += "-";
289  name += fAttributes.GetName();
290 
291  return name;
292 }
293 
294 //_____________________________________________________________________________
295 void
296 AliMUONVPainter::Copy(TObject& object) const
297 {
299 
300  TObject::Copy(object);
301 
302  AliMUONVPainter& painter = static_cast<AliMUONVPainter&>(object);
303 
304  painter.fType = fType;
305  painter.fName = fName;
306  painter.fPathName = fPathName;
307 
308  painter.fMother = 0x0;
309  painter.fContour = fContour;
310 
311  painter.fGroup = 0x0;
312  painter.fResponderGroup = 0x0;
313  painter.fPlotterGroup = 0x0;
314 
315  painter.fBorderFactor = fBorderFactor;
316 
317  painter.fAttributes = fAttributes;
318 
319  painter.fAttributes.SetCathodeAndPlaneDisabled(kFALSE);
320 
321  painter.fPad = fPad;
322 
323  painter.fLineColor = fLineColor;
324  painter.fLineWidth = fLineWidth;
325 
326  painter.fIsValid = fIsValid;
327 
328  delete painter.fChildren;
329  painter.fChildren = 0x0;
330 
331  painter.fID[0] = fID[0];
332  painter.fID[1] = fID[1];
333 
334  delete painter.fHistogram;
335  painter.fHistogram = 0x0;
336 
337  TIter next(fChildren);
339 
340  while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
341  {
342  painter.Add(static_cast<AliMUONVPainter*>(p->Clone()));
343  }
344 
345  painter.UpdateGroupsFrom(*this);
346 
347  object.ResetBit(kCanDelete);
348 }
349 
350 //_____________________________________________________________________________
352 AliMUONVPainter::CreateGroup(const char* type, Int_t depth)
353 {
355 
356  if (!fPainterGroups) fPainterGroups = new TMap;
357  TObject* o = fPainterGroups->GetValue(type);
358  if (o)
359  {
360  AliError(Form("Group %s is already there ! Check this",type));
361  return 0x0;
362  }
363  AliMUONPainterGroup* group = new AliMUONPainterGroup(type,depth);
364  fPainterGroups->Add(new TObjString(type),group);
365  return group;
366 }
367 
368 //_____________________________________________________________________________
369 void
371 {
373 
374  if ( Mother() )
375  {
376  AliFatal("Not supposed to create groups for a children");
377  }
378 
379  TList list;
380  FlatList(list);
381 
382  TIter next(&list);
383  AliMUONVPainter* painter;
384 
385  while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
386  {
387  AliMUONPainterGroup* group = Group(painter->Type());
388  if (!group)
389  {
390  group = CreateGroup(painter->Type(),painter->Depth());
391  }
392  group->Add(painter);
393  }
394 }
395 
396 //_____________________________________________________________________________
399 {
401 
402  AliMUONVPainter* p = static_cast<AliMUONVPainter*>(Clone());
403 
404  AliMUONVPainter* master = Master();
405 
406  if ( master )
407  {
408  p->UpdateGroupsFrom(*master);
409  }
410 
411  return p;
412 }
413 
414 //_____________________________________________________________________________
415 Int_t
417 {
419 
420  if ( Mother() )
421  {
422  return Mother()->Depth() + 1;
423  }
424  else
425  {
426  return 0;
427  }
428 }
429 
430 //_____________________________________________________________________________
431 Int_t
433 {
435 
436  static const Int_t kBigValue = 999999;
437 
438  if (!gPad) return kBigValue;
439 
440  Double_t x,y;
441 
442  AliMUONVPainter* painter = GetPainter(px,py,x,y);
443 
444  x=y=0.0; // to avoid compiler warning
445 
446  if ( painter == this) return 0;
447 
448  return kBigValue;
449 }
450 
451 //_____________________________________________________________________________
452 void
454 {
456 
457  AliWarning("Please implement me !");
458 
459  // if ( fMother )
460 // {
461 // // let our top mother emit the signal as clients are probably connected to
462 // // our mother, not to us
463 // Top()->DoubleClicked(painter,values);
464 // }
465 // else
466 // {
467 // Long_t param[] = { (Long_t)painter,(Long_t)values };
468 //
469 // Emit("DoubleClicked(AliMUONVPainter*,Double_t*)",param);
470 // }
471 }
472 
473 //_____________________________________________________________________________
474 void
475 AliMUONVPainter::Draw(Option_t* opt)
476 {
478 
479  if (!gPad)
480  {
481  gROOT->MakeDefCanvas();
482  }
483 
484  Bool_t kMustSetRange(kFALSE);
485 
486  TString sopt(opt);
487  sopt.ToUpper();
488 
489  if (sopt.Contains("R") ) kMustSetRange=kTRUE;
490 
491  if (kMustSetRange)
492  {
493  Double_t x1,y1,x2,y2;
494  GetBoundingBox(x1,y1,x2,y2);
495  if ( gPad) gPad->Range(x1,y1,x2,y2);
496  }
497 
498  if ( !fMother && !fPainterGroups )
499  {
500  CreateGroups();
501  }
502 
503  TIter next(fChildren);
504  AliMUONVPainter* painter;
505  while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
506  {
507  painter->Draw();
508  }
509 
510  AppendPad(opt);
511 
512  fPad = gPad;
513 }
514 
515 //_____________________________________________________________________________
516 void
517 AliMUONVPainter::ExecuteEvent(Int_t event, Int_t px, Int_t py)
518 {
520 
521  Double_t x,y;
522 
523  AliMUONVPainter* painter = GetPainter(px,py,x,y);
524 
525  if ( painter == this )
526  {
527  Double_t values[] = { x,y };
528 
529  switch (event)
530  {
531  case kButton2Up:
532  ShiftClicked(this,values);
533  break;
534  case kButton1Up:
535  Clicked(this,values);
536  break;
537  case kButton1Double:
538  //the following statement is required against other loop executions before returning (depending on the time between the clicks)
539  gPad->GetCanvas()->HandleInput((EEventType)-1,0,0);
540  DoubleClicked(this,values);
541  break;
542  }
543  }
544 }
545 
546 //_____________________________________________________________________________
547 void
549 {
551 
552  TIter next(fChildren);
553  AliMUONVPainter* painter;
554  while ( ( painter = static_cast<AliMUONVPainter*>(next())))
555  {
556  painter->FlatList(list);
557  }
558 
559  list.Add(this);
560 }
561 
562 //_____________________________________________________________________________
563 void
564 AliMUONVPainter::GetBoundingBox(Double_t& x1, Double_t& y1,
565  Double_t& x2, Double_t& y2) const
566 {
568  AliMpArea area(Area().GetPositionX(),
569  Area().GetPositionY(),
570  Area().GetDimensionX()*fBorderFactor,
571  Area().GetDimensionY()*fBorderFactor);
572 
573  x1 = area.LeftBorder();
574  y1 = area.DownBorder();
575  x2 = area.RightBorder();
576  y2 = area.UpBorder();
577 }
578 
579 //_____________________________________________________________________________
580 char*
582 {
584  return const_cast<char*>(GetName());
585 }
586 
587 //_____________________________________________________________________________
589 AliMUONVPainter::GetPainter(Int_t px, Int_t py, Double_t& x, Double_t& y) const
590 {
593 
594  PixelToPad(px,py,x,y);
595 
596  if ( !IsInside(x,y) ) return 0x0;
597 
598  if ( fGroup->IsResponder() ) return const_cast<AliMUONVPainter*>(this);
599 
600  if (fChildren)
601  {
602  TIter next(fChildren);
603  AliMUONVPainter* painter;
604 
605  while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
606  {
607  AliMUONVPainter* p = painter->GetPainter(px,py,x,y);
608  if (p) return p;
609  }
610  }
611 
612  return 0x0;
613 }
614 
615 //_____________________________________________________________________________
616 void
618 {
621 
622  types.SetOwner(kTRUE);
623  types.Clear();
624 
625  TObjArray tmp;
626  tmp.SetOwner(kFALSE);
627 
628  TIter next(fPainterGroups);
629 
630  TObjString* str;
631  while ( ( str = static_cast<TObjString*>(next()) ) )
632  {
633  AliMUONPainterGroup* group = Group(str->String().Data());
634  tmp.AddLast(group);
635  }
636 
637  tmp.Sort();
638 
639  Int_t n = tmp.GetLast()+1;
640 
641  Int_t* index = new Int_t[n];
642 
643  Int_t* a = new Int_t[n];
644 
645  for ( Int_t i = 0; i < n; ++i )
646  {
647  AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>(tmp.At(i));
648  a[i] = group->Depth();
649  }
650 
651  TMath::Sort(n,a,index,kFALSE);
652 
653  for ( Int_t i = 0; i < n; ++i )
654  {
655  AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>(tmp.At(index[i]));
656  types.AddLast(new TObjString(group->Type()));
657  }
658 
659  delete[] index;
660  delete[] a;
661 }
662 
663 //_____________________________________________________________________________
665 AliMUONVPainter::Group(const char* type) const
666 {
668  if (!fPainterGroups) return 0x0;
669  return static_cast<AliMUONPainterGroup*>(fPainterGroups->GetValue(type));
670 }
671 
672 //_____________________________________________________________________________
674 AliMUONVPainter::Group(Int_t depth) const
675 {
677  if (!fPainterGroups) return 0x0;
678  TIter next(fPainterGroups);
679  TObjString* groupName;
680  while ( ( groupName = static_cast<TObjString*>(next()) ) )
681  {
682  AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>
683  (fPainterGroups->GetValue(groupName->String().Data()));
684  if ( group->Depth() == depth )
685  {
686  return group;
687  }
688  }
689  return 0x0;
690 }
691 
692 //_____________________________________________________________________________
693 Bool_t
694 AliMUONVPainter::IsInside(Double_t x, Double_t y) const
695 {
697  if (!fContour) return kFALSE;
698  return fContour->IsInside(x,y);
699 }
700 
701 //_____________________________________________________________________________
702 Bool_t
704 {
706  return MotherGroup()->IsResponder();
707 }
708 
709 //_____________________________________________________________________________
712 {
714 
716 
717  if ( Mother() == 0x0 ) return const_cast<AliMUONVPainter*>(this);
718 
719  AliMUONVPainter* p = Mother();
720 
721  while ( p->Mother() )
722  {
723  p = p->Mother();
724  }
725 
726  return p;
727 }
728 
729 //_____________________________________________________________________________
730 void
732 {
737 
738  if ( !MotherGroup()->IsVisible() ) return;
739 
740  if ( MotherGroup()->IsPlotter() )
741  {
742  PaintArea(*(MotherGroup()->Data()),
743  MotherGroup()->DataIndex(),
744  MotherGroup()->DataMin(),
745  MotherGroup()->DataMax());
746  }
747 
748  if ( MotherGroup()->IsOutlined() )
749  {
750  PaintOutline();
751  }
752 
753  if ( IsExcluded() )
754  {
755  AliMUONContourPainter::Paint(*fContour,1,1,2); // red fill with black thin outline
756  }
757 }
758 
759 //_____________________________________________________________________________
760 TString
761 AliMUONVPainter::Describe(const AliMUONVTrackerData&, Int_t, Double_t, Double_t)
762 {
764  AliError(Form("%s : implement me",GetName()));
765  return "";
766 }
767 
768 //_____________________________________________________________________________
769 void
770 AliMUONVPainter::PaintArea(const AliMUONVTrackerData&, Int_t, Double_t, Double_t)
771 {
773  AliError(Form("%s : implement me",GetName()));
774  return;
775 }
776 
777 //_____________________________________________________________________________
778 void
779 AliMUONVPainter::PaintOutline(Int_t color, Int_t width, Double_t /*x*/, Double_t /*y*/)
780 {
783  Int_t c = color >= 0 ? color : GetLineColor();
784  Int_t w = width >= 0 ? width : GetLineWidth();
785 
787 }
788 
789 //_____________________________________________________________________________
790 void
791 AliMUONVPainter::PixelToPad(Int_t px, Int_t py, Double_t& x, Double_t& y)
792 {
794 
795  x = gPad->PadtoX(gPad->AbsPixeltoX(px));
796  y = gPad->PadtoY(gPad->AbsPixeltoY(py));
797 }
798 
799 //_____________________________________________________________________________
800 void
801 AliMUONVPainter::Print(Option_t* opt) const
802 {
804  for ( Int_t i = 0; i < Depth()*4; ++i )
805  {
806  cout << " ";
807  }
808 
809  if ( !IsValid() ) cout << "!!!INVALID!!!" << endl;
810 
811  cout << Form("%p Name %s Depth %d ContourName %s ID=(%d,%d)",
812  this,GetName(),Depth(),ContourName().Data(),ID0(),ID1());
813 
814  if ( fResponderGroup )
815  {
816  cout << Form(" Responder group %p %s",fResponderGroup,fResponderGroup->Type());
817  }
818  if ( fPlotterGroup )
819  {
820  cout << Form(" Plotter group %p %s",fPlotterGroup,fPlotterGroup->Type());
821  }
822  if ( Mother() )
823  {
824  cout << Form(" Mother %p %s",Mother(),Mother()->GetName());
825  }
826  if ( MotherGroup() )
827  {
828  cout << Form(" Group %p %s ",MotherGroup(),MotherGroup()->Type());
829  }
830 
831  if ( fChildren )
832  {
833  cout << Form(" %d children",fChildren->GetLast()+1);
834  }
835 
836  cout << endl;
837 
838  TString sopt(opt);
839  sopt.ToUpper();
840 
841  if ( fChildren && ( sopt == "FULL" || sopt == "CHILD" ) )
842  {
843  TIter next(fChildren);
844  AliMUONVPainter* painter;
845  while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
846  {
847  painter->Print(opt);
848  }
849  }
850 
851  if ( fPainterGroups && ( sopt == "FULL" || sopt == "GROUP" ) )
852  {
853  TIter next(fPainterGroups);
854  TObjString* groupName;
855  while ( ( groupName = static_cast<TObjString*>(next()) ) )
856  {
857  AliMUONPainterGroup* group = Group(groupName->String().Data());
858  group->Print(opt);
859  }
860  }
861 }
862 
863 //_____________________________________________________________________________
864 void
866 {
868  fAttributes = attributes;
869 }
870 
871 //_____________________________________________________________________________
872 void
874 {
876  if (!contour)
877  {
878  AliError(Form("Setting a null contour for painter %s : bad idea !",PathName().Data()));
879  }
880  fContour = contour;
881 }
882 
883 //_____________________________________________________________________________
884 void
886  Int_t dataIndex)
887 {
890 
891  if ( !fPainterGroups )
892  {
893  CreateGroups();
894  }
895 
896  if ( data )
897  {
898  data->Connect("Destroyed()",ClassName(),this,Form("SetData(=\"%s\",0x0,-1)",pattern));
899  }
900 
901  TIter next(fPainterGroups);
902  TObjString* str;
903 
904  fPlotterGroup = 0x0;
905 
906  while ( ( str = static_cast<TObjString*>(next()) ) )
907  {
908  AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>(fPainterGroups->GetValue(str));
909 
910  if ( group->Matches(pattern) )
911  {
912  group->SetData(data,dataIndex);
913  if ( data )
914  {
915  fPlotterGroup = group;
916  }
917  }
918  else
919  {
920  group->SetData(0x0,-1);
921  }
922  }
923 
924  // Update context menus
925  TList list;
926  FlatList(list);
927 
928  TIter pnext(&list);
930 
932 
933  while ( ( p = static_cast<AliMUONVPainter*>(pnext()) ) )
934  {
935  TList* l = p->IsA()->GetMenuList();
936 
937  l->Delete();
938 
939  TClassMenuItem* n(0x0);
940 
941  l->Add(new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
942  "Include","Include",p,"",-1,kTRUE));
943  l->Add(new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
944  "Exclude","Exclude",p,"",-1,kTRUE));
945 
946  if ( group )
947  {
948  if ( data && data->IsHistogrammed(0) )
949  {
950  // Add histo drawing to the popup menu
951  TString name("Draw histogram of ");
952 
953  name += data->ExternalDimensionName(0);
954 
955  n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
956  name.Data(),"DrawHistogram0",p,"",-1,kTRUE);
957  l->Add(n);
958 
959  name += " clone";
960 
961  n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
962  name.Data(),"DrawHistogramClone0",p,"",-1,kTRUE);
963  l->Add(n);
964  }
965 
966  Int_t nd = data->IsSingleEvent() ? data->ExternalDimension() : data->ExternalDimension()*2;
967 
968  for ( Int_t i = 0; i < nd; ++i )
969  {
970  n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
971  Form("Draw %s clone",data->DimensionName(i).Data()),
972  Form("DrawInternalHistogramClone%d",i),p,"",-1,kTRUE);
973  l->Add(n);
974  }
975  }
976  }
977 }
978 
979 //_____________________________________________________________________________
980 void
982 {
984 
985  delete fHistogram;
986  fHistogram = 0x0;
987 
989 }
990 
991 //_____________________________________________________________________________
992 void
994 {
996 
998 
999  if (fHistogram)
1000  {
1001  new TCanvas();
1002  fHistogram->Draw();
1003  }
1004 }
1005 
1006 //_____________________________________________________________________________
1007 void
1008 AliMUONVPainter::DrawHistogram(Double_t* values) const
1009 {
1011 
1012  delete fHistogram;
1013  fHistogram = 0x0;
1014 
1015  DrawHistogramClone(values);
1016 }
1017 
1018 //_____________________________________________________________________________
1019 void
1021 {
1023 
1025 
1026  if (fHistogram)
1027  {
1028  new TCanvas();
1029  fHistogram->Draw();
1030  }
1031 }
1032 
1033 //_____________________________________________________________________________
1034 void
1036 {
1042 
1043  TIter next(Children());
1044 
1045  AliMUONVPainter* p;
1046 
1047  while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
1048  {
1049  p->FillManuList(manuList);
1050  }
1051 }
1052 
1053 //_____________________________________________________________________________
1054 void
1055 AliMUONVPainter::SetLine(Int_t depth, Int_t lineColor, Int_t lineWidth)
1056 {
1058  AliMUONPainterGroup* group = Group(depth);
1059  if ( group )
1060  {
1061  group->SetLine(lineColor,lineWidth);
1062  }
1063 }
1064 
1065 //_____________________________________________________________________________
1066 void
1068 {
1070  fMother = painter;
1071 }
1072 
1073 //_____________________________________________________________________________
1074 void
1075 AliMUONVPainter::SetOutlined(const char* pattern, Bool_t flag)
1076 {
1079 
1080  if (!fPainterGroups)
1081  {
1082  CreateGroups();
1083  }
1084 
1085  TIter next(fPainterGroups);
1086  TObjString* str;
1087 
1088  while ( ( str = static_cast<TObjString*>(next()) ) )
1089  {
1090  AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>(fPainterGroups->GetValue(str));
1091  if ( group->Matches(pattern) )
1092  {
1093  group->SetOutlined(flag);
1094  }
1095  }
1096 }
1097 
1098 //_____________________________________________________________________________
1099 void
1100 AliMUONVPainter::SetResponder(const char* pattern)
1101 {
1103 
1104  if (!fPainterGroups)
1105  {
1106  CreateGroups();
1107  }
1108 
1109  TIter next(fPainterGroups);
1110  TObjString* str;
1111 
1112  fResponderGroup = 0x0;
1113 
1114  while ( ( str = static_cast<TObjString*>(next()) ) )
1115  {
1116  AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>(fPainterGroups->GetValue(str));
1117  if ( group->Matches(pattern) )
1118  {
1119  group->SetResponder(kTRUE);
1120  fResponderGroup = group;
1121  }
1122  else
1123  {
1124  group->SetResponder(kFALSE);
1125  }
1126  }
1127 }
1128 
1129 //_____________________________________________________________________________
1130 void
1132 {
1134 
1135  if (!fPainterGroups)
1136  {
1137  CreateGroups();
1138  }
1139 
1140  TIter next(fPainterGroups);
1141  TObjString* str;
1142 
1143  fResponderGroup = 0x0;
1144 
1145  while ( ( str = static_cast<TObjString*>(next()) ) )
1146  {
1147  AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>(fPainterGroups->GetValue(str));
1148  if ( group->Depth() == depth )
1149  {
1150  group->SetResponder(kTRUE);
1151  fResponderGroup = group;
1152  break;
1153  }
1154  else
1155  {
1156  group->SetResponder(kFALSE);
1157  }
1158  }
1159 }
1160 
1161 //_____________________________________________________________________________
1162 void
1163 AliMUONVPainter::SetVisible(const char* pattern, Bool_t flag)
1164 {
1166 
1167  if (!fPainterGroups)
1168  {
1169  CreateGroups();
1170  }
1171 
1172  TIter next(fPainterGroups);
1173  TObjString* str;
1174 
1175  while ( ( str = static_cast<TObjString*>(next()) ) )
1176  {
1177  AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>(fPainterGroups->GetValue(str));
1178  if ( group->Matches(pattern) )
1179  {
1180  group->SetVisible(flag);
1181  }
1182  }
1183 }
1184 
1185 //_____________________________________________________________________________
1186 void
1188 {
1190  delete fPainterGroups;
1191  fPainterGroups = 0x0;
1192 
1193  CreateGroups();
1194 
1195  // and copy the status of responder, plotter and visible
1196  if ( painter.ResponderGroup() )
1197  {
1198  SetResponder(painter.ResponderGroup()->Type());
1199  }
1200 
1201  if ( painter.PlotterGroup() )
1202  {
1203  SetData(painter.PlotterGroup()->Type(),
1204  painter.PlotterGroup()->Data(),
1205  painter.PlotterGroup()->DataIndex());
1207  painter.PlotterGroup()->DataMax());
1208  }
1209 
1210  TObjArray types;
1211  painter.GetTypes(types);
1212  TIter next(&types);
1213  TObjString* groupName;
1214 
1215  while ( ( groupName = static_cast<TObjString*>(next()) ) )
1216  {
1217  AliMUONPainterGroup* group = painter.Group(groupName->String().Data());
1218  if ( group->IsVisible() )
1219  {
1220  SetVisible(group->Type(),kTRUE);
1221  }
1222  else
1223  {
1224  SetVisible(group->Type(),kFALSE);
1225  }
1226 
1227  if ( group->IsOutlined() )
1228  {
1229  SetOutlined(group->Type(),kTRUE);
1230  }
1231  else
1232  {
1233  SetOutlined(group->Type(),kFALSE);
1234  }
1235 
1236  SetLine(group->Depth(),group->GetLineColor(),group->GetLineWidth());
1237  }
1238 
1239 }
1240 
1241 //_____________________________________________________________________________
1242 void
1244 {
1246  AliInfo(GetName());
1247 
1249  WriteIROC(1);
1250 }
1251 
1252 //_____________________________________________________________________________
1253 void
1255 {
1257 
1258  FillManuList(manuList);
1259 
1260  // get our dual
1262 
1263  att.Invert();
1264 
1265  att.SetCathodeAndPlaneDisabled(kTRUE);
1266 
1267  AliMUONVPainter* p = AliMUONVPainter::CreatePainter(ClassName(),att,ID0(),ID1());
1268 
1269  if (p)
1270  {
1271  p->FillManuList(manuList);
1272  }
1273 
1274  delete p;
1275 }
1276 
1277 //_____________________________________________________________________________
1278 void
1280 {
1282 
1283  TObjArray manuList;
1284  GetIROCManuList(manuList);
1285 
1286  AliMpManuUID* muid;
1287  TIter nextm(&manuList);
1288  AliMUON2DMap store(true);
1289 
1290  while ((muid=static_cast<AliMpManuUID*>(nextm())))
1291  {
1292  AliMUONVCalibParam* param = new AliMUONCalibParamND(1,64,
1293  muid->DetElemId(),
1294  muid->ManuId(),value);
1295  store.Add(param);
1296  }
1297 
1299 }
1300 
1301 //_____________________________________________________________________________
1302 void
1304 {
1306  AliInfo(GetName());
1307 
1309  WriteIROC(0.0);
1310 }
1311 
1312 //_____________________________________________________________________________
1315 {
1318 }
1319 
1320 //_____________________________________________________________________________
1322 AliMUONVPainter::CreatePainter(const char* className,
1323  const AliMUONAttPainter& att,
1324  Int_t id1, Int_t id2)
1325 {
1327 
1328  TClass* c = TClass::GetClass(className);
1329 
1330  if (!c)
1331  {
1332  AliErrorClass(Form("Cannot get class %s",className));
1333  return 0x0;
1334  }
1335 
1336  Int_t n(0);
1337 
1338  TMethodCall call;
1339 
1340  call.InitWithPrototype(c,className,"AliMUONAttPainter&,Int_t");
1341 
1342  if (call.IsValid()) n = 1;
1343  else
1344  {
1345  call.InitWithPrototype(c,className,"AliMUONAttPainter&,Int_t,Int_t");
1346 
1347  if ( call.IsValid() ) n = 2;
1348  }
1349 
1350  Long_t returnLong(0x0);
1351 
1352  if ( n ==1 )
1353  {
1354  Long_t params[] = { (Long_t)(&att), (Long_t)(id1) };
1355  call.SetParamPtrs((void*)(params),2);
1356  call.Execute((void*)(0x0),returnLong);
1357  }
1358  else if ( n == 2 )
1359  {
1360  Long_t params[] = { (Long_t)(&att), (Long_t)(id1), (Long_t)(id2) };
1361  call.SetParamPtrs((void*)(params),3);
1362  call.Execute((void*)(0x0),returnLong);
1363  }
1364 
1365  if (!returnLong)
1366  {
1367  AliErrorClass(Form("Cannot create a painter of class %s",className));
1368  }
1369 
1370  AliMUONVPainter* rv = reinterpret_cast<AliMUONVPainter*> (returnLong);
1371 
1372  if (!rv->IsValid())
1373  {
1374  AliErrorClass(Form("Painter of class %s is not valid",className));
1375  delete rv;
1376  rv = 0x0;
1377  }
1378  return rv;
1379 }
1380 
1381 //_____________________________________________________________________________
1382 void
1384 {
1386  AliMUONContourPainter::Paint(*(Contour()),-1,-1,fillColor);
1387 }
AliMUONPainterGroup * MotherGroup() const
Return our mother group.
Int_t fID[2]
our ids
AliMUONPainterGroup * ResponderGroup() const
Return the responder group.
void SetID(Int_t id0, Int_t id1)
Set our IDs.
AliMpArea Area() const
static void PixelToPad(Int_t px, Int_t py, Double_t &x, Double_t &y)
void SetOutlined(const char *pattern, Bool_t flag)
Bool_t IsResponder() const
Whether we are the responder group.
AliMUONVPainter * Detach() const
#define TObjArray
Double_t LeftBorder() const
Definition: AliMpArea.cxx:124
AliMUONVTrackerData * InteractiveReadOutConfig() const
Int_t DataIndex() const
Return the index within the data.
void SetLine(Int_t depth, Int_t lineColor, Int_t lineWidth)
virtual void Draw(Option_t *opt="")
TString fPathName
our long name
AliMUONVPainter * fMother
our mother
Int_t DetElemId() const
Get detection element.
Definition: AliMpManuUID.h:27
virtual Bool_t Replace(const AliMUONVStore &store)=0
Replace values.
Bool_t Matches(const char *pattern) const
void SetContour(AliMUONContour *contour)
Set out contour.
TH1 * fHistogram
! histogram
Int_t Depth() const
virtual void ComputeDataRange(const AliMUONVTrackerData &data, Int_t dataIndex, Double_t &dataMin, Double_t &dataMax) const
virtual void SetResponder(const char *pattern)
virtual void DrawInternalHistogramClone(Int_t dim) const
void SetResponder(Bool_t flag=kTRUE)
Set the responder flag.
static TH1 * CreateHisto(const AliMUONVPainter &painter, Int_t externalDim, Int_t internalDim)
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
TROOT * gROOT
Bool_t IsExcluded() const
Whether or not the part of the detector represented by this painter should be excluded from readout...
virtual void Include()
AliMUONPainterGroup * Group(const char *type) const
virtual void PaintOutline(Int_t color=-1, Int_t width=-1, Double_t x=FLT_MAX, Double_t y=FLT_MAX)
Float_t p[]
Definition: kNNTest.C:133
TVirtualPad * fPad
the pad we&#39;re drawn in
A rectangle area positioned in plane..
Definition: AliMpArea.h:20
virtual char * GetObjectInfo(Int_t px, Int_t py) const
virtual const char * GetName() const
Get our name.
virtual TString PathName() const
Get our path name (aka fullname)
void SetOutlined(Bool_t flag=kTRUE)
Set the outlined flag.
virtual TString ContourName() const
Bool_t fIsValid
whether we were properly initialized
void ShiftClicked(AliMUONVPainter *painter, Double_t *pos)
void GetTypes(TObjArray &types) const
Int_t GetLineWidth() const
Get our line width.
virtual void DrawHistogramClone(Double_t *values=0x0) const
virtual void Print(Option_t *opt="") const
AliMUONVPainter * Mother() const
Return our mother (0 if we&#39;re the top node)
virtual TString DimensionName(Int_t dim) const =0
Get the name of a given (internal) dimension.
Int_t ID0() const
Get our first ID.
virtual void PaintArea(Int_t fillColor)
TObjArray * fChildren
our children
Int_t fLineWidth
our outline width
void SetDataRange(Double_t min, Double_t max)
Set the data range.
#define AliWarning(message)
Definition: AliLog.h:541
AliMUONVPainter(TRootIOCtor *)
static AliMUONVPainter * CreatePainter(const char *className, const AliMUONAttPainter &att, Int_t id1, Int_t id2)
Unique ID for manus.
Definition: AliMpManuUID.h:19
virtual ~AliMUONVPainter()
AliMUONPainterGroup * fPlotterGroup
the plotter group
virtual void Copy(TObject &object) const
AliMUONVTrackerData * Data() const
Return the data we are plotting.
void SetVisible(Bool_t flag=kTRUE)
Set the visible flag.
static AliMUONPainterDataRegistry * Instance()
Container of calibration values for a given number of channels.
#define AliErrorClass(message)
Definition: AliLog.h:596
const AliMUONAttPainter & Attributes() const
Get our attributes.
const char * Type() const
Our type.
void SetData(AliMUONVTrackerData *data, Int_t dataIndex)
Int_t Depth() const
Depth.
Int_t ID1() const
Get our second ID.
Base class for a graphical object representing some part of the MUON tracking system.
TString fName
our (short) name
virtual void Exclude()
void SetMother(AliMUONVPainter *painter)
virtual TString Describe(const AliMUONVTrackerData &data, Int_t dataIndex, Double_t x=FLT_MAX, Double_t y=FLT_MAX)
virtual Bool_t IsSingleEvent() const =0
Whether we deal with only one event at a time.
void Add(AliMUONVPainter *painter)
Add a painter to our list of children. We adopt this painter (i.e. we become owner).
AliMUONContour * Contour() const
Return the contour representing the outline of this object.
Bool_t Add(AliMUONVPainter *painter)
#define AliInfo(message)
Definition: AliLog.h:484
void SetCathodeAndPlaneDisabled(Bool_t value)
void SetLine(Int_t lineColor, Int_t lineWidth)
Int_t GetLineColor() const
Get our line color.
Bool_t IsVisible() const
Whether we are visible.
virtual const char * GetName() const
Return our name.
Implementation of AliMUONVCalibParam for tuples of double.
Double_t UpBorder() const
Definition: AliMpArea.cxx:140
AliMUONVPainter * Master() const
void FlatList(TList &list)
AliMUONPainterGroup * fGroup
our group
AliMUONVPainter * GetPainter(Int_t px, Int_t py, Double_t &x, Double_t &y) const
void Clicked(AliMUONVPainter *painter, Double_t *pos)
virtual Bool_t IsHistogrammed(Int_t) const
Whether we have histograms for a given dimension, or not.
void GetBoundingBox(Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2) const
Bool_t IsOutlined() const
Whether we should outline ourselves.
AliMpArea Area() const
Return the area containing this painter.
TString fType
our type (DE, Chamber, MANU, etc...)
#define AliFatal(message)
Definition: AliLog.h:640
Basic implementation of AliMUONVStore container using AliMpExMap internally.
Definition: AliMUON2DMap.h:20
Int_t ManuId() const
Get manu identifier.
Definition: AliMpManuUID.h:30
Double_t DownBorder() const
Definition: AliMpArea.cxx:148
void SetVisible(const char *pattern, Bool_t flag)
AliMUONPainterGroup * CreateGroup(const char *type, Int_t depth)
virtual Bool_t IsValid() const
Whether we are valid or not.
const char * Type() const
Return our type (e.g. PCB, Chamber, DE, MANU, etc...)
AliMUONContour * fContour
our contour
virtual Bool_t Add(TObject *object)
Add an object to the store.
virtual void DrawInternalHistogram(Int_t dim) const
Bool_t IsResponder() const
TMap * fPainterGroups
map of groups
virtual void FillManuList(TObjArray &manuList) const
Append (i.e. don&#39;t have the right to clear the array !) our list of manus to manuList.
2D contour
void UpdateGroupsFrom(const AliMUONVPainter &painter)
AliMUONPainterGroup * fResponderGroup
the responder group
virtual TString ExternalDimensionName(Int_t dim) const =0
Get the name of a given (external) dimension.
Basic attributes shared by all painters.
Double_t DataMin() const
Min data we are plotting.
Int_t fLineColor
our outline color
void WriteIROC(Double_t value)
static void Paint(const AliMUONContour &contour, Int_t lineColor=1, Int_t lineStyle=1, Int_t fillColor=-1, Int_t fillStyle=1001)
Bool_t IsInside(Double_t x, Double_t y) const
#define AliError(message)
Definition: AliLog.h:591
void SetData(const char *pattern, AliMUONVTrackerData *data, Int_t dataIndex)
void DoubleClicked(AliMUONVPainter *painter, Double_t *pos)
A group of AliMUONVPainter.
AliMUONPainterGroup * PlotterGroup() const
Return the plotter group.
virtual TCollection * Children() const
void GetIROCManuList(TObjArray &manuList)
Bool_t IsInside(Double_t x, Double_t y) const
virtual void SetAttributes(const AliMUONAttPainter &attributes)
Base class for MUON data that can be presented at different levels in the hierarchy of the MUON syste...
AliMUONAttPainter fAttributes
our attributes (e.g. view type)
virtual void Paint(Option_t *opt="")
Double_t DataMax() const
Max data we are plotting.
Double_t RightBorder() const
Definition: AliMpArea.cxx:132
Double_t fBorderFactor
border factor for visu
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual Int_t ExternalDimension() const =0
The number of dimensions we are inputting.
void Print(Option_t *opt="") const
AliMUONVTrackerData * InteractiveReadOutConfig() const
AliMUONVPainter & operator=(const AliMUONVPainter &rhs)
virtual void DrawHistogram(Double_t *values=0x0) const