ROOT logo
// @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//______________________________________________________________________________
// TTreeTools
//
// Collection of classes for TTree interaction.

#include "TEveTreeTools.h"
#include "TTree.h"
#include "TTreeFormula.h"

/******************************************************************************/
/******************************************************************************/

//______________________________________________________________________________
// TEveSelectorToEventList
//
// TSelector that stores entry numbers of matching TTree entries into
// an event-list.


ClassImp(TEveSelectorToEventList)

//______________________________________________________________________________
TEveSelectorToEventList::TEveSelectorToEventList(TEventList* evl, const char* sel) :
   TSelectorDraw(), fEvList(evl)
{
   // Constructor.

   fInput.Add(new TNamed("varexp", ""));
   fInput.Add(new TNamed("selection", sel));
   SetInputList(&fInput);
}

//______________________________________________________________________________
Bool_t TEveSelectorToEventList::Process(Long64_t entry)
{
   // Process entry.

   if(GetSelect()->EvalInstance(0) != 0)
      fEvList->Enter(entry);
   return kTRUE;
}


//______________________________________________________________________________
// TEvePointSelector, TEvePointSelectorConsumer
//
// TEvePointSelector is a sub-class of TSelectorDraw for direct
// extraction of point-like data from a Tree.
//
// TEvePointSelectorConsumer is a virtual base for classes that can be
// filled from TTree data via the TEvePointSelector class.

ClassImp(TEvePointSelector)
ClassImp(TEvePointSelectorConsumer)

//______________________________________________________________________________
TEvePointSelector::TEvePointSelector(TTree* t,
                                     TEvePointSelectorConsumer* c,
                                     const char* vexp, const char* sel) :
   TSelectorDraw(),

   fTree      (t),
   fConsumer  (c),
   fVarexp    (vexp),
   fSelection (sel),
   fSubIdExp  (),
   fSubIdNum  (0)
{
   // Constructor.

   SetInputList(&fInput);
}

//______________________________________________________________________________
Long64_t TEvePointSelector::Select(const char* selection)
{
   // Process the tree, select points matching 'selection'.

   TString var(fVarexp);
   if (fSubIdExp.IsNull()) {
      fSubIdNum = 0;
   } else {
      fSubIdNum = fSubIdExp.CountChar(':') + 1;
      var += ":" + fSubIdExp;
   }

   TString sel;
   if (selection != 0)
      sel = selection;
   else
      sel = fSelection;

   fInput.Delete();
   fInput.Add(new TNamed("varexp",    var.Data()));
   fInput.Add(new TNamed("selection", sel.Data()));

   if (fConsumer)
      fConsumer->InitFill(fSubIdNum);

   // 'para' option -> hack allowing arbitrary dimensions.
   if(fTree)
      fTree->Process(this, "goff para");

   return fSelectedRows;
}

//______________________________________________________________________________
Long64_t TEvePointSelector::Select(TTree* t, const char* selection)
{
   // Process tree 't', select points matching 'selection'.

   fTree = t;
   return Select(selection);
}

//______________________________________________________________________________
void TEvePointSelector::TakeAction()
{
   // Callback from tree-player after a chunk of data has been processed.
   // This is forwarded to the current point-consumer.

   fSelectedRows += fNfill;
   // printf("TEvePointSelector::TakeAction nfill=%d, nall=%lld\n", fNfill, fSelectedRows);
   if (fConsumer) {
      fConsumer->TakeAction(this);
   }
}
 TEveTreeTools.cxx:1
 TEveTreeTools.cxx:2
 TEveTreeTools.cxx:3
 TEveTreeTools.cxx:4
 TEveTreeTools.cxx:5
 TEveTreeTools.cxx:6
 TEveTreeTools.cxx:7
 TEveTreeTools.cxx:8
 TEveTreeTools.cxx:9
 TEveTreeTools.cxx:10
 TEveTreeTools.cxx:11
 TEveTreeTools.cxx:12
 TEveTreeTools.cxx:13
 TEveTreeTools.cxx:14
 TEveTreeTools.cxx:15
 TEveTreeTools.cxx:16
 TEveTreeTools.cxx:17
 TEveTreeTools.cxx:18
 TEveTreeTools.cxx:19
 TEveTreeTools.cxx:20
 TEveTreeTools.cxx:21
 TEveTreeTools.cxx:22
 TEveTreeTools.cxx:23
 TEveTreeTools.cxx:24
 TEveTreeTools.cxx:25
 TEveTreeTools.cxx:26
 TEveTreeTools.cxx:27
 TEveTreeTools.cxx:28
 TEveTreeTools.cxx:29
 TEveTreeTools.cxx:30
 TEveTreeTools.cxx:31
 TEveTreeTools.cxx:32
 TEveTreeTools.cxx:33
 TEveTreeTools.cxx:34
 TEveTreeTools.cxx:35
 TEveTreeTools.cxx:36
 TEveTreeTools.cxx:37
 TEveTreeTools.cxx:38
 TEveTreeTools.cxx:39
 TEveTreeTools.cxx:40
 TEveTreeTools.cxx:41
 TEveTreeTools.cxx:42
 TEveTreeTools.cxx:43
 TEveTreeTools.cxx:44
 TEveTreeTools.cxx:45
 TEveTreeTools.cxx:46
 TEveTreeTools.cxx:47
 TEveTreeTools.cxx:48
 TEveTreeTools.cxx:49
 TEveTreeTools.cxx:50
 TEveTreeTools.cxx:51
 TEveTreeTools.cxx:52
 TEveTreeTools.cxx:53
 TEveTreeTools.cxx:54
 TEveTreeTools.cxx:55
 TEveTreeTools.cxx:56
 TEveTreeTools.cxx:57
 TEveTreeTools.cxx:58
 TEveTreeTools.cxx:59
 TEveTreeTools.cxx:60
 TEveTreeTools.cxx:61
 TEveTreeTools.cxx:62
 TEveTreeTools.cxx:63
 TEveTreeTools.cxx:64
 TEveTreeTools.cxx:65
 TEveTreeTools.cxx:66
 TEveTreeTools.cxx:67
 TEveTreeTools.cxx:68
 TEveTreeTools.cxx:69
 TEveTreeTools.cxx:70
 TEveTreeTools.cxx:71
 TEveTreeTools.cxx:72
 TEveTreeTools.cxx:73
 TEveTreeTools.cxx:74
 TEveTreeTools.cxx:75
 TEveTreeTools.cxx:76
 TEveTreeTools.cxx:77
 TEveTreeTools.cxx:78
 TEveTreeTools.cxx:79
 TEveTreeTools.cxx:80
 TEveTreeTools.cxx:81
 TEveTreeTools.cxx:82
 TEveTreeTools.cxx:83
 TEveTreeTools.cxx:84
 TEveTreeTools.cxx:85
 TEveTreeTools.cxx:86
 TEveTreeTools.cxx:87
 TEveTreeTools.cxx:88
 TEveTreeTools.cxx:89
 TEveTreeTools.cxx:90
 TEveTreeTools.cxx:91
 TEveTreeTools.cxx:92
 TEveTreeTools.cxx:93
 TEveTreeTools.cxx:94
 TEveTreeTools.cxx:95
 TEveTreeTools.cxx:96
 TEveTreeTools.cxx:97
 TEveTreeTools.cxx:98
 TEveTreeTools.cxx:99
 TEveTreeTools.cxx:100
 TEveTreeTools.cxx:101
 TEveTreeTools.cxx:102
 TEveTreeTools.cxx:103
 TEveTreeTools.cxx:104
 TEveTreeTools.cxx:105
 TEveTreeTools.cxx:106
 TEveTreeTools.cxx:107
 TEveTreeTools.cxx:108
 TEveTreeTools.cxx:109
 TEveTreeTools.cxx:110
 TEveTreeTools.cxx:111
 TEveTreeTools.cxx:112
 TEveTreeTools.cxx:113
 TEveTreeTools.cxx:114
 TEveTreeTools.cxx:115
 TEveTreeTools.cxx:116
 TEveTreeTools.cxx:117
 TEveTreeTools.cxx:118
 TEveTreeTools.cxx:119
 TEveTreeTools.cxx:120
 TEveTreeTools.cxx:121
 TEveTreeTools.cxx:122
 TEveTreeTools.cxx:123
 TEveTreeTools.cxx:124
 TEveTreeTools.cxx:125
 TEveTreeTools.cxx:126
 TEveTreeTools.cxx:127
 TEveTreeTools.cxx:128
 TEveTreeTools.cxx:129
 TEveTreeTools.cxx:130
 TEveTreeTools.cxx:131
 TEveTreeTools.cxx:132
 TEveTreeTools.cxx:133
 TEveTreeTools.cxx:134
 TEveTreeTools.cxx:135
 TEveTreeTools.cxx:136
 TEveTreeTools.cxx:137
 TEveTreeTools.cxx:138