ROOT logo
#ifndef HMDCVERTEXFIND_H
#define HMDCVERTEXFIND_H

#include "hreconstructor.h"
#include "hgeomvector.h"
#include "hgeomvertexfit.h"
#include "hspecgeompar.h"
#include "TIterator.h"
#include "TNtuple.h"
#include "TFile.h"
#include "TClonesArray.h"

class HCategory;
class HMdcGeomPar;
class HIterator;
class HMdcSeg;

class HMdcVertexFind : public HReconstructor {
public:
  enum EInputMode {kSegments,kHits};
  HMdcVertexFind(const Text_t name[] = "",const Text_t title[] = "",EInputMode m = kSegments,Bool_t tukey = kTRUE);
  virtual ~HMdcVertexFind(void);
  Bool_t init(void);
  Bool_t finalize(void);
  Int_t  execute(void);
  void        setCut(Double_t minz=-100,Double_t maxz=50,Double_t maxr=50) { fminZ = minz; fmaxZ = maxz; fmaxR = maxr;}
  void        useTukeyWeights        (Bool_t flag) { fUsingTukey    = flag; }
  void        setDebugMode           (Bool_t flag) { fDebugMode     = flag; }
  void        setTukeyConstant       (Double_t d)  { fTukeyConst    = d; }
  void        setMaxIterations       (Int_t max)   { fMaxIterations = max; }
  void        setEpsilon             (Double_t ep) { fEpsilon       = ep; }
  void        setSeg0Chi2Cut(Float_t cut)   { fseg0Chi2Cut = cut;}
  void        setMinReqTracks(Int_t min)    { fminReqTrack = min;}
  void        setMinWindow(Double_t wind)   { fminWindow = wind;}
  void        setProgessiveTukey(Bool_t prog){ fProgressiveTukey = prog;}
  void        setCallExecuteManual   (Bool_t call) { fcallExecuteManual = call;}
  EInputMode  getInputMode           (void) { return fInputMode; }
  Double_t    getTukeyConstant       (void) { return fTukeyConst; }
  Int_t       getMaxIterations       (void) { return fMaxIterations; }
  Double_t    getEpsilon             (void) { return fEpsilon; }
  Float_t     getSeg0Chi2Cut()              { return fseg0Chi2Cut;}
  Int_t       getMinReqTracks()             { return fminReqTrack;}
  Double_t    getMinWindow()                { return fminWindow;}
  Bool_t      getProgessiveTukey(void)      { return fProgressiveTukey;}
  Int_t       doFit();


  static void setRejectEmbeddedTracks(Bool_t reject = kTRUE){rejectEmbeddedTracks = reject;}
  static void setUseEventSeqNumber   (Bool_t use    = kTRUE){useEventSeqNumber    = use;   }
  static void setSkipNoVertex        (Bool_t skip   = kTRUE){doSkipNoVertex       = skip;  }
  static void setSkipFakeSegments    (Bool_t skip   = kTRUE){doSkipFakeSegments   = skip;  }
protected:
  void initVars(void);
  Bool_t pointsToTarget(const HGeomVector &r,HGeomVector &alpha,Int_t sector,Int_t module,Double_t zmin,Double_t zmax);
  Bool_t readSegments  (HGeomVector &estimate);
  Bool_t readHits      (HGeomVector &estimate);
  void transform       (HMdcSeg *data, HGeomVector &r, HGeomVector &alpha);
  Bool_t hasConverged  (HGeomVector &v,HGeomVector &oldV);

  HGeomVertexFit fFitter;              //!
  TNtuple        *fControl;            //!
  TClonesArray   fPos;                 //! r for each track
  TClonesArray   fAlpha;               //! alpha vector for each track
  HCategory      *fInput;              //! Geant MDC data
  HMdcGeomPar    *fGeometry;           //! Geometry transformation
  HSpecGeomPar   *fSpecGeometry;       //! Spectrometer's geometry
  HIterator      *fIter;               //!
  Double_t       fTukeyConst;          // Value used as Tukey constant
  Int_t          fMaxIterations;       // Maximum number of iterations
  Bool_t         fUsingTukey;          // Flag turning on and off Tukey weights
  Bool_t         fDebugMode;           // Debug mode on/off
  Double_t       fEpsilon;             // Used for convergence criterium
  Double_t       fminZ;                //! minz range for segments
  Double_t       fmaxZ;                //! maxz range for segments
  Double_t       fmaxR;                //! maxr range for segments
  Float_t        fseg0Chi2Cut;         //! cut off in mom fit chi2
  Int_t          fminReqTrack;         //! minimum required tracks after mean z filter
  Double_t       fminWindow;           //! minimum window  for mean z filter
  Bool_t         fProgressiveTukey;    //! make stronger cut with rising mult
  Bool_t         fcallExecuteManual;   //!
  EInputMode     fInputMode;           //! Read segments or hits?
  Bool_t         isEmbedding;          //! kTRUE if is in embedding mode
  static Bool_t  rejectEmbeddedTracks; //! = kTRUE (default) reject embedded tracks from vertex calculation
  static Bool_t  useEventSeqNumber;    //! use the eventSeq Number decide of event skipping in embedding mode
  static Bool_t  doSkipNoVertex;       //! skip events if no vertex is calculated
  static Bool_t  doSkipFakeSegments;   //! skip fake segments (default = kTRUE)
  TIterator*     geantKineIter;        //! Iterator over GeantKine category

public:
 
  ClassDef(HMdcVertexFind,1)
};

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