ROOT logo
#ifndef ALIITSMEANVERTEXER_H
#define ALIITSMEANVERTEXER_H

///////////////////////////////////////////////////////////////////////
//                                                                   //
// Class to compute vertex position using SPD local reconstruction   //
// An average vertex position using all the events                   //
// is built and saved                                                //
///////////////////////////////////////////////////////////////////////

/* $Id$ */

#include <TObject.h>
#include <TBits.h>

class TClonesArray;
class TH1F;
class TH2F;
class AliRawReader;
class AliESDVertex;
class AliITSDetTypeRec;
class AliITSVertexer;

class AliITSMeanVertexer : public TObject {

 public:
  // default constructor
    AliITSMeanVertexer(Bool_t mode = kTRUE);   
    virtual ~AliITSMeanVertexer();
 
    Bool_t Init();
 
    void   SetFilterOnContributors(Int_t nc=1){fFilterOnContributors = nc;}
    Bool_t Reconstruct(AliRawReader *rawReader);
    void SetCutOnErrX(Double_t cut=9.5){fErrXCut = cut;}
    void SetCutOnR(Double_t cut=0.5){fRCut = cut;}
    void SetCutOnCls(UInt_t vmin=50, UInt_t vmax=7000){fLowSPD0=vmin; fHighSPD0=vmax;}
    void SetZFiducialRegion(Double_t zcut=40.){fZCutDiamond=zcut;}
    void   WriteVertices(const char *filename);

    const TH2F*GetVertexXY() const { return fVertexXY; }
    const TH1F*GetVertexZ()  const { return fVertexZ;  }

    // Methods used for debug purposes
    Int_t GetArrayEntries() const {return fVertArray.GetEntries();}
    const AliESDVertex* GetElementAt(Int_t i) const {return (AliESDVertex*)fVertArray[i];}
    UInt_t GetSPD0cls(Int_t i) const {return fClu0[i];}
    Bool_t IsGoodVertex(Int_t i) const {return (fAccEvents.TestBitNumber(i)); }
 
 private:
    // copy constructor (NO copy allowed)
    AliITSMeanVertexer(const AliITSMeanVertexer& vtxr);
    // assignment operator (NO assignment allowed)
    AliITSMeanVertexer& operator=(const AliITSMeanVertexer& /* vtxr */);

    Bool_t Filter(AliESDVertex *vert,UInt_t mult);
    void   AddToMean(AliESDVertex *vert);
    Bool_t ComputeMean(Bool_t killOutliers);
    void Reset(Bool_t redefine2D,Bool_t complete);
    void ResetArray(){fAccEvents.ResetAllBits(kTRUE); fVertArray.Clear();
      fIndex=0; for(Int_t i=0;i<fgkMaxNumOfEvents;i++)fClu0[i]=0; }

    static const Int_t fgkMaxNumOfEvents;   // max. number of events 
    AliITSDetTypeRec *fDetTypeRec; //! ITS reco class
    TH2F    *fVertexXY;        //! histogram with transverse vertex distribution (vertex diamond)
    TH1F    *fVertexZ;         //! histogram with longitudinal vertex distribution

    Double_t fWeighPosSum[3];    //! weighted average position sum (transient)
    Double_t fWeighSigSum[3];    //! weighted average position sum (transient)
    Double_t fAverPosSum[3];     //! average position sum (transient)
    Double_t fAverPosSqSum[3][3];//! average square position sum for covariance (transient)
    Double_t fWeighPos[3];       //! weighted average position
    Double_t fWeighSig[3];       //! errors on weighted average position
    Double_t fAverPos[3];        //! average position
    Double_t fAverPosSq[3][3];   //! average square position for covariance
    Int_t fNoEventsContr;        //! number of events used for mean vertex
    Double_t fTotContributors;      //! Integrated number of contributors
    Double_t fAverContributors;  //! Average number of contributors
    Int_t fFilterOnContributors; //! Numb. of contrib must be > fFilter...
    Bool_t fMode;                //! kTRUE for Vertexer3D; 
                                 //! kFALSE for VertexerTapan
    AliITSVertexer* fVertexer;   //! vertexer

    TBits fAccEvents;           //! bit string: 1 for good events 0 for bad ones
    TClonesArray fVertArray;     //! array of vertices to be averaged
    UInt_t *fClu0;              //! number of clusters on SPD inner layer
    Int_t fIndex;               //! current index on the arrays
    Double_t fErrXCut;          //! cut on error on X (error*1000<fErrXCut)
    Double_t fRCut;             //| cut on distance from first estimate (mm)
    Double_t fZCutDiamond;      //! -/+ fZCutDiamond is the Z fiducial region
    UInt_t fLowSPD0;            //! low SPD0 cls value to accept event
    UInt_t fHighSPD0;           //! high SPD0 cls value to accept event
    TH1F *fMultH;               //! debug hist: mult. on SPD0 before Filter
    TH1F *fErrXH;               //! debug hist: error on X before Filter
    TH1F *fMultHa;              //! debug hist: mult. on SPD0 after Filter
    TH1F *fErrXHa;              //! debug hist: error on X after Filter
    TH1F *fDistH;               //! debug hist: distance from peak
    TH1F *fContrH;              //! debug hist: number of contributors
    TH1F *fContrHa;             //! debug hist: number of contributors - after filter

    ClassDef(AliITSMeanVertexer,0)
};

#endif
 AliITSMeanVertexer.h:1
 AliITSMeanVertexer.h:2
 AliITSMeanVertexer.h:3
 AliITSMeanVertexer.h:4
 AliITSMeanVertexer.h:5
 AliITSMeanVertexer.h:6
 AliITSMeanVertexer.h:7
 AliITSMeanVertexer.h:8
 AliITSMeanVertexer.h:9
 AliITSMeanVertexer.h:10
 AliITSMeanVertexer.h:11
 AliITSMeanVertexer.h:12
 AliITSMeanVertexer.h:13
 AliITSMeanVertexer.h:14
 AliITSMeanVertexer.h:15
 AliITSMeanVertexer.h:16
 AliITSMeanVertexer.h:17
 AliITSMeanVertexer.h:18
 AliITSMeanVertexer.h:19
 AliITSMeanVertexer.h:20
 AliITSMeanVertexer.h:21
 AliITSMeanVertexer.h:22
 AliITSMeanVertexer.h:23
 AliITSMeanVertexer.h:24
 AliITSMeanVertexer.h:25
 AliITSMeanVertexer.h:26
 AliITSMeanVertexer.h:27
 AliITSMeanVertexer.h:28
 AliITSMeanVertexer.h:29
 AliITSMeanVertexer.h:30
 AliITSMeanVertexer.h:31
 AliITSMeanVertexer.h:32
 AliITSMeanVertexer.h:33
 AliITSMeanVertexer.h:34
 AliITSMeanVertexer.h:35
 AliITSMeanVertexer.h:36
 AliITSMeanVertexer.h:37
 AliITSMeanVertexer.h:38
 AliITSMeanVertexer.h:39
 AliITSMeanVertexer.h:40
 AliITSMeanVertexer.h:41
 AliITSMeanVertexer.h:42
 AliITSMeanVertexer.h:43
 AliITSMeanVertexer.h:44
 AliITSMeanVertexer.h:45
 AliITSMeanVertexer.h:46
 AliITSMeanVertexer.h:47
 AliITSMeanVertexer.h:48
 AliITSMeanVertexer.h:49
 AliITSMeanVertexer.h:50
 AliITSMeanVertexer.h:51
 AliITSMeanVertexer.h:52
 AliITSMeanVertexer.h:53
 AliITSMeanVertexer.h:54
 AliITSMeanVertexer.h:55
 AliITSMeanVertexer.h:56
 AliITSMeanVertexer.h:57
 AliITSMeanVertexer.h:58
 AliITSMeanVertexer.h:59
 AliITSMeanVertexer.h:60
 AliITSMeanVertexer.h:61
 AliITSMeanVertexer.h:62
 AliITSMeanVertexer.h:63
 AliITSMeanVertexer.h:64
 AliITSMeanVertexer.h:65
 AliITSMeanVertexer.h:66
 AliITSMeanVertexer.h:67
 AliITSMeanVertexer.h:68
 AliITSMeanVertexer.h:69
 AliITSMeanVertexer.h:70
 AliITSMeanVertexer.h:71
 AliITSMeanVertexer.h:72
 AliITSMeanVertexer.h:73
 AliITSMeanVertexer.h:74
 AliITSMeanVertexer.h:75
 AliITSMeanVertexer.h:76
 AliITSMeanVertexer.h:77
 AliITSMeanVertexer.h:78
 AliITSMeanVertexer.h:79
 AliITSMeanVertexer.h:80
 AliITSMeanVertexer.h:81
 AliITSMeanVertexer.h:82
 AliITSMeanVertexer.h:83
 AliITSMeanVertexer.h:84
 AliITSMeanVertexer.h:85
 AliITSMeanVertexer.h:86
 AliITSMeanVertexer.h:87
 AliITSMeanVertexer.h:88
 AliITSMeanVertexer.h:89
 AliITSMeanVertexer.h:90
 AliITSMeanVertexer.h:91
 AliITSMeanVertexer.h:92
 AliITSMeanVertexer.h:93
 AliITSMeanVertexer.h:94
 AliITSMeanVertexer.h:95
 AliITSMeanVertexer.h:96
 AliITSMeanVertexer.h:97
 AliITSMeanVertexer.h:98
 AliITSMeanVertexer.h:99
 AliITSMeanVertexer.h:100
 AliITSMeanVertexer.h:101
 AliITSMeanVertexer.h:102
 AliITSMeanVertexer.h:103
 AliITSMeanVertexer.h:104