]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONVDigitStore.cxx
No more misaligned_geometry
[u/mrichter/AliRoot.git] / MUON / AliMUONVDigitStore.cxx
CommitLineData
8c740498 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"
2ed392cf 31#include <TClass.h>
8c740498 32#include <TString.h>
33#include <TTree.h>
34
35/// \cond CLASSIMP
36ClassImp(AliMUONVDigitStore)
37/// \endcond
38
39//_____________________________________________________________________________
40AliMUONVDigitStore::AliMUONVDigitStore()
41{
42 /// ctor
43}
44
45//_____________________________________________________________________________
46AliMUONVDigitStore::~AliMUONVDigitStore()
47{
48 /// dtor
49}
50
51//_____________________________________________________________________________
52Bool_t
53AliMUONVDigitStore::Add(TObject* object)
54{
55 /// Add an object, if it is of type AliMUONVDigit
56 if (object)
57 {
58 AliMUONVDigit* digit = dynamic_cast<AliMUONVDigit*>(object);
59 if (digit)
60 {
61 AliMUONVDigit* added = Add(*digit,AliMUONVDigitStore::kIgnore);
62 if (!added)
63 {
64 AliError("Could not add digit through Add(TObject*) method");
65 }
66 else
67 {
68 return kTRUE;
69 }
70 }
71 }
72 return kFALSE;
73}
74
75//_____________________________________________________________________________
76AliMUONVDigit*
77AliMUONVDigitStore::Add(Int_t detElemId,
78 Int_t manuId,
79 Int_t manuChannel,
80 Int_t cathode,
81 EReplacePolicy replace)
82{
83 /// Add a digit and return it
84 AliMUONVDigit* digit = CreateDigit(detElemId,manuId,manuChannel,cathode);
85 if (digit)
86 {
87 AliMUONVDigit* d = Add(*digit,replace);
88 delete digit;
89 return d;
90 }
91 return 0x0;
92}
93
2ed392cf 94//____________________________________________________________________________
95AliMUONVDigitStore*
96AliMUONVDigitStore::Create(const char* digitstoreclassname)
97{
22dce0e3 98 /// Create a concrete digitStore, given its classname
99
2ed392cf 100 TClass* classPtr = TClass::GetClass(digitstoreclassname);
101 if (!classPtr)
102 {
103 return 0x0;
104 }
105
106 AliMUONVDigitStore* digitStore =
107 reinterpret_cast<AliMUONVDigitStore*>(classPtr->New());
108
109 return digitStore;
110}
111
8c740498 112//_____________________________________________________________________________
113AliMUONVDigitStore*
114AliMUONVDigitStore::Create(TTree& tree)
115{
116 /// Create store from the given tree (if possible).
117 TString dataType = ( strcmp(tree.GetName(),"TreeD") == 0 ? "Digit" :
118 (strcmp(tree.GetName(),"TreeS")== 9 ? "SDigit" : "")
119 );
120 return static_cast<AliMUONVDigitStore*>(AliMUONVStore::Create(tree,dataType.Data()));
121}
122
2ed392cf 123//_____________________________________________________________________________
124AliMUONVDigit*
125AliMUONVDigitStore::FindObject(const TObject* object) const
126{
22dce0e3 127 /// Find an object, if of AliMUONVDigit type.
2ed392cf 128 const AliMUONVDigit* digit = dynamic_cast<const AliMUONVDigit*>(object);
129 if (digit)
130 {
131 return FindObject(digit->GetUniqueID());
132 }
133 return 0x0;
134}
135
136//_____________________________________________________________________________
137AliMUONVDigit*
138AliMUONVDigitStore::FindObject(UInt_t uniqueID) const
139{
140 /// Find digit by its uniqueID
141
142 return FindObject(AliMUONVDigit::DetElemId(uniqueID),
143 AliMUONVDigit::ManuId(uniqueID),
144 AliMUONVDigit::ManuChannel(uniqueID),
145 AliMUONVDigit::Cathode(uniqueID));
146}
147
8c740498 148//_____________________________________________________________________________
149Int_t
150AliMUONVDigitStore::GetSize(Int_t detElemId, Int_t cathode) const
151{
152 /// Return the number of digits we have for a given detection element
153 TIter next(CreateIterator(detElemId,detElemId,cathode));
154 AliMUONVDigit* digit;
155 Int_t n(0);
156 while ( ( digit = static_cast<AliMUONVDigit*>(next()) ) )
157 {
158 ++n;
159 }
160 return n;
161}
162