Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:15

0001 
0002 class Plots{
0003 
0004   public:
0005   Plots();
0006 
0007   void Legend(TString histoname1,TString histoname2,TString histoname3,TString histoname4,TString histoname5, TH1F *histo1, TH1F *histo2, TH1F *histo3, TH1F *histo4, TH1F *histo5);  
0008   void Save();
0009   
0010   float convert(float num);
0011 
0012 };
0013 
0014 void Plots::Plots()
0015 {
0016 
0017 gROOT->Reset();
0018 gROOT->Clear();
0019 
0020 gStyle->SetNdivisions(10);
0021 gStyle->SetCanvasBorderMode(0); 
0022 gStyle->SetPadBorderMode(1);
0023 gStyle->SetOptTitle(1);
0024 gStyle->SetStatFont(42);
0025 gStyle->SetCanvasColor(10);
0026 gStyle->SetPadColor(0);
0027 gStyle->SetTitleFont(62,"xy");
0028 gStyle->SetLabelFont(62,"xy");
0029 gStyle->SetTitleFontSize(0.05);
0030 gStyle->SetTitleSize(0.039,"xy");
0031 gStyle->SetLabelSize(0.046,"xy");
0032 // gStyle->SetTitleFillColor(0);
0033 gStyle->SetHistFillStyle(1001);
0034 gStyle->SetHistFillColor(0);
0035 gStyle->SetHistLineStyle(1);
0036 gStyle->SetHistLineWidth(2);
0037 gStyle->SetHistLineColor(2);
0038 gStyle->SetTitleXOffset(1.25);
0039 gStyle->SetTitleYOffset(1.3);
0040 gStyle->SetOptStat(1110);
0041 gStyle->SetOptStat(kFALSE);
0042 gStyle->SetOptFit(0111);
0043 gStyle->SetStatH(0.1); 
0044 
0045 TCanvas *c1 = new TCanvas("c1","c1",129,17,926,703);
0046 c1->SetBorderSize(2);
0047 c1->SetFrameFillColor(0);
0048 c1->SetLogy(0);
0049 c1->cd(); 
0050 
0051 TFile *f[5];
0052 TTree *MyTree[5];
0053 
0054 
0055 f[0]= new TFile("ValidationMisalignedTracker_singlemu100_merged.root");
0056 MyTree[0]=EffTracks;
0057 
0058 f[1]=new TFile("../../SurveyLAS/singlemu/Misalignment_SurveyLASOnlyScenario_refitter_singlemu.root");
0059 MyTree[1]=Tracks;
0060  
0061 f[2]=new TFile("Misalignment_SurveyLASOnlyScenario_refitter_zmumu_singlemuSurveyLASCosmics.root");
0062 MyTree[2]=Tracks;
0063  
0064 f[3]=new TFile("../../singlemu_310607/Misalignment10.root");
0065 MyTree[3]=Tracks;
0066  
0067 f[4]=new TFile("../../singlemu_310607/Misalignment100.root");
0068 MyTree[4]=Tracks;
0069 
0070 
0071 ////&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
0072 
0073 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
0074 /// EFFICIENCIES VS ETA ALIGNED
0075 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
0076 hframe = new TH2F("hframe","#Delta(z_{0})",100,-0.05,0.05,32,0.,0.17);
0077 hframe->SetXTitle("#Delta(z_{0}) [#mum]");
0078 hframe->SetYTitle("N. ev. /0.001");
0079 hframe->Draw();
0080 
0081 char histoname[128];
0082 char name[128];
0083 TH1F *Resz0[5];
0084 
0085 for(int i=0; i<5; i++){
0086   sprintf(name,"Resz0[%d]",i);
0087   Resz0[i] = new TH1F(name,name,100,-0.05,0.05);
0088   sprintf(histoname,"Resz0[%d]",i);
0089   MyTree[i]->Project(histoname,"resz0","eff==1 && TrackID==13");
0090 
0091   cout << "Entries " << Resz0[i]->GetEntries() <<endl;
0092   Resz0[i]->Scale(1/Resz0[i]->GetEntries());
0093   Resz0[i]->SetTitle("#Delta(z_{0})");    
0094   Resz0[i]->SetXTitle("#Delta(z_{0}) ");
0095   Resz0[i]->SetYTitle("arb. units");
0096   
0097   Resz0[i]->SetLineColor(i+2);
0098   Resz0[i]->SetLineStyle(i+1);
0099   Resz0[i]->SetLineWidth(i+2);
0100   if (i==0) Resz0[i]->Draw("same");
0101   else Resz0[i]->Draw("same");
0102   //  c1->WaitPrimitive();
0103   c1->Update();
0104 }
0105 
0106 Legend("Resz0[0]","Resz0[1]","Resz0[2]","Resz0[3]","Resz0[4]",Resz0[0],Resz0[1],Resz0[2],Resz0[3],Resz0[4]);
0107 
0108 c1->SaveAs("Residualz0_mu.eps");
0109 c1->SaveAs("Residualz0_mu.gif");
0110 gROOT->Reset();
0111 gROOT->Clear();
0112 
0113 delete c1;
0114 
0115 }
0116 
0117 void Plots::Legend(TString histoname1,TString histoname2,TString histoname3, TString histoname4, TString histoname5, TH1F *histo1, TH1F *histo2, TH1F *histo3, TH1F *histo4, TH1F *histo5)
0118 {
0119 
0120 TLegend *leg = new TLegend(0.31,0.74.,0.995,0.995);
0121 leg->SetTextAlign(32);
0122 leg->SetTextColor(1);
0123 leg->SetTextSize(0.033);
0124 leg->SetFillColor(0);
0125 
0126 char  label[128];
0127 // sprintf(label,"perfect alignment;      mean = %1.3f, RMS = %1.3f",convert(histo1->GetMean()),convert(histo1->GetRMS()));
0128 // leg->AddEntry(histoname1, label, "l");
0129 // sprintf(label,"SurveyLAS alignment; mean = %1.3f, RMS = %1.3f",convert(histo2->GetMean()),convert(histo2->GetRMS()));
0130 // leg->AddEntry(histoname2, label, "l");
0131 // sprintf(label,"SurveyLASCosmics alignment; mean = %1.3f, RMS = %1.3f",convert(histo3->GetMean()),convert(histo3->GetRMS()));
0132 // leg->AddEntry(histoname3, label, "l");
0133 // sprintf(label,"10 pb-1 alignment;  mean = %1.3f, RMS = %1.3f",convert(histo4->GetMean()),convert(histo4->GetRMS()));
0134 // leg->AddEntry(histoname4, label, "l");
0135 // sprintf(label,"100 pb-1 alignment;  mean = %1.3f, RMS = %1.3f",convert(histo5->GetMean()),convert(histo5->GetRMS()));
0136 // leg->AddEntry(histoname5, label, "l");
0137 
0138 
0139 
0140 sprintf(label,"perfect; mean=%1.4f, RMS=%1.4f",(histo1->GetMean()),histo1->GetRMS());
0141 leg->AddEntry(histoname1, label, "l");
0142 sprintf(label,"SurveyLAS; mean=%1.4f, RMS=%1.4f",(histo2->GetMean()),histo2->GetRMS());
0143 leg->AddEntry(histoname2, label, "l");
0144 sprintf(label,"SurveyLASCosmics; mean=%1.4f, RMS=%1.4f",(histo3->GetMean()),histo3->GetRMS());
0145 leg->AddEntry(histoname3, label, "l");
0146 sprintf(label,"10 pb^{-1};  mean=%1.4f, RMS=%1.4f",(histo4->GetMean()),histo4->GetRMS());
0147 leg->AddEntry(histoname4, label, "l");
0148 sprintf(label,"100 pb^{-1};  mean=%1.4f, RMS=%1.4f",(histo5->GetMean()),histo5->GetRMS());
0149 leg->AddEntry(histoname5, label, "l");
0150 
0151 leg->Draw();
0152 }
0153 
0154 float Plots::convert(float num){
0155   int mean1 = num;
0156   float res = num - mean1;
0157   int res2 = res*1000;
0158   float res3 = res2*0.001;
0159   float mean2 = mean1 + res3;
0160                                                                                                                   
0161   float res4 = res - res3;
0162   int res5 = res4*10000;
0163                                                                                                                   
0164   if(res5>5)
0165     mean2 = mean2 + 0.001;
0166                                                                                                                   
0167   return mean2;
0168 }