ROOTPWA
plotPhase.h
Go to the documentation of this file.
1 
2 //
3 // Copyright 2009 Sebastian Neubert
4 //
5 // This file is part of rootpwa
6 //
7 // rootpwa is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // rootpwa is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
19 //
21 //-----------------------------------------------------------
22 // File and Version Information:
23 // $Id$
24 //
25 // Description:
26 // Draws phase angle of (wave A - wave B) from tree.
27 //
28 //
29 // Author List:
30 // Sebastian Neubert TUM (original author)
31 //
32 //
33 //-----------------------------------------------------------
34 
35 
36 #ifndef PLOTPHASE_HH
37 #define PLOTPHASE_HH
38 
39 
40 #include <string>
41 #include <vector>
42 
43 #include "TTree.h"
44 #include "TMultiGraph.h"
45 
46 #include "fitResult.h"
47 
48 
49 // .............................................................................
50 // signatures with wave indices
51 TMultiGraph*
52 plotPhase(const unsigned int nmbTrees, // number of fitResult trees
53  TTree** trees, // array of fitResult trees
54  const int waveIndexA, // index of first wave
55  const int waveIndexB, // index of second wave
56  const bool saveEps = false, // if set, EPS file with name wave ID is created
57  const int* graphColors = NULL, // array of colors for graph line and marker
58  const bool drawLegend = true, // if set legend is drawn
59  const std::string& graphTitle = "", // name and title of graph (default is wave IDs)
60  const char* drawOption = "AP", // draw option for graph
61  const std::string& selectExpr = "", // TTree::Draw() selection expression
62  const std::string& branchName = "fitResult_v2"); // fitResult branch name
63 
64 
65 inline
66 TMultiGraph*
67 plotPhase(std::vector<TTree*>& trees, // array of fitResult trees
68  const int waveIndexA, // index of first wave
69  const int waveIndexB, // index of second wave
70  const bool saveEps = false, // if set, EPS file with name wave ID is created
71  const std::vector<int>& graphColors = std::vector<int>(), // array of colors for graph line and marker
72  const bool drawLegend = true, // if set legend is drawn
73  const std::string& graphTitle = "", // name and title of graph (default is wave IDs)
74  const char* drawOption = "AP", // draw option for graph
75  const std::string& selectExpr = "", // TTree::Draw() selection expression
76  const std::string& branchName = "fitResult_v2") // fitResult branch name
77 {
78  return plotPhase(trees.size(), &(*(trees.begin())), waveIndexA, waveIndexB, saveEps,
79  &(*(graphColors.begin())), drawLegend, graphTitle, drawOption,
80  selectExpr, branchName);
81 }
82 
83 
84 inline
85 TMultiGraph*
86 plotPhase(TTree* tree, // fitResult tree
87  const int waveIndexA, // index of first wave
88  const int waveIndexB, // index of second wave
89  const bool saveEps = false, // if set, EPS file with name wave ID is created
90  const int graphColor = kBlack, // array of colors for graph line and marker
91  const bool drawLegend = false, // if set legend is drawn
92  const std::string& graphTitle = "", // name and title of graph (default is wave IDs)
93  const char* drawOption = "AP", // draw option for graph
94  const std::string& selectExpr = "", // TTree::Draw() selection expression
95  const std::string& branchName = "fitResult_v2") // fitResult branch name
96 {
97  return plotPhase(1, &tree, waveIndexA, waveIndexB, saveEps, &graphColor,
98  drawLegend, graphTitle, drawOption, selectExpr, branchName);
99 }
100 
101 
102 // .............................................................................
103 // signatures with wave names
104 inline
105 TMultiGraph*
106 plotPhase(const unsigned int nmbTrees, // number of fitResult trees
107  TTree** trees, // array of fitResult trees
108  const std::string& waveNameA, // name of first wave
109  const std::string& waveNameB, // name of second wave
110  const bool saveEps = false, // if set, EPS file with name wave ID is created
111  const int* graphColors = NULL, // array of colors for graph line and marker
112  const bool drawLegend = true, // if set legend is drawn
113  const std::string& graphTitle = "", // name and title of graph (default is wave IDs)
114  const char* drawOption = "AP", // draw option for graph
115  const std::string& selectExpr = "", // TTree::Draw() selection expression
116  const std::string& branchName = "fitResult_v2") // fitResult branch name
117 {
118  if (!trees[0]) {
119  printErr << "null pointer to tree[" << 0 << "]. exiting." << std::endl;
120  return 0;
121  }
122  // get wave indices (assumes same wave set in all trees)
123  rpwa::fitResult* massBin = new rpwa::fitResult();
124  trees[0]->SetBranchAddress(branchName.c_str(), &massBin);
125  trees[0]->GetEntry(0);
126  const int indexA = massBin->waveIndex(waveNameA);
127  const int indexB = massBin->waveIndex(waveNameB);
128  if ((indexA >= 0) && (indexB >= 0))
129  return plotPhase(nmbTrees, trees, indexA, indexB, saveEps, graphColors, drawLegend,
130  graphTitle, drawOption, selectExpr, branchName);
131  printErr << "cannot find wave(s) in tree '" << trees[0]->GetName() << "'. aborting." << std::endl;
132  return 0;
133 }
134 
135 
136 inline
137 TMultiGraph*
138 plotPhase(std::vector<TTree*>& trees, // array of fitResult trees
139  const std::string& waveNameA, // name of first wave
140  const std::string& waveNameB, // name of second wave
141  const bool saveEps = false, // if set, EPS file with name wave ID is created
142  const std::vector<int>& graphColors = std::vector<int>(), // array of colors for graph line and marker
143  const bool drawLegend = true, // if set legend is drawn
144  const std::string& graphTitle = "", // name and title of graph (default is wave IDs)
145  const char* drawOption = "AP", // draw option for graph
146  const std::string& selectExpr = "", // TTree::Draw() selection expression
147  const std::string& branchName = "fitResult_v2") // fitResult branch name
148 {
149  return plotPhase(trees.size(), &(*(trees.begin())), waveNameA, waveNameB, saveEps,
150  &(*(graphColors.begin())), drawLegend, graphTitle, drawOption,
151  selectExpr, branchName);
152 }
153 
154 
155 inline
156 TMultiGraph*
157 plotPhase(TTree* tree, // fitResult tree
158  const std::string& waveNameA, // name of first wave
159  const std::string& waveNameB, // name of second wave
160  const bool saveEps = false, // if set, EPS file with name wave ID is created
161  const int graphColor = kBlack, // array of colors for graph line and marker
162  const bool drawLegend = false, // if set legend is drawn
163  const std::string& graphTitle = "", // name and title of graph (default is wave IDs)
164  const char* drawOption = "AP", // draw option for graph
165  const std::string& selectExpr = "", // TTree::Draw() selection expression
166  const std::string& branchName = "fitResult_v2") // fitResult branch name
167 {
168  return plotPhase(1, &tree, waveNameA, waveNameB, saveEps, &graphColor,
169  drawLegend, graphTitle, drawOption, selectExpr, branchName);
170 }
171 
172 
173 #endif // PLOTPHASE_HH