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