6 TTree *tres =
new TTree();
7 tres->ReadFile( csvfile,
"ptrue:etatrue:psig:psig_err:pmean:pmean_err:norm",
',' );
13 unsigned colors[8] = {1,2,3,4,6,7,14,16};
16 vector< double > etas_vis;
17 etas_vis.push_back(-2.75);
18 etas_vis.push_back(-2.25);
19 etas_vis.push_back(-1.75);
20 etas_vis.push_back(-0.25);
21 etas_vis.push_back( 0.25);
22 etas_vis.push_back( 1.75);
23 etas_vis.push_back( 2.25);
35 vector< double > etas_fit;
36 for (
double eta = -4.45;
eta < 4.5;
eta += 0.1 )
37 etas_fit.push_back(
eta );
40 TF1* f_momres =
new TF1(
"f_momres",
"sqrt( [0]*[0] + [1]*[1]*x*x )" );
42 cout <<
"\nFit function: " << f_momres->GetTitle() <<
"\n" << endl;
45 TCanvas *cscratch =
new TCanvas(
"cscratch");
48 TH1F* hframe =
new TH1F(
"hframe",
"",100,0,40);
49 hframe->GetYaxis()->SetRangeUser(0,0.15);
50 hframe->GetYaxis()->SetNdivisions(505);
51 hframe->GetXaxis()->SetTitle(
"Momentum (GeV/c)");
52 hframe->GetYaxis()->SetTitle(
"#sigma_{p}/p");
55 TCanvas *c1 =
new TCanvas();
59 TLegend* leg_eta =
new TLegend( 0.2, 0.6, 0.5, 0.9);
60 leg_eta->SetNColumns(2);
63 ofstream ofsfit(
"track_momres_new.csv");
64 ofsfit<<
"eta,par1,par1err,par2,par2err"<<endl;
67 for (
int i = 0;
i < etas_fit.size();
i++ )
72 double eta = etas_fit.at(
i);
75 if ( eta < -4 || eta > 4 )
78 cout <<
"\n***Eta = " << eta << endl;
86 TCut cutx( Form(
"ptrue > 1 && ( (etatrue > 0 && (etatrue > %f && etatrue < %f)) || (etatrue < 0 && (etatrue < %f && etatrue > %f)) )", eta_min, eta_max, eta_min, eta_max) );
89 tres->Draw(
"psig:ptrue:psig_err:0", cutx );
92 TGraphErrors *gres =
new TGraphErrors( tres->GetEntries(cutx),
96 &(tres->GetV3())[0] );
99 f_momres->SetParameter(0,0.1);
100 f_momres->SetParameter(1,0.1);
106 for ( vi = 0; vi < etas_vis.size(); vi++ )
108 if ( abs( etas_vis.at(vi) -
eta ) < 0.001 )
118 leg_eta->AddEntry(gres, Form(
"#eta = %.1f", eta),
"P");
122 gres->SetMarkerColor(colors[vi]);
124 f_momres->SetLineColor(colors[vi]);
133 double par1 = f_momres->GetParameter(0);
134 double par1err = f_momres->GetParError(0);
135 double par2 = f_momres->GetParameter(1);
136 double par2err = f_momres->GetParError(1);
137 ofsfit << eta <<
"," << par1 <<
"," << par1err <<
"," << par2 <<
"," << par2err << endl;
148 c1->Print(
"track_momres_vareta.eps");