LCOV - code coverage report
Current view: top level - MUON/MUONbase - AliMUONVDigitStore.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 18 45 40.0 %
Date: 2016-06-14 17:26:59 Functions: 6 12 50.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 AliMUONVDigitStore
      20             : ///
      21             : /// Interface for a digit (or sdigit) container
      22             : ///
      23             : /// It offers methods to Add, Find and Remove single elements, and
      24             : /// can create iterators to loop over (part of) the elements.
      25             : ///
      26             : /// \author Laurent Aphecetche, Subatech
      27             : //-----------------------------------------------------------------------------
      28             : 
      29             : #include "AliMUONVDigitStore.h"
      30             : 
      31             : #include "AliLog.h"
      32             : #include "AliMUONVDigit.h"
      33             : #include <TClass.h>
      34             : #include <TString.h>
      35             : #include <TTree.h>
      36             : 
      37             : /// \cond CLASSIMP
      38          18 : ClassImp(AliMUONVDigitStore)
      39             : /// \endcond
      40             : 
      41             : //_____________________________________________________________________________
      42          22 : AliMUONVDigitStore::AliMUONVDigitStore()
      43          66 : {
      44             :   /// ctor
      45          22 : }
      46             : 
      47             : //_____________________________________________________________________________
      48             : AliMUONVDigitStore::~AliMUONVDigitStore()
      49           0 : {
      50             :   /// dtor
      51          44 : }
      52             : 
      53             : //_____________________________________________________________________________
      54             : Bool_t 
      55             : AliMUONVDigitStore::Add(TObject* object)
      56             : {
      57             :   /// Add an object, if it is of type AliMUONVDigit
      58           0 :   if (object)
      59             :   {
      60           0 :     AliMUONVDigit* digit = dynamic_cast<AliMUONVDigit*>(object);
      61           0 :     if (digit)
      62             :     {
      63           0 :       AliMUONVDigit* added = Add(*digit,AliMUONVDigitStore::kIgnore);
      64           0 :       if (!added)
      65             :       {
      66           0 :         AliError("Could not add digit through Add(TObject*) method");
      67             :       }
      68             :       else
      69             :       {
      70           0 :         return kTRUE;
      71             :       }
      72           0 :     }
      73           0 :   }
      74           0 :   return kFALSE;
      75           0 : }
      76             : 
      77             : //_____________________________________________________________________________
      78             : AliMUONVDigit* 
      79             : AliMUONVDigitStore::Add(Int_t detElemId, 
      80             :                        Int_t manuId,
      81             :                        Int_t manuChannel,
      82             :                        Int_t cathode,
      83             :                        EReplacePolicy replace)
      84             : {
      85             :   /// Add a digit and return it
      86      486394 :   AliMUONVDigit* digit = CreateDigit(detElemId,manuId,manuChannel,cathode);
      87      243197 :   if (digit)
      88             :   {
      89      243197 :     AliMUONVDigit* d = Add(*digit,replace);
      90      486394 :     delete digit;
      91             :     return d;
      92             :   }
      93           0 :   return 0x0;
      94      243197 : }
      95             : 
      96             : //____________________________________________________________________________
      97             : AliMUONVDigitStore* 
      98             : AliMUONVDigitStore::Create(const char* digitstoreclassname)
      99             : {
     100             :   /// Create a concrete digitStore, given its classname
     101             :   
     102           4 :   TClass* classPtr = TClass::GetClass(digitstoreclassname);
     103           4 :   if (!classPtr || !classPtr->InheritsFrom("AliMUONVDigitStore"))
     104             :   {
     105           0 :     return 0x0;
     106             :   }
     107             :   
     108             :   AliMUONVDigitStore* digitStore = 
     109           2 :     reinterpret_cast<AliMUONVDigitStore*>(classPtr->New());
     110             :   
     111             :   return digitStore;
     112           2 : }
     113             : 
     114             : //_____________________________________________________________________________
     115             : AliMUONVDigitStore*
     116             : AliMUONVDigitStore::Create(TTree& tree)
     117             : {
     118             :   /// Create store from the given tree (if possible).
     119          19 :   TString dataType = ( strcmp(tree.GetName(),"TreeD") == 0 ? "Digit" : 
     120           1 :                        (strcmp(tree.GetName(),"TreeS")== 9 ? "SDigit" : "")
     121             :                        );
     122          18 :   return static_cast<AliMUONVDigitStore*>(AliMUONVStore::Create(tree,dataType.Data()));
     123           6 : }
     124             : 
     125             : //_____________________________________________________________________________
     126             : AliMUONVDigit* 
     127             : AliMUONVDigitStore::FindObject(const TObject* object) const
     128             : {
     129             :   /// Find an object, if of AliMUONVDigit type.
     130           0 :   const AliMUONVDigit* digit = dynamic_cast<const AliMUONVDigit*>(object);
     131           0 :   if (digit)
     132             :   {
     133           0 :     return FindObject(digit->GetUniqueID());
     134             :   }
     135           0 :   return 0x0;
     136           0 : }
     137             : 
     138             : //_____________________________________________________________________________
     139             : AliMUONVDigit* 
     140             : AliMUONVDigitStore::FindObject(UInt_t uniqueID) const
     141             : {
     142             :   /// Find digit by its uniqueID
     143             :   
     144           0 :   return FindObject(AliMUONVDigit::DetElemId(uniqueID),
     145           0 :                     AliMUONVDigit::ManuId(uniqueID),
     146           0 :                     AliMUONVDigit::ManuChannel(uniqueID),
     147           0 :                     AliMUONVDigit::Cathode(uniqueID));
     148             : }
     149             : 
     150             : //_____________________________________________________________________________
     151             : Int_t 
     152             : AliMUONVDigitStore::GetSize(Int_t detElemId, Int_t cathode) const
     153             : {
     154             :   /// Return the number of digits we have for a given detection element
     155           0 :   TIter next(CreateIterator(detElemId,detElemId,cathode));
     156             :   Int_t n(0);
     157           0 :   while ( ( next() ) )
     158             :   {
     159           0 :     ++n;
     160             :   }
     161             :   return n;
     162           0 : }
     163             : 

Generated by: LCOV version 1.11