StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EventT.h
1 #ifndef __EVENT__
2 #define __EVENT__
3 
4 // ROOT headers
5 #include "TObject.h"
6 #include "TClonesArray.h"
7 #include "TRefArray.h"
8 #include "TRef.h"
9 #include "THashList.h"
10 #include "TROOT.h"
11 #include "TFile.h"
12 #include "TChain.h"
13 #include "TTree.h"
14 
15 // StRoot headers
16 #include "HitT.h"
17 #include "TrackT.h"
18 
19 // C++ headers
20 #include <string>
21 
22 //________________
23 class TGeoHMatrix;
24 
25 //________________
26 class EventTHeader {
27  private:
28  Int_t fEvtNum;
29  Int_t fRun;
30  Int_t fDate;
31  Double32_t fField;
32  public:
33  EventTHeader() : fEvtNum(0), fRun(0), fDate(0), fField(0) { }
34  virtual ~EventTHeader() { }
35  void Set(Int_t i, Int_t r, Int_t d, Double32_t Field = 0)
36  { fEvtNum = i; fRun = r; fDate = d; fField = Field;}
37  Int_t GetEvtNum() const { return fEvtNum; }
38  Int_t GetRun() const { return fRun; }
39  Int_t GetDate() const { return fDate; }
40  Double32_t GetField() const {return fField;}
41 
42  ClassDef(EventTHeader,1) //EventT Header
43 };
44 class StEvent;
45 
46 //________________
47 class EventT : public TObject {
48 
49  private:
50  UInt_t fNPTracks;
51  UInt_t fNtrack; //Number of tracks
52  UInt_t fNhit; //Number of hits
53  UInt_t fFlag;
54  EventTHeader fEvtHdr;
55  Double32_t fVertex[3]; //
56  Double32_t fCovariantMatrix[6];//
57  TClonesArray *fTracks; //->array with all tracks
58  TClonesArray *fHits; //->array with all hits
59  Bool_t fIsValid; //
60 
61  static TClonesArray *fgTracks;
62  static TClonesArray *fgHits;
63  static THashList *fRotList;
64 
65  public:
66  EventT();
67  virtual ~EventT();
68  Int_t Build(StEvent *pEventT, Double_t pCut = 0.2);
69  void Clear(Option_t *option ="");
70  Bool_t IsValid() const { return fIsValid; }
71  static void Reset(Option_t *option ="");
72  void SetNtrack(UInt_t n) { fNtrack = n; }
73  void SetNhit(UInt_t n) { fNhit = n; }
74  void SetFlag(UInt_t f) { fFlag = f; }
75  void SetHeader(Int_t i, Int_t run, Int_t date, Double32_t field);
76  TrackT *AddTrackT();
77  HitT *AddHitT();
78  HitT *SetHitT(HitT *h, StHit *hit, TGeoHMatrix *comb, TrackT *track);
79  Double32_t GetVertex(UInt_t i=0) {return (i<3)?fVertex[i]:0;}
80  UInt_t GetTotalNoTracks() const {return fNPTracks;}
81  UInt_t GetNtrack() const { return fNtrack; }
82  UInt_t GetNhit() const { return fNhit; }
83  UInt_t GetFlag() const { return fFlag; }
84  EventTHeader *GetHeader() { return &fEvtHdr; }
85  const Double32_t *GetVertex() const {return fVertex;}
86  const Double32_t *GetCovMatrix() const {return fCovariantMatrix;}
87  TClonesArray *GetTracks() const {return fTracks;}
88  TClonesArray *GetHits() const {return fHits;}
89  TrackT *GetTrackT(UInt_t i=0) const {return fTracks && i < fNtrack ? (TrackT*) fTracks->At(i): 0;}
90  HitT *GetHitT(UInt_t i=0) const {return fHits && i < fNhit ? (HitT*) fHits->At(i): 0;}
91  Int_t GetIndexOfTrackT(const TrackT *obj) const {return fgTracks->IndexOf(obj);}
92  Int_t GetIndexOfHitT(const HitT *obj) const {return fgHits->IndexOf(obj);}
93  static void SetRotMatrices(THashList *Rot) {fRotList = Rot;}
94  static void RestoreListOfRotations();
95  static THashList *RotMatrices() {return fRotList;}
96  virtual void Print(Option_t *opt="") const;
97  ClassDef(EventT,1) //EventT structure
98 };
99 
100 //________________
101 class TBase {
102 
103  public :
104  TTree *fChain;
105  Int_t fCurrent;
107  TString fOutFileName;
108 
109  TBase( TTree *tree = 0,
110  const Char_t *f_name = "/star/data09/calib/fisyak/Pass112/TpcSsd/065/Event_6065045_raw_1010001.root") : fEvent(0) {
111  // if parameter tree is not specified (or zero), connect the file
112  // used to generate this class and read the Tree.
113  if (tree == 0) {
114  TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(f_name);
115  if (!f) {
116  f = new TFile(f_name);
117  }
118  tree = (TTree*)gDirectory->Get("T");
119  }
120  Init(tree);
121  }
122 
123  virtual ~TBase() {if (!fChain) return; delete fChain->GetCurrentFile();}
124  virtual Int_t Cut(Long64_t entry);
125  virtual Int_t GetEntry(Long64_t entry) { if (!fChain) return 0; return fChain->GetEntry(entry);}
126  virtual Long64_t LoadTree(Long64_t entry) {
127  // Set the environment to read one entry
128  if (!fChain) return -5;
129  Long64_t centry = fChain->LoadTree(entry);
130  if (centry < 0) return centry;
131  if (!fChain->InheritsFrom(TChain::Class())) return centry;
132  TChain *chain = (TChain*)fChain;
133  if (chain->GetTreeNumber() != fCurrent) {
134  fCurrent = chain->GetTreeNumber();
135  Notify();
136  }
137  return centry;
138  }
139  virtual void Init(TTree *tree) {
140  if (!tree) return;
141  fChain = tree;
142  fCurrent = -1;
143  fChain->SetMakeClass(1);
144  fEvent = new EventT();
145  TBranch *branch = fChain->GetBranch("EventT");
146  branch->SetAddress(&fEvent);
147  }
148  virtual void Loop() {Loop(0);}
149  virtual void Loop(Int_t Nevents);
150  virtual void SetOutFileName(const Char_t *name="Out.root") {fOutFileName = name;}
151  virtual Bool_t Notify() {return kTRUE;}
152  virtual void Show(Long64_t entry = -1) {if (!fChain) return; fChain->Show(entry);}
153 };
154 #endif
Definition: EventT.h:101
Definition: StHit.h:125
Definition: TrackT.h:15
Int_t fCurrent
pointer to the analyzed TTree or TChain
Definition: EventT.h:105
Definition: HitT.h:16
EventT * fEvent
current Tree number in a TChain
Definition: EventT.h:106
Definition: Cut.h:18
Definition: EventT.h:47