ROOTPWA
compareFits.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 #include "TFile.h"
22 #include "TTree.h"
23 #include "TFileCollection.h"
24 #include "TChain.h"
25 #include "TTree.h"
26 #include "TGraph.h"
27 #include "TMultiGraph.h"
28 #include "TString.h"
29 #include "TFitBin.h"
30 #include <string>
31 #include <vector>
32 #include <iostream>
33 using namespace std;
34 
35 TChain*
36 loadFit(TString select){
37  cout << "Loading " << select << endl;
38  TChain* pwa=new TChain(select,select);
39  TString kap=select;
40  kap+="/pwa";
41  pwa->Add(kap);
42 
43  pwa->Scan("nwaves()");
44 
45 
46  return pwa;
47 
48 
49 }
50 
51 
52 
53 void
55 
56  vector<TString> files;
57 files.push_back("/afs/e18/compass/analysis/sneubert/Q3PiData/FITS/testseries/1020.1220.test6.grad.result.root");
58 files.push_back("/afs/e18/compass/analysis/sneubert/Q3PiData/FITS/testseries/1020.1220.test7.grad.result.root");
59  files.push_back("/afs/e18/compass/analysis/sneubert/Q3PiData/FITS/testseries/1020.1220.test8.grad.result.root");
60  files.push_back("/afs/e18/compass/analysis/sneubert/Q3PiData/FITS/testseries/1020.1220.test9.grad.result.root");
61  files.push_back("/afs/e18/compass/analysis/sneubert/Q3PiData/FITS/testseries/1020.1220.test10.grad.result.root");
62 files.push_back("/afs/e18/compass/analysis/sneubert/Q3PiData/FITS/testseries/1020.1220.test11.grad.result.root");
63 //files.push_back("/afs/e18/compass/analysis/sneubert/Q3PiData/FITS/fit5/rank2/1020.1220.result.root");
64 
65  int b=1;
66 
67 
68  // load chains
69  vector<TChain* > chains;
70  for(int k=0;k<files.size();++k){
71  chains.push_back(loadFit(files[k]));
72  }
73 
74  // make error plots
75 
76  unsigned int nc=chains.size();
77 
78  TFitBin* bin=new TFitBin();
79  chains[nc-1]->SetBranchAddress("fitbin",&bin);
80  chains[nc-1]->GetEntry(b);
81 
82  // now build graphs;
83  int ng=bin->nwaves();
84  cout << "Installing "<<ng<<" error graphs:"<<endl;
85  TMultiGraph* mg=new TMultiGraph();
86  vector<TGraph*> graphs(ng);
87  vector<TString> names(ng);
88  for(int ig=0;ig<ng;++ig){
89  names[ig]=bin->waveDesignator(ig);
90  cout<<names[ig]<<endl;
91  TGraph* gerr=new TGraph(nc);
92  graphs[ig]=gerr;
93  gerr->SetMarkerStyle(22);
94  if(names[ig].Contains("1++0+rho770_01"))gerr->SetLineColor(kRed);
95  //gerr->SetTitel(names[ng]);
96  gerr->SetName(names[ig]);
97  mg->Add(gerr);
98  }
99 
100 
101  // loop through fits
102  for(unsigned int i=0; i<nc; ++i){
103  TChain* mychain=chains[i];
104  mychain->SetBranchAddress("fitbin",&bin);
105  mychain->GetBranch("fitbin")->SetAutoDelete();
106  mychain->GetEntry(b);
107  for(unsigned int ig=0;ig<ng;++ig){
108  // get error of wave in first bin
109  double intens=bin->intens(names[ig]);
110  if(intens>0)graphs[ig]->SetPoint(i,bin->nwaves(),bin->err(names[ig])/intens);
111  else graphs[ig]->SetPoint(i,bin->nwaves(),0);
112  }
113  }
114 
115  mg->Draw("APL");
116  cout << "there should be "<<nc<<" wavesets with these numbers of waves:" << endl;
117  for(unsigned int i=0; i<nc; ++i){
118  TChain* mychain=chains[i];
119  mychain->GetEntry(0);
120  cout << bin->nwaves() << endl;
121  }
122 
123 }