AliPhysics  b330fab (b330fab)
 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 <iosfwd>
15 
16 #include <AliAnalysisTaskSE.h>
17 #include <AliVCluster.h>
18 
19 #include "AliEmcalContainerUtils.h"
20 #include "AliParticleContainer.h"
21 #include "AliMCParticleContainer.h"
22 #include "AliTrackContainer.h"
23 #include "AliClusterContainer.h"
24 #include "AliEmcalTrackSelection.h"
25 
50  public:
55  enum BeamType {
56  kNA = -1,
57  kpp = 0,
58  kAA = 1,
59  kpA = 2
60  };
61 
63  static const std::map <std::string, AliVCluster::VCluUserDefEnergy_t> fgkClusterEnergyTypeMap;
64 
66  static const std::map <std::string, AliEmcalTrackSelection::ETrackFilterType_t> fgkTrackFilterTypeMap;
67 
69  AliEmcalCorrectionTask(const char * name);
70  // Implemented using copy-and-swap mechanism
73  friend void swap(AliEmcalCorrectionTask & first, AliEmcalCorrectionTask & second);
75  virtual ~AliEmcalCorrectionTask();
76 
77  // YAML
78  void Initialize();
79  // YAML options
81  void SetUserConfigurationFilename(std::string name) { fUserConfigurationFilename = name; }
84  // Print the actual configuration string
85  std::ostream & PrintConfigurationString(std::ostream & in, bool userConfig = false) const;
86  // Write configuration to file
87  bool WriteConfigurationFile(std::string filename, bool userConfig = false) const;
88  // Compare configurations
89  bool CompareToStoredConfiguration(std::string filename, bool userConfig = false) const;
90 
91  // Options
92  // Printing
93  friend std::ostream & operator<<(std::ostream &in, const AliEmcalCorrectionTask &myTask);
94  void Print(Option_t* opt = "") const;
95  std::ostream & Print(std::ostream &in) const;
96  std::string toString(bool includeYAMLConfigurationInfo = false) const;
97  // Set
100  // Centrality options
102  void SetCentralityEstimator(const char * c) { fCentEst = c ; }
103  virtual void SetNCentBins(Int_t n) { fNcentBins = n ; }
104  void SetCentRange(Double_t min, Double_t max) { fMinCent = min ; fMaxCent = max ; }
105 
113  const std::vector<AliEmcalCorrectionComponent *> & CorrectionComponents() { return fCorrectionComponents; }
114 
115  // Containers and cells
116  AliParticleContainer *AddParticleContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliParticleContainer>(n, fParticleCollArray); }
117  AliTrackContainer *AddTrackContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliTrackContainer>(n, fParticleCollArray); }
118  AliMCParticleContainer *AddMCParticleContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliMCParticleContainer>(n, fParticleCollArray); }
119  AliClusterContainer *AddClusterContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliClusterContainer>(n, fClusterCollArray); }
124  AliParticleContainer *GetParticleContainer(Int_t i=0) const { return AliEmcalContainerUtils::GetContainer<AliParticleContainer>(i, fParticleCollArray); }
125  AliParticleContainer *GetParticleContainer(const char* name) const { return AliEmcalContainerUtils::GetContainer<AliParticleContainer>(name, fParticleCollArray); }
126  AliClusterContainer *GetClusterContainer(Int_t i=0) const { return AliEmcalContainerUtils::GetContainer<AliClusterContainer>(i, fClusterCollArray); }
127  AliClusterContainer *GetClusterContainer(const char* name) const { return AliEmcalContainerUtils::GetContainer<AliClusterContainer>(name, fClusterCollArray); }
129  AliMCParticleContainer *GetMCParticleContainer(const char* name) const { return dynamic_cast<AliMCParticleContainer*>(GetParticleContainer(name)); }
131  AliTrackContainer *GetTrackContainer(const char* name) const { return dynamic_cast<AliTrackContainer*>(GetParticleContainer(name)) ; }
133  void RemoveClusterContainer(Int_t i=0) { fClusterCollArray.RemoveAt(i) ; }
134  // Cells
135  AliEmcalCorrectionCellContainer *GetCellContainer(const std::string & cellsContainerName) const;
136 
137  // Methods from AliAnalysisTaskSE
139  void UserExec(Option_t * option);
140  Bool_t UserNotify();
141 
142  // Aditional steering functions
143  virtual void ExecOnce();
144  virtual Bool_t Run();
145 
146  // Add Task
148 
149  private:
150  // Utility functions
151  // File utilities
152  static inline bool DoesFileExist(const std::string & filename);
153  void SetupConfigurationFilePath(std::string & filename, bool userFile = false);
154  // Cell utilities
156  // Container utilities
157  void CheckForContainerArray(AliEmcalContainer * cont, AliEmcalContainerUtils::InputObject_t objectType);
158  // YAML configuration utilities
160  bool CheckPossibleNamesForComponentName(std::string & name, std::set <std::string> & possibleComponents);
161  // General utilities
162  BeamType GetBeamType() const;
163  void PrintRequestedContainersInformation(AliEmcalContainerUtils::InputObject_t inputObjectType, std::ostream & stream) const;
164 
165  // Retrieve objects in event
167 
168  // Execute component functions
170  void ExecOnceComponents();
171 
172  // Initialization functions
174  void DetermineComponentsToExecute(std::vector <std::string> & componentsToExecute);
176  void InitializeComponents();
177 
178  // Input objects (Cells, Clusters, Tracks) functions
180  void AddContainersToComponent(AliEmcalCorrectionComponent * component, AliEmcalContainerUtils::InputObject_t inputObjectType, bool checkObjectExists = false);
181 
182 #if !(defined(__CINT__) || defined(__MAKECINT__))
183  // Hidden from CINT since it cannot handle YAML objects well
184  // Input objects
185  void SetupContainersFromInputNodes(AliEmcalContainerUtils::InputObject_t inputObjectType, YAML::Node & userInputObjectNode, YAML::Node & defaultInputObjectNode, std::set <std::string> & requestedContainers);
186  // Cells
187  void SetupCellsInfo(std::string containerName, YAML::Node & userNode, YAML::Node & defaultNode);
188  // Containers
189  void SetupContainer(AliEmcalContainerUtils::InputObject_t inputObjectType, std::string containerName, YAML::Node & userNode, YAML::Node & defaultNode);
190  AliEmcalContainer * AddContainer(AliEmcalContainerUtils::InputObject_t contType, std::string & containerName, YAML::Node & userNode, YAML::Node & defaultNode);
191 
192  // Utilities
193  // YAML node dependent input objects utilties
194  void GetNodeForInputObjects(YAML::Node & inputNode, YAML::Node & nodeToRetrieveFrom, std::string & inputObjectName, bool requiredProperty);
195  // YAML node dependent initialization utlitiles
196  void GetPropertyNamesFromNode(const std::string & componentName, const YAML::Node & node, std::set <std::string> & propertyNames, const bool nodeRequired);
197 #endif
198 
199 #if !(defined(__CINT__) || defined(__MAKECINT__))
200  // Hidden from CINT since it cannot handle YAML objects well
201  YAML::Node fUserConfiguration;
203 #endif
204 
205  std::string fSuffix;
208 
211 
212  std::vector <std::string> fOrderedComponentsToExecute;
213  std::vector <AliEmcalCorrectionComponent *> fCorrectionComponents;
215 
216  bool fIsEsd;
230  AliEMCALGeometry *fGeom;
231 
234  std::vector <AliEmcalCorrectionCellContainer *> fCellCollArray;
235 
237 
239  ClassDef(AliEmcalCorrectionTask, 4); // EMCal correction task
241 };
242 
262  public:
264  fBranchName(""),
265  fName(""),
266  fIsEmbedding(""),
267  fCells(0)
268  {}
269  AliEmcalCorrectionCellContainer(std::string branchName, std::string name, std::string branchToCopyName, bool isEmbedded):
270  fBranchName(branchName),
271  fName(name),
272  fIsEmbedding(isEmbedded),
273  fCells(0)
274  {}
276 
278  std::string GetBranchName() const { return fBranchName; }
280  std::string GetName() const { return fName; }
282  bool GetIsEmbedding() const { return fIsEmbedding; }
284  AliVCaloCells * GetCells() const { return fCells; }
285 
287  void SetBranchName(std::string branchName) { fBranchName = branchName; }
289  void SetName(std::string name ) { fName = name; }
291  void SetIsEmbedding(bool isEmbedded) { fIsEmbedding = isEmbedded; }
293  void SetCells(AliVCaloCells * cells) { fCells = cells; }
294 
295  protected:
296  std::string fBranchName;
297  std::string fName;
299  AliVCaloCells *fCells;
300 
302  ClassDef(AliEmcalCorrectionCellContainer, 1); // EMCal correction cell container
304 };
305 
306 #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)
void PrintRequestedContainersInformation(AliEmcalContainerUtils::InputObject_t inputObjectType, std::ostream &stream) const
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
static const std::map< std::string, AliVCluster::VCluUserDefEnergy_t > fgkClusterEnergyTypeMap
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
void SetCentralityEstimator(const char *c)
AliVCaloCells * fCells
! The actual cells object associated with this infomration
std::vector< std::string > fOrderedComponentsToExecute
Ordered set of components to execute.
bool WriteConfigurationFile(std::string filename, bool userConfig=false) 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.
std::string GetInputFieldNameFromInputObjectType(AliEmcalContainerUtils::InputObject_t inputObjectType)
void AdoptClusterContainer(AliClusterContainer *cont)
void SetupConfigurationFilePath(std::string &filename, bool userFile=false)
void UserExec(Option_t *option)
AliEmcalCorrectionTask & operator=(AliEmcalCorrectionTask other)
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
TCanvas * c
Definition: TestFitELoss.C:172
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
friend void swap(AliEmcalCorrectionTask &first, AliEmcalCorrectionTask &second)
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
bool CompareToStoredConfiguration(std::string filename, bool userConfig=false) 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
AliTrackContainer * AddTrackContainer(const char *n)
int Int_t
Definition: External.C:63
std::string fUserConfigurationFilename
! User YAML configruation filename
InputObject_t
Type of input object to be created
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
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)
friend std::ostream & operator<<(std::ostream &in, const AliEmcalCorrectionTask &myTask)
Bool_t fNeedEmcalGeom
whether or not the task needs the emcal geometry
static const std::map< std::string, AliEmcalTrackSelection::ETrackFilterType_t > fgkTrackFilterTypeMap
Relates string to the track filter enumeration for YAML configuration.
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.
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)
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
std::string toString(bool includeYAMLConfigurationInfo=false) const
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 Print(Option_t *opt="") const
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
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.
void AddContainersToComponent(AliEmcalCorrectionComponent *component, AliEmcalContainerUtils::InputObject_t inputObjectType, bool checkObjectExists=false)
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)
std::ostream & PrintConfigurationString(std::ostream &in, bool userConfig=false) const
AliParticleContainer * GetParticleContainer(const char *name) const
AliMCParticleContainer * AddMCParticleContainer(const char *n)
BeamType fForceBeamType
forced beam type