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_new.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     cout<<Form("CPEtest/TIBres_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS)<<endl;
0021    tibres[i]=(TH1F*)resfile->Get(Form("CPEtest/TIBres_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0022    tobres[i]=(TH1F*)resfile->Get(Form("CPEtest/TOBres_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0023    tidres[i]=(TH1F*)resfile->Get(Form("CPEtest/TIDres_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0024    tecres[i]=(TH1F*)resfile->Get(Form("CPEtest/TECres_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0025     allres[i]=(TH1F*)tibres[i]->Clone(Form("Allres_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0026     allres[i]->Add(tobres[i]);
0027     allres[i]->Add(tidres[i]);
0028     allres[i]->Add(tecres[i]);
0029 //     tibres[i]->Fit("gaus");
0030 //     tobres[i]->Fit("gaus");
0031 //     tidres[i]->Fit("gaus");
0032 //     tecres[i]->Fit("gaus");
0033 //     allres[i]->Fit("gaus");
0034 //     tibrms[i]=tibres[i]->GetFunction("gaus")->GetParameter(2);
0035 //     tibrmserror[i]=tibres[i]->GetFunction("gaus")->GetParError(2);
0036 //     tobrms[i]=tobres[i]->GetFunction("gaus")->GetParameter(2);
0037 //     tobrmserror[i]=tobres[i]->GetFunction("gaus")->GetParError(2);
0038 //     tidrms[i]=tidres[i]->GetFunction("gaus")->GetParameter(2);
0039 //     tidrmserror[i]=tidres[i]->GetFunction("gaus")->GetParError(2);
0040 //     tecrms[i]=tecres[i]->GetFunction("gaus")->GetParameter(2);
0041 //     tecrmserror[i]=tecres[i]->GetFunction("gaus")->GetParError(2);
0042 //     allrms[i]=allres[i]->GetFunction("gaus")->GetParameter(2);
0043 //     allrmserror[i]=allres[i]->GetFunction("gaus")->GetParError(2);
0044     TF1 *param_old=new TF1("error_param_old","[0]*x*exp(-x*[1])+[2]",0.,4);
0045     TF1 *newparam_old=new TF1("error_newparam_old","1/sqrt(12)",0.,4);
0046     param_old->SetParameter(0,-3.39e-01);
0047     param_old->SetParameter(1,9.0e-01);
0048     param_old->SetParameter(2,2.79e-01);
0049     newparam_old->SetLineColor(kRed);
0050     float range=newparam_old->Eval(float(i)/4+0.125)*sqrt(30);
0051     tibres[i]->GetXaxis()->SetRangeUser(-range,range);
0052     tidres[i]->GetXaxis()->SetRangeUser(-range,range);
0053     tobres[i]->GetXaxis()->SetRangeUser(-range,range);
0054     tecres[i]->GetXaxis()->SetRangeUser(-range,range);
0055     allres[i]->GetXaxis()->SetRangeUser(-range,range);
0056     tibrms[i]=tibres[i]->GetRMS();
0057     tibrmserror[i]=tibres[i]->GetRMSError();
0058     tobrms[i]=tobres[i]->GetRMS();
0059     tobrmserror[i]=tobres[i]->GetRMSError();
0060     tidrms[i]=tidres[i]->GetRMS();
0061     tidrmserror[i]=tidres[i]->GetRMSError();
0062     tecrms[i]=tecres[i]->GetRMS();
0063     tecrmserror[i]=tecres[i]->GetRMSError();
0064     allrms[i]=allres[i]->GetRMS();
0065     allrmserror[i]=allres[i]->GetRMSError();
0066   }
0067   float proj[NBINS],proje[NBINS];
0068   for (int i=0;i<NBINS;i++){proj[i]=float(i)/4+0.125; proje[i]=0.;};
0069   TGraphErrors *TIB=new TGraphErrors(NBINS/2,proj,tibrms,proje,tibrmserror);
0070   TGraphErrors *TOB=new TGraphErrors(NBINS/2,proj,tobrms,proje,tobrmserror);
0071   TGraphErrors *TID=new TGraphErrors(NBINS/2,proj,tidrms,proje,tidrmserror);
0072   TGraphErrors *TEC=new TGraphErrors(NBINS/2,proj,tecrms,proje,tecrmserror);
0073   TGraphErrors *ALL=new TGraphErrors(NBINS/2,proj,allrms,proje,allrmserror);
0074 
0075   TF1 *errparamtib=new TF1("error_paramtib","((x-[0])*(x-[0])*([1]-[2])/([0]*[0])+[2])",0.01,4);
0076   errparamtib->SetParameter(0,38.07*0.032);
0077   errparamtib->SetParameter(1,0.3184);
0078   errparamtib->SetParameter(2,0.09828);
0079   TF1 *errparamtob=new TF1("error_paramtob","((x-[0])*(x-[0])*([1]-[2])/([0]*[0])+[2])",0.01,4);
0080   errparamtob->SetParameter(0,38.07*0.05);
0081   errparamtob->SetParameter(1,0.3184);
0082   errparamtob->SetParameter(2,0.09828);
0083 
0084   //  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); 
0085   TF1 *newparam=new TF1("error_param","[0]*x*exp(-x*[1])+[2]",0.,4);
0086   //TF1 *newparam=new TF1("error_param","[0]*exp(-0.5*((x-[3])/[1])**2)+[2]*x",0.0001,8);
0087   // TF1 *newparam=new TF1("error_param",fit_func,0.0001,8,4);
0088   newparam->SetParameter(0,-0.339);
0089   newparam->SetParameter(1,0.9);
0090   newparam->SetParameter(2,0.279);
0091   // newparam->SetParameter(3,0.25);
0092   gROOT->SetStyle("Plain");
0093   //  gStyle->SetOptTitle(1);
0094 
0095  TCanvas * plot=new TCanvas("resolution","resolution");
0096  plot->Divide(2,2,0.001,0.001);
0097   plot->cd(1);
0098   TIB->SetMaximum(0.4);
0099   TIB->SetMinimum(0.);
0100   TIB->GetHistogram()->GetXaxis()->SetTitle("W_{track}");
0101   TIB->GetHistogram()->GetYaxis()->SetTitle("Resolution");
0102   TIB->GetHistogram()->SetTitle("TIB");
0103   TIB->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0104   TIB->Draw("ap");
0105   //  TIB->Fit(newparam);
0106   TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0107   l->SetLineColor(3);
0108   l->SetLineWidth(2);
0109 //   l->Draw("same");
0110 //   errparamtib->SetLineColor(4);
0111 //   errparamtib->Draw("same");
0112 //   newparam->Draw("same");
0113 
0114   plot->cd(2);
0115   TOB->SetMaximum(0.4);
0116   TOB->SetMinimum(0.);
0117   TOB->GetHistogram()->GetXaxis()->SetTitle("W_{track}");
0118   TOB->GetHistogram()->GetYaxis()->SetTitle("Resolution");
0119   TOB->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0120   TOB->GetHistogram()->SetTitle("TOB");
0121   TOB->Draw("ap");
0122   //  TOB->Fit(newparam);
0123   TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0124   l->SetLineColor(3);
0125   l->SetLineWidth(2);
0126 //   l->Draw("same");
0127 //   errparamtob->SetLineColor(4);
0128 //   errparamtob->Draw("same");
0129 //   newparam->Draw("same");
0130 
0131   plot->cd(3);
0132   TID->SetMaximum(0.4);
0133   TID->SetMinimum(0.);
0134   TID->GetHistogram()->GetXaxis()->SetTitle("W_{track}");
0135   TID->GetHistogram()->GetYaxis()->SetTitle("Resolution");
0136   TID->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0137   TID->GetHistogram()->SetTitle("TID");
0138   TID->Draw("ap");
0139   //  TID->Fit(newparam);
0140   TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0141   l->SetLineColor(3);
0142 //   l->Draw("same");
0143 //   errparamtib->SetLineColor(4);
0144 //   errparamtib->Draw("same");
0145 //   newparam->Draw("same");
0146 
0147   plot->cd(4);
0148   TEC->SetMaximum(0.4);
0149   TEC->SetMinimum(0.);
0150   TEC->GetHistogram()->GetXaxis()->SetTitle("W_{track}");
0151   TEC->GetHistogram()->GetYaxis()->SetTitle("Resolution");
0152   TEC->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0153   TEC->GetHistogram()->SetTitle("TEC");
0154   TEC->Draw("ap");
0155   //  TEC->Fit(newparam);
0156   TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0157   l->SetLineColor(3);
0158   l->SetLineWidth(2);
0159 //   l->Draw("same");
0160 //   newparam->Draw("same");
0161 //    gStyle->SetOptTitle(0);
0162     gStyle->SetOptFit(1111);
0163 
0164  TCanvas * plot2=new TCanvas("resolution2","resolution2");
0165  ALL->SetMaximum(0.4);
0166  ALL->SetMinimum(0.);
0167  ALL->GetHistogram()->SetTitle("Hit resolution");
0168  ALL->GetHistogram()->SetMarkerStyle(20);
0169  ALL->GetHistogram()->GetXaxis()->SetTitle("Track projection (n. strip)");
0170  ALL->GetHistogram()->GetYaxis()->SetTitle("Resolution (units of pitch)");
0171  ALL->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0172  ALL->Draw("ap");
0173  ALL->Fit(newparam);
0174  TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0175  l->SetLineColor(3);
0176  // l->Draw("same");
0177   param_old->SetLineColor(kRed); 
0178   param_old->Draw("same");
0179 }