]>
Commit | Line | Data |
---|---|---|
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 | ||
3d1463c8 | 18 | //----------------------------------------------------------------------------- |
8c740498 | 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 | |
3d1463c8 | 27 | //----------------------------------------------------------------------------- |
8c740498 | 28 | |
29 | #include "AliMUONVDigitStore.h" | |
30 | ||
31 | #include "AliLog.h" | |
32 | #include "AliMUONVDigit.h" | |
2ed392cf | 33 | #include <TClass.h> |
8c740498 | 34 | #include <TString.h> |
35 | #include <TTree.h> | |
36 | ||
37 | /// \cond CLASSIMP | |
38 | ClassImp(AliMUONVDigitStore) | |
39 | /// \endcond | |
40 | ||
41 | //_____________________________________________________________________________ | |
42 | AliMUONVDigitStore::AliMUONVDigitStore() | |
43 | { | |
44 | /// ctor | |
45 | } | |
46 | ||
47 | //_____________________________________________________________________________ | |
48 | AliMUONVDigitStore::~AliMUONVDigitStore() | |
49 | { | |
50 | /// dtor | |
51 | } | |
52 | ||
53 | //_____________________________________________________________________________ | |
54 | Bool_t | |
55 | AliMUONVDigitStore::Add(TObject* object) | |
56 | { | |
57 | /// Add an object, if it is of type AliMUONVDigit | |
58 | if (object) | |
59 | { | |
60 | AliMUONVDigit* digit = dynamic_cast<AliMUONVDigit*>(object); | |
61 | if (digit) | |
62 | { | |
63 | AliMUONVDigit* added = Add(*digit,AliMUONVDigitStore::kIgnore); | |
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 | //_____________________________________________________________________________ | |
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 | 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 | ||
2ed392cf | 96 | //____________________________________________________________________________ |
97 | AliMUONVDigitStore* | |
98 | AliMUONVDigitStore::Create(const char* digitstoreclassname) | |
99 | { | |
22dce0e3 | 100 | /// Create a concrete digitStore, given its classname |
101 | ||
2ed392cf | 102 | TClass* classPtr = TClass::GetClass(digitstoreclassname); |
7332f213 | 103 | if (!classPtr || !classPtr->InheritsFrom("AliMUONVDigitStore")) |
2ed392cf | 104 | { |
105 | return 0x0; | |
106 | } | |
107 | ||
108 | AliMUONVDigitStore* digitStore = | |
109 | reinterpret_cast<AliMUONVDigitStore*>(classPtr->New()); | |
110 | ||
111 | return digitStore; | |
112 | } | |
113 | ||
8c740498 | 114 | //_____________________________________________________________________________ |
115 | AliMUONVDigitStore* | |
116 | AliMUONVDigitStore::Create(TTree& tree) | |
117 | { | |
118 | /// Create store from the given tree (if possible). | |
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 | ||
2ed392cf | 125 | //_____________________________________________________________________________ |
126 | AliMUONVDigit* | |
127 | AliMUONVDigitStore::FindObject(const TObject* object) const | |
128 | { | |
22dce0e3 | 129 | /// Find an object, if of AliMUONVDigit type. |
2ed392cf | 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 | //_____________________________________________________________________________ | |
139 | AliMUONVDigit* | |
140 | AliMUONVDigitStore::FindObject(UInt_t uniqueID) const | |
141 | { | |
142 | /// Find digit by its uniqueID | |
143 | ||
144 | return FindObject(AliMUONVDigit::DetElemId(uniqueID), | |
145 | AliMUONVDigit::ManuId(uniqueID), | |
146 | AliMUONVDigit::ManuChannel(uniqueID), | |
147 | AliMUONVDigit::Cathode(uniqueID)); | |
148 | } | |
149 | ||
8c740498 | 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 | TIter next(CreateIterator(detElemId,detElemId,cathode)); | |
8c740498 | 156 | Int_t n(0); |
7c1b8e26 | 157 | while ( ( next() ) ) |
8c740498 | 158 | { |
159 | ++n; | |
160 | } | |
161 | return n; | |
162 | } | |
163 |