/
EventSelector.C
82 lines (67 loc) · 2.79 KB
/
EventSelector.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// For more information on the TSelector framework see
// $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
// The file for this selector can be found at
// http://lcg-heppkg.web.cern.ch/lcg-heppkg/ROOT/eventdata.root
// i.e run
// root [0] f = TFile::Open("http://lcg-heppkg.web.cern.ch/lcg-heppkg/ROOT/eventdata.root");
// root [1] EventTree->Process("EventSelector.C+")
// The following methods are defined in this file:
// SlaveBegin(): called after Begin(), when on PROOF called only on the
// slave servers, a convenient place to create your histograms.
// Process(): called for each event, in this function you decide what
// to read and fill your histograms.
// Terminate(): called at the end of the loop on the tree,
// a convenient place to draw/fit your histograms.
//
// To use this file, try the following session on your Tree T:
//
// Root > T->Process("EventSelector.C")
// Root > T->Process("EventSelector.C","some options")
// Root > T->Process("EventSelector.C+")
//
#include "TROOT.h"
#include "TChain.h"
#include "TFile.h"
#include "TSelector.h"
const Int_t kMaxfParticles = 1293;
class EventSelector : public TSelector {
public :
EventSelector(TTree * = 0) { }
virtual ~EventSelector() { }
virtual void Init(TTree *tree);
virtual void SlaveBegin(TTree *tree);
virtual Bool_t Process(Long64_t entry);
virtual void Terminate();
virtual Int_t Version() const { return 2; }
ClassDef(EventSelector,0);
};
void EventSelector::Init(TTree *tree)
{
// The Init() function is called when the selector needs to initialize
// a new tree or chain. Typically here the branch addresses and branch
// pointers of the tree will be set.
}
void EventSelector::SlaveBegin(TTree *tree)
{
// SlaveBegin() is a good place to create histograms.
// For PROOF, this is called for each worker.
// The TTree* is there for backward compatibility; e.g. PROOF passes 0.
}
Bool_t EventSelector::Process(Long64_t entry)
{
// The Process() function is called for each entry in the tree to be
// processed. The entry argument specifies which entry in the currently
// loaded tree is to be processed.
// It can be passed to either EventSelector::GetEntry() or TBranch::GetEntry()
// to read either all or the required parts of the TTree.
//
// This function should contain the "body" of the analysis: select relevant
// tree entries, run algorithms on the tree entry and typically fill histograms.
return kTRUE;
}
void EventSelector::Terminate()
{
// The Terminate() function is the last function to be called during the
// analysis of a tree with a selector. It always runs on the client, it can
// be used to present the results graphically or save the results to file.
}