File indexing completed on 2025-08-03 08:13:09
0001 #include <TF1.h>
0002 #include <TMath.h>
0003 #include <TFile.h>
0004 #include <TCanvas.h>
0005 #include <TH1.h>
0006 #include <TGraph.h>
0007 #include <TLegend.h>
0008 #include <TStyle.h>
0009 #include <TROOT.h>
0010 #include <TLatex.h>
0011
0012 Double_t CBcalc(Double_t *xx, Double_t *par)
0013 {
0014 double f;
0015 double x = xx[0];
0016
0017
0018 double alpha = par[0];
0019 double n = par[1];
0020 double x_mean = par[2];
0021 double sigma = par[3];
0022 double N = par[4];
0023
0024
0025 double A = pow( (n/TMath::Abs(alpha)),n) * exp(-pow(alpha,2)/2.0);
0026 double B = n/TMath::Abs(alpha) - TMath::Abs(alpha);
0027
0028
0029 if( (x-x_mean)/sigma > -alpha)
0030 {
0031 f = N * exp( -pow(x-x_mean,2) / (2.0*pow(sigma,2)));
0032 }
0033 else
0034 {
0035 f = N * A * pow(B - (x-x_mean)/sigma, -n);
0036 }
0037
0038 double Nexp = par[5];
0039 double slope = par[6];
0040
0041 TF1 *fexp = new TF1("fexp","[0]*exp([1]*x)",7,11);
0042 fexp->SetParameter(0,Nexp);
0043 fexp->SetParameter(1,slope);
0044
0045 f = f + fexp->Eval(x);
0046 return f;
0047 }
0048
0049 Double_t Upscalc(Double_t *xx, Double_t *par)
0050 {
0051 double x = xx[0];
0052
0053
0054 double alpha1s = par[0];
0055 double n1s = par[1];
0056 double sigma1s = par[2];
0057 double m1s = par[3];
0058 double m2s = par[4];
0059 double m3s = par[5];
0060 double N1s = par[6];
0061 double N2s = par[7];
0062 double N3s = par[8];
0063 double Nexp = par[9];
0064 double slope = par[10];
0065
0066
0067
0068 TF1 *f1 = new TF1("f1",CBcalc,7,11,5);
0069 f1->SetParameter(0,alpha1s);
0070 f1->SetParameter(1,n1s);
0071 f1->SetParameter(2,m1s);
0072 f1->SetParameter(3,sigma1s);
0073 f1->SetParameter(4,N1s);
0074
0075 TF1 *f2 = new TF1("f2",CBcalc,7,11,5);
0076 f2->SetParameter(0,alpha1s);
0077 f2->SetParameter(1,n1s);
0078 f2->SetParameter(2,m2s);
0079 f2->SetParameter(3,sigma1s);
0080 f2->SetParameter(4,N2s);
0081
0082 TF1 *f3 = new TF1("f3",CBcalc,7,11,5);
0083 f3->SetParameter(0,alpha1s);
0084 f3->SetParameter(1,n1s);
0085 f3->SetParameter(2,m3s);
0086 f3->SetParameter(3,sigma1s);
0087 f3->SetParameter(4,N3s);
0088
0089 TF1 *fexp = new TF1("fexp","[0]*exp([1]*x)",7,11);
0090 fexp->SetParameter(0,Nexp);
0091 fexp->SetParameter(1,slope);
0092
0093
0094
0095 double mass = f1->Eval(x) + f2->Eval(x) + f3->Eval(x) + fexp->Eval(x);
0096
0097 return mass;
0098 }
0099
0100
0101 void CBfitter_1state()
0102 {
0103 gROOT->SetStyle("Plain");
0104 gStyle->SetOptStat(0);
0105 gStyle->SetOptFit(0);
0106 gStyle->SetOptTitle(0);
0107
0108 TFile *file1S, *file2S, *file3S;
0109 TH1 *recomass1S, *recomass2S, *recomass3S;
0110
0111 bool draw_gauss = false;
0112
0113
0114 bool pp = false;
0115 bool pAu = false;
0116 bool AuAu_20pc = false;
0117 bool AuAu_10pc = true;
0118
0119
0120
0121 file1S = new TFile("root_files/ntp_quarkonium_out.root");
0122
0123 if(!file1S)
0124 {
0125 cout << "Failed to open file " << endl;
0126 exit(1);
0127 }
0128
0129 recomass1S = (TH1 *)file1S->Get("recomass0");
0130
0131 TH1 *recomass = (TH1*)recomass1S->Clone("recomass1");
0132 if(!recomass)
0133 {
0134 cout << "Failed to get recomass histogram " << endl;
0135 exit(1);
0136 }
0137
0138 recomass->GetXaxis()->SetTitle("invariant mass (GeV/c^{2})");
0139 recomass->Sumw2();
0140
0141 int nrebin = 1;
0142
0143 recomass->Rebin(nrebin);
0144
0145 TCanvas *cups = new TCanvas("cups","cups",5,5,800,800);
0146 recomass->SetTitle("Y(1S,2S,3S) #rightarrow e^{+}e^{-}");
0147 recomass->SetMarkerStyle(20);
0148 recomass->SetMarkerSize(1);
0149 recomass->SetLineStyle(kSolid);
0150 recomass->SetLineWidth(2);
0151
0152 recomass->DrawCopy("p");
0153
0154
0155 TF1 *f1S = new TF1("f1S",CBcalc,7,11,7);
0156 f1S->SetParameter(0, 1.0);
0157 f1S->SetParameter(1, 1.0);
0158 f1S->SetParameter(2, 9.46);
0159 f1S->SetParameter(3, 0.08);
0160 f1S->SetParameter(4, 2000.0);
0161
0162 f1S->SetParameter(5,3.5);
0163 f1S->SetParameter(6,0.05);
0164
0165 f1S->SetParNames("alpha1S","n1S","m1S","sigma1S","N1S");
0166 f1S->SetLineColor(kBlue);
0167 f1S->SetLineWidth(3);
0168 f1S->SetLineStyle(kDashed);
0169
0170 recomass->Fit(f1S);
0171 f1S->Draw("same");
0172 cout << "f1S pars " << f1S->GetParameter(3) << " " << f1S->GetParError(3) << endl;
0173
0174 char resstr[500];
0175 sprintf(resstr,"#sigma_{1S} = %.1f #pm %.1f MeV", f1S->GetParameter(3)*1000, f1S->GetParError(3)*1000);
0176 TLatex *res = new TLatex(0.13,0.55,resstr);
0177 res->SetNDC();
0178 res->SetTextSize(0.05);
0179 res->Draw();
0180
0181
0182 double binw = recomass->GetBinWidth(1);
0183 double renorm = 1.0/binw;
0184 cout << "renorm = " << renorm << endl;
0185
0186 cout << "Area of f1S is " << renorm * f1S->Integral(7,11) << endl;
0187
0188
0189
0190 TF1 *fgauss = new TF1("fgauss","gaus(0)",7,11);
0191 fgauss->SetParameter(0, f1S->GetParameter(4));
0192 fgauss->SetParameter(1, f1S->GetParameter(2));
0193 fgauss->SetParameter(2, f1S->GetParameter(3));
0194 fgauss->SetLineColor(kRed);
0195 if(draw_gauss) fgauss->Draw("same");
0196
0197
0198 double area_fgauss = fgauss->Integral(7,11) * renorm;
0199 double area_f1S = f1S->Integral(7,11) * renorm;
0200 double fraction = area_fgauss / area_f1S;
0201
0202
0203 cout << "Parameters of fgauss = " << fgauss->GetParameter(0) << " " << fgauss->GetParameter(1) << " " << fgauss->GetParameter(2) << " Area of fgauss is " << renorm * fgauss->Integral(7,11) << " fraction in fgauss " << area_fgauss / area_f1S << endl;
0204
0205 char labfrac[500];
0206 sprintf(labfrac, "Gauss fraction %.2f", fraction);
0207 TLatex *lab = new TLatex(0.13,0.75,labfrac);
0208 lab->SetNDC();
0209 lab->SetTextSize(0.05);
0210 if(draw_gauss) lab->Draw();
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332 }