8 #include "TGraphErrors.h"
10 #include "TMultiGraph.h"
15 #include "TObjArray.h"
25 #define RECOLOR kYellow-9
26 #define IMCOLOR kSpring-9
33 map<TString, TString> isobars;
34 isobars[
"pi+" ] =
"\\pi^{+}";
35 isobars[
"pi-" ] =
"\\pi^{-}";
36 isobars[
"pi+-" ] =
"\\pi^{\\pm}";
37 isobars[
"pi-+" ] =
"\\pi^{\\pm}";
38 isobars[
"sigma" ] =
"\\sigma";
39 isobars[
"rho770" ] =
"\\rho(770)";
40 isobars[
"a11269" ] =
"a_{1}(1269)";
41 isobars[
"a21320" ] =
"a_{2}(1320)";
42 isobars[
"rho1450" ] =
"\\rho(1450)";
43 isobars[
"rho1600" ] =
"\\rho(1600)";
44 isobars[
"rho1700" ] =
"\\rho(1700)";
45 isobars[
"pi1300" ] =
"\\pi(1300)";
46 isobars[
"pi1800" ] =
"\\pi(1800)";
47 isobars[
"pi21670" ] =
"\\pi_2(1670)";
48 isobars[
"f01370" ] =
"f_{0}(1370)";
49 isobars[
"f01500" ] =
"f_{0}(1500)";
50 isobars[
"f01700" ] =
"f_{0}(1700)";
51 isobars[
"f11285" ] =
"f_{1}(1285)";
52 isobars[
"f11420" ] =
"f_{1}(1420)";
53 isobars[
"b11235" ] =
"b_{1}(1235)";
54 isobars[
"b11800" ] =
"b_{1}(1800)";
55 isobars[
"b11500" ] =
"b_{1}(1500)";
56 isobars[
"f21270" ] =
"f_{2}(1270)";
57 isobars[
"f21950" ] =
"f_{2}(1950)";
58 isobars[
"f21565" ] =
"f_{2}(1565)";
59 isobars[
"f21270" ] =
"f_{2}(1270)";
60 isobars[
"f22010" ] =
"f_{2}(2010)";
61 isobars[
"f11420" ] =
"f_{1}(1420)";
62 isobars[
"eta1440" ] =
"\\eta(1420)";
63 isobars[
"eta11600" ] =
"\\eta_{1}(1600)";
64 isobars[
"eta21645"] =
"\\eta_{2}(1645)";
65 isobars[
"rho31690"] =
"\\rho_{3(1690)";
68 l.Remove(l.Length() - 4);
70 const TString head = l(0, 7);
71 const TString I = head(0, 1);
72 const TString G = head(1, 1);
73 const TString J = head(2, 1);
74 const TString P = head(3, 1);
75 const TString C = head(4, 1);
76 const TString
M = head(5, 1);
77 const TString refl = head(6, 1);
82 res << I <<
"^{" << G <<
"}(" << J <<
"^{" << P << C <<
"}" << M <<
"^{" << refl <<
"})";
85 TObjArray* tokens = l.Tokenize(
"_=");
87 unsigned int counter=0;
88 for (
int i = 0;
i < tokens->GetEntries(); ++
i) {
89 const TString token = ((TObjString*)tokens->At(
i))->GetString();
90 cerr <<
" " << mode <<
": '" << token <<
"'" << endl;
92 if (isobars.find(token) != isobars.end())
93 res << isobars[token];
98 l.Remove(0, token.Length());
103 }
else if (mode == 1) {
104 if (token.Length() == 1)
105 res <<
"[" << token <<
"] ";
107 res <<
"\\left[#splitline{" << token(0, 1) <<
"}{"
108 << token(1, 1) <<
"}\\right]";
109 l.Remove(0, token.Length());
111 }
else if (mode == 2) {
112 if(level<=counter)
break;
114 res <<
"\\rightarrow ";
115 if (isobars.find(token) != isobars.end())
116 res << isobars[token];
120 l.Remove(0, token.Length());
132 TString result(res.str().c_str());
136 void plotNice(TVirtualPad* pad, TString plotDir=
""){
137 TCanvas* cpopup=(TCanvas*)gROOT->FindObjectAny(
"cpopup");
139 cerr <<
"Popupo Window not found! RESPAWNING" << endl;
140 cpopup=
new TCanvas(
"cpopup",
"PopUp",50,50,700,700);
145 TVirtualPad* clone=(TVirtualPad*)pad->Clone();
147 cerr <<
"Cloning pad failed!" << endl;
152 clone->SetFillStyle(1);
154 clone->SetPad(
"pu",
"PopUp",0,0,1,1,0);
158 TMultiGraph* gr=(TMultiGraph*)clone->GetListOfPrimitives()->At(1);
160 cerr <<
"Cloning graphs failed!" << endl;
167 TString title=gr->GetName();
169 if(!title.Contains(
"dPhi") && !title.Contains(
"Re") && !title.Contains(
"Im"))hx=(TH1*)clone->GetListOfPrimitives()->At(2);
173 TGraphErrors* gdata=(TGraphErrors*)gr->GetListOfGraphs()->At(1);
175 cerr <<
"Cloning data failed!" << endl;
178 gdata->SetLineWidth(2);
181 double xmax=gr->GetXaxis()->GetBinCenter(gr->GetXaxis()->GetLast());
182 double xmin=gr->GetXaxis()->GetBinCenter(gr->GetXaxis()->GetFirst());
185 TGraphErrors* fitg=(TGraphErrors*)gr->GetListOfGraphs()->At(2);
188 fitg->SetLineWidth(2);
189 double* yp=fitg->GetY();
190 for(
unsigned int i=0;
i<fitg->GetN();++
i){
191 if(max<yp[
i])max=yp[
i];
192 if(min>yp[i])min=yp[
i];
200 double ymin=0.5*(max+min)-220;
201 double ymax=0.5*(max+min)+220;
203 if(title.Contains(
"dPhi")){
204 cerr <<
"Ymin: " << ymin <<
" Ymax: " << ymax << endl;
206 TGraphErrors* gsys=(TGraphErrors*)gr->GetListOfGraphs()->At(0);
208 unsigned int n=gsys->GetN();
209 for(
unsigned int i=0;
i<
n;++
i){
211 gsys->GetPoint(
i,x,y);
212 ey=gsys->GetErrorY(
i);
213 ex=gsys->GetErrorX(
i);
217 cerr <<
"correcting upper" << endl;
218 double dy=0.5*(y+ey-ymax);
223 double dy=0.5*(ymin-y+ey);
227 gsys->SetPoint(
i,x,y);
228 gsys->SetPointError(
i,ex,ey);
231 if(hx!=NULL)hx->SetLineColor(kMagenta);
234 clone->GetFrame()->Draw();
235 clone->SetBorderMode(0);
243 double x=xcenter-0.25;
244 double y=xcenter-0.2;
247 TLatex* prelim=
new TLatex(x,y,
"preliminary");
249 prelim->SetTextColor(kGray);
250 prelim->SetTextSize(0.1);
251 prelim->SetTextAngle(20);
260 double yc=ycenter+0.45;
261 TLatex* com04=
new TLatex(xc,yc,
"COMPASS 2004");
263 com04->SetTextSize(0.05);
268 TLatex* react=
new TLatex(xc,yc,
"#pi^{-} Pb #rightarrow #pi^{-}#pi^{+}#pi^{-}#pi^{+}#pi^{-} Pb");
270 react->SetTextSize(0.039);
278 if(ymax > 0 && ymin < 0){
279 TLine* zeroline=
new TLine(xmin,0,xmax,0);
280 zeroline->SetLineStyle(7);
285 gr->GetXaxis()->SetTitle(
"mass (GeV/c^{2})");
286 gr->GetXaxis()->Draw();
287 gr->GetYaxis()->Draw();
294 if(!title.Contains(
"---")){
295 cout <<
"Processing Intensity:" << endl;
305 unsigned int offset=3;
306 wave=
"#splitline{Interference - ";
307 if(title.Contains(
"Re"))wave+=
"real part";
308 else if(title.Contains(
"Im"))wave+=
"imaginary part";
310 wave+=
"phase difference";
314 unsigned int i = title.Index(
"---");
315 TString wave1=title(offset,i-offset);
316 TString wave2=title(i+3,title.Length());
329 double max=gr->GetYaxis()->GetXmax();
330 double min=gr->GetYaxis()->GetXmin();
332 TGraph* g=(TGraph*)gr->GetListOfGraphs()->At(1);
334 g->GetPoint((
int)(g->GetN()*0.6),xg,yg);
335 if(fabs(max-yg)>fabs(min-yg)){
348 TLatex* waveL=
new TLatex(xc,yc,wave);
350 if(isIntens)waveL->SetTextSize(0.03);
351 else waveL->SetTextSize(0.02);
359 TLatex* fitNameL=
new TLatex(xc,yc,
fitname);
361 fitNameL->SetTextSize(0.05);
364 cpopup->UseCurrentStyle();
365 if(hx!=NULL)hx->SetLineColor(kMagenta);
368 if(plotDir.Length()>1){
369 TString
filename=plotDir+title+
".eps";
370 filename.ReplaceAll(
".amp",
"");
371 filename.ReplaceAll(
"+",
"p");
372 filename.ReplaceAll(
"---",
"___");
373 filename.ReplaceAll(
"-",
"m");
374 filename.ReplaceAll(
"=",
"_to_");
375 cpopup->SaveAs(filename);
379 cerr <<
"###### end of plotnice" << endl;
385 TCanvas *c = (TCanvas *) gTQSender;
392 TVirtualPad* pad=c->GetClickSelectedPad();
409 void plotMassDepFitResult(TString infilename, TString plotdir=
"plots/", TString fittitle=
"",
double mmin=0,
double mmax=0,
unsigned int plotLevel=0 , TString xcheckfile=
"",
bool onlyDiag=
false){
410 if(fittitle.Length()<=1)
fitname=infilename;
412 TFile* infile=TFile::Open(infilename);
414 gStyle->SetTextFont(font);
415 gStyle->SetLabelFont(font,
"xy");
416 gStyle->SetTitleFont(font,
"xy");
417 gStyle->SetOptStat(0);
418 gStyle->SetOptTitle(0);
419 gStyle->SetStripDecimals(1);
420 TGaxis::SetMaxDigits(4);
421 gStyle->SetFrameFillStyle(0);
422 gStyle->SetFrameBorderMode(0);
427 ifstream xcheckmapfile;
428 map<TString,TString> xcheckmap;
429 if(xcheckfile.Length()>2){
430 cerr <<
"Found XCheck File " << xcheckfile << endl;
431 xcheck=TFile::Open(xcheckfile);
432 xcheckfile.ReplaceAll(
".root",
".map");
433 xcheckmapfile.open(xcheckfile.Data());
435 while(xcheckmapfile.good()){
436 xcheckmapfile >> wave >> key;
438 cerr << wave <<
" ---> " << key << endl;
445 TList* keylist=infile->GetListOfKeys();
446 unsigned int num=keylist->GetEntries();
449 vector<TString> wavenames;
451 for(
unsigned int i=0;
i<num;++
i){
452 TString keyname(((TKey*)keylist->At(
i))->GetName());
453 if(keyname.Contains(
"dPhi") || keyname.Contains(
"Re") || keyname.Contains(
"Im") || keyname.Contains(
"fPS"))
continue;
454 wavenames.push_back(keyname);
459 unsigned int nwaves=wavenames.size();
460 std::cout << nwaves <<
" waves used in fit" << endl;
462 map<TString,TString> xcheckmapReIm;
463 for(
unsigned int i=0;
i<nwaves;++
i){
464 TString map1=xcheckmap[wavenames[
i]];
465 unsigned int index1=
atoi(map1(1,2).Data());
466 for(
unsigned int j=
i+1;j<nwaves;++j){
467 TString keyRe=
"Re_"+wavenames[
i]+
"---"+wavenames[j];
468 TString keyIm=
"Im_"+wavenames[
i]+
"---"+wavenames[j];
469 TString map2=xcheckmap[wavenames[j]];
471 unsigned int index2=
atoi(map2(1,2).Data());
472 TString ReMapper=
"h";ReMapper+= 10000+100*index1+index2;
473 TString ImMapper=
"h";ImMapper+= 20000+100*index1+index2;
474 xcheckmapReIm[keyRe]=ReMapper;
475 xcheckmapReIm[keyIm]=ImMapper;
481 TCanvas* cS=
new TCanvas(
"cS",
"Spin Density Matrix",10,10,1000,1000);
482 cS->Divide(nwaves,nwaves,0,0);
483 TCanvas* cRe=
new TCanvas(
"cRe",
"Spin Density Matrix - RealImagPart",10,10,1000,1000);
484 cRe->Divide(nwaves,nwaves,0,0);
485 cRe->Connect(
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", 0, 0,
"exec3event(Int_t,Int_t,Int_t,TObject*)");
486 cS->Connect(
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", 0, 0,
"exec3event(Int_t,Int_t,Int_t,TObject*)");
488 TCanvas* cpopup=
new TCanvas(
"cpopup",
"PopUp",50,50,700,700);
500 for(
unsigned int ip=0;ip<nwaves;++ip){
501 for(
unsigned int jp=ip;jp<nwaves;++jp){
502 cS->cd(jp+ip*nwaves+1);
503 cerr <<
" ##### " << ip <<
"-" << jp <<
" ###### " << endl;
505 TMultiGraph* g=(TMultiGraph*)infile->Get(wavenames[ip]);
513 for(
unsigned int i=g->GetListOfGraphs()->GetSize()-1;
i>2;--
i){
514 g->GetListOfGraphs()->RemoveAt(
i);
518 else g->GetListOfGraphs()->RemoveAt(3);
522 if(plotLevel>1)g->GetListOfGraphs()->RemoveAt(2);
526 TGraphErrors* datag=(TGraphErrors*)g->GetListOfGraphs()->At(1);
527 double* y=datag->GetY();
530 for(
unsigned int i=0;
i<datag->GetN();++
i){
531 if(max<y[
i])max=y[
i];
532 if(min>y[i])min=y[
i];
534 cout << min <<
" " << max << endl;
536 g->GetYaxis()->SetTitle(
"intensity");
537 g->GetYaxis()->SetTitleOffset(1.3);
539 if(mmin!=0 || mmax!=0){
540 g->GetXaxis()->SetRangeUser(mmin,mmax);
544 cRe->cd(jp+ip*nwaves+1);
549 TString xcheckkey=xcheckmap[wavenames[ip]];
550 cerr <<
"Adding xcheckplot " << xcheckkey << endl;
552 TH1* xh=(TH1*)xcheck->Get(xcheckkey);
554 xh->SetLineColor(kMagenta);
557 else cerr <<
"Did not find xcheckPlot!" << endl;
569 plotNice(cRe->GetPad(jp+ip*nwaves+1),plotdir);
572 if(onlyDiag)
continue;
573 TString key=
"dPhi_"+wavenames[ip]+
"---"+wavenames[jp];
575 TMultiGraph* g=(TMultiGraph*)infile->Get(key);
577 TString title=g->GetName();
578 unsigned int i = title.Index(
"---");
579 TString wave1=title(5,i-5);
580 TString wave2=title(i+3,title.Length());
582 if(wave1(6)!=wave2(6))
continue;
584 if(plotLevel>1)g->GetListOfGraphs()->RemoveAt(2);
586 if(mmin!=0 || mmax!=0){
587 g->GetXaxis()->SetRangeUser(mmin,mmax);
591 TGraphErrors* fitg=(TGraphErrors*)g->GetListOfGraphs()->At(2);
593 double* y=fitg->GetY();
594 for(
unsigned int i=0;i<fitg->GetN();++
i){
595 if(max<y[i])max=y[
i];
596 if(min>y[i])min=y[
i];
599 TAxis*
a=g->GetYaxis();
600 if(a!=NULL)a->SetRangeUser(0.5*(max+min)-220,0.5*(max+min)+220);
601 a->SetTitle(
"#Delta#phi");
602 a->SetTitleOffset(1.3);
604 plotNice(cS->GetPad(jp+ip*nwaves+1),plotdir);
612 key.ReplaceAll(
"dPhi",
"Re");
613 TMultiGraph* g2=(TMultiGraph*)infile->Get(key);
614 if(plotLevel>1)g2->GetListOfGraphs()->RemoveAt(2);
615 TVirtualPad* pa= cRe->cd(jp+ip*nwaves+1);
618 if(mmin!=0 || mmax!=0){
619 g2->GetXaxis()->SetRangeUser(mmin,mmax);
621 g2->GetXaxis()->SetTitle(
"mass (MeV/c^{2})");
622 g2->GetYaxis()->SetTitle(
"real part");
623 g2->GetYaxis()->SetTitleOffset(1.3);
627 TString xcheckkey=xcheckmapReIm[key];
628 cerr <<
"Adding xcheckplot " << xcheckkey << endl;
630 TH1* xh=(TH1*)xcheck->Get(xcheckkey);
632 xh->SetLineColor(kMagenta);
635 else cerr <<
"Did not find xcheckPlot!" << endl;
640 plotNice(cRe->GetPad(jp+ip*nwaves+1),plotdir);
648 key.ReplaceAll(
"Re",
"Im");
649 TMultiGraph* g3=(TMultiGraph*)infile->Get(key);
650 if(plotLevel>1)g3->GetListOfGraphs()->RemoveAt(2);
652 pa=cRe->cd(ip+jp*nwaves+1);
655 if(mmin!=0 || mmax!=0){
656 g3->GetXaxis()->SetRangeUser(mmin,mmax);
658 g3->GetXaxis()->SetTitle(
"mass (MeV/c^{2})");
659 g3->GetYaxis()->SetTitle(
"imaginary part");
660 g3->GetYaxis()->SetTitleOffset(1.3);
664 TString xcheckkey=xcheckmapReIm[key];
665 cerr <<
"Adding xcheckplot " << xcheckkey << endl;
667 TH1* xh=(TH1*)xcheck->Get(xcheckkey);
671 xh->SetLineColor(kMagenta);
674 else cerr <<
"Did not find xcheckPlot!" << endl;
679 plotNice(cRe->GetPad(ip+jp*nwaves+1),plotdir);
693 cS->SaveAs(TString(plotdir+
"/spindensitymatrix.eps"));
694 cRe->SaveAs(TString(plotdir+
"/spindensitymatrixRe.eps"));