ROOTPWA
plotwave_comp.C
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 void plotwave_comp(TString tag, TString qtag, double scale=1, const char* select=0, const char* title=0, bool save=false){
22 
23  TString tit(tag);
24 
25  TString com="intens(";
26  if(tag.IsDigit()){
27  com+=tag;
28  com+="):err(";
29  com+=tag;
30  com+="):_mass";
31  if(title==NULL){
32  TFitBin* bin=new TFitBin();
33  pwa->SetBranchAddress("fitbin",&bin);
34  pwa->GetEntry(0);
35  tit=bin->wavename(atoi(tag.Data()));
36  }
37 
38  }
39  else{
40  com+="\"";
41  com+=tag;
42  com+="\"):err(\"";
43  com+=tag;
44  com+="\"):_mass";
45  }
46 
47 
48  TString sel;
49  if(select!=0){
50  sel=select;
51  }
52 
53  cout << com << endl;
54 
55  pwa->Draw(com.Data(),sel.Data(),"goff");
56  int np=pwa->GetSelectedRows();
57  double* xerr=new double[np];
58  for(int i=0;i<np;++i){
59  pwa->GetV1()[i]*=scale;
60  pwa->GetV2()[i]*=scale;
61  pwa->GetV3()[i]*=0.001; // convert to GeV
62  xerr[i]=0.02;
63  }
64 
65  TGraphErrors* g=new TGraphErrors(np,
66  pwa->GetV3(), // mass
67  pwa->GetV1(), // intensity
68  xerr,pwa->GetV2());
69 
70 
71  g->SetName(tag);
72  g->SetTitle(tag);
73 
74 
75 
76  double maxi=0;
77  for(int i=0;i<np;++i){
78  if(maxi<g->GetY()[i])maxi=g->GetY()[i];
79  }
80  cout << maxi << endl;
81 
82  g->SetTitle(tit);
83  //g->SetMarkerStyle(20);
84  g->SetMarkerSize(0.8);
85  if(title!=0)g->SetTitle(title);
86  g->SetMaximum(maxi*1.1);
87  g->SetMinimum(-maxi*0.1);
88  TGraphErrors* clone=(TGraphErrors*)g->DrawClone("AP");
89  clone->GetYaxis()->SetRangeUser(-maxi*0.1,maxi*1.1);
90  clone->SetLineColor(kRed);
91  clone->SetMarkerColor(kRed);
92  clone->GetXaxis()->SetTitle("Mass / GeV");
93 
94  clone->GetYaxis()->SetTitle("Intensity");
95  clone->GetYaxis()->SetTitleOffset(1.3);
96 
97  TString pathname = "/lustre/e18/user/sneubert/Q3PiData/";
98  TString filename1="hfit_t_0p1_1p0_zemach_42waves_tdep_30a_2.root";
99 
100  TFile file1(pathname+filename1);
101 
102 
103  TH1F* hist1 = (TH1F*)file1.Get(qtag);//results from mass-independent fit
104  if(hist1!=NULL){
105  hist1->DrawCopy("same");
106  }
107  else { cout << "Reference Histo not found!" << endl; }
108 
109  double xmax=clone->GetXaxis()->GetXmax();
110  TLegend* leg=new TLegend(0.65,0.75,0.85,0.85);
111  leg->AddEntry(hist1,"Weitzel/Ryabch","LE");
112  leg->AddEntry(clone,"pwaroot (scaled)","LE");
113 
114  leg->Draw();
115 
116  if(save){
117  TString outfile(tag);
118  outfile+=".eps";
119  gPad->SaveAs(outfile);
120  }
121 
122 
123  delete g;
124  return;
125 }