LCOV - code coverage report
Current view: top level - MUON/MUONrec - AliMUONClusterStoreV1.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 88 1.1 %
Date: 2016-06-14 17:26:59 Functions: 1 20 5.0 %

          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             : //-----------------------------------------------------------------------------
      19             : /// \class AliMUONClusterStoreV1
      20             : ///
      21             : /// Implementation of VClusterStore.
      22             : ///
      23             : /// This one is a basic implementation, let's say "legacy" one, i.e.
      24             : /// compatible with what we stored in MUON.RecPoints.root files before
      25             : /// the switch to data stores.
      26             : ///
      27             : /// \author Laurent Aphecetche, Subatech
      28             : ///
      29             : //-----------------------------------------------------------------------------
      30             : 
      31             : #include "AliMUONClusterStoreV1.h"
      32             : 
      33             : #include "AliLog.h"
      34             : #include "AliMUONRawCluster.h"
      35             : #include "AliMUONTOTCAStoreIterator.h"
      36             : #include "AliMUONTreeManager.h"
      37             : #include "AliMpConstants.h"
      38             : #include "AliMpDEManager.h"
      39             : #include <TClonesArray.h>
      40             : #include <TObjArray.h>
      41             : #include <TTree.h>
      42             : 
      43             : /// \cond CLASSIMP
      44          18 : ClassImp(AliMUONClusterStoreV1)
      45             : /// \endcond
      46             : 
      47             : //_____________________________________________________________________________
      48             : AliMUONClusterStoreV1::AliMUONClusterStoreV1() 
      49           0 : : AliMUONVClusterStore(), 
      50           0 : fClusters(new TObjArray(AliMpConstants::NofChambers()))
      51           0 : {
      52             :   /// ctor. Set correct ownerships
      53           0 :   fClusters->SetOwner(kTRUE);
      54           0 :   for ( Int_t i = 0; i < fClusters->GetSize(); ++i )
      55             :   {
      56           0 :     TClonesArray* tca = new TClonesArray("AliMUONRawCluster",100);
      57           0 :     fClusters->AddAt(tca,i);
      58             :   }
      59           0 :   AliDebug(1,"");
      60           0 : }
      61             : 
      62             : //_____________________________________________________________________________
      63             : AliMUONClusterStoreV1::AliMUONClusterStoreV1(const AliMUONClusterStoreV1&)
      64           0 : : AliMUONVClusterStore(), 
      65           0 : fClusters(0x0)
      66           0 : {
      67             :   /// copy ctor
      68           0 :   AliError("Please implement me");
      69           0 : }
      70             : 
      71             : //_____________________________________________________________________________
      72             : AliMUONClusterStoreV1& 
      73             : AliMUONClusterStoreV1::operator=(const AliMUONClusterStoreV1&)
      74             : {
      75             :   /// assignment operator
      76           0 :   AliError("Please implement me");
      77           0 :   return *this;
      78             : }
      79             : 
      80             : //_____________________________________________________________________________
      81             : AliMUONClusterStoreV1::~AliMUONClusterStoreV1()
      82           0 : {
      83             :   /// dtor
      84           0 :   AliDebug(1,"");
      85           0 :   delete fClusters;
      86           0 : }
      87             : 
      88             : //_____________________________________________________________________________
      89             : AliMUONVCluster* AliMUONClusterStoreV1::CreateCluster(Int_t /*chamberId*/, Int_t detElemId, Int_t /*clusterIndex*/) const
      90             : {
      91             :   /// Create a cluster
      92           0 :   AliMUONVCluster* vCluster = new AliMUONRawCluster();
      93           0 :   (static_cast<AliMUONRawCluster*> (vCluster))->SetDetElemId(detElemId);
      94           0 :   return vCluster;
      95           0 : }
      96             : 
      97             : //_____________________________________________________________________________
      98             : AliMUONVCluster* 
      99             : AliMUONClusterStoreV1::Add(const AliMUONVCluster& vCluster)
     100             : {
     101             :   /// Add a cluster to this store
     102           0 :   const AliMUONRawCluster* cluster = dynamic_cast<const AliMUONRawCluster*>(&vCluster);
     103             :   
     104           0 :   if (!cluster)
     105             :   {
     106           0 :     AliError(Form("Cluster is not of the expected type (%s vs AliMUONRawCluster)",
     107             :                   vCluster.ClassName()));
     108           0 :     return 0x0;
     109             :   }
     110             :   
     111           0 :   Int_t iChamber = AliMpDEManager::GetChamberId(cluster->GetDetElemId());
     112           0 :   TClonesArray* array = ChamberClusters(iChamber);
     113           0 :   if (!array) 
     114             :   {
     115           0 :     return 0x0;
     116             :   }
     117             :   
     118           0 :   return new((*array)[array->GetLast()+1]) AliMUONRawCluster(*cluster);
     119           0 : }
     120             : 
     121             : //_____________________________________________________________________________
     122             : AliMUONVCluster* AliMUONClusterStoreV1::Add(Int_t chamberId, Int_t detElemId, Int_t /*clusterIndex*/)
     123             : {
     124             :   /// Add a cluster to this store
     125           0 :   TClonesArray* array = ChamberClusters(chamberId);
     126           0 :   if (!array) return 0x0;
     127             :   
     128           0 :   AliMUONVCluster* vCluster = static_cast<AliMUONVCluster*> (new((*array)[array->GetLast()+1]) AliMUONRawCluster());
     129           0 :   (static_cast<AliMUONRawCluster*> (vCluster))->SetDetElemId(detElemId);
     130             :   return vCluster;
     131           0 : }
     132             : 
     133             : //_____________________________________________________________________________
     134             : TClonesArray*
     135             : AliMUONClusterStoreV1::ChamberClusters(Int_t chamberId) const
     136             : {
     137             :   /// Get the internal array of clusters for a given chamber
     138           0 :   TClonesArray* array = static_cast<TClonesArray*>(fClusters->At(chamberId));
     139           0 :   if (!array) 
     140             :   {
     141           0 :     AliError(Form("Cannot get Clusters for chamberId=%d",chamberId));
     142           0 :     return 0x0;
     143             :   }
     144           0 :   return array;
     145           0 : }
     146             : 
     147             : //_____________________________________________________________________________
     148             : TObject**
     149             : AliMUONClusterStoreV1::ChamberClustersPtr(Int_t chamberId) const
     150             : {
     151             :   /// Get the internal array of clusters for a given chamber
     152           0 :   TClonesArray* array = static_cast<TClonesArray*>(fClusters->At(chamberId));
     153           0 :   if (!array) 
     154             :   {
     155           0 :     AliError(Form("Cannot get Clusters for chamberId=%d",chamberId));
     156           0 :     return 0x0;
     157             :   }
     158           0 :   return fClusters->GetObjectRef(array);
     159           0 : }
     160             : 
     161             : //_____________________________________________________________________________
     162             : Bool_t
     163             : AliMUONClusterStoreV1::Connect(TTree& tree, Bool_t alone) const
     164             : {
     165             :   /// Connect this to the tree, i.e. make the branches or set their addresses.
     166             :   
     167           0 :   AliMUONTreeManager tman;
     168             :   Bool_t ok(kTRUE);
     169             :   
     170           0 :   TBranch* b = tree.GetBranch("MUONRawClusters1");
     171             :   
     172           0 :   Bool_t isMaking = (b == 0);
     173             :   
     174           0 :   if ( isMaking ) 
     175             :   {
     176           0 :     for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i ) 
     177             :     {
     178           0 :       TString branchName(Form("MUONRawClusters%d",i+1));
     179           0 :       ok = ok && tman.MakeBranch(tree,ClassName(),"TClonesArray",
     180           0 :                                  branchName.Data(),ChamberClustersPtr(i));
     181           0 :     }
     182             :     
     183           0 :   }
     184             :   else
     185             :   {
     186           0 :     if (alone) tman.UpdateBranchStatuses(tree,"MUONRawClusters");
     187           0 :     for ( Int_t i = 0; i < AliMpConstants::NofTrackingChambers(); ++i ) 
     188             :     {
     189           0 :       TString branchName(Form("MUONRawClusters%d",i+1));
     190           0 :       ok = ok && tman.SetAddress(tree,branchName.Data(),
     191           0 :                                    ChamberClustersPtr(i));
     192           0 :     }
     193             :   }
     194           0 :   return ok;
     195           0 : }
     196             : 
     197             : //_____________________________________________________________________________
     198             : AliMUONVCluster*
     199             : AliMUONClusterStoreV1::Remove(AliMUONVCluster& cluster)
     200             : {
     201             :   /// Remove a cluster
     202           0 :   Int_t iChamber = AliMpDEManager::GetChamberId(cluster.GetDetElemId());
     203           0 :   TClonesArray* array = ChamberClusters(iChamber);
     204           0 :   TObject* o = array->Remove(&cluster);
     205           0 :   if (o)
     206             :   {
     207           0 :     array->Compress();
     208           0 :   }
     209           0 :   return static_cast<AliMUONVCluster*>(o);
     210             : }
     211             : 
     212             : //_____________________________________________________________________________
     213             : void
     214             : AliMUONClusterStoreV1::Clear(Option_t*)
     215             : {
     216             :   /// Reset internal arrays
     217           0 :   AliDebug(1,"");
     218             :   /// Reset the tclonesarray, but keep the tobjarray's size constant.
     219           0 :   for ( Int_t i = 0; i < fClusters->GetSize(); ++i ) 
     220             :   {
     221           0 :     ChamberClusters(i)->Clear("C");
     222             :   }
     223           0 : }
     224             : 
     225             : //_____________________________________________________________________________
     226             : TIterator* 
     227             : AliMUONClusterStoreV1::CreateIterator() const
     228             : {
     229             :   /// Return an iterator to loop over our clusters
     230           0 :   return new AliMUONTOTCAStoreIterator(fClusters,0,AliMpConstants::NofTrackingChambers()-1);
     231           0 : }
     232             : 
     233             : //_____________________________________________________________________________
     234             : TIterator* 
     235             : AliMUONClusterStoreV1::CreateChamberIterator(Int_t firstChamber, Int_t lastChamber) const
     236             : {
     237             :   /// Return an iterator to loop over our clusters
     238           0 :   return new AliMUONTOTCAStoreIterator(fClusters,firstChamber,lastChamber);
     239           0 : }
     240             : 
     241             : //_____________________________________________________________________________
     242             : Int_t
     243             : AliMUONClusterStoreV1::GetSize() const
     244             : {
     245             :   /// Return the number of clusters we hold
     246             :   Int_t n(0);
     247           0 :   for ( Int_t i = 0; i < fClusters->GetSize(); ++i ) 
     248             :   {
     249           0 :     n += ChamberClusters(i)->GetLast()+1;
     250             :   }
     251           0 :   return n;
     252             : }
     253             : 

Generated by: LCOV version 1.11