AliRoot Core  edcc906 (edcc906)
AliMUONVDigitStore.cxx
Go to the documentation of this file.
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 //-----------------------------------------------------------------------------
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 
38 ClassImp(AliMUONVDigitStore)
40 
41 //_____________________________________________________________________________
43 {
45 }
46 
47 //_____________________________________________________________________________
49 {
51 }
52 
53 //_____________________________________________________________________________
54 Bool_t
55 AliMUONVDigitStore::Add(TObject* object)
56 {
58  if (object)
59  {
60  AliMUONVDigit* digit = dynamic_cast<AliMUONVDigit*>(object);
61  if (digit)
62  {
64  if (!added)
65  {
66  AliError("Could not add digit through Add(TObject*) method");
67  }
68  else
69  {
70  return kTRUE;
71  }
72  }
73  }
74  return kFALSE;
75 }
76 
77 //_____________________________________________________________________________
79 AliMUONVDigitStore::Add(Int_t detElemId,
80  Int_t manuId,
81  Int_t manuChannel,
82  Int_t cathode,
83  EReplacePolicy replace)
84 {
86  AliMUONVDigit* digit = CreateDigit(detElemId,manuId,manuChannel,cathode);
87  if (digit)
88  {
89  AliMUONVDigit* d = Add(*digit,replace);
90  delete digit;
91  return d;
92  }
93  return 0x0;
94 }
95 
96 //____________________________________________________________________________
98 AliMUONVDigitStore::Create(const char* digitstoreclassname)
99 {
101 
102  TClass* classPtr = TClass::GetClass(digitstoreclassname);
103  if (!classPtr || !classPtr->InheritsFrom("AliMUONVDigitStore"))
104  {
105  return 0x0;
106  }
107 
108  AliMUONVDigitStore* digitStore =
109  reinterpret_cast<AliMUONVDigitStore*>(classPtr->New());
110 
111  return digitStore;
112 }
113 
114 //_____________________________________________________________________________
117 {
119  TString dataType = ( strcmp(tree.GetName(),"TreeD") == 0 ? "Digit" :
120  (strcmp(tree.GetName(),"TreeS")== 9 ? "SDigit" : "")
121  );
122  return static_cast<AliMUONVDigitStore*>(AliMUONVStore::Create(tree,dataType.Data()));
123 }
124 
125 //_____________________________________________________________________________
127 AliMUONVDigitStore::FindObject(const TObject* object) const
128 {
130  const AliMUONVDigit* digit = dynamic_cast<const AliMUONVDigit*>(object);
131  if (digit)
132  {
133  return FindObject(digit->GetUniqueID());
134  }
135  return 0x0;
136 }
137 
138 //_____________________________________________________________________________
140 AliMUONVDigitStore::FindObject(UInt_t uniqueID) const
141 {
143 
144  return FindObject(AliMUONVDigit::DetElemId(uniqueID),
145  AliMUONVDigit::ManuId(uniqueID),
146  AliMUONVDigit::ManuChannel(uniqueID),
147  AliMUONVDigit::Cathode(uniqueID));
148 }
149 
150 //_____________________________________________________________________________
151 Int_t
152 AliMUONVDigitStore::GetSize(Int_t detElemId, Int_t cathode) const
153 {
155  TIter next(CreateIterator(detElemId,detElemId,cathode));
156  Int_t n(0);
157  while ( ( next() ) )
158  {
159  ++n;
160  }
161  return n;
162 }
163 
virtual Int_t ManuChannel() const =0
The channel within ManuId() this digit belongs to (manuChannel for tracker, localBoardChannel for tri...
Interface for a digit container.
TTree * tree
virtual Int_t DetElemId() const =0
The detection element this digit belongs to.
virtual TIterator * CreateIterator() const =0
Create an iterator to loop over all our digits.
virtual Int_t GetSize() const =0
Number of digits we store.
virtual AliMUONVDigitStore * Create() const =0
Create an (empty) object of the same concrete class as *this.
virtual AliMUONVStore * Create() const =0
Create an empty copy of this.
virtual Int_t Cathode() const =0
Cathode number this digit is on (0 or 1)
virtual Int_t ManuId() const =0
The electronic card id this digit belongs to (manuId for tracker, localboardId for trigger) ...
ABC of a MUON digit.
Definition: AliMUONVDigit.h:18
#define AliError(message)
Definition: AliLog.h:591
virtual AliMUONVDigit * FindObject(const TObject *object) const
Find an object (default is to forward to FindObject(object->GetUniqueID())
virtual AliMUONVDigit * CreateDigit(Int_t detElemId, Int_t manuId, Int_t manuChannel, Int_t cathode) const =0
Create a digit.
EReplacePolicy
Replacement policy : what to do when adding a digit to the store.
virtual Bool_t Add(TObject *object)
Add an object, if it is of the right class.