]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added new classes TPointSelector and TPointSelectorConsumer allowing more natural...
authormtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 3 Jul 2006 16:02:39 +0000 (16:02 +0000)
committermtadel <mtadel@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 3 Jul 2006 16:02:39 +0000 (16:02 +0000)
EVE/Reve/LinkDef.h
EVE/Reve/TTreeTools.cxx
EVE/Reve/TTreeTools.h

index 7132b4ab2c72ec403bfb1cfd1ab50c1c1f72132a..5317af018d0b736087a8618e3bf9d83234cae394 100644 (file)
@@ -46,6 +46,8 @@
 // TTreeTools
 #pragma link C++ class TSelectorToEventList+;
 #pragma link C++ class TTreeQuery+;
+#pragma link C++ class TPointSelectorConsumer+;
+#pragma link C++ class TPointSelector+;
 
 // RenderElement
 #pragma link C++ class Reve::RenderElement+;
index eda6096a7ee2b310964ccc7c651aa802a4a99a81..7155bd1c533732810898be6075d185c4e9cf1536 100644 (file)
@@ -24,13 +24,9 @@ TSelectorToEventList::TSelectorToEventList(TEventList* evl, const Text_t* sel) :
 
 Bool_t TSelectorToEventList::Process(Long64_t entry)
 {
-  if(ProcessCut(entry)) { ProcessFill(entry); return true; }
-  return false;
-}
-
-Bool_t TSelectorToEventList::ProcessCut(Long64_t )
-{
-  return GetSelect()->EvalInstance(0) != 0;
+  if(GetSelect()->EvalInstance(0) != 0)
+    fEvList->Enter(entry);
+  return kTRUE;
 }
 
 /**************************************************************************/
@@ -44,3 +40,52 @@ Int_t TTreeQuery::Select(TTree* t, const Text_t* selection)
   t->Process(&sel, "goff");
   return GetN();
 }
+
+/**************************************************************************/
+// TPointSelectorConsumer, TPointSelector
+/**************************************************************************/
+
+ClassImp(TPointSelectorConsumer)
+ClassImp(TPointSelector)
+
+TPointSelector::TPointSelector(TTree* t,
+                              TPointSelectorConsumer* c,
+                              const Text_t* vexp, const Text_t* sel) :
+  TSelectorDraw(),
+
+  fTree      (t),
+  fConsumer  (c),
+  fVarexp    (vexp),
+  fSelection (sel)
+{
+  SetInputList(&fInput);
+}
+
+Long64_t TPointSelector::Select(const Text_t* selection)
+{
+  if(selection != 0)
+    fSelection = selection;
+
+  fInput.Delete();
+  fInput.Add(new TNamed("varexp",    fVarexp.Data()));
+  fInput.Add(new TNamed("selection", fSelection.Data()));
+
+  if(fTree)
+    fTree->Process(this, "goff");
+  return fSelectedRows;
+}
+
+Long64_t TPointSelector::Select(TTree* t, const Text_t* selection)
+{
+  fTree = t;
+  return Select(selection);
+}
+
+void TPointSelector::TakeAction()
+{
+  fSelectedRows += fNfill;
+  // printf("TPointSelector::TakeAction nfill=%d, nall=%lld\n", fNfill, fSelectedRows);
+  if(fConsumer) {
+    fConsumer->TakeAction(this);
+  }
+}
index d4d417791d2e5a74f6dd606bbbe099496b8de10b..1b6f034c66b3e4d296ab6b2e3417cc4e0cd5d059 100644 (file)
@@ -18,9 +18,8 @@ protected:
 public:
   TSelectorToEventList(TEventList* evl, const Text_t* sel);
 
+  virtual Int_t  Version() const { return 1; }
   virtual Bool_t Process(Long64_t entry);
-  virtual Bool_t ProcessCut(Long64_t entry);
-  virtual void   ProcessFill(Long64_t entry) { fEvList->Enter(entry); }
 
   ClassDef(TSelectorToEventList, 1)
 };
@@ -39,6 +38,68 @@ public:
   ClassDef(TTreeQuery, 1)
 };
 
+/**************************************************************************/
+// TPointSelectorConsumer, TPointSelector
+/**************************************************************************/
+
+class TPointSelector;
+
+class TPointSelectorConsumer
+{
+public:
+  enum TreeVarType_e { TVT_XYZ, TVT_RPhiZ };
+
+protected:
+  TreeVarType_e fSourceCS;
+
+public:
+  TPointSelectorConsumer(TreeVarType_e cs=TVT_XYZ) :fSourceCS(cs) {}
+  virtual ~TPointSelectorConsumer() {}
+
+  virtual void TakeAction(TSelectorDraw*) = 0;
+
+  TreeVarType_e GetSourceCS() const  { return fSourceCS; }
+  void SetSourceCS(TreeVarType_e cs) { fSourceCS = cs; }
+
+  ClassDef(TPointSelectorConsumer, 1);
+};
+
+class TPointSelector : public TSelectorDraw
+{
+protected:
+  TTree                  *fTree;
+  TPointSelectorConsumer *fConsumer;
+
+  TString                 fVarexp;
+  TString                 fSelection;
+
+  TList                   fInput;
+
+public:
+  TPointSelector(TTree* t=0, TPointSelectorConsumer* c=0,
+                const Text_t* vexp="", const Text_t* sel="");
+  virtual ~TPointSelector() {}
+
+  virtual Long64_t Select(const Text_t* selection=0);
+  virtual Long64_t Select(TTree* t, const Text_t* selection=0);
+  virtual void  TakeAction();
+
+
+  TTree* GetTree() const   { return fTree; }
+  void   SetTree(TTree* t) { fTree = t; }
+
+  TPointSelectorConsumer* GetConsumer() const { return fConsumer; }
+  void SetConsumer(TPointSelectorConsumer* c) { fConsumer = c; }
+
+  const Text_t* GetVarexp() const { return fVarexp; }
+  void SetVarexp(const Text_t* v) { fVarexp = v; }
+
+  const Text_t* GetSelection() const { return fSelection; }
+  void SetSelection(const Text_t* s) { fSelection = s; }
+
+  ClassDef(TPointSelector, 1);
+};
+
 /**************************************************************************/
 /**************************************************************************/