File indexing completed on 2024-04-06 12:27:12
0001 void SeedEfficiency(){
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 TFile *file = TFile::Open("h_mp100_test.root");
0015
0016
0017
0018
0019 TString hfolder = "h_mp100";
0020
0021
0022
0023
0024
0025
0026 double xmin = 0.0;
0027 double xmax = 500.0;
0028 double rebin = 5;
0029 double nbin = 2500/rebin ;
0030 double ept = 100.0;
0031 double fl = ept - 9.0*sqrt(ept);
0032 double fh = ept + 9.0*sqrt(ept);
0033
0034 TString suffix = ".jpg";
0035
0036
0037
0038
0039
0040 TString name1 = "AllMu__heta_NSeed";
0041 TString name2 = "AllMu__heta_Sim";
0042
0043 TString name3 = "AllMu__heta_NSta";
0044 TString name4 = "AllMu__heta_mu3";
0045 TString name5 = "AllMu__heta_staPt";
0046 TString name6 = "AllMu__heta_pt";
0047 TString name7 = "AllMu__heta_bestPt";
0048 TString name8 = "AllMu__heta_simPt1";
0049
0050 TString plot01 = "SeeddEff"+suffix;
0051 TString plot02 = "StdEff"+suffix;
0052 TString plot03 = "RecEff"+suffix;
0053
0054 TString plot04 = "StaPT_py_ME1"+suffix;
0055 TString plot05 = "StaPT_py_ME"+suffix;
0056 TString plot06 = "StaPT_py_MB"+suffix;
0057
0058 TString plot07 = "SeedPT_py_ME0"+suffix;
0059 TString plot08 = "SeedPT_py_ME2"+suffix;
0060 TString plot09 = "SeedPT_py_MB"+suffix;
0061
0062 TString plot10 = "BestSeedPT_py_ME0"+suffix;
0063 TString plot11 = "BestSeedPT_py_ME2"+suffix;
0064 TString plot12 = "BestSeedPT_py_MB"+suffix;
0065
0066 TString plot13 = "simPT_py_ME0"+suffix;
0067 TString plot14 = "simPT_py_ME2"+suffix;
0068 TString plot15 = "simPT_py_MB"+suffix;
0069
0070
0071
0072
0073
0074
0075 heta_nSeed = (TH2F *) file->Get("AllMuonSys/"+name1);
0076 heta_Sim = (TH1F *) file->Get("AllMuonSys/"+name2);
0077 heta_sta = (TH2F *) file->Get("AllMuonSys/"+name3);
0078 heta_rSeg = (TH2F *) file->Get("AllMuonSys/"+name4);
0079 heta_staPt = (TH2F *) file->Get("AllMuonSys/"+name5);
0080 heta_seedPt = (TH2F *) file->Get("AllMuonSys/"+name6);
0081 heta_bestSeedPt = (TH2F *) file->Get("AllMuonSys/"+name7);
0082 heta_simPt = (TH2F *) file->Get("AllMuonSys/"+name8);
0083
0084
0085
0086
0087
0088 gSystem->mkdir(hfolder);
0089 gSystem->cd(hfolder);
0090
0091
0092
0093
0094
0095
0096 heta_nSeed->ProjectionX("heta_nSeed_pjx",3,-1,"");
0097
0098
0099
0100
0101
0102 heta_sta ->ProjectionX("heta_sta_pjx",2,-1,"");
0103
0104
0105 heta_rSeg->ProjectionX("heta_rSeg_pjx",3,-1,"");
0106
0107
0108
0109
0110 float eta =-2.9;
0111 Int_t ini_bin = 1;
0112 Int_t last_bin = 59;
0113 const Int_t sz = last_bin - ini_bin + 1;
0114
0115 Float_t xa1[sz]={0.0};
0116 Float_t ya1[sz]={0.0};
0117 Float_t ey1[sz]={0.0};
0118 Float_t xa2[sz]={0.0};
0119 Float_t ya2[sz]={0.0};
0120 Float_t ey2[sz]={0.0};
0121 Float_t xa3[sz]={0.0};
0122 Float_t ya3[sz]={0.0};
0123 Float_t ey3[sz]={0.0};
0124
0125 Float_t ex[sz]={0.0};
0126
0127 for (int i = ini_bin; i<last_bin; i++) {
0128 xa1[i-ini_bin] = eta;
0129 xa2[i-ini_bin] = eta;
0130 xa3[i-ini_bin] = eta;
0131
0132 float nsim = heta_Sim->GetBinContent(i);
0133 float nseed = heta_nSeed_pjx->GetBinContent(i);
0134 float nsta = heta_sta_pjx->GetBinContent(i);
0135 float rseg = heta_rSeg_pjx->GetBinContent(i);
0136
0137
0138 float eff_seed = 0.0;
0139 float eff_sta = 0.0;
0140 float eff_rec = 0.0;
0141
0142 float err_seed = 0.0;
0143 float err_sta = 0.0;
0144 float err_rec = 0.0;
0145
0146 if ( nsim != 0 ) {
0147
0148 eff_seed = nseed/nsim;
0149 eff_sta = nsta/nsim;
0150 eff_rec = rseg/nsim;
0151
0152 if (eff_seed < 0.999 ) { err_seed = sqrt( eff_seed*(1-eff_seed)/nsim );
0153 } else { err_seed = 1.0/nsim ; }
0154
0155 if (eff_sta < 0.999 ) { err_sta = sqrt( eff_sta*(1-eff_sta)/nsim );
0156 } else { err_sta = 1.0/nsim ; }
0157
0158 if (eff_rec < 0.999 ) { err_rec = sqrt( eff_rec*(1-eff_rec)/nsim );
0159 } else { err_rec = 1.0/nsim ; }
0160
0161 }
0162
0163 ya1[i-ini_bin] = eff_seed;
0164 ya2[i-ini_bin] = eff_sta;
0165 ya3[i-ini_bin] = eff_rec;
0166
0167 ey1[i-ini_bin] = err_seed;
0168 ey2[i-ini_bin] = err_sta;
0169 ey3[i-ini_bin] = err_rec;
0170
0171 eta = eta + 0.1;
0172 }
0173
0174 gStyle->SetOptStat(kFALSE);
0175 gStyle->SetOptFit(0111);
0176 c1 = new TCanvas("c1","",200,8,1000,700);
0177 c1->SetFillColor(10);
0178 c1->SetGrid();
0179 c1->GetFrame()->SetFillColor(21);
0180 c1->GetFrame()->SetBorderSize(12);
0181 c1->cd();
0182
0183 eta_seedeff = new TGraphErrors(sz,xa1,ya1,ex,ey1);
0184 eta_seedeff->SetMaximum(1.02);
0185 eta_seedeff->SetMinimum(0.8);
0186 eta_seedeff->SetMarkerColor(4);
0187 eta_seedeff->SetMarkerStyle(21);
0188 eta_seedeff->SetTitle("seed efficiency");
0189 eta_seedeff->GetXaxis()->SetTitle(" #eta ");
0190 eta_seedeff->GetYaxis()->SetTitle(" seed efficiency ");
0191 eta_seedeff->Draw("ACP");
0192
0193 c1->Update();
0194 c1->Print(plot01);
0195
0196 gStyle->SetOptStat(kFALSE);
0197 gStyle->SetOptFit(0111);
0198 c2 = new TCanvas("c2","",200,8,1000,700);
0199 c2->SetFillColor(10);
0200 c2->SetGrid();
0201 c2->GetFrame()->SetFillColor(21);
0202 c2->GetFrame()->SetBorderSize(12);
0203 c2->cd();
0204
0205 eta_stdeff = new TGraphErrors(sz,xa2,ya2,ex,ey2);
0206 eta_stdeff->SetMaximum(1.05);
0207 eta_stdeff->SetMinimum(0.8);
0208 eta_stdeff->SetMarkerColor(4);
0209 eta_stdeff->SetMarkerStyle(21);
0210 eta_stdeff->SetTitle(" muon track efficiency");
0211 eta_stdeff->GetXaxis()->SetTitle(" #eta ");
0212 eta_stdeff->GetYaxis()->SetTitle(" sta muon efficiency ");
0213 eta_stdeff->Draw("ACP");
0214
0215 c2->Update();
0216 c2->Print(plot02);
0217
0218 gStyle->SetOptStat(kFALSE);
0219 gStyle->SetOptFit(0111);
0220 c3 = new TCanvas("c3","",200,8,1000,700);
0221 c3->SetFillColor(10);
0222 c3->SetGrid();
0223 c3->GetFrame()->SetFillColor(21);
0224 c3->GetFrame()->SetBorderSize(12);
0225 c3->cd();
0226
0227 eta_receff = new TGraphErrors(sz,xa3,ya3,ex,ey3);
0228 eta_receff->SetMaximum(1.05);
0229 eta_receff->SetMinimum(0.8);
0230 eta_receff->SetMarkerColor(4);
0231 eta_receff->SetMarkerStyle(21);
0232 eta_receff->SetTitle("rec seg efficiency");
0233 eta_receff->GetXaxis()->SetTitle(" #eta ");
0234 eta_receff->GetYaxis()->SetTitle(" rec seg efficiency ");
0235 eta_receff->Draw("ACP");
0236
0237 c3->Update();
0238 c3->Print(plot03);
0239
0240
0241
0242
0243 heta_staPt->ProjectionY("heta_staPt_pyp1",50,59,"");
0244 heta_staPt_pyp1->Rebin(rebin,"heta_staPt_pyp_r1");
0245 heta_staPt->ProjectionY("heta_staPt_pyn1",1,10,"");
0246 heta_staPt_pyn1->Rebin(rebin,"heta_staPt_pyn_r1");
0247
0248 TH1F *heta_staPt_py1 = new TH1F("heta_staPt_py1","", nbin, 0., 2500.);
0249 heta_staPt_py1->Add(heta_staPt_pyp_r1, heta_staPt_pyn_r1, 1., 1.);
0250
0251
0252 gStyle->SetOptStat("nimou");
0253 gStyle->SetOptFit(0111);
0254 TCanvas *c4 = new TCanvas("c4","");
0255 c4->SetFillColor(10);
0256 c4->SetFillColor(10);
0257
0258
0259 heta_staPt_py1->Fit("gaus","R","",fl,fh);
0260 heta_staPt_py1->SetTitle(" sta Pt for |#eta| > 2.1 ");
0261 heta_staPt_py1->SetAxisRange(xmin,xmax,"X");
0262 heta_staPt_py1->DrawCopy();
0263 heta_staPt_py1->GetXaxis()->SetTitle(" #eta ");
0264
0265 c4->Update();
0266
0267
0268 heta_simPt->ProjectionY("heta_simPt_pyp1",50,54,"");
0269 heta_simPt_pyp1->Rebin(rebin,"heta_simPt_pyp_r1");
0270 heta_simPt->ProjectionY("heta_simPt_pyn1",1,10,"");
0271 heta_simPt_pyn1->Rebin(rebin,"heta_simPt_pyn_r1");
0272
0273 TH1F *heta_simPt_py1 = new TH1F("heta_simPt_py1","", nbin, 0., 2500.);
0274 heta_simPt_py1->Add(heta_simPt_pyp_r1, heta_simPt_pyn_r1, 1., 1.);
0275 heta_simPt_py1->SetLineColor(kRed);
0276 heta_simPt_py1->SetLineStyle(kDashed);
0277 heta_simPt_py1->DrawCopy("same");
0278
0279 c4->Update();
0280 c4->Print(plot04);
0281
0282 heta_staPt->ProjectionY("heta_staPt_pyp2",40,49,"");
0283 heta_staPt_pyp2->Rebin(rebin,"heta_staPt_pyp_r2");
0284 heta_staPt->ProjectionY("heta_staPt_pyn2",11,20,"");
0285 heta_staPt_pyn2->Rebin(rebin,"heta_staPt_pyn_r2");
0286
0287 TH1F *heta_staPt_py2 = new TH1F("heta_staPt_py2","", nbin, 0., 2500.);
0288 heta_staPt_py2->Add(heta_staPt_pyp_r2, heta_staPt_pyn_r2, 1., 1.);
0289
0290 gStyle->SetOptStat("nimou");
0291 TCanvas *c5 = new TCanvas("c5","");
0292 c5->SetFillColor(10);
0293 c5->SetFillColor(10);
0294
0295
0296 heta_staPt_py2->Fit("gaus","R","",fl,fh);
0297 heta_staPt_py2->SetTitle(" sta Pt for 1.0 < |#eta| < 2.1 ");
0298 heta_staPt_py2->SetAxisRange(xmin,xmax,"X");
0299 heta_staPt_py2->DrawCopy();
0300 heta_staPt_py2->GetXaxis()->SetTitle(" #eta ");
0301 c5->Update();
0302
0303
0304 heta_simPt->ProjectionY("heta_simPt_pyp2",40,49,"");
0305 heta_simPt_pyp2->Rebin(rebin,"heta_simPt_pyp_r2");
0306 heta_simPt->ProjectionY("heta_simPt_pyn2",11,20,"");
0307 heta_simPt_pyn2->Rebin(rebin,"heta_simPt_pyn_r2");
0308
0309 TH1F *heta_simPt_py2 = new TH1F("heta_simPt_py2","", nbin, 0., 2500.);
0310 heta_simPt_py2->Add(heta_simPt_pyp_r2, heta_simPt_pyn_r2, 1., 1.);
0311 heta_simPt_py2->SetLineColor(kRed);
0312 heta_simPt_py2->SetLineStyle(kDashed);
0313 heta_simPt_py2->DrawCopy("same");
0314
0315 c5->Update();
0316 c5->Print(plot05);
0317
0318
0319 heta_staPt->ProjectionY("heta_staPt_py0",21,39,"");
0320 heta_staPt_py0->Rebin(rebin,"heta_staPt_py_r0");
0321
0322
0323 gStyle->SetOptStat("nimou");
0324 TCanvas *c6 = new TCanvas("c6","");
0325 c6->SetFillColor(10);
0326 c6->SetFillColor(10);
0327
0328 heta_staPt_py_r0->Fit("gaus","N0R","",fl,fh);
0329 pt1 = gaus->GetParameter(1);
0330 pt2 = gaus->GetParameter(2);
0331 fl1 = pt1 - 2.*pt2;
0332 fh1 = pt1 + 2.*pt2;
0333 heta_staPt_py_r0->Fit("gaus","R","",fl,fh);
0334 heta_staPt_py_r0->SetTitle(" sta Pt for |#eta| < 1.0 ");
0335 heta_staPt_py_r0->SetAxisRange(xmin,xmax,"X");
0336 heta_staPt_py_r0->DrawCopy();
0337 heta_staPt_py_r0->GetXaxis()->SetTitle(" #eta ");
0338 c6->Update();
0339
0340
0341 heta_simPt->ProjectionY("heta_simPt_py0",21,39,"");
0342 heta_simPt_py0->Rebin(rebin,"heta_simPt_py_r0");
0343 heta_simPt_py_r0->SetLineStyle(kDashed);
0344 heta_simPt_py_r0->SetLineColor(kRed);
0345 heta_simPt_py_r0->DrawCopy("same");
0346
0347 c6->Update();
0348 c6->Print(plot06);
0349
0350
0351
0352
0353 heta_seedPt->ProjectionY("heta_seedPt_pyp1",50,59,"");
0354 heta_seedPt_pyp1->Rebin(rebin,"heta_seedPt_pyp_r1");
0355 heta_seedPt->ProjectionY("heta_seedPt_pyn1",1,10,"");
0356 heta_seedPt_pyn1->Rebin(rebin,"heta_seedPt_pyn_r1");
0357
0358 TH1F *heta_seedPt_py1 = new TH1F("heta_seedPt_py1","", nbin, 0., 2500.);
0359 heta_seedPt_py1->Add(heta_seedPt_pyp_r1, heta_seedPt_pyn_r1, 1., 1.);
0360
0361 gStyle->SetOptStat("nimou");
0362 TCanvas *c7 = new TCanvas("c7","");
0363 c7->SetFillColor(10);
0364 c7->SetFillColor(10);
0365
0366
0367 heta_seedPt_py1->Fit("gaus","R","",fl,fh);
0368 heta_seedPt_py1->SetTitle(" seed Pt for |#eta| > 2.1 ");
0369 heta_seedPt_py1->SetAxisRange(xmin,xmax,"X");
0370 heta_seedPt_py1->DrawCopy();
0371 heta_seedPt_py1->GetXaxis()->SetTitle(" #eta ");
0372
0373 c7->Update();
0374 c7->Print(plot07);
0375
0376
0377 heta_seedPt->ProjectionY("heta_seedPt_pyp2",40,49,"");
0378 heta_seedPt_pyp2->Rebin(rebin,"heta_seedPt_pyp_r2");
0379 heta_seedPt->ProjectionY("heta_seedPt_pyn2",11,20,"");
0380 heta_seedPt_pyn2->Rebin(rebin,"heta_seedPt_pyn_r2");
0381
0382 TH1F *heta_seedPt_py2 = new TH1F("heta_seedPt_py2","", nbin, 0., 2500.);
0383 heta_seedPt_py2->Add(heta_seedPt_pyp_r2, heta_seedPt_pyn_r2, 1., 1.);
0384
0385
0386 gStyle->SetOptStat("nimou");
0387 TCanvas *c8 = new TCanvas("c8","");
0388 c8->SetFillColor(10);
0389 c8->SetFillColor(10);
0390
0391
0392 heta_seedPt_py2->Fit("gaus","R","",fl,fh);
0393 heta_seedPt_py2->SetTitle(" seed Pt for 1.0 < |#eta| < 2.1 ");
0394 heta_seedPt_py2->SetAxisRange(xmin,xmax,"X");
0395 heta_seedPt_py2->DrawCopy();
0396 heta_seedPt_py2->GetXaxis()->SetTitle(" #eta ");
0397
0398 c8->Update();
0399 c8->Print(plot08);
0400
0401
0402
0403 heta_seedPt->ProjectionY("heta_seedPt_py0",21,39,"");
0404 heta_seedPt_py0->Rebin(rebin,"heta_seedPt_py_r0");
0405
0406
0407 gStyle->SetOptStat("nimou");
0408 TCanvas *c9 = new TCanvas("c9","");
0409 c9->SetFillColor(10);
0410 c9->SetFillColor(10);
0411
0412 heta_seedPt_py_r0->Fit("gaus","R","",fl,fh);
0413 heta_seedPt_py_r0->SetTitle(" seed Pt for |#eta| < 1.0 ");
0414 heta_seedPt_py_r0->SetAxisRange(xmin,xmax,"X");
0415 heta_seedPt_py_r0->DrawCopy();
0416 heta_seedPt_py_r0->GetXaxis()->SetTitle(" #eta ");
0417
0418 c9->Update();
0419 c9->Print(plot09);
0420
0421
0422
0423
0424 heta_bestSeedPt->ProjectionY("heta_bestSeedPt_pyp1",50,59,"");
0425 heta_bestSeedPt_pyp1->Rebin(rebin,"heta_bestSeedPt_pyp_r1");
0426 heta_bestSeedPt->ProjectionY("heta_bestSeedPt_pyn1",1,10,"");
0427 heta_bestSeedPt_pyn1->Rebin(rebin,"heta_bestSeedPt_pyn_r1");
0428
0429 TH1F *heta_bestSeedPt_py1 = new TH1F("heta_bestSeedPt_py1","", nbin*2, -2500., 2500.);
0430 heta_bestSeedPt_py1->Add(heta_bestSeedPt_pyp_r1, heta_bestSeedPt_pyn_r1, 1., 1.);
0431
0432 gStyle->SetOptStat("nimou");
0433 TCanvas *c7 = new TCanvas("c10","");
0434 c10->SetFillColor(10);
0435 c10->SetFillColor(10);
0436
0437
0438 heta_bestSeedPt_py1->SetTitle(" best seed Pt for |#eta| > 2.1 ");
0439 heta_bestSeedPt_py1->SetAxisRange(-1.*xmax,xmax,"X");
0440 heta_bestSeedPt_py1->DrawCopy();
0441 heta_bestSeedPt_py1->GetXaxis()->SetTitle(" #eta ");
0442 c10->Update();
0443
0444
0445 heta_simPt_py1->SetLineColor(kRed);
0446 heta_simPt_py1->SetLineStyle(kDashed);
0447 heta_simPt_py1->DrawCopy("same");
0448
0449 c10->Update();
0450 c10->Print(plot10);
0451
0452
0453 heta_bestSeedPt->ProjectionY("heta_bestSeedPt_pyp2",40,49,"");
0454 heta_bestSeedPt_pyp2->Rebin(rebin,"heta_bestSeedPt_pyp_r2");
0455 heta_bestSeedPt->ProjectionY("heta_bestSeedPt_pyn2",11,20,"");
0456 heta_bestSeedPt_pyn2->Rebin(rebin,"heta_bestSeedPt_pyn_r2");
0457
0458 TH1F *heta_bestSeedPt_py2 = new TH1F("heta_bestSeedPt_py2","", nbin*2, -2500., 2500.);
0459 heta_bestSeedPt_py2->Add(heta_bestSeedPt_pyp_r2, heta_bestSeedPt_pyn_r2, 1., 1.);
0460
0461 gStyle->SetOptStat("nimou");
0462 TCanvas *c8 = new TCanvas("c11","");
0463 c11->SetFillColor(10);
0464 c11->SetFillColor(10);
0465
0466
0467 heta_bestSeedPt_py2->SetTitle(" best seed Pt for 1.0 < |#eta| < 2.1 ");
0468 heta_bestSeedPt_py2->SetAxisRange(-1.*xmax,xmax,"X");
0469 heta_bestSeedPt_py2->DrawCopy();
0470 heta_bestSeedPt_py2->GetXaxis()->SetTitle(" #eta ");
0471 c11->Update();
0472
0473
0474 heta_simPt_py2->SetLineColor(kRed);
0475 heta_simPt_py2->SetLineStyle(kDashed);
0476 heta_simPt_py2->DrawCopy("same");
0477
0478 c11->Update();
0479 c11->Print(plot11);
0480
0481
0482
0483 heta_bestSeedPt->ProjectionY("heta_bestSeedPt_py0",21,39,"");
0484 heta_bestSeedPt_py0->Rebin(rebin,"heta_bestSeedPt_py_r0");
0485
0486 gStyle->SetOptStat("nimou");
0487 TCanvas *c9 = new TCanvas("c12","");
0488 c12->SetFillColor(10);
0489 c12->SetFillColor(10);
0490
0491 heta_bestSeedPt_py_r0->SetTitle(" best seed Pt for |#eta| < 1.0 ");
0492 heta_bestSeedPt_py_r0->SetAxisRange(-1.*xmax ,xmax,"X");
0493 heta_bestSeedPt_py_r0->DrawCopy();
0494 heta_bestSeedPt_py_r0->GetXaxis()->SetTitle(" #eta ");
0495 c12->Update();
0496
0497
0498 heta_simPt_py_r0->SetLineColor(kRed);
0499 heta_simPt_py_r0->SetLineStyle(kDashed);
0500 heta_simPt_py_r0->DrawCopy("same");
0501
0502 c12->Update();
0503 c12->Print(plot12);
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513
0514
0515
0516
0517
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543
0544
0545
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575 gSystem->cd("../");
0576 file->Close();
0577
0578
0579
0580 }