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
|
#include "Fireworks/Core/interface/FWTSelectorToEventList.h"
#include "TEventList.h"
#include "TTreePlayer.h"
#include "TTreeFormula.h"
// FWTSelectorToEventList
//______________________________________________________________________________
//
// TTree selector for direct extraction into an TEventList -- no need
// to create it in TDirectory and name it.
//
// The event-list passed in constructor is not owned by the selector
// unless SetOwnEventList(kTRUE) is called -- then it is destroyed in
// the destructor.
//
// Own TTreePlayer is created and used directly in ProcessTree().
// This avoids usage of various global variables / state that would be
// used in the process of calling TTree::Draw(">>event_list").
//
// This can be called in a dedicated thread, but also do TFile::Open()
// there and get the tree out so that the TTree object is unique.
//______________________________________________________________________________
FWTSelectorToEventList::FWTSelectorToEventList(TTree* tree, TEventList* evl, const char* sel)
: TSelectorEntries(sel), fEvList(evl), fPlayer(new TTreePlayer), fOwnEvList(kFALSE) {
fPlayer->SetTree(tree);
}
//______________________________________________________________________________
FWTSelectorToEventList::~FWTSelectorToEventList() {
delete fPlayer;
if (fOwnEvList)
delete fEvList;
}
//______________________________________________________________________________
void FWTSelectorToEventList::ClearEventList() { fEvList->Clear(); }
//==============================================================================
//______________________________________________________________________________
Bool_t FWTSelectorToEventList::Process(Long64_t entry) {
// Process entry.
Long64_t prevRows = fSelectedRows;
TSelectorEntries::Process(entry);
if (fSelectedRows > prevRows)
fEvList->Enter(entry);
return kTRUE;
}
//______________________________________________________________________________
Long64_t FWTSelectorToEventList::ProcessTree(Long64_t nentries, Long64_t firstentry) {
return fPlayer->Process(this, "", nentries, firstentry);
}
|