TEveTreeTools.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveTreeTools.cxx 27157 2009-01-15 14:05:12Z brun $
00002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //______________________________________________________________________________
00013 // TTreeTools
00014 //
00015 // Collection of classes for TTree interaction.
00016 
00017 #include "TEveTreeTools.h"
00018 #include "TTree.h"
00019 #include "TTreeFormula.h"
00020 
00021 /******************************************************************************/
00022 /******************************************************************************/
00023 
00024 //______________________________________________________________________________
00025 // TEveSelectorToEventList
00026 //
00027 // TSelector that stores entry numbers of matching TTree entries into
00028 // an event-list.
00029 
00030 
00031 ClassImp(TEveSelectorToEventList)
00032 
00033 //______________________________________________________________________________
00034 TEveSelectorToEventList::TEveSelectorToEventList(TEventList* evl, const char* sel) :
00035    TSelectorDraw(), fEvList(evl)
00036 {
00037    // Constructor.
00038 
00039    fInput.Add(new TNamed("varexp", ""));
00040    fInput.Add(new TNamed("selection", sel));
00041    SetInputList(&fInput);
00042 }
00043 
00044 //______________________________________________________________________________
00045 Bool_t TEveSelectorToEventList::Process(Long64_t entry)
00046 {
00047    // Process entry.
00048 
00049    if(GetSelect()->EvalInstance(0) != 0)
00050       fEvList->Enter(entry);
00051    return kTRUE;
00052 }
00053 
00054 
00055 //______________________________________________________________________________
00056 // TEvePointSelector, TEvePointSelectorConsumer
00057 //
00058 // TEvePointSelector is a sub-class of TSelectorDraw for direct
00059 // extraction of point-like data from a Tree.
00060 //
00061 // TEvePointSelectorConsumer is a virtual base for classes that can be
00062 // filled from TTree data via the TEvePointSelector class.
00063 
00064 ClassImp(TEvePointSelector)
00065 ClassImp(TEvePointSelectorConsumer)
00066 
00067 //______________________________________________________________________________
00068 TEvePointSelector::TEvePointSelector(TTree* t,
00069                                      TEvePointSelectorConsumer* c,
00070                                      const char* vexp, const char* sel) :
00071    TSelectorDraw(),
00072 
00073    fTree      (t),
00074    fConsumer  (c),
00075    fVarexp    (vexp),
00076    fSelection (sel),
00077    fSubIdExp  (),
00078    fSubIdNum  (0)
00079 {
00080    // Constructor.
00081 
00082    SetInputList(&fInput);
00083 }
00084 
00085 //______________________________________________________________________________
00086 Long64_t TEvePointSelector::Select(const char* selection)
00087 {
00088    // Process the tree, select points matching 'selection'.
00089 
00090    TString var(fVarexp);
00091    if (fSubIdExp.IsNull()) {
00092       fSubIdNum = 0;
00093    } else {
00094       fSubIdNum = fSubIdExp.CountChar(':') + 1;
00095       var += ":" + fSubIdExp;
00096    }
00097 
00098    TString sel;
00099    if (selection != 0)
00100       sel = selection;
00101    else
00102       sel = fSelection;
00103 
00104    fInput.Delete();
00105    fInput.Add(new TNamed("varexp",    var.Data()));
00106    fInput.Add(new TNamed("selection", sel.Data()));
00107 
00108    if (fConsumer)
00109       fConsumer->InitFill(fSubIdNum);
00110 
00111    // 'para' option -> hack allowing arbitrary dimensions.
00112    if(fTree)
00113       fTree->Process(this, "goff para");
00114 
00115    return fSelectedRows;
00116 }
00117 
00118 //______________________________________________________________________________
00119 Long64_t TEvePointSelector::Select(TTree* t, const char* selection)
00120 {
00121    // Process tree 't', select points matching 'selection'.
00122 
00123    fTree = t;
00124    return Select(selection);
00125 }
00126 
00127 //______________________________________________________________________________
00128 void TEvePointSelector::TakeAction()
00129 {
00130    // Callback from tree-player after a chunk of data has been processed.
00131    // This is forwarded to the current point-consumer.
00132 
00133    fSelectedRows += fNfill;
00134    // printf("TEvePointSelector::TakeAction nfill=%d, nall=%lld\n", fNfill, fSelectedRows);
00135    if (fConsumer) {
00136       fConsumer->TakeAction(this);
00137    }
00138 }

Generated on Tue Jul 5 14:16:15 2011 for ROOT_528-00b_version by  doxygen 1.5.1