AliPhysics  a60a912 (a60a912)
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; }
106 
109 
111  template<typename T> bool GetProperty(std::string propertyName, T & property, bool requiredProperty = true, std::string correctionName = "");
112  protected:
120  AliMCEvent *fMCEvent;
128  AliEMCALGeometry *fGeom;
132  AliVCaloCells *fCaloCells;
135 
138 
139  private:
140  AliEmcalCorrectionComponent(const AliEmcalCorrectionComponent &); // Not implemented
142 
144  ClassDef(AliEmcalCorrectionComponent, 6); // EMCal correction component
146 };
147 
160 template<typename T>
161 bool AliEmcalCorrectionComponent::GetProperty(std::string propertyName, T & property, bool requiredProperty, std::string correctionName)
162 {
163  // Get proper correction name
164  if (correctionName == "")
165  {
166  correctionName = GetName();
167  }
168  // Add the correction name as a prefix of the property
169  return fYAMLConfig.GetProperty(std::vector<std::string>{correctionName, propertyName}, property, requiredProperty);
170 }
171 
190 template<typename T> AliEmcalCorrectionComponent * createT() { return new T; }
192 
193 // Factory to create and keep track of new components
195 {
196  public:
198 
199  typedef std::map<std::string, AliEmcalCorrectionComponent*(*)()> map_type;
200 
202  static AliEmcalCorrectionComponent * createInstance(std::string const& s)
203  {
204  map_type::iterator it = getMap()->find(s);
205  if(it == getMap()->end())
206  return 0;
207  // Initializes the function with empty arguments (?)
208  return it->second();
209  }
210 
211  protected:
213  static map_type * getMap() {
214  // We never delete the map (until program termination) because we cannot guarantee
215  // correct destruction order
216  if(!componentMap) { componentMap = new map_type; }
217  return componentMap;
218  }
219 
220  private:
222  static map_type * componentMap;
223 };
224 
237 template<typename T>
239 {
240  public:
242  RegisterCorrectionComponent(std::string const& s)
243  {
244  getMap()->insert(std::make_pair(s, &createT<T>));
245  }
246 };
247 
248 #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 &)
TString fCustomBadChannelFilePath
Custom path to bad channel map OADB file.
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
void SetCustomBadChannels(TString customBC)
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.