]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONVDigitStore.cxx
Managed the 234 local boards inside the class & simplified the code
[u/mrichter/AliRoot.git] / MUON / AliMUONVDigitStore.cxx
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 /// \class AliMUONVDigitStore
19 ///
20 /// Interface for a digit (or sdigit) container
21 ///
22 /// It offers methods to Add, Find and Remove single elements, and
23 /// can create iterators to loop over (part of) the elements.
24 ///
25 /// \author Laurent Aphecetche, Subatech
26
27 #include "AliMUONVDigitStore.h"
28
29 #include "AliLog.h"
30 #include "AliMUONVDigit.h"
31 #include <TString.h>
32 #include <TTree.h>
33
34 /// \cond CLASSIMP
35 ClassImp(AliMUONVDigitStore)
36 /// \endcond
37
38 //_____________________________________________________________________________
39 AliMUONVDigitStore::AliMUONVDigitStore()
40 {
41   /// ctor
42 }
43
44 //_____________________________________________________________________________
45 AliMUONVDigitStore::~AliMUONVDigitStore()
46 {
47   /// dtor
48 }
49
50 //_____________________________________________________________________________
51 Bool_t 
52 AliMUONVDigitStore::Add(TObject* object)
53 {
54   /// Add an object, if it is of type AliMUONVDigit
55   if (object)
56   {
57     AliMUONVDigit* digit = dynamic_cast<AliMUONVDigit*>(object);
58     if (digit)
59     {
60       AliMUONVDigit* added = Add(*digit,AliMUONVDigitStore::kIgnore);
61       if (!added)
62       {
63         AliError("Could not add digit through Add(TObject*) method");
64       }
65       else
66       {
67         return kTRUE;
68       }
69     }
70   }
71   return kFALSE;
72 }
73
74 //_____________________________________________________________________________
75 AliMUONVDigit* 
76 AliMUONVDigitStore::Add(Int_t detElemId, 
77                        Int_t manuId,
78                        Int_t manuChannel,
79                        Int_t cathode,
80                        EReplacePolicy replace)
81 {
82   /// Add a digit and return it
83   AliMUONVDigit* digit = CreateDigit(detElemId,manuId,manuChannel,cathode);
84   if (digit)
85   {
86     AliMUONVDigit* d = Add(*digit,replace);
87     delete digit;
88     return d;
89   }
90   return 0x0;
91 }
92
93 //_____________________________________________________________________________
94 AliMUONVDigitStore*
95 AliMUONVDigitStore::Create(TTree& tree)
96 {
97   /// Create store from the given tree (if possible).
98   TString dataType = ( strcmp(tree.GetName(),"TreeD") == 0 ? "Digit" : 
99                        (strcmp(tree.GetName(),"TreeS")== 9 ? "SDigit" : "")
100                        );
101   return static_cast<AliMUONVDigitStore*>(AliMUONVStore::Create(tree,dataType.Data()));
102 }
103
104 //_____________________________________________________________________________
105 Int_t 
106 AliMUONVDigitStore::GetSize(Int_t detElemId, Int_t cathode) const
107 {
108   /// Return the number of digits we have for a given detection element
109   TIter next(CreateIterator(detElemId,detElemId,cathode));
110   AliMUONVDigit* digit;
111   Int_t n(0);
112   while ( ( digit = static_cast<AliMUONVDigit*>(next()) ) )
113   {
114     ++n;
115   }
116   return n;
117 }
118