Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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