1 #ifndef ALIEMCALCORRECTIONCOMPONENT_H
2 #define ALIEMCALCORRECTIONCOMPONENT_H
8 #if !(defined(__CINT__) || defined(__MAKECINT__))
9 #include <yaml-cpp/yaml.h>
16 class AliEMCALRecoUtils;
27 #include "AliEMCALGeometry.h"
100 #if !(defined(__CINT__) || defined(__MAKECINT__))
106 template<
typename T>
bool GetProperty(std::string propertyName,
T & property,
bool requiredProperty =
true, std::string correctionName =
"");
109 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 =
"");
115 #if !(defined(__CINT__) || defined(__MAKECINT__))
116 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);
117 template<
typename T>
static bool GetPropertyFromNode(
const YAML::Node & node, std::string propertyName,
T & property);
119 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);
120 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);
160 #if !(defined(__CINT__) || defined(__MAKECINT__))
177 if (correctionName ==
"")
179 correctionName = GetName();
204 std::size_t prefixStringLocation = correctionName.find(
"AliEmcalCorrection");
205 if (prefixStringLocation != std::string::npos)
208 correctionName.erase(prefixStringLocation, prefixStringLocation + 18);
211 bool setProperty =
false;
215 if (userConfiguration.IsNull() !=
true)
217 AliDebugClass(2,
"Looking for parameter in user configuration");
218 YAML::Node sharedParameters = userConfiguration[
"sharedParameters"];
223 if (setProperty !=
true)
225 AliDebugClass(2,
"Looking for parameter in default configuration");
226 YAML::Node sharedParameters = defaultConfiguration[
"sharedParameters"];
231 if (setProperty !=
true && requiredProperty ==
true)
233 std::stringstream message;
234 message <<
"Failed to retrieve property \""
235 << (correctionName !=
"" ? correctionName +
":" :
"")
236 << propertyName <<
"\" from default config!" << std::endl;
237 AliFatalClass(message.str().c_str());
273 std::stringstream tempMessage;
275 bool returnValue =
false;
280 tempMessage <<
"Went too many levels of recursion. Bailing out on \"" << correctionName <<
":" << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
281 AliDebugClass(2, TString::Format(
"%s", tempMessage.str().c_str()));
289 tempMessage <<
"Retreiving property \""
290 << (correctionName !=
"" ? correctionName +
":" :
"")
291 << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
292 AliDebugClass(1, TString::Format(
"%s", tempMessage.str().c_str()));
295 if (node.IsDefined() ==
true)
298 if (node[propertyName])
300 bool isShared =
false;
303 std::string sharedValueName =
"";
305 if (std::is_arithmetic<T>::value || std::is_same<T, std::string>::value || std::is_same<T, bool>::value)
308 sharedValueName = node[propertyName].as<std::string>();
314 tempMessage <<
"property \""
315 << (nodesDeep > 0 ? correctionName +
":" :
"")
317 <<
"\" using " << ( isShared ?
"\"sharedParameters:" + sharedValueName +
"\" in " :
"" )
318 <<
"values from the " << configurationType
319 <<
" configuration at level " << nodesDeep;
321 AliDebugClass(2, TString::Format(
"Retrieveing %s", tempMessage.str().c_str()));
323 bool retrievalResult =
false;
324 if (isShared ==
true)
334 if (retrievalResult ==
true)
338 AliDebugClassStream(2) <<
"Succeeded in retrieveing " << tempMessage.str() << std::endl;
344 if (configurationType ==
"default")
346 AliFatalClass(TString::Format(
"Failed to retrieve %s", tempMessage.str().c_str()));
350 AliDebugClass(2, TString::Format(
"Failed to retrieve %s", tempMessage.str().c_str()));
359 YAML::Node deeperNode = node[correctionName];
361 AliDebugClass(2, TString::Format(
"Going a node deeper with \"%s\" to level %i", correctionName.c_str(), nodesDeep));
362 returnValue =
GetPropertyFromNodes(deeperNode, sharedParametersNode, propertyName, property, correctionName, configurationType, nodesDeep);
365 if (returnValue ==
false)
368 std::size_t splitLocation = correctionName.find(
"_");
371 if (splitLocation != std::string::npos && nodesDeep == 1)
374 std::string subCorrectionName = correctionName.substr(0, splitLocation);
375 AliDebugClass(2, TString::Format(
"Attempting to retrieve property \"%s\" from base correction \"%s\" at level %i", propertyName.c_str(), subCorrectionName.c_str(), nodesDeep));
378 YAML::Node subCorrectionNode = node[subCorrectionName];
379 returnValue =
GetPropertyFromNodes(subCorrectionNode, sharedParametersNode, propertyName, property, subCorrectionName, configurationType, nodesDeep);
387 tempMessage <<
"Node is undefined for \""
388 << (correctionName !=
"" ? correctionName +
":" :
"")
389 << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
390 AliDebugClass(2, TString::Format(
"%s", tempMessage.str().c_str()));
409 typename std::enable_if<std::is_arithmetic<T>::value || std::is_same<T, std::string>::value || std::is_same<T, bool>::value>::type
413 tempMessage <<
" with value \"" <<
property <<
"\"";
425 typename std::enable_if<!std::is_arithmetic<T>::value && !std::is_same<T, std::string>::value && !std::is_same<T, bool>::value>::type
429 tempMessage <<
" with a value that cannot be trivially printed";
442 if (node[propertyName])
444 property = node[propertyName].as<
T>();
479 typedef std::map<std::string, AliEmcalCorrectionComponent*(*)()>
map_type;
484 map_type::iterator it =
getMap()->find(s);
524 getMap()->insert(std::make_pair(s, &createT<T>));
Int_t fNcentBins
How many centrality bins (this member copied from AliAnalysisTaskEmcal)
void AdoptClusterContainer(AliClusterContainer *cont)
AliMCParticleContainer * GetMCParticleContainer(Int_t i=0) const
Bool_t fEsdMode
flag for ESD
AliParticleContainer * GetParticleContainer(Int_t i=0) const
AliEMCALGeometry * fGeom
! Geometry object
AliTrackContainer * GetTrackContainer(Int_t i=0) const
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 SetEMCALGeometry(AliEMCALGeometry *geometry)
AliVCaloCells * GetCaloCells() const
void SetRecoUtils(AliEMCALRecoUtils *ru)
virtual ~AliEmcalCorrectionComponent()
TList * GetOutputList() const
void SetMCEvent(AliMCEvent *mcevent)
virtual Bool_t UserNotify()
Container with name, TClonesArray and cuts for particles.
Registers EMCal correction components in the factory map.
AliEmcalCorrectionComponent * createT()
Template function for creating a new component. Used to register the component.
AliParticleContainer * GetParticleContainer(const char *name) const
void SetNcentralityBins(Int_t n)
virtual void UserCreateOutputObjects()
Int_t fCentBin
! Event centrality bin
AliClusterContainer * AddClusterContainer(const char *n)
AliVCaloCells * fCaloCells
! Pointer to CaloCells
Container for particles within the EMCAL framework.
void RemoveParticleContainer(Int_t i=0)
TObjArray fParticleCollArray
Particle/track collection array.
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.
TObjArray fClusterCollArray
Cluster collection array.
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)
AliMCParticleContainer * AddMCParticleContainer(const char *n)
YAML::Node fDefaultConfiguration
! Default YAML configuration
void AdoptParticleContainer(AliParticleContainer *cont)
AliParticleContainer * AddParticleContainer(const char *n)
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.
void AdoptMCParticleContainer(AliMCParticleContainer *cont)
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
void RemoveClusterContainer(Int_t i=0)
AliTrackContainer * GetTrackContainer(const char *name) const
AliClusterContainer * GetClusterContainer(const char *name) const
virtual ~AliEmcalCorrectionComponentFactory()
virtual Bool_t Initialize()
AliTrackContainer * AddTrackContainer(const char *n)
void SetDefaultConfiguration(YAML::Node &node)
Double_t fMinBinPt
Min pt in histograms.
Factory for correction components in the EMCal correction framework.
virtual Bool_t CheckIfRunChanged()
void SetIsESD(Bool_t isESD)
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...
Int_t fNbins
No. of pt bins.
AliClusterContainer * GetClusterContainer(Int_t i=0) const
void AdoptTrackContainer(AliTrackContainer *cont)
Container structure for EMCAL clusters.
Container for MC-true particles within the EMCAL framework.
TString fFilepass
Input data pass number.
AliMCParticleContainer * GetMCParticleContainer(const char *name) const
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.