ROOTPWA
plotIntensity.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 intensity graph for single wave from tree.
27 //
28 //
29 // Author List:
30 // Sebastian Neubert TUM (original author)
31 //
32 //
33 //-----------------------------------------------------------
34 
35 
36 //
37 // plots wave intensities for a give number of trees on top of each
38 // other
39 //
40 
41 
42 #ifndef PLOTINTENSITY_HH
43 #define PLOTINTENSITY_HH
44 
45 
46 #include <string>
47 #include <vector>
48 
49 #include "TTree.h"
50 #include "TMultiGraph.h"
51 
52 #include "fitResult.h"
53 
54 
55 // .............................................................................
56 // signatures with wave index
57 TMultiGraph*
58 plotIntensity(const unsigned int nmbTrees, // number of fitResult trees
59  TTree** trees, // array of fitResult trees
60  const int waveIndex, // wave index
61  const bool saveEps = false, // if set, EPS file with name wave ID is created
62  const int* graphColors = NULL, // array of colors for graph line and marker
63  const double* graphScales = NULL, // array of scales for graphgroups
64  const bool drawLegend = true, // if set legend is drawn
65  const std::string& graphTitle = "", // name and title of graph (default is wave ID)
66  const char* drawOption = "AP", // draw option for graph
67  const double normalization = 1, // scale factor for intensities
68  const double yAxisRangeMax = 0, // if != 0; range of y-axis is limited to this value
69  const std::string& selectExpr = "", // TTree::Draw() selection expression
70  const std::string& branchName = "fitResult_v2"); // fitResult branch name
71 
72 
73 inline
74 TMultiGraph*
75 plotIntensity(std::vector<TTree*>& trees, // array of fitResult trees
76  const int waveIndex, // wave index
77  const bool saveEps = false, // if set, EPS file with name wave ID is created
78  const std::vector<int>& graphColors = std::vector<int>(), // array of colors for graph line and marker
79  const std::vector<double>& graphScales = std::vector<double>(), // array of scales for graphgroups
80  const bool drawLegend = true, // if set legend is drawn
81  const std::string& graphTitle = "", // name and title of graph (default is wave ID)
82  const char* drawOption = "AP", // draw option for graph
83  const double normalization = 1, // scale factor for intensities
84  const double yAxisRangeMax = 0, // if != 0; range of y-axis is limited to this value
85  const std::string& selectExpr = "", // TTree::Draw() selection expression
86  const std::string& branchName = "fitResult_v2") // fitResult branch name
87 {
88  return plotIntensity(trees.size(), &(*(trees.begin())), waveIndex, saveEps,
89  &(*(graphColors.begin())), &(*(graphScales.begin())), drawLegend, graphTitle, drawOption,
90  normalization, yAxisRangeMax, selectExpr, branchName);
91 }
92 
93 
94 inline
95 TMultiGraph*
96 plotIntensity(TTree* tree, // fitResult tree
97  const int waveIndex, // wave index
98  const bool saveEps = false, // if set, EPS file with name wave ID is created
99  const int graphColor = kBlack, // color of line and marker
100 
101  const bool drawLegend = false, // if set legend is drawn
102  const std::string& graphTitle = "", // name and title of graph (default is wave ID)
103  const char* drawOption = "AP", // draw option for graph
104  const double normalization = 1, // scale factor for intensities
105  const double yAxisRangeMax = 0, // if != 0; range of y-axis is limited to this value
106  const std::string& selectExpr = "", // TTree::Draw() selection expression
107  const std::string& branchName = "fitResult_v2") // fitResult branch name
108 {
109  return plotIntensity(1, &tree, waveIndex, saveEps, &graphColor, NULL, drawLegend, graphTitle,
110  drawOption, normalization, yAxisRangeMax, selectExpr, branchName);
111 }
112 
113 
114 // .............................................................................
115 // signatures with wave name
116 // in contrast to other methods, it does not assume
117 // to have all the same waves in all bins
118 //inline
119 TMultiGraph*
120 plotIntensity(const unsigned int nmbTrees, // number of fitResult trees
121  TTree** trees, // array of fitResult trees
122  const std::string& waveName, // wave name
123  const bool saveEps = false, // if set, EPS file with name wave ID is created
124  const int* graphColors = NULL, // array of colors for graph line and marker
125  const double* graphScales = NULL, // array of scales for graphgroups
126  const bool drawLegend = true, // if set legend is drawn
127  const std::string& graphTitle = "", // name and title of graph (default is wave ID)
128  const char* drawOption = "AP", // draw option for graph
129  const double normalization = 1, // scale factor for intensities
130  const double yAxisRangeMax = 0, // if != 0; range of y-axis is limited to this value
131  const std::string& selectExpr = "", // TTree::Draw() selection expression
132  const std::string& branchName = "fitResult_v2") // fitResult branch name
133  ;/*{
134  if (!trees[0]) {
135  printErr << "null pointer to tree[" << 0 << "]. aborting." << endl;
136  return 0;
137  }
138  // get wave index (assumes same wave set in all trees)
139  rpwa::fitResult* massBin = new rpwa::fitResult();
140  trees[0]->SetBranchAddress(branchName.c_str(), &massBin);
141  trees[0]->GetEntry(0);
142  const int index = massBin->waveIndex(waveName);
143  if (index >= 0)
144  return plotIntensity(nmbTrees, trees, index, saveEps, graphColors, drawLegend, graphTitle,
145  drawOption, normalization, yAxisRangeMax, selectExpr, branchName);
146  printErr << "cannot find wave '" << waveName << "' "
147  << "in tree '" << trees[0]->GetName() << "'. aborting." << endl;
148  return 0;
149  }*/
150 
151 
152 inline
153 TMultiGraph*
154 plotIntensity(std::vector<TTree*>& trees, // array of fitResult trees
155  const std::string& waveName, // wave name
156  const bool saveEps = false, // if set, EPS file with name wave ID is created
157  const std::vector<int>& graphColors = std::vector<int>(), // array of colors for graph line and marker
158  const std::vector<double>& graphScales = std::vector<double>(), // array of scales for graphgroups
159  const bool drawLegend = true, // if set legend is drawn
160  const std::string& graphTitle = "", // name and title of graph (default is wave ID)
161  const char* drawOption = "AP", // draw option for graph
162  const double normalization = 1, // scale factor for intensities
163  const double yAxisRangeMax = 0, // if != 0; range of y-axis is limited to this value
164  const std::string& selectExpr = "", // TTree::Draw() selection expression
165  const std::string& branchName = "fitResult_v2") // fitResult branch name
166 {
167  return plotIntensity(trees.size(), &(*(trees.begin())), waveName, saveEps,
168  &(*(graphColors.begin())), &(*(graphScales.begin())), drawLegend, graphTitle, drawOption,
169  normalization, yAxisRangeMax, selectExpr, branchName);
170 }
171 
172 
173 inline
174 TMultiGraph*
175 plotIntensity(TTree* tree, // fitResult tree
176  const std::string& waveName, // wave name
177  const bool saveEps = false, // if set, EPS file with name wave ID is created
178  const int graphColor = kBlack, // color of line and marker
179  const bool drawLegend = true, // if set legend is drawn
180  const std::string& graphTitle = "", // name and title of graph (default is wave ID)
181  const char* drawOption = "AP", // draw option for graph
182  const double normalization = 1, // scale factor for intensities
183  const double yAxisRangeMax = 0, // if != 0; range of y-axis is limited to this value
184  const std::string& selectExpr = "", // TTree::Draw() selection expression
185  const std::string& branchName = "fitResult_v2") // fitResult branch name
186 {
187  return plotIntensity(1, &tree, waveName, saveEps, &graphColor, NULL, drawLegend, graphTitle,
188  drawOption, normalization, yAxisRangeMax, selectExpr, branchName);
189 }
190 
191 
192 #endif //PLOTINTENSITY_HH