AliPhysics  cda3415 (cda3415)
 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 "AliParticleContainer.h"
16 #include "AliMCParticleContainer.h"
17 #include "AliTrackContainer.h"
18 #include "AliClusterContainer.h"
19 #include "AliVCluster.h"
20 #include "AliEmcalTrackSelection.h"
21 
46  public:
51  enum BeamType {
52  kNA = -1,
53  kpp = 0,
54  kAA = 1,
55  kpA = 2
56  };
57 
64  kCaloCells = 0,
65  kCluster = 1,
66  kTrack = 2,
67  };
68 
69 #if !(defined(__CINT__) || defined(__MAKECINT__))
70  // Hidden from CINT since it cannot handle these maps well
72  std::map <std::string, AliVCluster::VCluUserDefEnergy_t> clusterEnergyTypeMap = {
73  {"kNonLinCorr", AliVCluster::kNonLinCorr },
74  {"kHadCorr", AliVCluster::kHadCorr },
75  {"kUserDefEnergy1", AliVCluster::kUserDefEnergy1 },
76  {"kUserDefEnergy2", AliVCluster::kUserDefEnergy2 }
77  };
78 
80  std::map <std::string, AliEmcalTrackSelection::ETrackFilterType_t> trackFilterTypeMap = {
81  {"kNoTrackFilter", AliEmcalTrackSelection::kNoTrackFilter },
82  {"kCustomTrackFilter", AliEmcalTrackSelection::kCustomTrackFilter },
83  {"kHybridTracks", AliEmcalTrackSelection::kHybridTracks },
84  {"kTPCOnlyTracks", AliEmcalTrackSelection::kTPCOnlyTracks }
85  };
86 #endif
87 
89  AliEmcalCorrectionTask(const char * name);
90  virtual ~AliEmcalCorrectionTask();
91 
92  // YAML
93  void Initialize();
94  // YAML options
96  void SetUserConfigurationFilename(std::string name) { fUserConfigurationFilename = name; }
99  // Write configuration to file
100  bool WriteConfigurationFile(std::string filename, bool userConfig = false);
101 
102  // Options
103  // Get
104  const TString & GetRunPeriod() const { return fRunPeriod; }
105  // Set
107  void SetRunPeriod(const char* runPeriod) { fRunPeriod = runPeriod; fRunPeriod.ToLower(); }
108  // Centrality options
110  virtual void SetNCentBins(Int_t n) { fNcentBins = n ; }
111  void SetCentRange(Double_t min, Double_t max) { fMinCent = min ; fMaxCent = max ; }
112 
120  const std::vector<AliEmcalCorrectionComponent *> & CorrectionComponents() { return fCorrectionComponents; }
121 
122  // Containers and cells
124  AliTrackContainer *AddTrackContainer(const char *n);
132  AliParticleContainer *GetParticleContainer(const char* name) const;
134  AliClusterContainer *GetClusterContainer(const char* name) const;
136  AliMCParticleContainer *GetMCParticleContainer(const char* name) const { return dynamic_cast<AliMCParticleContainer*>(GetParticleContainer(name)); }
138  AliTrackContainer *GetTrackContainer(const char* name) const { return dynamic_cast<AliTrackContainer*>(GetParticleContainer(name)) ; }
139  void RemoveParticleContainer(Int_t i=0) { fParticleCollArray.RemoveAt(i) ; }
140  void RemoveClusterContainer(Int_t i=0) { fClusterCollArray.RemoveAt(i) ; }
141  // Cells
142  AliEmcalCorrectionCellContainer *GetCellContainer(const std::string & cellsContainerName) const;
143 
144  // Utility functions
145  static std::string DetermineUseDefaultName(InputObject_t contType, bool esdMode, bool returnObjectType = false);
146  static AliVEvent * GetEvent(AliVEvent * inputEvent, bool isEmbedding = false);
147 
148  // Methods from AliAnalysisTaskSE
150  void UserExec(Option_t * option);
151  Bool_t UserNotify();
152 
153  // Aditional steering functions
154  virtual void ExecOnce();
155  virtual Bool_t Run();
156 
157  private:
158  AliEmcalCorrectionTask(const AliEmcalCorrectionTask &); // Not implemented
159  AliEmcalCorrectionTask &operator=(const AliEmcalCorrectionTask &); // Not implemented
160 
161  // Utility functions
162  // File utilities
163  static inline bool DoesFileExist(const std::string & filename);
164  void SetupConfigurationFilePath(std::string & filename, bool userFile = false);
165  // Cell utilities
167  // Container utilities
168  void CheckForContainerArray(AliEmcalContainer * cont, InputObject_t objectType);
169  // YAML configuration utilities
170  std::string GetInputFieldNameFromInputObjectType(InputObject_t inputObjectType);
171  bool CheckPossibleNamesForComponentName(std::string & name, std::set <std::string> & possibleComponents);
172  // General utilities
174 
175  // Retrieve objects in event
177 
178  // Execute component functions
180  void ExecOnceComponents();
181 
182  // Initialization functions
184  void DetermineComponentsToExecute(std::vector <std::string> & componentsToExecute);
186  void InitializeComponents();
187 
188  // Input objects (Cells, Clusters, Tracks) functions
189  void CreateInputObjects(InputObject_t inputObjectType);
190  void AddContainersToComponent(AliEmcalCorrectionComponent * component, InputObject_t inputObjectType);
191 
192 #if !(defined(__CINT__) || defined(__MAKECINT__))
193  // Hidden from CINT since it cannot handle YAML objects well
194  // Input objects
195  void SetupContainersFromInputNodes(InputObject_t inputObjectType, YAML::Node & userInputObjectNode, YAML::Node & defaultInputObjectNode, std::set <std::string> & requestedContainers);
196  // Cells
197  void SetupCellsInfo(std::string containerName, YAML::Node & userNode, YAML::Node & defaultNode);
198  // Containers
199  void SetupContainer(InputObject_t inputObjectType, std::string containerName, YAML::Node & userNode, YAML::Node & defaultNode);
200  AliEmcalContainer * AddContainer(InputObject_t contType, std::string & containerName, YAML::Node & userNode, YAML::Node & defaultNode);
201 
202  // Utilities
203  // YAML node dependent input objects utilties
204  void GetNodeForInputObjects(YAML::Node & inputNode, YAML::Node & nodeToRetrieveFrom, std::string & inputObjectName, bool requiredProperty);
205  // YAML node dependent initialization utlitiles
206  void GetPropertyNamesFromNode(const std::string & componentName, const YAML::Node & node, std::set <std::string> & propertyNames, const bool nodeRequired);
207 #endif
208 
209 #if !(defined(__CINT__) || defined(__MAKECINT__))
210  // Hidden from CINT since it cannot handle YAML objects well
211  YAML::Node fUserConfiguration;
213 #endif
214 
215  std::string fSuffix;
218 
221 
222  std::vector <std::string> fOrderedComponentsToExecute;
223  std::vector <AliEmcalCorrectionComponent *> fCorrectionComponents;
225 
226  bool fIsEsd;
241  AliEMCALGeometry *fGeom;
242 
245  std::vector <AliEmcalCorrectionCellContainer *> fCellCollArray;
246 
248 
250  ClassDef(AliEmcalCorrectionTask, 3); // EMCal correction task
252 };
253 
273  public:
275  fBranchName(""),
276  fName(""),
277  fIsEmbedding(""),
278  fCells(0)
279  {}
280  AliEmcalCorrectionCellContainer(std::string branchName, std::string name, std::string branchToCopyName, bool isEmbedded):
281  fBranchName(branchName),
282  fName(name),
283  fIsEmbedding(isEmbedded),
284  fCells(0)
285  {}
287 
289  std::string GetBranchName() const { return fBranchName; }
291  std::string GetName() const { return fName; }
293  bool GetIsEmbedding() const { return fIsEmbedding; }
295  AliVCaloCells * GetCells() const { return fCells; }
296 
298  void SetBranchName(std::string branchName) { fBranchName = branchName; }
300  void SetName(std::string name ) { fName = name; }
302  void SetIsEmbedding(bool isEmbedded) { fIsEmbedding = isEmbedded; }
304  void SetCells(AliVCaloCells * cells) { fCells = cells; }
305 
306  protected:
307  std::string fBranchName;
308  std::string fName;
310  AliVCaloCells *fCells;
311 
313  ClassDef(AliEmcalCorrectionCellContainer, 1); // EMCal correction cell container
315 };
316 
317 #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
Default YAML Configuration.
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
AliTrackContainer * AddTrackContainer(const char *n)
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.
std::string GetInputFieldNameFromInputObjectType(InputObject_t inputObjectType)
AliClusterContainer * GetClusterContainer(Int_t i=0) const
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.
void AdoptClusterContainer(AliClusterContainer *cont)
void SetupConfigurationFilePath(std::string &filename, bool userFile=false)
void UserExec(Option_t *option)
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.
void RemoveClusterContainer(Int_t i=0)
Container for particles within the EMCAL framework.
void SetUserConfigurationFilename(std::string name)
Set the path to the user configuration filename.
AliEmcalContainer * AddContainer(InputObject_t contType, std::string &containerName, YAML::Node &userNode, YAML::Node &defaultNode)
AliTrackContainer * GetTrackContainer(Int_t i=0) const
void AddContainersToComponent(AliEmcalCorrectionComponent *component, InputObject_t inputObjectType)
AliMCParticleContainer * GetMCParticleContainer(const char *name) const
AliVCaloCells * GetCells() const
Pointer to the actual CaloCells object.
bool fEventInitialized
If the event is initialized properly.
TString fCentEst
name of V0 centrality estimator
int Int_t
Definition: External.C:63
std::string fUserConfigurationFilename
! User YAML configruation filename
std::string fBranchName
Name of the cells branch.
const std::vector< AliEmcalCorrectionComponent * > & CorrectionComponents()
std::string fDefaultConfigurationString
Store the default YAML configuration as a string so that it can be streamed.
TString fRunPeriod
Run period (passed by user)
void SetCells(AliVCaloCells *cells)
Sets the Pointer to the actual CaloCells object.
Double_t fCent
! Event centrality
Base class for correction components in the EMCal correction framework.
void SetUseNewCentralityEstimation(Bool_t b)
BeamType
Switch for the beam type.
AliMCParticleContainer * AddMCParticleContainer(const char *n)
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.
void SetupContainersFromInputNodes(InputObject_t inputObjectType, YAML::Node &userInputObjectNode, YAML::Node &defaultInputObjectNode, std::set< std::string > &requestedContainers)
static std::string DetermineUseDefaultName(InputObject_t contType, bool esdMode, bool returnObjectType=false)
void SetupContainer(InputObject_t inputObjectType, std::string containerName, YAML::Node &userNode, YAML::Node &defaultNode)
bool WriteConfigurationFile(std::string filename, bool userConfig=false)
Bool_t fNeedEmcalGeom
whether or not the task needs the emcal geometry
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 CheckForContainerArray(AliEmcalContainer *cont, InputObject_t objectType)
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.
static AliVEvent * GetEvent(AliVEvent *inputEvent, bool isEmbedding=false)
AliMCParticleContainer * GetMCParticleContainer(Int_t i=0) const
void SetCentRange(Double_t min, Double_t max)
const TString & GetRunPeriod() const
void AdoptTrackContainer(AliTrackContainer *cont)
AliParticleContainer * GetParticleContainer(Int_t i=0) const
void AdoptParticleContainer(AliParticleContainer *cont)
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
YAML::Node fDefaultConfiguration
User 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)
AliClusterContainer * AddClusterContainer(const char *n)
std::vector< AliEmcalCorrectionCellContainer * > fCellCollArray
Cells collection array.
AliParticleContainer * AddParticleContainer(const char *n)
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)
InputObject_t
Type of input object to be created
BeamType fForceBeamType
forced beam type
void CreateInputObjects(InputObject_t inputObjectType)