LCOV - code coverage report
Current view: top level - MUON/MUONgraphics - AliMUONPainterDataRegistry.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 91 1.1 %
Date: 2016-06-14 17:26:59 Functions: 1 23 4.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: AliMUONPainterDataRegistry.cxx 26812 2008-06-20 15:22:59Z laphecet $
      17             : 
      18             : #include "AliMUONPainterDataRegistry.h"
      19             : 
      20             : #include "AliMpManuIterator.h"
      21             : #include "AliMUON2DMap.h"
      22             : #include "AliMUONCalibParamND.h"
      23             : #include "AliMUONTrackerData.h"
      24             : #include "AliMUONVTrackerDataMaker.h"
      25             : #include "AliLog.h"
      26             : #include <THashList.h>
      27             : #include <TObjArray.h>
      28             : #include <TString.h>
      29             : #include <Riostream.h>
      30             : 
      31             : ///\class AliMUONPainterDataRegistry
      32             : ///
      33             : /// Registry for AliMUONVPainter related stuff : painter data sources
      34             : /// and painter matrices
      35             : ///
      36             : ///\author Laurent Aphecetche, Subatech
      37             : 
      38             : using std::cout;
      39             : using std::endl;
      40             : ///\cond CLASSIMP
      41          12 : ClassImp(AliMUONPainterDataRegistry)
      42             : ///\endcond
      43             : 
      44             : AliMUONPainterDataRegistry* AliMUONPainterDataRegistry::fgInstance(0x0);
      45             : 
      46             : //_____________________________________________________________________________
      47           0 : AliMUONPainterDataRegistry::AliMUONPainterDataRegistry() : TObject(), TQObject(),
      48           0 : fDataMakers(new TObjArray),
      49           0 : fZombies(new TObjArray),
      50           0 : fInteractiveReadOutConfig(0x0)
      51           0 : {
      52             :   /// ctor
      53           0 :   fDataMakers->SetOwner(kTRUE);
      54           0 :   fZombies->SetOwner(kTRUE);
      55           0 : }
      56             : 
      57             : //_____________________________________________________________________________
      58           0 : AliMUONPainterDataRegistry::~AliMUONPainterDataRegistry()
      59           0 : {
      60             :   /// dtor
      61           0 :   delete fDataMakers;
      62           0 :   delete fInteractiveReadOutConfig;
      63           0 : }
      64             : 
      65             : //_____________________________________________________________________________
      66             : void
      67             : AliMUONPainterDataRegistry::CreateInteractiveReadOutConfig() const
      68             : {
      69             :   /// Create a base config
      70             :   
      71           0 :   fInteractiveReadOutConfig = new AliMUONTrackerData("IROC","IROC",1);
      72           0 :   fInteractiveReadOutConfig->SetDimensionName(0,"Switch");
      73           0 :   fInteractiveReadOutConfig->DisableChannelLevel();
      74           0 :   AliMpManuIterator it;
      75           0 :   Int_t detElemId;
      76           0 :   Int_t manuId;
      77           0 :   AliMUON2DMap store(true);
      78             : 
      79           0 :   while ( it.Next(detElemId,manuId) )
      80             :   {
      81           0 :     AliMUONVCalibParam* param = new AliMUONCalibParamND(1,64,detElemId,manuId,1);
      82           0 :     store.Add(param);
      83             :   }
      84           0 :   fInteractiveReadOutConfig->Add(store);
      85           0 : }
      86             : 
      87             : //_____________________________________________________________________________
      88             : AliMUONVTrackerDataMaker* 
      89             : AliMUONPainterDataRegistry::DataMaker(Int_t i) const
      90             : {
      91             :   /// Get one data source
      92           0 :   if ( i >= 0 && i <= fDataMakers->GetLast() )
      93             :   {
      94           0 :     return static_cast<AliMUONVTrackerDataMaker*>(fDataMakers->At(i));
      95             :   }
      96             :   else
      97             :   {
      98           0 :     AliError(Form("Index out of bounds : %d / %d",i,fDataMakers->GetLast()+1));
      99           0 :     return 0x0;
     100             :   }
     101           0 : }
     102             : 
     103             : //_____________________________________________________________________________
     104             : AliMUONVTrackerData* 
     105             : AliMUONPainterDataRegistry::DataSource(Int_t i) const
     106             : {
     107             :   /// Get one data source
     108             :   
     109           0 :   AliMUONVTrackerDataMaker* maker = DataMaker(i);
     110           0 :   if ( maker ) return maker->Data();
     111           0 :   return 0x0;
     112           0 : }
     113             : 
     114             : //_____________________________________________________________________________
     115             : void 
     116             : AliMUONPainterDataRegistry::DataMakerWasRegistered(const AliMUONVTrackerDataMaker* data)
     117             : {
     118             :   /// A new reader source was registered
     119           0 :   Long_t param[] = { (Long_t)data };
     120             :   
     121           0 :   Emit("DataMakerWasRegistered(AliMUONVTrackerDataMaker*)",param);
     122           0 : }
     123             : 
     124             : //_____________________________________________________________________________
     125             : void
     126             : AliMUONPainterDataRegistry::DataMakerWasUnregistered(const AliMUONVTrackerDataMaker* data)
     127             : {
     128             :   /// A data reader was unregistered
     129           0 :   Long_t param[] = { (Long_t)data };
     130             :   
     131           0 :   Emit("DataMakerWasUnregistered(AliMUONVTrackerDataMaker*)",param);
     132             :   
     133           0 : }
     134             : 
     135             : //_____________________________________________________________________________
     136             : void 
     137             : AliMUONPainterDataRegistry::DataSourceWasRegistered(const AliMUONVTrackerData* data)
     138             : {
     139             :   /// A new data source was registered
     140           0 :   Long_t param[] = { (Long_t)data };
     141             :   
     142           0 :   Emit("DataSourceWasRegistered(AliMUONVTrackerData*)",param);
     143           0 : }
     144             : 
     145             : //_____________________________________________________________________________
     146             : void
     147             : AliMUONPainterDataRegistry::DataSourceWasUnregistered(const AliMUONVTrackerData* data)
     148             : {
     149             :   /// A data source was unregistered
     150           0 :   Long_t param[] = { (Long_t)data };
     151             :   
     152           0 :   Emit("DataSourceWasUnregistered(AliMUONVTrackerData*)",param);
     153             :   
     154           0 : }
     155             : 
     156             : //_____________________________________________________________________________
     157             : AliMUONVTrackerData*
     158             : AliMUONPainterDataRegistry::DataSource(const char* name) const
     159             : {
     160             :   /// Find a data source by name
     161           0 :   for ( Int_t i = 0; i < NumberOfDataMakers(); ++i )
     162             :   {
     163           0 :     AliMUONVTrackerData* data = DataMaker(i)->Data();
     164           0 :     if ( data ) 
     165             :     {
     166           0 :       TString dname(data->GetName());
     167           0 :       if ( dname == name ) return data;
     168           0 :     }
     169           0 :   }
     170           0 :   return 0x0;
     171           0 : }
     172             : 
     173             : //_____________________________________________________________________________
     174             : AliMUONPainterDataRegistry*
     175             : AliMUONPainterDataRegistry::Instance()
     176             : {
     177             :   /// Get unique instance of this class
     178           0 :   if ( !fgInstance ) fgInstance = new AliMUONPainterDataRegistry;
     179           0 :   return fgInstance;
     180           0 : }
     181             : 
     182             : //_____________________________________________________________________________
     183             : AliMUONVTrackerData*
     184             : AliMUONPainterDataRegistry::InteractiveReadOutConfig() const
     185             : {
     186             :   /// Return an object that contains the parts of the detector selected
     187             :   /// (using the mouse) to be part of the readout.
     188             : 
     189           0 :   if (!fInteractiveReadOutConfig) CreateInteractiveReadOutConfig();
     190           0 :   return fInteractiveReadOutConfig;
     191             : }
     192             : 
     193             : //_____________________________________________________________________________
     194             : void 
     195             : AliMUONPainterDataRegistry::Print(Option_t* opt) const
     196             : {
     197             :   /// Printout
     198           0 :   TString sopt(opt);
     199           0 :   sopt.ToUpper();
     200             :   
     201           0 :   cout << "Number of data readers = " << NumberOfDataMakers() << endl;
     202             :   
     203           0 :   if ( sopt.Contains("FULL") || sopt.Contains("READER") || sopt.Contains("DATA") )
     204             :   {
     205           0 :     TIter next(fDataMakers);
     206             :     AliMUONVTrackerDataMaker* reader;
     207             :     
     208           0 :     while ( ( reader = static_cast<AliMUONVTrackerDataMaker*>(next()) ) )
     209             :     {
     210           0 :       if ( sopt.Contains("DATA") ) 
     211             :       {
     212           0 :         AliMUONVTrackerData* data = reader->Data();
     213           0 :         if ( data ) data->Print();
     214           0 :       }
     215             :       else
     216             :       {
     217           0 :         reader->Print();
     218             :       }
     219             :     }
     220           0 :   }
     221           0 : }
     222             : 
     223             : //_____________________________________________________________________________
     224             : void
     225             : AliMUONPainterDataRegistry::Register(AliMUONVTrackerDataMaker* reader)
     226             : {
     227             :   /// reader is adopted, i.e. the registry becomes the owner of it.
     228           0 :   fDataMakers->AddLast(reader);
     229           0 :   DataMakerWasRegistered(reader);
     230           0 :   if ( reader->Data() ) DataSourceWasRegistered(reader->Data());
     231           0 : }
     232             : 
     233             : //_____________________________________________________________________________
     234             : Int_t 
     235             : AliMUONPainterDataRegistry::NumberOfDataMakers() const
     236             : {
     237             :   /// The number of data readers we handle
     238           0 :   return fDataMakers->GetLast()+1;
     239             : }
     240             : 
     241             : //_____________________________________________________________________________
     242             : void 
     243             : AliMUONPainterDataRegistry::DeleteZombies()
     244             : {
     245             :   /// Delete zombies
     246           0 :   fZombies->Delete();
     247           0 : }
     248             : 
     249             : //_____________________________________________________________________________
     250             : Bool_t 
     251             : AliMUONPainterDataRegistry::Unregister(AliMUONVTrackerDataMaker* reader)
     252             : {
     253             :   /// Unregister some reader
     254             :   
     255           0 :   if (!reader) return kFALSE;
     256             :   
     257           0 :   if ( reader->Data() ) 
     258             :   {
     259           0 :     DataSourceWasUnregistered(reader->Data());
     260           0 :     reader->Data()->Destroyed(); // we pretend it's deleted now, even
     261             :     // if it will be only later on when zombie are killed, so that
     262             :     // for instance painters depending on it will no longer try to access it
     263           0 :   }
     264             : 
     265           0 :   DataMakerWasUnregistered(reader);
     266             :   
     267           0 :   TObject* o = fDataMakers->Remove(reader);
     268             :   
     269           0 :   fZombies->Add(o); // for later deletion
     270             :   
     271             : //  if ( o ) 
     272             : //  {
     273             : //    delete o;
     274             : //  }
     275             : //  else
     276             : //  {
     277             : //    AliError(Form("Could not unregister data named %s title %s",reader->GetName(),
     278             : //                  reader->GetTitle()));
     279             : //  }
     280           0 :   return ( o != 0x0 );
     281           0 : }

Generated by: LCOV version 1.11