ROOT logo
#ifndef ALIFMDMCTRACKINSPECTORTASK_H
#define ALIFMDMCTRACKINSPECTORTASK_H
#include "AliBaseESDTask.h"
#include "AliFMDMCTrackInspector.h"
#include "AliFMDEventInspector.h"

/** 
 * This task is designed to read in MC truth information about the
 * energy loss in each strip, and then fit the distributions from
 * secondaries and primaries separately.
 * 
 * Then (this is not implemented yet) it tries to deconvolve the
 * contributions from secondaries and primaries separately from the
 * total sum energy loss distribution, and in that way estimate the
 * secondary to primary charge particle ratios per @f$\eta@f$ bin.  If
 * the same procedure is applied to real data, then we can have an
 * estimate - from data - of the ratio of secondaries to primaries and
 * thus perhaps get a clearer picture of the secondary particle
 * contamination.
 *
 * The the function fitted to the (scaled) energy loss
 * (@f$\Delta/\Delta_{mip}@f$ distributions is 
 *
 * @f[
 *    F(\Delta;\Delta_p,\xi,\sigma,\mathbf{a}) = 
 *    \sum_{i=1}^{N}a_i f(\Delta;\Delta_i,\xi_i,\sigma_i)
 * @f]
 * where @f$ a@f$ is of length @f$ N@f$ and 
 * @f[
 *   f(\Delta;\Delta,\xi,\sigma) = 
 *     \int_{-\infty}^{+\infty}d\Delta' L(\Delta,\Delta',\xi)
 *     \frac{1}{\sqrt{2\pi\sigma^2}}
 *     e^{-\frac{(\Delta'-\Delta_mp^2}{2\sigma^2}}
 * @f]
 * and 
 * @f[ 
 *     \Delta_i = i(\Delta_1+\xi\log(i))\\
 *     \xi_i    = i\xi_1\\
 *     \sigma_i = \sqrt{i}\sigma_1\\
 *     a_1      = 1\\
 *     \Delta_p = \Delta_1\\
 *     \xi      = \xi_1\\
 *     \sigma   = \sigma_1
 * @f]
 *
 * See also AliLandauGausFitter 
 */
class AliFMDMCTrackInspectorTask : public AliBaseESDTask
{
public:
  /** 
   * Default CTOR - do not use
   */
  AliFMDMCTrackInspectorTask()
    : AliBaseESDTask(),
      fEventInspector(), 
      fTrackInspector()
  {}
  /** 
   * CTOR
   * 
   * @param name     Name - not used
   * @param useTuple Whether to use store an NTuple
   */
  AliFMDMCTrackInspectorTask(const char* name, Bool_t useTuple=false);
  /** 
   * DTOR
   */
  ~AliFMDMCTrackInspectorTask() {}

  /** 
   * Called when setting up the train on the client - i.e., called
   * once before the job hits the worker nodes
   * 
   * @return true
   */  
  Bool_t Setup();
  /** 
   * Called at start-up on the clients - i.e., called once per worker
   * node before the event processing.
   * 
   * @return true
   */
  Bool_t Book();
  /** 
   * Called after the first event was seen - i.e., called once per
   * worker node just after the first event was seen, but before event
   * processing.
   * 
   * @param ipz Interaction point Z--coordinate axis to use 
   * @param eta @f$\eta=-\log[\tan^{-1}(\theta/2)]@f$ axis to use
   * 
   * @return true
   */
  Bool_t PreData(const TAxis& ipz, const TAxis& eta);
  /** 
   * Process a single event 
   * 
   * @param esd ESD input event 
   * 
   * @return true on success
   */
  Bool_t Event(AliESDEvent& esd);
  /** 
   * Finalize the task.  This is called once after all event
   * processing and after all outputs have been merged.  This is
   * called on the master/client once.
   * 
   * @return true on success
   */
  Bool_t Finalize() { fTrackInspector.Fit(fResults); return true; }
  /** 
   * Print information to standard out
   * 
   * @param option Passed to sub objects as-is
   */
  void   Print(Option_t* option="") const;
  /** 
   * Get the event inspector 
   * 
   * @return Reference to the event inspector 
   */
  AliFMDEventInspector& GetEventInspector() { return fEventInspector; }
  /** 
   * Get the event inspector 
   * 
   * @return Constant reference to the event inspector 
   */
  const AliFMDEventInspector& GetEventInspector() const 
  { 
    return fEventInspector; 
  }
  /** 
   * Get the energy fitter 
   * 
   * @return Reference to the energy fitter 
   */
  AliFMDMCTrackInspector& GetTrackInspector() { return fTrackInspector; }
  /** 
   * Get the energy fitter 
   * 
   * @return Constant reference to the energy fitter 
   */
  const AliFMDMCTrackInspector& GetTrackInspector() const 
  { 
    return fTrackInspector; 
  }
  void SetDebug(Int_t dbg) { 
    AliBaseESDTask::SetDebug(dbg); GetTrackInspector().SetDebug(dbg); }
protected:
  /** 
   * Copy CTOR - not Implemented
   * 
   * @param o Object to copy from 
   */  
  AliFMDMCTrackInspectorTask(const AliFMDMCTrackInspectorTask& o);
  /** 
   * Assignment operator - not implemented
   * 
   * @param o Object to assign from 
   * 
   * @return Reference to this 
   */
  AliFMDMCTrackInspectorTask& operator=(const AliFMDMCTrackInspectorTask&o);
  /** 
   * Get the default @f$\eta=-\log[\tan^{-1}(\theta/2)]@f$ axis to use 
   * 
   * @return Pointer to static object 
   */  
  TAxis* DefaultEtaAxis() const;
  /** 
   * Get the default interaction point Z--coordinate axis to use 
   * 
   * @return Pointer to static object 
   */  
  TAxis* DefaultVertexAxis() const;
  
  AliFMDEventInspector   fEventInspector; // The event inspector
  AliFMDMCTrackInspector fTrackInspector;   // The energy loss fitter 

  ClassDef(AliFMDMCTrackInspectorTask,1); // Task to fit Delta from MC hits
};

#endif
// Local Variables:
//  mode: C++
// End:
 AliFMDMCTrackInspectorTask.h:1
 AliFMDMCTrackInspectorTask.h:2
 AliFMDMCTrackInspectorTask.h:3
 AliFMDMCTrackInspectorTask.h:4
 AliFMDMCTrackInspectorTask.h:5
 AliFMDMCTrackInspectorTask.h:6
 AliFMDMCTrackInspectorTask.h:7
 AliFMDMCTrackInspectorTask.h:8
 AliFMDMCTrackInspectorTask.h:9
 AliFMDMCTrackInspectorTask.h:10
 AliFMDMCTrackInspectorTask.h:11
 AliFMDMCTrackInspectorTask.h:12
 AliFMDMCTrackInspectorTask.h:13
 AliFMDMCTrackInspectorTask.h:14
 AliFMDMCTrackInspectorTask.h:15
 AliFMDMCTrackInspectorTask.h:16
 AliFMDMCTrackInspectorTask.h:17
 AliFMDMCTrackInspectorTask.h:18
 AliFMDMCTrackInspectorTask.h:19
 AliFMDMCTrackInspectorTask.h:20
 AliFMDMCTrackInspectorTask.h:21
 AliFMDMCTrackInspectorTask.h:22
 AliFMDMCTrackInspectorTask.h:23
 AliFMDMCTrackInspectorTask.h:24
 AliFMDMCTrackInspectorTask.h:25
 AliFMDMCTrackInspectorTask.h:26
 AliFMDMCTrackInspectorTask.h:27
 AliFMDMCTrackInspectorTask.h:28
 AliFMDMCTrackInspectorTask.h:29
 AliFMDMCTrackInspectorTask.h:30
 AliFMDMCTrackInspectorTask.h:31
 AliFMDMCTrackInspectorTask.h:32
 AliFMDMCTrackInspectorTask.h:33
 AliFMDMCTrackInspectorTask.h:34
 AliFMDMCTrackInspectorTask.h:35
 AliFMDMCTrackInspectorTask.h:36
 AliFMDMCTrackInspectorTask.h:37
 AliFMDMCTrackInspectorTask.h:38
 AliFMDMCTrackInspectorTask.h:39
 AliFMDMCTrackInspectorTask.h:40
 AliFMDMCTrackInspectorTask.h:41
 AliFMDMCTrackInspectorTask.h:42
 AliFMDMCTrackInspectorTask.h:43
 AliFMDMCTrackInspectorTask.h:44
 AliFMDMCTrackInspectorTask.h:45
 AliFMDMCTrackInspectorTask.h:46
 AliFMDMCTrackInspectorTask.h:47
 AliFMDMCTrackInspectorTask.h:48
 AliFMDMCTrackInspectorTask.h:49
 AliFMDMCTrackInspectorTask.h:50
 AliFMDMCTrackInspectorTask.h:51
 AliFMDMCTrackInspectorTask.h:52
 AliFMDMCTrackInspectorTask.h:53
 AliFMDMCTrackInspectorTask.h:54
 AliFMDMCTrackInspectorTask.h:55
 AliFMDMCTrackInspectorTask.h:56
 AliFMDMCTrackInspectorTask.h:57
 AliFMDMCTrackInspectorTask.h:58
 AliFMDMCTrackInspectorTask.h:59
 AliFMDMCTrackInspectorTask.h:60
 AliFMDMCTrackInspectorTask.h:61
 AliFMDMCTrackInspectorTask.h:62
 AliFMDMCTrackInspectorTask.h:63
 AliFMDMCTrackInspectorTask.h:64
 AliFMDMCTrackInspectorTask.h:65
 AliFMDMCTrackInspectorTask.h:66
 AliFMDMCTrackInspectorTask.h:67
 AliFMDMCTrackInspectorTask.h:68
 AliFMDMCTrackInspectorTask.h:69
 AliFMDMCTrackInspectorTask.h:70
 AliFMDMCTrackInspectorTask.h:71
 AliFMDMCTrackInspectorTask.h:72
 AliFMDMCTrackInspectorTask.h:73
 AliFMDMCTrackInspectorTask.h:74
 AliFMDMCTrackInspectorTask.h:75
 AliFMDMCTrackInspectorTask.h:76
 AliFMDMCTrackInspectorTask.h:77
 AliFMDMCTrackInspectorTask.h:78
 AliFMDMCTrackInspectorTask.h:79
 AliFMDMCTrackInspectorTask.h:80
 AliFMDMCTrackInspectorTask.h:81
 AliFMDMCTrackInspectorTask.h:82
 AliFMDMCTrackInspectorTask.h:83
 AliFMDMCTrackInspectorTask.h:84
 AliFMDMCTrackInspectorTask.h:85
 AliFMDMCTrackInspectorTask.h:86
 AliFMDMCTrackInspectorTask.h:87
 AliFMDMCTrackInspectorTask.h:88
 AliFMDMCTrackInspectorTask.h:89
 AliFMDMCTrackInspectorTask.h:90
 AliFMDMCTrackInspectorTask.h:91
 AliFMDMCTrackInspectorTask.h:92
 AliFMDMCTrackInspectorTask.h:93
 AliFMDMCTrackInspectorTask.h:94
 AliFMDMCTrackInspectorTask.h:95
 AliFMDMCTrackInspectorTask.h:96
 AliFMDMCTrackInspectorTask.h:97
 AliFMDMCTrackInspectorTask.h:98
 AliFMDMCTrackInspectorTask.h:99
 AliFMDMCTrackInspectorTask.h:100
 AliFMDMCTrackInspectorTask.h:101
 AliFMDMCTrackInspectorTask.h:102
 AliFMDMCTrackInspectorTask.h:103
 AliFMDMCTrackInspectorTask.h:104
 AliFMDMCTrackInspectorTask.h:105
 AliFMDMCTrackInspectorTask.h:106
 AliFMDMCTrackInspectorTask.h:107
 AliFMDMCTrackInspectorTask.h:108
 AliFMDMCTrackInspectorTask.h:109
 AliFMDMCTrackInspectorTask.h:110
 AliFMDMCTrackInspectorTask.h:111
 AliFMDMCTrackInspectorTask.h:112
 AliFMDMCTrackInspectorTask.h:113
 AliFMDMCTrackInspectorTask.h:114
 AliFMDMCTrackInspectorTask.h:115
 AliFMDMCTrackInspectorTask.h:116
 AliFMDMCTrackInspectorTask.h:117
 AliFMDMCTrackInspectorTask.h:118
 AliFMDMCTrackInspectorTask.h:119
 AliFMDMCTrackInspectorTask.h:120
 AliFMDMCTrackInspectorTask.h:121
 AliFMDMCTrackInspectorTask.h:122
 AliFMDMCTrackInspectorTask.h:123
 AliFMDMCTrackInspectorTask.h:124
 AliFMDMCTrackInspectorTask.h:125
 AliFMDMCTrackInspectorTask.h:126
 AliFMDMCTrackInspectorTask.h:127
 AliFMDMCTrackInspectorTask.h:128
 AliFMDMCTrackInspectorTask.h:129
 AliFMDMCTrackInspectorTask.h:130
 AliFMDMCTrackInspectorTask.h:131
 AliFMDMCTrackInspectorTask.h:132
 AliFMDMCTrackInspectorTask.h:133
 AliFMDMCTrackInspectorTask.h:134
 AliFMDMCTrackInspectorTask.h:135
 AliFMDMCTrackInspectorTask.h:136
 AliFMDMCTrackInspectorTask.h:137
 AliFMDMCTrackInspectorTask.h:138
 AliFMDMCTrackInspectorTask.h:139
 AliFMDMCTrackInspectorTask.h:140
 AliFMDMCTrackInspectorTask.h:141
 AliFMDMCTrackInspectorTask.h:142
 AliFMDMCTrackInspectorTask.h:143
 AliFMDMCTrackInspectorTask.h:144
 AliFMDMCTrackInspectorTask.h:145
 AliFMDMCTrackInspectorTask.h:146
 AliFMDMCTrackInspectorTask.h:147
 AliFMDMCTrackInspectorTask.h:148
 AliFMDMCTrackInspectorTask.h:149
 AliFMDMCTrackInspectorTask.h:150
 AliFMDMCTrackInspectorTask.h:151
 AliFMDMCTrackInspectorTask.h:152
 AliFMDMCTrackInspectorTask.h:153
 AliFMDMCTrackInspectorTask.h:154
 AliFMDMCTrackInspectorTask.h:155
 AliFMDMCTrackInspectorTask.h:156
 AliFMDMCTrackInspectorTask.h:157
 AliFMDMCTrackInspectorTask.h:158
 AliFMDMCTrackInspectorTask.h:159
 AliFMDMCTrackInspectorTask.h:160
 AliFMDMCTrackInspectorTask.h:161
 AliFMDMCTrackInspectorTask.h:162
 AliFMDMCTrackInspectorTask.h:163
 AliFMDMCTrackInspectorTask.h:164
 AliFMDMCTrackInspectorTask.h:165
 AliFMDMCTrackInspectorTask.h:166
 AliFMDMCTrackInspectorTask.h:167
 AliFMDMCTrackInspectorTask.h:168
 AliFMDMCTrackInspectorTask.h:169
 AliFMDMCTrackInspectorTask.h:170
 AliFMDMCTrackInspectorTask.h:171
 AliFMDMCTrackInspectorTask.h:172
 AliFMDMCTrackInspectorTask.h:173
 AliFMDMCTrackInspectorTask.h:174
 AliFMDMCTrackInspectorTask.h:175
 AliFMDMCTrackInspectorTask.h:176
 AliFMDMCTrackInspectorTask.h:177
 AliFMDMCTrackInspectorTask.h:178
 AliFMDMCTrackInspectorTask.h:179
 AliFMDMCTrackInspectorTask.h:180
 AliFMDMCTrackInspectorTask.h:181
 AliFMDMCTrackInspectorTask.h:182
 AliFMDMCTrackInspectorTask.h:183
 AliFMDMCTrackInspectorTask.h:184
 AliFMDMCTrackInspectorTask.h:185
 AliFMDMCTrackInspectorTask.h:186
 AliFMDMCTrackInspectorTask.h:187