LCOV - code coverage report
Current view: top level - MUON/MUONgraphics - AliMUONPainterPadStore.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 85 1.2 %
Date: 2016-06-14 17:26:59 Functions: 1 14 7.1 %

          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 "AliMUONPainterPadStore.h"
      19             : 
      20             : #include "AliMUONCalibParamND.h"
      21             : #include "AliMUON2DMap.h"
      22             : #include "AliMUONVStore.h"
      23             : #include "AliMUONVDigit.h"
      24             : #include "AliLog.h"
      25             : #include <Riostream.h>
      26             : #include <TArrayI.h>
      27             : #include <TVector2.h>
      28             : 
      29             : ///\class AliMUONPainterPadStore
      30             : ///
      31             : /// Container for pads
      32             : ///
      33             : ///\author Laurent Aphecetche, Subatech
      34             : 
      35             : using std::cout;
      36             : using std::endl;
      37             : ///\cond CLASSIMP
      38          12 : ClassImp(AliMUONPainterPadStore)
      39             : ///\endcond
      40             : 
      41             : //_____________________________________________________________________________
      42           0 : AliMUONPainterPadStore::AliMUONPainterPadStore(TRootIOCtor* /*dummy*/) : TObject(),
      43           0 : fPadStore(0x0)
      44           0 : {
      45             :   /// ctor
      46           0 : }
      47             : 
      48             : //_____________________________________________________________________________
      49           0 : AliMUONPainterPadStore::AliMUONPainterPadStore() : TObject(),
      50           0 :   fPadStore(new AliMUON2DMap(kTRUE))
      51           0 : {
      52             :     /// ctor
      53           0 : }
      54             : 
      55             : //_____________________________________________________________________________
      56             : AliMUONPainterPadStore::~AliMUONPainterPadStore()
      57           0 : {
      58             :   /// dtor
      59           0 :   delete fPadStore;
      60           0 : }
      61             : 
      62             : //_____________________________________________________________________________
      63             : Int_t
      64             : AliMUONPainterPadStore::FindPadID(const TArrayI& pads, Double_t x, Double_t y) const
      65             : {
      66             :   /// Find, in array of pads, the one which contains (x,y). Returns -1 if not
      67             :   /// found
      68             :   
      69           0 :   for ( Int_t i = 0; i < pads.GetSize(); ++i ) 
      70             :   {
      71           0 :     Int_t id = pads.At(i);
      72             :     
      73           0 :     TVector2 position;
      74           0 :     TVector2 dimensions;
      75             :     
      76           0 :     GetPadGeometry(id,position,dimensions);
      77             :     
      78           0 :     TVector2 bl(position-dimensions);
      79           0 :     TVector2 ur(position+dimensions);    
      80           0 :     if ( bl.X() <= x && ur.X() >= x && bl.Y() <= y && ur.Y() >= y ) 
      81             :     {
      82           0 :       return id;
      83             :     }
      84           0 :   }
      85           0 :   return -1;
      86           0 : }
      87             : 
      88             : 
      89             : //_____________________________________________________________________________
      90             : AliMUONVCalibParam*
      91             : AliMUONPainterPadStore::Get(Int_t detElemId, Int_t manuId) const
      92             : {
      93             :   /// Get the pad container for a given manu
      94             :   
      95             :   AliMUONVCalibParam* param = 
      96           0 :   static_cast<AliMUONVCalibParam*>(fPadStore->FindObject(detElemId,manuId));
      97             :   
      98           0 :   if (!param)
      99             :   {
     100           0 :     param = new AliMUONCalibParamND(4,64,detElemId,manuId,-1.0);
     101           0 :     fPadStore->Add(param);
     102           0 :   }
     103             :   
     104           0 :   return param;
     105           0 : }
     106             : 
     107             : //_____________________________________________________________________________
     108             : void
     109             : AliMUONPainterPadStore::GetBoundaries(const TArrayI& pads,
     110             :                                       Double_t& xmin,
     111             :                                       Double_t& ymin,
     112             :                                       Double_t& xmax,
     113             :                                       Double_t& ymax) const
     114             : {
     115             :   /// Get the area covered by an array of pads
     116             :   
     117           0 :   xmin=ymin=1E9;
     118           0 :   xmax=ymax=-1E9;
     119             :   
     120           0 :   for ( Int_t i = 0; i < pads.GetSize(); ++i ) 
     121             :   {
     122           0 :     Int_t id = pads.At(i);
     123             :     
     124           0 :     TVector2 position;
     125           0 :     TVector2 dimensions;
     126             :     
     127           0 :     GetPadGeometry(id,position,dimensions);
     128             :     
     129           0 :     TVector2 bl(position-dimensions);
     130           0 :     TVector2 ur(position+dimensions);
     131           0 :     xmin = TMath::Min(xmin,bl.X());
     132           0 :     ymin = TMath::Min(ymin,bl.Y());
     133           0 :     xmax = TMath::Max(xmax,ur.X());
     134           0 :     ymax = TMath::Max(ymax,ur.Y());
     135           0 :   }     
     136           0 : }
     137             : 
     138             : //_____________________________________________________________________________
     139             : void
     140             : AliMUONPainterPadStore::GetPadGeometry(Int_t padId, 
     141             :                                        TVector2& position,
     142             :                                        TVector2& dimensions) const
     143             : {
     144             :   /// Get the geomtry of one pad
     145             :   
     146           0 :   if ( padId < 0 ) 
     147             :   {
     148           0 :     AliError(Form("padId is < 0 : %d",padId));
     149           0 :     position.Set(0.0,0.0);
     150           0 :     dimensions.Set(-1.0,-1.0);
     151           0 :     return;
     152             :   }
     153             :   
     154           0 :   Int_t detElemId = AliMUONVDigit::DetElemId(padId);
     155           0 :   Int_t manuId = AliMUONVDigit::ManuId(padId);
     156           0 :   Int_t manuChannel = AliMUONVDigit::ManuChannel(padId);
     157             :   
     158             :   AliMUONVCalibParam* param = 
     159           0 :     static_cast<AliMUONVCalibParam*>(fPadStore->FindObject(detElemId,manuId));
     160             :   
     161           0 :   if (!param)
     162             :   {
     163           0 :     AliError(Form("Could not find object DE %d manu %d",detElemId,manuId));
     164           0 :     position.Set(0.0,0.0);
     165           0 :     dimensions.Set(-1.0,-1.0);
     166           0 :     return;
     167             :   }
     168             :   
     169           0 :   position.Set(param->ValueAsDouble(manuChannel,0),
     170           0 :                param->ValueAsDouble(manuChannel,1));
     171             :   
     172           0 :   dimensions.Set(param->ValueAsDouble(manuChannel,2),
     173           0 :                  param->ValueAsDouble(manuChannel,3));
     174             :   
     175           0 : }
     176             : 
     177             : //_____________________________________________________________________________
     178             : Int_t
     179             : AliMUONPainterPadStore::GetSize() const
     180             : {
     181             :   /// Get the number of pads we handle
     182             :   
     183           0 :   TIter next(fPadStore->CreateIterator());
     184             :   AliMUONVCalibParam* param;
     185             :   Int_t n(0);
     186             :   
     187           0 :   while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
     188             :   {
     189           0 :     for ( Int_t i = 0; i < param->Size(); ++i ) 
     190             :     {
     191           0 :       if ( param->ValueAsDouble(i,2) >= 0 && param->ValueAsDouble(i,3) >= 0 ) 
     192             :       {
     193           0 :         ++n;
     194           0 :       }
     195             :     }
     196             :   }
     197             :   
     198             :   return n;
     199           0 : }
     200             : 
     201             : //_____________________________________________________________________________
     202             : void
     203             : AliMUONPainterPadStore::PrintPads(const TArrayI& pads) const
     204             : {
     205             :   /// Printout
     206           0 :   cout << "n=" << pads.GetSize() << endl;
     207             :   
     208           0 :   for ( Int_t i = 0; i < pads.GetSize(); ++i ) 
     209             :   {
     210           0 :     Int_t id = pads.At(i);
     211           0 :     TVector2 position, dimensions;
     212           0 :     GetPadGeometry(id,position,dimensions);
     213           0 :     cout << Form("i %4d DE %4d ManuID %4d ManuChannel %2d (X,Y)=(%7.3f,%7.3f)"
     214             :                  " (DX,DY)=(%7.3f,%7.3f)",
     215             :                  i,
     216           0 :                  AliMUONVDigit::DetElemId(id),
     217           0 :                  AliMUONVDigit::ManuId(id),
     218           0 :                  AliMUONVDigit::ManuChannel(id),
     219           0 :                  position.X(),position.Y(),
     220           0 :                  dimensions.X(),dimensions.Y()) << endl;
     221           0 :   }
     222           0 : }
     223             : 

Generated by: LCOV version 1.11