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.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("mTIBres_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0018     TH1F *tobres[i]=(TH1F*)resfile->Get(Form("mTOBres_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0019     TH1F *tidres[i]=(TH1F*)resfile->Get(Form("mTIDres_%f-%f",i*8./NBINS,i*8./NBINS+8./NBINS));
0020     TH1F *tecres[i]=(TH1F*)resfile->Get(Form("mTECres_%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]->GetRMS();
0031     tibrmserror[i]=tibres[i]->GetRMSError();
0032     tobrms[i]=tobres[i]->GetRMS();
0033     tobrmserror[i]=tobres[i]->GetRMSError();
0034     tidrms[i]=tidres[i]->GetRMS();
0035     tidrmserror[i]=tidres[i]->GetRMSError();
0036     tecrms[i]=tecres[i]->GetRMS();
0037     tecrmserror[i]=tecres[i]->GetRMSError();
0038     allrms[i]=allres[i]->GetRMS();
0039     allrmserror[i]=allres[i]->GetRMSError();
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("mTIBsqrterrvsprojx");
0050 //   TProfile *toberr=(TProfile*)resfile->Get("mTOBsqrterrvsprojx");
0051 //   TProfile *tiderr=(TProfile*)resfile->Get("mTIDsqrterrvsprojx");
0052 //   TProfile *tecerr=(TProfile*)resfile->Get("mTECsqrterrvsprojx");
0053   TProfile *tiberr=(TProfile*)resfile->Get("mTIBtksqrterrvsprojx");
0054   TProfile *toberr=(TProfile*)resfile->Get("mTOBtksqrterrvsprojx");
0055   TProfile *tiderr=(TProfile*)resfile->Get("mTIDtksqrterrvsprojx");
0056   TProfile *tecerr=(TProfile*)resfile->Get("mTECtksqrterrvsprojx");
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.4);
0080   TIB->SetMinimum(0.);
0081   TIB->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0082   TIB->Draw("ap");
0083   //  TIB->Fit(newparam);
0084   TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0085   l->SetLineColor(3);
0086   l->Draw("same");
0087   //  errparamtib->SetLineColor(4);
0088   tiberr->SetMarkerColor(2);
0089   tiberr->SetLineColor(2);
0090   tiberr->Draw("same");
0091   //  tibtkerr->SetMarkerColor(4);
0092   // tibtkerr->SetLineColor(4);
0093   // tibtkerr->Draw("same");
0094 
0095   plot->cd(2);
0096   TOB->SetMaximum(0.4);
0097   TOB->SetMinimum(0.);
0098   TOB->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0099   TOB->Draw("ap");
0100   //  TOB->Fit(newparam);
0101   TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0102   l->SetLineColor(3);
0103   l->Draw("same");
0104   toberr->SetMarkerColor(2);
0105   toberr->SetLineColor(2);
0106   //  errparamtob->SetLineColor(4);
0107   toberr->Draw("same");
0108   //tobtkerr->SetMarkerColor(4);
0109   //tobtkerr->SetLineColor(4);
0110   //tobtkerr->Draw("same");
0111 
0112   plot->cd(3);
0113   TID->SetMaximum(0.4);
0114   TID->SetMinimum(0.);
0115   TID->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0116   TID->Draw("ap");
0117   //  TID->Fit(newparam);
0118    TLine *l=new TLine(0,1./sqrt(12),8,1./sqrt(12));
0119   l->SetLineColor(3);
0120   l->Draw("same");
0121   //errparamtib->SetLineColor(4);
0122   tiderr->SetMarkerColor(2);
0123   tiderr->SetLineColor(2);
0124   tiderr->Draw("same");
0125   //tidtkerr->SetMarkerColor(4);
0126   //tidtkerr->SetLineColor(4);
0127   //tidtkerr->Draw("same");
0128 
0129   plot->cd(4);
0130   TEC->SetMaximum(0.4);
0131   TEC->SetMinimum(0.);
0132   TEC->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0133   TEC->Draw("ap");
0134   //  TEC->Fit(newparam);
0135   TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0136   l->SetLineColor(3);
0137   l->Draw("same");
0138   tecerr->SetMarkerColor(2);
0139   tecerr->SetLineColor(2);
0140   tecerr->Draw("same");
0141   //tectkerr->SetMarkerColor(4);
0142   //tectkerr->SetLineColor(4);
0143   //tectkerr->Draw("same");
0144 
0145  TCanvas * plot2=new TCanvas("resolution2","resolution2");
0146  ALL->SetMaximum(0.4);
0147  ALL->SetMinimum(0.);
0148  ALL->GetHistogram()->GetXaxis()->SetRangeUser(0,4);
0149  ALL->Draw("ap");
0150  // ALL->Fit(newparam);
0151  TLine *l=new TLine(0,1./sqrt(12),4,1./sqrt(12));
0152  l->SetLineColor(3);
0153  l->Draw("same");
0154 }