File indexing completed on 2024-04-06 11:59:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 {
0010 #include <vector>
0011 #include <tdrstyle.C>
0012
0013 gROOT->Reset();
0014 setTDRStyle();
0015
0016 int nLayers = 21;
0017 float RatioNoBad[nLayers+1];
0018 float errRatio[nLayers+1];
0019 float RatioAll[nLayers+1];
0020 float errRatioAll[nLayers+1];
0021 float Mod[nLayers+1];
0022 float ModErr[nLayers+1];
0023 int cont[nLayers+1];
0024
0025 TH1F * found = new TH1F("found","found",nLayers+1,0,nLayers+1);
0026 TH1F * all = new TH1F("all","all",nLayers+1,0,nLayers+1);
0027
0028 float SNoBad[nLayers+1],BNoBad[nLayers+1];
0029 float SAll[nLayers+1],BAll[nLayers+1];
0030
0031 SNoBad[0] = 0;
0032 BNoBad[0] = 6;
0033 SAll[0] = 0;
0034 BAll[0] = 6;
0035
0036 for (Long_t i=1; i< nLayers+1; ++i) {
0037 if (i==10) i++;
0038 TString file = TString("HitEff_V11_69912_layer") + i;
0039 TFile* f = TFile::Open(file+".root");
0040 f->cd("anEff");
0041 bool isTEC = false;
0042 if (i>13) isTEC = true;
0043 TString cut;
0044 if (isTEC) cut = TString("SiStripQualBad==0&&(Id<402674821||Id>470078964||(Id<470048885&Id>402674977))&&abs(TrajLocY)>2");
0045 else cut = TString("SiStripQualBad==0&&(Id<402674821||Id>470078964||(Id<470048885&Id>402674977))");
0046 traj->Draw("ModIsBad",cut,"goff");
0047
0048
0049
0050
0051
0052
0053
0054
0055 SNoBad[i] = htemp->GetBinContent(1);
0056 if (i==13) SNoBad[i] = htemp->GetBinContent(3);
0057 BNoBad[i] = htemp->GetBinContent(2);
0058 cout << "filling for layer " << i << " s = " << htemp->GetBinContent(1) << " b = " << htemp->GetBinContent(2) << endl;
0059 if ((SNoBad[i]+BNoBad[i]) > 5) {
0060 float ratio = (SNoBad[i]*1. / (SNoBad[i]+BNoBad[i])*1.);
0061 RatioNoBad[i] = ratio;
0062 float deno = (SNoBad[i] + BNoBad[i]) * (SNoBad[i] + BNoBad[i]) * (SNoBad[i] + BNoBad[i]);
0063 errRatio[i] = sqrt( (SNoBad[i]*BNoBad[i]) / deno*1.);
0064 found->SetBinContent(i,SNoBad[i]);
0065 all->SetBinContent(i,SNoBad[i]+BNoBad[i]);
0066 } else {
0067 RatioNoBad[i] = -1.0;
0068 errRatio[i] = 0.0;
0069 found->SetBinContent(i,0);
0070 all->SetBinContent(i,10);
0071 }
0072
0073 cout << i << " SNoBad " << SNoBad[i] << " BNoBad " << BNoBad[i] << " ratio " << ratio*100. << " +o- " << errRatio[i]*100. << endl;
0074 Mod[i] = i;
0075 ModErr[i] = 0.;
0076
0077 }
0078
0079 TCanvas *c7 =new TCanvas("c7"," test ",10,10,800,600);
0080 c7->SetFillColor(0);
0081 c7->SetGrid();
0082
0083 found->Sumw2();
0084 all->Sumw2();
0085
0086 gr = new TGraphAsymmErrors(nLayers+1);
0087 gr->BayesDivide(found,all);
0088
0089 for(int j = 0; j<nLayers+1; j++){
0090 gr->SetPointError(j, 0., 0., gr->GetErrorYlow(j),gr->GetErrorYhigh(j) );
0091 }
0092
0093 gr->GetXaxis()->SetLimits(0,nLayers);
0094 gr->SetMarkerColor(2);
0095 gr->SetMarkerSize(1.2);
0096 gr->SetLineColor(2);
0097 gr->SetLineWidth(4);
0098 gr->SetMarkerStyle(20);
0099 gr->SetMinimum(0.98);
0100 gr->SetMaximum(1.001);
0101 gr->GetYaxis()->SetTitle("Efficiency");
0102 for ( int j=1; j<nLayers+1; j++) {
0103 if (j==10) j++;
0104 TString label;
0105 if (j<5) {
0106 label = TString("TIB ")+j;
0107 } else if (j>4&&j<11) {
0108 label = TString("TOB ")+(j-4);
0109 } else if (j>10&&j<14) {
0110 label = TString("TID ")+(j-10);
0111 } else if (j>13) {
0112 label = TString("TEC ")+(j-13);
0113 }
0114 gr->GetXaxis()->SetBinLabel((j*100)/(nLayers)-2,label);
0115 }
0116
0117 gr->Draw("AP");
0118 gr->GetXaxis()->SetNdivisions(36);
0119
0120 TPaveText *pt = new TPaveText(0.3,0.3,0.5,0.4,"blNDC");
0121 pt->SetBorderSize(0);
0122 pt->SetFillColor(0);
0123 TText *text = pt->AddText("CMS 2008");
0124 pt->Draw("same");
0125
0126 c7->SaveAs("HitEffSummary69912QualGood_TECcut.png");
0127 c7->SaveAs("HitEffSummary69912QualGood_TECcut.eps");
0128 c7->SaveAs("HitEffSummary69912QualGood_TECcut.pdf");
0129 }