hlit-ana  0.0.0
 All Classes Functions Variables Pages
HlitAnalysisSelector.cxx
1 #include <TFile.h>
2 #include <TTree.h>
3 #include <TCanvas.h>
4 #include "HlitEvent.h"
5 #include "HlitTask.h"
6 
7 #include "HlitAnalysisSelector.h"
8 
10 ClassImp(HlitAnalysisSelector);
12 
14  : TSelector(), fChain(0), fEvent(0), fTaskMgr(0) {
18 }
19 
24  SafeDelete(fEvent);
25 }
26 
27 void HlitAnalysisSelector::Init(TTree *tree) {
31  if (!tree)
32  return;
33  fChain = tree;
34  fEvent = new HlitEvent(0);
35 
36  fChain->SetBranchAddress("HlitEvent", &fEvent);
37  if (fTaskMgr)
38  fTaskMgr->GetOutput()->Add(fEvent);
39 }
40 
45  if (fChain->GetCurrentFile())
46  Printf("File : %s", fChain->GetCurrentFile()->GetName());
47  return kTRUE;
48 }
49 
50 void HlitAnalysisSelector::Begin(TTree * /*tree*/) {
54 }
55 
56 void HlitAnalysisSelector::SlaveBegin(TTree * /*tree*/) {
60 
61  TString option = GetOption();
62 
63  if (fTaskMgr)
64  fTaskMgr->Init("");
65 }
66 
67 Bool_t HlitAnalysisSelector::Process(Long64_t entry) {
71 
72  GetEntry(entry);
73 
74  if (entry % 1000 == 0)
75  Printf("Event %lld ID=%lld nTracks=%lld", entry, fEvent->GetID(),
76  fEvent->GetNTrack());
77 
78  if (fTaskMgr)
79  fTaskMgr->ExecuteTask("");
80 
81  return kTRUE;
82 }
83 
88  if (fTaskMgr)
89  fTaskMgr->Finish("");
90 }
91 
96 }
97 
98 Int_t HlitAnalysisSelector::GetEntry(Long64_t entry, Int_t getall) {
102  return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0;
103 }
TTree * fChain
Pointer to the analyzed TTree or TChain.
TList * GetOutput() const
Returns output list.
Definition: HlitTask.h:79
virtual void ExecuteTask(Option_t *option)
Definition: HlitTask.cxx:44
HlitEvent * fEvent
Current Event.
virtual Bool_t Process(Long64_t entry)
virtual void Finish(Option_t *option)
User&#39;s function executed after all sub tasks.
Definition: HlitTask.cxx:171
Long64_t GetID() const
Event ID.
Definition: HlitEvent.h:65
virtual void SlaveBegin(TTree *tree)
Event object.
Definition: HlitEvent.h:15
virtual void Init(Option_t *option)
Init function.
Definition: HlitTask.cxx:159
virtual void Begin(TTree *)
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
HlitAnalysisSelector(TTree *tree=0)
virtual void Init(TTree *tree)
Long64_t GetNTrack() const
Definition: HlitEvent.h:75
HlitTask * fTaskMgr
Task Manager.