1 #if !(defined(__CINT__) || defined(__MAKECINT__)) 2 #ifndef ALIEMCALCONTAINERINDEXMAP_H 3 #define ALIEMCALCONTAINERINDEXMAP_H 9 #include <TClonesArray.h> 10 #include <TObjArray.h> 73 template <
class U,
class V>
82 template<
class X,
class Y>
103 int GetOffset(
const U2 * inputObject)
const;
113 const TClonesArray *
GetObject(
const AliEmcalContainer * inputObject)
const;
114 const TClonesArray *
GetObject(
const TClonesArray * inputObject)
const;
126 template<
class U,
class V>
130 fClass(TClass::GetClass(typeid(V)))
137 template<
class U,
class V>
148 template<
class U,
class V>
159 template<
class U,
class V>
170 template<
class X,
class Y>
175 swap(first.offset, second.offset);
189 template<
class U,
class V>
192 return inputObject->GetArray();
203 template<
class U,
class V>
220 template<
class U,
class V>
223 if (!(inputObject->GetClass()->InheritsFrom(
fClass))) {
224 AliErrorGeneral(
"AliEmcalContainerIndexMap", Form(
"Cannot register array %s. This map can only accept arrays of type %s.", inputObject->GetName(),
fClass->GetName()));
241 template<
class U,
class V>
249 bool addToMap =
true;
261 if (val.first >= index) {
269 fGlobalIndexMap[index] = inputObject;
284 template<
class U,
class V>
287 int globalIndex =
GetOffset(inputObject);
290 if (globalIndex >= 0) {
291 globalIndex += localIndex;
294 AliWarningGeneral(
"AliEmcalContainerIndexMap", TString::Format(
"Unable to retrieve global index for input object %s. Was the input object registered?", inputObject->GetName()));
307 template<
class U,
class V>
311 int globalIndex = -1;
316 globalIndex = val.first;
331 template<
class U,
class V>
340 return std::pair<int, U*> (globalIndex - index, array);
351 template<
class U,
class V>
357 return static_cast<V *
>((*res.second)[res.first]);
370 template<
class U,
class V>
374 TIter next(&containers);
376 while((obj = next())) {
377 U* cont =
dynamic_cast<U*
>(obj);
398 template<
class U,
class V>
std::map< int, U * > fGlobalIndexMap
! Map between index and input object
std::pair< int, U * > LocalIndexFromGlobalIndex(const int globalIndex) const
AliEmcalContainerIndexMap()
Container or array to index mapping for AliEmcalContainer derived classes.
const TClonesArray * GetObject(const AliEmcalContainer *inputObject) const
int GetOffset(const U2 *inputObject) const
int GlobalIndexFromLocalIndex(const U *inputObject, const int localIndex) const
AliEmcalContainerIndexMap & operator=(AliEmcalContainerIndexMap map)
V * GetObjectFromGlobalIndex(const int globalIndex) const
int RegisterArray(U *inputObject)
TClass * fClass
Used to compare the type of V against the underlying input object type.
friend void swap(AliEmcalContainerIndexMap< X, Y > &first, AliEmcalContainerIndexMap< X, Y > &second)
void CopyMappingFrom(const AliEmcalContainerIndexMap< U2, V > &map, U *cont)
void swap(AliEmcalContainerIndexMap< X, Y > &first, AliEmcalContainerIndexMap< X, Y > &second)
int fOffset
Offset between each TClonesArray.
bool IsUnderlyingInputObjectTypeCompatible(const U *inputObject) const
virtual ~AliEmcalContainerIndexMap()