AliPhysics  5a28df1 (5a28df1)
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 
16 // string to enum map for use with the %YAML config
17 const std::map <std::string, AliVEvent::EOfflineTriggerTypes> AliEmcalContainerUtils::fgkPhysicsSelectionMap = {
18  {"kMB", AliVEvent::kMB},
19  {"kINT1", AliVEvent::kINT1},
20  {"kINT7", AliVEvent::kINT7},
21  {"kMUON", AliVEvent::kMUON},
22  {"kHighMult", AliVEvent::kHighMult},
23  {"kHighMultSPD", AliVEvent::kHighMultSPD},
24  {"kEMC1", AliVEvent::kEMC1},
25  {"kCINT5", AliVEvent::kCINT5},
26  {"kINT5", AliVEvent::kINT5},
27  {"kCMUS5", AliVEvent::kCMUS5},
28  {"kMUSPB", AliVEvent::kMUSPB},
29  {"kINT7inMUON", AliVEvent::kINT7inMUON},
30  {"kMuonSingleHighPt7", AliVEvent::kMuonSingleHighPt7},
31  {"kMUSH7", AliVEvent::kMUSH7},
32  {"kMUSHPB", AliVEvent::kMUSHPB},
33  {"kMuonLikeLowPt7", AliVEvent::kMuonLikeLowPt7},
34  {"kMUL7", AliVEvent::kMUL7},
35  {"kMuonLikePB", AliVEvent::kMuonLikePB},
36  {"kMuonUnlikeLowPt7", AliVEvent::kMuonUnlikeLowPt7},
37  {"kMUU7", AliVEvent::kMUU7},
38  {"kMuonUnlikePB", AliVEvent::kMuonUnlikePB},
39  {"kEMC7", AliVEvent::kEMC7},
40  {"kEMC8", AliVEvent::kEMC8},
41  {"kMUS7", AliVEvent::kMUS7},
42  {"kMuonSingleLowPt7", AliVEvent::kMuonSingleLowPt7},
43  {"kPHI1", AliVEvent::kPHI1},
44  {"kPHI7", AliVEvent::kPHI7},
45  {"kPHI8", AliVEvent::kPHI8},
46  {"kPHOSPb", AliVEvent::kPHOSPb},
47  {"kEMCEJE", AliVEvent::kEMCEJE},
48  {"kEMCEGA", AliVEvent::kEMCEGA},
49  {"kHighMultV0", AliVEvent::kHighMultV0},
50  {"kCentral", AliVEvent::kCentral},
51  {"kSemiCentral", AliVEvent::kSemiCentral},
52  {"kDG", AliVEvent::kDG},
53  {"kDG5", AliVEvent::kDG5},
54  {"kZED", AliVEvent::kZED},
55  {"kSPI7", AliVEvent::kSPI7},
56  {"kSPI", AliVEvent::kSPI},
57  {"kINT8", AliVEvent::kINT8},
58  {"kMuonSingleLowPt8", AliVEvent::kMuonSingleLowPt8},
59  {"kMuonSingleHighPt8", AliVEvent::kMuonSingleHighPt8},
60  {"kMuonLikeLowPt8", AliVEvent::kMuonLikeLowPt8},
61  {"kMuonUnlikeLowPt8", AliVEvent::kMuonUnlikeLowPt8},
62  {"kMuonUnlikeLowPt0", AliVEvent::kMuonUnlikeLowPt0},
63  {"kUserDefined", AliVEvent::kUserDefined},
64  {"kTRD", AliVEvent::kTRD},
65  {"kMuonCalo", AliVEvent::kMuonCalo},
66  {"kFastOnly", AliVEvent::kFastOnly},
67  {"kAny", AliVEvent::kAny},
68  {"kAnyINT", AliVEvent::kAnyINT}
69 };
70 
77 UInt_t AliEmcalContainerUtils::DeterminePhysicsSelectionFromYAML(const std::vector<std::string> & selections)
78 {
79  UInt_t physicsSelection = 0;
80  for (auto sel : selections) {
81  physicsSelection |= fgkPhysicsSelectionMap.at(sel);
82  }
83  return physicsSelection;
84 }
85 
96 {
97  // Get the pointer to the existing analysis manager via the static access method.
98  //==============================================================================
99  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
100  if (!mgr)
101  {
102  ::Error("AddTaskEmcalSample", "No analysis manager to connect to.");
103  return 0;
104  }
105 
106  // Check the analysis type using the event handlers connected to the analysis manager.
107  //==============================================================================
108  AliVEventHandler* handler = mgr->GetInputEventHandler();
109  if (!handler)
110  {
111  ::Error("AddTaskEmcalSample", "This task requires an input event handler");
112  return 0;
113  }
114 
115  enum EDataType_t {
116  kUnknown,
117  kESD,
118  kAOD
119  };
120 
121  EDataType_t dataType = kUnknown;
122 
123  if (handler->InheritsFrom("AliESDInputHandler")) {
124  dataType = kESD;
125  }
126  else if (handler->InheritsFrom("AliAODInputHandler")) {
127  dataType = kAOD;
128  }
129 
130  return DetermineUseDefaultName(objType, dataType == kESD, false);
131 }
132 
148 std::string AliEmcalContainerUtils::DetermineUseDefaultName(InputObject_t objType, bool esdMode, bool returnObjectType)
149 {
150  std::string returnValue = "";
151  if (objType == kCluster) {
152  if (esdMode == true) {
153  if (returnObjectType == true) {
154  returnValue = "AliESDCaloCluster";
155  }
156  else {
157  returnValue = "CaloClusters";
158  }
159  }
160  else {
161  if (returnObjectType == true) {
162  returnValue = "AliAODCaloCluster";
163  }
164  else {
165  returnValue = "caloClusters";
166  }
167  }
168  }
169  else if (objType == kTrack) {
170  if (esdMode == true) {
171  if (returnObjectType == true) {
172  returnValue = "AliESDtrack";
173  }
174  else {
175  returnValue = "Tracks";
176  }
177  }
178  else {
179  if (returnObjectType == true) {
180  returnValue = "AliAODTrack";
181  }
182  else {
183  returnValue = "tracks";
184  }
185  }
186  }
187  else if (objType == kCaloCells) {
188  if (esdMode == true) {
189  if (returnObjectType == true) {
190  returnValue = "AliESDCaloCells";
191  }
192  else {
193  returnValue = "EMCALCells";
194  }
195  }
196  else {
197  if (returnObjectType == true) {
198  returnValue = "AliAODCaloCells";
199  }
200  else {
201  returnValue = "emcalCells";
202  }
203  }
204  }
205  else {
206  // Default to empty if we are given an unrecognized type with "usedefault"
207  returnValue = "";
208  AliWarningGeneralStream("AliEmcalContainerUtils") << "Unrecognized combination of inputs! Passed values of input object: " << objType << ", esdMode: " << std::boolalpha << esdMode << ", returnObjectType " << returnObjectType << std::endl;
209  }
210 
211  return returnValue;
212 }
213 
224 const AliVEvent * AliEmcalContainerUtils::GetEvent(const AliVEvent * inputEvent, bool isEmbedding)
225 {
226  const AliVEvent * event = nullptr;
227  if (isEmbedding) {
229  if (!embedding) return nullptr;
230 
231  // Need the const cast as GetExternalEvent() returns a non-const event
232  event = const_cast<const AliVEvent *>(embedding->GetExternalEvent());
233  }
234  else {
235  event = inputEvent;
236  }
237 
238  return event;
239 }
240 
251 AliVEvent * AliEmcalContainerUtils::GetEvent(AliVEvent * inputEvent, bool isEmbedding)
252 {
253  return const_cast<AliVEvent *>(GetEvent(const_cast<const AliVEvent *>(inputEvent), isEmbedding));
254 }
255 
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.
static UInt_t DeterminePhysicsSelectionFromYAML(const std::vector< std::string > &selections)
InputObject_t
Type of input object to be created
unsigned int UInt_t
Definition: External.C:33
Implementation of task to embed external events.
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 const AliAnalysisTaskEmcalEmbeddingHelper * GetInstance()