Logo ROOT   6.12/07
Reference Guide
ProofFriends.h
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_ProofFriends
3 ///
4 /// Selector to process tree friends
5 ///
6 /// \macro_code
7 ///
8 /// \author Gerardo Ganis (gerardo.ganis@cern.ch)
9 
10 #ifndef ProofFriends_h
11 #define ProofFriends_h
12 
13 #include "TChain.h"
14 #include "TSelector.h"
15 
16 class TH1F;
17 class TH2F;
18 
19 class ProofFriends : public TSelector {
20 public :
21  TTree *fChain; //!pointer to the analyzed TTree or TChain
22 
23  Bool_t fPlot; // Whether to plot the result
24  Bool_t fDoFriends; // Whether to use the friend tree
25 
26  // Specific members
27  TH2F *fXY;
28  TH1F *fZ;
29  TH1F *fR;
30  TH2F *fRZ;
31 
32  // Declaration of leaf types
33  Int_t Run;
34  Long64_t Event;
35  Float_t x;
36  Float_t y;
37  Float_t z;
38 
39  Float_t r; // The friend
40 
41  // List of branches
42  TBranch *b_Run; //!
43  TBranch *b_Event; //!
44  TBranch *b_x; //!
45  TBranch *b_y; //!
46  TBranch *b_z; //!
47 
48  TBranch *b_r; //! The friend branch
49 
50  ProofFriends();
51  virtual ~ProofFriends() { }
52  virtual Int_t Version() const { return 2; }
53  virtual void Begin(TTree *tree);
54  virtual void SlaveBegin(TTree *tree);
55  virtual void Init(TTree *tree);
56  virtual Bool_t Notify();
57  virtual Bool_t Process(Long64_t entry);
58  virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; }
59  virtual void SetOption(const char *option) { fOption = option; }
60  virtual void SetObject(TObject *obj) { fObject = obj; }
61  virtual void SetInputList(TList *input) { fInput = input; }
62  virtual TList *GetOutputList() const { return fOutput; }
63  virtual void SlaveTerminate();
64  virtual void Terminate();
65 
66  ClassDef(ProofFriends,0);
67 };
68 
69 #endif
70 
71 #ifdef ProofFriends_cxx
73 {
74  // The Init() function is called when the selector needs to initialize
75  // a new tree or chain. Typically here the branch addresses and branch
76  // pointers of the tree will be set.
77  // It is normally not necessary to make changes to the generated
78  // code, but the routine can be extended by the user if needed.
79  // Init() will be called many times when running on PROOF
80  // (once per file to be processed).
81 
82  // Set branch addresses and branch pointers
83  if (!tree) return;
84  fChain = tree;
85  fChain->SetMakeClass(1);
86 
87  fChain->SetBranchAddress("Run", &Run, &b_Run);
88  fChain->SetBranchAddress("Event", &Event, &b_Event);
89  fChain->SetBranchAddress("x", &x, &b_x);
90  fChain->SetBranchAddress("y", &y, &b_y);
91  fChain->SetBranchAddress("z", &z, &b_z);
92 
93  fChain->SetBranchAddress("r", &r, &b_r); // The friend
94 }
95 
96 Bool_t ProofFriends::Notify()
97 {
98  // The Notify() function is called when a new file is opened. This
99  // can be either for a new TTree in a TChain or when when a new TTree
100  // is started when using PROOF. It is normally not necessary to make changes
101  // to the generated code, but the routine can be extended by the
102  // user if needed. The return value is currently not used.
103 
104  return kTRUE;
105 }
106 
107 #endif // #ifdef ProofFriends_cxx
virtual Int_t GetEntry(Long64_t, Int_t=0)
Definition: TSelector.h:61
TSelectorList * fOutput
! List of objects created during processing
Definition: TSelector.h:44
long long Long64_t
Definition: RtypesCore.h:69
virtual Bool_t Notify()
This method must be overridden to handle object notification.
Definition: TSelector.h:58
float Float_t
Definition: RtypesCore.h:53
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
Definition: TTree.cxx:5330
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:567
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void SetInputList(TList *input)
Definition: TSelector.h:68
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
Definition: TTree.cxx:7898
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:119
virtual void Begin(TTree *)
Definition: TSelector.h:56
virtual TTree * GetTree() const
Definition: TTree.h:434
A doubly linked list.
Definition: TList.h:44
virtual int Version() const
Definition: TSelector.h:54
ROOT::R::TRInterface & r
Definition: Object.C:4
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:249
virtual void SlaveBegin(TTree *)
Definition: TSelector.h:57
virtual void Terminate()
Definition: TSelector.h:73
virtual void SlaveTerminate()
Definition: TSelector.h:72
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:8665
Double_t y[n]
Definition: legend1.C:17
virtual Bool_t Process(Long64_t)
Definition: TSelector.cxx:330
virtual void SetObject(TObject *obj)
Definition: TSelector.h:67
virtual void SetOption(const char *option)
Definition: TSelector.h:66
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
Definition: tree.py:1
A TTree object has a header with a name and a title.
Definition: TTree.h:70
A TTree is a list of TBranches.
Definition: TBranch.h:59
A TSelector object is used by the TTree::Draw, TTree::Scan, TTree::Process to navigate in a TTree and...
Definition: TSelector.h:33
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual TList * GetOutputList() const
Definition: TSelector.h:71
virtual void Init(TTree *)
Definition: TSelector.h:55