Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TSelEvent.h
Go to the documentation of this file.
1 // @(#)root/proof:$Id$
2 // Author: Sangsu Ryu 22/06/2010
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TSelEvent
13 #define ROOT_TSelEvent
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TSelEvent //
18 // //
19 // PROOF selector for I/O benchmark test. //
20 // For I/O benchmark, event files are read in and histograms are filled.//
21 // For memory clean-up, dedicated files large enough to clean up memory //
22 // cache on the machine are read in. Or memory clean-up can be //
23 // accompolished by system call on Linux machine inside SlaveBegin(..) //
24 // which should be much faster the reading in large files. //
25 // //
26 //////////////////////////////////////////////////////////////////////////
27 
28 #include <TChain.h>
29 #include <TFile.h>
30 #include <TSelector.h>
31 #include <TRef.h>
32 #include <Event.h>
33 
34 class TROOT;
35 class TH1F;
36 class TCanvas;
37 class THashList;
38 class TClonesArray;
39 class TRefArray;
40 class TPBReadType;
41 
42 class TSelEvent : public TSelector {
43 
44 private:
45 
46  TPBReadType *fReadType; //read type
47  Bool_t fDebug; //debug switch
48  TCanvas* fCHist; //canvas to display histograms
49 
50  //Output hists
51  TH1F* fPtHist;
52  TH1F* fNTracksHist;
53 
54 public :
55 
56  TTree *fChain; //!pointer to the analyzed TTree or TChain
57 
58  // Declaration of leave types
59 // Event *event;
60  Char_t fType[20];
61  Char_t *fEventName;
62  Int_t fNtrack;
63  Int_t fNseg;
64  Int_t fNvertex;
65  UInt_t fFlag;
66  Double32_t fTemperature;
67  Int_t fMeasures[10];
68  Double32_t fMatrix[4][4];
69  Double32_t fClosestDistance[21]; //[fNvertex]
70  EventHeader fEvtHdr;
71  TClonesArray *fTracks;
72  TRefArray *fHighPt;
73  TRefArray *fMuons;
74  TRef fLastTrack;
75  TRef fWebHistogram;
76  TH1F *fH;
77  TBits fTriggerBits;
78  Bool_t fIsValid;
79 
80  // List of branches
81  TBranch *b_event_fType; //!
82  TBranch *b_fEventName; //!
83  TBranch *b_event_fNtrack; //!
84  TBranch *b_event_fNseg; //!
85  TBranch *b_event_fNvertex; //!
86  TBranch *b_event_fFlag; //!
87  TBranch *b_event_fTemperature; //!
88  TBranch *b_event_fMeasures; //!
89  TBranch *b_event_fMatrix; //!
90  TBranch *b_fClosestDistance; //!
91  TBranch *b_event_fEvtHdr; //!
92  TBranch *b_fTracks; //!
93  TBranch *b_fHighPt; //!
94  TBranch *b_fMuons; //!
95  TBranch *b_event_fLastTrack; //!
96  TBranch *b_event_fWebHistogram; //!
97  TBranch *b_fH; //!
98  TBranch *b_event_fTriggerBits; //!
99  TBranch *b_event_fIsValid; //!
100 
101  TSelEvent(TTree *);
102  TSelEvent();
103  //virtual ~TSelEvent() {if (fCHist) delete fCHist;}
104  virtual ~TSelEvent() {}
105  virtual Int_t Version() const {return 1;}
106  virtual void Begin(TTree *);
107  virtual void SlaveBegin(TTree *tree);
108  virtual void Init(TTree *tree);
109  virtual Bool_t Notify();
110  virtual Bool_t Process(Long64_t entry);
111  virtual void SetOption(const char *option) { fOption = option; }
112  virtual void SetObject(TObject *obj) { fObject = obj; }
113  virtual void SetInputList(TList *input) {fInput = input;}
114  virtual TList *GetOutputList() const { return fOutput; }
115  virtual void SlaveTerminate();
116  virtual void Terminate();
117 
118  TPBReadType *GetReadType() {return fReadType;}
119  Bool_t GetDebug(){return fDebug;}
120  TCanvas* GetCHist(){return fCHist;}
121  TH1F* GetPtHist(){return fPtHist;}
122  TH1F* GetNTracksHist(){return fNTracksHist;}
123 
124  ClassDef(TSelEvent,0) //PROOF selector for I/O-intensive benchmark test
125 };
126 
127 #endif
128 
129 #ifdef TSelEvent_cxx
130 void TSelEvent::Init(TTree *tree)
131 {
132  // The Init() function is called when the selector needs to initialize
133  // a new tree or chain. Typically here the branch addresses of the tree
134  // will be set. It is normaly not necessary to make changes to the
135  // generated code, but the routine can be extended by the user if needed.
136  // Init() will be called many times when running with PROOF.
137 
138  // Set branch addresses
139  fEventName=0;
140  fTracks=0;
141  fHighPt=0;
142  fMuons=0;
143  fH=0;
144 
145  if (tree == 0) return;
146  fChain = tree;
147  fChain->SetMakeClass(1);
148 
149  fChain->SetBranchAddress("fType[20]",fType);
150  fChain->SetBranchAddress("fEventName",fEventName);
151  fChain->SetBranchAddress("fNtrack",&fNtrack);
152  fChain->SetBranchAddress("fNseg",&fNseg);
153  fChain->SetBranchAddress("fNvertex",&fNvertex);
154  fChain->SetBranchAddress("fFlag",&fFlag);
155  fChain->SetBranchAddress("fTemperature",&fTemperature);
156  fChain->SetBranchAddress("fMeasures[10]",fMeasures);
157  fChain->SetBranchAddress("fMatrix[4][4]",fMatrix);
158  fChain->SetBranchAddress("fClosestDistance",fClosestDistance);
159  fChain->SetBranchAddress("fEvtHdr",&fEvtHdr);
160  fChain->SetBranchAddress("fTracks",&fTracks);
161  fChain->SetBranchAddress("fHighPt",&fHighPt);
162  fChain->SetBranchAddress("fMuons",&fMuons);
163  fChain->SetBranchAddress("fLastTrack",&fLastTrack);
164  fChain->SetBranchAddress("fWebHistogram",&fWebHistogram);
165  fChain->SetBranchAddress("fH",&fH);
166  fChain->SetBranchAddress("fTriggerBits",&fTriggerBits);
167  fChain->SetBranchAddress("fIsValid",&fIsValid);
168 }
169 
170 Bool_t TSelEvent::Notify()
171 {
172  // The Notify() function is called when a new file is opened. This
173  // can be either for a new TTree in a TChain or when when a new TTree
174  // is started when using PROOF. Typically here the branch pointers
175  // will be retrieved. It is normaly not necessary to make changes
176  // to the generated code, but the routine can be extended by the
177  // user if needed.
178 
179  Info("Notify","processing file: %s", fChain->GetCurrentFile()->GetName());
180 
181  // Get branch pointers
182  b_event_fType = fChain->GetBranch("fType[20]");
183  b_fEventName = fChain->GetBranch("fEventName");
184  b_event_fNtrack = fChain->GetBranch("fNtrack");
185  b_event_fNseg = fChain->GetBranch("fNseg");
186  b_event_fNvertex = fChain->GetBranch("fNvertex");
187  b_event_fFlag = fChain->GetBranch("fFlag");
188  b_event_fTemperature = fChain->GetBranch("fTemperature");
189  b_event_fMeasures = fChain->GetBranch("fMeasures[10]");
190  b_event_fMatrix = fChain->GetBranch("fMatrix[4][4]");
191  b_fClosestDistance = fChain->GetBranch("fClosestDistance");
192  b_event_fEvtHdr = fChain->GetBranch("fEvtHdr");
193  b_fTracks = fChain->GetBranch("fTracks");
194  b_fHighPt = fChain->GetBranch("fHighPt");
195  b_fMuons = fChain->GetBranch("fMuons");
196  b_event_fLastTrack = fChain->GetBranch("fLastTrack");
197  b_event_fWebHistogram = fChain->GetBranch("fWebHistogram");
198  b_fH = fChain->GetBranch("fH");
199  b_event_fTriggerBits = fChain->GetBranch("fTriggerBits");
200  b_event_fIsValid = fChain->GetBranch("fIsValid");
201 
202  return kTRUE;
203 }
204 
205 #endif // #ifdef TSelEvent_cxx