AliPhysics  b555aef (b555aef)
AliEmcalContainerUtils.cxx
Go to the documentation of this file.
1 //
2 // Containers EMCal container utility functions
3 //
4 
6 
7 #include <iostream>
8 
9 #include <AliVEvent.h>
10 #include <AliLog.h>
11 #include <AliAnalysisManager.h>
12 #include <AliVEventHandler.h>
13 
15 
26 {
27  // Get the pointer to the existing analysis manager via the static access method.
28  //==============================================================================
29  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
30  if (!mgr)
31  {
32  ::Error("AddTaskEmcalSample", "No analysis manager to connect to.");
33  return 0;
34  }
35 
36  // Check the analysis type using the event handlers connected to the analysis manager.
37  //==============================================================================
38  AliVEventHandler* handler = mgr->GetInputEventHandler();
39  if (!handler)
40  {
41  ::Error("AddTaskEmcalSample", "This task requires an input event handler");
42  return 0;
43  }
44 
45  enum EDataType_t {
46  kUnknown,
47  kESD,
48  kAOD
49  };
50 
51  EDataType_t dataType = kUnknown;
52 
53  if (handler->InheritsFrom("AliESDInputHandler")) {
54  dataType = kESD;
55  }
56  else if (handler->InheritsFrom("AliAODInputHandler")) {
57  dataType = kAOD;
58  }
59 
60  return DetermineUseDefaultName(objType, dataType == kESD, false);
61 }
62 
78 std::string AliEmcalContainerUtils::DetermineUseDefaultName(InputObject_t objType, bool esdMode, bool returnObjectType)
79 {
80  std::string returnValue = "";
81  if (objType == kCluster) {
82  if (esdMode == true) {
83  if (returnObjectType == true) {
84  returnValue = "AliESDCaloCluster";
85  }
86  else {
87  returnValue = "CaloClusters";
88  }
89  }
90  else {
91  if (returnObjectType == true) {
92  returnValue = "AliAODCaloCluster";
93  }
94  else {
95  returnValue = "caloClusters";
96  }
97  }
98  }
99  else if (objType == kTrack) {
100  if (esdMode == true) {
101  if (returnObjectType == true) {
102  returnValue = "AliESDtrack";
103  }
104  else {
105  returnValue = "Tracks";
106  }
107  }
108  else {
109  if (returnObjectType == true) {
110  returnValue = "AliAODTrack";
111  }
112  else {
113  returnValue = "tracks";
114  }
115  }
116  }
117  else if (objType == kCaloCells) {
118  if (esdMode == true) {
119  if (returnObjectType == true) {
120  returnValue = "AliESDCaloCells";
121  }
122  else {
123  returnValue = "EMCALCells";
124  }
125  }
126  else {
127  if (returnObjectType == true) {
128  returnValue = "AliAODCaloCells";
129  }
130  else {
131  returnValue = "emcalCells";
132  }
133  }
134  }
135  else {
136  // Default to empty if we are given an unrecognized type with "usedefault"
137  returnValue = "";
138  AliWarningGeneralStream("AliEmcalContainerUtils") << "Unrecognized combination of inputs! Passed values of input object: " << objType << ", esdMode: " << std::boolalpha << esdMode << ", returnObjectType " << returnObjectType << std::endl;
139  }
140 
141  return returnValue;
142 }
143 
154 const AliVEvent * AliEmcalContainerUtils::GetEvent(const AliVEvent * inputEvent, bool isEmbedding)
155 {
156  const AliVEvent * event = nullptr;
157  if (isEmbedding) {
159  if (!embedding) return nullptr;
160 
161  // Need the const cast as GetExternalEvent() returns a non-const event
162  event = const_cast<const AliVEvent *>(embedding->GetExternalEvent());
163  }
164  else {
165  event = inputEvent;
166  }
167 
168  return event;
169 }
170 
181 AliVEvent * AliEmcalContainerUtils::GetEvent(AliVEvent * inputEvent, bool isEmbedding)
182 {
183  return const_cast<AliVEvent *>(GetEvent(const_cast<const AliVEvent *>(inputEvent), isEmbedding));
184 }
185 
static const AliVEvent * GetEvent(const AliVEvent *inputEvent, bool isEmbedding=false)
Declaration of class AliAnalysisTaskEmcalEmbeddingHelper.
AliVEvent * GetExternalEvent() const
Retrieve the embedded event from the embedding helper.
InputObject_t
Type of input object to be created
Implementation of task to embed external events.
static std::string DetermineUseDefaultName(InputObject_t objType)
static const AliAnalysisTaskEmcalEmbeddingHelper * GetInstance()