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