AliPhysics  cdeda5a (cdeda5a)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalContainerUtils.h
Go to the documentation of this file.
1 #ifndef ALIEMCALCONTAINERUTILS_H
2 #define ALIEMCALCONTAINERUTILS_H
3 
4 #include <string>
5 
6 #include <TObjArray.h>
7 
8 class AliVEvent;
9 
38 namespace AliEmcalContainerUtils {
45  kCaloCells = 0,
46  kCluster = 1,
47  kTrack = 2,
48  };
49 
50  // Utility functions
51  std::string DetermineUseDefaultName(InputObject_t objType, bool esdMode, bool returnObjectType = false);
52  AliVEvent * GetEvent(AliVEvent * inputEvent, bool isEmbedding = false);
53 
54 #if !(defined(__CINT__) || defined(__MAKECINT__))
55  template <class T>
56  inline T * AddContainer(const char *n, TObjArray & collection);
57  template <class T>
58  T * GetContainer(Int_t i, const TObjArray & collection);
59  template <class T>
60  T * GetContainer(const char *name, const TObjArray & collection);
61 
62  // Then
63  /*AliMCParticleContainer * AddMCParticleContainer(const char * name) { AddContainer<AliMCPartileContainer>(name, fParticleCollArray); }
64  AliTrackContainer * AddTrackContainer(const char * name) { AddContainer<AliTrackContainer>(name, fParticleCollArray); }
65  AliParticleContainer * AddTrackContainer(const char * name) { AddContainer<AliParticleContainer>(name, fParticleCollArray); }
66  */
67 #endif /* Hide from CINT */
68 };
69 
70 #if !(defined(__CINT__) || defined(__MAKECINT__))
71 
80 template <class T>
81 inline T * AliEmcalContainerUtils::AddContainer(const char *n, TObjArray & collection)
82 {
83  if (TString(n).IsNull()) return 0;
84 
85  T * cont = new T(n);
86 
87  collection.Add(cont);
88 
89  return cont;
90 }
91 
98 template <class T>
99 inline T * AliEmcalContainerUtils::GetContainer(Int_t i, const TObjArray & collection)
100 {
101  if (i<0 || i>collection.GetEntriesFast()) return 0;
102  T *cont = static_cast<T *>(collection.At(i));
103  return cont;
104 }
105 
112 template <class T>
113 inline T * AliEmcalContainerUtils::GetContainer(const char *name, const TObjArray & collection)
114 {
115  T *cont = static_cast<T *>(collection.FindObject(name));
116  return cont;
117 }
118 #endif /* Hide from CINT */
119 
120 #endif /* AliEmcalContainerUtils.h */
T * GetContainer(Int_t i, const TObjArray &collection)
std::string DetermineUseDefaultName(InputObject_t objType, bool esdMode, bool returnObjectType=false)
UShort_t T(UShort_t m, UShort_t t)
Definition: RingBits.C:60
int Int_t
Definition: External.C:63
InputObject_t
Type of input object to be created
T * AddContainer(const char *n, TObjArray &collection)
AliVEvent * GetEvent(AliVEvent *inputEvent, bool isEmbedding=false)