39 #include "TGraphErrors.h"
45 #include "reportingUtils.hpp"
60 const int* graphColors,
61 const bool drawLegend,
62 const string& graphTitle,
63 const char* drawOption,
64 const string& selectExpr,
65 const string& branchName)
67 for (
unsigned int i = 0;
i < nmbTrees; ++
i)
69 printErr <<
"null pointer to tree[" << i <<
"]. aborting." << endl;
72 string waveNameA, waveNameB;
76 trees[0]->SetBranchAddress(branchName.c_str(), &massBin);
77 trees[0]->GetEntry(0);
78 waveNameA = massBin->
waveName(waveIndexA).Data();
79 waveNameB = massBin->
waveName(waveIndexB).Data();
81 printInfo <<
"plotting phase between waves '" << waveNameA <<
"' [" << waveIndexA <<
"] "
82 <<
"and '" << waveNameB <<
"' [" << waveIndexB <<
"]" << endl;
84 cout <<
" using selection criterion '" << selectExpr <<
"'" << endl;
87 TMultiGraph* graph =
new TMultiGraph();
89 if (graphTitle !=
"") {
90 graph->SetName (graphTitle.c_str());
91 graph->SetTitle(graphTitle.c_str());
94 name <<
"phase_" << waveNameA <<
"_" << waveNameB;
96 title <<
"#Delta#varphi(" << waveNameA <<
" [" << waveIndexA <<
"], "
97 << waveNameB <<
" [" << waveIndexB <<
"])";
98 graph->SetName(name.str().c_str());
99 graph->SetTitle(title.str().c_str());
104 for (
unsigned int i = 0; i < nmbTrees; ++
i) {
108 trees[
i]->SetBranchAddress(branchName.c_str(), &massBin);
109 trees[
i]->GetEntry(0);
110 const int waveIndexAThisTree = massBin->
waveIndex(waveNameA);
111 const int waveIndexBThisTree = massBin->
waveIndex(waveNameB);
112 if (waveIndexAThisTree < 0) {
113 printInfo <<
"cannot find wave '" << waveNameA <<
"' in tree '" << trees[
i]->GetTitle() <<
"'. "
114 <<
"skipping." << endl;
117 if (waveIndexBThisTree < 0) {
118 printInfo <<
"cannot find wave '" << waveNameB <<
"' in tree '" << trees[
i]->GetTitle() <<
"'. "
119 <<
"skipping." << endl;
124 stringstream drawExpr;
125 drawExpr << branchName <<
".phase(" << waveIndexAThisTree <<
"," << waveIndexBThisTree <<
"):"
126 << branchName <<
".phaseErr(" << waveIndexAThisTree <<
"," << waveIndexBThisTree <<
"):"
127 << branchName <<
".massBinCenter() >> h" << waveIndexAThisTree <<
"_"
128 << waveIndexBThisTree <<
"_" <<
i;
129 cout <<
" running TTree::Draw() expression '" << drawExpr.str() <<
"' "
130 <<
"on tree '" << trees[
i]->GetName() <<
"', '" << trees[
i]->GetTitle() <<
"'" << endl;
131 trees[
i]->Draw(drawExpr.str().c_str(), selectExpr.c_str(),
"goff");
134 const int nmbBins = trees[
i]->GetSelectedRows();
135 vector<double> x(nmbBins), xErr(nmbBins);
136 for (
int j = 0; j < nmbBins; ++j) {
137 x [j] = trees[
i]->GetV3()[j] * 0.001;
140 TGraphErrors* g =
new TGraphErrors(nmbBins,
147 stringstream graphName;
148 graphName << graph->GetName() <<
"_" <<
i;
149 g->SetName (graphName.str().c_str());
150 g->SetTitle(graphName.str().c_str());
151 g->SetMarkerStyle(21);
152 g->SetMarkerSize(0.5);
154 g->SetMarkerColor(graphColors[i]);
155 g->SetLineColor (graphColors[i]);
160 graph->SetMinimum(-240);
161 graph->SetMaximum( 240);
163 graph->Draw(drawOption);
164 graph->GetXaxis()->SetTitle(
"Mass [GeV]");
165 graph->GetYaxis()->SetTitle(
"Phase Angle [deg]");
169 if (drawLegend && (nmbTrees > 1)) {
170 TLegend* legend =
new TLegend(0.65, 0.80, 0.99, 0.99);
171 legend->SetFillColor(10);
172 legend->SetBorderSize(1);
173 legend->SetMargin(0.2);
174 for (
unsigned int i = 0; i < nmbTrees; ++
i) {
175 TGraph* g =
static_cast<TGraph*
>(graph->GetListOfGraphs()->At(i));
176 legend->AddEntry(g, trees[i]->GetTitle(),
"LPE");
183 gPad->SaveAs(((
string)graph->GetName() +
".eps").c_str());