Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 {
0002 gStyle->SetNdivisions(5);
0003 gStyle->SetCanvasBorderMode(0); 
0004 gStyle->SetPadBorderMode(1);
0005 gStyle->SetOptTitle(1);
0006 gStyle->SetStatFont(42);
0007 gStyle->SetCanvasColor(10);
0008 gStyle->SetPadColor(0);
0009 gStyle->SetTitleFont(62,"xy");
0010 gStyle->SetLabelFont(62,"xy");
0011 gStyle->SetTitleFontSize(0.05);
0012 gStyle->SetTitleSize(0.043,"xy");
0013 gStyle->SetLabelSize(0.05,"xy");
0014 gStyle->SetHistFillStyle(1001);
0015 gStyle->SetHistFillColor(0);
0016 gStyle->SetHistLineStyle(1);
0017 gStyle->SetHistLineWidth(1);
0018 gStyle->SetHistLineColor(1);
0019 gStyle->SetTitleXOffset(1.1);
0020 gStyle->SetTitleYOffset(1.15);
0021 gStyle->SetOptStat(1110);
0022 gStyle->SetOptStat(kFALSE);
0023 gStyle->SetOptFit(0111);
0024 gStyle->SetStatH(0.1); 
0025 
0026 TCanvas *Canv = new TCanvas("c1","c1",129,17,926,703);
0027 Canv->SetBorderSize(2);
0028 Canv->SetFrameFillColor(0);
0029 //Canv->SetLogy(1);
0030 Canv->SetGrid(1,1);
0031 Canv->cd(); 
0032 
0033 TFile f0("../../Z/MisalignmentIdeal.root");  
0034 TTree *MyTree=Tracks;
0035 
0036 TFile f1("Misalignment_SurveyLASOnlyScenario_refitter_zmumu_allmuSurveyLASCosmics.root");
0037 TTree *MyTree2=Tracks;
0038 
0039 TFile f2("../../Z/Misalignment10.root");
0040 TTree *MyTree3=Tracks;
0041 
0042 TFile f3("../../Z/Misalignment100.root");
0043 TTree *MyTree4=Tracks;
0044 
0045 
0046 
0047 int nbin=15;
0048 float binwidth=20./nbin;
0049 float binstart=0.,binstop=0.,binbias=7.;
0050 char cutname[128];
0051 float mean[nbin],sigma[nbin],cost[nbin],entry[nbin],meanorig[nbin],etabin[nbin],erretabin[nbin],chiq[nbin],ndf[nbin],rms[nbin],errsigma[nbin];
0052 
0053 for (int i=0;i<nbin;i++){
0054   meanorig[i]=0.;
0055   mean[i]=0.;
0056   sigma[i]=0.;
0057   cost[i]=0.;
0058   entry[i]=0.;
0059   etabin[i]=0.;
0060   chiq[i]=0.;
0061   ndf[i]=0.;
0062   rms[i]=0.;
0063   errsigma[i]=0.;
0064 }
0065 
0066 
0067 cout << "binwidth is " << binwidth << endl; 
0068 
0069 
0070 // //////////////////////////////////////////////////////////////////
0071 // d0 resolution
0072 /////////////////////////////////////////////////////////////////////
0073 
0074 
0075 for (int i=1;i<=nbin;i++){
0076   binstart=binwidth*(i-1)+binbias;
0077   binstop = binwidth*i+binbias;
0078   etabin[i-1]= (binstop-binstart)/2.+binstart;
0079   erretabin[i-1]=(binstop-binstart)/2.;
0080   cout << "binstart=" << binstart << " binstop is=" << binstop << " hit is " << etabin[i-1] << endl;
0081   sprintf(cutname,"recnhit>=%f && recnhit<%f && recnhit <100 && eff==1 && TrackID==13",binstart, binstop);
0082   cout << "cutname is " << cutname <<endl;
0083   TH1F *resd0= new TH1F("d0","d0",500,-0.2,0.2);  
0084   MyTree->Project("d0","(respt/pt)",cutname);
0085   resd0->Fit("gaus");
0086   meanorig[i-1]=1.*resd0->GetMean();
0087   rms[i-1]=1.*resd0->GetRMS();
0088   mean[i-1]=1.*gaus->GetParameter(1);
0089   sigma[i-1]=1.*gaus->GetParameter(2);
0090   errsigma[i-1]=1.*gaus->GetParError(2);
0091   entry[i-1]=resd0->GetEntries();
0092   // Canv->WaitPrimitive();
0093   delete resd0;
0094 }
0095 
0096 for (int i=1;i<nbin;i++){
0097   binstart=binwidth*(i-1)+binbias;
0098   binstop = binwidth*(i+1)+binbias;
0099   cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0100   cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0101   cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0102 }
0103 
0104 hframe = new TH2F("hframe","SigmapT/pT_gaus",15,7.,20.,100,-0.2,1.5);
0105 hframe->SetTitle("#sigma(p_{T})/p_{T} vs n rec. hits ; #mu from CSA06 Z->#mu#mu");
0106 hframe->SetXTitle("n rec. hits");
0107 hframe->SetYTitle("#sigma(p_{T})/p_{T}");
0108 hframe->Draw();
0109 gr = new TGraphErrors(25,etabin,sigma,erretabin,errsigma);
0110 gr->SetMarkerColor(2);
0111 gr->SetMarkerStyle(20);
0112 gr->Draw("P");
0113 Canv->Update();
0114 //Canv->SaveAs("SigmapT_pT_gaus_scen0.eps");
0115 Canv->WaitPrimitive();
0116 
0117 // //////////////////////////////////////////////////////////////////
0118 // d0 resolution scen1
0119 /////////////////////////////////////////////////////////////////////
0120 for (int i=1;i<=nbin;i++){
0121   binstart=binwidth*(i-1)+binbias;
0122   binstop = binwidth*i+binbias;
0123   etabin[i-1]= (binstop-binstart)/2.+binstart;
0124   erretabin[i-1]=(binstop-binstart)/2.;
0125   cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0126   sprintf(cutname,"recnhit>=%f && recnhit<%f  && recnhit <100 && eff==1 && TrackID==13",binstart, binstop);
0127   cout << "cutname is " << cutname <<endl;
0128   TH1F *resd0= new TH1F("d0","d0",500,-0.2,0.2);  
0129   MyTree2->Project("d0","(respt/pt)",cutname);
0130   resd0->Fit("gaus");
0131   meanorig[i-1]=1.*resd0->GetMean();
0132   rms[i-1]=1.*resd0->GetRMS();
0133   mean[i-1]=1.*gaus->GetParameter(1);
0134   sigma[i-1]=1.*gaus->GetParameter(2);
0135   errsigma[i-1]=1.*gaus->GetParError(2);
0136   entry[i-1]=resd0->GetEntries();
0137   //Canv->WaitPrimitive();
0138   delete resd0;
0139 }
0140 
0141 for (int i=1;i<nbin;i++){
0142   binstart=binwidth*(i-1)+binbias;
0143   binstop = binwidth*(i+1)+binbias;
0144   cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0145   cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0146   cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0147 }
0148 
0149 hframe_scen1 = new TH2F("hframe","SigmapT/pT_gaus_scen1",15,7.,20.,100,-0.2,1.5);
0150 hframe_scen1->SetTitle("#sigma(p_{T})/p_{T} vs n rec. hits; #mu from CSA06 Z->#mu#mu");
0151 hframe_scen1->SetXTitle("n rec. hits");
0152 hframe_scen1->SetYTitle("#sigma(p_{T})/p_{T}");
0153 hframe_scen1->Draw();
0154 gr_scen1 = new TGraphErrors(25,etabin,sigma,erretabin,errsigma);
0155 gr_scen1->SetMarkerColor(3);
0156 gr_scen1->SetMarkerStyle(21);
0157 gr_scen1->Draw("P");
0158 Canv->Update();
0159 //Canv->SaveAs("SigmapT_pT_gaus_scen1.eps");
0160 //Canv->WaitPrimitive();
0161 
0162 //////////////////////////////////////////////////////////////////
0163 //d0 resolution scen2
0164 ////
0165 
0166 for (int i=1;i<=nbin;i++){
0167   binstart=binwidth*(i-1)+binbias;
0168   binstop = binwidth*i+binbias+binbias;
0169   etabin[i-1]= (binstop-binstart)/2.+binstart;
0170   erretabin[i-1]=(binstop-binstart)/2.;
0171   cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0172   sprintf(cutname,"recnhit>=%f && recnhit<%f  && recnhit <100 && eff==1 && TrackID==13",binstart, binstop);
0173   cout << "cutname is " << cutname <<endl;
0174   TH1F *resd0= new TH1F("d0","d0",500,-0.2,0.2);  
0175   MyTree3->Project("d0","(respt/pt)",cutname);
0176   resd0->Fit("gaus");
0177   meanorig[i-1]=1.*resd0->GetMean();
0178   rms[i-1]=1.*resd0->GetRMS();
0179   cost[i-1]=gaus->GetParameter(0);
0180   mean[i-1]=1*gaus->GetParameter(1);
0181   sigma[i-1]=1*gaus->GetParameter(2);
0182   errsigma[i-1]=1*gaus->GetParError(2);
0183   entry[i-1]=resd0->GetEntries();
0184   //Canv->WaitPrimitive();
0185   delete resd0;
0186 }
0187 
0188 for (int i=1;i<nbin;i++){
0189   binstart=binwidth*(i-1)+binbias;
0190   binstop = binwidth*(i+1)+binbias;
0191   cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0192   cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0193   cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0194 }
0195 
0196 hframe_scen2 = new TH2F("hframe_scen2","SigmapT/pT_gaus_scen2",15,7.,20.,100,-0.2,1.5);
0197 hframe_scen2->SetTitle("#sigma(p_{T})/p_{T} vs n rec. hits; #mu from CSA06 Z->#mu#mu ");
0198 hframe_scen2->SetXTitle("n rec.hits");
0199 hframe_scen2->SetYTitle("#sigma(p_{T})/p_{T}");
0200 hframe_scen2->Draw();
0201 gr_scen2 = new TGraphErrors(25,etabin,sigma,erretabin,errsigma);
0202 gr_scen2->SetMarkerColor(4);
0203 gr_scen2->SetMarkerStyle(22);
0204 gr_scen2->Draw("P");
0205 Canv->Update();
0206 //Canv->SaveAs("SigmapT_pT_gaus_scen2.eps");
0207 //Canv->WaitPrimitive()
0208 
0209 //////////////////////////////////////////////////////////////////
0210 //d0 resolution scen3
0211 ////
0212 
0213 for (int i=1;i<=nbin;i++){
0214   binstart=binwidth*(i-1)+binbias;
0215   binstop = binwidth*i+binbias+binbias;
0216   etabin[i-1]= (binstop-binstart)/2.+binstart;
0217   erretabin[i-1]=(binstop-binstart)/2.;
0218   cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0219   sprintf(cutname,"recnhit>=%f && recnhit<%f  && recnhit <100 && eff==1 && TrackID==13",binstart, binstop);
0220   cout << "cutname is " << cutname <<endl;
0221   TH1F *resd0= new TH1F("d0","d0",500,-0.2,0.2);  
0222   MyTree4->Project("d0","(respt/pt)",cutname);
0223   resd0->Fit("gaus");
0224   meanorig[i-1]=1.*resd0->GetMean();
0225   rms[i-1]=1.*resd0->GetRMS();
0226   cost[i-1]=gaus->GetParameter(0);
0227   mean[i-1]=1*gaus->GetParameter(1);
0228   sigma[i-1]=1*gaus->GetParameter(2);
0229   errsigma[i-1]=1*gaus->GetParError(2);
0230   entry[i-1]=resd0->GetEntries();
0231   //Canv->WaitPrimitive();
0232   delete resd0;
0233 }
0234 
0235 for (int i=1;i<nbin;i++){
0236   binstart=binwidth*(i-1)+binbias;
0237   binstop = binwidth*(i+1)+binbias;
0238   cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0239   cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0240   cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0241 }
0242 
0243 hframe_scen3 = new TH2F("hframe_scen3","SigmapT/pT_gaus_scen3",15,7.,20.,100,-0.2,1.5);
0244 hframe_scen3->SetTitle("#sigma(p_{T})/p_{T} vs n rec. hits; #mu from CSA06 Z->#mu#mu ");
0245 hframe_scen3->SetXTitle("n rec.hits");
0246 hframe_scen3->SetYTitle("#sigma(p_{T})/p_{T}");
0247 hframe_scen3->Draw();
0248 gr_scen3 = new TGraphErrors(25,etabin,sigma,erretabin,errsigma);
0249 gr_scen3->SetMarkerColor(5);
0250 gr_scen3->SetMarkerStyle(23);
0251 gr_scen3->Draw("P");
0252 Canv->Update();
0253 //Canv->SaveAs("SigmapT_pT_gaus_scen3.eps");
0254 //Canv->WaitPrimitive()
0255 
0256 // //////////////////////////////////////////////////////////////////
0257 // d0 resolution scen1_noErr
0258 /////////////////////////////////////////////////////////////////////
0259 // for (int i=1;i<=nbin;i++){
0260 //   binstart=binwidth*(i-1)+binbias;
0261 //   binstop = binwidth*i+binbias+binbias;
0262 //   etabin[i-1]= (binstop-binstart)/2.+binstart;
0263 //   erretabin[i-1]=(binstop-binstart)/2.;
0264 //   cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0265 //   sprintf(cutname,"recnhit>=%f && recnhit<%f  && recnhit <100 && eff==1 && TrackID==13",binstart, binstop);
0266 //   cout << "cutname is " << cutname <<endl;
0267 //   TH1F *resd0= new TH1F("d0","d0",500,-0.2,0.2);  
0268 //   MyTree4->Project("d0","(respt/pt)",cutname);
0269 //   resd0->Fit("gaus");
0270 //   meanorig[i-1]=1.*resd0->GetMean();
0271 //   rms[i-1]=1.*resd0->GetRMS();
0272 //   cost[i-1]=gaus->GetParameter(0);
0273 //   mean[i-1]=1*gaus->GetParameter(1);
0274 //   sigma[i-1]=1*gaus->GetParameter(2);
0275 //   errsigma[i-1]=1*gaus->GetParError(2);
0276 //   entry[i-1]=resd0->GetEntries();
0277 //   //Canv->WaitPrimitive();
0278 //   delete resd0;
0279 // }
0280 
0281 // for (int i=1;i<nbin;i++){
0282 //   binstart=binwidth*(i-1)+binbias;
0283 //   binstop = binwidth*(i+1)+binbias;
0284 //   cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0285 //   cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0286 //   cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0287 // }
0288 
0289 // hframe_scen3 = new TH2F("hframe_scen3","SigmapT/pT_gaus_scen3",15,7.,20.,100,-0.2,1.5);
0290 // hframe_scen3->SetTitle("#sigma(p_{T})/p_{T} vs n rec. hits; #mu from CSA06 Z->#mu#mu ");
0291 // hframe_scen3->SetXTitle("n rec.hits");
0292 // hframe_scen3->SetYTitle("#sigma(p_{T})/p_{T}");
0293 // hframe_scen3->Draw();
0294 // gr_scen3 = new TGraphErrors(25,etabin,sigma,erretabin,errsigma);
0295 // gr_scen3->SetMarkerColor(5);
0296 // gr_scen3->SetMarkerStyle(22);
0297 // gr_scen3->Draw("P");
0298 // Canv->Update();
0299 // //Canv->SaveAs("SigmapT_pT_gaus_scen2.eps");
0300 // //Canv->WaitPrimitive()
0301 ;
0302 
0303 
0304 
0305 gr->Draw("P");
0306 gr_scen1->Draw("Psame");
0307 gr_scen2->Draw("Psame");
0308 gr_scen3->Draw("Psame");
0309 
0310 TLegend *leg1 = new TLegend(0.1,0.76,0.67,0.9);
0311 leg1->SetTextAlign(32);
0312 leg1->SetTextColor(1);
0313 leg1->SetTextSize(0.03);
0314 
0315 
0316 leg1->AddEntry(gr,"No Misalignment", "P");
0317 leg1->AddEntry(gr_scen1,"SurveyLASCosmics Misalignment", "P");
0318 leg1->AddEntry(gr_scen2,"10 pb-1 Misalignment", "P");
0319 leg1->AddEntry(gr_scen3,"100 pb-1 Misalignment", "P");
0320 leg1->Draw();
0321 
0322 Canv->Update();
0323 Canv->SaveAs("SigmapT_nrechits_gaus_CMSSW_1_3_4_lat.eps");
0324 Canv->SaveAs("SigmapT_nrechits_gaus_CMSSW_1_3_4_lat.gif");
0325 
0326 delete Canv;
0327 gROOT->Reset();
0328 gROOT->Clear();
0329 
0330 
0331 }
0332