ROOT logo
#ifndef __HPARTICLECANDFILLER_H__
#define __HPARTICLECANDFILLER_H__

#include "hreconstructor.h"
#include "hparticlestructs.h"
#include "hmdcsizescells.h"
#include "hmdcgeomobj.h"
#include "hgeomvector.h"

using  std::vector;

class HCategory;
class HIterator;
class HMetaMatch2;
class HMdcSeg;
class HParticleCandFillerPar;
class HRich700DigiPar;
class HTofWalkPar;
class HMdcLayer;

class HParticleCandFiller : public HReconstructor {
protected:
	
	// input data categories
	HCategory              *fCatMetaMatch;		   //!
	HCategory              *fCatMdcTrkCand;	           //!
	HCategory              *fCatMdcSeg;    	           //!
	HCategory              *fCatTofHit;    	           //!
	HCategory              *fCatTofCluster;	           //!
	HCategory              *fCatShowerHit;	           //!
	HCategory              *fCatEmcCluster;	           //!
	HCategory              *fCatRichHit;   	           //!
	HCategory              *fCatRpcCluster;	           //!
	HCategory              *fCatSpline;    	           //!
	HCategory              *fCatRK;		           //!
	HCategory              *fCatKalman;   	           //!
	HCategory              *fCatGeantKine;	           //!
	
	HIterator              *fMetaMatchIter;	           //!

	// output data categories
	HCategory              *fCatParticleCand;	   //!
        HCategory              *fCatParticleDebug;         //!
        HCategory              *fCatParticleMdc;         //!

	// flags
	Bool_t                  fbIsSimulation;	      	   //!
	Bool_t                  fbIsDebug;                 //! debug mode ?
	Bool_t                  fbFillMdc;                 //! true: fill catParticleMdc
	Bool_t                  fbgoodSeg0;                //! true: keep only fitted seg0
        Bool_t                  fbgoodSeg1;                //! true: keep only fitted seg1
        Bool_t                  fbgoodMeta;                //! true: keep only candidate with META
        Bool_t                  fbgoodRK;                  //! true: keep only fitted RK
        Bool_t                  fbgoodLepton;              //! true: keep only candidate with ring match
        Bool_t                  fbnoFake;                  //! true: keep only candidate which is not markerd as fake rejected
        Bool_t                  fbdoRichAlign;             //! true: (default)align the rich (real data)
        Bool_t                  fbdoRichVertexCorr;        //! true: (default) do correction for vertexz pos in ring sorting
        Bool_t                  fbdoMETAQANorm;            //! true: (default) do normalization of RK meta dx
        Bool_t                  fbdoMomentumCorr;          //! true: (default) do systematic corrections on momentum
        Bool_t                  fbdoPathLengthCorr;        //! true: (default) do correction of path length to vertex
	Bool_t                  fbdoGeantAcceptance;       //! true: (default) loop geant kine and fill acceptance + crop bits
	Int_t                   fmomSwitch;                //! : Particle::kMomRK or Particle::kMomKalman
        Int_t                   fsortSwitch;               //! sort by quality (0), radius(1)
	// parameter container
        HParticleCandFillerPar *fFillerPar;                //!
        HTofWalkPar            *fTofWalkPar;                //!
        HMdcSizesCells         *fSizesCells;               //!
        HMdcLayer* cropLay;                                //!
	HRich700DigiPar* fRich700DigiPar;                  //!

	// working structures
	vector < candidate * > all_candidates;  //! vector for all metaMatch objects candidates.

        // cut parameters
        Int_t   fMinWireGoodTrack;              //! minium number of wire from same track for good track (MDC), otherwise ghost
	Float_t fScaleGhostTrack;               //! scale weight of wires of ghost track (MDC)
        Float_t fScaleGoodTrack;                //! scale weight of wires of good  track (MDC)
        Float_t fAngleCloseTrack;               //! take into account for filling neighbour tracks with open angle < this

        Int_t  fRichCorrectionVersion;          //! -1=init  0=apr12,aug14,jul14 , 1 = mar19

	void   initVars();
	void   setConditions(const Option_t par[]);
        Int_t  findBestRich(HMetaMatch2* meta,HMdcSeg* seg);

	void   fillCandNoMeta(Bool_t rkSuccess,HMetaMatch2* meta,candidate& cand,Int_t num);
        void   fillCandTof   (Bool_t rkSuccess,HMetaMatch2* meta,candidate& cand,Int_t num,Int_t slot);
        void   fillCandRpc   (Bool_t rkSuccess,HMetaMatch2* meta,candidate& cand,Int_t num,Int_t slot);
        void   fillCandShower(Bool_t rkSuccess,HMetaMatch2* meta,candidate& cand,Int_t num,Int_t slot);
        void   fillCandEmc   (Bool_t rkSuccess,HMetaMatch2* meta,candidate& cand,Int_t num,Int_t slot);

	void   fillCand(HMetaMatch2* meta);
	void   fillCandSim(candidate& cand);
	void   fillCollectiveProperties(void);
	void   fillSingleProperties    (void);
	void   fillOutput(void);
	void   clearVector(void);
        void   fillGeantAcceptance();
	void   checkCropLayer(HParticleCand* c);
public:
	HParticleCandFiller(const Option_t pOpt[] = "");
	HParticleCandFiller(const Text_t* name,const Text_t* title,const Option_t pOpt[] = "");
	~HParticleCandFiller(void);
	
	Bool_t init(void);
	Bool_t  reinit(void);
	Int_t  execute(void);
	Bool_t finalize(void);

	void setMinWireGoodTrack(Int_t w)  { fMinWireGoodTrack = w; }
        void setScaleGoodTrack (Float_t s) { fScaleGoodTrack   = s; }
        void setScaleGhostTrack(Float_t s) { fScaleGhostTrack  = s; }
        void setAngleCloseTrack(Float_t a) { fAngleCloseTrack  = a; }
        void setMomSwitch      (Int_t s  ) { fmomSwitch        = s; }
        void setDoAlignRich    (Bool_t align ) { fbdoRichAlign = align; }
        void setDoRichVertexCorr(Bool_t corr ) { fbdoRichVertexCorr = corr; }
        void setDoMETAQANorm   (Bool_t norm )  { fbdoMETAQANorm = norm; }
        void setDoMomentumCorr (Bool_t corr )  { fbdoMomentumCorr = corr; }
        void setDoPathLengthCorr(Bool_t corr ) { fbdoPathLengthCorr = corr; }
        void setDoGeantAcceptance(Bool_t acc)  { fbdoGeantAcceptance = acc; }
	void setFillMdc        (Bool_t fill)   { fbFillMdc     = fill;}
	void setSortMeta       (Int_t s=0)     { fsortSwitch = (s>=0&&s<2) ? s:0;}
	void setRichCorrectionVersion(Int_t vers) { fRichCorrectionVersion = vers;}

	ClassDef(HParticleCandFiller,0) // HMetaMatch -> HParticleCand
};

#endif /* !__HPARTICLECAND_H__ */

 hparticlecandfiller.h:1
 hparticlecandfiller.h:2
 hparticlecandfiller.h:3
 hparticlecandfiller.h:4
 hparticlecandfiller.h:5
 hparticlecandfiller.h:6
 hparticlecandfiller.h:7
 hparticlecandfiller.h:8
 hparticlecandfiller.h:9
 hparticlecandfiller.h:10
 hparticlecandfiller.h:11
 hparticlecandfiller.h:12
 hparticlecandfiller.h:13
 hparticlecandfiller.h:14
 hparticlecandfiller.h:15
 hparticlecandfiller.h:16
 hparticlecandfiller.h:17
 hparticlecandfiller.h:18
 hparticlecandfiller.h:19
 hparticlecandfiller.h:20
 hparticlecandfiller.h:21
 hparticlecandfiller.h:22
 hparticlecandfiller.h:23
 hparticlecandfiller.h:24
 hparticlecandfiller.h:25
 hparticlecandfiller.h:26
 hparticlecandfiller.h:27
 hparticlecandfiller.h:28
 hparticlecandfiller.h:29
 hparticlecandfiller.h:30
 hparticlecandfiller.h:31
 hparticlecandfiller.h:32
 hparticlecandfiller.h:33
 hparticlecandfiller.h:34
 hparticlecandfiller.h:35
 hparticlecandfiller.h:36
 hparticlecandfiller.h:37
 hparticlecandfiller.h:38
 hparticlecandfiller.h:39
 hparticlecandfiller.h:40
 hparticlecandfiller.h:41
 hparticlecandfiller.h:42
 hparticlecandfiller.h:43
 hparticlecandfiller.h:44
 hparticlecandfiller.h:45
 hparticlecandfiller.h:46
 hparticlecandfiller.h:47
 hparticlecandfiller.h:48
 hparticlecandfiller.h:49
 hparticlecandfiller.h:50
 hparticlecandfiller.h:51
 hparticlecandfiller.h:52
 hparticlecandfiller.h:53
 hparticlecandfiller.h:54
 hparticlecandfiller.h:55
 hparticlecandfiller.h:56
 hparticlecandfiller.h:57
 hparticlecandfiller.h:58
 hparticlecandfiller.h:59
 hparticlecandfiller.h:60
 hparticlecandfiller.h:61
 hparticlecandfiller.h:62
 hparticlecandfiller.h:63
 hparticlecandfiller.h:64
 hparticlecandfiller.h:65
 hparticlecandfiller.h:66
 hparticlecandfiller.h:67
 hparticlecandfiller.h:68
 hparticlecandfiller.h:69
 hparticlecandfiller.h:70
 hparticlecandfiller.h:71
 hparticlecandfiller.h:72
 hparticlecandfiller.h:73
 hparticlecandfiller.h:74
 hparticlecandfiller.h:75
 hparticlecandfiller.h:76
 hparticlecandfiller.h:77
 hparticlecandfiller.h:78
 hparticlecandfiller.h:79
 hparticlecandfiller.h:80
 hparticlecandfiller.h:81
 hparticlecandfiller.h:82
 hparticlecandfiller.h:83
 hparticlecandfiller.h:84
 hparticlecandfiller.h:85
 hparticlecandfiller.h:86
 hparticlecandfiller.h:87
 hparticlecandfiller.h:88
 hparticlecandfiller.h:89
 hparticlecandfiller.h:90
 hparticlecandfiller.h:91
 hparticlecandfiller.h:92
 hparticlecandfiller.h:93
 hparticlecandfiller.h:94
 hparticlecandfiller.h:95
 hparticlecandfiller.h:96
 hparticlecandfiller.h:97
 hparticlecandfiller.h:98
 hparticlecandfiller.h:99
 hparticlecandfiller.h:100
 hparticlecandfiller.h:101
 hparticlecandfiller.h:102
 hparticlecandfiller.h:103
 hparticlecandfiller.h:104
 hparticlecandfiller.h:105
 hparticlecandfiller.h:106
 hparticlecandfiller.h:107
 hparticlecandfiller.h:108
 hparticlecandfiller.h:109
 hparticlecandfiller.h:110
 hparticlecandfiller.h:111
 hparticlecandfiller.h:112
 hparticlecandfiller.h:113
 hparticlecandfiller.h:114
 hparticlecandfiller.h:115
 hparticlecandfiller.h:116
 hparticlecandfiller.h:117
 hparticlecandfiller.h:118
 hparticlecandfiller.h:119
 hparticlecandfiller.h:120
 hparticlecandfiller.h:121
 hparticlecandfiller.h:122
 hparticlecandfiller.h:123
 hparticlecandfiller.h:124
 hparticlecandfiller.h:125
 hparticlecandfiller.h:126
 hparticlecandfiller.h:127
 hparticlecandfiller.h:128
 hparticlecandfiller.h:129