LCOV - code coverage report
Current view: top level - MUON/MUONgraphics - AliMUONBusPatchPainter.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 103 1.0 %
Date: 2016-06-14 17:26:59 Functions: 1 21 4.8 %

          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 "AliMUONBusPatchPainter.h"
      19             : 
      20             : #include "AliMUONManuPainter.h"
      21             : #include "AliMUONContour.h"
      22             : #include "AliMUONPainterHelper.h"
      23             : #include "AliMUONVCalibParam.h"
      24             : #include "AliMUONVTrackerData.h"
      25             : #include "AliMpBusPatch.h"
      26             : #include "AliMpConstants.h"
      27             : #include "AliMpDDLStore.h"
      28             : #include "AliMpDEManager.h"
      29             : #include "AliMpPlaneType.h"
      30             : #include "AliLog.h"
      31             : #include <TObjArray.h>
      32             : #include <TString.h>
      33             : #include <float.h>
      34             : 
      35             : /// \class AliMUONBusPatchPainter
      36             : ///
      37             : /// Painter for one bus patch. Actually possibly for only part of one
      38             : /// buspatch (the part that is on the plane/cathode requested when
      39             : /// creating the painter)
      40             : ///
      41             : /// \author Laurent Aphecetche, Subatech
      42             : 
      43             : ///\cond CLASSIMP
      44          12 : ClassImp(AliMUONBusPatchPainter)
      45             : ///\endcond
      46             : 
      47             : //_____________________________________________________________________________
      48             : AliMUONBusPatchPainter::AliMUONBusPatchPainter()
      49           0 : : AliMUONVPainter(),
      50           0 : fBusPatchId(-1)
      51           0 : {
      52             :   /// default ctor
      53           0 : }
      54             : 
      55             : //_____________________________________________________________________________
      56             : AliMUONBusPatchPainter::AliMUONBusPatchPainter(TRootIOCtor* ioCtor)
      57           0 : : AliMUONVPainter(ioCtor),
      58           0 : fBusPatchId(-1)
      59           0 : {
      60             :   /// default streaming ctor
      61           0 : }
      62             : 
      63             : //_____________________________________________________________________________
      64             : AliMUONBusPatchPainter::AliMUONBusPatchPainter(const AliMUONAttPainter& att, 
      65             :                                                Int_t busPatchId)
      66           0 : : AliMUONVPainter("BUSPATCH"),
      67           0 : fBusPatchId(busPatchId)
      68           0 : {
      69             :   /// normal ctor
      70             :   /// WARNING : the construction of this object can fail.
      71             :   /// You MUST check the IsValid() method afterwards (real world would
      72             :   /// be to use exception, but well, whether we should use exceptions
      73             :   /// in aliroot is still unclear to me.
      74             :   
      75           0 :   SetAttributes(Validate(att));
      76             :   
      77           0 :   AliMp::PlaneType planeType = ( Attributes().IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
      78             : 
      79           0 :   Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(busPatchId);
      80             : 
      81           0 :   AliMUONPainterHelper* h = AliMUONPainterHelper::Instance();
      82             :   
      83           0 :   SetID(busPatchId,-1);
      84           0 :   SetName(h->BusPatchName(busPatchId));
      85           0 :   SetPathName(h->BusPatchPathName(busPatchId));
      86             :   
      87           0 :   AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(fBusPatchId);
      88             :   
      89           0 :   Int_t mask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
      90             :   
      91           0 :   AliMUONContour* bpContour = h->GetContour(ContourName());
      92             :   
      93             :   Double_t xmin(FLT_MAX), ymin(FLT_MAX), xmax(-FLT_MAX), ymax(-FLT_MAX);
      94             :   
      95           0 :   TObjArray contours;
      96             :   
      97             :   Int_t nmanus(0);
      98             :   
      99           0 :   for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i ) 
     100             :   {
     101           0 :     Int_t manuId = busPatch->GetManuId(i);
     102             :     
     103             :     Bool_t correctPlane(kTRUE);
     104             :     
     105           0 :     if ( planeType == AliMp::kNonBendingPlane ) 
     106             :     {
     107           0 :       if ( ( manuId & mask ) == 0 ) correctPlane = kFALSE;
     108             :     }
     109             :     else
     110             :     {
     111           0 :       if ( ( manuId & mask ) == mask ) correctPlane = kFALSE;
     112             :     }
     113             : 
     114           0 :     if (!correctPlane) continue;
     115             :     
     116           0 :     ++nmanus;
     117             :     
     118           0 :     AliMUONVPainter* painter = new AliMUONManuPainter(Attributes(),
     119           0 :                                                       busPatch->GetDEId(),
     120             :                                                       manuId);
     121             :     
     122           0 :     Add(painter);
     123             :     
     124           0 :     const AliMpArea& area = painter->Area();
     125             :     
     126           0 :     xmin = TMath::Min(xmin,area.LeftBorder());
     127           0 :     ymin = TMath::Min(ymin,area.DownBorder());
     128           0 :     xmax = TMath::Max(xmax,area.RightBorder());
     129           0 :     ymax = TMath::Max(ymax,area.UpBorder());
     130             :     
     131           0 :     if (!bpContour)
     132             :     {
     133           0 :       contours.Add(painter->Contour());
     134             :     }
     135           0 :   }
     136             :   
     137           0 :   if ( !nmanus )
     138             :   {
     139           0 :     Invalidate();
     140           0 :     return;
     141             :   }
     142             :     
     143           0 :   if (!bpContour)
     144             :   {
     145           0 :     bpContour = h->MergeContours(contours,ContourName());
     146           0 :     if (!bpContour)
     147             :     {
     148           0 :       AliError("Could not merge those contours");
     149           0 :       StdoutToAliError(contours.Print(););
     150           0 :     }
     151             :   }
     152             :   
     153           0 :   SetContour(bpContour);
     154           0 : }
     155             : 
     156             : //_____________________________________________________________________________
     157             : void 
     158             : AliMUONBusPatchPainter::ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex, 
     159             :                                          Double_t& dataMin, Double_t& dataMax) const
     160             : {
     161             :   /// Compute the data range spanned by this bus patch (on this cathode or plane)
     162           0 :   dataMin = dataMax = data.BusPatch(fBusPatchId, dataIndex);
     163           0 : }
     164             : 
     165             : //_____________________________________________________________________________
     166             : AliMUONBusPatchPainter::AliMUONBusPatchPainter(const AliMUONBusPatchPainter& rhs)
     167           0 : : AliMUONVPainter(rhs), fBusPatchId(-1)
     168           0 : {
     169             :   /// Copy ctor
     170           0 :   rhs.Copy(*this);
     171           0 : }
     172             : 
     173             : //_____________________________________________________________________________
     174             : AliMUONBusPatchPainter&
     175             : AliMUONBusPatchPainter::operator=(const AliMUONBusPatchPainter& rhs)
     176             : {
     177             :   /// Assignment operator
     178           0 :   if ( this != &rhs ) 
     179             :   {
     180           0 :     rhs.Copy(*this);
     181           0 :   }
     182           0 :   return *this;
     183             : }
     184             : 
     185             : //_____________________________________________________________________________
     186           0 : AliMUONBusPatchPainter::~AliMUONBusPatchPainter()
     187           0 : {
     188             :   /// dtor
     189           0 : }
     190             : 
     191             : //_____________________________________________________________________________
     192             : void
     193             : AliMUONBusPatchPainter::Copy(TObject& object) const
     194             : {
     195             :   /// Copy this to object
     196           0 :   AliMUONVPainter::Copy((AliMUONVPainter&)(object));
     197           0 :   ((AliMUONBusPatchPainter&)(object)).fBusPatchId = fBusPatchId;
     198           0 : }
     199             : 
     200             : //_____________________________________________________________________________
     201             : Bool_t
     202             : AliMUONBusPatchPainter::IsIncluded() const
     203             : {
     204             :   /// whether this bus patch is included in the readout or not
     205           0 :   return ( InteractiveReadOutConfig()->BusPatch(fBusPatchId) > 0 );
     206             : }
     207             : 
     208             : //_____________________________________________________________________________
     209             : TString
     210             : AliMUONBusPatchPainter::Describe(const AliMUONVTrackerData& data, Int_t dataIndex, 
     211             :                                  Double_t, Double_t)
     212             : {
     213             :   /// Text about data
     214             :   
     215           0 :   if (!data.HasBusPatch(fBusPatchId)) return "";
     216             :   
     217           0 :   Double_t value = data.BusPatch(fBusPatchId,dataIndex);
     218             :   
     219           0 :   return AliMUONPainterHelper::Instance()->FormatValue(data.DimensionName(dataIndex).Data(),value);
     220           0 : }
     221             : 
     222             : //_____________________________________________________________________________
     223             : void
     224             : AliMUONBusPatchPainter::PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
     225             :                                   Double_t min, Double_t max)
     226             : {
     227             :   /// Paint area of this buspatch according to the data
     228             :   
     229           0 :   if (!data.HasBusPatch(fBusPatchId)) return;
     230             :   
     231           0 :   Double_t value = data.BusPatch(fBusPatchId,dataIndex);
     232             :   
     233           0 :   if ( value >= AliMUONVCalibParam::InvalidFloatValue() ) return;
     234             :   
     235           0 :   Int_t color = AliMUONPainterHelper::Instance()->ColorFromValue(value,min,max);
     236             :   
     237           0 :   PaintArea(color);
     238           0 : }
     239             : 
     240             : //_____________________________________________________________________________
     241             : AliMUONAttPainter 
     242             : AliMUONBusPatchPainter::Validate(const AliMUONAttPainter& attributes) const
     243             : {
     244             :   /// Normalize attributes
     245             :   
     246             :   // we invalidate the attributes, if we have no manu in the requested plane
     247             :   // and we cross-check that both cathode and plane are up-to-date
     248             :   
     249           0 :   AliMUONAttPainter norm(attributes);
     250             :   
     251           0 :   Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(fBusPatchId);
     252             : 
     253           0 :   if (!norm.IsValid()) return norm;
     254             :   
     255           0 :   if ( !norm.IsCathodeDefined() )
     256             :   {
     257           0 :     AliMp::PlaneType planeType = ( norm.IsBendingPlane() ? AliMp::kBendingPlane : AliMp::kNonBendingPlane );
     258             :   
     259           0 :     AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId,planeType);
     260             :     
     261           0 :     Bool_t cath0 = ( cathodeType == AliMp::kCath0 );
     262             :     
     263           0 :     norm.SetCathode(cath0,!cath0);
     264           0 :   }
     265           0 :   else if ( !norm.IsPlaneDefined() )
     266             :   {
     267           0 :     AliMp::CathodType cathodeType = ( norm.IsCathode0() ? AliMp::kCath0 : AliMp::kCath1 );
     268             :     
     269           0 :     AliMp::PlaneType planeType = AliMpDEManager::GetPlaneType(detElemId,cathodeType);
     270             :     
     271           0 :     Bool_t bending = ( planeType == AliMp::kBendingPlane );
     272             : 
     273           0 :     norm.SetPlane(bending,!bending);    
     274           0 :   }
     275             :   
     276           0 :   AliMpBusPatch* busPatch = AliMpDDLStore::Instance()->GetBusPatch(fBusPatchId);
     277             :   
     278           0 :   Int_t mask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
     279             :   
     280             :   Int_t nb(0);
     281             :   Int_t b(0);
     282             :   
     283           0 :   for ( Int_t i = 0; i < busPatch->GetNofManus(); ++i ) 
     284             :   {
     285           0 :     Int_t manuId = busPatch->GetManuId(i);
     286             :     
     287           0 :     if ( manuId & mask  ) ++nb;
     288           0 :     else ++b;
     289             :   }
     290             :   
     291           0 :   if ( norm.IsBendingPlane() && !b ) norm.SetValid(kFALSE);
     292           0 :   if ( norm.IsNonBendingPlane() && !nb ) norm.SetValid(kFALSE);
     293             :   
     294             :   return norm;
     295           0 : }
     296             : 

Generated by: LCOV version 1.11