ROOT logo
#ifndef HROOTSOURCE_H
#define HROOTSOURCE_H

#include "hdatasource.h"
#include "haddef.h"
#include "hgeantdef.h"
#include "TFile.h"
#include "TChain.h"
#include "TTree.h"
#include <map>
#include "TString.h"
#include "TEventList.h"

class HRootSource : public HDataSource {
protected:
  TChain *fInput;         //TTree to be read.
  TString fDirectory;
  Stat_t fEntries;
  Bool_t fPersistency;
  Bool_t fMerge;
  Int_t fCursor;          //Number of next event.
  Int_t fSplitLevel;      //Split level of input tree
  Int_t fCurrentRunId;
  Int_t fCurrentRefId;
  Int_t fGlobalRefId;
  std::map<Int_t,Int_t> fRefIds;//!
  HEvent *fEventInFile;   //! Pointer to the event structure in file
  TEventList *fEventList;
  Int_t fLastRunId;  //! last run number (needed to detect switch to new run)
  Bool_t overwriteVersion; //! flag for modifying version
  Int_t replaceVersion;    //! value for replacing version is overwriteVersion=kTRUE

  Bool_t fileExists(const TString &name);
  virtual TFile * getFile(TString name);
  virtual TString getFileName(const Text_t file[]);
public:
  HRootSource(Bool_t fPersistent=kTRUE, Bool_t fMerge=kFALSE);
  ~HRootSource(void);
  void setEventList(TEventList *el) { fEventList = el; }
  virtual EDsState getNextEvent(Bool_t doUnpack=kTRUE);
  void setCursorToPreviousEvent();
  virtual EDsState skipEvents(Int_t nEv);
  Bool_t rewind() {fCursor=0; return kTRUE;}
  Bool_t init(void);
  Bool_t reinit(void) {return kTRUE; }
  Bool_t finalize(void) {return kTRUE;}
  Int_t getCurrentRunId(void) {return fCurrentRunId;}
  Int_t getCurrentRefId(void) {return fCurrentRefId;}
  Int_t getGlobalRefId(void) {return fGlobalRefId;}
  void  setCurrentRunId(Int_t id) {fCurrentRunId = id;}
  void setRefId(Int_t runId, Int_t refId) {
     fRefIds[runId]=refId;
     if(runId==fCurrentRunId) fCurrentRefId = refId;
  }
  void setGlobalRefId (Int_t refId) {
     fGlobalRefId=refId;
     if(fCurrentRefId==-1) fCurrentRefId = fGlobalRefId; 
  }
  Text_t const *getCurrentFileName(void);
  virtual Bool_t getEvent(Int_t eventN);
  void setDirectory(const Text_t dirName[]);
  Bool_t addFile(const Text_t file[]);
  Bool_t setInput(const Text_t *fileName,const Text_t *treeName);
  Bool_t disableCategory(Cat_t aCat);
  void deactivateBranch(const Text_t *branchName);
  Bool_t disablePartialEvent(Cat_t aCat);
  TTree *getTree(void);
  TChain* getChain(){return fInput;}
  Int_t getSplitLevel(void);
  virtual void Clear(void);
  void Print() {
    HDataSource::Print();
    if(fInput) {fInput->GetEntries(); fInput->ls();}
  } 
  void replaceHeaderVersion(Int_t vers,Bool_t replace=kTRUE){replaceVersion=vers;overwriteVersion=replace;}
  ClassDef(HRootSource,1) //Data source to read Root files.
};

#endif /* !HROOTSOURCE_H */


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