AliPhysics  cc1c0ba (cc1c0ba)
 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 
39  public:
46  kCaloCells = 0,
47  kCluster = 1,
48  kTrack = 2,
49  };
50 
51  // Utility functions
52  static std::string DetermineUseDefaultName(InputObject_t objType, bool esdMode, bool returnObjectType = false);
53  static const AliVEvent * GetEvent(const AliVEvent * inputEvent, bool isEmbedding = false);
54  static AliVEvent * GetEvent(AliVEvent * inputEvent, bool isEmbedding = false);
55 
56 #if !(defined(__CINT__) || defined(__MAKECINT__))
57  template <class T>
58  static inline T * AddContainer(const char *n, TObjArray & collection);
59  template <class T>
60  static T * GetContainer(Int_t i, const TObjArray & collection);
61  template <class T>
62  static T * GetContainer(const char *name, const TObjArray & collection);
63 
64  // Then to use these functions, add below (for example) to each class (or you can use it directly if desired)
65  /*AliMCParticleContainer * AddMCParticleContainer(const char * name) { AddContainer<AliMCPartileContainer>(name, fParticleCollArray); }
66  AliTrackContainer * AddTrackContainer(const char * name) { AddContainer<AliTrackContainer>(name, fParticleCollArray); }
67  AliParticleContainer * AddTrackContainer(const char * name) { AddContainer<AliParticleContainer>(name, fParticleCollArray); }
68  */
69 #endif /* Hide from CINT */
70 };
71 
72 #if !(defined(__CINT__) || defined(__MAKECINT__))
73 
82 template <class T>
83 inline T * AliEmcalContainerUtils::AddContainer(const char *n, TObjArray & collection)
84 {
85  if (TString(n).IsNull()) return 0;
86 
87  T * cont = new T(n);
88 
89  collection.Add(cont);
90 
91  return cont;
92 }
93 
100 template <class T>
101 inline T * AliEmcalContainerUtils::GetContainer(Int_t i, const TObjArray & collection)
102 {
103  if (i<0 || i>collection.GetEntriesFast()) return 0;
104  T *cont = static_cast<T *>(collection.At(i));
105  return cont;
106 }
107 
114 template <class T>
115 inline T * AliEmcalContainerUtils::GetContainer(const char *name, const TObjArray & collection)
116 {
117  T *cont = static_cast<T *>(collection.FindObject(name));
118  return cont;
119 }
120 #endif /* Hide from CINT */
121 
122 #endif /* AliEmcalContainerUtils.h */
static const AliVEvent * GetEvent(const AliVEvent *inputEvent, bool isEmbedding=false)
static 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
static T * AddContainer(const char *n, TObjArray &collection)
static T * GetContainer(Int_t i, const TObjArray &collection)