AliPhysics  64f4410 (64f4410)
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 <AliEMCALGeometry.h>
18 #include "AliYAMLConfiguration.h"
19 #include "AliEmcalContainerUtils.h"
20 #include "AliParticleContainer.h"
21 #include "AliMCParticleContainer.h"
22 #include "AliTrackContainer.h"
23 #include "AliClusterContainer.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) ; }
83  AliVCaloCells *GetCaloCells() const { return fCaloCells; }
84  TList *GetOutputList() const { return fOutput; }
85 
86  void SetCaloCells(AliVCaloCells * cells) { fCaloCells = cells; }
88 
89  void SetInputEvent(AliVEvent * event) { fEventManager.SetInputEvent(event); }
90  void SetMCEvent(AliMCEvent * mcevent) { fMCEvent = mcevent; }
98 
99  void SetEMCALGeometry(AliEMCALGeometry * geometry ) { fGeom = geometry; }
100  void SetCentralityBin(Int_t bin) { fCentBin = bin; }
101  void SetCentrality(Double_t cent) { fCent = cent; }
103  void SetVertex(Double_t * vertex) { fVertex[0] = vertex[0]; fVertex[1] = vertex[1]; fVertex[2] = vertex[2]; }
104  void SetIsESD(Bool_t isESD) {fEsdMode = isESD; }
105 
108 
110  template<typename T> bool GetProperty(std::string propertyName, T & property, bool requiredProperty = true, std::string correctionName = "");
111  protected:
119  AliMCEvent *fMCEvent;
127  AliEMCALGeometry *fGeom;
131  AliVCaloCells *fCaloCells;
134 
136 
137  private:
138  AliEmcalCorrectionComponent(const AliEmcalCorrectionComponent &); // Not implemented
140 
142  ClassDef(AliEmcalCorrectionComponent, 5); // 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:
220  static map_type * componentMap;
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...
AliEMCALRecoUtils * GetRecoUtils() const
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
bool GetProperty(std::vector< std::string > propertyPath, const std::string &propertyName, T &property, const bool requiredProperty) const
Int_t fCentBin
! Event centrality bin
AliClusterContainer * AddClusterContainer(const char *n)
AliVCaloCells * fCaloCells
! Pointer to CaloCells
Some utilities for cluster and cell treatment.
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.
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.
YAML configuration class for AliPhysics.
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.