LCOV - code coverage report
Current view: top level - MUON/MUONgraphics - AliMUONPainterGroup.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 114 0.9 %
Date: 2016-06-14 17:26:59 Functions: 1 19 5.3 %

          Line data    Source code
       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 "AliMUONPainterGroup.h"
      19             : 
      20             : #include "AliMUONVPainter.h"
      21             : #include "AliMUONVTrackerData.h"
      22             : #include "AliLog.h"
      23             : #include <Riostream.h>
      24             : #include <TObjArray.h>
      25             : #include <float.h>
      26             : 
      27             : ///\class AliMUONPainterGroup
      28             : ///
      29             : /// A group of AliMUONVPainter
      30             : ///
      31             : ///\author Laurent Aphecetche, Subatech
      32             : 
      33             : using std::cout;
      34             : using std::endl;
      35             : ///\cond CLASSIMP
      36          12 : ClassImp(AliMUONPainterGroup)
      37             : ///\endcond
      38             : 
      39             : //_____________________________________________________________________________
      40             : AliMUONPainterGroup::AliMUONPainterGroup()
      41           0 : : TObject(),
      42           0 : fType(""),
      43           0 : fIsResponder(kFALSE),
      44           0 : fIsVisible(kTRUE),
      45           0 : fData(0x0),
      46           0 : fDataIndex(-1),
      47           0 : fDataMin(FLT_MAX),
      48           0 : fDataMax(-FLT_MAX),
      49           0 : fPainters(0x0),
      50           0 : fDepth(-1),
      51           0 : fIsOutlined(kTRUE)
      52           0 : {
      53             :   /// ctor
      54           0 : }
      55             : 
      56             : //_____________________________________________________________________________
      57             : AliMUONPainterGroup::AliMUONPainterGroup(const char* type, Int_t depth)
      58           0 : : TObject(),
      59           0 :  fType(type),
      60           0 :  fIsResponder(kFALSE),
      61           0 :  fIsVisible(kTRUE),
      62           0 :  fData(0x0),
      63           0 :  fDataIndex(-1),
      64           0 :  fDataMin(FLT_MAX),
      65           0 :  fDataMax(-FLT_MAX),
      66           0 :  fPainters(0x0),
      67           0 :  fDepth(depth),
      68           0 :  fIsOutlined(kTRUE)
      69           0 : {
      70             :    /// ctor
      71           0 :    if ( fType == "" || fDepth < 0 ) 
      72             :    {
      73           0 :      AliFatal("Sorry guy.");
      74             :    }
      75           0 : }
      76             : 
      77             : //_____________________________________________________________________________
      78             : AliMUONPainterGroup::~AliMUONPainterGroup()
      79           0 : {
      80             :   /// dtor
      81           0 :   delete fPainters;
      82           0 : }
      83             : 
      84             : //_____________________________________________________________________________
      85             : Bool_t
      86             : AliMUONPainterGroup::Add(AliMUONVPainter* painter)
      87             : {
      88             :   /// Add a painter to this group (must be of the correct type)
      89             :   
      90           0 :    if ( fType != painter->Type() ) 
      91             :    {
      92           0 :      AliError(Form("Cannot add painter of type %s to this = %s",
      93             :                    painter->Type(), fType.Data()));
      94           0 :      return kFALSE;
      95             :    }
      96             :   
      97           0 :   if ( fDepth != painter->Depth() )
      98             :   {
      99           0 :     AliError(Form("Cannot add painter of depth %d to this = %d",
     100             :                   painter->Depth(), fDepth));
     101           0 :     return kFALSE;
     102             :   }
     103             :   
     104           0 :   if (!fPainters)
     105             :   {
     106           0 :     fPainters = new TObjArray;
     107           0 :   }
     108             :   
     109           0 :   painter->SetMotherGroup(this);
     110             :   
     111           0 :   fPainters->Add(painter);
     112             : 
     113           0 :   return kTRUE;
     114           0 : }
     115             : 
     116             : //_____________________________________________________________________________
     117             : Int_t 
     118             : AliMUONPainterGroup::Compare(const TObject* obj) const
     119             : {
     120             :   /// Compare with another group (based on type)
     121             :   
     122           0 :   const AliMUONPainterGroup* group = static_cast<const AliMUONPainterGroup*>(obj);
     123           0 :   return fType.CompareTo(group->Type());
     124             : }
     125             : 
     126             : //_____________________________________________________________________________
     127             : void
     128             : AliMUONPainterGroup::ComputeDataRange(Double_t& dataMin, Double_t& dataMax)
     129             : {
     130             :   /// Compute the data range spanned by this group
     131           0 :   dataMin = FLT_MAX;
     132           0 :   dataMax = -FLT_MAX;
     133             :   
     134           0 :   if ( !fData || fDataIndex < 0 ) return;
     135             : 
     136           0 :   TIter next(fPainters);
     137             :   AliMUONVPainter* p;
     138             :   
     139           0 :   while ( ( p = static_cast<AliMUONVPainter*>(next()) ) )
     140             :   {
     141           0 :     Double_t min, max;
     142           0 :     p->ComputeDataRange(*fData,fDataIndex,min,max);
     143           0 :     dataMin = TMath::Min(min,dataMin);
     144           0 :     dataMax = TMath::Max(max,dataMax);
     145           0 :   }
     146           0 : }
     147             : 
     148             : //_____________________________________________________________________________
     149             : void
     150             : AliMUONPainterGroup::Draw(Option_t* opt)
     151             : {
     152             :   /// Draw our painters
     153           0 :   TIter next(fPainters);
     154             :   TObject* o;
     155           0 :   while ( ( o = next() ) )
     156             :   {
     157           0 :     o->Draw(opt);
     158             :   }
     159           0 : }  
     160             : 
     161             : //_____________________________________________________________________________
     162             : AliMUONVPainter* 
     163             : AliMUONPainterGroup::First() const
     164             : {
     165             :   /// Get the first painter in group
     166           0 :   if ( fPainters ) 
     167             :   {
     168           0 :     return static_cast<AliMUONVPainter*>(fPainters->First());
     169             :   }
     170           0 :   return 0x0;
     171           0 : }
     172             : 
     173             : //_____________________________________________________________________________
     174             : Int_t
     175             : AliMUONPainterGroup::GetLineColor() const
     176             : {
     177             :   /// Get line color of this group's painters
     178           0 :   if ( fPainters ) 
     179             :   {
     180           0 :     return static_cast<AliMUONVPainter*>(fPainters->First())->GetLineColor();
     181             :   }
     182           0 :   return 1;
     183           0 : }
     184             : 
     185             : //_____________________________________________________________________________
     186             : Int_t
     187             : AliMUONPainterGroup::GetLineWidth() const
     188             : {
     189             :   /// Get line width of this group's painters
     190           0 :   if ( fPainters ) 
     191             :   {
     192           0 :     return static_cast<AliMUONVPainter*>(fPainters->First())->GetLineWidth();
     193             :   }
     194           0 :   return 1;
     195           0 : }
     196             : 
     197             : //_____________________________________________________________________________
     198             : Bool_t
     199             : AliMUONPainterGroup::Matches(const char* pattern) const
     200             : {
     201             :   /// Whether our type matches "pattern"
     202           0 :   TString spattern(pattern);
     203             :   
     204           0 :   if ( spattern == "*" || fType.Contains(pattern) )
     205             :   {
     206           0 :     return kTRUE;
     207             :   }
     208           0 :   return kFALSE;
     209           0 : }
     210             : 
     211             : //_____________________________________________________________________________
     212             : void
     213             : AliMUONPainterGroup::Print(Option_t* opt) const
     214             : {
     215             :   /// Printout
     216           0 :   cout << "Type " << fType.Data() << " Depth " << fDepth;
     217           0 :   if ( IsResponder() ) cout << " is responder ";
     218           0 :   if ( IsVisible() ) cout << " is visible ";
     219           0 :   if ( IsPlotter() ) 
     220             :   {
     221           0 :     cout << Form(" is plotter for data %p %s dimension %d %s plot range = %e, %e",
     222           0 :                  fData,(fData ? fData->Name() : ""),
     223           0 :                  fDataIndex,( (fData && fDataIndex>=0 ) ? 
     224           0 :                               fData->DimensionName(fDataIndex).Data() : ""),
     225           0 :                  DataMin(),DataMax());
     226             :   }
     227           0 :   if ( IsOutlined() ) 
     228             :   {
     229           0 :     cout << " is outlined";
     230           0 :   }
     231           0 :   if ( fPainters ) 
     232             :   {
     233           0 :     cout << " contains " << fPainters->GetLast()+1 << " painters";
     234           0 :   }
     235             :   
     236           0 :   cout << endl;
     237             :   
     238           0 :   TString sopt(opt);
     239           0 :   sopt.ToUpper();
     240           0 :   if ( sopt == "FULL" ) 
     241             :   {
     242           0 :     TIter next(fPainters);
     243             :     AliMUONVPainter* painter;
     244           0 :     while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
     245             :     {
     246           0 :       cout << "    ";
     247           0 :       painter->Print();
     248             :     }
     249           0 :   }
     250           0 : }
     251             : 
     252             : //_____________________________________________________________________________
     253             : void 
     254             : AliMUONPainterGroup::SetData(AliMUONVTrackerData* data, Int_t dataIndex)
     255             : { 
     256             :   /// Set the data to be plotted
     257           0 :   fData = data; 
     258           0 :   fDataIndex = dataIndex; 
     259           0 :   fDataMax = -FLT_MAX;
     260           0 :   fDataMin = FLT_MAX;
     261           0 : }
     262             : 
     263             : //_____________________________________________________________________________
     264             : void
     265             : AliMUONPainterGroup::SetLine(Int_t lineColor, Int_t lineWidth)
     266             : {
     267             :   /// Set our outline attributes
     268           0 :   TIter next(fPainters);
     269             :   AliMUONVPainter* painter;
     270           0 :   while ( ( painter = static_cast<AliMUONVPainter*>(next()) ) )
     271             :   {
     272           0 :     painter->SetLineColor(lineColor);
     273           0 :     painter->SetLineWidth(lineWidth);
     274             :   }
     275           0 : }  
     276             : 

Generated by: LCOV version 1.11