AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TTreeSelection.cxx
Go to the documentation of this file.
1 
14 #include "TMath.h"
15 #include "TFile.h"
16 #include "TTree.h"
17 #include "TTreeStream.h"
18 #include "TPolyMarker3D.h"
19 #include "TVectorD.h"
20 #include "TObjString.h"
21 
22 
23 class TTreePoint: public TNamed{
24 public:
25  TTreePoint();
26  TTreePoint(const char *alias, const char * px, const char * py, const char *pz, Int_t mColor, Int_t mSize, Int_t mType);
27  // TString GetSelection();
28 public:
29  TString fPx;
30  TString fPy;
31  TString fPz;
32  Int_t fMColor;
33  Int_t fMSize;
34  Int_t fMType;
35  Bool_t fIsOn;
36  ClassDef(TTreePoint,1)
37 };
38 
39 
40 class TTreeCutAtom: public TNamed{
41 public:
42  enum ExprType { kBool=0, kInt=1, kRange=2};
43  TTreeCutAtom();
44  TTreeCutAtom(const char *alias, const char *expr, ExprType type, Double_t val0, Double_t val1=0);
45  TString GetSelection();
46 public:
47  Double_t fInt0;
48  Double_t fInt1;
49  Double_t fVal0;
50  Double_t fVal1;
52  ClassDef(TTreeCutAtom,1)
53 };
54 
55 class TTreeDraw: public TNamed{
56 public:
57  TTreeDraw(const char *name, TTree * tree);
59  TString MakeSelection();
60  void AddSelectionRange(const char *alias, const char*expr, Float_t min, Float_t max);
61  void AddSelection(const char *alias, const char*expr);
62  void AddDraw(const char *alias, const char * px, const char * py, const char *pz, Int_t mColor, Int_t mSize, Int_t mType);
63  // TGCompositeFrame * MakeFrame();
64 public:
65  TTree * fTree;
68 private:
69  TTreeDraw();
70  ClassDef(TTreeDraw,1)
71 };
72 
78 
80  TNamed(),
81  fPx(), // point X
82  fPy(), // point Y
83  fPz(), // point Z
84  fMColor(1), //color
85  fMSize(1), //marker size
86  fMType(22), //marker type
87  fIsOn(kTRUE) //is On
88 {
89 }
90 
91 TTreePoint::TTreePoint(const char *alias, const char * px, const char * py, const char *pz, Int_t mColor, Int_t mSize, Int_t mType)
92 :
93  TNamed(alias,alias),
94  fPx(px), // point X
95  fPy(py), // point Y
96  fPz(pz), // point Z
97  fMColor(mColor), //color
98  fMSize(mSize), //marker size
99  fMType(mType), //marker type
100  fIsOn(kTRUE) //is On
101 {
102 }
103 
104 
106  TNamed(),
107  fVal0(0),
108  fVal1(0),
109  fType(kBool)
110 {
111  //
112  //
113  //
114 }
115 
116 TTreeCutAtom::TTreeCutAtom(const char *alias, const char *expr, ExprType type, Double_t val0, Double_t val1):
117  TNamed(alias,expr),
118  fInt0(val0),
119  fInt1(val1),
120  fVal0(val0),
121  fVal1(val1),
122  fType(type)
123 {
124  //
125  //
126  //
127 }
128 
130  //
131  //
132  //
133  TString str;
134  char command[1000];
135  if (fType==kBool) str = fTitle;
136  if (fType==kInt){
137  sprintf(command,"(%s==%d)",GetTitle(), TMath::Nint(fVal0));
138  str = command;
139  }
140  if (fType==kRange){
141  sprintf(command,"((%s>%f) &&(%s<%f))",GetTitle(), fVal0,GetTitle(),fVal1);
142  str = command;
143  }
144  return str;
145 }
146 
147 
149  TNamed(),
150  fTree(0),
151  fCutAtoms(0),
152  fDraws(0)
153 {
154 }
155 
156 TTreeDraw::TTreeDraw(const char *name, TTree * tree):
157  TNamed(name,name),
158  fTree(tree),
159  fCutAtoms(100),
160  fDraws(100)
161 {
162 }
163 
164 void TTreeDraw::AddSelection(const char *alias, const char*expr){
165  //
166  // add string selection
167  //
168  TTreeCutAtom * atom = new TTreeCutAtom(alias,expr,TTreeCutAtom::kBool,0,1);
169  fCutAtoms.AddLast(atom);
170 }
171 
172 void TTreeDraw::AddSelectionRange(const char *alias, const char*expr, Float_t min, Float_t max){
173  //
174  //
175  //
176  TTreeCutAtom * atom = new TTreeCutAtom(alias,expr,TTreeCutAtom::kRange,min,max);
177  fCutAtoms.AddLast(atom);
178 }
179 
181  //
182  // Make selection string
183  //
184  TString res;
185  for (Int_t i=0; i<fCutAtoms.GetEntries(); i++){
186  TTreeCutAtom * atom = (TTreeCutAtom*)fCutAtoms.At(i);
187  if (!atom) continue;
188  if (res.Length()>0) res+="&&";
189  res+=atom->GetSelection();
190  }
191  return res;
192 }
TString fPz
point Z
TTree * fTree
Definition: MakeTreeStat.C:55
Double_t fVal1
selection value 1
#define TObjArray
TObjArray fDraws
array of draw experssions
TString fPx
point X
TObjArray fCutAtoms
array of axpressions
Int_t fMSize
marker size
TTree * tree
void AddSelection(const char *alias, const char *expr)
ExprType fType
selection type
Int_t fMColor
color
ClassImp(TTreePoint) ClassImp(TTreeCutAtom) TTreePoint
Double_t fInt0
interval value 0
TString GetSelection()
Double_t fInt1
interval value 1
void AddDraw(const char *alias, const char *px, const char *py, const char *pz, Int_t mColor, Int_t mSize, Int_t mType)
TString MakeSelection()
Double_t fVal0
selection value 0
void AddSelectionRange(const char *alias, const char *expr, Float_t min, Float_t max)
TTree * fTree
tree
Int_t fMType
marker type
TString fPy
point Y
Bool_t fIsOn
is On