35 #include "TMultiGraph.h"
38 #include "TGraphErrors.h"
48 unsigned int ybins=h->GetNbinsY();
49 unsigned int xpoints=g->GetN();
50 TAxis* ax=h->GetYaxis();
51 double ymin=ax->GetXmin();
52 double ymax=ax->GetXmax();
54 TF1 gaus(
"gaus",
"gausn(0)",ymin,ymax);
55 TString tit=g->GetTitle();
57 for(
unsigned int ip=0; ip<xpoints; ++ip){
58 double x=g->GetX()[ip];
59 double err=g->GetEY()[ip];
60 double val=g->GetY()[ip];
69 gaus.SetParameters(1,val,err);
70 for(
unsigned int ibin=1; ibin<ybins;++ibin){
71 double y=ax->GetBinCenter(ibin);
73 double w=gaus.Eval(ax->GetBinCenter(ibin))*weight;
74 if(w==w)h->Fill(x,y,w);
85 return wavename.substr(0,7);
92 pwaPlotter::pwaPlotter()
109 std::vector<string> waves;
110 waves.push_back(
"1-2-+0+pi-_02_f21270=pi-+_1_a11269=pi+-_0_rho770.amp");
111 waves.push_back(
"1-2-+0+pi-_22_f21270=pi-+_11_a11269=pi+-_01_rho770.amp");
112 waves.push_back(
"1-2-+0+rho770_02_a21320=pi-_2_rho770.amp");
113 waves.push_back(
"1-2-+0+rho770_02_a11269=pi-_0_rho770.amp");
114 waves.push_back(
"1-0-+0+pi-_00_f01500=rho770_00_rho770.amp");
115 waves.push_back(
"1-0-+0+pi-_00_f01500=sigma_0_sigma.amp");
116 waves.push_back(
"1-0-+0+rho770_00_a11269=pi-_0_rho770.amp");
117 waves.push_back(
"1-0-+0+rho770_22_a11269=pi-_01_rho770.amp");
118 waves.push_back(
"1-0-+0+pi-_22_f21270=sigma_2_sigma.amp");
119 waves.push_back(
"1-1++0+pi-_01_eta11600=pi-+_10_pi1300=pi+-_00_sigma.amp");
120 waves.push_back(
"1-1++0+pi-_01_eta11600=pi-+_01_a11269=pi+-_01_rho770.amp");
122 waves.push_back(
"1-1++0+sigma_01_a11269=pi-_0_rho770.amp");
123 waves.push_back(
"1-1++0+sigma_01_a11269=pi-_1_sigma.amp");
124 waves.push_back(
"1-1++0+rho770_11_a11269=pi-_0_rho770.amp");
125 waves.push_back(
"1-1++0+rho770_12_a11269=pi-_0_rho770.amp");
126 waves.push_back(
"1-1++0+rho770_01_pi1300=pi-_1_rho770.amp");
128 waves.push_back(
"1-1++0+pi-_11_f11285=pi-+_11_a11269=pi+-_0_rho770.amp");
129 waves.push_back(
"1-1++0+pi-_01_rho1600=sigma_01_rho770.amp");
130 waves.push_back(
"1-1++0+pi-_10_f01370=rho770_00_rho770.amp");
131 waves.push_back(
"1-1++0+pi-_10_f01500=sigma_0_sigma.amp");
132 waves.push_back(
"1-1++0+pi-_12_b21800=pi-+_12_a21320=pi+-_21_rho770.amp");
134 std::vector<strpair> phlist;
135 for(
unsigned int i=0;
i<waves.size();++
i){
136 for(
unsigned int j=
i+1;j<waves.size();++j){
137 phlist.push_back(
strpair(waves[
i],waves[j]));
143 for(
unsigned int i=0;
i<phlist.size();++
i){
144 mPhases[phlist[
i]]=
new TMultiGraph();
145 std::stringstream name;
146 name <<
"PHI"<<phlist[
i].first<<
"---"<<
"PHI"<<phlist[
i].second;
147 mPhases[phlist[
i]]->SetTitle(name.str().c_str());
148 mPhases[phlist[
i]]->SetName(name.str().c_str());
162 const std::string& title,
163 const unsigned int colour,
164 const std::string& treename,
165 const std::string& branchname,
166 const unsigned int numb_bins){
169 TFile* infile = TFile::Open(filename.c_str(),
"READ");
170 if(infile==NULL || infile->IsZombie()){
171 cerr <<
"Input file "<<filename<<
" is not a valid file!" << endl;
174 TTree* intree=(TTree*)infile->FindObjectAny(treename.c_str());
175 if(intree==NULL || intree->IsZombie()){
176 cerr <<
"Tree "<<treename<<
" not found in file "<<filename<< endl;
180 if(intree->FindBranch(branchname.c_str())==NULL){
181 cerr <<
"Invalid branch "<<treename<<
"."<<branchname<<
" in file "
187 cerr <<
"Adding file "<< filename << endl;
189 intree->SetBranchAddress(branchname.c_str(),&result);
190 unsigned int nbins=intree->GetEntries();
191 if(numb_bins!=0 && nbins!=numb_bins){
192 cerr <<
"Wrong number of bins "<<nbins<<
" in file "
204 double logliperevt=0;
207 unsigned int numwaves=0;
208 set<string> wavesinthisfit;
210 for(
unsigned int i=0;
i<nbins;++
i){
214 if(massBinCenter>mass_max)mass_max=massBinCenter;
215 if(massBinCenter<mass_min)mass_min=massBinCenter;
218 wavesinthisfit.insert(
".*");
220 wavesinthisfit.insert(
"^.....0");
222 wavesinthisfit.insert(
"^.....1");
225 wavesinthisfit.insert(
"^......\\+");
227 wavesinthisfit.insert(
"^......-");
231 const vector<string>& waveNames=result->
waveNames();
232 numwaves=waveNames.size();
234 for(
unsigned int iw=0;iw<numwaves;++iw){
236 wavesinthisfit.insert(waveNames[iw]);
248 double binwidth=(mass_max-mass_min)/(
double)(nbins-1);
249 cerr <<
"Number of bins: " << nbins
250 <<
" Width: " << binwidth << endl;
262 set<string>::iterator it=wavesinthisfit.begin();
263 while(it!=wavesinthisfit.end()){
265 stringstream graphName;
266 if(*it==
".*") graphName <<
"g" << title <<
"_total";
267 else if(*it==
"^.....0") graphName <<
"g" << title <<
"_M0";
268 else if(*it==
"^.....1") graphName <<
"g" << title <<
"_M1";
269 else if(*it==
"^......\\+") graphName <<
"g" << title <<
"_E+";
270 else if(*it==
"^......-") graphName <<
"g" << title <<
"_E-";
271 else graphName <<
"g" << title <<
"_" << *it;
275 g->SetName (graphName.str().c_str());
276 g->SetTitle(graphName.str().c_str());
278 g->SetMarkerSize(0.5);
279 g->SetMarkerColor(colour);
280 g->SetLineColor(colour);
281 g->GetXaxis()->SetTitle(
"mass (GeV/c^{2})");
282 g->GetYaxis()->SetTitle(
"intensity");
292 TGraph* gLikeli=
new TGraph(nbins);
293 stringstream graphName;
294 graphName <<
"g" << title <<
"_LogLikelihood";
295 gLikeli->SetName (graphName.str().c_str());
296 gLikeli->SetTitle(graphName.str().c_str());
297 gLikeli->SetMarkerStyle(21);
298 gLikeli->SetMarkerSize(0.5);
299 gLikeli->SetMarkerColor(colour);
300 gLikeli->SetLineColor(colour);
302 TGraph* gLikeliPE=
new TGraph(nbins);
304 graphName <<
"g" << title <<
"_LogLikelihoodPerEvent";
305 gLikeliPE->SetName (graphName.str().c_str());
306 gLikeliPE->SetTitle(graphName.str().c_str());
307 gLikeliPE->SetMarkerStyle(21);
308 gLikeliPE->SetMarkerSize(0.5);
309 gLikeliPE->SetMarkerColor(colour);
310 gLikeliPE->SetLineColor(colour);
312 TGraph* gEvidence=
new TGraph(nbins);
314 graphName <<
"g" << title <<
"_Evidence";
315 gEvidence->SetName (graphName.str().c_str());
316 gEvidence->SetTitle(graphName.str().c_str());
317 gEvidence->SetMarkerStyle(21);
318 gEvidence->SetMarkerSize(0.5);
319 gEvidence->SetMarkerColor(colour);
320 gEvidence->SetLineColor(colour);
322 TGraph* gEvidencePE=
new TGraph(nbins);
324 graphName <<
"g" << title <<
"_EvidencePerEvent";
325 gEvidencePE->SetName (graphName.str().c_str());
326 gEvidencePE->SetTitle(graphName.str().c_str());
327 gEvidencePE->SetMarkerStyle(21);
328 gEvidencePE->SetMarkerSize(0.5);
329 gEvidencePE->SetMarkerColor(colour);
330 gEvidencePE->SetLineColor(colour);
335 std::map<strpair,TMultiGraph*>::iterator iph=
mPhases.begin();
338 std::string w1=iph->first.first;
339 std::string w2=iph->first.second;
340 if(wavesinthisfit.find(w1)!=wavesinthisfit.end() &&
341 wavesinthisfit.find(w2)!=wavesinthisfit.end() ){
343 stringstream graphName;
344 graphName <<
"PHI"<<w1<<
"---"<<
"PHI"<<w2;
346 cout <<
"creating graph " << graphName.str() << endl;
348 g->SetName (graphName.str().c_str());
349 g->SetTitle(graphName.str().c_str());
350 g->SetMarkerStyle(21);
351 g->SetMarkerSize(0.5);
352 g->SetMarkerColor(colour);
353 g->SetLineColor(colour);
354 g->GetXaxis()->SetTitle(
"mass (GeV/c^{2})");
355 g->GetYaxis()->SetTitle(
"#Delta #Phi");
356 iph->second->Add(g,
"p");
372 for(
unsigned int i=0;
i<nbins;++
i){
375 it=wavesinthisfit.begin();
376 while(it!=wavesinthisfit.end()){
378 if(it->find(
"amp")!=it->npos){
382 unsigned int waveid=result->
waveIndex(*it);
392 TGraphErrors* g=
dynamic_cast<TGraphErrors*
>(mg->GetListOfGraphs()->Last());
407 std::string w1=iph->first.first;
408 std::string w2=iph->first.second;
409 if(wavesinthisfit.find(w1)!=wavesinthisfit.end() &&
410 wavesinthisfit.find(w2)!=wavesinthisfit.end() ){
411 TGraphErrors* g=
dynamic_cast<TGraphErrors*
>(iph->second->GetListOfGraphs()->Last());
413 double ph=result->
phase(w1,w2);
419 g->GetPoint(
i-3,mpre,phpre);
420 double diff1=fabs(ph-phpre);
421 double diff2=fabs(ph+360-phpre);
422 double diff3=fabs(ph-360-phpre);
423 if(diff2<diff1 && diff2<diff3)ph+=360;
424 else if(diff3<diff1 && diff3<diff2)ph-=360;
432 g->SetPointError(
i*3,
440 g->SetPointError(
i*3+1,
447 g->SetPointError(
i*3+2,
461 gLikeliPE->SetPoint(
i,
464 gEvidence->SetPoint(
i,
467 gEvidencePE->SetPoint(
i,
479 meta.
setBinRange(mass_min-binwidth*0.5,mass_max+binwidth*0.5,nbins);
484 cout <<
"Fit Quality Summary: " << endl;
485 cout <<
" LogLikelihood: " << logli << endl;
486 cout <<
" Evidence: " << evi << endl;
487 cout <<
" Number of waves: " << numwaves << endl;
500 pair<set<string>::iterator,
bool> inserted=
mWavenames.insert(wavename);
502 cerr <<
"New wave ("<<
mWavenames.size()<<
"): " << wavename << endl;
509 string psname=wavename;psname.append(
"PS");
515 return inserted.second;
522 map<string,TMultiGraph*>::iterator it=
mIntensities.begin();
523 multimap<unsigned int, string> m;
526 TList* graphs=it->second->GetListOfGraphs();
527 unsigned int ng=graphs->GetEntries();
528 m.insert(pair<unsigned int,string>(ng,it->first));
532 multimap<unsigned int, string>::iterator it2=m.begin();
535 cout << it2->second <<
" used " << it2->first <<
" times"
536 <<
" with average evidence " <<
mWaveEvidence[it2->second]/(double)it2->first<< endl;
545 cout <<
"Average number of waves: " << numwave << endl;
555 map<string,TMultiGraph*>::iterator it=
mIntensities.begin();
558 TList* graphs=it->second->GetListOfGraphs();
559 unsigned int ng=graphs->GetEntries();
560 double xmin=1E9;
double ymin=1E9;
561 double xmax=0;
double ymax=-1E9;
562 unsigned int nbins=0;
563 for(
unsigned int ig=0;ig<ng;++ig){
565 double xmin1,xmax1,ymin1,ymax1;
566 g->ComputeRange(xmin1,ymin1,xmax1,ymax1);
568 if(ymin > ymin1)ymin=ymin1;
569 if(ymax < ymax1)ymax=ymax1;
576 double r=fabs(ymax-ymin)*0.1;
578 string name=
"d";name.append(it->first);
581 TH2D* h=
new TH2D(name.c_str(),name.c_str(),
588 for(
unsigned int ig=0;ig<ng;++ig){
598 for(
unsigned int ibin=1; ibin<=nbins; ++ibin){
601 for(
unsigned int iy=0;iy<400;++iy){
602 unsigned int bin = h->GetBin(ibin,iy);
603 double val=h->GetBinContent(bin);
606 if(max!=0 && max==max){
607 for(
unsigned int iy=0;iy<400;++iy){
608 unsigned int bin = h->GetBin(ibin,iy);
609 h->SetBinContent(bin,h->GetBinContent(bin)/max);
623 TFile* outfile=TFile::Open(filename.c_str(),
"RECREATE");
624 if(outfile!=0 && !outfile->IsZombie()){
629 cerr <<
"Error opening file " << filename << endl;
647 TFile* outfile=TFile::Open(filename.c_str(),
"RECREATE");
648 if(outfile!=0 && !outfile->IsZombie()){
653 cerr <<
"Error opening file " << filename << endl;
662 map<string,TMultiGraph*>::iterator it=
mIntensities.begin();
669 itd->second->Write();
672 map<string,TGraph*>::iterator itps=
mPhaseSpace.begin();
674 itps->second->Write();
677 map<strpair,TMultiGraph*>::iterator itph=
mPhases.begin();
679 itph->second->Write();