1 #ifndef ALIEMCALCORRECTIONCOMPONENT_H
2 #define ALIEMCALCORRECTIONCOMPONENT_H
14 #if !(defined(__CINT__) || defined(__MAKECINT__))
15 #include <yaml-cpp/yaml.h>
24 #include "AliEMCALRecoUtils.h"
25 #include "AliAODEvent.h"
26 #include "AliESDEvent.h"
27 #include "AliAODCaloCluster.h"
29 #include "AliEMCALGeometry.h"
30 #include "AliAnalysisManager.h"
74 #if !(defined(__CINT__) || defined(__MAKECINT__))
80 template<
typename T>
void GetProperty(std::string propertyName,
T & property,
bool requiredProperty =
true, std::string correctionName =
"");
83 template<
typename T>
static void GetProperty(std::string propertyName,
T & property,
const YAML::Node & userConfiguration,
const YAML::Node & defaultConfiguration,
bool requiredProperty =
true, std::string correctionName =
"");
94 #if !(defined(__CINT__) || defined(__MAKECINT__))
95 template<
typename T>
static bool GetPropertyFromNodes(
const YAML::Node & node,
const YAML::Node & sharedParametersNode, std::string propertyName,
T & property,
const std::string correctionName,
const std::string configurationType,
int nodesDeep = 0);
96 template<
typename T>
static bool GetPropertyFromNode(
const YAML::Node & node, std::string propertyName,
T & property);
134 #if !(defined(__CINT__) || defined(__MAKECINT__))
143 if (correctionName ==
"")
145 correctionName = GetName();
158 std::size_t prefixStringLocation = correctionName.find(
"AliEmcalCorrection");
159 if (prefixStringLocation != std::string::npos)
162 correctionName.erase(prefixStringLocation, prefixStringLocation + 18);
165 bool setProperty =
false;
169 if (userConfiguration.IsNull() !=
true)
171 AliDebugClass(2,
"Looking for parameter in user configuration");
172 YAML::Node sharedParameters = userConfiguration[
"sharedParameters"];
177 if (setProperty !=
true)
179 AliDebugClass(2,
"Looking for parameter in defulat configuration");
180 YAML::Node sharedParameters = defaultConfiguration[
"sharedParameters"];
185 if (setProperty !=
true && requiredProperty ==
true)
187 std::stringstream message;
188 message <<
"Failed to retrieve property \""
189 << (correctionName !=
"" ? correctionName +
":" :
"")
190 << propertyName <<
"\" from default config!" << std::endl;
191 AliFatalClass(message.str().c_str());
203 std::stringstream tempMessage;
205 bool returnValue =
false;
210 tempMessage <<
"Went too many levels of recursion. Bailing out on \"" << correctionName <<
":" << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
211 AliDebugClass(2, TString::Format(
"%s", tempMessage.str().c_str()));
219 tempMessage <<
"Retreiving property \""
220 << (correctionName !=
"" ? correctionName +
":" :
"")
221 << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
222 AliDebugClass(1, TString::Format(
"%s", tempMessage.str().c_str()));
225 if (node.IsDefined() ==
true)
228 if (node[propertyName])
230 bool isShared =
false;
233 std::string sharedValueName =
"";
235 if (std::is_arithmetic<T>::value || std::is_same<T, std::string>::value)
238 sharedValueName = node[propertyName].as<std::string>();
244 tempMessage <<
"property \""
245 << (nodesDeep > 0 ? correctionName +
":" :
"")
247 <<
"\" using " << ( isShared ?
"\"sharedParameters:" + sharedValueName +
"\" in " :
"" )
248 <<
"values from the " << configurationType
249 <<
" configuration at level " << nodesDeep;
251 AliDebugClass(2, TString::Format(
"Retrieveing %s", tempMessage.str().c_str()));
253 bool retrievalResult =
false;
254 if (isShared ==
true)
264 if (retrievalResult ==
true)
266 AliDebugClass(2, TString::Format(
"Succeeded in retrieveing %s", tempMessage.str().c_str()));
272 if (configurationType ==
"default")
274 AliFatalClass(TString::Format(
"Failed to retrieve %s", tempMessage.str().c_str()));
278 AliDebugClass(2, TString::Format(
"Failed to retrieve %s", tempMessage.str().c_str()));
287 YAML::Node deeperNode = node[correctionName];
289 AliDebugClass(2, TString::Format(
"Going a node deeper with \"%s\" to level %i", correctionName.c_str(), nodesDeep));
290 returnValue =
GetPropertyFromNodes(deeperNode, sharedParametersNode, propertyName, property, correctionName, configurationType, nodesDeep);
293 if (returnValue ==
false)
296 std::size_t splitLocation = correctionName.find(
"_");
299 if (splitLocation != std::string::npos && nodesDeep == 1)
302 std::string subCorrectionName = correctionName.substr(0, splitLocation);
303 AliDebugClass(2, TString::Format(
"Attempting to retrieve property \"%s\" from base correction \"%s\" at level %i", propertyName.c_str(), subCorrectionName.c_str(), nodesDeep));
306 YAML::Node subCorrectionNode = node[subCorrectionName];
307 returnValue =
GetPropertyFromNodes(subCorrectionNode, sharedParametersNode, propertyName, property, subCorrectionName, configurationType, nodesDeep);
315 tempMessage <<
"Node is undefined for \""
316 << (correctionName !=
"" ? correctionName +
":" :
"")
317 << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
318 AliDebugClass(2, TString::Format(
"%s", tempMessage.str().c_str()));
333 if (node[propertyName])
335 property = node[propertyName].as<
T>();
354 typedef std::map<std::string, AliEmcalCorrectionComponent*(*)()>
map_type;
359 map_type::iterator it =
getMap()->find(s);
387 getMap()->insert(std::make_pair(s, &createT<T>));
Int_t fNcentBins
how many centrality bins (this member copied from AliAnalysisTaskEmcal)
void AddContainer(inputObjectType type)
static std::string DetermineUseDefaultName(inputObjectType contType, Bool_t esdMode)
AliParticleContainer * GetParticleContainer()
AliEMCALGeometry * fGeom
!geometry object
RegisterCorrectionComponent(std::string const &s)
void SetClusterContainer(AliClusterContainer *cont)
void SetEMCALGeometry(AliEMCALGeometry *geometry)
void SetRecoUtils(AliEMCALRecoUtils *ru)
virtual ~AliEmcalCorrectionComponent()
void SetMCEvent(AliMCEvent *mcevent)
virtual Bool_t UserNotify()
AliEmcalCorrectionComponent * createT()
void SetNcentralityBins(Int_t n)
Int_t fCentBin
!event centrality bin
AliVCaloCells * fCaloCells
! pointer to calo cells
Container for particles within the EMCAL framework.
UShort_t T(UShort_t m, UShort_t t)
void SetUserConfiguration(YAML::Node &node)
Make copy to ensure that the nodes do not point to each other (?)
AliEMCALRecoUtils * fRecoUtils
! pointer to reco utils
AliClusterContainer * fClusCont
! pointer to the cluster container
void SetParticleContainer(AliParticleContainer *cont)
static bool GetPropertyFromNode(const YAML::Node &node, std::string propertyName, T &property)
static bool GetPropertyFromNodes(const YAML::Node &node, const YAML::Node &sharedParametersNode, std::string propertyName, T &property, const std::string correctionName, const std::string configurationType, int nodesDeep=0)
YAML::Node fDefaultConfiguration
Int_t fMinMCLabel
minimum MC label value for the tracks/clusters being considered MC particles
void SetEvent(AliVEvent *event)
void GetProperty(std::string propertyName, T &property, bool requiredProperty=true, std::string correctionName="")
Retrieve property.
static map_type * componentMap
static map_type * getMap()
std::map< std::string, AliEmcalCorrectionComponent *(*)()> map_type
Double_t fVertex[3]
!event vertex
Double_t fMaxBinPt
max pt in histograms
TList * fOutput
! list of output histograms
AliEmcalCorrectionComponent & operator=(const AliEmcalCorrectionComponent &)
static bool IsSharedValue(std::string &value)
Bool_t fGetPassFromFileName
Double_t fCent
!event centrality
virtual ~AliEmcalCorrectionComponentFactory()
virtual Bool_t Initialize()
void SetDefaultConfiguration(YAML::Node &node)
Double_t fMinBinPt
min pt in histograms
AliVCaloCells * GetCaloCells()
YAML::Node fUserConfiguration
void SetCaloCells(AliVCaloCells *cells)
void SetCentrality(Double_t cent)
AliEmcalCorrectionComponent()
void GetEtaPhiDiff(const AliVTrack *t, const AliVCluster *v, Double_t &phidiff, Double_t &etadiff)
static AliEmcalCorrectionComponent * createInstance(std::string const &s)
AliClusterContainer * GetClusterContainer()
Int_t fNbins
no. of pt bins
AliParticleContainer * fPartCont
! pointer to the track/particle container
Container structure for EMCAL clusters.
TString fFilepass
run number
void SetCentralityBin(Int_t bin)
Bool_t fIsEmbedded
trigger, embedded signal