]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONVPainter.cxx
- update track cuts
[u/mrichter/AliRoot.git] / MUON / AliMUONVPainter.cxx
index 1754d572585e0097ef0dd73f0e06a8481131cbc2..11b2d595d8f9cc71d653a24097318abc579f62e6 100644 (file)
 
 #include "AliMUONVPainter.h"
 
+#include "AliLog.h"
+#include "AliMUON2DMap.h"
+#include "AliMUONCalibParamND.h"
+#include "AliMUONContour.h"
+#include "AliMUONContourPainter.h"
 #include "AliMUONObjectPair.h"
-#include "AliMUONPainterContour.h"
 #include "AliMUONPainterGroup.h"
 #include "AliMUONPainterHelper.h"
+#include "AliMUONPainterDataRegistry.h"
+#include "AliMUONTrackerDataHistogrammer.h"
 #include "AliMUONVTrackerData.h"
-#include "AliCodeTimer.h"
-#include "AliLog.h"
+#include "AliMpManuUID.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 +45,6 @@
 #include <cassert>
 #include <float.h>
 
-
 /// \class AliMUONVPainter
 ///
 /// Base class for a graphical object representing some part of the
 ///
 /// \author Laurent Aphecetche, Subatech
 
+using std::cout;
+using std::endl;
 ///\cond CLASSIMP
 ClassImp(AliMUONVPainter)
 ///\endcond
 
+//_____________________________________________________________________________
+AliMUONVPainter::AliMUONVPainter(TRootIOCtor*) : TObject(), 
+TQObject(),
+fHistogram(0x0),
+fPainterGroups(0x0),
+fResponderGroup(0x0),
+fName(""),
+fPathName(""),
+fType(""),
+fMother(0x0),
+fGroup(0x0),
+fContour(0x0),
+fChildren(0x0),
+fPlotterGroup(0x0),
+fBorderFactor(1.1),
+fPad(0x0),
+fAttributes(),
+fLineColor(1),
+fLineWidth(1),
+fIsValid(kTRUE)
+{
+  /// streamer ctor
+  SetID(-1,-1);
+}
+
 //_____________________________________________________________________________
 AliMUONVPainter::AliMUONVPainter(const char* type)
 : TObject(), 
+  TQObject(),
+  fHistogram(0x0),
+  fPainterGroups(0x0),
+  fResponderGroup(0x0),
   fName(""),
   fPathName(""),
   fType(type),
   fMother(0x0),
   fGroup(0x0),
   fContour(0x0),
-  fPainterGroups(0x0),
   fChildren(0x0),
-  fResponderGroup(0x0),
   fPlotterGroup(0x0),
   fBorderFactor(1.1),
   fPad(0x0),
@@ -118,15 +152,17 @@ AliMUONVPainter::AliMUONVPainter(const char* type)
 //_____________________________________________________________________________
 AliMUONVPainter::AliMUONVPainter(const AliMUONVPainter& rhs)
 : TObject(rhs),
+TQObject(),
+fHistogram(0x0),
+fPainterGroups(0x0),
+fResponderGroup(0x0),
 fName(""),
 fPathName(""),
 fType(""),
 fMother(0x0),
 fGroup(0x0),
 fContour(0x0),
-fPainterGroups(0x0),
 fChildren(0x0),
-fResponderGroup(0x0),
 fPlotterGroup(0x0),
 fBorderFactor(1.0),
 fPad(0x0),
@@ -156,6 +192,7 @@ AliMUONVPainter::~AliMUONVPainter()
 {
   /// dtor
   delete fChildren;
+  delete fHistogram;
 }
 
 //_____________________________________________________________________________
@@ -294,6 +331,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 +551,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;
@@ -529,7 +569,10 @@ AliMUONVPainter::GetBoundingBox(Double_t& x1, Double_t& y1,
                                 Double_t& x2, Double_t& y2) const
 {
   /// Get the bounding box = our area
-  AliMpArea area(Area().Position(),Area().Dimensions()*fBorderFactor);
+  AliMpArea area(Area().GetPositionX(),
+                 Area().GetPositionY(),
+                 Area().GetDimensionX()*fBorderFactor,
+                 Area().GetDimensionY()*fBorderFactor);
 
   x1 = area.LeftBorder();
   y1 = area.DownBorder();
@@ -710,6 +753,11 @@ AliMUONVPainter::Paint(Option_t*)
   {
     PaintOutline();
   }
+  
+  if ( IsExcluded() )
+  {
+    AliMUONContourPainter::Paint(*fContour,1,1,2); // red fill with black thin outline
+  }
 }
 
 //_____________________________________________________________________________
@@ -727,6 +775,7 @@ AliMUONVPainter::PaintArea(const AliMUONVTrackerData&, Int_t, Double_t, Double_t
 {
   /// Default implementation (must be overriden)
   AliError(Form("%s : implement me",GetName()));
+  return;
 }
 
 //_____________________________________________________________________________
@@ -738,7 +787,7 @@ AliMUONVPainter::PaintOutline(Int_t color, Int_t width, Double_t /*x*/, Double_t
   Int_t c = color >= 0 ? color : GetLineColor();
   Int_t w = width >= 0 ? width : GetLineWidth();
   
-  fContour->PaintOutline(c,w);
+  AliMUONContourPainter::Paint(*fContour,c,w);
 }
 
 //_____________________________________________________________________________
@@ -825,7 +874,7 @@ AliMUONVPainter::SetAttributes(const AliMUONAttPainter& attributes)
 
 //_____________________________________________________________________________
 void 
-AliMUONVPainter::SetContour(AliMUONPainterContour* contour)
+AliMUONVPainter::SetContour(AliMUONContour* contour)
 {
   /// Set out contour
   if (!contour)
@@ -848,6 +897,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 +910,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 +924,134 @@ 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->Delete();
+  
+    TClassMenuItem* n(0x0);
+    
+    l->Add(new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
+                              "Include","Include",p,"",-1,kTRUE));
+    l->Add(new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
+                              "Exclude","Exclude",p,"",-1,kTRUE));    
+    
+    if ( group )  
+    {
+      if ( data && data->IsHistogrammed(0) ) 
+      {
+        // Add histo drawing to the popup menu
+        TString name("Draw histogram of ");
+        
+        name += data->ExternalDimensionName(0);
+        
+        n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
+                               name.Data(),"DrawHistogram0",p,"",-1,kTRUE);
+        l->Add(n);
+        
+        name += " clone";
+        
+        n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,p->IsA(),
+                               name.Data(),"DrawHistogramClone0",p,"",-1,kTRUE);
+        l->Add(n);
+      }
+      
+      Int_t nd = data->IsSingleEvent() ? data->ExternalDimension() : data->ExternalDimension()*2;
+      
+      for ( Int_t i = 0; i < nd; ++i ) 
+      {
+        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);
+  }
 }
 
 //_____________________________________________________________________________
@@ -1067,6 +1250,86 @@ AliMUONVPainter::UpdateGroupsFrom(const AliMUONVPainter& painter)
     
     SetLine(group->Depth(),group->GetLineColor(),group->GetLineWidth());
   }
+  
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::Include()
+{
+  /// Include this painter
+  AliInfo(GetName());
+  
+  /// Update the global interactive read out configuration  
+  WriteIROC(1);
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::GetIROCManuList(TObjArray& manuList)
+{
+  /// Get the list of manus spanned by this painter AND by its dual
+
+  FillManuList(manuList);
+  
+  // get our dual
+  AliMUONAttPainter att(Attributes());
+  
+  att.Invert();
+  
+  att.SetCathodeAndPlaneDisabled(kTRUE);
+  
+  AliMUONVPainter* p = AliMUONVPainter::CreatePainter(ClassName(),att,ID0(),ID1());
+  
+  if (p)
+  {
+    p->FillManuList(manuList);
+  }
+  
+  delete p;
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::WriteIROC(Double_t value)
+{
+  /// Update the interactive readout configuration
+  
+  TObjArray manuList;
+  GetIROCManuList(manuList);
+  
+  AliMpManuUID* muid;
+  TIter nextm(&manuList);
+  AliMUON2DMap store(true);
+  
+  while ((muid=static_cast<AliMpManuUID*>(nextm())))
+  {
+    AliMUONVCalibParam* param = new AliMUONCalibParamND(1,64,
+                                                        muid->DetElemId(),
+                                                        muid->ManuId(),value);
+    store.Add(param);
+  }
+  
+  InteractiveReadOutConfig()->Replace(store);
+}
+
+//_____________________________________________________________________________
+void
+AliMUONVPainter::Exclude()
+{
+  /// Exclude this painter
+  AliInfo(GetName());
+  
+  /// Update the global interactive read out configuration
+  WriteIROC(0.0);
+}
+
+//_____________________________________________________________________________
+AliMUONVTrackerData*
+AliMUONVPainter::InteractiveReadOutConfig() const
+{
+  /// get the interactive readout config object
+  return AliMUONPainterDataRegistry::Instance()->InteractiveReadOutConfig();
 }
 
 //_____________________________________________________________________________
@@ -1130,3 +1393,10 @@ AliMUONVPainter::CreatePainter(const char* className,
   return rv;
 }
 
+//_____________________________________________________________________________
+void
+AliMUONVPainter::PaintArea(Int_t fillColor)
+{
+  /// Draw a filled area
+  AliMUONContourPainter::Paint(*(Contour()),-1,-1,fillColor);
+}