ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProofEventProc.h
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_ProofEventProc
3 ///
4 /// Selector to process trees containing Event structures
5 ///
6 /// \macro_code
7 ///
8 /// \author Gerardo Ganis (gerardo.ganis@cern.ch)
9 
10 #ifndef ProofEventProc_h
11 #define ProofEventProc_h
12 
13 #include <TROOT.h>
14 #include <TChain.h>
15 #include <TFile.h>
16 #include <TSelector.h>
17 #include "Event.h"
18 #include "ProcFileElements.h"
19 
20 class TH1F;
21 class TH2F;
22 
23 class ProofEventProc : public TSelector {
24 public :
25  TTree *fChain; //!pointer to the analyzed TTree or TChain
26 
27  // Declaration of leave types
28  Event *event;
29  Char_t fType[20];
30  Char_t *fEventName;
31  Int_t fNtrack;
32  Int_t fNseg;
33  Int_t fNvertex;
34  UInt_t fFlag;
35  Double32_t fTemperature;
36  Int_t fMeasures[10];
37  Double32_t fMatrix[4][4];
38  Double32_t fClosestDistance[21]; //[fNvertex]
39  EventHeader fEvtHdr;
40  TClonesArray *fTracks;
41  TRefArray *fHighPt;
42  TRefArray *fMuons;
43  TRef fLastTrack;
44  TRef fWebHistogram;
45  TH1F *fH;
46  TBits fTriggerBits;
47  Bool_t fIsValid;
48  void InitEvent() { event = 0 ; fEventName = 0; fTracks = 0;
49  fHighPt = 0; fMuons = 0; fH = 0; fIsValid = kFALSE; }
50 
51  // Read controller
52  Bool_t fFullRead;
53 
54  // Abortion test
55  Int_t fTestAbort; // -1 none, 0 init, 1 file
56 
57  // Event ranges
58  Long64_t fEntMin; // Min entry num of the current element
59  Long64_t fEntMax; // Max entry num of the current element
60  TList *fProcElems; // List of ProcFileElements processed so far
61  ProcFileElements *fProcElem; // Element currently processed
62  void CheckRanges();
63 
64  //Output hist
65  TH1F* fPtHist;
66  TH1F* fPzHist;
67  TH2F* fPxPyHist;
68 
69  // List of branches
70  TBranch *b_event_fType; //!
71  TBranch *b_fEventName; //!
72  TBranch *b_event_fNtrack; //!
73  TBranch *b_event_fNseg; //!
74  TBranch *b_event_fNvertex; //!
75  TBranch *b_event_fFlag; //!
76  TBranch *b_event_fTemperature; //!
77  TBranch *b_event_fMeasures; //!
78  TBranch *b_event_fMatrix; //!
79  TBranch *b_fClosestDistance; //!
80  TBranch *b_event_fEvtHdr; //!
81  TBranch *b_fTracks; //!
82  TBranch *b_fHighPt; //!
83  TBranch *b_fMuons; //!
84  TBranch *b_event_fLastTrack; //!
85  TBranch *b_event_fWebHistogram; //!
86  TBranch *b_fH; //!
87  TBranch *b_event_fTriggerBits; //!
88  TBranch *b_event_fIsValid; //!
89 
90  ProofEventProc(TTree *) { InitEvent(); fFullRead = kTRUE; fTestAbort = -1;
91  fPtHist = 0; fPzHist = 0; fPxPyHist = 0;
92  fEntMin = -1; fEntMax = -1; fProcElems = 0; fProcElem = 0;}
93  ProofEventProc() { InitEvent(); fFullRead = kTRUE; fTestAbort = -1;
94  fPtHist = 0; fPzHist = 0; fPxPyHist = 0;
95  fEntMin = -1; fEntMax = -1; fProcElems = 0; fProcElem = 0;}
96  virtual ~ProofEventProc() {if (fProcElems) { fProcElems->SetOwner(kFALSE);
97  delete fProcElems;} }
98  virtual Int_t Version() const {return 1;}
99  virtual void Begin(TTree *);
100  virtual void SlaveBegin(TTree *tree);
101  virtual void Init(TTree *tree);
102  virtual Bool_t Notify();
103  virtual Bool_t Process(Long64_t entry);
104  virtual void SetOption(const char *option) { fOption = option; }
105  virtual void SetObject(TObject *obj) { fObject = obj; }
106  virtual void SetInputList(TList *input) {fInput = input;}
107  virtual TList *GetOutputList() const { return fOutput; }
108  virtual void SlaveTerminate();
109  virtual void Terminate();
110 
111  ClassDef(ProofEventProc,0);
112 };
113 
114 #endif
115 
116 #ifdef ProofEventProc_cxx
117 void ProofEventProc::Init(TTree *tree)
118 {
119  // The Init() function is called when the selector needs to initialize
120  // a new tree or chain. Typically here the branch addresses of the tree
121  // will be set. It is normaly not necessary to make changes to the
122  // generated code, but the routine can be extended by the user if needed.
123  // Init() will be called many times when running with PROOF.
124 
125  // Set branch addresses
126  fEventName=0;
127  fTracks=0;
128  fHighPt=0;
129  fMuons=0;
130  fH=0;
131  if (tree == 0) return;
132  fChain = tree;
133  fChain->SetMakeClass(1);
134 
135  fChain->SetBranchAddress("fType[20]",fType);
136  fChain->SetBranchAddress("fEventName",fEventName);
137  fChain->SetBranchAddress("fNtrack",&fNtrack);
138  fChain->SetBranchAddress("fNseg",&fNseg);
139  fChain->SetBranchAddress("fNvertex",&fNvertex);
140  fChain->SetBranchAddress("fFlag",&fFlag);
141  fChain->SetBranchAddress("fTemperature",&fTemperature);
142  fChain->SetBranchAddress("fMeasures[10]",fMeasures);
143  fChain->SetBranchAddress("fMatrix[4][4]",fMatrix);
144  fChain->SetBranchAddress("fClosestDistance",fClosestDistance);
145  fChain->SetBranchAddress("fEvtHdr",&fEvtHdr);
146  fChain->SetBranchAddress("fTracks",&fTracks);
147  fChain->SetBranchAddress("fHighPt",&fHighPt);
148  fChain->SetBranchAddress("fMuons",&fMuons);
149  fChain->SetBranchAddress("fLastTrack",&fLastTrack);
150  fChain->SetBranchAddress("fWebHistogram",&fWebHistogram);
151  fChain->SetBranchAddress("fH",&fH);
152  fChain->SetBranchAddress("fTriggerBits",&fTriggerBits);
153  fChain->SetBranchAddress("fIsValid",&fIsValid);
154 }
155 
157 {
158  // The Notify() function is called when a new file is opened. This
159  // can be either for a new TTree in a TChain or when when a new TTree
160  // is started when using PROOF. Typically here the branch pointers
161  // will be retrieved. It is normaly not necessary to make changes
162  // to the generated code, but the routine can be extended by the
163  // user if needed.
164 
165  TString fn(fChain->GetCurrentFile()->GetName());
166  Info("Notify", "processing file: %s", fn.Data());
167 
168  // Save information about previous element, if any
169  if (fProcElem) fProcElem->Add(fEntMin, fEntMax);
170 
171  // Reset counters
172  fEntMin = -1;
173  fEntMax = -1;
174 
175  // Point to current element
176  if (fProcElems) fProcElem = (ProcFileElements *) fProcElems->FindObject(fn);
177  if (!fProcElem) {
178  Info("Notify", "assigned new file: create ProcFileElements entry");
179  fProcElem = new ProcFileElements(fn.Data());
180  if (!fProcElems) fProcElems = new TList;
181  if (fProcElems) fProcElems->Add(fProcElem);
182  }
183 
184  // Get branch pointers
185  b_event_fType = fChain->GetBranch("fType[20]");
186  b_fEventName = fChain->GetBranch("fEventName");
187  b_event_fNtrack = fChain->GetBranch("fNtrack");
188  b_event_fNseg = fChain->GetBranch("fNseg");
189  b_event_fNvertex = fChain->GetBranch("fNvertex");
190  b_event_fFlag = fChain->GetBranch("fFlag");
191  b_event_fTemperature = fChain->GetBranch("fTemperature");
192  b_event_fMeasures = fChain->GetBranch("fMeasures[10]");
193  b_event_fMatrix = fChain->GetBranch("fMatrix[4][4]");
194  b_fClosestDistance = fChain->GetBranch("fClosestDistance");
195  b_event_fEvtHdr = fChain->GetBranch("fEvtHdr");
196  b_fTracks = fChain->GetBranch("fTracks");
197  b_fHighPt = fChain->GetBranch("fHighPt");
198  b_fMuons = fChain->GetBranch("fMuons");
199  b_event_fLastTrack = fChain->GetBranch("fLastTrack");
200  b_event_fWebHistogram = fChain->GetBranch("fWebHistogram");
201  b_fH = fChain->GetBranch("fH");
202  b_event_fTriggerBits = fChain->GetBranch("fTriggerBits");
203  b_event_fIsValid = fChain->GetBranch("fIsValid");
204 
205  return kTRUE;
206 }
207 
208 #endif // #ifdef ProofEventProc_cxx
virtual int Version() const
Definition: TSelector.h:60
TSelectorList * fOutput
Definition: TSelector.h:50
long long Long64_t
Definition: RtypesCore.h:69
virtual Bool_t Notify()
This method must be overridden to handle object notification.
Definition: TSelector.h:64
virtual TList * GetOutputList() const
Definition: TSelector.h:76
Bool_t Notify()
Definition: TTimer.cxx:65
Basic string class.
Definition: TString.h:137
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:570
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
An array of references to TObjects.
Definition: TRefArray.h:43
virtual void SetInputList(TList *input)
Definition: TSelector.h:73
Class to hold information about the processed elements of a file.
Persistent Reference link to a TObject A TRef is a lightweight object pointing to any TObject...
Definition: TRef.h:34
#define ClassDef(name, id)
Definition: Rtypes.h:254
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:118
void Info(const char *location, const char *msgfmt,...)
virtual void Begin(TTree *)
Definition: TSelector.h:62
double Double32_t
Definition: RtypesCore.h:56
A doubly linked list.
Definition: TList.h:47
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:256
virtual void SlaveBegin(TTree *)
Definition: TSelector.h:63
unsigned int UInt_t
Definition: RtypesCore.h:42
Long64_t entry
virtual void Terminate()
Definition: TSelector.h:78
virtual void SlaveTerminate()
Definition: TSelector.h:77
PyObject * fType
tuple tree
Definition: tree.py:24
virtual Bool_t Process(Long64_t)
Definition: TSelector.cxx:290
virtual void SetObject(TObject *obj)
Definition: TSelector.h:72
virtual void SetOption(const char *option)
Definition: TSelector.h:71
Mother of all ROOT objects.
Definition: TObject.h:58
Container of bits.
Definition: TBits.h:33
char Char_t
Definition: RtypesCore.h:29
An array of clone (identical) objects.
Definition: TClonesArray.h:32
virtual void Add(TObject *obj)
Definition: TList.h:81
A TTree object has a header with a name and a title.
Definition: TTree.h:98
TGMatrixLayout * fMatrix
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
virtual void Init(TTree *)
Definition: TSelector.h:61