ROOT  6.06/09
Reference Guide
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 #ifndef ROOT_TChain
29 #include <TChain.h>
30 #endif
31 #ifndef ROOT_TFile
32 #include <TFile.h>
33 #endif
34 #ifndef ROOT_TSelector
35 #include <TSelector.h>
36 #endif
37 #ifndef ROOT_TRef
38 #include <TRef.h>
39 #endif
40 #ifndef ROOT_Event
41 #include <Event.h>
42 #endif
43 
44 class TROOT;
45 class TH1F;
46 class TCanvas;
47 class THashList;
48 class TClonesArray;
49 class TRefArray;
50 class TPBReadType;
51 
52 class TSelEvent : public TSelector {
53 
54 private:
55 
56  TPBReadType *fReadType; //read type
57  Bool_t fDebug; //debug switch
58  TCanvas* fCHist; //canvas to display histograms
59 
60  //Output hists
63 
64 public :
65 
66  TTree *fChain; //!pointer to the analyzed TTree or TChain
67 
68  // Declaration of leave types
69 // Event *event;
79  Double32_t fClosestDistance[21]; //[fNvertex]
80  EventHeader fEvtHdr;
86  TH1F *fH;
89 
90  // List of branches
107  TBranch *b_fH; //!
110 
111  TSelEvent(TTree *);
112  TSelEvent();
113  //virtual ~TSelEvent() {if (fCHist) delete fCHist;}
114  virtual ~TSelEvent() {}
115  virtual Int_t Version() const {return 1;}
116  virtual void Begin(TTree *);
117  virtual void SlaveBegin(TTree *tree);
118  virtual void Init(TTree *tree);
119  virtual Bool_t Notify();
120  virtual Bool_t Process(Long64_t entry);
121  virtual void SetOption(const char *option) { fOption = option; }
122  virtual void SetObject(TObject *obj) { fObject = obj; }
123  virtual void SetInputList(TList *input) {fInput = input;}
124  virtual TList *GetOutputList() const { return fOutput; }
125  virtual void SlaveTerminate();
126  virtual void Terminate();
127 
129  Bool_t GetDebug(){return fDebug;}
130  TCanvas* GetCHist(){return fCHist;}
131  TH1F* GetPtHist(){return fPtHist;}
133 
134  ClassDef(TSelEvent,0) //PROOF selector for I/O-intensive benchmark test
135 };
136 
137 #endif
138 
139 #ifdef TSelEvent_cxx
140 void TSelEvent::Init(TTree *tree)
141 {
142  // The Init() function is called when the selector needs to initialize
143  // a new tree or chain. Typically here the branch addresses of the tree
144  // will be set. It is normaly not necessary to make changes to the
145  // generated code, but the routine can be extended by the user if needed.
146  // Init() will be called many times when running with PROOF.
147 
148  // Set branch addresses
149  fEventName=0;
150  fTracks=0;
151  fHighPt=0;
152  fMuons=0;
153  fH=0;
154 
155  if (tree == 0) return;
156  fChain = tree;
157  fChain->SetMakeClass(1);
158 
159  fChain->SetBranchAddress("fType[20]",fType);
160  fChain->SetBranchAddress("fEventName",fEventName);
161  fChain->SetBranchAddress("fNtrack",&fNtrack);
162  fChain->SetBranchAddress("fNseg",&fNseg);
163  fChain->SetBranchAddress("fNvertex",&fNvertex);
164  fChain->SetBranchAddress("fFlag",&fFlag);
165  fChain->SetBranchAddress("fTemperature",&fTemperature);
166  fChain->SetBranchAddress("fMeasures[10]",fMeasures);
167  fChain->SetBranchAddress("fMatrix[4][4]",fMatrix);
168  fChain->SetBranchAddress("fClosestDistance",fClosestDistance);
169  fChain->SetBranchAddress("fEvtHdr",&fEvtHdr);
170  fChain->SetBranchAddress("fTracks",&fTracks);
171  fChain->SetBranchAddress("fHighPt",&fHighPt);
172  fChain->SetBranchAddress("fMuons",&fMuons);
173  fChain->SetBranchAddress("fLastTrack",&fLastTrack);
174  fChain->SetBranchAddress("fWebHistogram",&fWebHistogram);
175  fChain->SetBranchAddress("fH",&fH);
176  fChain->SetBranchAddress("fTriggerBits",&fTriggerBits);
177  fChain->SetBranchAddress("fIsValid",&fIsValid);
178 }
179 
181 {
182  // The Notify() function is called when a new file is opened. This
183  // can be either for a new TTree in a TChain or when when a new TTree
184  // is started when using PROOF. Typically here the branch pointers
185  // will be retrieved. It is normaly not necessary to make changes
186  // to the generated code, but the routine can be extended by the
187  // user if needed.
188 
189  Info("Notify","processing file: %s", fChain->GetCurrentFile()->GetName());
190 
191  // Get branch pointers
192  b_event_fType = fChain->GetBranch("fType[20]");
193  b_fEventName = fChain->GetBranch("fEventName");
194  b_event_fNtrack = fChain->GetBranch("fNtrack");
195  b_event_fNseg = fChain->GetBranch("fNseg");
196  b_event_fNvertex = fChain->GetBranch("fNvertex");
197  b_event_fFlag = fChain->GetBranch("fFlag");
198  b_event_fTemperature = fChain->GetBranch("fTemperature");
199  b_event_fMeasures = fChain->GetBranch("fMeasures[10]");
200  b_event_fMatrix = fChain->GetBranch("fMatrix[4][4]");
201  b_fClosestDistance = fChain->GetBranch("fClosestDistance");
202  b_event_fEvtHdr = fChain->GetBranch("fEvtHdr");
203  b_fTracks = fChain->GetBranch("fTracks");
204  b_fHighPt = fChain->GetBranch("fHighPt");
205  b_fMuons = fChain->GetBranch("fMuons");
206  b_event_fLastTrack = fChain->GetBranch("fLastTrack");
207  b_event_fWebHistogram = fChain->GetBranch("fWebHistogram");
208  b_fH = fChain->GetBranch("fH");
209  b_event_fTriggerBits = fChain->GetBranch("fTriggerBits");
210  b_event_fIsValid = fChain->GetBranch("fIsValid");
211 
212  return kTRUE;
213 }
214 
215 #endif // #ifdef TSelEvent_cxx
Int_t fNseg
Definition: TSelEvent.h:73
Double32_t fMatrix[4][4]
Definition: TSelEvent.h:78
Char_t fType[20]
pointer to the analyzed TTree or TChain
Definition: TSelEvent.h:70
TBranch * b_event_fTemperature
Definition: TSelEvent.h:97
ROOT top level object description.
Definition: TROOT.h:80
TSelectorList * fOutput
Definition: TSelector.h:50
virtual Int_t Version() const
Definition: TSelEvent.h:115
TBranch * b_fMuons
Definition: TSelEvent.h:104
TBits fTriggerBits
Definition: TSelEvent.h:87
long long Long64_t
Definition: RtypesCore.h:69
TTree * fChain
Definition: TSelEvent.h:66
TBranch * b_event_fTriggerBits
Definition: TSelEvent.h:108
virtual ~TSelEvent()
Definition: TSelEvent.h:114
Char_t * fEventName
Definition: TSelEvent.h:71
TCanvas * fCHist
Definition: TSelEvent.h:58
TBranch * b_fTracks
Definition: TSelEvent.h:102
Double32_t fClosestDistance[21]
Definition: TSelEvent.h:79
TPBReadType * fReadType
Definition: TSelEvent.h:56
virtual TList * GetOutputList() const
Definition: TSelEvent.h:124
UInt_t fFlag
Definition: TSelEvent.h:75
TBranch * b_event_fMatrix
Definition: TSelEvent.h:99
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
virtual void Begin(TTree *)
The Begin() function is called at the start of the query.
Definition: TSelEvent.cxx:81
TBranch * b_event_fType
Definition: TSelEvent.h:91
TPBReadType * GetReadType()
Definition: TSelEvent.h:128
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:570
TBranch * b_event_fLastTrack
Definition: TSelEvent.h:105
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void Init(TTree *tree)
TBranch * b_event_fNseg
Definition: TSelEvent.h:94
An array of references to TObjects.
Definition: TRefArray.h:43
virtual void SlaveTerminate()
The SlaveTerminate() function is called after all entries or objects have been processed.
Definition: TSelEvent.cxx:255
TClonesArray * fTracks
Definition: TSelEvent.h:81
TFile * GetCurrentFile() const
Return pointer to the current file.
Definition: TTree.cxx:5006
TBranch * b_fEventName
Definition: TSelEvent.h:92
virtual void SetOption(const char *option)
Definition: TSelEvent.h:121
Persistent Reference link to a TObject A TRef is a lightweight object pointing to any TObject...
Definition: TRef.h:34
TRef fWebHistogram
Definition: TSelEvent.h:85
#define ClassDef(name, id)
Definition: Rtypes.h:254
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
Definition: TTree.cxx:7529
EventHeader fEvtHdr
Definition: TSelEvent.h:80
Bool_t fIsValid
Definition: TSelEvent.h:88
virtual void SlaveBegin(TTree *tree)
The SlaveBegin() function is called after the Begin() function.
Definition: TSelEvent.cxx:130
TString fOption
Definition: TSelector.h:47
double Double32_t
Definition: RtypesCore.h:56
TBranch * b_event_fEvtHdr
Definition: TSelEvent.h:101
A doubly linked list.
Definition: TList.h:47
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition: TTree.cxx:4822
TBranch * b_event_fMeasures
Definition: TSelEvent.h:98
TBranch * b_event_fFlag
Definition: TSelEvent.h:96
TObject * fObject
Definition: TSelector.h:48
Int_t fMeasures[10]
Definition: TSelEvent.h:77
TCanvas * GetCHist()
Definition: TSelEvent.h:130
TH1F * fPtHist
Definition: TSelEvent.h:61
Int_t fNvertex
Definition: TSelEvent.h:74
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
Int_t fNtrack
Definition: TSelEvent.h:72
TRefArray * fMuons
Definition: TSelEvent.h:83
Long64_t entry
TBranch * b_event_fIsValid
Definition: TSelEvent.h:109
The Canvas class.
Definition: TCanvas.h:48
virtual void SetMakeClass(Int_t make)
Set all the branches in this TTree to be in decomposed object mode (also known as MakeClass mode)...
Definition: TTree.cxx:8272
TH1F * GetPtHist()
Definition: TSelEvent.h:131
virtual Bool_t Process(Long64_t entry)
The Process() function is called for each entry in the tree (or possibly keyed object in the case of ...
Definition: TSelEvent.cxx:202
TBranch * b_fHighPt
Definition: TSelEvent.h:103
Double32_t fTemperature
Definition: TSelEvent.h:76
TSelEvent()
Constructor.
Definition: TSelEvent.cxx:64
virtual void SetInputList(TList *input)
Definition: TSelEvent.h:123
Mother of all ROOT objects.
Definition: TObject.h:58
TBranch * b_fClosestDistance
Definition: TSelEvent.h:100
Container of bits.
Definition: TBits.h:33
char Char_t
Definition: RtypesCore.h:29
TBranch * b_fH
Definition: TSelEvent.h:107
TBranch * b_event_fWebHistogram
Definition: TSelEvent.h:106
virtual Bool_t Notify()
This method must be overridden to handle object notification.
An array of clone (identical) objects.
Definition: TClonesArray.h:32
TList * fInput
Current object if processing object (vs. TTree)
Definition: TSelector.h:49
TRefArray * fHighPt
Definition: TSelEvent.h:82
virtual void SetObject(TObject *obj)
Definition: TSelEvent.h:122
virtual void Terminate()
The Terminate() function is the last function to be called during a query.
Definition: TSelEvent.cxx:264
TRef fLastTrack
Definition: TSelEvent.h:84
Bool_t GetDebug()
Definition: TSelEvent.h:129
TH1F * fNTracksHist
Definition: TSelEvent.h:62
TBranch * b_event_fNtrack
Definition: TSelEvent.h:93
A TTree object has a header with a name and a title.
Definition: TTree.h:94
TBranch * b_event_fNvertex
Definition: TSelEvent.h:95
TH1F * GetNTracksHist()
Definition: TSelEvent.h:132
A TTree is a list of TBranches.
Definition: TBranch.h:58
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:39
const Bool_t kTRUE
Definition: Rtypes.h:91
TObject * obj
Bool_t fDebug
Definition: TSelEvent.h:57
TH1F * fH
Definition: TSelEvent.h:86