1 #ifndef ALIEMCALCORRECTIONCOMPONENT_H
2 #define ALIEMCALCORRECTIONCOMPONENT_H
8 #if !(defined(__CINT__) || defined(__MAKECINT__))
9 #include <yaml-cpp/yaml.h>
18 class AliEMCALRecoUtils;
22 class AliEMCALGeometry;
74 #if !(defined(__CINT__) || defined(__MAKECINT__))
80 template<
typename T>
bool GetProperty(std::string propertyName,
T & property,
bool requiredProperty =
true, std::string correctionName =
"");
83 template<
typename T>
static bool GetProperty(std::string propertyName,
T & property,
const YAML::Node & userConfiguration,
const YAML::Node & defaultConfiguration,
bool requiredProperty =
true, std::string correctionName =
"");
89 #if !(defined(__CINT__) || defined(__MAKECINT__))
90 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);
91 template<
typename T>
static bool GetPropertyFromNode(
const YAML::Node & node, std::string propertyName,
T & property);
131 #if !(defined(__CINT__) || defined(__MAKECINT__))
140 if (correctionName ==
"")
142 correctionName = GetName();
157 std::size_t prefixStringLocation = correctionName.find(
"AliEmcalCorrection");
158 if (prefixStringLocation != std::string::npos)
161 correctionName.erase(prefixStringLocation, prefixStringLocation + 18);
164 bool setProperty =
false;
168 if (userConfiguration.IsNull() !=
true)
170 AliDebugClass(2,
"Looking for parameter in user configuration");
171 YAML::Node sharedParameters = userConfiguration[
"sharedParameters"];
176 if (setProperty !=
true)
178 AliDebugClass(2,
"Looking for parameter in default configuration");
179 YAML::Node sharedParameters = defaultConfiguration[
"sharedParameters"];
184 if (setProperty !=
true && requiredProperty ==
true)
186 std::stringstream message;
187 message <<
"Failed to retrieve property \""
188 << (correctionName !=
"" ? correctionName +
":" :
"")
189 << propertyName <<
"\" from default config!" << std::endl;
190 AliFatalClass(message.str().c_str());
205 std::stringstream tempMessage;
207 bool returnValue =
false;
212 tempMessage <<
"Went too many levels of recursion. Bailing out on \"" << correctionName <<
":" << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
213 AliDebugClass(2, TString::Format(
"%s", tempMessage.str().c_str()));
221 tempMessage <<
"Retreiving property \""
222 << (correctionName !=
"" ? correctionName +
":" :
"")
223 << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
224 AliDebugClass(1, TString::Format(
"%s", tempMessage.str().c_str()));
227 if (node.IsDefined() ==
true)
230 if (node[propertyName])
232 bool isShared =
false;
235 std::string sharedValueName =
"";
237 if (std::is_arithmetic<T>::value || std::is_same<T, std::string>::value)
240 sharedValueName = node[propertyName].as<std::string>();
246 tempMessage <<
"property \""
247 << (nodesDeep > 0 ? correctionName +
":" :
"")
249 <<
"\" using " << ( isShared ?
"\"sharedParameters:" + sharedValueName +
"\" in " :
"" )
250 <<
"values from the " << configurationType
251 <<
" configuration at level " << nodesDeep;
253 AliDebugClass(2, TString::Format(
"Retrieveing %s", tempMessage.str().c_str()));
255 bool retrievalResult =
false;
256 if (isShared ==
true)
266 if (retrievalResult ==
true)
268 AliDebugClass(2, TString::Format(
"Succeeded in retrieveing %s", tempMessage.str().c_str()));
274 if (configurationType ==
"default")
276 AliFatalClass(TString::Format(
"Failed to retrieve %s", tempMessage.str().c_str()));
280 AliDebugClass(2, TString::Format(
"Failed to retrieve %s", tempMessage.str().c_str()));
289 YAML::Node deeperNode = node[correctionName];
291 AliDebugClass(2, TString::Format(
"Going a node deeper with \"%s\" to level %i", correctionName.c_str(), nodesDeep));
292 returnValue =
GetPropertyFromNodes(deeperNode, sharedParametersNode, propertyName, property, correctionName, configurationType, nodesDeep);
295 if (returnValue ==
false)
298 std::size_t splitLocation = correctionName.find(
"_");
301 if (splitLocation != std::string::npos && nodesDeep == 1)
304 std::string subCorrectionName = correctionName.substr(0, splitLocation);
305 AliDebugClass(2, TString::Format(
"Attempting to retrieve property \"%s\" from base correction \"%s\" at level %i", propertyName.c_str(), subCorrectionName.c_str(), nodesDeep));
308 YAML::Node subCorrectionNode = node[subCorrectionName];
309 returnValue =
GetPropertyFromNodes(subCorrectionNode, sharedParametersNode, propertyName, property, subCorrectionName, configurationType, nodesDeep);
317 tempMessage <<
"Node is undefined for \""
318 << (correctionName !=
"" ? correctionName +
":" :
"")
319 << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
320 AliDebugClass(2, TString::Format(
"%s", tempMessage.str().c_str()));
335 if (node[propertyName])
337 property = node[propertyName].as<
T>();
356 typedef std::map<std::string, AliEmcalCorrectionComponent*(*)()>
map_type;
361 map_type::iterator it =
getMap()->find(s);
389 getMap()->insert(std::make_pair(s, &createT<T>));
Int_t fNcentBins
how many centrality bins (this member copied from AliAnalysisTaskEmcal)
Bool_t fEsdMode
flag for ESD
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)
virtual void UserCreateOutputObjects()
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)
Base class for correction components in the EMCal correction framework.
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)
static map_type * componentMap
static map_type * getMap()
std::map< std::string, AliEmcalCorrectionComponent *(*)()> map_type
Double_t fVertex[3]
!event vertex
TString fBasePath
base folder path to get root files
Double_t fMaxBinPt
max pt in histograms
AliVEvent * fEvent
!pointer to event
TList * fOutput
! list of output histograms
AliEmcalCorrectionComponent & operator=(const AliEmcalCorrectionComponent &)
static bool IsSharedValue(std::string &value)
Bool_t fCreateHisto
flag to make some basic histograms
Bool_t fGetPassFromFileName
get fFilepass from file name
Double_t fCent
!event centrality
virtual ~AliEmcalCorrectionComponentFactory()
virtual Bool_t Initialize()
void SetDefaultConfiguration(YAML::Node &node)
Double_t fMinBinPt
min pt in histograms
void SetIsESD(Bool_t isESD)
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
input data pass number
bool GetProperty(std::string propertyName, T &property, bool requiredProperty=true, std::string correctionName="")
Retrieve property.
void SetCentralityBin(Int_t bin)
Bool_t fIsEmbedded
trigger, embedded signal