]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONVPainter.cxx
Changes needed by the following commit: coding convention for type (_t) and access...
[u/mrichter/AliRoot.git] / MUON / AliMUONVPainter.cxx
index 4cb8ef2266f1382d6ef7c9827f3d5c5c0c243d67..1554162a893a64427757b491136f5a694d153aa1 100644 (file)
 
 #include "AliMUONVPainter.h"
 
+#include "AliCodeTimer.h"
+#include "AliLog.h"
 #include "AliMUONObjectPair.h"
 #include "AliMUONPainterContour.h"
 #include "AliMUONPainterGroup.h"
 #include "AliMUONPainterHelper.h"
+#include "AliMUONTrackerDataHistogrammer.h"
 #include "AliMUONVTrackerData.h"
-#include "AliCodeTimer.h"
-#include "AliLog.h"
 #include <Riostream.h>
 #include <TCanvas.h>
 #include <TClass.h>
-#include <TClass.h>
+#include <TClassMenuItem.h>
+#include <TH1.h>
 #include <TList.h>
 #include <TMap.h>
 #include <TMath.h>
@@ -39,7 +41,6 @@
 #include <cassert>
 #include <float.h>
 
-
 /// \class AliMUONVPainter
 ///
 /// Base class for a graphical object representing some part of the
@@ -94,6 +95,7 @@ ClassImp(AliMUONVPainter)
 //_____________________________________________________________________________
 AliMUONVPainter::AliMUONVPainter(const char* type)
 : TObject(), 
+  TQObject(),
   fName(""),
   fPathName(""),
   fType(type),
@@ -109,7 +111,8 @@ AliMUONVPainter::AliMUONVPainter(const char* type)
   fAttributes(),
   fLineColor(1),
   fLineWidth(1),
-  fIsValid(kTRUE)
+  fIsValid(kTRUE),
+  fHistogram(0x0)
 {
     /// ctor
     SetID(-1,-1);
@@ -118,6 +121,7 @@ AliMUONVPainter::AliMUONVPainter(const char* type)
 //_____________________________________________________________________________
 AliMUONVPainter::AliMUONVPainter(const AliMUONVPainter& rhs)
 : TObject(rhs),
+TQObject(),
 fName(""),
 fPathName(""),
 fType(""),
@@ -133,7 +137,8 @@ fPad(0x0),
 fAttributes(),
 fLineColor(-1),
 fLineWidth(-1),
-fIsValid(kTRUE)
+fIsValid(kTRUE),
+fHistogram(0x0)
 {
   /// copy ctor
   rhs.Copy(*this);
@@ -156,6 +161,7 @@ AliMUONVPainter::~AliMUONVPainter()
 {
   /// dtor
   delete fChildren;
+  delete fHistogram;
 }
 
 //_____________________________________________________________________________
@@ -197,8 +203,8 @@ AliMUONVPainter::Children() const
 void
 AliMUONVPainter::Clicked(AliMUONVPainter* painter, Double_t* values)
 {
-  // let our mother emit the signal as clients are probably connected to
-  // our (grand)mother, not to us
+  /// Let our mother emit the signal as clients are probably connected to
+  /// our (grand)mother, not to us
 
   if ( Mother() ) 
   {
@@ -216,8 +222,8 @@ AliMUONVPainter::Clicked(AliMUONVPainter* painter, Double_t* values)
 void
 AliMUONVPainter::ShiftClicked(AliMUONVPainter* painter, Double_t* values)
 {
-  // let our mother emit the signal as clients are probably connected to
-  // our (grand)mother, not to us
+  /// Let our mother emit the signal as clients are probably connected to
+  /// our (grand)mother, not to us
   
   if ( Mother() ) 
   {
@@ -294,6 +300,9 @@ AliMUONVPainter::Copy(TObject& object) const
   painter.fID[0] = fID[0];
   painter.fID[1] = fID[1];
   
+  delete painter.fHistogram;
+  painter.fHistogram = 0x0;
+  
   TIter next(fChildren);
   AliMUONVPainter* p;
   
@@ -511,7 +520,7 @@ AliMUONVPainter::ExecuteEvent(Int_t event, Int_t px, Int_t py)
 void
 AliMUONVPainter::FlatList(TList& list)
 {
-  /// Make a flat list of our children
+  /// Make a flat list of our children (and ourselves)
   
   TIter next(fChildren);
   AliMUONVPainter* painter;
@@ -848,6 +857,11 @@ AliMUONVPainter::SetData(const char* pattern, AliMUONVTrackerData* data,
     CreateGroups();
   }
   
+  if ( data ) 
+  {
+    data->Connect("Destroyed()",ClassName(),this,Form("SetData(=\"%s\",0x0,-1)",pattern));
+  }
+  
   TIter next(fPainterGroups);
   TObjString* str;
   
@@ -856,6 +870,7 @@ AliMUONVPainter::SetData(const char* pattern, AliMUONVTrackerData* data,
   while ( ( str = static_cast<TObjString*>(next()) ) )
   {
     AliMUONPainterGroup* group = static_cast<AliMUONPainterGroup*>(fPainterGroups->GetValue(str));
+        
     if ( group->Matches(pattern) )
     {
       group->SetData(data,dataIndex);
@@ -869,6 +884,125 @@ AliMUONVPainter::SetData(const char* pattern, AliMUONVTrackerData* data,
       group->SetData(0x0,-1);
     }
   }
+  
+  // Update context menus
+  TList list;
+  FlatList(list);
+  
+  TIter pnext(&list);
+  AliMUONVPainter* p;
+  
+  AliMUONPainterGroup* group = Master()->PlotterGroup();
+  
+  while ( ( p = static_cast<AliMUONVPainter*>(pnext()) ) )
+  {
+    TList* l = p->IsA()->GetMenuList();
+  
+//    l->Clear();
+    l->Delete();
+  
+    if ( group ) 
+    {
+      Int_t dim = group->Data()->InternalToExternal(group->DataIndex());
+      if ( dim < group->Data()->ExternalDimension() )
+      {      
+        if ( data && data->IsHistogrammed(dim) ) 
+        {
+          // Add histo drawing to the popup menu
+          TClassMenuItem* n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
+                                                 "Draw histogram","DrawHistogram0",p,"",-1,kTRUE);
+          l->Add(n);
+          
+          n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
+                                 "Draw histogram clone","DrawHistogramClone0",p,"",-1,kTRUE);
+          l->Add(n);
+        }
+        
+      }
+      
+      for ( Int_t i = 0; i < data->ExternalDimension()*2; ++i ) 
+      {
+        TClassMenuItem* n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
+                                               Form("Draw %s clone",data->DimensionName(i).Data()),
+                                               Form("DrawInternalHistogramClone%d",i),p,"",-1,kTRUE);
+        l->Add(n);
+      } 
+    }
+  }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::DrawInternalHistogram(Int_t dim) const
+{
+  /// Draw histogram (and delete the previous one)
+  
+  delete fHistogram;
+  fHistogram = 0x0;
+  
+  DrawInternalHistogramClone(dim);
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::DrawInternalHistogramClone(Int_t dim) const
+{
+  /// Draw histogram 
+  
+  fHistogram = AliMUONTrackerDataHistogrammer::CreateHisto(*this,-1,dim);
+  
+  if (fHistogram) 
+  {
+    new TCanvas();
+    fHistogram->Draw();
+  }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::DrawHistogram(Double_t* values) const
+{
+  /// Draw histogram (and delete the previous one)
+
+  delete fHistogram;
+  fHistogram = 0x0;
+  
+  DrawHistogramClone(values);
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::DrawHistogramClone(Double_t*) const
+{
+  /// Draw histogram 
+  
+  fHistogram = AliMUONTrackerDataHistogrammer::CreateHisto(*this,0,-1);
+  
+  if (fHistogram) 
+  {
+    new TCanvas();
+    fHistogram->Draw();
+  }
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::FillManuList(TObjArray& manuList) const
+{
+  /// Append to manulist
+  /// This is the default implementation, which just calls the FillManuList
+  /// of all our children.
+  /// Some derived class might need to override this in order to exclude
+  /// some children from the fill.
+  
+  TIter next(Children());
+  
+  AliMUONVPainter* p;
+  
+  while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
+  {
+    p->FillManuList(manuList);
+  }
 }
 
 //_____________________________________________________________________________