Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:14

0001 // Double_t fit_func(Double_t *x, Double_t *par){
0002 //   Float_t xx =x[0];
0003 //   if(xx<par[0])f = par[1]*x+par[2];
0004 //   else f=par[3]*x+par[0]*(par[1]-par[3])+par[2];
0005 //   return f;
0006 // }
0007 {
0008   int NBINS=32;
0009     TFile *resfile=new TFile("resolution_2.5.root");
0010  // TFile *resfile=new TFile("resolution_good.root");
0011   float tibrms[NBINS],tobrms[NBINS],tidrms[NBINS],tecrms[NBINS];
0012   float tibsigma[NBINS],tobsigma[NBINS],tidsigma[NBINS],tecsigma[NBINS];
0013   float tibrmserror[NBINS],tobrmserror[NBINS],tidrmserror[NBINS],tecrmserror[NBINS];
0014   float tibsigmaerror[NBINS],tobsigmaerror[NBINS],tidsigmaerror[NBINS],tecsigmaerror[NBINS];
0015   TH1F *tibres[NBINS],*tobres[NBINS],*tidres[NBINS],*tecres[NBINS];
0016   TH1F *allres[NBINS];
0017   float allrms[NBINS],allrmserror[NBINS];
0018   float allsigma[NBINS],allsigmaerror[NBINS];
0019   for(int i=0;i<NBINS;i++){
0020     TH1F *tibres[i]=(TH1F*)resfile->Get(Form("TIBreswc_%d_strip",i));
0021     TH1F *tobres[i]=(TH1F*)resfile->Get(Form("TOBreswc_%d_strip",i));
0022     TH1F *tidres[i]=(TH1F*)resfile->Get(Form("TIDreswc_%d_strip",i));
0023     TH1F *tecres[i]=(TH1F*)resfile->Get(Form("TECreswc_%d_strip",i));
0024     allres[i]=(TH1F*)tibres[i]->Clone(Form("Allres_%d_strip",i));
0025     allres[i]->Add(tobres[i]);
0026     allres[i]->Add(tidres[i]);
0027     allres[i]->Add(tecres[i]);
0028 //     tibres[i]->Fit("gaus");
0029 //     tobres[i]->Fit("gaus");
0030 //     tidres[i]->Fit("gaus");
0031 //     tecres[i]->Fit("gaus");
0032 //     allres[i]->Fit("gaus");
0033 //     tibrms[i]=tibres[i]->GetFunction("gaus")->GetParameter(2);
0034 //     tibrmserror[i]=tibres[i]->GetFunction("gaus")->GetParError(2);
0035 //     tobrms[i]=tobres[i]->GetFunction("gaus")->GetParameter(2);
0036 //     tobrmserror[i]=tobres[i]->GetFunction("gaus")->GetParError(2);
0037 //     tidrms[i]=tidres[i]->GetFunction("gaus")->GetParameter(2);
0038 //     tidrmserror[i]=tidres[i]->GetFunction("gaus")->GetParError(2);
0039 //     tecrms[i]=tecres[i]->GetFunction("gaus")->GetParameter(2);
0040 //     tecrmserror[i]=tecres[i]->GetFunction("gaus")->GetParError(2);
0041 //     allrms[i]=allres[i]->GetFunction("gaus")->GetParameter(2);
0042 //     allrmserror[i]=allres[i]->GetFunction("gaus")->GetParError(2);
0043        TF1 *newparam_old=new TF1("error_param_old","[0]*x*exp(-x*[1])+[2]",0.,8);
0044        //         TF1 *newparam_old=new TF1("error_param_old","1/sqrt(12)",0.,8);
0045     newparam_old->SetParameter(0,-3.18e-01);
0046     newparam_old->SetParameter(1,6.67e-01);
0047     newparam_old->SetParameter(2,3.19e-01);
0048     //    float range=newparam_old->Eval(float(i)/4+0.125)*sqrt(30);
0049     float range=5;
0050     tibres[i]->GetXaxis()->SetRangeUser(-range,range);
0051     tidres[i]->GetXaxis()->SetRangeUser(-range,range);
0052     tobres[i]->GetXaxis()->SetRangeUser(-range,range);
0053     tecres[i]->GetXaxis()->SetRangeUser(-range,range);
0054     allres[i]->GetXaxis()->SetRangeUser(-range,range);
0055     tibrms[i]=tibres[i]->GetRMS();
0056     tibrmserror[i]=tibres[i]->GetRMSError();
0057     tobrms[i]=tobres[i]->GetRMS();
0058     tobrmserror[i]=tobres[i]->GetRMSError();
0059     tidrms[i]=tidres[i]->GetRMS();
0060     tidrmserror[i]=tidres[i]->GetRMSError();
0061     tecrms[i]=tecres[i]->GetRMS();
0062     tecrmserror[i]=tecres[i]->GetRMSError();
0063     allrms[i]=allres[i]->GetRMS();
0064     allrmserror[i]=allres[i]->GetRMSError();
0065   }
0066   float proj[NBINS],proje[NBINS];
0067   for (int i=0;i<NBINS;i++){proj[i]=i; proje[i]=0.;};
0068   TGraphErrors *TIB=new TGraphErrors(NBINS,proj,tibrms,proje,tibrmserror);
0069   TGraphErrors *TOB=new TGraphErrors(NBINS,proj,tobrms,proje,tobrmserror);
0070   TGraphErrors *TID=new TGraphErrors(NBINS,proj,tidrms,proje,tidrmserror);
0071   TGraphErrors *TEC=new TGraphErrors(NBINS,proj,tecrms,proje,tecrmserror);
0072   TGraphErrors *ALL=new TGraphErrors(NBINS,proj,allrms,proje,allrmserror);
0073 
0074   TF1 *errparamtib=new TF1("error_paramtib","((x-[0])*(x-[0])*([1]-[2])/([0]*[0])+[2])",0.01,4);
0075   errparamtib->SetParameter(0,38.07*0.032);
0076   errparamtib->SetParameter(1,0.3184);
0077   errparamtib->SetParameter(2,0.09828);
0078   TF1 *errparamtob=new TF1("error_paramtob","((x-[0])*(x-[0])*([1]-[2])/([0]*[0])+[2])",0.01,4);
0079   errparamtob->SetParameter(0,38.07*0.05);
0080   errparamtob->SetParameter(1,0.3184);
0081   errparamtob->SetParameter(2,0.09828);
0082 
0083   //  TF1 *newparam=new TF1("error_param","(((x-[0])*(x-[0])*([1]-[2])/([0]*[0]))*(([3]-x)/[3])+[2])*(((x-[0])*(x-[0])*([1]-[2])/([0]*[0]))*(([3]-x)/[3])+[2])",0,8); 
0084   TF1 *newparam=new TF1("error_param","[0]*x*exp(-x*[1])+[2]",0.,4);
0085   //TF1 *newparam=new TF1("error_param","[0]*exp(-0.5*((x-[3])/[1])**2)+[2]*x",0.0001,8);
0086   // TF1 *newparam=new TF1("error_param",fit_func,0.0001,8,4);
0087   newparam->SetParameter(0,-0.411);
0088   newparam->SetParameter(1,0.740);
0089   newparam->SetParameter(2,0.325);
0090   // newparam->SetParameter(3,0.25);
0091  
0092  TCanvas * plot=new TCanvas("resolution","resolution");
0093   plot->Divide(2,2);
0094   plot->cd(1);
0095   TIB->SetMaximum(4);
0096   TIB->SetMinimum(0.);
0097   TIB->GetHistogram()->GetXaxis()->SetTitle("Track projection");
0098   TIB->GetHistogram()->SetTitle("TIB");
0099   TIB->Draw("ap");
0100   //  TIB->Fit(newparam);
0101   TLine *l=new TLine(4,4/sqrt(12),32,32./sqrt(12));
0102   l->SetLineColor(3);
0103   l->SetLineWidth(2);
0104   l->Draw("same");
0105   errparamtib->SetLineColor(4);
0106   //errparamtib->Draw("same");
0107   // newparam->Draw("same");
0108 
0109   plot->cd(2);
0110   TOB->SetMaximum(4);
0111   TOB->SetMinimum(0.);
0112   TOB->GetHistogram()->GetXaxis()->SetTitle("Track projection");
0113   TOB->GetHistogram()->SetTitle("TOB");
0114   TOB->Draw("ap");
0115   //  TOB->Fit(newparam);
0116   TLine *l=new TLine(4,4./sqrt(12),32,32./sqrt(12));
0117   l->SetLineColor(3);
0118   l->SetLineWidth(2);
0119   l->Draw("same");
0120   errparamtob->SetLineColor(4);
0121   // errparamtob->Draw("same");
0122   // newparam->Draw("same");
0123 
0124   plot->cd(3);
0125   TID->SetMaximum(4);
0126   TID->SetMinimum(0.);
0127   TID->GetHistogram()->GetXaxis()->SetTitle("Track projection");
0128   TID->GetHistogram()->SetTitle("TID");
0129   TID->Draw("ap");
0130   //  TID->Fit(newparam);
0131   TLine *l=new TLine(4,4./sqrt(12),32,32./sqrt(12));
0132   l->SetLineColor(3);
0133   l->Draw("same");
0134   errparamtib->SetLineColor(4);
0135   //errparamtib->Draw("same");
0136   // newparam->Draw("same");
0137 
0138   plot->cd(4);
0139   TEC->SetMaximum(4);
0140   TEC->SetMinimum(0.);
0141   TEC->GetHistogram()->GetXaxis()->SetTitle("Track projection");
0142   TEC->GetHistogram()->SetTitle("TEC");
0143   TEC->Draw("ap");
0144   //  TEC->Fit(newparam);
0145   TLine *l=new TLine(4,4./sqrt(12),32,32./sqrt(12));
0146   l->SetLineColor(3);
0147   l->SetLineWidth(2);
0148   l->Draw("same");
0149   // newparam->Draw("same");
0150 
0151  TCanvas * plot2=new TCanvas("resolution2","resolution2");
0152  ALL->SetMaximum(4);
0153  ALL->SetMinimum(0.);
0154  ALL->Draw("ap");
0155  // ALL->Fit(newparam);
0156  TLine *l=new TLine(4,2./sqrt(12),32,16./sqrt(12));
0157  l->SetLineColor(3);
0158  l->Draw("same");
0159  // newparam_old->Draw("same");
0160 }