1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 /// \class AliMUONVDigitStore
20 /// Interface for a digit (or sdigit) container
22 /// It offers methods to Add, Find and Remove single elements, and
23 /// can create iterators to loop over (part of) the elements.
25 /// \author Laurent Aphecetche, Subatech
27 #include "AliMUONVDigitStore.h"
30 #include "AliMUONVDigit.h"
36 ClassImp(AliMUONVDigitStore)
39 //_____________________________________________________________________________
40 AliMUONVDigitStore::AliMUONVDigitStore()
45 //_____________________________________________________________________________
46 AliMUONVDigitStore::~AliMUONVDigitStore()
51 //_____________________________________________________________________________
53 AliMUONVDigitStore::Add(TObject* object)
55 /// Add an object, if it is of type AliMUONVDigit
58 AliMUONVDigit* digit = dynamic_cast<AliMUONVDigit*>(object);
61 AliMUONVDigit* added = Add(*digit,AliMUONVDigitStore::kIgnore);
64 AliError("Could not add digit through Add(TObject*) method");
75 //_____________________________________________________________________________
77 AliMUONVDigitStore::Add(Int_t detElemId,
81 EReplacePolicy replace)
83 /// Add a digit and return it
84 AliMUONVDigit* digit = CreateDigit(detElemId,manuId,manuChannel,cathode);
87 AliMUONVDigit* d = Add(*digit,replace);
94 //____________________________________________________________________________
96 AliMUONVDigitStore::Create(const char* digitstoreclassname)
98 /// Create a concrete digitStore, given its classname
100 TClass* classPtr = TClass::GetClass(digitstoreclassname);
106 AliMUONVDigitStore* digitStore =
107 reinterpret_cast<AliMUONVDigitStore*>(classPtr->New());
112 //_____________________________________________________________________________
114 AliMUONVDigitStore::Create(TTree& tree)
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" : "")
120 return static_cast<AliMUONVDigitStore*>(AliMUONVStore::Create(tree,dataType.Data()));
123 //_____________________________________________________________________________
125 AliMUONVDigitStore::FindObject(const TObject* object) const
127 /// Find an object, if of AliMUONVDigit type.
128 const AliMUONVDigit* digit = dynamic_cast<const AliMUONVDigit*>(object);
131 return FindObject(digit->GetUniqueID());
136 //_____________________________________________________________________________
138 AliMUONVDigitStore::FindObject(UInt_t uniqueID) const
140 /// Find digit by its uniqueID
142 return FindObject(AliMUONVDigit::DetElemId(uniqueID),
143 AliMUONVDigit::ManuId(uniqueID),
144 AliMUONVDigit::ManuChannel(uniqueID),
145 AliMUONVDigit::Cathode(uniqueID));
148 //_____________________________________________________________________________
150 AliMUONVDigitStore::GetSize(Int_t detElemId, Int_t cathode) const
152 /// Return the number of digits we have for a given detection element
153 TIter next(CreateIterator(detElemId,detElemId,cathode));
154 AliMUONVDigit* digit;
156 while ( ( digit = static_cast<AliMUONVDigit*>(next()) ) )