39 #include "TGraphErrors.h"
46 #include "reportingUtils.hpp"
57 const std::string& waveName,
59 const int* graphColors,
60 const double* graphScales,
61 const bool drawLegend,
62 const string& graphTitle,
63 const char* drawOption,
64 const double normalization,
65 const double yAxisRangeMax,
66 const string& selectExpr,
67 const string& branchName)
70 for (
unsigned int i = 0;
i < nmbTrees; ++
i)
72 printErr <<
"null pointer to tree[" << i <<
"]. aborting." << endl;
75 printInfo <<
"plotting wave intensity for wave '" << waveName;
77 cout <<
" using selection criterion '" << selectExpr <<
"'";
81 TMultiGraph* graph =
new TMultiGraph();
83 if (graphTitle !=
"") {
84 graph->SetName (graphTitle.c_str());
85 graph->SetTitle(graphTitle.c_str());
89 graph->SetName (waveName.c_str());
90 graph->SetTitle((waveName + suffix.str()).c_str());
96 for (
unsigned int i = 0; i < nmbTrees; ++
i) {
100 trees[
i]->SetBranchAddress(branchName.c_str(), &massBin);
101 vector<int> waveIndexThisTree;
103 for (
int imassBin = 0; imassBin < trees[
i]->GetEntries(); imassBin++){
104 trees[
i]->GetEntry(imassBin);
105 waveIndexThisTree.push_back(massBin->
waveIndex(waveName));
106 if (waveIndexThisTree[imassBin] >= 0){
111 printInfo <<
"cannot find wave '" << waveName <<
"' in tree '" << trees[
i]->GetTitle() <<
"'. "
112 <<
"skipping." << endl;
119 stringstream drawExpr;
120 drawExpr << branchName <<
".intensity(\"" << waveName <<
"\"):"
121 << branchName <<
".intensityErr(\"" << waveName <<
"\"):"
122 << branchName <<
".massBinCenter() >> h" << waveName <<
"_" <<
i;
123 cout <<
" running TTree::Draw() expression '" << drawExpr.str() <<
"' "
124 <<
"on tree '" << trees[
i]->GetName() <<
"', '" << trees[
i]->GetTitle() <<
"'" << endl;
125 trees[
i]->Draw(drawExpr.str().c_str(), selectExpr.c_str(),
"goff");
128 const int nmbBins = trees[
i]->GetSelectedRows();
129 vector<double> x, xErr;
130 vector<double> y, yErr;
132 double scale = normalization;
134 scale = scale * graphScales[
i];
137 for (
int j = 0; j < nmbBins; ++j) {
138 y .push_back(trees[i]->GetV1()[j] * scale);
143 x .push_back(trees[i]->GetV3()[j] * 0.001);
145 yErr.push_back(trees[i]->GetV2()[j] * scale);
147 TGraphErrors* g =
new TGraphErrors(x.size(),
154 stringstream graphName;
155 graphName << graph->GetName() <<
"_" <<
i;
156 g->SetName (graphName.str().c_str());
157 g->SetTitle(graphName.str().c_str());
158 g->SetMarkerStyle(21);
159 g->SetMarkerSize(0.5);
161 g->SetMarkerColor(graphColors[i]);
162 g->SetLineColor (graphColors[i]);
167 for (
unsigned int j = 0; j < x.size(); ++j) {
168 const double val = y[j] + yErr[j];
173 cout <<
" maximum intensity for graph " << graph->GetName() <<
" is " << maxY << endl;
175 if ((yAxisRangeMax > 0) && (maxY > yAxisRangeMax))
176 maxY = yAxisRangeMax;
177 graph->SetMinimum(-maxY * 0.1);
178 graph->SetMaximum( maxY * 1.1);
180 graph->Draw(drawOption);
181 graph->GetXaxis()->SetTitle(
"Mass [GeV]");
182 graph->GetYaxis()->SetTitle(
"Intensity");
184 line.SetLineStyle(3);
185 line.DrawLine(graph->GetXaxis()->GetXmin(), 0, graph->GetXaxis()->GetXmax(), 0);
189 if (drawLegend && (nmbTrees > 1)) {
190 TLegend* legend =
new TLegend(0.65,0.80,0.99,0.99);
191 legend->SetFillColor(10);
192 legend->SetBorderSize(1);
193 legend->SetMargin(0.2);
194 for (
unsigned int i = 0; i < nmbTrees; ++
i) {
195 TGraph* g =
static_cast<TGraph*
>(graph->GetListOfGraphs()->At(i));
196 legend->AddEntry(g, trees[i]->GetTitle(),
"LPE");
203 gPad->SaveAs(((
string)graph->GetName() +
".eps").c_str());
214 const int* graphColors,
215 const double* graphScales,
216 const bool drawLegend,
217 const string& graphTitle,
218 const char* drawOption,
219 const double normalization,
220 const double yAxisRangeMax,
221 const string& selectExpr,
222 const string& branchName)
224 for (
unsigned int i = 0;
i < nmbTrees; ++
i)
226 printErr <<
"null pointer to tree[" << i <<
"]. aborting." << endl;
233 trees[0]->SetBranchAddress(branchName.c_str(), &massBin);
234 trees[0]->GetEntry(0);
235 waveName = massBin->
waveName(waveIndex).Data();
237 printInfo <<
"plotting wave intensity for wave '" << waveName <<
"' [" << waveIndex <<
"]";
238 if (selectExpr !=
"")
239 cout <<
" using selection criterion '" << selectExpr <<
"'";
243 TMultiGraph* graph =
new TMultiGraph();
245 if (graphTitle !=
"") {
246 graph->SetName (graphTitle.c_str());
247 graph->SetTitle(graphTitle.c_str());
250 suffix <<
" [" << waveIndex <<
"]";
251 graph->SetName (waveName.c_str());
252 graph->SetTitle((waveName + suffix.str()).c_str());
258 for (
unsigned int i = 0; i < nmbTrees; ++
i) {
262 trees[
i]->SetBranchAddress(branchName.c_str(), &massBin);
263 trees[
i]->GetEntry(0);
264 const int waveIndexThisTree = massBin->
waveIndex(waveName);
265 if (waveIndexThisTree < 0) {
266 printInfo <<
"cannot find wave '" << waveName <<
"' in tree '" << trees[
i]->GetTitle() <<
"'. "
267 <<
"skipping." << endl;
272 stringstream drawExpr;
273 drawExpr << branchName <<
".intensity(" << waveIndexThisTree <<
"):"
274 << branchName <<
".intensityErr(" << waveIndexThisTree <<
"):"
275 << branchName <<
".massBinCenter() >> h" << waveName <<
"_" <<
i;
276 cout <<
" running TTree::Draw() expression '" << drawExpr.str() <<
"' "
277 <<
"on tree '" << trees[
i]->GetName() <<
"', '" << trees[
i]->GetTitle() <<
"'" << endl;
278 trees[
i]->Draw(drawExpr.str().c_str(), selectExpr.c_str(),
"goff");
281 const int nmbBins = trees[
i]->GetSelectedRows();
282 vector<double> x(nmbBins), xErr(nmbBins);
283 vector<double> y(nmbBins), yErr(nmbBins);
285 double scale = normalization;
287 scale = scale * graphScales[
i];
290 for (
int j = 0; j < nmbBins; ++j) {
291 x [j] = trees[
i]->GetV3()[j] * 0.001;
293 y [j] = trees[
i]->GetV1()[j] * scale;
294 yErr[j] = trees[
i]->GetV2()[j] * scale;
296 TGraphErrors* g =
new TGraphErrors(nmbBins,
303 stringstream graphName;
304 graphName << graph->GetName() <<
"_" <<
i;
305 g->SetName (graphName.str().c_str());
306 g->SetTitle(graphName.str().c_str());
307 g->SetMarkerStyle(21);
308 g->SetMarkerSize(0.5);
310 g->SetMarkerColor(graphColors[i]);
311 g->SetLineColor (graphColors[i]);
316 for (
int j = 0; j < nmbBins; ++j) {
317 const double val = y[j] + yErr[j];
322 cout <<
" maximum intensity for graph " << graph->GetName() <<
" is " << maxY << endl;
324 if ((yAxisRangeMax > 0) && (maxY > yAxisRangeMax))
325 maxY = yAxisRangeMax;
326 graph->SetMinimum(-maxY * 0.1);
327 graph->SetMaximum( maxY * 1.1);
329 graph->Draw(drawOption);
330 graph->GetXaxis()->SetTitle(
"Mass [GeV]");
331 graph->GetYaxis()->SetTitle(
"Intensity");
333 line.SetLineStyle(3);
334 line.DrawLine(graph->GetXaxis()->GetXmin(), 0, graph->GetXaxis()->GetXmax(), 0);
338 if (drawLegend && (nmbTrees > 1)) {
339 TLegend* legend =
new TLegend(0.65,0.80,0.99,0.99);
340 legend->SetFillColor(10);
341 legend->SetBorderSize(1);
342 legend->SetMargin(0.2);
343 for (
unsigned int i = 0; i < nmbTrees; ++
i) {
344 TGraph* g =
static_cast<TGraph*
>(graph->GetListOfGraphs()->At(i));
345 legend->AddEntry(g, trees[i]->GetTitle(),
"LPE");
352 gPad->SaveAs(((
string)graph->GetName() +
".eps").c_str());