46 TSelectorEntries::TSelectorEntries(TTree *tree,
const char *selection) :
47 fOwnInput(kFALSE), fChain(tree), fSelect(0), fSelectedRows(0), fSelectMultiple(kFALSE)
49 if (selection && selection[0]) {
50 TSelectorEntries::SetSelection(selection);
57 TSelectorEntries::TSelectorEntries(
const char *selection) :
58 fOwnInput(kFALSE), fChain(0), fSelect(0), fSelectedRows(0), fSelectMultiple(kFALSE)
60 TSelectorEntries::SetSelection(selection);
66 TSelectorEntries::~TSelectorEntries()
68 delete fSelect; fSelect =
nullptr;
81 void TSelectorEntries::Begin(TTree *tree)
83 TString option = GetOption();
92 void TSelectorEntries::SlaveBegin(TTree *tree)
95 TString option = GetOption();
99 TObject *selectObj = fInput->FindObject(
"selection");
100 const char *selection = selectObj ? selectObj->GetTitle() :
"";
102 if (strlen(selection)) {
103 fSelect =
new TTreeFormula(
"Selection",selection,fChain);
104 fSelect->SetQuickLoad(kTRUE);
105 if (!fSelect->GetNdim()) {
delete fSelect; fSelect = 0;
return; }
107 if (fSelect && fSelect->GetMultiplicity()) fSelectMultiple = kTRUE;
109 fChain->ResetBit(TTree::kForceRead);
115 Int_t TSelectorEntries::GetEntry(Long64_t entry, Int_t getall)
117 return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0;
129 void TSelectorEntries::Init(TTree * )
136 Bool_t TSelectorEntries::Notify()
138 if (fSelect) fSelect->UpdateFormulaLeaves();
161 Bool_t TSelectorEntries::Process(Long64_t )
163 if (!fSelectMultiple) {
165 if ( fSelect->EvalInstance(0) ) {
171 }
else if (fSelect) {
173 Int_t ndata = fSelect->GetNdata();
176 if (!ndata)
return kTRUE;
181 if (fSelect->EvalInstance(0)) {
184 for (Int_t i=1;i<ndata;i++) {
185 if (fSelect->EvalInstance(i)) {
198 void TSelectorEntries::SetSelection(
const char *selection)
204 TNamed *cselection = (TNamed*)fInput->FindObject(
"selection");
206 cselection =
new TNamed(
"selection",
"");
207 fInput->Add(cselection);
209 cselection->SetTitle(selection);
217 void TSelectorEntries::SlaveTerminate()
219 fOutput->Add(
new TSelectorScalar(
"fSelectedRows",fSelectedRows));
227 void TSelectorEntries::Terminate()
229 TSelectorScalar* rows = (TSelectorScalar*)fOutput->FindObject(
"fSelectedRows");
232 fSelectedRows = rows->GetVal();
234 Error(
"Terminate",
"fSelectedRows is missing in fOutput");