AliPhysics  a6017e1 (a6017e1)
AliEmcalContainerUtils.h
Go to the documentation of this file.
1 #ifndef ALIEMCALCONTAINERUTILS_H
2 #define ALIEMCALCONTAINERUTILS_H
3 
4 #include <string>
5 #include <map>
6 
7 #include <TObjArray.h>
8 
9 #include <AliVEvent.h>
10 
40  public:
47  kCaloCells = 0,
48  kCluster = 1,
49  kTrack = 2,
50  };
51 
52  // YAML Configuration helpers
54  static const std::map <std::string, AliVEvent::EOfflineTriggerTypes> fgkPhysicsSelectionMap;
55  static UInt_t DeterminePhysicsSelectionFromYAML(const std::vector<std::string> & selections);
56 
57  // Utility functions
58  static std::string DetermineUseDefaultName(InputObject_t objType);
59  static std::string DetermineUseDefaultName(InputObject_t objType, bool esdMode, bool returnObjectType = false);
60  static const AliVEvent * GetEvent(const AliVEvent * inputEvent, bool isEmbedding = false);
61  static AliVEvent * GetEvent(AliVEvent * inputEvent, bool isEmbedding = false);
62 
63 #if !(defined(__CINT__) || defined(__MAKECINT__))
64  template <class T>
65  static inline T * AddContainer(const char *n, TObjArray & collection);
66  template <class T>
67  static T * GetContainer(Int_t i, const TObjArray & collection);
68  template <class T>
69  static T * GetContainer(const char *name, const TObjArray & collection);
70 
71  // Then to use these functions, add below (for example) to each class (or you can use it directly if desired)
72  /*AliMCParticleContainer * AddMCParticleContainer(const char * name) { AddContainer<AliMCPartileContainer>(name, fParticleCollArray); }
73  AliTrackContainer * AddTrackContainer(const char * name) { AddContainer<AliTrackContainer>(name, fParticleCollArray); }
74  AliParticleContainer * AddTrackContainer(const char * name) { AddContainer<AliParticleContainer>(name, fParticleCollArray); }
75  */
76 #endif /* Hide from CINT */
77 };
78 
79 #if !(defined(__CINT__) || defined(__MAKECINT__))
80 
89 template <class T>
90 inline T * AliEmcalContainerUtils::AddContainer(const char *n, TObjArray & collection)
91 {
92  if (TString(n).IsNull()) return 0;
93 
94  T * cont = new T(n);
95 
96  collection.Add(cont);
97 
98  return cont;
99 }
100 
107 template <class T>
108 inline T * AliEmcalContainerUtils::GetContainer(Int_t i, const TObjArray & collection)
109 {
110  if (i<0 || i>collection.GetEntriesFast()) return 0;
111  T *cont = static_cast<T *>(collection.At(i));
112  return cont;
113 }
114 
121 template <class T>
122 inline T * AliEmcalContainerUtils::GetContainer(const char *name, const TObjArray & collection)
123 {
124  T *cont = static_cast<T *>(collection.FindObject(name));
125  return cont;
126 }
127 #endif /* Hide from CINT */
128 
129 #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
static UInt_t DeterminePhysicsSelectionFromYAML(const std::vector< std::string > &selections)
int Int_t
Definition: External.C:63
InputObject_t
Type of input object to be created
unsigned int UInt_t
Definition: External.C:33
static T * AddContainer(const char *n, TObjArray &collection)
static const std::map< std::string, AliVEvent::EOfflineTriggerTypes > fgkPhysicsSelectionMap
Relates string to the physics selection enumeration for YAML configuration.
static std::string DetermineUseDefaultName(InputObject_t objType)
static T * GetContainer(Int_t i, const TObjArray &collection)