Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:20

0001 
0002 #include "Fireworks/Core/interface/FWTSelectorToEventList.h"
0003 
0004 #include "TEventList.h"
0005 #include "TTreePlayer.h"
0006 #include "TTreeFormula.h"
0007 
0008 // FWTSelectorToEventList
0009 
0010 //______________________________________________________________________________
0011 //
0012 // TTree selector for direct extraction into an TEventList -- no need
0013 // to create it in TDirectory and name it.
0014 //
0015 // The event-list passed in constructor is not owned by the selector
0016 // unless SetOwnEventList(kTRUE) is called -- then it is destroyed in
0017 // the destructor.
0018 //
0019 // Own TTreePlayer is created and used directly in ProcessTree().
0020 // This avoids usage of various global variables / state that would be
0021 // used in the process of calling TTree::Draw(">>event_list").
0022 //
0023 // This can be called in a dedicated thread, but also do TFile::Open()
0024 // there and get the tree out so that the TTree object is unique.
0025 
0026 //______________________________________________________________________________
0027 FWTSelectorToEventList::FWTSelectorToEventList(TTree* tree, TEventList* evl, const char* sel)
0028     : TSelectorEntries(sel), fEvList(evl), fPlayer(new TTreePlayer), fOwnEvList(kFALSE) {
0029   fPlayer->SetTree(tree);
0030 }
0031 
0032 //______________________________________________________________________________
0033 FWTSelectorToEventList::~FWTSelectorToEventList() {
0034   delete fPlayer;
0035   if (fOwnEvList)
0036     delete fEvList;
0037 }
0038 
0039 //______________________________________________________________________________
0040 void FWTSelectorToEventList::ClearEventList() { fEvList->Clear(); }
0041 
0042 //==============================================================================
0043 
0044 //______________________________________________________________________________
0045 Bool_t FWTSelectorToEventList::Process(Long64_t entry) {
0046   // Process entry.
0047 
0048   Long64_t prevRows = fSelectedRows;
0049 
0050   TSelectorEntries::Process(entry);
0051 
0052   if (fSelectedRows > prevRows)
0053     fEvList->Enter(entry);
0054 
0055   return kTRUE;
0056 }
0057 
0058 //______________________________________________________________________________
0059 Long64_t FWTSelectorToEventList::ProcessTree(Long64_t nentries, Long64_t firstentry) {
0060   return fPlayer->Process(this, "", nentries, firstentry);
0061 }