ROOT logo
// This task finds the eventplane
// using the FMD
// 
#ifndef ALIFMDEVENTPLANEFINDER_H 
#define ALIFMDEVENTPLANEFINDER_H 
/**
 * @file AliFMDEventPlaneFinder.h
 * @author Alexander Hansen
 * @date   Tue Feb 14 2012
 * 
 * @brief
 * 
 * 
 * @ingroup pwglf_forward
 */
#include <TNamed.h>
#include <TVector2.h>
#include "AliForwardUtil.h"
class AliVEvent;
class TH1D;
class TH2F;
class TH2D;
class TString;
class AliOADBContainer;
class AliAODForwardEP;

/**
 * Find the event plane using the FMD
 * 
 */
class AliFMDEventPlaneFinder : public TNamed
{
public:
  /** 
   * Constructor 
   */
  AliFMDEventPlaneFinder();
  /** 
   * Constructor 
   * 
   * @param name Name of object
   */
  AliFMDEventPlaneFinder(const char* name);
  /** 
   * Copy constructor 
   * 
   * @param o Object to copy from 
   */
  AliFMDEventPlaneFinder(const AliFMDEventPlaneFinder& o);
  /** 
   * Destructor 
   */
  virtual ~AliFMDEventPlaneFinder();
  /** 
   * Assignement operator
   * 
   * @param o Object to assign from 
   * 
   * @return Reference to this object
   */
  AliFMDEventPlaneFinder& operator=(const AliFMDEventPlaneFinder& o);
  /** 
   * Initialize this sub-algorithm
   * 
   * @param etaAxis  Eta axis to use 
   */
  virtual void SetupForData(const TAxis& etaAxis);
  /** 
   * Do the calculations 
   * 
   * @param hists    Histogram cache
   * @param esd      Event 
   * @param aodEp    Output object 
   * @param h        Output histogram
   * 
   * @return true on successs 
   */
  Bool_t FindEventplane(AliVEvent* esd,
                        AliAODForwardEP& aodEp,
                        TH2D* h,
                        AliForwardUtil::Histos* hists);
  /** 
   * Output diagnostic histograms to directory 
   * 
   * @param dir List to write in
   */  
  virtual void CreateOutputObjects(TList* dir);
  /** 
   * Print information 
   * 
   * @param option Print options 
   *   - max  Print max weights 
   */
  void Print(Option_t* option="") const;
  /** 
   * Set the debug level.  The higher the value the more output 
   * 
   * @param dbg Debug level 
   */
  void SetDebug(Int_t dbg=1) { fDebug = dbg; }
  /**
   * Calculate Q vectors
   *
   * @param h dN/detadphi histogram
   * @param eHist histogram for ep vs. eta
   */
  void CalcQVectors(TH2D* h, TH1D* eHist);
  /**
   * Calculate the eventplane from a vector
   *
   * @param v TVector2 of Q-vectors
   *
   * @return the eventplane as a double
   */
  Double_t CalcEventplane(const TVector2& v) const;
  /**
   * Set the run number, used for OADB object
   *
   * @param run Run number
   */
  void SetRunNumber(Int_t run);
  /**
   * Get the run number
   *
   * @return returns the run number
   */
  Int_t GetRunNumber() { return fRunNumber; }
  /**
   * Get the OADB phi distribution for flattening
   */
  void GetPhiDist();
  /**
   * Flag for setting the use of phi weights for flattening
   * 
   * @param use true or false
   */
  void SetUsePhiWeights(Bool_t use = kTRUE) { fUsePhiWeights = use; }
  /**
   * Fill diagnostics hists
   *
   * @param fmdEP Object containing results of FMD EP calculations
   */
  void FillHists(AliAODForwardEP* fmdEP);
  /**
   * Set the OADB path, for using a custom OADB path and file
   *
   * @param fname Name of the custom OADB file, including path
   */
  void SetOADBPath(Char_t* fname) { fOADBFileName = fname; }

protected:
  /**
   * Get the phi weight from OADB histogram for the ep flattening
   *
   * @param etaBin which eta bin
   * @param phiBin which phi bin
   *
   * @return phi weight for etaBin, phiBin as double
   */
  Double_t GetPhiWeight(Int_t etaBin, Int_t phiBin) const;
  /** 
   * Calculat the difference @f$a_1 - a_2@f$ between two angles
   * @f$a_1, a_2@f$ and normalize to @f$[-\pi/2,\pi/2]@f$
   * 
   * @param a1 First angle @f$a_1@f$
   * @param a2 Second angle @f$a_2@f$
   * 
   * @return @f$a_1 - a_2 \in[-\pi/2,\pi/2]@f$
   */
  Double_t CalcDifference(Double_t a1, Double_t a2) const;
  /** 
   * Make a histogram of @f$\Psi_R@f$ values 
   * 
   * @param name   Name of histogram
   * @param title  Source 
   * @param color  Color of histogram 
   * 
   * @return Newly allocated histogram
   */
  TH1D* MakePsiRHist(const char* name, 
		     const char* title,
		     Int_t color);
  /** 
   * Make a difference histogram, and add to the output list
   * 
   * @param name    Name of histogram
   * @param first   First variable to correlate (X axis)
   * @param second  Second variable to correlate (Y axis)
   * @param color   Fill and line color of histogram
   * 
   * @return Newly allocated histogram
   */
  TH1D* MakeDiffHist(const char* name, 
		     const char* first,
		     const char* second,
		     Int_t color);
  /** 
   * Make a correlation histogram, and add it to the output list.
   * 
   * @param name    Name of histogram
   * @param first   First variable to correlate (X axis)
   * @param second  Second variable to correlate (Y axis)
   * 
   * @return Newly allocated histogram 
   */
  TH2F* MakeCorrHist(const char* name, 
		     const char* first,
		     const char* second);
  TList*            fList;               // List for diag. hists.
  AliVEvent*        fEvent;              // Current event
  TVector2          fQt;                 // Q vector for total ep
  TVector2          fQa;                 // Q vector for sub-ep A
  TVector2          fQc;                 // Q vector for sub-ep C
  TVector2          fQ1;                 // Q vector for sub-ep 1
  TVector2          fQ2;                 // Q vector for sub-ep 2
  TVector2          fQeta;               // Q vector for psi eta-dependence
  TH1D*             fHepFMD;             // Diagnostics histogram
  TH1D*             fHepFMDA;            // Diagnostics histogram
  TH1D*             fHepFMDC;            // Diagnostics histogram
  TH1D*             fHepFMDQC1;          // Diagnostics histogram
  TH1D*             fHepFMDQC2;          // Diagnostics histogram
  TH1D*             fHdiffFMDAC;         // Diagnostics histogram
  TH1D*             fHdiffFMDTPC;        // Diagnostics histogram
  TH1D*             fHdiffFMDVZERO;      // Diagnostics histogram
  TH2F*             fHcorrFMDAC;         // Diagnostics histogram
  TH2F*             fHcorrFMDTPC;        // Diagnostics histogram
  TH2F*             fHcorrFMDVZERO;      // Diagnostics histogram
  TH2D*             fHPhi;               // Diagnostics histogram
  Int_t             fDebug;              // Debug flag
  TString           fOADBFileName;       // Path to OADB container
  AliOADBContainer* fOADBContainer;      // OADBContainer object
  TH2D*             fPhiDist;            // Phi dist. for phi weights
  Int_t             fRunNumber;          // Run number supplied
  Bool_t            fUsePhiWeights;      // Flag for phi weights

  ClassDef(AliFMDEventPlaneFinder,2); //  
};

#endif
// Local Variables:
//   mode: C++
// End:

 AliFMDEventPlaneFinder.h:1
 AliFMDEventPlaneFinder.h:2
 AliFMDEventPlaneFinder.h:3
 AliFMDEventPlaneFinder.h:4
 AliFMDEventPlaneFinder.h:5
 AliFMDEventPlaneFinder.h:6
 AliFMDEventPlaneFinder.h:7
 AliFMDEventPlaneFinder.h:8
 AliFMDEventPlaneFinder.h:9
 AliFMDEventPlaneFinder.h:10
 AliFMDEventPlaneFinder.h:11
 AliFMDEventPlaneFinder.h:12
 AliFMDEventPlaneFinder.h:13
 AliFMDEventPlaneFinder.h:14
 AliFMDEventPlaneFinder.h:15
 AliFMDEventPlaneFinder.h:16
 AliFMDEventPlaneFinder.h:17
 AliFMDEventPlaneFinder.h:18
 AliFMDEventPlaneFinder.h:19
 AliFMDEventPlaneFinder.h:20
 AliFMDEventPlaneFinder.h:21
 AliFMDEventPlaneFinder.h:22
 AliFMDEventPlaneFinder.h:23
 AliFMDEventPlaneFinder.h:24
 AliFMDEventPlaneFinder.h:25
 AliFMDEventPlaneFinder.h:26
 AliFMDEventPlaneFinder.h:27
 AliFMDEventPlaneFinder.h:28
 AliFMDEventPlaneFinder.h:29
 AliFMDEventPlaneFinder.h:30
 AliFMDEventPlaneFinder.h:31
 AliFMDEventPlaneFinder.h:32
 AliFMDEventPlaneFinder.h:33
 AliFMDEventPlaneFinder.h:34
 AliFMDEventPlaneFinder.h:35
 AliFMDEventPlaneFinder.h:36
 AliFMDEventPlaneFinder.h:37
 AliFMDEventPlaneFinder.h:38
 AliFMDEventPlaneFinder.h:39
 AliFMDEventPlaneFinder.h:40
 AliFMDEventPlaneFinder.h:41
 AliFMDEventPlaneFinder.h:42
 AliFMDEventPlaneFinder.h:43
 AliFMDEventPlaneFinder.h:44
 AliFMDEventPlaneFinder.h:45
 AliFMDEventPlaneFinder.h:46
 AliFMDEventPlaneFinder.h:47
 AliFMDEventPlaneFinder.h:48
 AliFMDEventPlaneFinder.h:49
 AliFMDEventPlaneFinder.h:50
 AliFMDEventPlaneFinder.h:51
 AliFMDEventPlaneFinder.h:52
 AliFMDEventPlaneFinder.h:53
 AliFMDEventPlaneFinder.h:54
 AliFMDEventPlaneFinder.h:55
 AliFMDEventPlaneFinder.h:56
 AliFMDEventPlaneFinder.h:57
 AliFMDEventPlaneFinder.h:58
 AliFMDEventPlaneFinder.h:59
 AliFMDEventPlaneFinder.h:60
 AliFMDEventPlaneFinder.h:61
 AliFMDEventPlaneFinder.h:62
 AliFMDEventPlaneFinder.h:63
 AliFMDEventPlaneFinder.h:64
 AliFMDEventPlaneFinder.h:65
 AliFMDEventPlaneFinder.h:66
 AliFMDEventPlaneFinder.h:67
 AliFMDEventPlaneFinder.h:68
 AliFMDEventPlaneFinder.h:69
 AliFMDEventPlaneFinder.h:70
 AliFMDEventPlaneFinder.h:71
 AliFMDEventPlaneFinder.h:72
 AliFMDEventPlaneFinder.h:73
 AliFMDEventPlaneFinder.h:74
 AliFMDEventPlaneFinder.h:75
 AliFMDEventPlaneFinder.h:76
 AliFMDEventPlaneFinder.h:77
 AliFMDEventPlaneFinder.h:78
 AliFMDEventPlaneFinder.h:79
 AliFMDEventPlaneFinder.h:80
 AliFMDEventPlaneFinder.h:81
 AliFMDEventPlaneFinder.h:82
 AliFMDEventPlaneFinder.h:83
 AliFMDEventPlaneFinder.h:84
 AliFMDEventPlaneFinder.h:85
 AliFMDEventPlaneFinder.h:86
 AliFMDEventPlaneFinder.h:87
 AliFMDEventPlaneFinder.h:88
 AliFMDEventPlaneFinder.h:89
 AliFMDEventPlaneFinder.h:90
 AliFMDEventPlaneFinder.h:91
 AliFMDEventPlaneFinder.h:92
 AliFMDEventPlaneFinder.h:93
 AliFMDEventPlaneFinder.h:94
 AliFMDEventPlaneFinder.h:95
 AliFMDEventPlaneFinder.h:96
 AliFMDEventPlaneFinder.h:97
 AliFMDEventPlaneFinder.h:98
 AliFMDEventPlaneFinder.h:99
 AliFMDEventPlaneFinder.h:100
 AliFMDEventPlaneFinder.h:101
 AliFMDEventPlaneFinder.h:102
 AliFMDEventPlaneFinder.h:103
 AliFMDEventPlaneFinder.h:104
 AliFMDEventPlaneFinder.h:105
 AliFMDEventPlaneFinder.h:106
 AliFMDEventPlaneFinder.h:107
 AliFMDEventPlaneFinder.h:108
 AliFMDEventPlaneFinder.h:109
 AliFMDEventPlaneFinder.h:110
 AliFMDEventPlaneFinder.h:111
 AliFMDEventPlaneFinder.h:112
 AliFMDEventPlaneFinder.h:113
 AliFMDEventPlaneFinder.h:114
 AliFMDEventPlaneFinder.h:115
 AliFMDEventPlaneFinder.h:116
 AliFMDEventPlaneFinder.h:117
 AliFMDEventPlaneFinder.h:118
 AliFMDEventPlaneFinder.h:119
 AliFMDEventPlaneFinder.h:120
 AliFMDEventPlaneFinder.h:121
 AliFMDEventPlaneFinder.h:122
 AliFMDEventPlaneFinder.h:123
 AliFMDEventPlaneFinder.h:124
 AliFMDEventPlaneFinder.h:125
 AliFMDEventPlaneFinder.h:126
 AliFMDEventPlaneFinder.h:127
 AliFMDEventPlaneFinder.h:128
 AliFMDEventPlaneFinder.h:129
 AliFMDEventPlaneFinder.h:130
 AliFMDEventPlaneFinder.h:131
 AliFMDEventPlaneFinder.h:132
 AliFMDEventPlaneFinder.h:133
 AliFMDEventPlaneFinder.h:134
 AliFMDEventPlaneFinder.h:135
 AliFMDEventPlaneFinder.h:136
 AliFMDEventPlaneFinder.h:137
 AliFMDEventPlaneFinder.h:138
 AliFMDEventPlaneFinder.h:139
 AliFMDEventPlaneFinder.h:140
 AliFMDEventPlaneFinder.h:141
 AliFMDEventPlaneFinder.h:142
 AliFMDEventPlaneFinder.h:143
 AliFMDEventPlaneFinder.h:144
 AliFMDEventPlaneFinder.h:145
 AliFMDEventPlaneFinder.h:146
 AliFMDEventPlaneFinder.h:147
 AliFMDEventPlaneFinder.h:148
 AliFMDEventPlaneFinder.h:149
 AliFMDEventPlaneFinder.h:150
 AliFMDEventPlaneFinder.h:151
 AliFMDEventPlaneFinder.h:152
 AliFMDEventPlaneFinder.h:153
 AliFMDEventPlaneFinder.h:154
 AliFMDEventPlaneFinder.h:155
 AliFMDEventPlaneFinder.h:156
 AliFMDEventPlaneFinder.h:157
 AliFMDEventPlaneFinder.h:158
 AliFMDEventPlaneFinder.h:159
 AliFMDEventPlaneFinder.h:160
 AliFMDEventPlaneFinder.h:161
 AliFMDEventPlaneFinder.h:162
 AliFMDEventPlaneFinder.h:163
 AliFMDEventPlaneFinder.h:164
 AliFMDEventPlaneFinder.h:165
 AliFMDEventPlaneFinder.h:166
 AliFMDEventPlaneFinder.h:167
 AliFMDEventPlaneFinder.h:168
 AliFMDEventPlaneFinder.h:169
 AliFMDEventPlaneFinder.h:170
 AliFMDEventPlaneFinder.h:171
 AliFMDEventPlaneFinder.h:172
 AliFMDEventPlaneFinder.h:173
 AliFMDEventPlaneFinder.h:174
 AliFMDEventPlaneFinder.h:175
 AliFMDEventPlaneFinder.h:176
 AliFMDEventPlaneFinder.h:177
 AliFMDEventPlaneFinder.h:178
 AliFMDEventPlaneFinder.h:179
 AliFMDEventPlaneFinder.h:180
 AliFMDEventPlaneFinder.h:181
 AliFMDEventPlaneFinder.h:182
 AliFMDEventPlaneFinder.h:183
 AliFMDEventPlaneFinder.h:184
 AliFMDEventPlaneFinder.h:185
 AliFMDEventPlaneFinder.h:186
 AliFMDEventPlaneFinder.h:187
 AliFMDEventPlaneFinder.h:188
 AliFMDEventPlaneFinder.h:189
 AliFMDEventPlaneFinder.h:190
 AliFMDEventPlaneFinder.h:191
 AliFMDEventPlaneFinder.h:192
 AliFMDEventPlaneFinder.h:193
 AliFMDEventPlaneFinder.h:194
 AliFMDEventPlaneFinder.h:195
 AliFMDEventPlaneFinder.h:196
 AliFMDEventPlaneFinder.h:197
 AliFMDEventPlaneFinder.h:198
 AliFMDEventPlaneFinder.h:199
 AliFMDEventPlaneFinder.h:200
 AliFMDEventPlaneFinder.h:201
 AliFMDEventPlaneFinder.h:202
 AliFMDEventPlaneFinder.h:203
 AliFMDEventPlaneFinder.h:204
 AliFMDEventPlaneFinder.h:205
 AliFMDEventPlaneFinder.h:206
 AliFMDEventPlaneFinder.h:207
 AliFMDEventPlaneFinder.h:208
 AliFMDEventPlaneFinder.h:209
 AliFMDEventPlaneFinder.h:210
 AliFMDEventPlaneFinder.h:211
 AliFMDEventPlaneFinder.h:212
 AliFMDEventPlaneFinder.h:213
 AliFMDEventPlaneFinder.h:214
 AliFMDEventPlaneFinder.h:215
 AliFMDEventPlaneFinder.h:216
 AliFMDEventPlaneFinder.h:217
 AliFMDEventPlaneFinder.h:218
 AliFMDEventPlaneFinder.h:219
 AliFMDEventPlaneFinder.h:220
 AliFMDEventPlaneFinder.h:221
 AliFMDEventPlaneFinder.h:222
 AliFMDEventPlaneFinder.h:223
 AliFMDEventPlaneFinder.h:224
 AliFMDEventPlaneFinder.h:225
 AliFMDEventPlaneFinder.h:226
 AliFMDEventPlaneFinder.h:227
 AliFMDEventPlaneFinder.h:228
 AliFMDEventPlaneFinder.h:229
 AliFMDEventPlaneFinder.h:230
 AliFMDEventPlaneFinder.h:231
 AliFMDEventPlaneFinder.h:232
 AliFMDEventPlaneFinder.h:233
 AliFMDEventPlaneFinder.h:234
 AliFMDEventPlaneFinder.h:235
 AliFMDEventPlaneFinder.h:236
 AliFMDEventPlaneFinder.h:237
 AliFMDEventPlaneFinder.h:238
 AliFMDEventPlaneFinder.h:239
 AliFMDEventPlaneFinder.h:240
 AliFMDEventPlaneFinder.h:241
 AliFMDEventPlaneFinder.h:242
 AliFMDEventPlaneFinder.h:243