AliPhysics  068200c (068200c)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalCorrectionComponent.h
Go to the documentation of this file.
1 #ifndef ALIEMCALCORRECTIONCOMPONENT_H
2 #define ALIEMCALCORRECTIONCOMPONENT_H
3 
4 #include <map>
5 #include <string>
6 
7 class TH1F;
8 #include <TNamed.h>
9 
10 class AliMCEvent;
11 class AliEMCALRecoUtils;
12 class AliVCaloCells;
13 class AliVTrack;
14 class AliVCluster;
15 class AliVEvent;
16 #include <AliLog.h>
17 #include "AliYAMLConfiguration.h"
18 #include "AliEmcalContainerUtils.h"
19 #include "AliParticleContainer.h"
20 #include "AliMCParticleContainer.h"
21 #include "AliTrackContainer.h"
22 #include "AliClusterContainer.h"
23 #include "AliEMCALGeometry.h"
25 
44  public:
46  AliEmcalCorrectionComponent(const char * name);
48 
49  // Virtual functions to be overloaded
50  virtual Bool_t Initialize();
51  virtual void UserCreateOutputObjects();
52  virtual void ExecOnce();
53  virtual Bool_t Run();
54  virtual Bool_t UserNotify();
55  virtual Bool_t CheckIfRunChanged();
56 
57  void GetEtaPhiDiff(const AliVTrack *t, const AliVCluster *v, Double_t &phidiff, Double_t &etadiff);
58  void UpdateCells();
59  void GetPass();
60  void FillCellQA(TH1F* h);
62 
63  // Containers and cells
64  AliParticleContainer *AddParticleContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliParticleContainer>(n, fParticleCollArray); }
65  AliTrackContainer *AddTrackContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliTrackContainer>(n, fParticleCollArray); }
66  AliMCParticleContainer *AddMCParticleContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliMCParticleContainer>(n, fParticleCollArray); }
67  AliClusterContainer *AddClusterContainer(const char *n) { return AliEmcalContainerUtils::AddContainer<AliClusterContainer>(n, fClusterCollArray); }
72  AliParticleContainer *GetParticleContainer(Int_t i=0) const { return AliEmcalContainerUtils::GetContainer<AliParticleContainer>(i, fParticleCollArray); }
73  AliParticleContainer *GetParticleContainer(const char* name) const { return AliEmcalContainerUtils::GetContainer<AliParticleContainer>(name, fParticleCollArray); }
74  AliClusterContainer *GetClusterContainer(Int_t i=0) const { return AliEmcalContainerUtils::GetContainer<AliClusterContainer>(i, fClusterCollArray); }
75  AliClusterContainer *GetClusterContainer(const char* name) const { return AliEmcalContainerUtils::GetContainer<AliClusterContainer>(name, fClusterCollArray); }
77  AliMCParticleContainer *GetMCParticleContainer(const char* name) const { return dynamic_cast<AliMCParticleContainer*>(GetParticleContainer(name)); }
79  AliTrackContainer *GetTrackContainer(const char* name) const { return dynamic_cast<AliTrackContainer*>(GetParticleContainer(name)) ; }
80  void RemoveParticleContainer(Int_t i=0) { fParticleCollArray.RemoveAt(i) ; }
81  void RemoveClusterContainer(Int_t i=0) { fClusterCollArray.RemoveAt(i) ; }
82  AliVCaloCells *GetCaloCells() const { return fCaloCells; }
83  TList *GetOutputList() const { return fOutput; }
84 
85  void SetCaloCells(AliVCaloCells * cells) { fCaloCells = cells; }
86  void SetRecoUtils(AliEMCALRecoUtils *ru) { fRecoUtils = ru; }
87 
88  void SetInputEvent(AliVEvent * event) { fEventManager.SetInputEvent(event); }
89  void SetMCEvent(AliMCEvent * mcevent) { fMCEvent = mcevent; }
97 
98  void SetEMCALGeometry(AliEMCALGeometry * geometry ) { fGeom = geometry; }
99  void SetCentralityBin(Int_t bin) { fCentBin = bin; }
100  void SetCentrality(Double_t cent) { fCent = cent; }
102  void SetVertex(Double_t * vertex) { fVertex[0] = vertex[0]; fVertex[1] = vertex[1]; fVertex[2] = vertex[2]; }
103  void SetIsESD(Bool_t isESD) {fEsdMode = isESD; }
104 
107 
109  template<typename T> bool GetProperty(std::string propertyName, T & property, bool requiredProperty = true, std::string correctionName = "");
110  protected:
118  AliMCEvent *fMCEvent;
126  AliEMCALGeometry *fGeom;
131  AliVCaloCells *fCaloCells;
132  AliEMCALRecoUtils *fRecoUtils;
134 
136 
137  private:
138  AliEmcalCorrectionComponent(const AliEmcalCorrectionComponent &); // Not implemented
140 
142  ClassDef(AliEmcalCorrectionComponent, 4); // EMCal correction component
144 };
145 
158 template<typename T>
159 bool AliEmcalCorrectionComponent::GetProperty(std::string propertyName, T & property, bool requiredProperty, std::string correctionName)
160 {
161  // Get proper correction name
162  if (correctionName == "")
163  {
164  correctionName = GetName();
165  }
166  // Add the correction name as a prefix of the property
167  return fYAMLConfig.GetProperty(std::vector<std::string>{correctionName, propertyName}, property, requiredProperty);
168 }
169 
188 template<typename T> AliEmcalCorrectionComponent * createT() { return new T; }
190 
191 // Factory to create and keep track of new components
193 {
194  public:
196 
197  typedef std::map<std::string, AliEmcalCorrectionComponent*(*)()> map_type;
198 
200  static AliEmcalCorrectionComponent * createInstance(std::string const& s)
201  {
202  map_type::iterator it = getMap()->find(s);
203  if(it == getMap()->end())
204  return 0;
205  // Initializes the function with empty arguments (?)
206  return it->second();
207  }
208 
209  protected:
211  static map_type * getMap() {
212  // We never delete the map (until program termination) because we cannot guarantee
213  // correct destruction order
214  if(!componentMap) { componentMap = new map_type; }
215  return componentMap;
216  }
217 
218  private:
221 };
222 
235 template<typename T>
237 {
238  public:
240  RegisterCorrectionComponent(std::string const& s)
241  {
242  getMap()->insert(std::make_pair(s, &createT<T>));
243  }
244 };
245 
246 #endif /* ALIEMCALCORRECTIONCOMPONENT_H */
Int_t fNcentBins
How many centrality bins (this member copied from AliAnalysisTaskEmcal)
void AdoptClusterContainer(AliClusterContainer *cont)
AliMCParticleContainer * GetMCParticleContainer(Int_t i=0) const
AliParticleContainer * GetParticleContainer(Int_t i=0) const
AliEMCALGeometry * fGeom
! Geometry object
double Double_t
Definition: External.C:58
AliTrackContainer * GetTrackContainer(Int_t i=0) const
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)
void SetMCEvent(AliMCEvent *mcevent)
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
Int_t fCentBin
! Event centrality bin
AliClusterContainer * AddClusterContainer(const char *n)
AliVCaloCells * fCaloCells
! Pointer to CaloCells
Container for particles within the EMCAL framework.
TObjArray fParticleCollArray
Particle/track collection array.
UShort_t T(UShort_t m, UShort_t t)
Definition: RingBits.C:60
AliEMCALRecoUtils * fRecoUtils
Pointer to RecoUtils.
bool GetProperty(std::vector< std::string > propertyPath, const std::string &propertyName, T &property, const bool requiredProperty) const
TObjArray fClusterCollArray
Cluster collection array.
void SetYAMLConfiguration(PWG::Tools::AliYAMLConfiguration config)
Set YAML Configuration.
int Int_t
Definition: External.C:63
Base class for correction components in the EMCal correction framework.
AliMCParticleContainer * AddMCParticleContainer(const char *n)
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
Double_t fVertex[3]
! Event vertex
TString fBasePath
Base folder path to get root files.
Double_t fMaxBinPt
Max pt in histograms.
TList * fOutput
! List of output histograms
AliEmcalCorrectionComponent & operator=(const AliEmcalCorrectionComponent &)
Bool_t fCreateHisto
Flag to make some basic histograms.
Bool_t fGetPassFromFileName
Get fFilepass from file name.
Double_t fCent
! Event centrality
AliTrackContainer * GetTrackContainer(const char *name) const
AliClusterContainer * GetClusterContainer(const char *name) const
AliTrackContainer * AddTrackContainer(const char *n)
Double_t fMinBinPt
Min pt in histograms.
AliEmcalCorrectionEventManager fEventManager
Minimal task which inherits from AliAnalysisTaskSE and manages access to the event.
PWG::Tools::AliYAMLConfiguration fYAMLConfig
Contains the YAML configuration used to configure the component.
Factory for correction components in the EMCal correction framework.
void SetCaloCells(AliVCaloCells *cells)
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...
bool Bool_t
Definition: External.C:53
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.
Bool_t fIsEmbedded
Trigger, embedded signal.