Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:55

0001 ////////////////////////////
0002 // Script to plot sensor efficiency layer by layer
0003 // The input files are the output from CalibTracker/SiStripHitEfficiency/src/HitRes.cc
0004 // Usage in root: root> .x plotHitEffSummaryQualBadCRAFT09.C
0005 // Original Author:  Keith Ulmer  University of Colorado 
0006 //                   keith.ulmer@colorado.edu
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], AllNoBad[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   AllNoBad[0] = 6;
0036   
0037   for (Long_t i=1; i< nLayers+1; ++i) {
0038     if (i==10) i++;
0039     TString file = TString("HitEff_V11_69912_layer") + i;
0040     TFile* f = TFile::Open(file+".root");
0041     f->cd("anEff");
0042     traj->Draw("ModIsBad","SiStripQualBad==0&(Id<402674821||Id>470078964||(Id<470048885&Id>402674977))","goff");
0043     //traj->Draw("ModIsBad","SiStripQualBad==0","goff");
0044     //exclude bad modules from TID 2: 402674821-402674977
0045     // and TEC 3: 470048885-470078964
0046     SNoBad[i] =  htemp->GetBinContent(1);
0047     if (i==13) SNoBad[i] = htemp->GetBinContent(3); //not sure why the entries are in bin 3 for layer 13?
0048     BNoBad[i] =  htemp->GetBinContent(2);
0049     cout << "filling for layer " << i << " s = " << htemp->GetBinContent(1) << " b = " << htemp->GetBinContent(2) << endl;
0050     if ((SNoBad[i]+BNoBad[i]) > 5) {
0051       AllNoBad[i] = (SNoBad[i]+BNoBad[i]);
0052       float ratio = (SNoBad[i]*1. / (SNoBad[i]+BNoBad[i])*1.);
0053       RatioNoBad[i] = ratio;
0054       float deno = (SNoBad[i] + BNoBad[i]) * (SNoBad[i] + BNoBad[i]) * (SNoBad[i] + BNoBad[i]);
0055       errRatio[i] = sqrt( (SNoBad[i]*BNoBad[i]) / deno*1.);
0056     } else {
0057       RatioNoBad[i] = -1.0;
0058       errRatio[i] = 0.0;
0059     }
0060     
0061     cout << i << " SNoBad " << SNoBad[i] << " BNoBad " << BNoBad[i] << " ratio "  << ratio*100. <<  " +o- " << errRatio[i]*100. << endl;
0062     Mod[i] = i;
0063     ModErr[i] = 0.;
0064     
0065     bool isTEC = false;
0066     if (i>13) isTEC = true;
0067     TString cut;
0068     if (isTEC) cut = TString("abs(TrajLocY)>2");
0069     else  cut = TString("");
0070     traj->Draw("ModIsBad>>htemp2",cut,"goff");
0071 
0072     //traj->Draw("ModIsBad>>htemp2","","goff");
0073     SAll[i] =  htemp2->GetBinContent(1);
0074     BAll[i] =  htemp2->GetBinContent(2);
0075     if ((SAll[i]+BAll[i]) > 5) {
0076       float ratio = (SAll[i]*1. / (SAll[i]+BAll[i])*1.);
0077       RatioAll[i] = ratio;
0078       float deno = (SAll[i] + BAll[i]) * (SAll[i] + BAll[i]) * (SAll[i] + BAll[i]);
0079       errRatioAll[i] = sqrt( (SAll[i]*BAll[i]) / deno*1.);
0080       found->SetBinContent(i,SAll[i]);
0081       all->SetBinContent(i,SAll[i]+BAll[i]);
0082     } else {
0083       RatioAll[i] = -1.0;
0084       errRatioAll[i] = 0.0;
0085       found->SetBinContent(i,0);
0086       all->SetBinContent(i,10);
0087     }
0088 
0089     cout << i << " SAll " << SAll[i] << " BAll " << BAll[i] << " ratio "  << ratio*100. <<  " +o- " << errRatioAll[i]*100. << endl;
0090 
0091   }
0092 
0093   TCanvas *c7 =new TCanvas("c7"," test ",10,10,800,600);
0094   c7->SetFillColor(0);
0095   c7->SetGrid();
0096 
0097   found->Sumw2();
0098   all->Sumw2();
0099 
0100   gr = new TGraphAsymmErrors(nLayers+1);
0101   gr->BayesDivide(found,all); 
0102 
0103   for(int j = 0; j<nLayers+1; j++){
0104     gr->SetPointError(j, 0., 0., gr->GetErrorYlow(j),gr->GetErrorYhigh(j) );
0105   }
0106   
0107   gr->GetXaxis()->SetLimits(0,nLayers);
0108   gr->SetMarkerColor(1);
0109   gr->SetMarkerSize(1.2);
0110   gr->SetLineColor(1);
0111   gr->SetLineWidth(4);
0112   gr->SetMarkerStyle(21);
0113   gr->SetMinimum(0.89);
0114   gr->SetMaximum(1.005);
0115   gr->GetYaxis()->SetTitle("Uncorrected efficiency");
0116   gr->GetXaxis()->SetTitle("");
0117 
0118 
0119   for ( int j=1; j<nLayers+1; j++) {
0120     if (j==10) j++;
0121     TString label;
0122     if (j<5) {
0123       label = TString("TIB ")+j;
0124     } else if (j>4&&j<11) {
0125       label = TString("TOB ")+(j-4);
0126     } else if (j>10&&j<14) {
0127       label = TString("TID ")+(j-10);
0128     } else if (j>13) {
0129       label = TString("TEC ")+(j-13);
0130     }
0131     gr->GetXaxis()->SetBinLabel((j*100)/(nLayers)-2,label);
0132   }
0133   gr->Draw("AP");
0134 
0135   TPaveText *pt = new TPaveText(0.3,0.35,0.5,0.45,"blNDC");
0136   pt->SetBorderSize(0);
0137   pt->SetFillColor(0);
0138   TText *text = pt->AddText("CMS 2008");
0139   pt->Draw("same");
0140   
0141 
0142   c7->SaveAs("HitEffSummary69912QualBad_TECcut.png");
0143   c7->SaveAs("HitEffSummary69912QualBad_TECcut.eps");
0144   c7->SaveAs("HitEffSummary69912QualBad_TECcut.pdf");
0145 }