ROOT logo
#ifndef ALIFMDMCTRACKINSPECTOR_H
#define ALIFMDMCTRACKINSPECTOR_H
#include "AliFMDEnergyFitter.h"
#include "AliFMDMCTrackELoss.h"
#include <TArrayF.h>
class AliMCEvent;
class AliESDEvent;

/**
 * Class to fit the simulated energy loss in the FMD
 * 
 * @ingroup pwglf_forward_mc
 * @ingroup pwglf_forward_eloss
 */
class AliFMDMCTrackInspector : public AliFMDEnergyFitter
{
public:
  /** 
   * Constructor - do not use
   */
  AliFMDMCTrackInspector();
  /** 
   * Constructor 
   * 
   * @param title    Title of object - not significant 
   */
  AliFMDMCTrackInspector(const char* title);
  /**
   * Destructor
   */
  virtual ~AliFMDMCTrackInspector();

  /** 
   * Define the output histograms.  These are put in a sub list of the
   * passed list.   The histograms are merged before the parent task calls 
   * AliAnalysisTaskSE::Terminate 
   * 
   * @param dir Directory to add to 
   */
  virtual void CreateOutputObjects(TList* dir);
  /** 
   * Set-up before processing an event 
   * 
   * @param mcInput MC input 
   * 
   * @return true
   */
  virtual Bool_t PreEvent(const AliMCEvent& mcInput);
  /** 
   * Process a single event 
   * 
   * @param esdInput ESD input 
   * @param mcInput  MC input
   * @param cent     Event centrality 
   * 
   * @return true
   */
  virtual Bool_t Event(const AliESDEvent&  esdInput,
		       const AliMCEvent&   mcInput,
		       Double_t            cent=-1);
  /** 
   * Post-process accumulated signals 
   * 
   * @return true 
   */
  virtual Bool_t PostEvent();

  /** 
   * Get reference to the tracker of energy loss 
   * 
   * @return Reference to tracker of energy loss 
   */  
  AliFMDMCTrackELoss& GetTracker() { return fTracker; }
  /** 
   * Get constant reference to the tracker of energy loss 
   * 
   * @return Constant reference to tracker of energy loss 
   */  
  const AliFMDMCTrackELoss& GetTracker() const { return fTracker; }
protected:
  /**
   * copy constructor - not implemented
   */
  AliFMDMCTrackInspector(const AliFMDMCTrackInspector&);
  /**
   * Assignment operator - not implemented
   * 
   */
  AliFMDMCTrackInspector& operator=(const AliFMDMCTrackInspector&);

  /**
   * Container of ring histograms 
   * 
   */
public:
  struct RingHistos : public AliFMDEnergyFitter::RingHistos
  {
    /** 
     * Default CTOR - do not use 
     */
    RingHistos();
    /** 
     * User CTOR 
     * 
     * @param d Detector number 
     * @param r Ring identifier 
     */
    RingHistos(UShort_t d, Char_t r);
    /** 
     * DTOR
     */
    ~RingHistos() {}
    /** 
     * Copy constructor - not defined
     * 
     * @param o Object to copy from 
     */
    RingHistos(const RingHistos& o);
    /** 
     * Assignment operator  - not defined
     * 
     * @param o Object to assign from 
     * 
     * @return Reference to this 
     */
    RingHistos& operator=(const RingHistos& o);
    /** 
     * Create a bin array of increasing bins. This overload uses the
     * service AliFMDEncodedEdx::Spec::FillBinArray. 
     * 
     * @param nBins Number of bins - ignored
     * @param low   Low cut - ignored
     * @param high  High cut - ignored
     * 
     * @return Array of bin boundaries 
     */
    TArrayD MakeIncreasingAxis(Int_t nBins, 
			       Double_t low,
			       Double_t high) const;
    /** 
     * Initialise object 
     * 
     * @param eAxis      Eta axis
     * @param cAxis      Centrality axis 
     * @param maxDE      Max energy loss to consider 
     * @param nDEbins    Number of bins 
     * @param useIncrBin Whether to use an increasing bin size 
     */
    virtual void SetupForData(const TAxis& eAxis, 
			      const TAxis& cAxis,
			      Double_t     maxDE=10, 
			      Int_t        nDEbins=300, 
			      Bool_t       useIncrBin=true);
    /** 
     * Fill in observation 
     * 
     * @param flag 0 - fill all, 1 - primary, 2 - secondary
     * @param eta  Eta of particle observations
     * @param mult Scaled energy loss 
     */
    virtual void FillMC(UShort_t flag, Double_t eta, Double_t mult);
    /** 
     * Do scaling of histogram before fitting.  This can be
     * overwritten to do some smoothing or the like. By default, this
     * simply scales to the bin width.
     * 
     * @param dist Histogram to scale. 
     */     
    virtual void  Scale(TH1* dist) const;
    /** 
     * Fit the final distributions - called via Terminate 
     * 
     * @param dir           Containing directory
     * @param lowCut        Lower cut on @f$\Delta/\Delta_{mip}@f$ 
     * @param nParticles    Max. number of particle peaks to fit
     * @param minEntries    Least number of entries required before fitting
     * @param minusBins     Number of bins below the 1st peak we start fitting
     * @param relErrorCut   Largest relative error on paramters
     * @param chi2nuCut     Largest value of the @f$\chi^2/\nu@f$ 
     * @param minWeight     Least weight to consider 
     * @param regCut        When to regalurize 
     * @param residuals     How to do residuals - if at all 
     * 
     * @return List of histograms of parameters 
     */
    TObjArray* Fit(TList*           dir, 
		   Double_t         lowCut, 
		   UShort_t         nParticles,
		   UShort_t         minEntries,
		   UShort_t         minusBins, 
		   Double_t         relErrorCut, 
		   Double_t         chi2nuCut,
		   Double_t         minWeight,
		   Double_t         regCut,
		   EResidualMethod  residuals) const;
    
    TH2* fPrimary;   // @f$\Delta@f$ vs @f$\eta@f$ for primaries
    TH2* fSecondary; // @f$\Delta@f$ vs @f$\eta@f$ for second.
  public:
    TH2* fBetaGammadEdx;
    TH2* fBetaGammaEta;
    TH2* fDedxEta;
    ClassDef(RingHistos,1); // Cache of histograms per ring 
  };
protected:
  /** 
   * Create a container of histograms for a single ring
   * 
   * @param d Detector 
   * @param r Ring 
   * 
   * @return Newly allocated container 
   */
  AliFMDEnergyFitter::RingHistos* CreateRingHistos(UShort_t d, Char_t r) const;
  /** Our 'tracker' */
  AliFMDMCTrackELoss fTracker;
  /** Cache of current MC IP */
  TArrayF          fIp;
  /** Cache of number of tracks */
  Int_t            fNTrack;
  /** Cache of numbr of primaries */
  Int_t            fNPrimary;

  ClassDef(AliFMDMCTrackInspector,1);
};

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