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.045,"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("MisalignmentIdeal.root");  
0034 TTree *MyTree=Tracks;
0035 
0036 TFile f1("Misalignment10.root");  
0037 TTree *MyTree2=Tracks;
0038 
0039 TFile f2("Misalignment100.root");
0040 TTree *MyTree3=Tracks;
0041 
0042 TFile f3("Misalignment1000.root");
0043 TTree *MyTree4=Tracks;
0044 
0045 TFile f4("Misalignment_NOAPE_2.root");
0046 TTree *MyTree5=Tracks;
0047 
0048 int nbin=25;
0049 float binwidth=2.5/nbin;
0050 float binstart=0.,binstop=0.;
0051 char cutname[128];
0052 float mean[nbin],sigma[nbin],cost[nbin],entry[nbin],meanorig[nbin],etabin[nbin],erretabin[nbin],chiq[nbin],ndf[nbin],rms[nbin],errsigma[nbin];
0053 
0054 for (int i=0;i<nbin;i++){
0055   meanorig[i]=0.;
0056   mean[i]=0.;
0057   sigma[i]=0.;
0058   cost[i]=0.;
0059   entry[i]=0.;
0060   etabin[i]=0.;
0061   chiq[i]=0.;
0062   ndf[i]=0.;
0063   rms[i]=0.;
0064   errsigma[i]=0.;
0065 }
0066 
0067 
0068 //cout << "binwidth is " << binwidth << endl; 
0069 
0070 
0071 // //////////////////////////////////////////////////////////////////
0072 // d0 resolution
0073 /////////////////////////////////////////////////////////////////////
0074 
0075 
0076 for (int i=1;i<=nbin;i++){
0077   binstart=binwidth*(i-1);
0078   binstop =binwidth*i;
0079   etabin[i-1]= (binstop-binstart)/2.+binstart;
0080   erretabin[i-1]=(binstop-binstart)/2.;
0081   cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0082   //sprintf(cutname,"abs(recthetazmu*3.14/360.)>=%f && abs(recthetazmu*3.14/360.)<%f && eff==1 && TrackID==13",binstart, binstop);
0083   sprintf(cutname,"abs(recyzmu)>=%f && abs(recyzmu)<%f && eff==1 && TrackID==13",binstart, binstop);
0084   cout << "cutname is " << cutname <<endl;
0085   TH1F *resd0= new TH1F("d0","d0",200,-10.,10.);   
0086   MyTree->Project("d0","(recmzmu-mzmu)",cutname);
0087   resd0->Fit("gaus");
0088   meanorig[i-1]=10000.*resd0->GetMean();
0089   rms[i-1]=10000.*resd0->GetRMS();
0090   cost[i-1]=gaus->GetParameter(0);
0091   mean[i-1]=10000*gaus->GetParameter(1);
0092   sigma[i-1]=gaus->GetParameter(2);
0093   errsigma[i-1]=gaus->GetParError(2);
0094   entry[i-1]=resd0->GetEntries();
0095   chiq[i-1]=(gaus->GetChisquare()) /(gaus->GetNDF());
0096   cout << "mean is= " << mean[i-1] << " sigma is= " << sigma[i-1]/(sqrt(entry[i-1])) << " Entries= " << entry[i-1] << endl;
0097   delete resd0;
0098 }
0099 
0100 for (int i=0;i<nbin;i++){
0101   binstart=binwidth*(i);
0102   binstop = binwidth*(i+1);
0103   cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0104   cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0105   cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0106 }
0107 
0108 hframe = new TH2F("hframe","Resd0_gaus",25,0.,2.5,100,0,10.);
0109 hframe->SetTitle("#sigma(m_{Z}) vs y ");
0110 hframe->SetXTitle("y");
0111 hframe->SetYTitle("#sigma(m_{Z}) [GeV/c^2]");
0112 hframe->Draw();
0113 gr = new TGraphErrors(25,etabin,sigma,erretabin,errsigma);
0114 gr->SetMarkerColor(2);
0115 gr->SetMarkerStyle(20);
0116 gr->Draw("P");
0117 Canv->Update();
0118 //Canv->SaveAs("Resd0_gaus_scen0.eps");
0119 //Canv->WaitPrimitive();
0120 
0121 // //////////////////////////////////////////////////////////////////
0122 // d0 resolution scen1
0123 /////////////////////////////////////////////////////////////////////
0124 for (int i=1;i< nbin;i++){
0125   binstart=binwidth*(i-1);
0126   binstop = binwidth*i;
0127   etabin[i-1]= (binstop-binstart)/2.+binstart;
0128   erretabin[i-1]=(binstop-binstart)/2.;
0129   cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0130   // sprintf(cutname,"abs(recetazmu)>=%f && abs(recetazmu)<%f && eff==1 && TrackID==13",binstart, binstop);
0131   //sprintf(cutname,"abs(recthetazmu*3.14/360.)>=%f && abs(recthetazmu*3.14/360.)<%f && eff==1 && TrackID==13",binstart, binstop);
0132   sprintf(cutname,"abs(recyzmu)>=%f && abs(recyzmu)<%f && eff==1 && TrackID==13",binstart, binstop);
0133   cout << "cutname is " << cutname <<endl;
0134   TH1F *resd0= new TH1F("d0","d0",200,-10.,10.);   
0135   MyTree2->Project("d0","(recmzmu-mzmu)",cutname);
0136   resd0->Fit("gaus");
0137   meanorig[i-1]=10000.*resd0->GetMean();
0138   rms[i-1]=10000.*resd0->GetRMS();
0139   cost[i-1]=gaus->GetParameter(0);
0140   mean[i-1]=10000*gaus->GetParameter(1);
0141   sigma[i-1]=gaus->GetParameter(2);
0142   errsigma[i-1]=gaus->GetParError(2);
0143   entry[i-1]=resd0->GetEntries();
0144   chiq[i-1]=(gaus->GetChisquare()) /(gaus->GetNDF());
0145   cout << "mean is= " << mean[i-1] << " sigma is= " << sigma[i-1]/(sqrt(entry[i-1])) << " Entries= " << entry[i-1] << endl;
0146   delete resd0;
0147 }
0148 
0149 for (int i=0;i<nbin;i++){
0150   binstart=binwidth*(i);
0151   binstop = binwidth*(i+1);
0152   cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0153   cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0154   cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0155 }
0156 
0157 hframe_scen1 = new TH2F("hframe_scen1","Resd0_gaus_scen1",25,0.,2.5,100,0.,10.);
0158 hframe_scen1->SetTitle("#sigma(m_{Z}) vs y ");
0159 hframe_scen1->SetXTitle("y");
0160 hframe_scen1->SetYTitle("#sigma(m_{Z}) [GeV/c^2]");
0161 hframe_scen1->Draw();
0162 gr_scen1 = new TGraphErrors(25,etabin,sigma,erretabin,errsigma);
0163 gr_scen1->SetMarkerColor(3);
0164 gr_scen1->SetMarkerStyle(21);
0165 gr_scen1->Draw("P");
0166 Canv->Update();
0167 //Canv->SaveAs("Resd0_gaus_scen1.eps");
0168 //Canv->WaitPrimitive();
0169 
0170 // //////////////////////////////////////////////////////////////////
0171 // d0 resolution scen2
0172 /////////////////////////////////////////////////////////////////////
0173 for (int i=1;i<=nbin;i++){
0174   binstart=binwidth*(i-1);
0175   binstop = binwidth*i;
0176   etabin[i-1]= (binstop-binstart)/2.+binstart;
0177   erretabin[i-1]=(binstop-binstart)/2.;
0178   cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0179   // sprintf(cutname,"abs(recetazmu)>=%f && abs(recetazmu)<%f && eff==1 && TrackID==13",binstart, binstop);
0180   //sprintf(cutname,"abs(recthetazmu*3.14/360.)>=%f && abs(recthetazmu*3.14/360.)<%f && eff==1 && TrackID==13",binstart, binstop);
0181    sprintf(cutname,"abs(recyzmu)>=%f && abs(recyzmu)<%f && eff==1 && TrackID==13",binstart, binstop);
0182   cout << "cutname is " << cutname <<endl;
0183   TH1F *resd0= new TH1F("d0","d0",200,-10.,10.);   
0184   MyTree3->Project("d0","(recmzmu-mzmu)",cutname);
0185   resd0->Fit("gaus");
0186   meanorig[i-1]=10000.*resd0->GetMean();
0187   rms[i-1]=10000.*resd0->GetRMS();
0188   cost[i-1]=gaus->GetParameter(0);
0189   mean[i-1]=10000*gaus->GetParameter(1);
0190   sigma[i-1]=gaus->GetParameter(2);
0191   errsigma[i-1]=gaus->GetParError(2);
0192   entry[i-1]=resd0->GetEntries();
0193   chiq[i-1]=(gaus->GetChisquare()) /(gaus->GetNDF());
0194   cout << "mean is= " << mean[i-1] << " sigma is= " << sigma[i-1]/(sqrt(entry[i-1])) << " Entries= " << entry[i-1] << endl;
0195   delete resd0;
0196 }
0197 
0198 for (int i=0;i<nbin;i++){
0199   binstart=binwidth*(i);
0200   binstop = binwidth*(i+1);
0201   cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0202   cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0203   cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0204 }
0205 
0206 hframe_scen2 = new TH2F("hframe_scen1","Resd0_gaus_scen2",25,0.,2.5,100,0.,10.);
0207 hframe_scen2->SetTitle("#sigma(m_{Z}) vs y ");
0208 hframe_scen2->SetXTitle("y");
0209 hframe_scen2->SetYTitle("#sigma(m_{Z}) [GeV/c^2]");
0210 hframe_scen2->Draw();
0211 gr_scen2 = new TGraphErrors(25,etabin,sigma,erretabin,errsigma);
0212 gr_scen2->SetMarkerColor(4);
0213 gr_scen2->SetMarkerStyle(22);
0214 gr_scen2->Draw("P");
0215 Canv->Update();
0216 //Canv->SaveAs("Resd0_gaus_scen2.eps");
0217 //Canv->WaitPrimitive();
0218 
0219 
0220 // //////////////////////////////////////////////////////////////////
0221 // d0 resolution scen3
0222 /////////////////////////////////////////////////////////////////////
0223 for (int i=1;i<=nbin;i++){
0224   binstart=binwidth*(i-1);
0225   binstop = binwidth*i;
0226   etabin[i-1]= (binstop-binstart)/2.+binstart;
0227   erretabin[i-1]=(binstop-binstart)/2.;
0228   cout << "binstart=" << binstart << " binstop is=" << binstop << " eta is " << etabin[i-1] << endl;
0229   // sprintf(cutname,"abs(recetazmu)>=%f && abs(recetazmu)<%f && eff==1 && TrackID==13",binstart, binstop);
0230   //sprintf(cutname,"abs(recthetazmu*3.14/360.)>=%f && abs(recthetazmu*3.14/360.)<%f && eff==1 && TrackID==13",binstart, binstop);
0231    sprintf(cutname,"abs(recyzmu)>=%f && abs(recyzmu)<%f && eff==1 && TrackID==13",binstart, binstop);
0232   cout << "cutname is " << cutname <<endl;
0233   TH1F *resd0= new TH1F("d0","d0",200,-10.,10.);   
0234   MyTree4->Project("d0","(recmzmu-mzmu)",cutname);
0235   resd0->Fit("gaus");
0236   meanorig[i-1]=10000.*resd0->GetMean();
0237   rms[i-1]=10000.*resd0->GetRMS();
0238   cost[i-1]=gaus->GetParameter(0);
0239   mean[i-1]=10000*gaus->GetParameter(1);
0240   sigma[i-1]=gaus->GetParameter(2);
0241   errsigma[i-1]=gaus->GetParError(2);
0242   entry[i-1]=resd0->GetEntries();
0243   chiq[i-1]=(gaus->GetChisquare()) /(gaus->GetNDF());
0244   cout << "mean is= " << mean[i-1] << " sigma is= " << sigma[i-1]/(sqrt(entry[i-1])) << " Entries= " << entry[i-1] << endl;
0245   delete resd0;
0246 }
0247 
0248 for (int i=0;i<nbin;i++){
0249   binstart=binwidth*(i);
0250   binstop = binwidth*(i+1);
0251   cout << "binstart= " << binstart << " binstop= " << binstop << endl;
0252   cout << " etabin=" << etabin[i] << " Vector mean/sigma are "<< mean[i] << " +/- " << sigma[i] << endl;
0253   cout << " ErrOnSigma =" << errsigma[i] << " Mean/RMS orig =" << meanorig[i] << " +/-" << rms[i] << endl;
0254 }
0255 
0256 hframe_scen3 = new TH2F("hframe_scen1","Resd0_gaus_scen3",25,0.,2.5,100,0.,10.);
0257 hframe_scen3->SetTitle("#sigma(m_{Z}) vs y ");
0258 hframe_scen3->SetXTitle("y");
0259 hframe_scen3->SetYTitle("#sigma(m_{Z}) [GeV/c^2]");
0260 hframe_scen3->Draw();
0261 gr_scen3 = new TGraphErrors(25,etabin,sigma,erretabin,errsigma);
0262 gr_scen3->SetMarkerColor(5);
0263 gr_scen3->SetMarkerStyle(23);
0264 gr_scen3->Draw("P");
0265 Canv->Update();
0266 //Canv->SaveAs("Resd0_gaus_scen3.eps");
0267 //Canv->WaitPrimitive();
0268 
0269 ///////////////////////////////////////////////
0270 
0271 gr->Draw("P");
0272 gr_scen1->Draw("Psame");
0273 gr_scen2->Draw("Psame");
0274 gr_scen3->Draw("Psame");
0275 
0276 TLegend *leg1 = new TLegend(0.1,0.76,0.47,0.9); 
0277 leg1->SetTextAlign(32);
0278 leg1->SetTextColor(1);
0279 leg1->SetTextSize(0.03);
0280 
0281 leg1->AddEntry(gr,"No Misalignment", "P");
0282 leg1->AddEntry(gr_scen1,"10pb-1 Misalignment", "P");
0283 leg1->AddEntry(gr_scen2,"100pb-1 Misalignment", "P");
0284 leg1->AddEntry(gr_scen3,"1000pb-1 Misalignment", "P");
0285 
0286 leg1->Draw();
0287 
0288 Canv->Update();
0289 Canv->SaveAs("SigmamZ_yzmu_CMSSW_1_3_4_lat.gif");
0290 Canv->SaveAs("SigmamZ_yzmu_CMSSW_1_3_4_lat.eps");
0291 
0292 delete Canv;
0293 gROOT->Reset();
0294 gROOT->Clear();
0295 
0296 
0297 }
0298