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;
81 #if !(defined(__CINT__) || defined(__MAKECINT__))
87 template<
typename T>
bool GetProperty(std::string propertyName,
T & property,
bool requiredProperty =
true, std::string correctionName =
"");
90 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 =
"");
96 #if !(defined(__CINT__) || defined(__MAKECINT__))
97 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);
98 template<
typename T>
static bool GetPropertyFromNode(
const YAML::Node & node, std::string propertyName,
T & property);
100 template<
typename T>
static typename std::enable_if<!std::is_arithmetic<T>::value && !std::is_same<T, std::string>::value && !std::is_same<T, bool>::value>::type
PrintRetrievedPropertyValue(
T & property, std::stringstream & tempMessage);
101 template<
typename T>
static typename std::enable_if<std::is_arithmetic<T>::value || std::is_same<T, std::string>::value || std::is_same<T, bool>::value>::type
PrintRetrievedPropertyValue(
T & property, std::stringstream & tempMessage);
141 #if !(defined(__CINT__) || defined(__MAKECINT__))
158 if (correctionName ==
"")
160 correctionName = GetName();
185 std::size_t prefixStringLocation = correctionName.find(
"AliEmcalCorrection");
186 if (prefixStringLocation != std::string::npos)
189 correctionName.erase(prefixStringLocation, prefixStringLocation + 18);
192 bool setProperty =
false;
196 if (userConfiguration.IsNull() !=
true)
198 AliDebugClass(2,
"Looking for parameter in user configuration");
199 YAML::Node sharedParameters = userConfiguration[
"sharedParameters"];
204 if (setProperty !=
true)
206 AliDebugClass(2,
"Looking for parameter in default configuration");
207 YAML::Node sharedParameters = defaultConfiguration[
"sharedParameters"];
212 if (setProperty !=
true && requiredProperty ==
true)
214 std::stringstream message;
215 message <<
"Failed to retrieve property \""
216 << (correctionName !=
"" ? correctionName +
":" :
"")
217 << propertyName <<
"\" from default config!" << std::endl;
218 AliFatalClass(message.str().c_str());
254 std::stringstream tempMessage;
256 bool returnValue =
false;
261 tempMessage <<
"Went too many levels of recursion. Bailing out on \"" << correctionName <<
":" << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
262 AliDebugClass(2, TString::Format(
"%s", tempMessage.str().c_str()));
270 tempMessage <<
"Retreiving property \""
271 << (correctionName !=
"" ? correctionName +
":" :
"")
272 << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
273 AliDebugClass(1, TString::Format(
"%s", tempMessage.str().c_str()));
276 if (node.IsDefined() ==
true)
279 if (node[propertyName])
281 bool isShared =
false;
284 std::string sharedValueName =
"";
286 if (std::is_arithmetic<T>::value || std::is_same<T, std::string>::value || std::is_same<T, bool>::value)
289 sharedValueName = node[propertyName].as<std::string>();
295 tempMessage <<
"property \""
296 << (nodesDeep > 0 ? correctionName +
":" :
"")
298 <<
"\" using " << ( isShared ?
"\"sharedParameters:" + sharedValueName +
"\" in " :
"" )
299 <<
"values from the " << configurationType
300 <<
" configuration at level " << nodesDeep;
302 AliDebugClass(2, TString::Format(
"Retrieveing %s", tempMessage.str().c_str()));
304 bool retrievalResult =
false;
305 if (isShared ==
true)
315 if (retrievalResult ==
true)
319 AliDebugClassStream(2) <<
"Succeeded in retrieveing " << tempMessage.str() << std::endl;
325 if (configurationType ==
"default")
327 AliFatalClass(TString::Format(
"Failed to retrieve %s", tempMessage.str().c_str()));
331 AliDebugClass(2, TString::Format(
"Failed to retrieve %s", tempMessage.str().c_str()));
340 YAML::Node deeperNode = node[correctionName];
342 AliDebugClass(2, TString::Format(
"Going a node deeper with \"%s\" to level %i", correctionName.c_str(), nodesDeep));
343 returnValue =
GetPropertyFromNodes(deeperNode, sharedParametersNode, propertyName, property, correctionName, configurationType, nodesDeep);
346 if (returnValue ==
false)
349 std::size_t splitLocation = correctionName.find(
"_");
352 if (splitLocation != std::string::npos && nodesDeep == 1)
355 std::string subCorrectionName = correctionName.substr(0, splitLocation);
356 AliDebugClass(2, TString::Format(
"Attempting to retrieve property \"%s\" from base correction \"%s\" at level %i", propertyName.c_str(), subCorrectionName.c_str(), nodesDeep));
359 YAML::Node subCorrectionNode = node[subCorrectionName];
360 returnValue =
GetPropertyFromNodes(subCorrectionNode, sharedParametersNode, propertyName, property, subCorrectionName, configurationType, nodesDeep);
368 tempMessage <<
"Node is undefined for \""
369 << (correctionName !=
"" ? correctionName +
":" :
"")
370 << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
371 AliDebugClass(2, TString::Format(
"%s", tempMessage.str().c_str()));
390 typename std::enable_if<std::is_arithmetic<T>::value || std::is_same<T, std::string>::value || std::is_same<T, bool>::value>::type
394 tempMessage <<
" with value \"" <<
property <<
"\"";
406 typename std::enable_if<!std::is_arithmetic<T>::value && !std::is_same<T, std::string>::value && !std::is_same<T, bool>::value>::type
410 tempMessage <<
" with a value that cannot be trivially printed";
423 if (node[propertyName])
425 property = node[propertyName].as<
T>();
460 typedef std::map<std::string, AliEmcalCorrectionComponent*(*)()>
map_type;
465 map_type::iterator it =
getMap()->find(s);
505 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
static std::enable_if<!std::is_arithmetic< T >::value &&!std::is_same< T, std::string >::value &&!std::is_same< T, bool >::value >::type PrintRetrievedPropertyValue(T &property, std::stringstream &tempMessage)
RegisterCorrectionComponent(std::string const &s)
Registers the name of the component to map to a function that can create the component.
void SetClusterContainer(AliClusterContainer *cont)
void SetEMCALGeometry(AliEMCALGeometry *geometry)
void SetRecoUtils(AliEMCALRecoUtils *ru)
virtual ~AliEmcalCorrectionComponent()
void SetMCEvent(AliMCEvent *mcevent)
virtual Bool_t UserNotify()
Registers EMCal correction components in the factory map.
AliEmcalCorrectionComponent * createT()
Template function for creating a new component. Used to register the component.
void SetNcentralityBins(Int_t n)
virtual void UserCreateOutputObjects()
Int_t fCentBin
! Event centrality bin
AliVCaloCells * fCaloCells
! Pointer to CaloCells
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 RecoUtils.
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
! Default YAML configuration
Int_t fMinMCLabel
Minimum MC label value for the tracks/clusters being considered MC particles.
void SetEvent(AliVEvent *event)
static map_type * componentMap
Contains the map to all of the components.
static map_type * getMap()
Creates and access the component map.
std::map< std::string, AliEmcalCorrectionComponent *(*)()> map_type
AliMCEvent * fMCEvent
! MC
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.
Factory for correction components in the EMCal correction framework.
void SetIsESD(Bool_t isESD)
AliVCaloCells * GetCaloCells()
YAML::Node fUserConfiguration
! User YAML configuration
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)
Creates an instance of an object based on the name if the name is registered in the map...
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.