ROOT logo
#ifndef __HPARTICLETREE_H__
#define __HPARTICLETREE_H__

#include "TObject.h"
#include "TObjArray.h"

#include "hreconstructor.h"
#include "htree.h"
#include "hrecevent.h"
#include "hparticletracksorter.h"
#include "hparticledef.h"

#include <TFile.h>

#include <map>
#include <vector>
using namespace std;

class HParticleCand;
class HSrcKeeper;
class HGeantMedia;
class HMdcLayer;

class HParticleTree : public HReconstructor
{
private:

    HRecEvent*         fCurrentEvent;      //! Event under reconstruction
    TFile*             fOutputFile;        //! File used to store the output tree
    HTree*             fTree;              //! Output tree
    Int_t              fCycleNumber;       //! cycle number of output file
    TString            fOutputFileName;    //! output file name (derived from hades output name)
    TString            fOutputTitle;       //! output file title
    TString            fOutputOption;      //! output file option
    Int_t              fOutputCompression; //! output file compression
    TString            fOutputFileSuffix;  //! replace .root by fOutputFileSuffix.root
    TString            fOutputDir;         //! outputdir
    Bool_t             fOutFound;          //!

    Bool_t             kSkipEmptyEvents;   //! kTRUE = skip not selected events (default = kFALSE)
    Bool_t             kSkipTracks;        //! kTRUE = skip not selected tracks (default = kTRUE)
    Bool_t             kDoSorter;          //! kTRUE run new tracksorter        (default = kTRUE)

    Particle::ESwitch sortType;

    HParticleTrackSorter sorter;

    HSrcKeeper*  keeper;    //!
    HGeantMedia* media;     //!
    HMdcLayer*   mdclayer;  //!

    vector <Int_t>              fCatNums;           //! list of persistent output categories
    map    <TString,Int_t>      fmCatNameToNum;     //!
    map    <Int_t,TString>      fmCatNumToName;     //!
    map    <Int_t,HCategory*>   fmCatNumToPointer;  //!
    map    <TString,HCategory*> fmCatNameToPointer; //!
    map    <Int_t,Int_t>        fmCatNumToFullCopy; //!
    vector <Int_t>              fmCatNumSupport;    //!
    vector <Int_t>              fmCatNumFullCopySupport; //!

    Bool_t (*pUserSelectEvent)  (TObjArray* );     //! user provided function pointer event selection (TObjArray for parameters)
    Bool_t (*pUserSelectLeptons)(HParticleCand* ); //! user provided function pointer to lepton selection
    Bool_t (*pUserSelectHadrons)(HParticleCand* ); //! user provided function pointer to hadron selection
    Bool_t (*pUserKeepTrack)    (HParticleCand* ); //! user provided function pointer to keep/discard tracks independent of sorterflags

    TObjArray* fParamSelectEvent;                  //! object array for optional parameters of event selection function

    Bool_t  makeTree       (void);         // create output tree
    void    recreateOutput (void);         // open new output file if max filesize is reached
    void    closeOutput    (void);         // close output file
    void    setEvent       (void);         // setup the event layout
    void    extractMdcSeg(HParticleCand* cand, Bool_t isSim,Int_t segInd1,Int_t&segInd2);
    void    extractMdcCal1(Bool_t isSim,Int_t segInd);
    void    extractMdcCal1FromClus(Bool_t isSim,Int_t segInd);

    Int_t ctMdcSeg [6][2];                     //!
    Int_t ctMdcClus[6][2];                     //!
    Int_t ctMdcHit [6][4];                     //!
    Int_t ctRpcClus[6]   ;                     //!

    Bool_t doFullCopy(Cat_t cat);

public:

    HParticleTree(const Text_t *name = "",const Text_t *title ="");
    virtual ~HParticleTree();

    Bool_t  init();
    Int_t   execute();
    Bool_t  finalize();
    void    setSkipEmptyEvents (Bool_t skip) { kSkipEmptyEvents = skip; }
    void    setSkipTracks      (Bool_t skip) { kSkipTracks      = skip; }

    void    setOutputFile      (TString fname  = "filter_tree.root",
                                TString ftitle = "Filter",
                                TString fopt   = "RECREATE",
                                Int_t   fcomp  = 2
			       );
    void    setOutputFileSuffix(TString suff  = "filter_tree") { fOutputFileSuffix = suff;}
    void    setOutputDir       (TString dir   = "")            { fOutputDir        = dir ;}
    void    setEventStructure  (Int_t n,Cat_t PersistentCat[],Bool_t fullCopy=kFALSE);

    void    setSortType(Particle::ESwitch type) { sortType = type; }
    void    setDoSorter           (Bool_t sort)           { kDoSorter=sort;}


    sorter_setup&  getSorterSetup() {return sorter.getSetup();}

    void    setIgnoreRICH         (Bool_t ignore = kTRUE) { sorter.getSetup().kIgnoreRICH          = ignore;}
    void    setIgnoreInnerMDC     (Bool_t ignore = kTRUE) { sorter.getSetup().kIgnoreInnerMDC      = ignore;}
    void    setIgnoreOuterMDC     (Bool_t ignore = kTRUE) { sorter.getSetup().kIgnoreOuterMDC      = ignore;}
    void    setIgnoreMETA         (Bool_t ignore = kTRUE) { sorter.getSetup().kIgnoreMETA          = ignore;}
    void    setIgnorePreviousIndex(Bool_t ignore = kTRUE) { sorter.getSetup().kIgnorePreviousIndex = ignore;}
    void    setRICHMatching(Particle::ERichMatch match, Float_t window = 4.) {
	sorter.getSetup().kSwitchRICHMatching = match;
	sorter.getSetup().fRICHMDCWindow      = window;
    }


    void    setUserSelectionEvent  (Bool_t (*function)(TObjArray*),TObjArray* ar) { pUserSelectEvent   = function; fParamSelectEvent = ar;}
    void    setUserSelectionLeptons(Bool_t (*function)(HParticleCand* )){ pUserSelectLeptons = function;}
    void    setUserSelectionHadrons(Bool_t (*function)(HParticleCand* )){ pUserSelectHadrons = function;}

    void    setUserkeepTrack(Bool_t (*function)(HParticleCand* )){ pUserKeepTrack = function;}

    ClassDef(HParticleTree,0)  // A task to create an fitered  root output
};


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