AliPhysics  cdeda5a (cdeda5a)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalCorrectionTask.h
Go to the documentation of this file.
1 #ifndef ALIEMCALCORRECTIONTASK_H
2 #define ALIEMCALCORRECTIONTASK_H
3 
4 // CINT can't handle the yaml header!
5 #if !(defined(__CINT__) || defined(__MAKECINT__))
6 #include <yaml-cpp/yaml.h>
7 #endif
8 
11 class AliEMCALGeometry;
12 class AliVEvent;
13 
14 #include <AliAnalysisTaskSE.h>
15 #include <AliVCluster.h>
16 
17 #include "AliEmcalContainerUtils.h"
18 #include "AliParticleContainer.h"
19 #include "AliMCParticleContainer.h"
20 #include "AliTrackContainer.h"
21 #include "AliClusterContainer.h"
22 #include "AliEmcalTrackSelection.h"
23 
48  public:
53  enum BeamType {
54  kNA = -1,
55  kpp = 0,
56  kAA = 1,
57  kpA = 2
58  };
59 
60 #if !(defined(__CINT__) || defined(__MAKECINT__))
61  // Hidden from CINT since it cannot handle these maps well
63  std::map <std::string, AliVCluster::VCluUserDefEnergy_t> clusterEnergyTypeMap = {
64  {"kNonLinCorr", AliVCluster::kNonLinCorr },
65  {"kHadCorr", AliVCluster::kHadCorr },
66  {"kUserDefEnergy1", AliVCluster::kUserDefEnergy1 },
67  {"kUserDefEnergy2", AliVCluster::kUserDefEnergy2 }
68  };
69 
71  std::map <std::string, AliEmcalTrackSelection::ETrackFilterType_t> trackFilterTypeMap = {
72  {"kNoTrackFilter", AliEmcalTrackSelection::kNoTrackFilter },
73  {"kCustomTrackFilter", AliEmcalTrackSelection::kCustomTrackFilter },
74  {"kHybridTracks", AliEmcalTrackSelection::kHybridTracks },
75  {"kTPCOnlyTracks", AliEmcalTrackSelection::kTPCOnlyTracks }
76  };
77 #endif
78 
80  AliEmcalCorrectionTask(const char * name);
81  virtual ~AliEmcalCorrectionTask();
82 
83  // YAML
84  void Initialize();
85  // YAML options
87  void SetUserConfigurationFilename(std::string name) { fUserConfigurationFilename = name; }
90  // Write configuration to file
91  bool WriteConfigurationFile(std::string filename, bool userConfig = false);
92 
93  // Options
94  // Get
95  const TString & GetRunPeriod() const { return fRunPeriod; }
96  // Set
98  void SetRunPeriod(const char* runPeriod) { fRunPeriod = runPeriod; fRunPeriod.ToLower(); }
99  // Centrality options
101  virtual void SetNCentBins(Int_t n) { fNcentBins = n ; }
102  void SetCentRange(Double_t min, Double_t max) { fMinCent = min ; fMaxCent = max ; }
103 
111  const std::vector<AliEmcalCorrectionComponent *> & CorrectionComponents() { return fCorrectionComponents; }
112 
113  // Containers and cells
114  AliParticleContainer *AddParticleContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliParticleContainer>(n, fParticleCollArray); }
115  AliTrackContainer *AddTrackContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliTrackContainer>(n, fParticleCollArray); }
116  AliMCParticleContainer *AddMCParticleContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliMCParticleContainer>(n, fParticleCollArray); }
117  AliClusterContainer *AddClusterContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliClusterContainer>(n, fClusterCollArray); }
122  AliParticleContainer *GetParticleContainer(Int_t i=0) const { return AliEmcalContainerUtils::GetContainer<AliParticleContainer>(i, fParticleCollArray); }
123  AliParticleContainer *GetParticleContainer(const char* name) const { return AliEmcalContainerUtils::GetContainer<AliParticleContainer>(name, fParticleCollArray); }
124  AliClusterContainer *GetClusterContainer(Int_t i=0) const { return AliEmcalContainerUtils::GetContainer<AliClusterContainer>(i, fClusterCollArray); }
125  AliClusterContainer *GetClusterContainer(const char* name) const { return AliEmcalContainerUtils::GetContainer<AliClusterContainer>(name, fClusterCollArray); }
127  AliMCParticleContainer *GetMCParticleContainer(const char* name) const { return dynamic_cast<AliMCParticleContainer*>(GetParticleContainer(name)); }
129  AliTrackContainer *GetTrackContainer(const char* name) const { return dynamic_cast<AliTrackContainer*>(GetParticleContainer(name)) ; }
131  void RemoveClusterContainer(Int_t i=0) { fClusterCollArray.RemoveAt(i) ; }
132  // Cells
133  AliEmcalCorrectionCellContainer *GetCellContainer(const std::string & cellsContainerName) const;
134 
135  // Methods from AliAnalysisTaskSE
137  void UserExec(Option_t * option);
138  Bool_t UserNotify();
139 
140  // Aditional steering functions
141  virtual void ExecOnce();
142  virtual Bool_t Run();
143 
144  // Add Task
146 
147  private:
148  AliEmcalCorrectionTask(const AliEmcalCorrectionTask &); // Not implemented
149  AliEmcalCorrectionTask &operator=(const AliEmcalCorrectionTask &); // Not implemented
150 
151  // Utility functions
152  // File utilities
153  static inline bool DoesFileExist(const std::string & filename);
154  void SetupConfigurationFilePath(std::string & filename, bool userFile = false);
155  // Cell utilities
157  // Container utilities
158  void CheckForContainerArray(AliEmcalContainer * cont, AliEmcalContainerUtils::InputObject_t objectType);
159  // YAML configuration utilities
161  bool CheckPossibleNamesForComponentName(std::string & name, std::set <std::string> & possibleComponents);
162  // General utilities
165 
166  // Retrieve objects in event
168 
169  // Execute component functions
171  void ExecOnceComponents();
172 
173  // Initialization functions
175  void DetermineComponentsToExecute(std::vector <std::string> & componentsToExecute);
177  void InitializeComponents();
178 
179  // Input objects (Cells, Clusters, Tracks) functions
182 
183 #if !(defined(__CINT__) || defined(__MAKECINT__))
184  // Hidden from CINT since it cannot handle YAML objects well
185  // Input objects
186  void SetupContainersFromInputNodes(AliEmcalContainerUtils::InputObject_t inputObjectType, YAML::Node & userInputObjectNode, YAML::Node & defaultInputObjectNode, std::set <std::string> & requestedContainers);
187  // Cells
188  void SetupCellsInfo(std::string containerName, YAML::Node & userNode, YAML::Node & defaultNode);
189  // Containers
190  void SetupContainer(AliEmcalContainerUtils::InputObject_t inputObjectType, std::string containerName, YAML::Node & userNode, YAML::Node & defaultNode);
191  AliEmcalContainer * AddContainer(AliEmcalContainerUtils::InputObject_t contType, std::string & containerName, YAML::Node & userNode, YAML::Node & defaultNode);
192 
193  // Utilities
194  // YAML node dependent input objects utilties
195  void GetNodeForInputObjects(YAML::Node & inputNode, YAML::Node & nodeToRetrieveFrom, std::string & inputObjectName, bool requiredProperty);
196  // YAML node dependent initialization utlitiles
197  void GetPropertyNamesFromNode(const std::string & componentName, const YAML::Node & node, std::set <std::string> & propertyNames, const bool nodeRequired);
198 #endif
199 
200 #if !(defined(__CINT__) || defined(__MAKECINT__))
201  // Hidden from CINT since it cannot handle YAML objects well
202  YAML::Node fUserConfiguration;
204 #endif
205 
206  std::string fSuffix;
209 
212 
213  std::vector <std::string> fOrderedComponentsToExecute;
214  std::vector <AliEmcalCorrectionComponent *> fCorrectionComponents;
216 
217  bool fIsEsd;
232  AliEMCALGeometry *fGeom;
233 
236  std::vector <AliEmcalCorrectionCellContainer *> fCellCollArray;
237 
239 
241  ClassDef(AliEmcalCorrectionTask, 3); // EMCal correction task
243 };
244 
264  public:
266  fBranchName(""),
267  fName(""),
268  fIsEmbedding(""),
269  fCells(0)
270  {}
271  AliEmcalCorrectionCellContainer(std::string branchName, std::string name, std::string branchToCopyName, bool isEmbedded):
272  fBranchName(branchName),
273  fName(name),
274  fIsEmbedding(isEmbedded),
275  fCells(0)
276  {}
278 
280  std::string GetBranchName() const { return fBranchName; }
282  std::string GetName() const { return fName; }
284  bool GetIsEmbedding() const { return fIsEmbedding; }
286  AliVCaloCells * GetCells() const { return fCells; }
287 
289  void SetBranchName(std::string branchName) { fBranchName = branchName; }
291  void SetName(std::string name ) { fName = name; }
293  void SetIsEmbedding(bool isEmbedded) { fIsEmbedding = isEmbedded; }
295  void SetCells(AliVCaloCells * cells) { fCells = cells; }
296 
297  protected:
298  std::string fBranchName;
299  std::string fName;
301  AliVCaloCells *fCells;
302 
304  ClassDef(AliEmcalCorrectionCellContainer, 1); // EMCal correction cell container
306 };
307 
308 #endif /* ALIEMCALCORRECTIONTASK_H */
Int_t fNcentBins
how many centrality bins
void SetBranchName(std::string branchName)
Set the name of the cells branch (NOT the same as the name!)
std::string fSuffix
Suffix of the Correction Task (used to select components)
Steering task for the EMCal correction framework.
bool fIsEmbedding
Whether the cells should be taken from an external file (embedded)
AliEMCALGeometry * fGeom
! Emcal geometry
const char * filename
Definition: TestFCM.C:1
std::map< std::string, AliVCluster::VCluUserDefEnergy_t > clusterEnergyTypeMap
Relates string to the cluster energy enumeration for YAML configuration.
static bool DoesFileExist(const std::string &filename)
std::string GetName() const
Get the name of the cells object (NOT the same as the branch!)
double Double_t
Definition: External.C:58
virtual void SetNCentBins(Int_t n)
AliTrackContainer * GetTrackContainer(const char *name) const
AliVCaloCells * fCells
! The actual cells object associated with this infomration
std::vector< std::string > fOrderedComponentsToExecute
Ordered set of components to execute.
bool CheckPossibleNamesForComponentName(std::string &name, std::set< std::string > &possibleComponents)
std::vector< AliEmcalCorrectionComponent * > fCorrectionComponents
Contains the correction components.
Container with name, TClonesArray and cuts for particles.
std::string GetInputFieldNameFromInputObjectType(AliEmcalContainerUtils::InputObject_t inputObjectType)
void AdoptClusterContainer(AliClusterContainer *cont)
void SetupConfigurationFilePath(std::string &filename, bool userFile=false)
void UserExec(Option_t *option)
YAML::Node fUserConfiguration
! User YAML Configuration
void SetDefaultConfigurationFilename(std::string name)
Set the path to the default configuration filename (Expert use only! The user should set the user con...
Double_t fMaxCent
max centrality for event selection
Double_t fVertex[3]
! Event vertex
AliEmcalCorrectionTask & operator=(const AliEmcalCorrectionTask &)
void DetermineComponentsToExecute(std::vector< std::string > &componentsToExecute)
TList * fOutput
! Output for histograms
Wrapper around cells objects for the EMCal Correction Task.
bool fConfigurationInitialized
True if the YAML configuration files are initialized.
AliEmcalContainer * AddContainer(AliEmcalContainerUtils::InputObject_t contType, std::string &containerName, YAML::Node &userNode, YAML::Node &defaultNode)
void RemoveClusterContainer(Int_t i=0)
void CheckForContainerArray(AliEmcalContainer *cont, AliEmcalContainerUtils::InputObject_t objectType)
AliParticleContainer * GetParticleContainer(Int_t i=0) const
Container for particles within the EMCAL framework.
void SetUserConfigurationFilename(std::string name)
Set the path to the user configuration filename.
AliTrackContainer * GetTrackContainer(Int_t i=0) const
AliMCParticleContainer * GetMCParticleContainer(const char *name) const
AliVCaloCells * GetCells() const
Pointer to the actual CaloCells object.
bool fEventInitialized
If the event is initialized properly.
void AddContainersToComponent(AliEmcalCorrectionComponent *component, AliEmcalContainerUtils::InputObject_t inputObjectType)
TString fCentEst
name of V0 centrality estimator
AliTrackContainer * AddTrackContainer(const char *n)
int Int_t
Definition: External.C:63
std::string fUserConfigurationFilename
! User YAML configruation filename
std::string fBranchName
Name of the cells branch.
AliClusterContainer * GetClusterContainer(Int_t i=0) const
const std::vector< AliEmcalCorrectionComponent * > & CorrectionComponents()
std::string fDefaultConfigurationString
Store the default YAML configuration as a string so that it can be streamed.
AliClusterContainer * GetClusterContainer(const char *name) const
TString fRunPeriod
Run period (passed by user)
static AliEmcalCorrectionTask * AddTaskEmcalCorrectionTask(TString suffix="")
void SetCells(AliVCaloCells *cells)
Sets the Pointer to the actual CaloCells object.
Double_t fCent
! Event centrality
void CreateInputObjects(AliEmcalContainerUtils::InputObject_t inputObjectType)
Base class for correction components in the EMCal correction framework.
void SetUseNewCentralityEstimation(Bool_t b)
BeamType
Switch for the beam type.
AliEmcalCorrectionCellContainer(std::string branchName, std::string name, std::string branchToCopyName, bool isEmbedded)
std::map< std::string, AliEmcalTrackSelection::ETrackFilterType_t > trackFilterTypeMap
Relates string to the track filter enumeration for YAML configuration.
bool WriteConfigurationFile(std::string filename, bool userConfig=false)
Bool_t fNeedEmcalGeom
whether or not the task needs the emcal geometry
InputObject_t
Type of input object to be created
std::string GetBranchName() const
Get the name of the cells branch (NOT the same as the name!)
void SetCellsObjectInCellContainerBasedOnProperties(AliEmcalCorrectionCellContainer *cellContainer)
Bool_t fUseNewCentralityEstimation
Use new centrality estimation (for 2015 data)
bool GetIsEmbedding() const
True if the cells are located in the event that is being embedded.
void PrintRequestedContainersInformation(AliEmcalContainerUtils::InputObject_t inputObjectType)
AliEmcalCorrectionCellContainer * GetCellContainer(const std::string &cellsContainerName) const
std::string fDefaultConfigurationFilename
! Default YAML configuration filename
void GetNodeForInputObjects(YAML::Node &inputNode, YAML::Node &nodeToRetrieveFrom, std::string &inputObjectName, bool requiredProperty)
TObjArray fParticleCollArray
Particle/track collection array.
TObjArray fClusterCollArray
Cluster collection array.
AliClusterContainer * AddClusterContainer(const char *n)
AliMCParticleContainer * GetMCParticleContainer(Int_t i=0) const
void SetCentRange(Double_t min, Double_t max)
void SetForceBeamType(BeamType f)
const TString & GetRunPeriod() const
void AdoptTrackContainer(AliTrackContainer *cont)
void AdoptParticleContainer(AliParticleContainer *cont)
AliParticleContainer * AddParticleContainer(const char *n)
std::string fName
Name of the cells object.
void SetIsEmbedding(bool isEmbedded)
Set to true if the cells are located in the event that is being embedded.
BeamType fBeamType
! Event beam type
const char Option_t
Definition: External.C:48
void SetupContainersFromInputNodes(AliEmcalContainerUtils::InputObject_t inputObjectType, YAML::Node &userInputObjectNode, YAML::Node &defaultInputObjectNode, std::set< std::string > &requestedContainers)
YAML::Node fDefaultConfiguration
! Default YAML Configuration
void SetupCellsInfo(std::string containerName, YAML::Node &userNode, YAML::Node &defaultNode)
Int_t fNVertCont
! Event vertex number of contributors
void RemoveParticleContainer(Int_t i=0)
void SetName(std::string name)
Set the name of the cells object (NOT the same as the branch!)
bool Bool_t
Definition: External.C:53
Int_t fCentBin
! Event centrality bin
void AdoptMCParticleContainer(AliMCParticleContainer *cont)
Double_t fMinCent
min centrality for event selection
void SetRunPeriod(const char *runPeriod)
std::vector< AliEmcalCorrectionCellContainer * > fCellCollArray
Cells collection array.
void SetupContainer(AliEmcalContainerUtils::InputObject_t inputObjectType, std::string containerName, YAML::Node &userNode, YAML::Node &defaultNode)
Container structure for EMCAL clusters.
Container for MC-true particles within the EMCAL framework.
std::string fUserConfigurationString
Store the user YAML configuration as a string so that it can be streamed.
void GetPropertyNamesFromNode(const std::string &componentName, const YAML::Node &node, std::set< std::string > &propertyNames, const bool nodeRequired)
AliParticleContainer * GetParticleContainer(const char *name) const
AliMCParticleContainer * AddMCParticleContainer(const char *n)
BeamType fForceBeamType
forced beam type