ROOTPWA
plotCoherence.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 coherence 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 PLOTCOHERENCE_HH
37 #define PLOTCOHERENCE_HH
38 
39 
40 #include <string>
41 
42 #include "TTree.h"
43 #include "TMultiGraph.h"
44 
45 #include "fitResult.h"
46 
47 
48 // .............................................................................
49 // signature with wave indices
50 TMultiGraph*
51 plotCoherence(const unsigned int nmbTrees, // number of fitResult trees
52  TTree** trees, // array of fitResult trees
53  const int waveIndexA, // index of first wave
54  const int waveIndexB, // index of second wave
55  const bool saveEps = false, // if set, EPS file with name wave ID is created
56  const int* graphColors = NULL, // array of colors for graph line and marker
57  const bool drawLegend = true, // if set legend is drawn
58  const std::string& graphTitle = "", // name and title of graph (default is wave IDs)
59  const char* drawOption = "AP", // draw option for graph
60  const std::string& selectExpr = "", // TTree::Draw() selection expression
61  const std::string& branchName = "fitResult_v2"); // fitResult branch name
62 
63 
64 TMultiGraph*
65 plotCoherence(TTree* tree, // fitResult tree
66  const int waveIndexA, // index of first wave
67  const int waveIndexB, // index of second wave
68  const bool saveEps = false, // if set, EPS file with name waveId is created
69  const int graphColor = kBlack, // color of line and marker
70  const bool drawLegend = false, // if set legend is drawn
71  const std::string& graphTitle = "", // name and title of graph
72  const char* drawOption = "AP", // draw option for graph
73  const std::string& selectExpr = "", // TTree::Draw() selection expression
74  const std::string& branchName = "fitResult_v2")
75 {
76  return plotCoherence(1, &tree, waveIndexA, waveIndexB, saveEps, &graphColor,
77  drawLegend, graphTitle, drawOption, selectExpr, branchName);
78 }
79 
80 
81 // .............................................................................
82 // signature with wave names
83 TMultiGraph*
84 plotCoherence(const unsigned int nmbTrees, // number of fitResult trees
85  TTree** trees, // array of fitResult trees
86  const std::string& waveNameA, // name of first wave
87  const std::string& waveNameB, // name of second wave
88  const bool saveEps = false, // if set, EPS file with name wave ID is created
89  const int* graphColors = NULL, // array of colors for graph line and marker
90  const bool drawLegend = true, // if set legend is drawn
91  const std::string& graphTitle = "", // name and title of graph (default is wave IDs)
92  const char* drawOption = "AP", // draw option for graph
93  const std::string& selectExpr = "", // TTree::Draw() selection expression
94  const std::string& branchName = "fitResult_v2") // fitResult branch name
95 {
96  if (!trees[0]) {
97  printErr << "null pointer to tree. exiting." << std::endl;
98  return 0;
99  }
100  // get wave indices (assumes same wave set in all trees)
101  rpwa::fitResult* massBin = new rpwa::fitResult();
102  trees[0]->SetBranchAddress(branchName.c_str(), &massBin);
103  trees[0]->GetEntry(0);
104  const int indexA = massBin->waveIndex(waveNameA);
105  const int indexB = massBin->waveIndex(waveNameB);
106  if ((indexA >= 0) && (indexB >= 0))
107  return plotCoherence(nmbTrees, trees, indexA, indexB, saveEps, graphColors, drawLegend,
108  graphTitle, drawOption, selectExpr, branchName);
109  printErr << "cannot find wave(s) in tree '" << trees[0]->GetName() << "'. exiting." << std::endl;
110  return 0;
111 }
112 
113 
114 TMultiGraph*
115 plotCoherence(TTree* tree, // fitResult tree
116  const std::string& waveNameA, // name of first wave
117  const std::string& waveNameB, // name of second wave
118  const bool saveEps = false, // if set, EPS file with name waveId is created
119  const int graphColor = kBlack, // color of line and marker
120  const bool drawLegend = false, // if set legend is drawn
121  const std::string& graphTitle = "", // name and title of graph
122  const char* drawOption = "AP", // draw option for graph
123  const std::string& selectExpr = "", // TTree::Draw() selection expression
124  const std::string& branchName = "fitResult_v2")
125 {
126  return plotCoherence(1, &tree, waveNameA, waveNameB, saveEps, &graphColor,
127  drawLegend, graphTitle, drawOption, selectExpr, branchName);
128 }
129 
130 
131 #endif // PLOTCOHERENCE_HH