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"
109 #if !(defined(__CINT__) || defined(__MAKECINT__))
115 template<
typename T>
bool GetProperty(std::string propertyName,
T & property,
bool requiredProperty =
true, std::string correctionName =
"");
118 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 =
"");
124 #if !(defined(__CINT__) || defined(__MAKECINT__))
125 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);
126 template<
typename T>
static bool GetPropertyFromNode(
const YAML::Node & node, std::string propertyName,
T & property);
128 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);
129 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);
169 #if !(defined(__CINT__) || defined(__MAKECINT__))
186 if (correctionName ==
"")
188 correctionName = GetName();
213 std::size_t prefixStringLocation = correctionName.find(
"AliEmcalCorrection");
214 if (prefixStringLocation != std::string::npos)
217 correctionName.erase(prefixStringLocation, prefixStringLocation + 18);
220 bool setProperty =
false;
224 if (userConfiguration.IsNull() !=
true)
226 AliDebugClass(2,
"Looking for parameter in user configuration");
227 YAML::Node sharedParameters = userConfiguration[
"sharedParameters"];
232 if (setProperty !=
true)
234 AliDebugClass(2,
"Looking for parameter in default configuration");
235 YAML::Node sharedParameters = defaultConfiguration[
"sharedParameters"];
240 if (setProperty !=
true && requiredProperty ==
true)
242 std::stringstream message;
243 message <<
"Failed to retrieve property \""
244 << (correctionName !=
"" ? correctionName +
":" :
"")
245 << propertyName <<
"\" from default config!" << std::endl;
246 AliFatalClass(message.str().c_str());
282 std::stringstream tempMessage;
284 bool returnValue =
false;
289 tempMessage <<
"Went too many levels of recursion. Bailing out on \"" << correctionName <<
":" << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
290 AliDebugClass(2, TString::Format(
"%s", tempMessage.str().c_str()));
298 tempMessage <<
"Retreiving property \""
299 << (correctionName !=
"" ? correctionName +
":" :
"")
300 << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
301 AliDebugClass(1, TString::Format(
"%s", tempMessage.str().c_str()));
304 if (node.IsDefined() ==
true)
307 if (node[propertyName])
309 bool isShared =
false;
312 std::string sharedValueName =
"";
314 if (std::is_arithmetic<T>::value || std::is_same<T, std::string>::value || std::is_same<T, bool>::value)
317 sharedValueName = node[propertyName].as<std::string>();
323 tempMessage <<
"property \""
324 << (nodesDeep > 0 ? correctionName +
":" :
"")
326 <<
"\" using " << ( isShared ?
"\"sharedParameters:" + sharedValueName +
"\" in " :
"" )
327 <<
"values from the " << configurationType
328 <<
" configuration at level " << nodesDeep;
330 AliDebugClass(2, TString::Format(
"Retrieveing %s", tempMessage.str().c_str()));
332 bool retrievalResult =
false;
333 if (isShared ==
true)
343 if (retrievalResult ==
true)
347 AliDebugClassStream(2) <<
"Succeeded in retrieveing " << tempMessage.str() << std::endl;
353 if (configurationType ==
"default")
355 AliFatalClass(TString::Format(
"Failed to retrieve %s", tempMessage.str().c_str()));
359 AliDebugClass(2, TString::Format(
"Failed to retrieve %s", tempMessage.str().c_str()));
368 YAML::Node deeperNode = node[correctionName];
370 AliDebugClass(2, TString::Format(
"Going a node deeper with \"%s\" to level %i", correctionName.c_str(), nodesDeep));
371 returnValue =
GetPropertyFromNodes(deeperNode, sharedParametersNode, propertyName, property, correctionName, configurationType, nodesDeep);
374 if (returnValue ==
false)
377 std::size_t splitLocation = correctionName.find(
"_");
380 if (splitLocation != std::string::npos && nodesDeep == 1)
383 std::string subCorrectionName = correctionName.substr(0, splitLocation);
384 AliDebugClass(2, TString::Format(
"Attempting to retrieve property \"%s\" from base correction \"%s\" at level %i", propertyName.c_str(), subCorrectionName.c_str(), nodesDeep));
387 YAML::Node subCorrectionNode = node[subCorrectionName];
388 returnValue =
GetPropertyFromNodes(subCorrectionNode, sharedParametersNode, propertyName, property, subCorrectionName, configurationType, nodesDeep);
396 tempMessage <<
"Node is undefined for \""
397 << (correctionName !=
"" ? correctionName +
":" :
"")
398 << propertyName <<
"\" from " << configurationType <<
" config at level " << nodesDeep;
399 AliDebugClass(2, TString::Format(
"%s", tempMessage.str().c_str()));
418 typename std::enable_if<std::is_arithmetic<T>::value || std::is_same<T, std::string>::value || std::is_same<T, bool>::value>::type
422 tempMessage <<
" with value \"" <<
property <<
"\"";
434 typename std::enable_if<!std::is_arithmetic<T>::value && !std::is_same<T, std::string>::value && !std::is_same<T, bool>::value>::type
438 tempMessage <<
" with a value that cannot be trivially printed";
451 if (node[propertyName])
453 property = node[propertyName].as<
T>();
488 typedef std::map<std::string, AliEmcalCorrectionComponent*(*)()>
map_type;
493 map_type::iterator it =
getMap()->find(s);
533 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
Class to manage the current event for correction components in the EMCal correction framework...
void SetRecoUtils(AliEMCALRecoUtils *ru)
virtual ~AliEmcalCorrectionComponent()
void SetInputEvent(AliVEvent *inputEvent)
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
void SetUsingInputEvent(bool b=true)
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)
void SetUseEmbeddingEvent(bool b=true)
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.
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.
void SetVertex(Double_t *vertex)
void SetInputEvent(AliVEvent *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.
AliEmcalCorrectionEventManager fEventManager
Minimal task which inherits from AliAnalysisTaskSE and manages access to the event.
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.