Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:30

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.root");
0010   // TFile *resfile=new TFile("resolution_good.root");
0011   float tibrms[NBINS],tobrms[NBINS],tidrms[NBINS],tecrms[NBINS];
0012   float tibrmserror[NBINS],tobrmserror[NBINS],tidrmserror[NBINS],tecrmserror[NBINS];
0013   TH1F *tibres[NBINS],*tobres[NBINS],*tidres[NBINS],*tecres[NBINS];
0014   TH1F *allres[NBINS];
0015   float allrms[NBINS],allrmserror[NBINS];
0016   for(int i=0;i<NBINS;i++){
0017     TH1F *tibres[i]=(TH1F*)resfile->Get(Form("mTIBresy_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0018     TH1F *tobres[i]=(TH1F*)resfile->Get(Form("mTOBresy_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0019     TH1F *tidres[i]=(TH1F*)resfile->Get(Form("mTIDresy_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0020     TH1F *tecres[i]=(TH1F*)resfile->Get(Form("mTECresy_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0021     allres[i]=(TH1F*)tibres[i]->Clone(Form("Allres_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0022     allres[i]->Add(tobres[i]);
0023     allres[i]->Add(tidres[i]);
0024     allres[i]->Add(tecres[i]);
0025     tibres[i]->Fit("gaus");
0026     tobres[i]->Fit("gaus");
0027     tidres[i]->Fit("gaus");
0028     tecres[i]->Fit("gaus");
0029     allres[i]->Fit("gaus");
0030     tibrms[i]=tibres[i]->GetFunction("gaus")->GetParameter(2);
0031     tibrmserror[i]=tibres[i]->GetFunction("gaus")->GetParError(2);
0032     tobrms[i]=tobres[i]->GetFunction("gaus")->GetParameter(2);
0033     tobrmserror[i]=tobres[i]->GetFunction("gaus")->GetParError(2);
0034     tidrms[i]=tidres[i]->GetFunction("gaus")->GetParameter(2);
0035     tidrmserror[i]=tidres[i]->GetFunction("gaus")->GetParError(2);
0036     tecrms[i]=tecres[i]->GetFunction("gaus")->GetParameter(2);
0037     tecrmserror[i]=tecres[i]->GetFunction("gaus")->GetParError(2);
0038     allrms[i]=allres[i]->GetFunction("gaus")->GetParameter(2);
0039     allrmserror[i]=allres[i]->GetFunction("gaus")->GetParError(2);
0040   }
0041   float proj[NBINS],proje[NBINS];
0042   for (int i=0;i<NBINS;i++){proj[i]=float(i)/4+0.125; proje[i]=0;};
0043   TGraphErrors *TIB=new TGraphErrors(NBINS,proj,tibrms,proje,tibrmserror);
0044   TGraphErrors *TOB=new TGraphErrors(NBINS,proj,tobrms,proje,tobrmserror);
0045   TGraphErrors *TID=new TGraphErrors(NBINS,proj,tidrms,proje,tidrmserror);
0046   TGraphErrors *TEC=new TGraphErrors(NBINS,proj,tecrms,proje,tecrmserror);
0047   TGraphErrors *ALL=new TGraphErrors(NBINS,proj,allrms,proje,allrmserror);
0048 
0049 //   TProfile *tiberr=(TProfile*)resfile->Get("mTIBsqrterrvsprojy");
0050 //   TProfile *toberr=(TProfile*)resfile->Get("mTOBsqrterrvsprojy");
0051 //   TProfile *tiderr=(TProfile*)resfile->Get("mTIDsqrterrvsprojy");
0052 //   TProfile *tecerr=(TProfile*)resfile->Get("mTECsqrterrvsprojy");
0053    TProfile *tiberr=(TProfile*)resfile->Get("mTIBtksqrterrvsprojy");
0054    TProfile *toberr=(TProfile*)resfile->Get("mTOBtksqrterrvsprojy");
0055    TProfile *tiderr=(TProfile*)resfile->Get("mTIDtksqrterrvsprojy");
0056    TProfile *tecerr=(TProfile*)resfile->Get("mTECtksqrterrvsprojy");
0057 
0058 //   TF1 *errparamtib=new TF1("error_paramtib","((x-[0])*(x-[0])*([1]-[2])/([0]*[0])+[2])",0.01,4);
0059 //   errparamtib->SetParameter(0,38.07*0.032);
0060 //   errparamtib->SetParameter(1,0.3184);
0061 //   errparamtib->SetParameter(2,0.09828);
0062 //   TF1 *errparamtob=new TF1("error_paramtob","((x-[0])*(x-[0])*([1]-[2])/([0]*[0])+[2])",0.01,4);
0063 //   errparamtob->SetParameter(0,38.07*0.05);
0064 //   errparamtob->SetParameter(1,0.3184);
0065 //   errparamtob->SetParameter(2,0.09828);
0066 
0067 //   //  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); 
0068 //   TF1 *newparam=new TF1("error_param","[0]*x*exp(-x*[1])+[2]",0.,8);
0069 //   //TF1 *newparam=new TF1("error_param","[0]*exp(-0.5*((x-[3])/[1])**2)+[2]*x",0.0001,8);
0070 //   // TF1 *newparam=new TF1("error_param",fit_func,0.0001,8,4);
0071 //   newparam->SetParameter(0,-0.25);
0072 //   newparam->SetParameter(1,1.5);
0073 //   newparam->SetParameter(2,0.3);
0074 //   // newparam->SetParameter(3,0.25);
0075  
0076  TCanvas * plot=new TCanvas("resolution","resolution");
0077   plot->Divide(2,2);
0078   plot->cd(1);
0079   TIB->SetMaximum(0.007);
0080   TIB->SetMinimum(0.);
0081   TIB->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0082   TIB->GetHistogram()->GetXaxis()->SetTitle("Track projection");
0083   TIB->GetHistogram()->SetTitle("TIB");
0084   TIB->Draw("ap");
0085   //  TIB->Fit(newparam);
0086   TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0087   l->SetLineColor(3);
0088   l->Draw("same");
0089   //  errparamtib->SetLineColor(4);
0090   tiberr->SetMarkerColor(2);
0091   tiberr->SetLineColor(2);
0092   tiberr->Draw("same");
0093   //  tibtkerr->SetMarkerColor(4);
0094   // tibtkerr->SetLineColor(4);
0095   // tibtkerr->Draw("same");
0096 
0097   plot->cd(2);
0098   TOB->SetMaximum(0.007);
0099   TOB->SetMinimum(0.);
0100   TOB->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0101   TOB->GetHistogram()->GetXaxis()->SetTitle("Track projection");
0102   TOB->GetHistogram()->SetTitle("TOB");
0103   TOB->Draw("ap");
0104   //  TOB->Fit(newparam);
0105   TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0106   l->SetLineColor(3);
0107   l->Draw("same");
0108   toberr->SetMarkerColor(2);
0109   toberr->SetLineColor(2);
0110   //  errparamtob->SetLineColor(4);
0111   toberr->Draw("same");
0112   //  tobtkerr->SetMarkerColor(4);
0113   // tobtkerr->SetLineColor(4);
0114   // tobtkerr->Draw("same");
0115 
0116   plot->cd(3);
0117   TID->SetMaximum(0.007);
0118   TID->SetMinimum(0.);
0119   TID->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0120   TID->GetHistogram()->GetXaxis()->SetTitle("Track projection");
0121   TID->GetHistogram()->SetTitle("TID");
0122   TID->Draw("ap");
0123   //  TID->Fit(newparam);
0124   TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0125   l->SetLineColor(3);
0126   l->Draw("same");
0127   //errparamtib->SetLineColor(4);
0128   tiderr->SetMarkerColor(2);
0129   tiderr->SetLineColor(2);
0130   tiderr->Draw("same");
0131   //  tidtkerr->SetMarkerColor(4);
0132   //  tidtkerr->SetLineColor(4);
0133   // tidtkerr->Draw("same");
0134 
0135   plot->cd(4);
0136   TEC->SetMaximum(0.007);
0137   TEC->SetMinimum(0.);
0138   TEC->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0139   TEC->GetHistogram()->GetXaxis()->SetTitle("Track projection");
0140   TEC->GetHistogram()->SetTitle("TEC");
0141   TEC->Draw("ap");
0142   //  TEC->Fit(newparam);
0143   TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0144   l->SetLineColor(3);
0145   l->Draw("same");
0146   tecerr->SetMarkerColor(2);
0147   tecerr->SetLineColor(2);
0148   tecerr->Draw("same");
0149   //  tectkerr->SetMarkerColor(4);
0150   //  tectkerr->SetLineColor(4);
0151   //  tectkerr->Draw("same");
0152 
0153  TCanvas * plot2=new TCanvas("resolution2","resolution2");
0154  ALL->SetMaximum(0.01);
0155  ALL->SetMinimum(0.);
0156  ALL->Draw("ap");
0157  // ALL->Fit(newparam);
0158  TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0159  l->SetLineColor(3);
0160  l->Draw("same");
0161 }