Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:46:00

0001 {
0002 gStyle->SetNdivisions(5);
0003 gStyle->SetCanvasBorderMode(0); 
0004 gStyle->SetPadBorderMode(1);
0005 gStyle->SetOptTitle(1);
0006 gStyle->SetStatFont(42);
0007 gStyle->SetCanvasColor(10);
0008 gStyle->SetPadColor(0);
0009 gStyle->SetTitleFont(62,"xy");
0010 gStyle->SetLabelFont(62,"xy");
0011 gStyle->SetTitleFontSize(0.05);
0012 gStyle->SetTitleSize(0.047,"xy");
0013 gStyle->SetLabelSize(0.05,"xy");
0014 gStyle->SetHistFillStyle(1001);
0015 gStyle->SetHistFillColor(0);
0016 gStyle->SetHistLineStyle(1);
0017 gStyle->SetHistLineWidth(1);
0018 gStyle->SetHistLineColor(1);
0019 gStyle->SetTitleXOffset(1.1);
0020 gStyle->SetTitleYOffset(1.15);
0021 gStyle->SetOptStat(1110);
0022 gStyle->SetOptStat(kFALSE);
0023 gStyle->SetOptFit(0111);
0024 gStyle->SetStatH(0.1); 
0025 
0026 TCanvas *Canv = new TCanvas("c1","c1",129,17,926,703);
0027 Canv->SetBorderSize(2);
0028 Canv->SetFrameFillColor(0);
0029 // Canv->SetLogy(1);
0030 Canv->SetGrid(1,1);
0031 Canv->cd(); 
0032 
0033 TFile f0("../../singlemu_310607/Misalignment_scenarioIdeal_singlemu131.root");  
0034 TTree *MyTree=Tracks;
0035 
0036 TFile f2("Misalignment_SurveyLASCosmicsScenario_refitter_singlemu.root");
0037 TTree *MyTree2=Tracks;
0038 
0039 TFile f3("../../singlemu_310607/Misalignment10.root");
0040 TTree *MyTree3=Tracks;
0041 
0042 TFile f4("../../singlemu_310607/Misalignment100.root");
0043 TTree *MyTree4=Tracks;
0044 
0045 TFile f5("../../SurveyLAS/singlemu/Misalignment_SurveyLASOnlyScenario_refitter_singlemu_NOAPE.root");
0046 TTree *MyTree5=Tracks;
0047 
0048 
0049 int nbin=25;
0050 float binwidth=2.5/nbin;
0051 float binstart=0.,binstop=0.;
0052 char cutname[128];
0053 float errmean[nbin],mean[nbin],sigma[nbin],cost[nbin],entry[nbin],meanorig[nbin],etabin[nbin],erretabin[nbin],chiq[nbin],ndf[nbin],rms[nbin],errsigma[nbin];
0054 
0055 for (int i=0;i<nbin;i++){
0056   meanorig[i]=0.;
0057   mean[i]=0.;
0058   errmean[i]=0.;
0059   sigma[i]=0.;
0060   cost[i]=0.;
0061   entry[i]=0.;
0062   etabin[i]=0.;
0063   chiq[i]=0.;
0064   ndf[i]=0.;
0065   rms[i]=0.;
0066   errsigma[i]=0.;
0067 }
0068 
0069 
0070 //cout << "binwidth is " << binwidth << endl; 
0071 
0072 
0073 // //////////////////////////////////////////////////////////////////
0074 // d0 resolution
0075 /////////////////////////////////////////////////////////////////////
0076 
0077 
0078 for (int i=1;i<=nbin;i++){
0079   binstart=0.1*(i-1);
0080   binstop = 0.1*i;
0081   etabin[i-1]= (binstop-binstart)/2.+binstart;
0082   erretabin[i-1]=(binstop-binstart)/2.;
0083   cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0084   sprintf(cutname,"abs(eta)>=%f && abs(eta)<%f && eff==1 && TrackID==13",binstart, binstop);
0085   cout << "cutname is " << cutname <<endl;
0086   TH1F *resd0= new TH1F("d0","d0",500,-0.5,0.5);  
0087   MyTree->Project("d0","(respt/pt)",cutname);
0088   resd0->Fit("gaus");
0089   meanorig[i-1]=1.*resd0->GetMean();
0090   rms[i-1]=1.*resd0->GetRMS();
0091   cost[i-1]=gaus->GetParameter(0);
0092   mean[i-1]=100.*gaus->GetParameter(1);
0093   sigma[i-1]=1.*gaus->GetParameter(2);
0094   errsigma[i-1]=1.*gaus->GetParError(2);
0095   entry[i-1]=resd0->GetEntries();
0096   errmean[i-1]=100.*sigma[i-1]/(sqrt(entry[i-1]));
0097   chiq[i-1]=(gaus->GetChisquare()) /(gaus->GetNDF());
0098   cout << "mean is= " << mean[i-1] << " sigma is= " << sigma[i-1]/(sqrt(entry[i-1])) << " Entries= " << entry[i-1] << endl;
0099   delete resd0;
0100 }
0101 
0102 for (int i=0;i<nbin;i++){
0103   binstart=0.1*(i);
0104   binstop = 0.1*(i+1);
0105   cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0106   cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0107   cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0108 }
0109 
0110 hframe = new TH2F("hframe","SigmapT/pT_gaus",25,0.,2.5,100,-2.,2.0);
0111 hframe->SetTitle("Bias(p_{T})/p_{T} vs #eta, p_{T} = 100 GeV/c");
0112 hframe->SetXTitle("#eta");
0113 hframe->SetYTitle("Bias(p_{T})/p_{T}");
0114 hframe->Draw();
0115 gr = new TGraphErrors(25,etabin,mean,erretabin,errmean);
0116 gr->SetMarkerColor(2);
0117 gr->SetMarkerStyle(20);
0118 gr->Draw("P");
0119 Canv->Update();
0120 //Canv->SaveAs("SigmapT_gaus_scen0.eps");
0121 //Canv->WaitPrimitive();
0122 
0123 // //////////////////////////////////////////////////////////////////
0124 // d0 resolution scen1
0125 /////////////////////////////////////////////////////////////////////
0126 for (int i=1;i<=nbin;i++){
0127   binstart=0.1*(i-1);
0128   binstop = 0.1*i;
0129   etabin[i-1]= (binstop-binstart)/2.+binstart;
0130   erretabin[i-1]=(binstop-binstart)/2.;
0131   cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0132   sprintf(cutname,"abs(eta)>=%f && abs(eta)<%f && eff==1 && TrackID==13",binstart, binstop);
0133   cout << "cutname is " << cutname <<endl;
0134   TH1F *resd0= new TH1F("d0","d0",500,-0.5,0.5);  
0135   MyTree2->Project("d0","(respt/pt)",cutname);
0136   resd0->Fit("gaus");
0137   meanorig[i-1]=1.*resd0->GetMean();
0138   rms[i-1]=1.*resd0->GetRMS();
0139   cost[i-1]=gaus->GetParameter(0);
0140   mean[i-1]=100.*gaus->GetParameter(1);
0141   sigma[i-1]=1.*gaus->GetParameter(2);
0142   errsigma[i-1]=1.*gaus->GetParError(2);
0143   entry[i-1]=resd0->GetEntries();
0144   errmean[i-1]=100.*sigma[i-1]/(sqrt(entry[i-1]));
0145   chiq[i-1]=(gaus->GetChisquare()) /(gaus->GetNDF());
0146   cout << "mean is= " << mean[i-1] << " sigma is= " << sigma[i-1]/(sqrt(entry[i-1])) << " Entries= " << entry[i-1] << endl;
0147   delete resd0;
0148 }
0149 
0150 for (int i=0;i<nbin;i++){
0151   binstart=0.1*(i);
0152   binstop = 0.1*(i+1);
0153   cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0154   cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0155   cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0156 }
0157 
0158 hframe_scen1 = new TH2F("hframe","SigmapT/pT_gaus_scen1",25,0.,2.5,100,-2.,2.0);
0159 hframe_scen1->SetTitle("Bias(p_{T})/p_{T} vs #eta, p_{T} = 100 GeV/c");
0160 hframe_scen1->SetXTitle("#eta");
0161 hframe_scen1->SetYTitle("Bias(p_{T})/p_{T}");
0162 hframe_scen1->Draw();
0163 gr_scen1 = new TGraphErrors(25,etabin,mean,erretabin,errmean);
0164 gr_scen1->SetMarkerColor(3);
0165 gr_scen1->SetMarkerStyle(21);
0166 gr_scen1->Draw("P");
0167 Canv->Update();
0168 //Canv->SaveAs("SigmapT_gaus_scen1.eps");
0169 //Canv->WaitPrimitive();
0170 
0171 // // //////////////////////////////////////////////////////////////////
0172 // // d0 resolution scen2
0173 // /////////////////////////////////////////////////////////////////////
0174  for (int i=1;i<=nbin;i++){
0175    binstart=0.1*(i-1);
0176    binstop = 0.1*i;
0177    etabin[i-1]= (binstop-binstart)/2.+binstart;
0178    erretabin[i-1]=(binstop-binstart)/2.;
0179    cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0180    sprintf(cutname,"abs(eta)>=%f && abs(eta)<%f && eff==1 && TrackID==13",binstart, binstop);
0181    cout << "cutname is " << cutname <<endl;
0182    TH1F *resd0= new TH1F("d0","d0",500,-0.5,0.5);  
0183    MyTree3->Project("d0","(respt/pt)",cutname);
0184    resd0->Fit("gaus");
0185    meanorig[i-1]=1.*resd0->GetMean();
0186    rms[i-1]=1.*resd0->GetRMS();
0187    cost[i-1]=gaus->GetParameter(0);
0188    mean[i-1]=100.*gaus->GetParameter(1);
0189   
0190    sigma[i-1]=1*gaus->GetParameter(2);
0191    errsigma[i-1]=1*gaus->GetParError(2);
0192    entry[i-1]=resd0->GetEntries();
0193    errmean[i-1]=100.*sigma[i-1]/(sqrt(entry[i-1]));
0194    chiq[i-1]=(gaus->GetChisquare()) /(gaus->GetNDF());
0195    cout << "mean is= " << mean[i-1] << " sigma is= " << sigma[i-1]/(sqrt(entry[i-1])) << " Entries= " << entry[i-1] << endl;
0196    delete resd0;
0197  }
0198 
0199  for (int i=0;i<nbin;i++){
0200    binstart=0.1*(i);
0201    binstop = 0.1*(i+1);
0202    cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0203    cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0204    cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0205  }
0206 
0207  hframe_scen2 = new TH2F("hframe_scen2","SigmapT/pT_gaus_scen2",25,0.,2.5,100,-2.,2.0);
0208  hframe_scen2->SetTitle("Bias(p_{T})/p_{T} vs #eta, p_{T} = 100 GeV/c");
0209  hframe_scen2->SetXTitle("#eta");
0210  hframe_scen2->SetYTitle("Bias(p_{T})/p_{T}");
0211  hframe_scen2->Draw();
0212  gr_scen2 = new TGraphErrors(25,etabin,mean,erretabin,errmean);
0213  gr_scen2->SetMarkerColor(4);
0214  gr_scen2->SetMarkerStyle(22);
0215  gr_scen2->Draw("P");
0216  Canv->Update();
0217 // //Canv->SaveAs("SigmapT_gaus_scen2.eps");
0218 // //Canv->WaitPrimitive();
0219 
0220 // /////////////////////////////////7
0221 // // d0 resolution scen3
0222 // /////////////////////////////////////////////////////////////////////
0223  for (int i=1;i<=nbin;i++){
0224    binstart=0.1*(i-1);
0225    binstop = 0.1*i;
0226    etabin[i-1]= (binstop-binstart)/2.+binstart;
0227    erretabin[i-1]=(binstop-binstart)/2.;
0228    cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0229    sprintf(cutname,"abs(eta)>=%f && abs(eta)<%f && eff==1 && TrackID==13",binstart, binstop);
0230    cout << "cutname is " << cutname <<endl;
0231    TH1F *resd0= new TH1F("d0","d0",500,-0.5,0.5);  
0232    MyTree4->Project("d0","(respt/pt)",cutname);
0233    resd0->Fit("gaus");
0234    meanorig[i-1]=1.*resd0->GetMean();
0235    rms[i-1]=1.*resd0->GetRMS();
0236    cost[i-1]=gaus->GetParameter(0);
0237    mean[i-1]=100.*gaus->GetParameter(1);
0238   
0239    sigma[i-1]=1*gaus->GetParameter(2);
0240    errsigma[i-1]=1*gaus->GetParError(2);
0241    entry[i-1]=resd0->GetEntries();
0242    errmean[i-1]=100.*sigma[i-1]/(sqrt(entry[i-1]));
0243    chiq[i-1]=(gaus->GetChisquare()) /(gaus->GetNDF());
0244    cout << "mean is= " << mean[i-1] << " sigma is= " << sigma[i-1]/(sqrt(entry[i-1])) << " Entries= " << entry[i-1] << endl;
0245    delete resd0;
0246  }
0247 
0248  for (int i=0;i<nbin;i++){
0249    binstart=0.1*(i);
0250    binstop = 0.1*(i+1);
0251    cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0252    cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0253    cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0254  }
0255 
0256  hframe_scen3 = new TH2F("hframe_scen3","SigmapT/pT_gaus_scen3",25,0.,2.5,100,-2.,2.0);
0257  hframe_scen3->SetTitle("Bias(p_{T})/p_{T} vs #eta, p_{T} = 100 GeV/c");
0258  hframe_scen3->SetXTitle("#eta");
0259  hframe_scen3->SetYTitle("Bias(p_{T})/p_{T}");
0260  hframe_scen3->Draw();
0261  gr_scen3 = new TGraphErrors(25,etabin,mean,erretabin,errmean);
0262  gr_scen3->SetMarkerColor(5);
0263  gr_scen3->SetMarkerStyle(22);
0264  gr_scen3->Draw("P");
0265  Canv->Update();
0266 // //Canv->SaveAs("SigmapT_gaus_scen3.eps");
0267 // //Canv->WaitPrimitive();
0268 
0269 // /////////////////////////////////7
0270 // // d0 resolution scen1_noErr
0271 // /////////////////////////////////////////////////////////////////////
0272 //  for (int i=1;i<=nbin;i++){
0273 //    binstart=0.1*(i-1);
0274 //    binstop = 0.1*i;
0275 //    etabin[i-1]= (binstop-binstart)/2.+binstart;
0276 //    erretabin[i-1]=(binstop-binstart)/2.;
0277 //    cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0278 //    sprintf(cutname,"abs(eta)>=%f && abs(eta)<%f && eff==1 && TrackID==13",binstart, binstop);
0279 //    cout << "cutname is " << cutname <<endl;
0280 //    TH1F *resd0= new TH1F("d0","d0",500,-0.5,0.5);  
0281 //    MyTree5->Project("d0","(respt/pt)",cutname);
0282 //    resd0->Fit("gaus");
0283 //    meanorig[i-1]=1.*resd0->GetMean();
0284 //    rms[i-1]=1.*resd0->GetRMS();
0285 //    cost[i-1]=gaus->GetParameter(0);
0286 //    mean[i-1]=100.*gaus->GetParameter(1);
0287   
0288 //    sigma[i-1]=1*gaus->GetParameter(2);
0289 //    errsigma[i-1]=1*gaus->GetParError(2);
0290 //    entry[i-1]=resd0->GetEntries();
0291 //    errmean[i-1]=100.*sigma[i-1]/(sqrt(entry[i-1]));
0292 //    chiq[i-1]=(gaus->GetChisquare()) /(gaus->GetNDF());
0293 //    cout << "mean is= " << mean[i-1] << " sigma is= " << sigma[i-1]/(sqrt(entry[i-1])) << " Entries= " << entry[i-1] << endl;
0294 //    delete resd0;
0295 //  }
0296 
0297 //  for (int i=0;i<nbin;i++){
0298 //    binstart=0.1*(i);
0299 //    binstop = 0.1*(i+1);
0300 //    cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0301 //    cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0302 //    cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0303 //  }
0304 
0305 //  hframe_scen1_noErr = new TH2F("hframe_scen1_noErr","SigmapT/pT_gaus_scen1_noErr",25,0.,2.5,100,-2.,2.0);
0306 //  hframe_scen1_noErr->SetTitle("Bias(p_{T})/p_{T} vs #eta, p_{T} = 100 GeV/c");
0307 //  hframe_scen1_noErr->SetXTitle("#eta");
0308 //  hframe_scen1_noErr->SetYTitle("Bias(p_{T})/p_{T}");
0309 //  hframe_scen1_noErr->Draw();
0310 //  gr_scen1_noErr = new TGraphErrors(25,etabin,mean,erretabin,errmean);
0311 //  gr_scen1_noErr->SetMarkerColor(4);
0312 //  gr_scen1_noErr->SetMarkerStyle(22);
0313 //  gr_scen1_noErr->Draw("P");
0314 //  Canv->Update();
0315 // //Canv->SaveAs("SigmapT_gaus_scen1_noErr.eps");
0316 // //Canv->WaitPrimitive();
0317 
0318 gr->Draw("P");
0319 gr_scen1->Draw("Psame");
0320 gr_scen2->Draw("Psame");
0321 gr_scen3->Draw("Psame");
0322 //gr_scen1_noErr->Draw("Psame");
0323 
0324 
0325 
0326 TLegend *leg1 = new TLegend(0.1,0.76,0.47,0.9);                            
0327 leg1->SetTextAlign(32);
0328 leg1->SetTextColor(1);
0329 leg1->SetTextSize(0.038);
0330 
0331 leg1->AddEntry(gr,"perfect alignment", "P");
0332 leg1->AddEntry(gr_scen1,"SurveyLASCosmics alignment ", "P");
0333 leg1->AddEntry(gr_scen2,"10 pb-1 alignment ", "P");
0334 leg1->AddEntry(gr_scen3,"100 pb-1 alignment ", "P");
0335 // leg1->AddEntry(gr_scen1_noErr,"10 pb-1 alignment: NOAPE ", "P");
0336 
0337 
0338 leg1->Draw();
0339 
0340 Canv->Update();
0341 Canv->SaveAs("MeanpT_eta_gaus.eps");
0342 Canv->SaveAs("MeanpT_eta_gaus.gif");
0343 
0344 delete Canv;
0345 gROOT->Reset();
0346 gROOT->Clear();
0347 
0348 
0349 }
0350