#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:
	
	
	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;	           
	
	HCategory              *fCatParticleCand;	   
        HCategory              *fCatParticleDebug;         
        HCategory              *fCatParticleMdc;         
	
	Bool_t                  fbIsSimulation;	      	   
	Bool_t                  fbIsDebug;                 
	Bool_t                  fbFillMdc;                 
	Bool_t                  fbgoodSeg0;                
        Bool_t                  fbgoodSeg1;                
        Bool_t                  fbgoodMeta;                
        Bool_t                  fbgoodRK;                  
        Bool_t                  fbgoodLepton;              
        Bool_t                  fbnoFake;                  
        Bool_t                  fbdoRichAlign;             
        Bool_t                  fbdoRichVertexCorr;        
        Bool_t                  fbdoMETAQANorm;            
        Bool_t                  fbdoMomentumCorr;          
        Bool_t                  fbdoPathLengthCorr;        
	Bool_t                  fbdoGeantAcceptance;       
	Int_t                   fmomSwitch;                
        Int_t                   fsortSwitch;               
	
        HParticleCandFillerPar *fFillerPar;                
        HTofWalkPar            *fTofWalkPar;                
        HMdcSizesCells         *fSizesCells;               
        HMdcLayer* cropLay;                                
	HRich700DigiPar* fRich700DigiPar;                  
	
	vector < candidate * > all_candidates;  
        
        Int_t   fMinWireGoodTrack;              
	Float_t fScaleGhostTrack;               
        Float_t fScaleGoodTrack;                
        Float_t fAngleCloseTrack;               
        Int_t  fRichCorrectionVersion;          
	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) 
};
#endif /* !__HPARTICLECAND_H__ */
 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