void SinglePionEfficiency::Loop() { // In a ROOT session, you can do: // Root > .L SinglePionEfficiency.C // Root > SinglePionEfficiency t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; // number of pt bins and intervals const Int_t nptbins = 12; const Int_t nptcuts = nptbins+1; // 0 1 2 3 4 5 6 7 8 9 10 11 Double_t pt[nptcuts]={0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 40., 50.0}; // number of eta bins and intervals const Int_t netabins = 12; const Int_t netacuts = netabins+1; // 0 1 2 3 4 5 6 7 8 9 10 11 Double_t eta[netacuts]={0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4}; cout <<" Eta bins " << endl; // prepare eta points for graph Float_t etagr[netabins], eetagr[netabins]; for(Int_t i = 0; i < netabins; i++) { etagr[i] = 0.5*(eta[i]+eta[i+1]); eetagr[i] = 0.5*(eta[i+1]-eta[i]); cout <<" i = " << i <<" Eta = " << etagr[i] <<" err Eta = " << eetagr[i] << endl; } // prepare for graph Float_t ptgr[nptbins], eptgr[nptbins]; for(Int_t i = 0; i < nptbins; i++) { ptgr[i] = 0.5*(pt[i]+pt[i+1]); eptgr[i] = 0.5*(pt[i+1]-pt[i]); cout <<" i = " << i <<" pT = " << ptgr[i] <<" err pT = " << eptgr[i] << endl; } TH2D* hResp = new TH2D("hResp","Resp",nptbins, pt, netabins, eta); // histos for energy losses TH1F* hEnTrkNotInter[netabins]; const char* namesEnTrkNotInter[netabins] = {"hEnTrkNotInter1", "hEnTrkNotInter2", "hEnTrkNotInter3", "hEnTrkNotInter4", "hEnTrkNotInter5", "hEnTrkNotInter6", "hEnTrkNotInter7", "hEnTrkNotInter8", "hEnTrkNotInter9", "hEnTrkNotInter10", "hEnTrkNotInter11", "hEnTrkNotInter12"}; const char* titleEnTrkNotInter[netabins] = {"EnTrkNotInter1", "EnTrkNotInter2", "EnTrkNotInter3", "EnTrkNotInter4", "EnTrkNotInter5", "EnTrkNotInter6", "EnTrkNotInter7", "EnTrkNotInter8", "EnTrkNotInter9", "EnTrkNotInter10", "EnTrkNotInter11", "EnTrkNotInter12"}; TH1F* hEnTrkInter[netabins]; const char* namesEnTrkInter[netabins] = {"hEnTrkInter1", "hEnTrkInter2", "hEnTrkInter3", "hEnTrkInter4", "hEnTrkInter5", "hEnTrkInter6", "hEnTrkInter7", "hEnTrkInter8", "hEnTrkInter9", "hEnTrkInter10", "hEnTrkInter11", "hEnTrkInter12"}; const char* titleEnTrkInter[netabins] = {"EnTrkInter1", "EnTrkInter2", "EnTrkInter3", "EnTrkInter4", "EnTrkInter5", "EnTrkInter6", "EnTrkInter7", "EnTrkInter8", "EnTrkInter9", "EnTrkInter10", "EnTrkInter11", "EnTrkInter12"}; for(Int_t ih=0; ih < netabins; ih++) { hEnTrkNotInter[ih] = new TH1F(namesEnTrkNotInter[ih], titleEnTrkNotInter[ih], 40, -1., 3.); hEnTrkInter[ih] = new TH1F(namesEnTrkInter[ih], titleEnTrkInter[ih], 40, -1., 3.); } // // ===> for pi- and pi+ // N total and N reco tracks // find how to write output in file //~/scratch0/CMSSW_TEST/cmssw134gammajet/src/JetMETCorrections/GammaJet/src/GammaJetAnalysis.cc // total number of analized MC tracks Int_t ntrk[netabins][nptbins] = { {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, }; // number of found tracks Int_t ntrkreco[netabins][nptbins] = { {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, }; // number of lost tracks Int_t ntrklost[netabins][nptbins] = { {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, }; // number of tracks with impact point on calo Int_t ntrkrecor[netabins][nptbins] = { {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, }; // trk efficiency and error Float_t trkeff[netabins][nptbins], etrkeff[netabins][nptbins]; // response in 11x11 crystals + 5x5 HCAL around IP in ECAL Double_t response[netabins][nptbins] = { {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, }; // response for found tracks in cone 0.5 around MC track direction at vertex Double_t responseFoundTrk[netabins][nptbins] = { {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, }; // response for lost tracks in cone 0.5 around MC track direction at vertex Double_t responseLostTrk[netabins][nptbins] = { {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, }; // average response in 11x11 crystals + 5x5 HCAL around IP in ECAL Double_t responseF[netabins][nptbins]; // average response for found tracks in cone 0.5 around MC track direction at vertex Double_t responseFoundTrkF[netabins][nptbins]; // average response for lost tracks in cone 0.5 around MC track direction at vertex Double_t responseLostTrkF[netabins][nptbins]; // ratio of responses of lost and found tracks Double_t leak[netabins][nptbins]; Double_t drTrkcut = 0.01; Double_t purityTrkcut = 0.75; // for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; // counting events for efficiency calculation for(Int_t ieta = 0; ieta < netabins; ieta++) { for(Int_t ipt = 0; ipt < nptbins; ipt++) { // ==> pi+ if(fabs(etaSim1) >= eta[ieta] && fabs(etaSim1) < eta[ieta+1]) { // checking leakage if(ptSim1 > 10. && ptSim1 < 10000.) { if(drTrk2 < 0.01 && purityTrk2 == 1) { hEnTrkNotInter[ieta]->Fill(etCalo1/ptSim1); } else { hEnTrkInter[ieta]->Fill(etCalo1/ptSim1); } } // end of checking leakage if(ptSim1 >= pt[ipt] && ptSim1 < pt[ipt+1]) { ntrk[ieta][ipt] = ntrk[ieta][ipt]+1; // number of reco tracks if(drTrk1 < drTrkcut && purityTrk1 >= purityTrkcut) { ntrkreco[ieta][ipt] = ntrkreco[ieta][ipt]+1; // response for found tracks responseFoundTrk[ieta][ipt] = responseFoundTrk[ieta][ipt] + etCalo1/ptSim1; // Double_t theta = 2.*atan(exp(-etaSim1)); Double_t eSim1 = ptSim1/sin(theta); if(e1ECAL11x11 > -1000. && e1HCAL5x5 > -1000. && fabs(etaSim1) < 1000.) { ntrkrecor[ieta][ipt] = ntrkrecor[ieta][ipt]+1; Double_t e_ecal11 = e1ECAL11x11/eSim1; Double_t e_hcal5 = e1HCAL5x5/eSim1; Double_t e_ecalhcal11x5 = e_ecal11 + e_hcal5; response[ieta][ipt] = response[ieta][ipt] + e_ecalhcal11x5; } } else { // response for lost tracks ntrklost[ieta][ipt] = ntrklost[ieta][ipt]+1; responseLostTrk[ieta][ipt] = responseLostTrk[ieta][ipt] + etCalo1/ptSim1; // } } } // ==> pi- if(fabs(etaSim2) >= eta[ieta] && fabs(etaSim2) < eta[ieta+1]) { // checking leakage if(ptSim2 > 10. && ptSim2 < 1000.) { if(drTrk2 < 0.01 && purityTrk2 == 1) { hEnTrkNotInter[ieta]->Fill(etCalo2/ptSim2); } else { hEnTrkInter[ieta]->Fill(etCalo2/ptSim2); } } // end of checking leakage if(ptSim2 >= pt[ipt] && ptSim2 < pt[ipt+1]) { ntrk[ieta][ipt] = ntrk[ieta][ipt]+1; // number of reco tracks if(drTrk2 < drTrkcut && purityTrk2 >= purityTrkcut) { ntrkreco[ieta][ipt] = ntrkreco[ieta][ipt]+1; // response for found tracks responseFoundTrk[ieta][ipt] = responseFoundTrk[ieta][ipt] + etCalo2/ptSim2; // Double_t theta = 2.*atan(exp(-etaSim2)); Double_t eSim2 = ptSim2/sin(theta); if(e2ECAL11x11 > -1000. && e2HCAL5x5 > -1000. && fabs(etaSim2) < 1000.) { ntrkrecor[ieta][ipt] = ntrkrecor[ieta][ipt]+1; Double_t e_ecal11 = e2ECAL11x11/eSim2; Double_t e_hcal5 = e2HCAL5x5/eSim2; Double_t e_ecalhcal11x5 = e_ecal11 + e_hcal5; response[ieta][ipt] = response[ieta][ipt] + e_ecalhcal11x5; } } else { // response for lost tracks ntrklost[ieta][ipt] = ntrklost[ieta][ipt]+1; responseLostTrk[ieta][ipt] = responseLostTrk[ieta][ipt] + etCalo2/ptSim2; // } } } } } } // calculate efficiencfy, full graph and write output stream ofstream myoutput_eff("CMSSW_167_TrackNonEff.txt"); ofstream myoutput_eff1("CMSSW_167_TrackNonEff_one.txt"); ofstream myoutput_leak("CMSSW_167_TrackLeakage.txt"); ofstream myoutput_leak1("CMSSW_167_TrackLeakage_one.txt"); ofstream myoutput_resp("CMSSW_167_response.txt"); // calculate map of leackage for(Int_t ieta = 0; ieta < netabins; ieta++) { for(Int_t ipt = 0; ipt < nptbins; ipt++) { // found tracks if(ntrkreco[ieta][ipt] != 0) { responseFoundTrkF[ieta][ipt] = responseFoundTrk[ieta][ipt]/ntrkreco[ieta][ipt]; } else { responseFoundTrkF[ieta][ipt] = responseFoundTrkF[ieta][ipt-1]; } // lost tracks if(ntrklost[ieta][ipt] != 0) { responseLostTrkF[ieta][ipt] = responseLostTrk[ieta][ipt]/ntrklost[ieta][ipt]; } else { responseLostTrkF[ieta][ipt] = responseLostTrkF[ieta][ipt-1]; } } } for(Int_t ieta = 0; ieta <= netabins; ieta++) { for(Int_t ipt = 0; ipt <= nptbins; ipt++) { if(ieta < netabins && ipt < nptbins) { leak[ieta][ipt] = responseLostTrkF[ieta][ipt]/responseFoundTrkF[ieta][ipt]; cout <<" ieta = " << ieta <<" eta = " << eta[ieta] <<" ipt = " << ipt <<" pt = " << pt[ipt] <<" ntrkreco = " << ntrkreco[ieta][ipt] <<" ntrklost = " << ntrklost[ieta][ipt] <<" responseFoundTrk = " << responseFoundTrkF[ieta][ipt] <<" responseLostTrk = " << responseLostTrkF[ieta][ipt] <<" leak = " << leak[ieta][ipt] << endl; myoutput_leak << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << leak[ieta][ipt] << endl; myoutput_leak1 << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << " 1. " << endl; } if(ipt == nptbins && ieta < netabins) { myoutput_leak << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << leak[ieta][ipt-1] << endl; myoutput_leak1 << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << " 1. " << endl; } if(ipt < nptbins && ieta == netabins) { myoutput_leak << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << leak[ieta-1][ipt] << endl; myoutput_leak1 << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << " 1. " << endl; } if(ipt == nptbins && ieta == netabins) { myoutput_leak << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << leak[ieta-1][ipt-1] << endl; myoutput_leak1 << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << " 1. " << endl; } } } // calculate map of response and tracker efficiency cout <<" " << endl; cout <<" " << endl; cout <<" " << endl; for(Int_t ieta = 0; ieta <= netabins; ieta++) { for(Int_t ipt = 0; ipt <= nptbins; ipt++) { if(ieta < netabins && ipt < nptbins) { if(ntrk[ieta][ipt] != 0 && ntrkrecor[ieta][ipt] != 0) { trkeff[ieta][ipt] = 1.*ntrkreco[ieta][ipt]/ntrk[ieta][ipt]; etrkeff[ieta][ipt] = sqrt( trkeff[ieta][ipt]*(1.-trkeff[ieta][ipt])/ntrk[ieta][ipt] ); responseF[ieta][ipt] = response[ieta][ipt]/ntrkrecor[ieta][ipt]; cout <<" ieta = " << ieta <<" eta = " << eta[ieta] <<" ipt = " << ipt <<" pt = " << pt[ipt] <<" ntrkreco = " << ntrkreco[ieta][ipt] <<" ntrkrecor = " << ntrkrecor[ieta][ipt] <<" ntrk = " << ntrk[ieta][ipt] <<" eff = " << trkeff[ieta][ipt] <<" +/- " << etrkeff[ieta][ipt] <<" response = " << responseF[ieta][ipt] << endl; hResp->Fill(pt[ipt],eta[ieta],responseF[ieta][ipt]); myoutput_eff << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << trkeff[ieta][ipt] << endl; myoutput_resp << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << responseF[ieta][ipt] << endl; myoutput_eff1 << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << " 1." << endl; } else { trkeff[ieta][ipt] = trkeff[ieta][ipt-1]; responseF[ieta][ipt] = responseF[ieta][ipt-1]; hResp->Fill(pt[ipt],eta[ieta],responseF[ieta][ipt]); myoutput_eff << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << trkeff[ieta][ipt] << endl; myoutput_resp << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << responseF[ieta][ipt] << endl; myoutput_eff1 << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << " 1." << endl; } } if(ipt == nptbins && ieta < netabins) { myoutput_eff << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << trkeff[ieta][ipt-1] << endl; myoutput_resp << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << responseF[ieta][ipt-1] << endl; myoutput_eff1 << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << " 1." << endl; } if(ipt < nptbins && ieta == netabins) { myoutput_eff << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << trkeff[ieta-1][ipt] << endl; myoutput_resp << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << responseF[ieta-1][ipt] << endl; myoutput_eff1 << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << " 1." << endl; } if(ipt == nptbins && ieta == netabins) { myoutput_eff << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << trkeff[ieta-1][ipt-1] << endl; myoutput_resp << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << responseF[ieta-1][ipt-1] << endl; myoutput_eff1 << ieta << " " << ipt << " " << eta[ieta] << " " << pt[ipt] << " " << " 1." << endl; } } } // // plot leakage graph Float_t leakage[netabins], eleakage[netabins]; Float_t MeanNotInter[netabins], MeanErrorNotInter[netabins]; Float_t MeanInter[netabins], MeanErrorInter[netabins]; for(Int_t ih=0; ih < netabins; ih++) { // hEnTrkNotInter[ih]->Write(); // hEnTrkInter[ih]->Write(); MeanNotInter[ih] = hEnTrkNotInter[ih]->GetMean(); MeanErrorNotInter[ih] = hEnTrkNotInter[ih]->GetMeanError(); MeanInter[ih] = hEnTrkInter[ih]->GetMean(); MeanErrorInter[ih] = hEnTrkInter[ih]->GetMeanError(); leakage[ih] = MeanInter[ih]/MeanNotInter[ih]; eleakage[ih] = leakage[ih] * sqrt( (MeanErrorNotInter[ih]/MeanNotInter[ih])*(MeanErrorNotInter[ih]/MeanNotInter[ih]) + (MeanErrorInter[ih]/MeanInter[ih])*(MeanErrorInter[ih]/MeanInter[ih])); cout <<" ieta = " << ih <<" MeanNotInter = " << MeanNotInter[ih] <<" +/- " << MeanErrorNotInter[ih] <<" MeanInter = " << MeanInter[ih] <<" +/- " << MeanErrorInter[ih] <<" leakage = " << leakage[ih] <<" +/- " << eleakage[ih] << endl; } TGraph *gleak = new TGraphErrors(netabins,etagr,leakage, eetagr,eleakage); TGraph *eMeanNotInter = new TGraphErrors(netabins,etagr,MeanNotInter, eetagr,MeanErrorNotInter); TGraph *eMeanInter = new TGraphErrors(netabins,etagr,MeanInter, eetagr,MeanErrorInter); // vs Eta setTDRStyle(0,0); TCanvas* c3 = new TCanvas("X","Y",1); c3->Divide(1,2); c3->cd(1); TAxis* xaxis = eMeanNotInter->GetXaxis(); eMeanNotInter->GetXaxis()->SetTitle("#eta"); eMeanNotInter->GetYaxis()->SetTitle("calo E_{T}^{raw reco} in cone 0.5/p_{T}^{MC}"); xaxis->SetLimits(0.0,2.4); eMeanNotInter->SetMarkerStyle(21); // eMeanNotInter->SetMaximum(0.95); // eMeanNotInter->SetMinimum(0.55); eMeanNotInter->SetMaximum(1.); eMeanNotInter->SetMinimum(0.); eMeanNotInter->Draw("AP"); eMeanInter->SetMarkerStyle(24); eMeanInter->Draw("P"); TLatex *t = new TLatex(); t->SetTextSize(0.08); t->DrawLatex(0.2,0.9,"CMSSW_1_6_9"); TLegend *leg = new TLegend(0.2,0.2,0.8,0.4,NULL,"brNDC"); leg->SetFillColor(10); leg->AddEntry(eMeanNotInter,"recontructed tracks 2 < p_{T}^{#pi^{#pm}} < 10 GeV","P"); leg->AddEntry(eMeanInter,"not reconstructed tracks 2 < p_{T}^{#pi^{#pm}} < 10 GeV","P"); leg->Draw(); c3->cd(2); TAxis* xaxis = gleak->GetXaxis(); gleak->GetXaxis()->SetTitle("#eta"); gleak->GetYaxis()->SetTitle("ratio = <E_{T for lost tracks}^{raw reco} / E_{T for found tracks}^{raw reco}>"); xaxis->SetLimits(0.0,2.4); gleak->SetMarkerStyle(21); gleak->SetMaximum(1.0); // leak->SetMinimum(0.7); gleak->SetMinimum(0.5); gleak->Draw("AP"); TLatex *t = new TLatex(); t->SetTextSize(0.08); // t->DrawLatex(0.1,0.75,"<E_{T for lost tracks}^{raw reco} / E_{T for found tracks}^{raw reco}> for p_{T}^{#pi^{#pm}} >2 GeV"); c3->SaveAs("eMean_vs_eta_pt2-10.gif"); c3->SaveAs("eMean_vs_eta_pt2-10.eps"); // original distribtions setTDRStyle(0,0); gStyle->SetOptFit(0); TCanvas* c4 = new TCanvas("X","Y",1); hEnTrkNotInter[0]->GetYaxis()->SetTitle(""); hEnTrkNotInter[0]->GetXaxis()->SetTitle("calo E_{T}^{raw reco} in cone 0.5/p_{T}^{MC}"); Double_t scale = 1./hEnTrkNotInter[0]->Integral(); hEnTrkNotInter[0]->Scale(scale); hEnTrkNotInter[0]->SetLineWidth(4); hEnTrkNotInter[0]->SetMaximum(0.14); // hEnTrkNotInter[0]->SetMinimum(0.55); // Fitting Int_t binMax = hEnTrkNotInter[0]->GetMaximumBin(); TAxis* xaxis = hEnTrkNotInter[0]->GetXaxis(); Double_t binCenter = xaxis->GetBinCenter(binMax); Double_t rms = hEnTrkNotInter[0]->GetRMS(); Double_t rFitMin = binCenter - 1.5 * rms; Double_t rFitMax = binCenter + 1.5 * rms; hEnTrkNotInter[0]->Fit("gaus","","",rFitMin,rFitMax); TF1 *fit = hEnTrkNotInter[0]->GetFunction("gaus"); fit->SetLineWidth(4); fit->SetLineStyle(2); fit->Draw("same"); scale = 1./hEnTrkInter[0]->Integral(); hEnTrkInter[0]->Scale(scale); hEnTrkInter[0]->SetLineWidth(2); // Fitting Int_t binMax = hEnTrkInter[0]->GetMaximumBin(); TAxis* xaxis = hEnTrkInter[0]->GetXaxis(); Double_t binCenter = xaxis->GetBinCenter(binMax); Double_t rms = hEnTrkNotInter[0]->GetRMS(); Double_t rFitMin = binCenter - 1.5 * rms; Double_t rFitMax = binCenter + 1.5 * rms; hEnTrkInter[0]->Fit("gaus","","same",rFitMin,rFitMax); TF1 *fit = hEnTrkInter[0]->GetFunction("gaus"); fit->SetLineWidth(2); fit->SetLineStyle(2); fit->Draw("same"); TLatex *t = new TLatex(); t->SetTextSize(0.08); t->DrawLatex(0.2,0.9,"CMSSW_1_6_9"); TLegend *leg = new TLegend(0.15,0.7,0.9,0.9,NULL,"brNDC"); leg->SetFillColor(10); leg->AddEntry(hEnTrkNotInter[0],"recontructed tracks 2< p_{T}^{#pi^{#pm}} < 10 GeV, 0<#eta<0.2","L"); leg->AddEntry(hEnTrkInter[0],"not reconstructed tracks 2< p_{T}^{#pi^{#pm}} < 10 GeV, 0<#eta<0.2","L"); leg->Draw(); c4->SaveAs("eMean_at_eta0.gif"); c4->SaveAs("eMean_at_eta0.eps"); // original distribtions setTDRStyle(0,0); gStyle->SetOptFit(0); TCanvas* c5 = new TCanvas("X","Y",1); hEnTrkNotInter[9]->GetYaxis()->SetTitle(""); hEnTrkNotInter[9]->GetXaxis()->SetTitle("calo E_{T}^{raw reco} in cone 0.5/p_{T}^{MC}"); Double_t scale = 1./hEnTrkNotInter[9]->Integral(); hEnTrkNotInter[9]->Scale(scale); hEnTrkNotInter[9]->SetLineWidth(4); hEnTrkNotInter[9]->SetMaximum(0.17); // hEnTrkNotInter[9]->SetMinimum(0.55); // Fitting Int_t binMax = hEnTrkNotInter[9]->GetMaximumBin(); TAxis* xaxis = hEnTrkNotInter[9]->GetXaxis(); Double_t binCenter = xaxis->GetBinCenter(binMax); Double_t rms = hEnTrkNotInter[9]->GetRMS(); Double_t rFitMin = binCenter - 1.5 * rms; Double_t rFitMax = binCenter + 1.5 * rms; hEnTrkNotInter[9]->Fit("gaus","","",rFitMin,rFitMax); TF1 *fit = hEnTrkNotInter[9]->GetFunction("gaus"); fit->SetLineWidth(4); fit->SetLineStyle(2); fit->Draw("same"); scale = 1./hEnTrkInter[9]->Integral(); hEnTrkInter[9]->Scale(scale); hEnTrkInter[9]->SetLineWidth(2); // Fitting Int_t binMax = hEnTrkInter[9]->GetMaximumBin(); TAxis* xaxis = hEnTrkInter[9]->GetXaxis(); Double_t binCenter = xaxis->GetBinCenter(binMax); Double_t rms = hEnTrkNotInter[9]->GetRMS(); Double_t rFitMin = binCenter - 1.2 * rms; Double_t rFitMax = binCenter + 1.5 * rms; hEnTrkInter[9]->Fit("gaus","","same",rFitMin,rFitMax); TF1 *fit = hEnTrkInter[9]->GetFunction("gaus"); fit->SetLineWidth(2); fit->SetLineStyle(2); fit->Draw("same"); TLatex *t = new TLatex(); t->SetTextSize(0.08); t->DrawLatex(0.2,0.9,"CMSSW_1_6_9"); TLegend *leg = new TLegend(0.15,0.7,0.9,0.9,NULL,"brNDC"); leg->SetFillColor(10); leg->AddEntry(hEnTrkNotInter[9],"recontructed tracks p_{T}^{#pi^{#pm}} > 2 GeV, 1.8<#eta<2.0","L"); leg->AddEntry(hEnTrkInter[9],"not reconstructed tracks p_{T}^{#pi^{#pm}} > 2 GeV, 1.8<#eta<2.0","L"); leg->Draw(); c5->SaveAs("eMean_at_eta1.9.gif"); c5->SaveAs("eMean_at_eta1.9.eps"); TFile efile("response.root","recreate"); hResp->Write(); efile.Close(); }
int Mbb_reg(int type_int){ gROOT->ProcessLine(".x /afs/cern.ch/work/n/nchernya/setTDRStyle.C"); // int type_int; //double =0; single=1 TString type; if (type_int==0) type = "_double"; if (type_int==1) type = "_single"; TString text_type; if (type_int==0) text_type = "DoubleB"; if (type_int==1) text_type = "SingleB"; const int num_ss = 1; // TString s_names[num_ss] = {"VBFHToBB_M-125_13TeV_powheg"}; TString s_names[num_ss] = {"vbf_76"}; TString tex_s_names[num_ss] = {"VBF powheg, m(H) = 125 GeV"}; TFile *file_s1 = new TFile("../output_hist/v14/golden/skimmed_tree_analysis"+type+s_names[0]+"_v14_final_74cmssw_woweight.root"); TH1F *hist_Mbb = (TH1F*)file_s1->Get("hMbb"); TH1F *hist_Mbb_reg = (TH1F*)file_s1->Get("hMbb_regVBF"); TH1F *hist_Mbb_reg_fsr = (TH1F*)file_s1->Get("hMbb_regVBF_fsr"); TF1 *gaus = new TF1("gaus","gaus",95,140); gaus->SetLineColor(4); gaus->SetLineWidth(1); hist_Mbb->Sumw2(kFALSE); hist_Mbb_reg->Sumw2(kFALSE); hist_Mbb_reg_fsr->Sumw2(kFALSE); hist_Mbb->Sumw2(kFALSE); hist_Mbb->Fit(gaus,"R"); Float_t Mbb_mean = gaus->GetParameter(1); Float_t Mbb_rms = gaus->GetParameter(2); hist_Mbb_reg->Sumw2(kFALSE); gaus->SetLineColor(2); hist_Mbb_reg->Fit(gaus,"R"); Float_t Mbb_reg_mean = gaus->GetParameter(1); Float_t Mbb_reg_rms = gaus->GetParameter(2); hist_Mbb_reg_fsr->Sumw2(kFALSE); gaus->SetLineColor(8); hist_Mbb_reg_fsr->Fit(gaus,"R"); Float_t Mbb_reg_fsr_mean = gaus->GetParameter(1); Float_t Mbb_reg_fsr_rms = gaus->GetParameter(2); ///// /* Float_t Mbb_mean = hist_Mbb->GetMean(1); Float_t Mbb_rms = hist_Mbb->GetRMS(1); Float_t Mbb_reg_mean = hist_Mbb_reg->GetMean(1); Float_t Mbb_reg_rms = hist_Mbb_reg->GetRMS(1); Float_t Mbb_reg_fsr_mean = hist_Mbb_reg_fsr->GetMean(1); Float_t Mbb_reg_fsr_rms = hist_Mbb_reg_fsr->GetRMS(1); */ ///// TCanvas *c1 = new TCanvas(); c1->SetBottomMargin(.15); c1->SetRightMargin(.25); c1->cd(); TH1F *frame2 = new TH1F("frame2","",50,0.,230.); frame2->SetMinimum(0.); frame2->SetMaximum(hist_Mbb->GetMaximum()*1.6); // if (type_int==1) frame2->SetMaximum(0.005); frame2->SetStats(0); frame2->SetYTitle("Events / 5 GeV"); frame2->SetXTitle("M_{bb} (GeV)"); frame2->GetYaxis()->SetNdivisions(505); frame2->GetXaxis()->SetLabelSize(0.0); frame2->GetXaxis()->SetTitleSize(0.05); frame2->GetXaxis()->SetLabelSize(0.04); frame2->Draw(); TLatex* tex = new TLatex(0.75,0.95,"13 TeV"); tex->SetNDC(); tex->SetTextAlign(35); tex->SetTextFont(42); tex->SetTextSize(0.035); tex->SetLineWidth(2); TLatex *tex1 = new TLatex(0.17,0.95,"CMS"); tex1->SetNDC(); tex1->SetTextAlign(20); tex1->SetTextFont(61); tex1->SetTextSize(0.04); tex1->SetLineWidth(2); TLatex* tex2 = new TLatex(0.25,0.89,"Work in progress"); tex2->SetNDC(); tex2->SetTextAlign(20); tex2->SetTextFont(52); tex2->SetTextSize(0.035); tex2->SetLineWidth(2); TLatex* tex_file = new TLatex(0.36,0.95,text_type); tex_file->SetNDC(); tex_file->SetTextAlign(35); tex_file->SetTextFont(42); tex_file->SetTextSize(0.04); tex_file->SetLineWidth(2); tex->Draw(); tex1->Draw(); tex2->Draw(); // tex_file->Draw(); hist_Mbb->SetLineColor(4); hist_Mbb->SetLineWidth(2); hist_Mbb_reg->SetLineColor(2); hist_Mbb_reg->SetLineWidth(2); hist_Mbb_reg_fsr->SetLineColor(8); hist_Mbb_reg_fsr->SetLineWidth(2); hist_Mbb_reg->Draw("same"); hist_Mbb_reg_fsr->Draw("same"); hist_Mbb->Draw("same"); TString leg_Mbb0 = "Nominal"; TString leg_Mbb_reg0 = "Regressed"; TString leg_Mbb_reg_fsr0 = "Regressed+FSR"; TString leg_Mbb = ""; TString leg_Mbb_reg = ""; TString leg_Mbb_reg_fsr = ""; TString leg_mean = "Mean="; TString leg_rms = ", RMS="; TString leg_mean = "#mu="; TString leg_rms = ", #sigma="; TString leg_ratio = ",#sigma/#mu="; TString temp_str; temp_str.Form("%2.1f",Mbb_mean); leg_Mbb.Append(leg_mean); leg_Mbb.Append(temp_str); leg_Mbb.Append(leg_rms); temp_str.Form("%2.1f",Mbb_rms); leg_Mbb.Append(temp_str); leg_Mbb.Append(leg_ratio); temp_str.Form("%2.2f",Mbb_rms/Mbb_mean); leg_Mbb.Append(temp_str); /////// temp_str.Form("%2.1f",Mbb_reg_mean); leg_Mbb_reg.Append(leg_mean); leg_Mbb_reg.Append(temp_str); leg_Mbb_reg.Append(leg_rms); temp_str.Form("%2.1f",Mbb_reg_rms); leg_Mbb_reg.Append(temp_str); leg_Mbb_reg.Append(leg_ratio); temp_str.Form("%2.2f",Mbb_reg_rms/Mbb_reg_mean); leg_Mbb_reg.Append(temp_str); //////// temp_str.Form("%2.1f",Mbb_reg_fsr_mean); leg_Mbb_reg_fsr.Append(leg_mean); leg_Mbb_reg_fsr.Append(temp_str); leg_Mbb_reg_fsr.Append(leg_rms); temp_str.Form("%2.1f",Mbb_reg_fsr_rms); leg_Mbb_reg_fsr.Append(temp_str); leg_Mbb_reg_fsr.Append(leg_ratio); temp_str.Form("%2.2f",Mbb_reg_fsr_rms/Mbb_reg_fsr_mean); leg_Mbb_reg_fsr.Append(temp_str); TLegend *leg = new TLegend(0.77,0.6,0.92,0.9); leg->SetFillColor(0); leg->SetBorderSize(0); leg->SetTextFont(42); leg->SetTextSize(0.025); leg->AddEntry(hist_Mbb,text_type,""); leg->AddEntry(hist_Mbb,leg_Mbb0,"L"); leg->AddEntry(hist_Mbb,leg_Mbb,""); leg->AddEntry(hist_Mbb_reg,leg_Mbb_reg0,"L"); leg->AddEntry(hist_Mbb_reg,leg_Mbb_reg,""); leg->AddEntry(hist_Mbb_reg_fsr,leg_Mbb_reg_fsr0,"L"); leg->AddEntry(hist_Mbb_reg_fsr,leg_Mbb_reg_fsr,""); leg->Draw("same"); c1->Print("plots/v14Mbb_regressed"+type+"_cmssw76.png"); return 0; }
void geugd_riordan() { gROOT->SetStyle("HALLA"); TCanvas *cn = new TCanvas("cn"); cn->Draw(); cn->UseCurrentStyle(); TH1F *frm = new TH1F("frm","",100,0.,12.); frm->GetXaxis()->SetTitle("Q^{2} [GeV^{2}]"); frm->GetXaxis()->CenterTitle(); frm->GetYaxis()->SetTitle("G_{E}^{u}/G_{D}"); frm->GetYaxis()->CenterTitle(); frm->SetMinimum(.40); frm->SetMaximum(2.4); //frm->SetMaximum(0.3); frm->UseCurrentStyle(); frm->Draw(); frm->SetAxisRange(0.10,12.,"X"); TF1* galster = new TF1("galster", "x/(4.*0.938*.938)*1.91/(1.+x/.71)^2/(1.+5.6*x/(4.*.938*.938))", 0.,4.); galster->SetLineColor(kBlack); galster->SetLineStyle(kBlack); galster->SetLineWidth(2); TF1* gen0 = new TF1("gen0", f1dugen0, 0.,12.); gen0->SetLineColor(kBlack); gen0->SetLineStyle(kBlack); gen0->SetLineWidth(1); TF1 *genf = new TF1("genf",genff,1.,10.,1); genf->SetLineColor(kBlue); genf->SetLineStyle(1); genf->SetParameter(0,1.); // match to Madey point just below 1.5 // genf->SetParameter(0,.0411/genf->Eval(1.45)); // genf->SetParameter(0,-0.558645); genf->SetParameter(0,-0.182645); TF1 *roberts_curve = new TF1("roberts",roberts_gen,0.035,12.344,1); roberts_curve->SetLineColor(kRed); roberts_curve->SetLineStyle(9); TF1 *ourfit = new TF1("ourfit",gen_ourfit,0.,10.,0); ourfit->SetLineColor(kBlue); ourfit->SetLineStyle(0); /* TF1 *bbba05 = new TF1("BBBA05",gen_bbba05,0.,10.,0); bbba05->SetLineColor(kGreen); bbba05->SetLineStyle(3); */ // TF1 *lomon = new TF1("Lomon",Lomon_GEn,0.,10.,0); // lomon->SetLineColor(7); // lomon->SetLineStyle(4); TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}"); //TLegend *legDta = new TLegend(.3448,.6123,.6810,.9110,"","brNDC"); TLegend *legDta = new TLegend(.6020,.4004,.9382,.9089,"","brNDC"); TMultiGraph* wgr = mgrDta; TLegend *wlg = legDta; // the data legDta->SetBorderSize(0); // turn off border legDta->SetFillStyle(0); datafile_t *f = datafiles; TGraph* gr=0; TGraph* ogr=0; while ( f && f->filename ) { ogr=OneGraph(f); if (ogr) { gr = fromGEntransform(ogr); gr->SetLineStyle(0); if (f->lnpt) { mgrDta->Add(gr,f->lnpt); if( f->label[0] != 'x' ) legDta->AddEntry(gr,f->label,f->lnpt); } mgrDta->Add(gr,"p"); if( f->label[0] != 'x' ) legDta->AddEntry(gr,f->label,"p"); /* else if (gr->GetMarkerStyle()>=20) { mgrDta->Add(gr,"p"); if( f->label[0] != 'x' ) legDta->AddEntry(gr,f->label,"p"); } else { mgrDta->Add(gr,"l"); if( f->label[0] != 'x' ) legDta->AddEntry(gr,f->label,"l"); } */ } f++; } mgrDta->Draw("p"); legDta->Draw(); TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}"); // TLegend *legThry = new TLegend(.546,.6208,.8822,.9195,"","brNDC"); // TLegend *legThry = new TLegend(.2055,.7013,.6020,.8893,"","brNDC"); TLegend *legThry = new TLegend(.4267,.8453,.6236,.8962,"","brNDC"); wgr = mgrThry; wlg = legThry; // the theory wlg->SetBorderSize(0); // turn off border wlg->SetFillStyle(0); f = theoryfiles1; gr=0; Bool_t isfill; while ( f && f->filename ) { gr=OneGraph(f); gr->SetLineWidth(2); isfill = kFALSE; if (gr) { TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr); if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) { gr = toerror_band(egr); gr->SetFillStyle(3000+f->style); gr->SetFillStyle(1); gr->SetFillColor(gr->GetLineColor()); isfill = kTRUE; } if (f->lnpt) { wgr->Add(gr,f->lnpt); if( f->label[0] != 'x' ) wlg->AddEntry(gr,f->label,f->lnpt); } else if (gr->GetMarkerStyle()>=20) { wgr->Add(gr,"p"); if( f->label[0] != 'x' ) wlg->AddEntry(gr,f->label,"p"); } else { if( isfill ){ gr->SetLineStyle(0); wgr->Add(gr,"f"); // wgr->Add( new TGraph(*egr),"l"); if( f->label[0] != 'x' ) wlg->AddEntry(gr,f->label,"lf"); } else { wgr->Add(gr,"l"); if( f->label[0] != 'x' ) wlg->AddEntry(gr,f->label,"l"); } } } f++; } TPaveLabel *prelim = new TPaveLabel( 0.3204, 0.1886, 0.9310, 0.4643, "PRELIMINARY", "NDC" ); prelim->SetTextAngle(0); TColor *pink = new TColor(300, 1.0, 0.7, 0.7, "pink"); prelim->SetTextColor(300); prelim->SetFillStyle(0); prelim->SetBorderSize(0); #ifdef FAKE_SCHIAVILLA TGraph *schiagraph = draw_schiavilla(); schiagraph->Draw("F"); schiagraph = draw_schiavilla(1); schiagraph->Draw("C"); legThry->AddEntry(schiagraph, "d(e,e'd) T_{20} - Schiavilla & Sick", "LF"); #endif #ifdef PRELIMINARY prelim->Draw("same"); #endif TPaveLabel *nofsilab = new TPaveLabel( 0.4569, 0.1674, 0.7514, 0.2415, "No FSI Corrections", "NDC" ); nofsilab->SetFillStyle(0); nofsilab->SetBorderSize(0); nofsilab->SetTextColor(kRed); #ifdef NOFSI // nofsilab->Draw("same"); #endif #ifdef PQCD genf->Draw("same"); #endif mgrThry->Draw("c"); #ifdef GALSTER galster->Draw("same"); #endif // gen0->Draw("same"); #ifdef NEW_ROBERTS roberts_curve->Draw("same"); #endif // ourfit->Draw("same"); // bbba05->Draw("same"); //lomon->Draw("same"); // bandi->Draw("same"); #ifdef PQCD legThry->AddEntry(genf,"F_{2}/F_{1} #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l"); #endif #ifdef GALSTER legThry->AddEntry(galster,"Galster fit (1971)","l"); #endif // legThry->AddEntry(gen0,"G_{E}^{n} = 0","l"); #ifdef NEW_ROBERTS legThry->AddEntry(roberts_curve,"q(qq) Faddeev - I. Cloet, ANL","l"); #endif // legThry->AddEntry(bbba05,"BBBA05","l"); // legThry->AddEntry(lomon, "Lomon", "l"); // legThry->AddEntry(ourfit, "Our Fit", "l"); legThry->Draw(); legDta->Draw(); mgrDta->Draw("p"); legDta->Draw(); TEllipse *cir1 = new TEllipse(1.31, 0.0, 0.17, 0.0065); TEllipse *cir2 = new TEllipse(2.4, 0.0, 0.17, 0.0065); cir1->SetFillStyle(0); cir2->SetFillStyle(0); #ifdef PLOTKIN1 cir1->Draw("same"); // cir2->Draw("same"); // TPaveLabel *exacc = new TPaveLabel( 0.3779, 0.2691, 0.5963, 0.3114, "Expected Accuracy", "NDC"); TPaveLabel *exacc = new TPaveLabel( 0.2716, 0.2733, 0.4899, 0.3136, "Expected Accuracy", "NDC"); exacc->SetFillStyle(0); exacc->SetBorderSize(0); exacc->Draw("same"); #endif // draw a line at 1 cn->Modified(); cn->Update(); cn->SaveAs(Form("%s.pdf",psfile)); cn->SaveAs(Form("%s.eps",psfile)); // cn->SaveAs(Form("%s.root",psfile)); // gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile)); // cn->SaveAs("bogdan_gen.eps"); return; // LEAVING HERE // now an overlay, hopefully matching dimensions // remove everything but the graph cn->Update(); TList *clist = cn->GetListOfPrimitives(); TFrame* frame = cn->GetFrame(); for (int i=0; i<clist->GetSize(); ) { if (clist->At(i) != frame) { clist->RemoveAt(i); } else i++; } // draw markers in the corners TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2); mkr->Draw(); mkr = new TMarker(frame->GetX2(),frame->GetY1(),2); mkr->Draw(); mkr = new TMarker(frame->GetX1(),frame->GetY2(),2); mkr->Draw(); mkr = new TMarker(frame->GetX2(),frame->GetY2(),2); mkr->Draw(); frame->SetLineColor(10); cn->Update(); datafile_t miller = { "figure_input/Miller/lattice.GEn.rtf","Miller", "[0]","[1]","[1]-[3]","[2]-[1]",0,0,1,3,"F" }; gr = OneGraph(&miller); TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr); if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) { gr = toerror_band(egr); gr->SetLineStyle(1); gr->SetFillColor(gr->GetLineColor()); gr->SetFillStyle(3000+miller.style); } gr->Draw("F"); cn->Update(); cn->SaveAs("gen_Miller_Overlay.pdf"); cn->SaveAs("gen_Miller_Overlay.root"); }
TF1* fit(Double_t ptmin, Double_t ptmax) { TCanvas* c = new TCanvas(Form("c_%.0f_%.0f",ptmin,ptmax),"",600,600); TFile* infile = new TFile(Form("%s_%s_%.0f_%.0f.root",infname.Data(),collisionsystem.Data(),ptmin,ptmax)); TH1D* h = (TH1D*)infile->Get("h"); h->SetName(Form("h_%.0f_%.0f",ptmin,ptmax)); TH1D* hMCSignal = (TH1D*)infile->Get("hMCSignal"); hMCSignal->SetName(Form("hMCSignal_%.0f_%.0f",ptmin,ptmax)); TH1D* hMCSwapped = (TH1D*)infile->Get("hMCSwapped"); hMCSwapped->SetName(Form("hMCSwapped_%.0f_%.0f",ptmin,ptmax)); TF1* f = new TF1(Form("f_%.0f_%.0f",ptmin,ptmax),"[0]*([7]*([9]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[9])*Gaus(x,[1],[10])/(sqrt(2*3.14159)*[10]))+(1-[7])*Gaus(x,[1],[8])/(sqrt(2*3.14159)*[8]))+[3]*exp([4]*x)", 1.7, 2.0); f->SetParLimits(10,0.001,0.05); f->SetParLimits(2,0.01,0.1); f->SetParLimits(8,0.02,0.2); f->SetParLimits(7,0,1); f->SetParLimits(9,0,1); f->SetParameter(0,setparam0); f->SetParameter(1,setparam1); f->SetParameter(2,setparam2); f->SetParameter(10,setparam10); f->SetParameter(9,setparam9); f->FixParameter(8,setparam8); f->FixParameter(7,1); f->FixParameter(1,fixparam1); f->FixParameter(3,0); f->FixParameter(4,0); h->GetEntries(); hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto); hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto); f->ReleaseParameter(1); hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto); hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto); hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto); f->FixParameter(1,f->GetParameter(1)); f->FixParameter(2,f->GetParameter(2)); f->FixParameter(10,f->GetParameter(10)); f->FixParameter(9,f->GetParameter(9)); f->FixParameter(7,0); f->ReleaseParameter(8); f->SetParameter(8,setparam8); hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto); f->SetParLimits(0,0,1.e+6); f->FixParameter(7,hMCSignal->Integral(0,1000)/(hMCSwapped->Integral(0,1000)+hMCSignal->Integral(0,1000))); f->FixParameter(8,f->GetParameter(8)); f->ReleaseParameter(3); f->ReleaseParameter(4); f->SetParLimits(3,0,1.e+10); f->SetParameter(3,1.e+3); f->SetLineColor(kRed); h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto); f->ReleaseParameter(1); f->SetParLimits(1,1.85,1.90); //f->ReleaseParameter(2); // you need to release these two parameters if you want to perform studies on the sigma shape //f->ReleaseParameter(10); // you need to release these two parameters if you want to perform studies on the sigma shape h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto); TF1* background = new TF1(Form("background_%.0f_%.0f",ptmin,ptmax),"[0]*exp([1]*x)"); background->SetParameter(0,f->GetParameter(3)); background->SetParameter(1,f->GetParameter(4)); background->SetLineColor(4); background->SetRange(minhisto,maxhisto); background->SetLineStyle(2); TF1* mass = new TF1(Form("fmass_%.0f_%.0f",ptmin,ptmax),"[0]*([3]*([4]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[4])*Gaus(x,[1],[5])/(sqrt(2*3.14159)*[5])))"); mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(9),f->GetParameter(10)); mass->SetParError(0,f->GetParError(0)); mass->SetParError(1,f->GetParError(1)); mass->SetParError(2,f->GetParError(2)); mass->SetParError(3,f->GetParError(7)); mass->SetParError(4,f->GetParError(9)); mass->SetParError(5,f->GetParError(10)); mass->SetFillColor(kOrange-3); mass->SetFillStyle(3002); mass->SetLineColor(kOrange-3); mass->SetLineWidth(3); mass->SetLineStyle(2); TF1* massSwap = new TF1(Form("fmassSwap_%.0f_%.0f",ptmin,ptmax),"[0]*(1-[2])*Gaus(x,[1],[3])/(sqrt(2*3.14159)*[3])"); massSwap->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(7),f->GetParameter(8)); massSwap->SetParError(0,f->GetParError(0)); massSwap->SetParError(1,f->GetParError(1)); massSwap->SetParError(2,f->GetParError(7)); massSwap->SetParError(3,f->GetParError(8)); massSwap->SetFillColor(kGreen+4); massSwap->SetFillStyle(3005); massSwap->SetLineColor(kGreen+4); massSwap->SetLineWidth(3); massSwap->SetLineStyle(1); h->SetXTitle("m_{#piK} (GeV/c^{2})"); h->SetYTitle("Entries / (5 MeV/c^{2})"); h->GetXaxis()->CenterTitle(); h->GetYaxis()->CenterTitle(); h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y"); h->GetXaxis()->SetTitleOffset(1.3); h->GetYaxis()->SetTitleOffset(1.8); h->GetXaxis()->SetLabelOffset(0.007); h->GetYaxis()->SetLabelOffset(0.007); h->GetXaxis()->SetTitleSize(0.045); h->GetYaxis()->SetTitleSize(0.045); h->GetXaxis()->SetTitleFont(42); h->GetYaxis()->SetTitleFont(42); h->GetXaxis()->SetLabelFont(42); h->GetYaxis()->SetLabelFont(42); h->GetXaxis()->SetLabelSize(0.04); h->GetYaxis()->SetLabelSize(0.04); h->SetMarkerSize(0.8); h->SetMarkerStyle(20); h->SetStats(0); h->Draw("e"); background->Draw("same"); mass->SetRange(minhisto,maxhisto); mass->Draw("same"); massSwap->SetRange(minhisto,maxhisto); massSwap->Draw("same"); f->Draw("same"); Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass; Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0); std::cout<<"YIELD="<<yield<<std::endl; TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->SetFillStyle(0); leg->AddEntry(h,"Data","pl"); leg->AddEntry(f,"Fit","l"); leg->AddEntry(mass,"D^{0}+#bar{D^{#lower[0.2]{0}}} Signal","f"); leg->AddEntry(massSwap,"K-#pi swapped","f"); leg->AddEntry(background,"Combinatorial","l"); leg->Draw("same"); TLatex* texCms = new TLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary"); texCms->SetNDC(); texCms->SetTextAlign(12); texCms->SetTextSize(0.04); texCms->SetTextFont(42); texCms->Draw(); TLatex* texCol = new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV",collisionsystem.Data())); texCol->SetNDC(); texCol->SetTextAlign(32); texCol->SetTextSize(0.04); texCol->SetTextFont(42); texCol->Draw(); TLatex* texPt = new TLatex(0.22,0.78,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax)); texPt->SetNDC(); texPt->SetTextFont(42); texPt->SetTextSize(0.04); texPt->SetLineWidth(2); texPt->Draw(); TLatex* texY = new TLatex(0.22,0.83,"|y| < 1.0"); texY->SetNDC(); texY->SetTextFont(42); texY->SetTextSize(0.04); texY->SetLineWidth(2); texY->Draw(); TLatex* texYield = new TLatex(0.22,0.73,Form("N_{D} = %.0f #pm %.0f",yield,yieldErr)); texYield->SetNDC(); texYield->SetTextFont(42); texYield->SetTextSize(0.04); texYield->SetLineWidth(2); texYield->Draw(); c->SaveAs(Form("plotFits/DMass_expo_%s_%.0f_%.0f.pdf",collisionsystem.Data(),ptmin,ptmax)); TCanvas* cPull = new TCanvas(Form("cPull_%.0f_%.0f",ptmin,ptmax),"",600,700); TH1D* hPull = (TH1D*)h->Clone("hPull"); for(int i=0;i<h->GetNbinsX();i++) { Double_t nfit = f->Integral(h->GetBinLowEdge(i+1),h->GetBinLowEdge(i+1)+h->GetBinWidth(i+1))/h->GetBinWidth(i+1); if(h->GetBinError(i+1)==0) { hPull->SetBinContent(i+1,0.); } else hPull->SetBinContent(i+1,(h->GetBinContent(i+1)-nfit)/h->GetBinError(i+1)); hPull->SetBinError(i+1,0); } hPull->SetMinimum(-4.); hPull->SetMaximum(4.); hPull->SetYTitle("Pull"); hPull->GetXaxis()->SetTitleOffset(1.); hPull->GetYaxis()->SetTitleOffset(0.65); hPull->GetXaxis()->SetLabelOffset(0.007); hPull->GetYaxis()->SetLabelOffset(0.007); hPull->GetXaxis()->SetTitleSize(0.12); hPull->GetYaxis()->SetTitleSize(0.12); hPull->GetXaxis()->SetLabelSize(0.1); hPull->GetYaxis()->SetLabelSize(0.1); hPull->GetYaxis()->SetNdivisions(504); TLine* lPull = new TLine(1.7, 0, 2., 0); lPull->SetLineWidth(1); lPull->SetLineStyle(7); lPull->SetLineColor(1); TPad* pFit = new TPad("pFit","",0,0.3,1,1); pFit->SetBottomMargin(0); pFit->Draw(); pFit->cd(); h->Draw("e"); background->Draw("same"); mass->Draw("same"); massSwap->Draw("same"); f->Draw("same"); leg->Draw("same"); texCms->Draw(); texCol->Draw(); texPt->Draw(); texY->Draw(); texYield->Draw(); cPull->cd(); TPad* pPull = new TPad("pPull","",0,0,1,0.3); pPull->SetTopMargin(0); pPull->SetBottomMargin(0.3); pPull->Draw(); pPull->cd(); hPull->Draw("p"); lPull->Draw(); cPull->cd(); cPull->SaveAs(Form("plotFits/DMass_expo_%s_%.0f_%.0f_Pull.pdf",collisionsystem.Data(),ptmin,ptmax)); return mass; }
void MakeMinvMix(Int_t cen=6){ TFile fout("raw_MBmix.root","update") ; TFile * f = new TFile("LHC13bc_MB.root") ; //result of data scan TH1F * hev = (TH1F*)f->Get("hSelEvents") ; TH1F * hCentrality1 = (TH1F*)f->Get("hCentrality") ; printf("TotSelEvents: %f \n",hev->GetBinContent(7)) ; printf("Centrality: %f \n",hCentrality1->Integral()) ; Int_t nbin=33 ; Double_t xa[34] ={0.8,1.0,1.2,1.4,1.6, 1.8,2.0,2.2,2.4,2.6, 2.8,3.0,3.2,3.4,3.6, 3.8,4.0,4.5,5.0,5.5, 6.,7.,8.,10.,12.,16.,20.,22., 24.,26.,28.,30.,35., 40.}; // Int_t nbin=26 ; // Double_t xa[27] ={0.8,1.0,1.2,1.4,1.6, 1.8,2.0,2.2,2.4,2.6, 2.8,3.0,3.2,3.4,3.6, 3.8,4.0,4.5,5.0,5.5, 6.,7.,8.,10.,12.,16.,20.}; const Int_t nPID=4 ; char cPID[14][15] ; snprintf(cPID[0],15,"Emin3_All") ; snprintf(cPID[1],15,"Emin3_Disp"); snprintf(cPID[2],15,"Emin3_CPV") ; snprintf(cPID[3],15,"Emin3_Both"); TH2F * hRe[20] ; TH2F * hMi[20] ; TH2F * tmp = 0x0 ; if(cen==6){ //6:0-20, 7:0-10 for(Int_t iPID=0;iPID<nPID;iPID++){ hRe[iPID] = (TH2F*)f->Get(Form("hInvM_Re_%s_cent0",cPID[iPID])) ; tmp = (TH2F*)f->Get(Form("hInvM_Re_%s_cent1",cPID[iPID])) ; hRe[iPID]->Add(tmp) ;delete tmp ; tmp = (TH2F*)f->Get(Form("hInvM_Re_%s_cent2",cPID[iPID])) ; hRe[iPID]->Add(tmp) ;delete tmp ; tmp = (TH2F*)f->Get(Form("hInvM_Re_%s_cent3",cPID[iPID])) ; hRe[iPID]->Add(tmp) ;delete tmp ; tmp = (TH2F*)f->Get(Form("hInvM_Re_%s_cent4",cPID[iPID])) ; hRe[iPID]->Add(tmp) ;delete tmp ; hRe[iPID]->Sumw2() ; hMi[iPID] = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent0",cPID[iPID])) ; tmp = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent1",cPID[iPID])) ; hMi[iPID]->Add(tmp) ;delete tmp ; tmp = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent2",cPID[iPID])) ; hMi[iPID]->Add(tmp) ;delete tmp ; tmp = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent3",cPID[iPID])) ; hMi[iPID]->Add(tmp) ;delete tmp ; tmp = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent4",cPID[iPID])) ; hMi[iPID]->Add(tmp) ;delete tmp ; hMi[iPID]->Sumw2() ; } } else{ for(Int_t iPID=0;iPID<nPID;iPID++){ hRe[iPID] = (TH2F*)f->Get(Form("hInvM_Re_%s_cent%d",cPID[iPID],cen)) ; hRe[iPID]->Sumw2() ; hMi[iPID] = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent%d",cPID[iPID],cen)) ; hMi[iPID]->Sumw2() ; } } PPRstyle(); gStyle->SetPadLeftMargin(0.14); gStyle->SetPadRightMargin(0.01); gStyle->SetPadTopMargin(0.01); gStyle->SetPadBottomMargin(0.08); //Gaus TH1D *mr1[nPID],*sr1[nPID],*nr1[nPID],*nr1int[nPID] ; for(Int_t iPID=0;iPID<nPID;iPID++){ mr1[iPID] = new TH1D(Form("mass1_GS_%s_cen%d",cPID[iPID],cen),"Mass",nbin,xa) ; sr1[iPID] = new TH1D(Form("width1_GS_%s_cen%d",cPID[iPID],cen),"Width",nbin,xa) ; nr1[iPID] = new TH1D(Form("yeild1_GS_%s_cen%d",cPID[iPID],cen),"Raw yield",nbin,xa) ; nr1int[iPID] = new TH1D(Form("yeild1_int_GS_%s_cen%d",cPID[iPID],cen),"Raw yield, integrated",nbin,xa) ; } //CB TH1D *mr2[nPID],*sr2[nPID],*nr2[nPID],*nr2int[nPID] ; for(Int_t iPID=0;iPID<nPID;iPID++){ mr2[iPID] = new TH1D(Form("mass2_CB_%s_cen%d",cPID[iPID],cen),"Mass",nbin,xa) ; sr2[iPID] = new TH1D(Form("width2_CB_%s_cen%d",cPID[iPID],cen),"Width",nbin,xa) ; nr2[iPID] = new TH1D(Form("yeild2_CB_%s_cen%d",cPID[iPID],cen),"Raw yield",nbin,xa) ; nr2int[iPID] = new TH1D(Form("yeild2_int_CB_%s_cen%d",cPID[iPID],cen),"Raw yield, integrated",nbin,xa) ; } TF1 * fun1 = new TF1("ft1",CB1,0.,1.,8) ; fun1->SetParName(0,"A") ; fun1->SetParName(1,"m_{0}") ; fun1->SetParName(2,"#sigma") ; fun1->SetParName(3,"n") ; fun1->SetParName(4,"#alpha") ; fun1->SetParName(5,"a_{0}") ; fun1->SetParName(6,"a_{1}") ; fun1->SetParName(7,"a_{2}") ; fun1->FixParameter(3,3.28) ; fun1->FixParameter(4,1.56) ; fun1->SetLineWidth(2) ; fun1->SetLineColor(4) ; fun1->SetLineStyle(2) ; TF1 * fun2 = new TF1("ft2",CB2,0.,1.,9) ; fun2->SetParName(0,"A") ; fun2->SetParName(1,"m_{0}") ; fun2->SetParName(2,"#sigma") ; fun2->SetParName(3,"n") ; fun2->SetParName(4,"#alpha") ; fun2->SetParName(5,"a_{0}") ; fun2->SetParName(6,"a_{1}") ; fun2->SetParName(7,"a_{2}") ; fun2->SetParName(8,"a_{3}") ; fun2->FixParameter(3,3.28) ; fun2->FixParameter(4,1.56) ; fun2->SetLineWidth(2) ; fun2->SetLineColor(4) ; fun2->SetLineStyle(2) ; TF1 * funGS1 = new TF1("ft1",GS1,0.,1.,6) ; funGS1->SetParName(0,"A") ; funGS1->SetParName(1,"m_{0}") ; funGS1->SetParName(2,"#sigma") ; funGS1->SetParName(3,"a_{0}") ; funGS1->SetParName(4,"a_{1}") ; funGS1->SetParName(5,"a_{2}") ; funGS1->SetLineWidth(2) ; funGS1->SetLineColor(8) ; // funGS1->SetLineStyle(2) ; TF1 * funGS2 = new TF1("ft2",GS2,0.,1.,7) ; funGS2->SetParName(0,"A") ; funGS2->SetParName(1,"m_{0}") ; funGS2->SetParName(2,"#sigma") ; funGS2->SetParName(3,"a_{0}") ; funGS2->SetParName(4,"a_{1}") ; funGS2->SetParName(5,"a_{2}") ; funGS2->SetParName(6,"a_{3}") ; funGS2->SetLineWidth(2) ; funGS2->SetLineColor(8) ; // funGS2->SetLineStyle(2) ; TF1 * fit1=0x0 ; TF1 * fit2=0x0 ; TF1 * fbgP0 = new TF1("bg",BG,0.,1.,2) ; TF1 * fbgP1 = new TF1("bg1",BG1,0.,1.,3) ; TF1 * fbgP2 = new TF1("bg2",BG2,0.,1.,4) ; TF1 * fbg1=0x0 ; TF1 * fbg2=0x0 ; TF1 * fgs = new TF1("gs",GSs,0.,1.,4) ; TF1 * fcb = new TF1("cb",CBs,0.,1.,6) ; fgs->SetLineColor(8) ; fgs->SetLineWidth(2) ; fcb->SetLineColor(4) ; fcb->SetLineWidth(2) ; fcb->SetLineStyle(2) ; fcb->FixParameter(3,3.28) ; fcb->FixParameter(4,1.56) ; TCanvas * c1[nPID] ; TCanvas * c2[nPID] ; TCanvas * c1b[nPID] ; TCanvas * c2b[nPID] ; for(Int_t iPID=0;iPID<nPID;iPID++){ c1[iPID] = new TCanvas(Form("Ratio_%s",cPID[iPID]),Form("Ratio_%s",cPID[iPID]),10+10*iPID,10,1200+10*iPID,800) ; c1[iPID]->Divide(4,4) ; c2[iPID] = new TCanvas(Form("Signal_%s",cPID[iPID]),Form("Signal_%s",cPID[iPID]),10+10*iPID,10,1200+10*iPID,800) ; c2[iPID]->Divide(4,4) ; c1b[iPID] = new TCanvas(Form("RatioB_%s",cPID[iPID]),Form("Ratio_%s",cPID[iPID]),10+10*iPID,10,1200+10*iPID,800) ; c1b[iPID]->Divide(4,3) ; c2b[iPID] = new TCanvas(Form("SignalB_%s",cPID[iPID]),Form("Signal_%s",cPID[iPID]),10+10*iPID,10,1200+10*iPID,800) ; c2b[iPID]->Divide(4,3) ; } c1[0]->cd(0) ; TAxis * pta=hRe[0]->GetYaxis() ; TAxis * ma=hRe[0]->GetXaxis() ; for(Int_t i=1;i<=nbin;i++){ Int_t imin=pta->FindBin(xa[i-1]+0.0001); Int_t imax=pta->FindBin(xa[i]-0.0001) ; TH1D *hp; Double_t pt=(xa[i]+xa[i-1])/2. ; for(Int_t iPID=0;iPID<nPID;iPID++){ if(i<17) c1[iPID]->cd(i) ; else c1b[iPID]->cd(i-16) ; hp = hRe[iPID]->ProjectionX(Form("re%d_%d",i,iPID),imin,imax) ; // hp->Sumw2() ; hpm= hMi[iPID]->ProjectionX(Form("mi%d_%d",i,iPID),imin,imax) ; // hpm->Sumw2() ; if(pt>12.){ hp ->Rebin(2) ; hpm->Rebin(2) ; } if(pt<2.){ //2pol,3pol fit1=funGS2 ; fit2=fun2 ; fbg1=fbgP2 ; fbg2=fbgP2 ; } else{ //pol1,pol2 fit1=funGS1 ; fit2=fun1 ; fbg1=fbgP1 ; fbg2=fbgP1 ; } // for(Int_t ib=1; ib<=hp->GetNbinsX();ib++){if(hp ->GetBinContent(ib)==0)hp ->SetBinError(ib,1.);} // for(Int_t ib=1; ib<=hp->GetNbinsX();ib++){if(hpm->GetBinContent(ib)==0)hpm->SetBinError(ib,1.);} TH1D * hpm2 = (TH1D*)hpm->Clone(Form("Bg1_%d",iPID)) ; TH1D * hpcopy = (TH1D*)hp ->Clone(Form("hpcopy_%d",iPID)) ; TH1D * hp2 = (TH1D*)hp ->Clone(Form("hp2_%d",iPID)) ; hpcopy->SetXTitle("M_{#gamma#gamma} (GeV/c^{2})"); hp2 ->SetXTitle("M_{#gamma#gamma} (GeV/c^{2})"); hpcopy->Divide(hpm) ; hpcopy->SetTitle(Form("%3.1f<p_{T}<%3.1f GeV/c",xa[i-1],xa[i])) ; hpcopy->SetMarkerStyle(20) ; hpcopy->SetMarkerSize(0.7) ; hpcopy->GetXaxis()->SetRangeUser(0.05,0.25) ; // fit1->SetParameters(0.0002+0.0001*i*i,0.136,0.011,0.0002,-0.002,0.0) ; fit1->SetParameters(0.0002+0.0001*i*i,0.136,0.005,0.0002,-0.002,0.0) ; // fit1->SetParameters(0.0002,0.136,0.011,0.0002,-0.002,0.0) ; if(cen==0) fit1->SetParameters(0.001,0.146,0.005,0.12,-0.002,0.0) ; fit1->SetParLimits(0,0.000,2.*hpcopy->GetMaximum()) ; fit1->SetParLimits(1,0.125,0.145) ; fit1->SetParLimits(2,0.0045,0.010) ; Double_t rangeMin=0.07 ;//TMath::Max(0.06,0.11-0.01*i) ; Double_t rangeMax=0.22; //TMath::Min(0.25,0.18+0.01*i) ; // if(pt>10){ // rangeMax=0.18; // rangeMin=0.10; // } // Double_t rangeMin=TMath::Max(0.06,0.12-0.01*i) ; // Double_t rangeMax=TMath::Min(0.25,0.16+0.01*i) ; hpcopy->Fit(fit1,"Q","",rangeMin,rangeMax) ; hpcopy->Fit(fit1,"MQ","",rangeMin,rangeMax) ; fit2->SetParameters(fit1->GetParameters()) ; fit2->SetParameter(3,3.2) ; fit2->SetParameter(4,1.56) ; fit2->SetParameter(5,fit1->GetParameter(3)) ; fit2->SetParameter(6,fit1->GetParameter(4)) ; fit2->SetParameter(7,fit1->GetParameter(5)) ; fit2->SetParLimits(0,0.000,2.*hpcopy->GetMaximum()) ; fit2->SetParLimits(1,0.125,0.145) ; fit2->SetParLimits(2,0.0045,0.010) ; hpcopy->Fit(fit2,"+QN","",rangeMin,rangeMax) ; hpcopy->Fit(fit2,"+MQ","",rangeMin,rangeMax) ; c1[iPID]->cd(i) ; hpcopy->Draw() ; if(i<17) c1[iPID]->Update() ; else c1b[iPID]->Update() ; if(i<17) c2[iPID]->cd(i) ; else c2b[iPID]->cd(i-16) ; fbg1->SetParameters(fit1->GetParameter(3),fit1->GetParameter(4),fit1->GetParameter(5),fit1->GetParameter(6)); fbg2->SetParameters(fit2->GetParameter(5),fit2->GetParameter(6),fit2->GetParameter(7),fit2->GetParameter(8)); Double_t intRangeMin = PeakPosition(pt)-3.*PeakWidth(pt) ; Double_t intRangeMax = PeakPosition(pt)+3.*PeakWidth(pt) ; Int_t intBinMin = hp->GetXaxis()->FindBin(intRangeMin) ; Int_t intBinMax = hp->GetXaxis()->FindBin(intRangeMax) ; Double_t errStat = hpm->Integral(intBinMin,intBinMax); hpm ->Multiply(fbg1) ; hpm2->Multiply(fbg2) ; if(pt<10.){ hp ->Add(hpm ,-1.) ; hp2 ->Add(hpm2,-1.) ; } Int_t binPi0 = hp->FindBin(kMean); fgs->SetParameters(hp->Integral(binPi0-1,binPi0+1)/3.,fit1->GetParameter(1),0.006) ; fgs->SetParLimits(0,0.000,10.*hp->GetMaximum()) ; fgs->SetParLimits(1,0.120,0.175) ; fgs->SetParLimits(2,0.0055,0.010) ; hp->Fit(fgs,"QL","",rangeMin,rangeMax) ; hp->Fit(fgs,"QML","",rangeMin,rangeMax) ; hp->SetMaximum(hp->GetMaximum()*1.4) ; hp->SetMinimum(hp->GetMinimum()*1.1) ; hp->SetMarkerStyle(20) ; hp->SetMarkerSize(0.7) ; mr1[iPID]->SetBinContent(i,fgs->GetParameter(1)) ; mr1[iPID]->SetBinError (i,fgs->GetParError(1) ) ; sr1[iPID]->SetBinContent(i,TMath::Abs(fgs->GetParameter(2))) ; sr1[iPID]->SetBinError (i,fgs->GetParError(2) ) ; Double_t y=fgs->GetParameter(0)/hp->GetXaxis()->GetBinWidth(1) ; nr1[iPID]->SetBinContent(i,y) ; Double_t ey=fgs->GetParError(0)/hp->GetXaxis()->GetBinWidth(1) ; nr1[iPID]->SetBinError(i,ey) ; Double_t npiInt = hp->Integral(intBinMin,intBinMax)-(intBinMax-intBinMin)*fgs->GetParameter(3) ; Double_t norm = fbg1->GetParameter(0) ; Double_t normErr= fbg1->GetParError(0) ; if(npiInt>0.){ nr1int[iPID]->SetBinContent(i,npiInt) ; nr1int[iPID]->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; } //printf(" Nint1 =%f+-%f \n",npiInt,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; hp2->GetXaxis()->SetRangeUser(rangeMin,rangeMax) ; hp2->SetMaximum(hp2->GetMaximum()*1.4) ; hp2->SetMinimum(hp2->GetMinimum()*1.1) ; hp2->SetMarkerStyle(24) ; hp2->SetMarkerSize(0.8) ; fcb->SetParameters(hp->Integral(binPi0-1,binPi0+1)/3.,fit2->GetParameter(1),0.006,fit2->GetParameter(3),fit2->GetParameter(4)) ; fcb->SetParLimits(0,0.000,10.*hp->GetMaximum()) ; fcb->SetParLimits(1,0.120,0.175) ; fcb->SetParLimits(2,0.005,0.010) ; hp2->Fit(fcb,"QL","",rangeMin,rangeMax) ; hp2->Fit(fcb,"QML","",rangeMin,rangeMax) ; mr2[iPID]->SetBinContent(i,fcb->GetParameter(1)) ; mr2[iPID]->SetBinError (i,fcb->GetParError(1)) ; sr2[iPID]->SetBinContent(i,TMath::Abs(fcb->GetParameter(2))) ; sr2[iPID]->SetBinError (i,fcb->GetParError(2)) ; y=(fcb->Integral(0.05,0.25)-fcb->GetParameter(5)*(0.25-0.05))/hp->GetXaxis()->GetBinWidth(1) ; nr2[iPID]->SetBinContent(i,y) ; Double_t ey=fcb->IntegralError(0.05,0.25)/hp->GetXaxis()->GetBinWidth(1) ; nr2[iPID]->SetBinError(i,ey) ; npiInt=hp2->Integral(intBinMin,intBinMax)-(intBinMax-intBinMin)*fgs->GetParameter(3) ; norm=fbg2->GetParameter(0) ; normErr=fbg2->GetParError(0) ; if(npiInt>0.){ nr2int[iPID]->SetBinContent(i,npiInt) ; nr2int[iPID]->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; } //printf(" Nint2 =%f+-%f \n",npiInt,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ; hp2->SetTitle(Form("%3.1f<p_{T}<%3.1f GeV/c",xa[i-1],xa[i])) ; hp2->Draw() ; hp->SetMarkerColor(6) ; hp->Draw("same") ; hp2->Draw("same") ; c2[iPID]->Update() ; // delete hp ; // delete hp2 ; // delete hpcopy ; delete hpm ; // delete hpm2 ; } } /* for(Int_t iPID=0; iPID<4; iPID++){ c1[iPID]->Print(Form("Ratio_%s_cen%d.eps",cPID[iPID],cen)) ; c2[iPID]->Print(Form("Signal_%s_cen%d.eps",cPID[iPID],cen)) ; } */ //Normalize by the number of events Int_t cMin,cMax; if (cen == 0) { cMin=1; cMax=20; } else if (cen == 1) { cMin=21; cMax=40; } else if (cen == 2) { cMin=41; cMax=60; } else if (cen == 3) { cMin=61; cMax=80; } else if (cen == 4) { cMin=81; cMax=100; } else if (cen == 5) { cMin=61; cMax=80; } else if (cen == 6) { cMin=1; cMax=100; } else if (cen == 7) { cMin=1; cMax=10; } else if (cen == 8) { cMin=41; cMax=80; } else if (cen == 9) { cMin=1; cMax=40; } Double_t nevents = hCentrality1->Integral(cMin,cMax); printf("Nevents=%f \n",nevents) ; for(Int_t iPID=0;iPID<nPID;iPID++){ nr1[iPID] ->Scale(1./nevents) ; nr1int[iPID]->Scale(1./nevents) ; nr2[iPID] ->Scale(1./nevents) ; nr2int[iPID]->Scale(1./nevents) ; nr1[iPID]->SetMarkerStyle(20) ; nr1[iPID]->SetMarkerColor(2) ; nr1[iPID]->SetTitle("#pi^{0} raw yield per event") ; nr2[iPID]->SetTitle("#pi^{0} raw yield per event") ; } fout.cd() ; for(Int_t iPID=0;iPID<nPID;iPID++){ nr1[iPID]->Write(0,TObject::kOverwrite) ; nr2[iPID]->Write(0,TObject::kOverwrite) ; nr1int[iPID]->Write(0,TObject::kOverwrite) ; nr2int[iPID]->Write(0,TObject::kOverwrite) ; mr1[iPID]->Write(0,TObject::kOverwrite) ; mr2[iPID]->Write(0,TObject::kOverwrite) ; sr1[iPID]->Write(0,TObject::kOverwrite) ; sr2[iPID]->Write(0,TObject::kOverwrite) ; } fout.Close() ; }
void TriggerEfficienciesSF(TString datafile, TString mcfile, TString ref, TString id, TString variable, TString xtitle, Bool_t linear = true) { gROOT->SetStyle("Plain"); gStyle->SetOptStat(0); TFile * file = new TFile(datafile); TH1D * All = (TH1D*) file->Get(TString("AllEvents")+variable)->Clone(); TH1D * Ref = (TH1D*) file->Get("Trigger"+ref+variable)->Clone(); TH1D * Trigger = (TH1D*) file->Get("Trigger"+id+variable)->Clone(); Int_t ngroup = 2; All->Rebin(ngroup); Ref->Rebin(ngroup); Trigger->Rebin(ngroup); TCanvas * canvas = new TCanvas(); // canvas->SetLogy(); All->GetXaxis()->SetTitle(xtitle); All->GetYaxis()->SetTitle("Trigger efficiency"); All->GetYaxis()->SetRangeUser(0.0,1.1); All->Draw("axis"); TEfficiency * EffData = new TEfficiency(); EffData->SetTotalHistogram(*Ref, "f"); EffData->SetPassedHistogram(*Trigger, "f"); EffData->SetMarkerStyle(kFullCircle); EffData->SetMarkerColor(kBlack); EffData->SetLineColor(kBlack); EffData->Draw("samep"); TF1 * datafit = new TF1("datafit","[0] + [1]*(x-100)^2", 100, 800); datafit->SetParameter(0,1.0); datafit->SetParameter(1,0.0); if (linear) datafit->FixParameter(1,0.0); TBinomialEfficiencyFitter * fitter = new TBinomialEfficiencyFitter(Trigger,Ref); fitter->Fit(datafit); datafit->Draw("same"); Double_t * datamatrix = fitter->GetFitter()->GetCovarianceMatrix(); Double_t dataparam[7]; dataparam[1] = datafit->GetParameter(0); dataparam[2] = datafit->GetParameter(1); for (Int_t i = 0; i < 4; ++i) { if (linear && i) dataparam[i+3] = 0; else dataparam[i+3] = datamatrix[i]; } dataparam[0] = 1.0; TF1 * dataplus = new TF1("dataplus", fitSigma, 100.0, 1000, 7); dataplus->SetParameters(dataparam); dataplus->SetLineStyle(kDashed); dataplus->SetLineWidth(1); dataplus->Draw("same"); dataparam[0] = -1.0; TF1 * dataminus = new TF1("dataminus", fitSigma, 100.0, 1000, 7); dataminus->SetParameters(dataparam); dataminus->SetLineStyle(kDashed); dataminus->SetLineWidth(1); dataminus->Draw("same"); canvas->SaveAs(id+variable+"r"+ref+"-data.png"); file = new TFile(mcfile); Ref = (TH1D*) file->Get("Trigger"+ref+variable)->Clone(); Trigger = (TH1D*) file->Get("Trigger"+id+variable)->Clone(); Ref->Rebin(ngroup); Trigger->Rebin(ngroup); TEfficiency * EffMC = new TEfficiency(); EffMC->SetTotalHistogram(*Ref, "f"); EffMC->SetPassedHistogram(*Trigger, "f"); EffMC->SetMarkerStyle(kFullSquare); EffMC->SetMarkerColor(kRed); EffMC->SetLineColor(kRed); All->Draw("axis"); EffMC->Draw("samep"); TF1 * mcfit = new TF1("mcfit","[0] + [1]*(x-100)^2", 100, 800); mcfit->SetLineColor(kRed); mcfit->SetParameter(0,1.0); mcfit->SetParameter(1,0.0); if (linear) mcfit->FixParameter(1,0.0); TBinomialEfficiencyFitter * mcfitter = new TBinomialEfficiencyFitter(Trigger,Ref); mcfitter->Fit(mcfit); mcfit->Draw("same"); Double_t * mcmatrix = mcfitter->GetFitter()->GetCovarianceMatrix(); Double_t mcparam[7]; mcparam[1] = mcfit->GetParameter(0); mcparam[2] = mcfit->GetParameter(1); for (Int_t i = 0; i < 4; ++i) { if (linear && i) mcparam[i+3] = 0; else mcparam[i+3] = mcmatrix[i]; } mcparam[0] = 1.0; TF1 * mcplus = new TF1("dataplus", fitSigma, 100.0, 1000, 7); mcplus->SetParameters(mcparam); mcplus->SetLineStyle(kDashed); mcplus->SetLineColor(kRed); mcplus->SetLineWidth(1); mcplus->Draw("same"); mcparam[0] = -1.0; TF1 * mcminus = new TF1("dataminus", fitSigma, 100.0, 1000, 7); mcminus->SetParameters(mcparam); mcminus->SetLineStyle(kDashed); mcminus->SetLineColor(kRed); mcminus->SetLineWidth(1); mcminus->Draw("same"); canvas->SaveAs(id+variable+"r"+ref+"-mc.png"); Double_t sfparam[13]; sfparam[1] = dataparam[1]; sfparam[2] = dataparam[2]; sfparam[3] = mcparam[1]; sfparam[4] = mcparam[2]; for (Int_t i = 0; i < 4; ++i) sfparam[i+5] = dataparam[i+3]; for (Int_t i = 0; i < 4; ++i) sfparam[i+9] = mcparam[i+3]; for (Int_t i = 0; i < 13; ++i) cout << sfparam[i] << " "; cout << endl; sfparam[0] = 0.0; TF1 * sf = new TF1("sf", sffit, 100.0, 1000, 13); sf->SetParameters(sfparam); All->GetYaxis()->SetTitle("Trigger scale factor"); All->GetYaxis()->SetRangeUser(0.0,1.1); All->Draw("axis"); sf->Draw("same"); sfparam[0] = 1.0; TF1 * sfplus = new TF1("sfplus", sffit, 100.0, 1000, 13); sfplus->SetParameters(sfparam); sfplus->SetLineStyle(kDashed); sfplus->SetLineWidth(1); sfplus->Draw("same"); sfparam[0] = -1.0; TF1 * sfminus = new TF1("sfminus", sffit, 100.0, 1000, 13); sfminus->SetParameters(sfparam); sfminus->SetLineStyle(kDashed); sfminus->SetLineWidth(1); sfminus->Draw("same"); if (linear) cout << "Linear fit for sf: " << sf->Eval(100) << " +- " << (sfplus->Eval(100)-sf->Eval(100)) << endl; canvas->SaveAs(id+variable+"r"+ref+"-sf.png"); }
void fillTree(TTree*& tree, TGraph*& graph, double& limit, unsigned int itype, std::map<double, std::string>& tanb_values, bool upper_exclusion, unsigned int verbosity) { double value=-99; double tanb_help=-99; unsigned int ibin=0; // fill graph with scanned points for(std::map<double, std::string>::const_iterator tanb = tanb_values.begin(); tanb!=tanb_values.end(); ++tanb){ value = singlePointLimit(tanb->second, tanb->first, itype, verbosity); if( value>0 ){ graph->SetPoint(ibin++, tanb->first, value); } tanb_help=tanb->first; } // determine smooth curve on graph for interpolation TSpline3* spline = new TSpline3("spline", graph, "r", 3., 10.); // linear polarisation func TF1 *fnc = 0; // determine all crossing points with y==1 std::vector<CrossPoint> points = crossPoints(graph); int dist = 1; bool filled = false; unsigned int np = 0; unsigned int steps = 10e6; if(points.size()>0) limit = graph->GetX()[upper_exclusion ? points.begin()->first : points.end()->first]; for(std::vector<CrossPoint>::const_reverse_iterator point = points.rbegin(); point!=points.rend(); ++point, ++np){ //for(std::vector<CrossPoint>::iterator point = points.begin(); point!=points.end(); ++point, ++np){ //double min = (point->first-dist)>0 ? graph->GetX()[point->first-dist] : graph->GetX()[0]; double min = (point->first)>0 ? graph->GetX()[point->first] : graph->GetX()[0]; double max = (point->first+dist)<graph->GetN() ? graph->GetX()[point->first+dist] : graph->GetX()[graph->GetN()-1]; //double y_min = (point->first-dist)>0 ? graph->GetY()[point->first-dist] : graph->GetY()[0]; double y_min = (point->first)>0 ? graph->GetY()[point->first] : graph->GetY()[0]; double y_max = (point->first+dist)<graph->GetN() ? graph->GetY()[point->first+dist] : graph->GetY()[graph->GetN()-1]; vector<double> crossing; crossing.push_back((min-max-y_max*min+y_min*max)/(y_min-y_max)); //double crossing; //crossing = (1.-y_min)/(y_max-y_min)*(max-min); double deltaM = -999.; double offset = min; double step_size = (max-min)/steps; for(unsigned int scan=0; scan<=steps; ++scan){ if(deltaM<0 || fabs(spline->Eval(offset+scan*step_size)-1.)<deltaM){ limit=offset+scan*step_size; deltaM=fabs(spline->Eval(offset+scan*step_size)-1.); } } std::cout << "****************************************************************" << std::endl; std::cout << "* [" << np+1 << "|" << point->second << "] asymptotic limit("; std::cout << limitType(itype) << ") :" << crossing[np] << " -- " << limit << " deltaM : " << deltaM; // if(((upper_exclusion && point->second) || (!upper_exclusion && !(point->second))) && !filled){ // //std::cout << "limit is taken from linear interpolation at the moment" << std::endl; // //limit = crossing; // std::cout << " [-->to file]"; filled=true; tree->Fill(); // } if(np==0){ fnc = new TF1("fnc", "[0]*x+[1]", min, max); fnc->SetParameter(0, (y_min-y_max)/(min-max)); fnc->SetParameter(1, (y_max*min-y_min*max)/(min-max)); std::cout << std::endl; std::cout << "limit is taken from linear interpolation at the moment" << std::endl; limit = crossing[np]; std::cout << limit << std::endl; std::cout << " [-->to file]"; filled=true; tree->Fill(); } std::cout << endl; std::cout << "****************************************************************" << std::endl; } // catch cases where no crossing point was found if(!filled){ if(value<1) { std::cout << "WARNING: no crossing found - all tanb values excluded: " << value << std::endl; if(itype == observed) { limit=3.00; } if(itype == plus_2sigma) { limit=5.00; } if(itype == plus_1sigma) { limit=4.00; } if(itype == expected) { limit=3.00; } if(itype == minus_1sigma) { limit=2.50; } if(itype == minus_2sigma) { limit=2.00; } tree->Fill(); } else { std::cout << "WARNING: no crossing found - no tanb value excluded: " << value << " -- " << tanb_help << std::endl; if(itype == observed) { limit=tanb_help*value; } if(itype == plus_2sigma) { limit=tanb_help*value; } if(itype == plus_1sigma) { limit=tanb_help*value; } if(itype == expected) { limit=tanb_help*value; } if(itype == minus_1sigma) { limit=tanb_help*value; } if(itype == minus_2sigma) { limit=tanb_help*value; } tree->Fill(); } } if( verbosity>0 ){ std::string monitor = std::string("SCAN-")+limitType(itype); TCanvas* canv = new TCanvas(monitor.c_str(), monitor.c_str(), 600, 600); TH1F* frame = canv->DrawFrame(graph->GetX()[0]-0.1, 0., graph->GetX()[graph->GetN()-1]+0.1, 10.); canv->SetGridx(1); canv->SetGridy(1); canv->cd(); graph->SetMarkerStyle(20.); graph->SetMarkerColor(kBlack); graph->SetMarkerSize(1.3); graph->Draw("P"); //spline->SetLineColor(kBlue); //spline->SetLineWidth(3.); //spline->Draw("same"); if(filled) fnc->SetLineColor(kRed); if(filled) fnc->SetLineWidth(3.); if(filled) fnc->Draw("same"); canv->Print(monitor.append(".png").c_str(), "png"); delete frame; delete canv; delete spline; if(filled) delete fnc; } return; }
void Draw_vn_ratio( TH1D * vn_default, TH1D * vn_fromJing, TString vnname, TString method, TString MBorDtrig, int cent_low, int cent_high, float ptlow, float pthigh) { TCanvas * cfg_vn_effcorrection = new TCanvas(Form("cfg_vn_effcorrection_%s_cent%dto%d", (vnname+"_"+method+"_"+MBorDtrig).Data(), cent_low, cent_high), Form("cfg_vn_effcorrection_%s_cent%dto%d", (vnname+"_"+method+"_"+MBorDtrig).Data(), cent_low, cent_high), 600, 600); // TPad *pad1 = new TPad("pad1","top pad",0.0,0.6,1.0,1.0); // pad1->SetBottomMargin(0.0); // pad1->Draw(); // // TPad *pad2 = new TPad("pad2","middle pad",0.0,0.3,1.0,0.6); // pad2->SetTopMargin(0.0); // pad2->SetBottomMargin(0.0); // pad2->Draw(); // // TPad *pad3 = new TPad("pad3","bottom pad",0.0,0.0,1.0,0.3); // pad3->SetTopMargin(0.0); // pad3->Draw(); // // pad1->cd(); // vn_default->SetTitleSize(0.06,"xyz"); // vn_default->SetLabelSize(0.08,"xyz"); vn_default->Draw(); vn_fromJing->SetMarkerColor(8); vn_fromJing->SetLineColor(8); vn_fromJing->Draw("same"); TF1 * fun = new TF1("fun", "0.0", 0, 100); fun->SetLineColor(1.0); fun->SetLineStyle(3); fun->SetLineWidth(1); fun->Draw("same"); TLegend * leg = new TLegend(0.60, 0.65, 0.75, 0.90); leg->SetTextSize(0.045); leg->SetTextFont(42); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->AddEntry( (TObject*)0, Form("Cent. %d-%d%%", cent_low, cent_high) , ""); leg->AddEntry( vn_default, "Default"); leg->AddEntry( vn_fromJing, "Jing"); leg->Draw(); // pad2->cd(); // TH1D * h_vn_diff_fromJing_default = (TH1D *) vn_fromJing->Clone("h_vn_diff_fromJing_default"); // // h_vn_diff_fromJing_default->Add( vn_default, -1.0); // // h_vn_diff_fromJing_default->GetYaxis()->SetRangeUser(-0.1,0.1); // h_vn_diff_fromJing_default->GetYaxis()->SetTitle("*-Default"); // h_vn_diff_fromJing_default->SetTitleSize(0.06,"xyz"); // h_vn_diff_fromJing_default->SetLabelSize(0.08,"xyz"); // h_vn_diff_fromJing_default->Draw(); // // TF1 * fun1 = new TF1("fun1", "0.0", 0, 100); // fun1->SetLineColor(1.0); // fun1->SetLineStyle(3); // fun1->SetLineWidth(1); // fun1->Draw("same"); // // pad3->cd(); // TH1D * h_vn_ratio_fromJing_default = (TH1D *) vn_fromJing->Clone("h_vn_ratio_fromJing_default"); // // h_vn_ratio_fromJing_default->Divide( vn_fromJing, vn_default, 1.0, 1.0, "B"); // // h_vn_ratio_fromJing_default->GetYaxis()->SetRangeUser(0.8,1.2); // if( method == "deltaphibins" ) h_vn_ratio_fromJing_default->GetYaxis()->SetRangeUser(0.5,1.5); // h_vn_ratio_fromJing_default->GetYaxis()->SetTitle("*/Default"); // h_vn_ratio_fromJing_default->SetTitleSize(0.06,"xyz"); // h_vn_ratio_fromJing_default->SetLabelSize(0.08,"xyz"); // h_vn_ratio_fromJing_default->Draw(); // // TF1 * fun2 = new TF1("fun2", "1.0", 0, 100); // fun2->SetLineColor(1.0); // fun2->SetLineStyle(3); // fun2->SetLineWidth(1); // fun2->Draw("same"); // cfg_vn_effcorrection->SaveAs(Form("Plots_vn/cfg_vn_fromJing_%s_cent%dto%d.pdf", (vnname+"_"+method+"_"+MBorDtrig).Data(), cent_low, cent_high)); }
void read_scope_spect() { int i,j,k; //for(i=0;i<17;i++) { cin>>i; ifstream indata; sprintf(fileName,"F620130603-%d-%.1f-00000",i+1,hv[i]); // sprintf(fileName,"F6-21-73.9v-00000"); sprintf(buf1,"%s%s.txt",directory,fileName); indata.open(buf1,ios::in); if(!indata) { cout<<endl<<buf1<<" doesn't exist!!"<<endl<<endl; // exit(-1); continue; } else { int nCount; varMax=0; varMin=nMax; indxMin=nMax; indxMax=0; nCount=0; while(!indata.eof()) { indata>>indx1>>var1; //cout<<indx1<<" "<<var1<<endl; if(indxMin>indx1) indxMin=indx1; if(indxMax<indx1) indxMax=indx1; var[nCount]=var1*1e9; indx[nCount]=indx1; if(varMax<var[nCount]) varMax=var[nCount]; if(varMin>var[nCount]) varMin=var[nCount]; nCount++; } //h1->Write(); indata.close(); //file1->Close(); varbuf=varMax-varMin; varMax=varMax+0.025*varbuf; varMin=varMin-0.025*varbuf; //TH1D *spec = new TH1D("SiPM","Spectrum",nBins,varMin,varMax); //TH1D *spec = new TH1D("SiPM","Spectrum",nBins,tLimits[0],tLimits[1]); // TGraph *spec = new TGraph(nCount,indx,var); // for(j=0;j<nCount;j++) { // spec->Fill(var[j]); // } gStyle->SetOptFit(1111); gStyle->SetOptStat(1111); double mean,sigma,para[16],err; //////////////output fit result to txt ofstream outResult; outResult.open(Form("%sfitResult.txt",directory),ios::app); cout<<fileName<<endl; outResult<<"######## file: "<<fileName<<".txt #######"<<"\n"; ///////////////////////////////// int nBins,nFill; TH1D *spec; TCanvas *c1 = new TCanvas(fileName,fileName,10,10,700,600); for(k=0;k<3;k++) { nBins= (tLimits[1]-tLimits[0])*1.0*nNumBins[k]; spec = new TH1D("SiPM","Spectrum",nBins,tLimits[0],tLimits[1]); nFill=0; for(j=0;j<nCount;j++) { if(var[j]>=tLimits[0] && var[j]<=tLimits[1]) { spec->Fill(var[j]); nFill++; } if(nFill==nFillMax) break; } c1->Divide(2,2); for(j=0;j<4;j++) { c1->cd(j+1); spec->Draw(); // spec->Draw("AB"); // spec->SetFillColor(38); // spec->GetXaxis()->SetLimits(tLimits[0],tLimits[1]); spec->GetXaxis()->SetTitle("t [ns]"); // spec->GetXaxis()->SetTitle("Maximum of SiPM signals [mV]"); spec->GetXaxis()->CenterTitle(); spec->GetYaxis()->SetTitle("Counts"); spec->GetYaxis()->CenterTitle(); spec->SetTitle("CTR_2_STiC"); spec->Fit("gaus","NQ"); gaus->GetParameters(¶[0]); gaus->SetRange(para[1]-nSigma[j]*para[2], para[1]+nSigma[j]*para[2]); spec->Fit("gaus","NQR"); gaus->GetParameters(¶[0]); gaus->SetRange(para[1]-nSigma[j]*para[2], para[1]+nSigma[j]*para[2]); spec->Fit("gaus","NQR"); gaus->GetParameters(¶[0]); gaus->SetRange(para[1]-nSigma[j]*para[2], para[1]+nSigma[j]*para[2]); spec->Fit("gaus","QR"); //spec->Fit("gaus"); gaus->GetParameters(¶[0]); err=gaus->GetParError(2); cout<<nNumBins[k]<<" "<<nSigma[j]<<" FWHM: "<<para[2]*2.35<<"\t"<<err*2.35<<"\n"; TF1 *ftemp = new TF1("ftemp","[0]*exp(-0.5*((x-[1])/[2])**2)",tLimits[0],tLimits[1]); //TF1 *ftemp = new TF1("ftemp","[0]*exp(-0.5*((x-[1])/[2])**2)",varMin,varMax); ftemp->SetParameters(para[0],para[1],para[2]); ftemp->SetLineWidth(3); ftemp->SetLineStyle(2); ftemp->SetLineColor(2); ftemp->Draw("same"); c1->cd(j+1)->Update(); outResult<<nSigma[j]<<' '<<tLimits[0]<<' '<<tLimits[1]<<" "<<nBins<<"\n"; outResult<<"Sigma[ps] Err_of_Sigma[ps] CTR_FWHM Err_of_FWHM"<<"\n"; outResult<<para[2]<<"\t"<<err<<"\t"<<para[2]*2.35<<"\t"<<err*2.35<<"\n\n"; } wait(); c1->Clear(); } c1->Close(); // ///////////save histogram to .root file // TFile *fHist = new TFile(Form("%s%s-hist.root",directory,fileName),"recreate"); // c1->Write(); // fHist->ls(); // fHist->Close(); // ////////// ////////close output file outResult<<"\n\n"; outResult.close(); ///////////////////////// // wait(); // c1->Close(); } //} }
void doCarlosPlots() { TCanvas *c1 = new TCanvas("c1","Luminosity",200,10,700,500); // c1->SetFillColor(42); c1->SetGrid(); // c1->GetFrame()->SetFillColor(21); // c1->GetFrame()->SetBorderSize(12); const Int_t n = 6; Float_t x[n] = {0., 28., 54., 74., 91., 100.}; // Float_t y[n] = {8.0E29, 3.4E30, 2.5E31, 4.9E31, 5.1E31, 1.4E32}; Float_t y[n] = {8.0E29, 3.4E30, 2.5E31, 4.9E31, 5.1E31, 6.278E31}; Float_t ex[n] = {.0001,.0001,.0001,.0001,.0001,.0001}; Float_t ey[n] = {0.,0.,0.,0.,0.,0.}; Float_t y2[n] = {0., 2., 15., 40.,70.,99.7}; Float_t xd[2] = {0., 100.}; Float_t yd[2] = {-10000.,1500000.}; Float_t yd2[2] = {0.001,0.3}; Float_t exd[n] = {.0001,.0001}; Float_t eyd[n] = {0.,0.}; TGraphErrors *gr3 = new TGraphErrors(n,x,y,ex,ey); gr3->SetMarkerColor(2); gr3->SetLineColor(2); gr3->SetLineWidth(3); gr3->SetMarkerStyle(20); gr3->SetMinimum(-2.E30); gr3->GetXaxis()->SetTitle("Time (days)"); gr3->GetYaxis()->SetTitle("L_{inst} (cm^{-2} s^{-1})"); gr3->Draw("ALP"); TLine *hline = new TLine(-10.,1E31,36.,1E31); hline->SetLineColor(4); hline->SetLineWidth(3); hline->Draw("SAME"); TLine *vline = new TLine(36.,-2E30,36.,1E31); vline->SetLineColor(4); vline->SetLineWidth(3); vline->Draw("SAME"); c1->Update(); c1->SaveAs("LumiInst.gif"); TGraphErrors *gr2 = new TGraphErrors(n,x,y2,ex,ey); gr2->SetMarkerColor(2); gr2->SetMinimum(-5.0); gr2->SetMaximum(110.0); gr2->SetMarkerStyle(20); gr2->GetXaxis()->SetTitle("Time (days)"); gr2->GetYaxis()->SetTitle("L_{integ} (pb^{-1})"); gr2->Draw("AP"); TF1 *ftotal = new TF1("ftotal","myFunc(x)",0.,101.); ftotal->SetLineWidth(3); ftotal->SetLineColor(2); ftotal->Draw("SAME"); TLine *hline2 = new TLine(-10.,3.85,36.,3.85); hline2->SetLineColor(4); hline2->SetLineWidth(3); hline2->Draw("SAME"); TLine *vline2 = new TLine(36.,-5.0,36.,3.85); vline2->SetLineColor(4); vline2->SetLineWidth(3); vline2->Draw("SAME"); c1->Update(); c1->SaveAs("LumiInteg.gif"); c1->SetLogy(); c1->Update(); c1->SaveAs("LumiIntegLog.gif"); TCanvas *c2 = new TCanvas("c2","Events",300,100,700,500); c2->cd(); c2->SetGrid(); TGraphErrors *gr4 = new TGraphErrors(2,xd,yd,exd,eyd); // DUMMY gr4->SetMarkerColor(kWhite); gr4->GetXaxis()->SetTitle("Time (days)"); gr4->GetYaxis()->SetTitle("N (prompt J/#psi reco)"); TLine *vline3 = new TLine(36.,-20000.0,36.,900000.); // MENU CHANGE vline3->SetLineColor(kMagenta); vline3->SetLineStyle(kDashed); vline3->SetLineWidth(2); /// FUNCTIONS: HLTMu3 TF1 *fhighHLTMu3 = new TF1("fhighHLTMu3","23887*myFunc(x)",0.,36.); fhighHLTMu3->SetLineWidth(4); fhighHLTMu3->SetLineColor(2); TF1 *fmediumHLTMu3 = new TF1("fmediumHLTMu3","30993*myFunc(x)",0.,36.); fmediumHLTMu3->SetLineWidth(2); fmediumHLTMu3->SetLineColor(4); TF1 *flowHLTMu3 = new TF1("flowHLTMu3","66119*myFunc(x)",0.,36.); flowHLTMu3->SetLineWidth(2); flowHLTMu3->SetLineColor(3); TF1 *ftotalHLTMu3 = new TF1("ftotalHLTMu3","121000*myFunc(x)",0.,36.); ftotalHLTMu3->SetLineWidth(4); ftotalHLTMu3->SetLineColor(1); /// /// FUNCTIONS: HLTMu5 TF1 *fhighHLTMu5 = new TF1("fhighHLTMu5","491*myFunc(x)+90309",36.,100.); fhighHLTMu5->SetLineWidth(4); fhighHLTMu5->SetLineColor(2); TF1 *fmediumHLTMu5 = new TF1("fmediumHLTMu5","475*myFunc(x)+117799",36.,100.); fmediumHLTMu5->SetLineWidth(2); fmediumHLTMu5->SetLineColor(4); TF1 *flowHLTMu5 = new TF1("flowHLTMu5","1112*myFunc(x)+250927",36.,100.); flowHLTMu5->SetLineWidth(2); flowHLTMu5->SetLineColor(3); TF1 *ftotalHLTMu5 = new TF1("ftotalHLTMu5","2078*myFunc(x)+459038",36.,100.); ftotalHLTMu5->SetLineWidth(4); ftotalHLTMu5->SetLineColor(1); /// /// FUNCTIONS: HLTMu9 TF1 *fhighHLTMu9 = new TF1("fhighHLTMu9","2430*myFunc(x)+82824",36.,100.); fhighHLTMu9->SetLineWidth(4); fhighHLTMu9->SetLineColor(2); TF1 *fmediumHLTMu9 = new TF1("fmediumHLTMu9","1401*myFunc(x)+114225",36.,100.); fmediumHLTMu9->SetLineWidth(2); fmediumHLTMu9->SetLineColor(4); TF1 *flowHLTMu9 = new TF1("flowHLTMu9","2833*myFunc(x)+244283",36.,100.); flowHLTMu9->SetLineWidth(2); flowHLTMu9->SetLineColor(3); TF1 *ftotalHLTMu9 = new TF1("ftotalHLTMu9","6664*myFunc(x)+441337",36.,100.); ftotalHLTMu9->SetLineWidth(4); ftotalHLTMu9->SetLineColor(1); /// /// FUNCTIONS: HLT2Mu3 TF1 *fhighHLT2Mu3 = new TF1("fhighHLT2Mu3","10271*myFunc(x)+52258",36.,100.); fhighHLT2Mu3->SetLineWidth(4); fhighHLT2Mu3->SetLineColor(2); TF1 *fmediumHLT2Mu3 = new TF1("fmediumHLT2Mu3","1157*myFunc(x)+115167",36.,100.); fmediumHLT2Mu3->SetLineWidth(2); fmediumHLT2Mu3->SetLineColor(4); TF1 *flowHLT2Mu3 = new TF1("flowHLT2Mu3","52*myFunc(x)+255122",36.,100.); flowHLT2Mu3->SetLineWidth(2); flowHLT2Mu3->SetLineColor(3); TF1 *ftotalHLT2Mu3 = new TF1("ftotalHLT2Mu3","11480*myFunc(x)+422747",36.,100.); ftotalHLT2Mu3->SetLineWidth(4); ftotalHLT2Mu3->SetLineColor(1); /// /// FIRST PLOT: HLTMu3 + HLTMu5 gr4->Draw("AP"); fhighHLTMu3->Draw("SAME"); fmediumHLTMu3->Draw("SAME"); flowHLTMu3->Draw("SAME"); ftotalHLTMu3->Draw("SAME"); fhighHLTMu5->Draw("SAME"); fmediumHLTMu5->Draw("SAME"); flowHLTMu5->Draw("SAME"); ftotalHLTMu5->Draw("SAME"); vline3->Draw("SAME"); // LEGENDS leg = new TLegend(0.20,0.65,0.60,0.9); leg->AddEntry(fhighHLTMu3,"2 global muons","l"); leg->AddEntry(fmediumHLTMu3,"1 global + 1 tracker muon","l"); leg->AddEntry(flowHLTMu3,"1 global + 1 calo muon","l"); leg->AddEntry(ftotalHLTMu3,"all muons","l"); leg->AddEntry(vline3,"Trigger menu switch","l"); leg->Draw("SAME"); hltmu3 = new TPaveLabel(-5.,400000.,20.,550000.,"HLT_Mu3 (1x1)"); hltmu3->SetTextColor(kMagenta); hltmu3->Draw("SAME"); hltmu5 = new TPaveLabel(65.,1100000.,95.,1250000.,"HLT_Mu5 (25x1)"); hltmu5->SetTextColor(kMagenta); hltmu5->Draw("SAME"); c2->Update(); c2->SaveAs("Njpsi_Mu3Mu5.gif"); /// SECOND PLOT: HLTMu3 + HLTMu9 gr4->Draw("AP"); fhighHLTMu3->Draw("SAME"); fmediumHLTMu3->Draw("SAME"); flowHLTMu3->Draw("SAME"); ftotalHLTMu3->Draw("SAME"); fhighHLTMu9->Draw("SAME"); fmediumHLTMu9->Draw("SAME"); flowHLTMu9->Draw("SAME"); ftotalHLTMu9->Draw("SAME"); vline3->Draw("SAME"); // LEGENDS leg->Draw("SAME"); hltmu3->Draw("SAME"); hltmu9 = new TPaveLabel(65.,1100000.,90.,1250000.,"HLT_Mu9 (1x1)"); hltmu9->SetTextColor(kMagenta); hltmu9->Draw("SAME"); c2->Update(); c2->SaveAs("Njpsi_Mu3Mu9.gif"); /// THIRD PLOT: HLTMu3 + HLT2Mu3 gr4->Draw("AP"); fhighHLTMu3->Draw("SAME"); fmediumHLTMu3->Draw("SAME"); flowHLTMu3->Draw("SAME"); ftotalHLTMu3->Draw("SAME"); fhighHLT2Mu3->Draw("SAME"); fmediumHLT2Mu3->Draw("SAME"); flowHLT2Mu3->Draw("SAME"); ftotalHLT2Mu3->Draw("SAME"); vline3->Draw("SAME"); // LEGENDS leg->Draw("SAME"); hltmu3->Draw("SAME"); hltmu9 = new TPaveLabel(60.,1200000.,87.,1350000.,"HLT_2Mu3 (1x1)"); hltmu9->SetTextColor(kMagenta); hltmu9->Draw("SAME"); c2->Update(); c2->SaveAs("Njpsi_Mu32Mu3.gif"); // S/B TCanvas *c3 = new TCanvas("c3","Events",500,300,700,500); c3->cd(); c3->SetGrid(); c3->SetLogy(); TGraphErrors *grsb4 = new TGraphErrors(2,xd,yd2,exd,eyd); // DUMMY grsb4->SetMarkerColor(kWhite); grsb4->GetXaxis()->SetTitle("Time (days)"); grsb4->GetYaxis()->SetTitle("sqrt(S+B)/S (prompt J/#psi reco)"); TLine *vline6 = new TLine(36.,0.0,36.,0.3); // MENU CHANGE vline6->SetLineColor(kMagenta); vline6->SetLineStyle(kDashed); vline6->SetLineWidth(2); /// FUNCTIONS: HLTMu3 TF1 *sbhighHLTMu3 = new TF1("sbhighHLTMu3","sqrt(31649*myFunc(x))/(23887*myFunc(x))",0.,36.); sbhighHLTMu3->SetLineWidth(4); sbhighHLTMu3->SetLineColor(2); TF1 *sbmediumHLTMu3 = new TF1("sbmediumHLTMu3","sqrt(215502*myFunc(x))/(30993*myFunc(x))",0.,36.); sbmediumHLTMu3->SetLineWidth(2); sbmediumHLTMu3->SetLineColor(4); TF1 *sblowHLTMu3 = new TF1("sblowHLTMu3","sqrt(493892*myFunc(x))/(66119*myFunc(x))",0.,36.); sblowHLTMu3->SetLineWidth(2); sblowHLTMu3->SetLineColor(3); TF1 *sbtotalHLTMu3 = new TF1("sbtotalHLTMu3","sqrt(741043*myFunc(x))/(121000*myFunc(x))",0.,36.); sbtotalHLTMu3->SetLineWidth(4); sbtotalHLTMu3->SetLineColor(1); /// /// FUNCTIONS: HLTMu5 TF1 *sbhighHLTMu5 = new TF1("sbhighHLTMu5","sqrt(636*myFunc(x)+119747)/(491*myFunc(x)+90309)",36.,100.); sbhighHLTMu5->SetLineWidth(4); sbhighHLTMu5->SetLineColor(2); TF1 *sbmediumHLTMu5 = new TF1("sbmediumHLTMu5","sqrt(3640*myFunc(x)+821259)/(475*myFunc(x)+117799)",36.,100.); sbmediumHLTMu5->SetLineWidth(2); sbmediumHLTMu5->SetLineColor(4); TF1 *sblowHLTMu5 = new TF1("sblowHLTMu5","sqrt(7050*myFunc(x)+1674140)/(1112*myFunc(x)+250927)",36.,100.); sblowHLTMu5->SetLineWidth(2); sblowHLTMu5->SetLineColor(3); TF1 *sbtotalHLTMu5 = new TF1("sbtotalHLTMu5","sqrt(11326*myFunc(x)+2615146)/(2078*myFunc(x)+459038)",36.,100.); sbtotalHLTMu5->SetLineWidth(4); sbtotalHLTMu5->SetLineColor(1); /// /// FUNCTIONS: HLTMu9 TF1 *sbhighHLTMu9 = new TF1("sbhighHLTMu9","sqrt(3339*myFunc(x)+109315)/(2430*myFunc(x)+82824)",36.,100.); sbhighHLTMu9->SetLineWidth(4); sbhighHLTMu9->SetLineColor(2); TF1 *sbmediumHLTMu9 = new TF1("sbmediumHLTMu9","sqrt(17310*myFunc(x)+768495)/(1401*myFunc(x)+114225)",36.,100.); sbmediumHLTMu9->SetLineWidth(2); sbmediumHLTMu9->SetLineColor(4); TF1 *sblowHLTMu9 = new TF1("sblowHLTMu9","sqrt(12969*myFunc(x)+1856362)/(2833*myFunc(x)+244283)",36.,100.); sblowHLTMu9->SetLineWidth(2); sblowHLTMu9->SetLineColor(3); TF1 *sbtotalHLTMu9 = new TF1("sbtotalHLTMu9","sqrt(33438*myFunc(x)+2734172)/(6664*myFunc(x)+441337)",36.,100.); sbtotalHLTMu9->SetLineWidth(4); sbtotalHLTMu9->SetLineColor(1); /// /// FUNCTIONS: HLT2Mu3 TF1 *sbhighHLT2Mu3 = new TF1("sbhighHLT2Mu3","sqrt(12498*myFunc(x)+73661)/(10271*myFunc(x)+52258)",36.,100.); sbhighHLT2Mu3->SetLineWidth(4); sbhighHLT2Mu3->SetLineColor(2); TF1 *sbmediumHLT2Mu3 = new TF1("sbmediumHLT2Mu3","sqrt(6702*myFunc(x)+809442)/(1157*myFunc(x)+115167)",36.,100.); sbmediumHLT2Mu3->SetLineWidth(2); sbmediumHLT2Mu3->SetLineColor(4); TF1 *sblowHLT2Mu3 = new TF1("sblowHLT2Mu3","sqrt(5233*myFunc(x)+1886327)/(52*myFunc(x)+255122)",36.,100.); sblowHLT2Mu3->SetLineWidth(2); sblowHLT2Mu3->SetLineColor(3); TF1 *sbtotalHLT2Mu3 = new TF1("sbtotalHLT2Mu3","sqrt(24433*myFunc(x)+2769430)/(11480*myFunc(x)+422747)",36.,100.); sbtotalHLT2Mu3->SetLineWidth(4); sbtotalHLT2Mu3->SetLineColor(1); /// /// FIRST PLOT: HLTMu3 + HLTMu5 grsb4->Draw("AP"); sbhighHLTMu3->Draw("SAME"); sbmediumHLTMu3->Draw("SAME"); sblowHLTMu3->Draw("SAME"); sbtotalHLTMu3->Draw("SAME"); sbhighHLTMu5->Draw("SAME"); sbmediumHLTMu5->Draw("SAME"); sblowHLTMu5->Draw("SAME"); sbtotalHLTMu5->Draw("SAME"); vline6->Draw("SAME"); // LEGENDS leg = new TLegend(0.50,0.65,0.90,0.9); leg->AddEntry(sbhighHLTMu3,"2 global muons","l"); leg->AddEntry(sbmediumHLTMu3,"1 global + 1 tracker muon","l"); leg->AddEntry(sblowHLTMu3,"1 global + 1 calo muon","l"); leg->AddEntry(sbtotalHLTMu3,"all muons","l"); leg->AddEntry(vline6,"Trigger menu switch","l"); leg->Draw("SAME"); hltmu3 = new TPaveLabel(-5.,0.002,20.,0.004,"HLT_Mu3 (1x1)"); hltmu3->SetTextColor(kMagenta); hltmu3->Draw("SAME"); hltmu5 = new TPaveLabel(65.,0.02,95.,0.03,"HLT_Mu5 (25x1)"); hltmu5->SetTextColor(kMagenta); hltmu5->Draw("SAME"); c3->Update(); c3->SaveAs("SBjpsi_Mu3Mu5.gif"); /// SECOND PLOT: HLTMu3 + HLTMu9 grsb4->Draw("AP"); sbhighHLTMu3->Draw("SAME"); sbmediumHLTMu3->Draw("SAME"); sblowHLTMu3->Draw("SAME"); sbtotalHLTMu3->Draw("SAME"); sbhighHLTMu9->Draw("SAME"); sbmediumHLTMu9->Draw("SAME"); sblowHLTMu9->Draw("SAME"); sbtotalHLTMu9->Draw("SAME"); vline6->Draw("SAME"); // LEGENDS leg->Draw("SAME"); hltmu3->Draw("SAME"); hltmu9 = new TPaveLabel(65.,0.02,90.,0.03,"HLT_Mu9 (1x1)"); hltmu9->SetTextColor(kMagenta); hltmu9->Draw("SAME"); c3->Update(); c3->SaveAs("SBjpsi_Mu3Mu9.gif"); /// THIRD PLOT: HLTMu3 + HLT2Mu3 grsb4->Draw("AP"); sbhighHLTMu3->Draw("SAME"); sbmediumHLTMu3->Draw("SAME"); sblowHLTMu3->Draw("SAME"); sbtotalHLTMu3->Draw("SAME"); sbhighHLT2Mu3->Draw("SAME"); sbmediumHLT2Mu3->Draw("SAME"); sblowHLT2Mu3->Draw("SAME"); sbtotalHLT2Mu3->Draw("SAME"); vline6->Draw("SAME"); // LEGENDS leg->Draw("SAME"); hltmu3->Draw("SAME"); hltmu9 = new TPaveLabel(60.,0.02,87.,0.03,"HLT_2Mu3 (1x1)"); hltmu9->SetTextColor(kMagenta); hltmu9->Draw("SAME"); c3->Update(); c3->SaveAs("SBjpsi_Mu32Mu3.gif"); // S/B (pt < 6) TCanvas *c4 = new TCanvas("c4","Events",600,400,700,500); c4->cd(); c4->SetGrid(); c4->SetLogy(); /// FUNCTIONS: HLTMu3 TF1 *sbpt6highHLTMu3 = new TF1("sbpt6highHLTMu3","sqrt(4301*myFunc(x))/(3301*myFunc(x))",0.,36.); sbpt6highHLTMu3->SetLineWidth(4); sbpt6highHLTMu3->SetLineColor(2); TF1 *sbpt6mediumHLTMu3 = new TF1("sbpt6mediumHLTMu3","sqrt(85523*myFunc(x))/(14660*myFunc(x))",0.,36.); sbpt6mediumHLTMu3->SetLineWidth(2); sbpt6mediumHLTMu3->SetLineColor(4); TF1 *sbpt6lowHLTMu3 = new TF1("sbpt6lowHLTMu3","sqrt(174973*myFunc(x))/(35700*myFunc(x))",0.,36.); sbpt6lowHLTMu3->SetLineWidth(2); sbpt6lowHLTMu3->SetLineColor(3); TF1 *sbpt6totalHLTMu3 = new TF1("sbpt6totalHLTMu3","sqrt(264797*myFunc(x))/(53661*myFunc(x))",0.,36.); sbpt6totalHLTMu3->SetLineWidth(4); sbpt6totalHLTMu3->SetLineColor(1); /// FUNCTIONS: HLTMu5 (NON PRESCALED) TF1 *sbpt6highHLTMu5 = new TF1("sbpt6highHLTMu5","sqrt(402*myFunc(x)+15050)/(311*myFunc(x)+11541)",36.,100.); sbpt6highHLTMu5->SetLineWidth(4); sbpt6highHLTMu5->SetLineColor(2); TF1 *sbpt6mediumHLTMu5 = new TF1("sbpt6mediumHLTMu5","sqrt(10083*myFunc(x)+291198)/(2902*myFunc(x)+45385)",36.,100.); sbpt6mediumHLTMu5->SetLineWidth(2); sbpt6mediumHLTMu5->SetLineColor(4); TF1 *sbpt6lowHLTMu5 = new TF1("sbpt6lowHLTMu5","sqrt(38740*myFunc(x)+525859)/(11650*myFunc(x)+92833)",36.,100.); sbpt6lowHLTMu5->SetLineWidth(2); sbpt6lowHLTMu5->SetLineColor(3); TF1 *sbpt6totalHLTMu5 = new TF1("sbpt6totalHLTMu5","sqrt(49225*myFunc(x)+832107)/(14863*myFunc(x)+149759)",36.,100.); sbpt6totalHLTMu5->SetLineWidth(4); sbpt6totalHLTMu5->SetLineColor(1); /// FIRST PLOT: HLTMu3 + HLTMu5 grsb4->GetYaxis()->SetTitle("sqrt(S+B)/S (p_{T} < 6 GeV)"); grsb4->Draw("AP"); sbpt6highHLTMu3->Draw("SAME"); sbpt6mediumHLTMu3->Draw("SAME"); sbpt6lowHLTMu3->Draw("SAME"); sbpt6totalHLTMu3->Draw("SAME"); sbpt6highHLTMu5->Draw("SAME"); sbpt6mediumHLTMu5->Draw("SAME"); sbpt6lowHLTMu5->Draw("SAME"); sbpt6totalHLTMu5->Draw("SAME"); vline6->Draw("SAME"); // LEGENDS leg->Draw("SAME"); hltmu3->Draw("SAME"); hltmu5 = new TPaveLabel(65.,0.02,90.,0.03,"HLT_Mu5 (1x1)"); hltmu5->SetTextColor(kMagenta); hltmu5->Draw("SAME"); c4->Update(); c4->SaveAs("SBjpsi_Mu3Mu5_ptlt6.gif"); }
void makePlot(TH1* histogram_data, bool doKeepBlinded, TH1* histogram_ttH, TH1* histogram_ttZ, TH1* histogram_ttW, TH1* histogram_EWK, TH1* histogram_Rares, TH1* histogram_fakes, TH1* histogramSum_mc, TH1* histogramErr_mc, const std::string& xAxisTitle, const std::string& yAxisTitle, double yMin, double yMax, bool showLegend, const std::string& label, const std::string& outputFileName, bool useLogScale) { TH1* histogram_data_density = 0; if ( histogram_data ) { histogram_data_density = divideHistogramByBinWidth(histogram_data); } histogram_data_density->SetMarkerColor(1); histogram_data_density->SetMarkerStyle(20); histogram_data_density->SetMarkerSize(2); histogram_data_density->SetLineColor(1); histogram_data_density->SetLineWidth(1); histogram_data_density->SetLineStyle(1); TH1* histogram_ttH_density = 0; if ( histogram_ttH ) { if ( histogram_data ) checkCompatibleBinning(histogram_ttH, histogram_data); histogram_ttH_density = divideHistogramByBinWidth(histogram_ttH); } histogram_ttH_density->SetFillColor(628); histogram_ttH_density->SetLineColor(1); histogram_ttH_density->SetLineWidth(1); TH1* histogram_ttZ_density = 0; if ( histogram_ttZ ) { if ( histogram_data ) checkCompatibleBinning(histogram_ttZ, histogram_data); histogram_ttZ_density = divideHistogramByBinWidth(histogram_ttZ); } histogram_ttZ_density->SetFillColor(822); histogram_ttZ_density->SetLineColor(1); histogram_ttZ_density->SetLineWidth(1); TH1* histogram_ttW_density = 0; if ( histogram_ttW ) { if ( histogram_data ) checkCompatibleBinning(histogram_ttW, histogram_data); histogram_ttW_density = divideHistogramByBinWidth(histogram_ttW); } histogram_ttW_density->SetFillColor(823); histogram_ttW_density->SetLineColor(1); histogram_ttW_density->SetLineWidth(1); TH1* histogram_EWK_density = 0; if ( histogram_EWK ) { if ( histogram_data ) checkCompatibleBinning(histogram_EWK, histogram_data); histogram_EWK_density = divideHistogramByBinWidth(histogram_EWK); } histogram_EWK_density->SetFillColor(610); histogram_EWK_density->SetLineColor(1); histogram_EWK_density->SetLineWidth(1); TH1* histogram_Rares_density = 0; if ( histogram_Rares ) { if ( histogram_data ) checkCompatibleBinning(histogram_Rares, histogram_data); histogram_Rares_density = divideHistogramByBinWidth(histogram_Rares); } histogram_Rares_density->SetFillColor(851); histogram_Rares_density->SetLineColor(1); histogram_Rares_density->SetLineWidth(1); TH1* histogram_fakes_density = 0; if ( histogram_fakes ) { if ( histogram_data ) checkCompatibleBinning(histogram_fakes, histogram_data); histogram_fakes_density = divideHistogramByBinWidth(histogram_fakes); } histogram_fakes_density->SetFillColor(1); histogram_fakes_density->SetFillStyle(3005); histogram_fakes_density->SetLineColor(1); histogram_fakes_density->SetLineWidth(1); TH1* histogramSum_mc_density = 0; if ( histogramSum_mc ) { if ( histogram_data ) checkCompatibleBinning(histogramSum_mc, histogram_data); histogramSum_mc_density = divideHistogramByBinWidth(histogramSum_mc); } std::cout << "histogramSum_mc_density = " << histogramSum_mc_density << std::endl; dumpHistogram(histogramSum_mc_density); TH1* histogramErr_mc_density = 0; if ( histogramErr_mc ) { if ( histogram_data ) checkCompatibleBinning(histogramErr_mc, histogram_data); histogramErr_mc_density = divideHistogramByBinWidth(histogramErr_mc); } setStyle_uncertainty(histogramErr_mc_density); TCanvas* canvas = new TCanvas("canvas", "canvas", 950, 1100); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->Draw(); TPad* topPad = new TPad("topPad", "topPad", 0.00, 0.34, 1.00, 0.995); topPad->SetFillColor(10); topPad->SetTopMargin(0.065); topPad->SetLeftMargin(0.20); topPad->SetBottomMargin(0.00); topPad->SetRightMargin(0.04); topPad->SetLogy(useLogScale); TPad* bottomPad = new TPad("bottomPad", "bottomPad", 0.00, 0.01, 1.00, 0.335); bottomPad->SetFillColor(10); bottomPad->SetTopMargin(0.085); bottomPad->SetLeftMargin(0.20); bottomPad->SetBottomMargin(0.35); bottomPad->SetRightMargin(0.04); bottomPad->SetLogy(false); canvas->cd(); topPad->Draw(); topPad->cd(); THStack* histogramStack_mc = new THStack(); histogramStack_mc->Add(histogram_fakes_density); histogramStack_mc->Add(histogram_Rares_density); histogramStack_mc->Add(histogram_EWK_density); histogramStack_mc->Add(histogram_ttW_density); histogramStack_mc->Add(histogram_ttZ_density); histogramStack_mc->Add(histogram_ttH_density); TH1* histogram_ref = histogram_data_density; histogram_ref->SetTitle(""); histogram_ref->SetStats(false); histogram_ref->SetMaximum(yMax); histogram_ref->SetMinimum(yMin); TAxis* xAxis_top = histogram_ref->GetXaxis(); assert(xAxis_top); if ( xAxisTitle != "" ) xAxis_top->SetTitle(xAxisTitle.data()); xAxis_top->SetTitleOffset(1.20); xAxis_top->SetLabelColor(10); xAxis_top->SetTitleColor(10); TAxis* yAxis_top = histogram_ref->GetYaxis(); assert(yAxis_top); if ( yAxisTitle != "" ) yAxis_top->SetTitle(yAxisTitle.data()); yAxis_top->SetTitleOffset(1.20); yAxis_top->SetTitleSize(0.080); yAxis_top->SetLabelSize(0.065); yAxis_top->SetTickLength(0.04); histogram_ref->Draw("axis"); // CV: calling THStack::Draw() causes segmentation violation ?! //histogramStack_mc->Draw("histsame"); // CV: draw histograms without using THStack instead; // note that order in which histograms need to be drawn needs to be reversed // compared to order in which histograms were added to THStack !! histogram_ttH_density->Add(histogram_ttZ_density); histogram_ttH_density->Add(histogram_ttW_density); histogram_ttH_density->Add(histogram_EWK_density); histogram_ttH_density->Add(histogram_Rares_density); histogram_ttH_density->Add(histogram_fakes_density); histogram_ttH_density->Draw("histsame"); std::cout << "histogram_ttH_density = " << histogram_ttH_density << ":" << std::endl; dumpHistogram(histogram_ttH_density); histogram_ttZ_density->Add(histogram_ttW_density); histogram_ttZ_density->Add(histogram_EWK_density); histogram_ttZ_density->Add(histogram_Rares_density); histogram_ttZ_density->Add(histogram_fakes_density); histogram_ttZ_density->Draw("histsame"); histogram_ttW_density->Add(histogram_EWK_density); histogram_ttW_density->Add(histogram_Rares_density); histogram_ttW_density->Add(histogram_fakes_density); histogram_ttW_density->Draw("histsame"); histogram_EWK_density->Add(histogram_Rares_density); histogram_EWK_density->Add(histogram_fakes_density); histogram_EWK_density->Draw("histsame"); histogram_Rares_density->Add(histogram_fakes_density); histogram_Rares_density->Draw("histsame"); TH1* histogram_fakes_density_cloned = (TH1*)histogram_fakes_density->Clone(); histogram_fakes_density_cloned->SetFillColor(10); histogram_fakes_density_cloned->SetFillStyle(1001); histogram_fakes_density_cloned->Draw("histsame"); histogram_fakes_density->Draw("histsame"); if ( histogramErr_mc_density ) { histogramErr_mc_density->Draw("e2same"); } if ( !doKeepBlinded ) { histogram_data_density->Draw("e1psame"); } histogram_ref->Draw("axissame"); double legend_y0 = 0.6950; if ( showLegend ) { TLegend* legend1 = new TLegend(0.2600, legend_y0, 0.5350, 0.9250, NULL, "brNDC"); legend1->SetFillStyle(0); legend1->SetBorderSize(0); legend1->SetFillColor(10); legend1->SetTextSize(0.050); TH1* histogram_data_forLegend = (TH1*)histogram_data_density->Clone(); histogram_data_forLegend->SetMarkerSize(2); legend1->AddEntry(histogram_data_forLegend, "Observed", "p"); legend1->AddEntry(histogram_ttH_density, "t#bar{t}H", "f"); legend1->AddEntry(histogram_ttZ_density, "t#bar{t}Z", "f"); legend1->AddEntry(histogram_ttW_density, "t#bar{t}W", "f"); legend1->Draw(); TLegend* legend2 = new TLegend(0.6600, legend_y0, 0.9350, 0.9250, NULL, "brNDC"); legend2->SetFillStyle(0); legend2->SetBorderSize(0); legend2->SetFillColor(10); legend2->SetTextSize(0.050); legend2->AddEntry(histogram_EWK_density, "Electroweak", "f"); legend2->AddEntry(histogram_Rares_density, "Rares", "f"); legend2->AddEntry(histogram_fakes_density, "Fakes", "f"); if ( histogramErr_mc ) legend2->AddEntry(histogramErr_mc_density, "Uncertainty", "f"); legend2->Draw(); } //addLabel_CMS_luminosity(0.2100, 0.9700, 0.6350); addLabel_CMS_preliminary(0.2100, 0.9700, 0.6350); TPaveText* label_category = 0; if ( showLegend ) label_category = new TPaveText(0.6600, legend_y0 - 0.0550, 0.9350, legend_y0, "NDC"); else label_category = new TPaveText(0.2350, 0.8500, 0.5150, 0.9100, "NDC"); label_category->SetTextAlign(13); label_category->AddText(label.data()); label_category->SetTextSize(0.055); label_category->SetTextColor(1); label_category->SetFillStyle(0); label_category->SetBorderSize(0); label_category->Draw(); canvas->cd(); bottomPad->Draw(); bottomPad->cd(); TH1* histogramRatio = (TH1*)histogram_data_density->Clone("histogramRatio"); if ( !histogramRatio->GetSumw2N() ) histogramRatio->Sumw2(); histogramRatio->SetTitle(""); histogramRatio->SetStats(false); histogramRatio->SetMinimum(-0.99); histogramRatio->SetMaximum(+0.99); histogramRatio->SetMarkerColor(histogram_data_density->GetMarkerColor()); histogramRatio->SetMarkerStyle(histogram_data_density->GetMarkerStyle()); histogramRatio->SetMarkerSize(histogram_data_density->GetMarkerSize()); histogramRatio->SetLineColor(histogram_data_density->GetLineColor()); TH1* histogramRatioUncertainty = (TH1*)histogram_data_density->Clone("histogramRatioUncertainty"); if ( !histogramRatioUncertainty->GetSumw2N() ) histogramRatioUncertainty->Sumw2(); histogramRatioUncertainty->SetMarkerColor(10); histogramRatioUncertainty->SetMarkerSize(0); setStyle_uncertainty(histogramRatioUncertainty); int numBins_bottom = histogramRatio->GetNbinsX(); for ( int iBin = 1; iBin <= numBins_bottom; ++iBin ) { double binContent_data = histogram_data_density->GetBinContent(iBin); double binError_data = histogram_data_density->GetBinError(iBin); double binContent_mc = 0; double binError_mc = 0; if ( histogramSum_mc && histogramErr_mc ) { binContent_mc = histogramSum_mc_density->GetBinContent(iBin); binError_mc = histogramErr_mc_density->GetBinError(iBin); } else { TList* histograms = histogramStack_mc->GetHists(); TIter nextHistogram(histograms); double binError2_mc = 0.; while ( TH1* histogram_density = dynamic_cast<TH1*>(nextHistogram()) ) { binContent_mc += histogram_density->GetBinContent(iBin); binError2_mc += square(histogram_density->GetBinError(iBin)); } binError_mc = TMath::Sqrt(binError2_mc); } if ( binContent_mc > 0. ) { histogramRatio->SetBinContent(iBin, binContent_data/binContent_mc - 1.0); histogramRatio->SetBinError(iBin, binError_data/binContent_mc); histogramRatioUncertainty->SetBinContent(iBin, 0.); histogramRatioUncertainty->SetBinError(iBin, binError_mc/binContent_mc); } } std::cout << "histogramRatio = " << histogramRatio << std::endl; dumpHistogram(histogramRatio); std::cout << "histogramRatioUncertainty = " << histogramRatioUncertainty << std::endl; dumpHistogram(histogramRatioUncertainty); TAxis* xAxis_bottom = histogramRatio->GetXaxis(); assert(xAxis_bottom); xAxis_bottom->SetTitle(xAxis_top->GetTitle()); xAxis_bottom->SetLabelColor(1); xAxis_bottom->SetTitleColor(1); xAxis_bottom->SetTitleOffset(1.05); xAxis_bottom->SetTitleSize(0.16); xAxis_bottom->SetTitleFont(xAxis_top->GetTitleFont()); xAxis_bottom->SetLabelOffset(0.02); xAxis_bottom->SetLabelSize(0.12); xAxis_bottom->SetTickLength(0.065); xAxis_bottom->SetNdivisions(505); TAxis* yAxis_bottom = histogramRatio->GetYaxis(); assert(yAxis_bottom); yAxis_bottom->SetTitle("#frac{Data - Expectation}{Expectation}"); yAxis_bottom->SetLabelColor(1); yAxis_bottom->SetTitleColor(1); yAxis_bottom->SetTitleOffset(0.95); yAxis_bottom->SetTitleFont(yAxis_top->GetTitleFont()); yAxis_bottom->SetNdivisions(505); yAxis_bottom->CenterTitle(); yAxis_bottom->SetTitleSize(0.095); yAxis_bottom->SetLabelSize(0.110); yAxis_bottom->SetTickLength(0.04); histogramRatio->Draw("axis"); TF1* line = new TF1("line","0", xAxis_bottom->GetXmin(), xAxis_bottom->GetXmax()); line->SetLineStyle(3); line->SetLineWidth(1.5); line->SetLineColor(kBlack); line->Draw("same"); histogramRatioUncertainty->Draw("e2same"); if ( !doKeepBlinded ) { histogramRatio->Draw("epsame"); } histogramRatio->Draw("axissame"); canvas->Update(); size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); if ( useLogScale ) outputFileName_plot.append("_log"); else outputFileName_plot.append("_linear"); canvas->Print(std::string(outputFileName_plot).append(".pdf").data()); canvas->Print(std::string(outputFileName_plot).append(".root").data()); //delete label_cms; delete topPad; delete label_category; delete histogramRatio; delete histogramRatioUncertainty; delete line; delete bottomPad; delete canvas; }
void CreateDrawAndSaveHistogramWithFit(TH1* &histo, TString outputdir, TString outputname, bool saveoutput, bool close, bool autorange = true, double innerRange = 0.1 , double outerRange=1, bool excludeCenter=false, int fittype=2){ /** @brief saves Histogramm as *.root and *.png and if wanted closes the histograms at the end * @details This mehtod create a histogramm and save it as root and png file. If you choose close, the canvas is closed after the histogram was saved */ setPandaStyle(); TString name = TString(histo->GetName()); TString title = TString(histo->GetTitle()); TCanvas * canvas = new TCanvas("c_"+name, title, 0,0,1500,1000); histo->Draw(); TF1 * fit; TF1 * fitinner; TF1 * fitouter; if(excludeCenter){ fit = andi::doubleGaussFitExcludeCenter(histo, false, innerRange, outerRange); } else if (fittype==1){ fit = gaussFit(histo, innerRange); } else if (fittype==2){ fit = doubleGaussFit(histo, autorange, innerRange, outerRange); fitinner = getDoubleFit(histo, autorange, innerRange, outerRange, 1); fitouter = getDoubleFit(histo, autorange, innerRange, outerRange, 2); } else{ std::cout << "Type of fit is not defined"<< std::endl; } fit->SetLineColor(kRed); fit->SetLineStyle(7); fit->SetLineWidth(3); fit->Draw("SAME"); fitinner->SetLineColor(kBlue); fitinner->SetLineStyle(7); fitinner->SetLineWidth(3); fitinner->Draw("SAME"); fitouter->SetLineColor(kBlack); fitouter->SetLineStyle(7); fitouter->SetLineWidth(3); fitouter->Draw("SAME"); PandaSmartLabel("L"); if (saveoutput){ canvas->Print(outputdir + "root-files/" + outputname + ".root"); canvas->Print(outputdir + "png-files/" + outputname + ".png"); canvas->Print(outputdir + "pdf-files/" + outputname + ".pdf"); } if (close) canvas->Close(); }
void plot_ch1() { TFile* hfile=TFile::Open("Histo_ch1.root"); gStyle->SetPadTopMargin(0.10); gStyle->SetOptStat(0); gStyle->SetTitleSize(.5,"XYZ"); TLatex* tt=new TLatex(); tt->SetTextSize(0.05); if (false) { TString hNames[13]={"hMbc","hDeltaE","hMinvEta","hMinvEtaP","hMinvK0S","hPIDpi","hD0pi","hZ0pi","hNPxdHitspi","hVtxPValueK0S","hVtxPValueEta","hVtxPValueEtaP","hVtxPValueB0"}; bool hLog[13]={false,false,false,false,true,true,true,true,false,true,true,true,true}; float hCutLow[13] ={5.25,-0.1,0.45,0.93,0.48,0.2,-0.08,-0.1,1,1E-3,1E-3,1E-3,1E-3}; float hCutHigh[13]={5.29, 0.1,0.57,0.98,0.52,1.0,+0.08,+0.1,4,1E-3,1E-3,1E-3,1E-3}; TLine* tl=new TLine(); tl->SetLineWidth(2); tl->SetLineColor(kRed+2); TCanvas* c1=new TCanvas("c1","Before Cuts"); c1->Divide(4,4); for (int i=0; i<13; ++i) { c1->cd(i+1); hfile->cd("AllCandidates"); TH1* htmp=(TH1F*)gDirectory->Get(hNames[i]); if (htmp) htmp->DrawCopy(); float ymin=0; if (hLog[i]) { gPad->SetLogy(); ymin=1; } hfile->cd("AllCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetFillColor(kYellow); htmp_is->DrawCopy("same"); } hfile->cd("AllGoodCandidates"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_good"); if (htmp_is) { htmp_is->SetFillColor(kBlue); htmp_is->DrawCopy("same"); } hfile->cd("AllGoodCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_is_good"); if (htmp_is) { htmp_is->SetFillColor(kGreen); htmp_is->DrawCopy("same"); } hfile->cd("BestCandidates"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_best"); if (htmp_is) { htmp_is->SetLineColor(kRed); htmp_is->DrawCopy("same"); } hfile->cd("BestCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_is_best"); if (htmp_is) { htmp_is->SetLineColor(kViolet); htmp_is->DrawCopy("same"); } tl->DrawLine(hCutLow[i],ymin,hCutLow[i],htmp->GetMaximum()*1.05); tl->DrawLine(hCutHigh[i],ymin,hCutHigh[i],htmp->GetMaximum()*1.05); } c1->cd(16); TH1* htmp=(TH1F*)hfile->Get("hNCands"); if (htmp) htmp->DrawCopy(); tt->DrawLatexNDC(0.3,0.6,Form("All cands #e: %3.2f",htmp->GetEntries()/10000.)); tt->DrawLatexNDC(0.3,0.5,Form("All cands multiplicity: %3.2f",htmp->GetMean())); //c1->cd(16); htmp=(TH1F*)hfile->Get("hNGoodCands"); if (htmp) { htmp->SetFillColor(kGreen); htmp->DrawCopy("same"); tt->DrawLatexNDC(0.3,0.4,Form("All cands #e: %3.2f",htmp->GetEntries()/10000.)); tt->DrawLatexNDC(0.3,0.3,Form("Good cands multiplicity: %3.2f",htmp->GetMean())); } c1->cd(15); channel(c1,0.3,0.3); hfile->cd(); } if(true) { TString hNames[6]={"hMbc","hDeltaE","hMinvEta","hMinvEtaP","hMinvK0S","hPIDpi"}; bool hLog[6]={false,false,false,false,true,true}; float hCutLow[6] ={5.25,-0.1,0.45,0.93,0.48,0.2}; float hCutHigh[6]={5.29, 0.1,0.57,0.98,0.52,1.0}; TLine* tl=new TLine(); tl->SetLineWidth(2); tl->SetLineColor(kRed+2); TCanvas* c1=new TCanvas("c1","Before Cuts",900,600); c1->Divide(3,2); TLegend* tleg=new TLegend(0.2,0.4,0.6,0.89); tleg->SetFillStyle(0); for (int i=0; i<6; ++i) { c1->cd(i+1); hfile->cd("AllCandidates"); TH1* htmp=(TH1F*)gDirectory->Get(hNames[i]); if (htmp) { htmp->GetXaxis()->SetTitleOffset(.7); htmp->GetXaxis()->SetTitleSize(0.08); htmp->DrawCopy(); if (i==0)tleg->AddEntry(htmp,"All cands","l"); } float ymin=0; if (hLog[i]) { gPad->SetLogy(); ymin=1; } hfile->cd("AllCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetFillColor(kYellow); htmp_is->DrawCopy("same"); if (i==0)tleg->AddEntry(htmp_is,"MC match","f"); } hfile->cd("AllGoodCandidates"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetFillColor(kBlue); htmp_is->DrawCopy("same"); if (i==0)tleg->AddEntry(htmp_is,"Good cands","f"); } hfile->cd("AllGoodCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetFillColor(kGreen); htmp_is->DrawCopy("same"); if (i==0)tleg->AddEntry(htmp_is," \" MC match","f"); } tl->DrawLine(hCutLow[i],ymin,hCutLow[i],htmp->GetMaximum()*1.05); tl->DrawLine(hCutHigh[i],ymin,hCutHigh[i],htmp->GetMaximum()*1.05); if (i==0) tleg->Draw(); } channel(c1); c1->Print("Ch1_distr.pdf"); c1->Print("Ch1_distr.png"); TCanvas* c2=new TCanvas("c2","Before Cuts",900,600); c2->Divide(3,2); TLegend* tleg=new TLegend(0.2,0.6,0.6,0.89); for (int i=0; i<6; ++i) { c2->cd(i+1); hfile->cd("BestCandidates"); TH1* htmp=(TH1F*)gDirectory->Get(hNames[i]); float ymin=0; if (hLog[i]) { gPad->SetLogy(); ymin=1; } if (htmp) { htmp->GetXaxis()->SetTitleOffset(.7); htmp->GetXaxis()->SetTitleSize(0.08); htmp->SetMinimum(ymin); htmp->SetFillColor(kBlue); htmp->DrawCopy(); if (i==0)tleg->AddEntry(htmp,"Best cands","f"); } hfile->cd("BestCandidatesIsSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetFillColor(kGreen); htmp_is->DrawCopy("same"); if (i==0)tleg->AddEntry(htmp_is," \" MC match","f"); } hfile->cd("BestCandidatesIsNotSignal"); TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]); if (htmp_is) { htmp_is->SetLineColor(kBlack); htmp_is->SetLineStyle(2); htmp_is->DrawCopy("same"); if (i==0)tleg->AddEntry(htmp_is," \" SXF","l"); } tl->DrawLine(hCutLow[i],ymin,hCutLow[i],htmp->GetMaximum()*1.05); tl->DrawLine(hCutHigh[i],ymin,hCutHigh[i],htmp->GetMaximum()*1.05); if (i==0) tleg->Draw(); } channel(c2); c2->Print("Ch1_best_distr.pdf"); c2->Print("Ch1_best_distr.png"); } if (true) { hfile->cd(); TCanvas* cEvents=new TCanvas("cEvents","",600,300); cEvents->Divide(2); cEvents->cd(1); TH1* htmp=(TH1F*)hfile->Get("hNCands"); if (htmp) htmp->DrawCopy(); tt->DrawLatexNDC(0.3,0.6,Form("All cands multiplicity: %3.2f",htmp->GetMean())); tt->DrawLatexNDC(0.3,0.5,Form("All cands #epsilon: %3.3f",htmp->GetEntries()/10000.)); cEvents->cd(2); htmp=(TH1F*)hfile->Get("hNGoodCands"); if (htmp) { htmp->SetFillColor(kBlue); htmp->DrawCopy(); tt->DrawLatexNDC(0.3,0.5,Form("Good cands #epsilon: %3.3f",htmp->GetEntries()/10000.)); tt->DrawLatexNDC(0.3,0.6,Form("Good cands multiplicity: %3.2f",htmp->GetMean())); } hfile->cd(); // Statistics TH1* hEvents=(TH1F*)hfile->Get("hEvents"); cout << "Total number of events: " << hEvents->GetBinContent(1) << " " << hEvents->GetBinContent(10)<< endl; cout << "Total number of events passed: " << hEvents->GetBinContent(2) << " " << hEvents->GetBinContent(11)<< endl; cout << "Total number of signal events passed: " << hEvents->GetBinContent(3) << " " << hEvents->GetBinContent(12)<< endl; channel(cEvents,0.5,0.93); cEvents->Print("Ch1_events.pdf"); cEvents->Print("Ch1_events.png"); } hfile->cd("BestCandidatesDeltaT"); // MC DT TH1* hTrueDT_best=(TH1F*)gDirectory->Get("hTrueDT_best"); TH1* hTrueDT_TrueB0_best=(TH1F*)gDirectory->Get("hTrueDT_TrueB0_best"); hTrueDT_TrueB0_best->SetLineColor(kRed); TH1* hTrueDT_TrueB0bar_best=(TH1F*)gDirectory->Get("hTrueDT_TrueB0bar_best"); hTrueDT_TrueB0bar_best->SetLineColor(kBlue); TH1* hTrueDT_TagB0_best=(TH1F*)gDirectory->Get("hTrueDT_TagB0_best"); hTrueDT_TagB0_best->SetLineColor(kRed); TH1* hTrueDT_TagB0bar_best=(TH1F*)gDirectory->Get("hTrueDT_TagB0bar_best"); hTrueDT_TagB0bar_best->SetLineColor(kBlue); // Reco DT TH1* hDT_best=(TH1F*)gDirectory->Get("hDT_best"); TH1* hDT_TrueB0_best=(TH1F*)gDirectory->Get("hDT_TrueB0_best"); hDT_TrueB0_best->SetLineColor(kRed); TH1* hDT_TrueB0bar_best=(TH1F*)gDirectory->Get("hDT_TrueB0bar_best"); hDT_TrueB0bar_best->SetLineColor(kBlue); TH1* hDT_TagB0_best=(TH1F*)gDirectory->Get("hDT_TagB0_best"); hDT_TagB0_best->SetLineColor(kRed); TH1* hDT_TagB0bar_best=(TH1F*)gDirectory->Get("hDT_TagB0bar_best"); hDT_TagB0bar_best->SetLineColor(kBlue); // define the number of parameters and fit range for the function fitFunc. Int_t npar = 9; Double_t min_range = -20.0; Double_t max_range = 20.0; TF1 * myFitFunc = new TF1("fitFunc", fitFunc, min_range, max_range, npar); myFitFunc->SetParName(0, "norm"); myFitFunc->SetParName(1, "Bias_{C}"); myFitFunc->SetParName(2, "#sigma_{C}"); myFitFunc->SetParName(3, "Bias_{T}"); myFitFunc->SetParName(4, "#sigma_{T}"); myFitFunc->SetParName(5, "Bias_{O}"); myFitFunc->SetParName(6, "#sigma_{O}"); myFitFunc->SetParName(7, "f_{C}"); myFitFunc->SetParName(8, "f_{T}"); myFitFunc->SetParameters(1500.0, 0., 1., 0., 1.5, 0, 3., 0.4, 0.3); myFitFunc->SetParLimits(0, 0.0, 2500.0); // norm myFitFunc->SetParLimits(1, -2.0, 2.0); // mu1 myFitFunc->SetParLimits(2, 0.1, 1.); // sigma1 myFitFunc->SetParLimits(3, -4.0, +4.0); // mu2 myFitFunc->SetParLimits(4, 1., 3.); // sigma2 myFitFunc->SetParLimits(5, -4.0, +4.0); // mu3 myFitFunc->SetParLimits(6, 2., 20.); // sigma3 myFitFunc->SetParLimits(7, 0.0, 1.0); // frac1 myFitFunc->SetParLimits(8, 0.0, 1.0); // frac2 myFitFunc->SetLineWidth(2); if (false) { TCanvas* cDtAll=new TCanvas("cDtAll"); cDtAll->Divide(3,2); cDtAll->cd(1); //hTrueDT_best->Draw(); hTrueDT_best->Fit("fitFunc", "LE"); hTrueDT_best->Draw("e"); TF1 *gC = new TF1("gC","gaus",min_range, max_range); TF1 *gT = new TF1("gT","gaus",min_range, max_range); TF1 *gO = new TF1("gO","gaus",min_range, max_range); double* fitParams=myFitFunc->GetParameters(); gC->SetLineColor(kRed); gC->SetLineStyle(2); gC->SetParameter(0,fitParams[0]*fitParams[7]); gC->SetParameter(1,fitParams[1]); gC->SetParameter(2,fitParams[2]); cout << "Core " << gC->GetParameter(0) << " " << gC->GetParameter(1) << " " << gC->GetParameter(2)<< endl; gT->SetLineColor(kGreen); gT->SetLineStyle(2); gT->SetParameter(0,fitParams[0]*fitParams[8]); gT->SetParameter(1,fitParams[3]); gT->SetParameter(2,fitParams[4]); cout << "Tail " << gT->GetParameter(0) << " " << gT->GetParameter(1) << " " << gT->GetParameter(2)<< endl; gO->SetLineColor(kBlue); gO->SetLineStyle(2); gO->SetParameter(0,fitParams[0]*(1-fitParams[7]-fitParams[8])); gO->SetParameter(1,fitParams[5]); gO->SetParameter(2,fitParams[6]); cout << "Outlier " << gO->GetParameter(0) << " " << gO->GetParameter(1) << " " << gO->GetParameter(2)<< endl; gC->Draw("same"); gT->Draw("same"); gO->Draw("same"); //return; cDtAll->cd(2); hTrueDT_TrueB0_best->Draw(); hTrueDT_TrueB0bar_best->Draw("same"); cDtAll->cd(3); hTrueDT_TagB0_best->Draw(); hTrueDT_TagB0bar_best->Draw("same"); cDtAll->cd(4); //hDT_best->Draw(); hDT_best->Fit("fitFunc", "LE"); hDT_best->Draw("e"); TF1 *gC = new TF1("gC","gaus",min_range, max_range); TF1 *gT = new TF1("gT","gaus",min_range, max_range); TF1 *gO = new TF1("gO","gaus",min_range, max_range); double* fitParams=myFitFunc->GetParameters(); gC->SetLineColor(kRed); gC->SetLineStyle(2); gC->SetParameter(0,fitParams[0]*fitParams[7]); gC->SetParameter(1,fitParams[1]); gC->SetParameter(2,fitParams[2]); cout << "Core " << gC->GetParameter(0) << " " << gC->GetParameter(1) << " " << gC->GetParameter(2)<< endl; gT->SetLineColor(kGreen); gT->SetLineStyle(2); gT->SetParameter(0,fitParams[0]*fitParams[8]); gT->SetParameter(1,fitParams[3]); gT->SetParameter(2,fitParams[4]); cout << "Tail " << gT->GetParameter(0) << " " << gT->GetParameter(1) << " " << gT->GetParameter(2)<< endl; gO->SetLineColor(kBlue); gO->SetLineStyle(2); gO->SetParameter(0,fitParams[0]*(1-fitParams[7]-fitParams[8])); gO->SetParameter(1,fitParams[5]); gO->SetParameter(2,fitParams[6]); cout << "Outlier " << gO->GetParameter(0) << " " << gO->GetParameter(1) << " " << gO->GetParameter(2)<< endl; gC->Draw("same"); gT->Draw("same"); gO->Draw("same"); cDtAll->cd(5); hDT_TrueB0_best->Draw(); hDT_TrueB0bar_best->Draw("same"); cDtAll->cd(6); hDT_TagB0_best->Draw(); hDT_TagB0bar_best->Draw("same"); } gStyle->SetOptStat(0); gStyle->SetFitFormat("4.3g"); gStyle->SetStatFontSize(0.05); gStyle->SetStatFont(62); gStyle->SetStatH(0.15); gStyle->SetStatW(0.18); TCanvas* cDt=new TCanvas("cDt"); //hDT_best->Draw(); hDT_best->Fit("fitFunc", "LE"); hDT_best->Draw("e"); TF1 *gC = new TF1("gC","gaus",min_range, max_range); TF1 *gT = new TF1("gT","gaus",min_range, max_range); TF1 *gO = new TF1("gO","gaus",min_range, max_range); double* fitParams=myFitFunc->GetParameters(); gC->SetLineColor(kRed); gC->SetLineStyle(2); gC->SetParameter(0,fitParams[0]*fitParams[7]); gC->SetParameter(1,fitParams[1]); gC->SetParameter(2,fitParams[2]); cout << "Core " << gC->GetParameter(0) << " " << gC->GetParameter(1) << " " << gC->GetParameter(2)<< endl; gT->SetLineColor(kGreen); gT->SetLineStyle(2); gT->SetParameter(0,fitParams[0]*fitParams[8]); gT->SetParameter(1,fitParams[3]); gT->SetParameter(2,fitParams[4]); cout << "Tail " << gT->GetParameter(0) << " " << gT->GetParameter(1) << " " << gT->GetParameter(2)<< endl; gO->SetLineColor(kBlue); gO->SetLineStyle(2); gO->SetParameter(0,fitParams[0]*(1-fitParams[7]-fitParams[8])); gO->SetParameter(1,fitParams[5]); gO->SetParameter(2,fitParams[6]); cout << "Outlier " << gO->GetParameter(0) << " " << gO->GetParameter(1) << " " << gO->GetParameter(2)<< endl; gC->Draw("same"); gT->Draw("same"); gO->Draw("same"); double resoDt=(gC->GetParameter(2)*gC->GetParameter(0))+(gO->GetParameter(2)*gO->GetParameter(0))+(gT->GetParameter(2)*gT->GetParameter(0)); double sumW=gC->GetParameter(0)+gO->GetParameter(0)+gT->GetParameter(0); cout << "Mean(DT) = " << resoDt/sumW << endl; TLegend* tleg=new TLegend(0.2,.6,0.4,0.89,"Fit","NDC"); tleg->AddEntry(gC,"Core","l"); tleg->AddEntry(gT,"Tail","l"); tleg->AddEntry(gO,"Outlier","l"); tleg->Draw(); tt->DrawLatexNDC(0.65,0.35,Form("<#Deltat>: %3.2f ps",resoDt/sumW)); channel(cDt,0.3,0.96); cDt->Print("Ch1_Dt.pdf"); cDt->Print("Ch1_Dt.png"); TCanvas* cAsym=new TCanvas("cAsym"); TPad *pad1 = new TPad("pad1", "The pad 80% of the height",0.0,0.3,1.0,1.0,0); TPad *pad2 = new TPad("pad2", "The pad 20% of the height",0.0,0.0,1.0,0.3,0); pad1->Draw(); pad2->Draw(); pad1->cd(); hDT_TagB0_best->SetMarkerStyle(24); hDT_TagB0_best->SetMarkerColor(kBlue); hDT_TagB0_best->SetLineColor(kBlue); hDT_TagB0_best->Draw("histoe"); hDT_TagB0bar_best->SetMarkerStyle(20); hDT_TagB0bar_best->SetMarkerColor(kRed); hDT_TagB0bar_best->SetLineColor(kRed); hDT_TagB0bar_best->Draw("histo e same"); TLegend* tleg=new TLegend(0.2,.6,0.4,0.89,"Flavour","NDC"); tleg->AddEntry(hDT_TagB0_best,"B_{0}","l"); tleg->AddEntry(hDT_TagB0bar_best,"#bar{B_{0}}","l"); tleg->Draw(); pad2->cd(); TH1* hDT_Tag_best_num=hDT_TagB0_best->Clone(); hDT_Tag_best_num->Add(hDT_TagB0bar_best,-1.); TH1* hDT_Tag_best_den=hDT_TagB0_best->Clone(); hDT_Tag_best_den->Add(hDT_TagB0bar_best,+1.); TH1* hDT_Tag_best_asym=hDT_Tag_best_num->Clone(); hDT_Tag_best_asym->Divide(hDT_Tag_best_den); hDT_Tag_best_asym->SetMaximum(+1.05); hDT_Tag_best_asym->SetMinimum(-1.05); hDT_Tag_best_asym->SetLineColor(kBlack); hDT_Tag_best_asym->SetMarkerColor(kBlack); hDT_Tag_best_asym->SetMarkerStyle(20); gPad->SetGridy(); hDT_Tag_best_asym->Draw("e"); hDT_Tag_best_asym->GetYaxis()->SetNdivisions(503); hDT_Tag_best_asym->GetYaxis()->SetTitle("Asymmetry"); hDT_Tag_best_asym->GetYaxis()->SetTitleOffset(0.3); hDT_Tag_best_asym->GetYaxis()->SetTitleSize(0.1); hDT_Tag_best_asym->GetYaxis()->SetLabelSize(0.1); hDT_Tag_best_asym->GetXaxis()->SetLabelSize(0.1); hDT_Tag_best_asym->GetXaxis()->SetTitleSize(0.1); hDT_Tag_best_asym->Draw("e"); // TF1* mysin=new TF1("mysin","[0]*sin([1]*x)",-10,10); // mysin->SetParameter(0,0.2); // mysin->SetParameter(1,0.2); // hDT_Tag_best_asym->Fit("mysin","R"); channel(cAsym,0.5,0.96); cAsym->Print("Ch1_Asym.pdf"); cAsym->Print("Ch1_Asym.png"); }
//***############## main fitting Fxn ################ *****// void ZeetimeFitAndPlot( char *Ifile ){ /** Plot Options***/ //gROOT->Reset(); // gROOT->Clear(); gROOT->SetStyle("Plain") ; gROOT->SetBatch(kFALSE); gStyle->SetOptTitle(0); gStyle->SetOptStat(0); gStyle->SetOptFit(1); gStyle->SetStatX(.89); gStyle->SetStatY(.89) ; gStyle->SetStatBorderSize(0); //gStyle->SetOptStat(1111111) gStyle->SetCanvasColor(kWhite); // background is no longer mouse-dropping white gStyle->SetPalette(1); // blue to red false color palette. Use 9 for b/w gStyle->SetCanvasBorderMode(0); // turn off canvas borders gStyle->SetPadBorderMode(0); gStyle->SetPaintTextFormat("5.2f"); // What precision to put numbers if plotted with "TEXT" // For publishing: gStyle->SetLineWidth(2); gStyle->SetTextSize(1.1); gStyle->SetLabelSize(0.06,"xy"); gStyle->SetTitleSize(0.08,"xy"); gStyle->SetTitleOffset(1.2,"x"); gStyle->SetTitleOffset(1.0,"y"); gStyle->SetPadTopMargin(0.1); gStyle->SetPadRightMargin(0.1); gStyle->SetPadBottomMargin(0.16); gStyle->SetPadLeftMargin(0.12); TGaxis::SetMaxDigits(2); // Set Axis to be of the form 0.11 10^N TFile *ifile = new TFile(Ifile); TF1 *fitFcn = new TF1("fitFcn", mygaus, FitLowRange, FitHighRange, 3 ); fitFcn->SetNpx(500); fitFcn->SetLineWidth(4); fitFcn->SetLineStyle(5); fitFcn->SetLineColor(kBlue); TH1F*h_Seed_TimeEBEB = (TH1F*)ifile->Get("EBEB/seed time"); TH1F*h_Seed_TimeEEEE = (TH1F*)ifile->Get("EEEE/seed time"); TH1F*h_TofCor_TimeEBEB = (TH1F*)ifile->Get("EBEB/TOF-corr time difference of seeds"); TH1F*h_TofCor_TimeEEEE = (TH1F*)ifile->Get("EEEE/TOF-corr time difference of seeds"); if(h_Seed_TimeEBEB == 0){ std::cout <<"!! Histogram Does not exist!!" << std::endl; throw 1;} if(h_Seed_TimeEEEE == 0){ std::cout <<"!! Histogram Does not exist!!" << std::endl; throw 1;} if(h_TofCor_TimeEBEB == 0){ std::cout <<"!! Histogram Does not exist!!" << std::endl; throw 1;} if(h_TofCor_TimeEEEE == 0){ std::cout <<"!! Histogram Does not exist!!" << std::endl; throw 1;} h_Seed_TimeEBEB->SetTitle("Seed Time[ns]"); h_Seed_TimeEBEB->SetMarkerStyle(20); h_Seed_TimeEBEB->SetMarkerSize(0.8); h_Seed_TimeEBEB->SetStats(1); h_Seed_TimeEBEB->SetTitleSize(0.08, "x"); h_Seed_TimeEBEB->SetTitleOffset(1.0, "x"); h_Seed_TimeEBEB->SetTitleSize(0.06, "y"); h_Seed_TimeEBEB->SetTitleOffset(0.95, "y"); h_Seed_TimeEBEB->SetYTitle("Number of Seeds/0.05ns"); h_Seed_TimeEBEB->SetXTitle("t_{seed}[ns]"); h_Seed_TimeEBEB->GetXaxis()->SetRangeUser(FitLowRange, FitHighRange); h_Seed_TimeEBEB->GetXaxis()->SetNoExponent(kFALSE); /** Set parms as parms of Fit Fxn **/ fitFcn->SetParameters(500, h_Seed_TimeEBEB->GetMean(), h_Seed_TimeEBEB->GetRMS() ); fitFcn->SetParNames("CONST", "#mu(ns)", "#sigma(ns)"); h_Seed_TimeEBEB->Fit("fitFcn", "LL"); /**Fit with improved LL**/ std::cout << "Printing Fit Parameters for EBEB ...... " << std::endl; printf("Integral of function in EBEB = %g\n", fitFcn->Integral( FitLowRange, FitHighRange)); //*** retrive fit results***// int npar = fitFcn->GetNpar(); TVirtualFitter *fit = TVirtualFitter::GetFitter(); fit->PrintResults(2,0.); TMatrixD *CovMatrix = new TMatrixD ( npar, npar, fit->GetCovarianceMatrix() ); CovMatrix->Print(); TCanvas *cBB = new TCanvas("cBB","EB-EB",200,10,800,900); cBB->SetGridx(); cBB->SetGridy(); cBB->GetFrame()->SetFillColor(21); cBB->GetFrame()->SetBorderMode(-1); cBB->GetFrame()->SetBorderSize(5); /* c1->Divide(2,1); */ cBB->cd(); h_Seed_TimeEBEB->Draw(); fitFcn->Draw("sames"); cBB->SetLogy(0); // draw the legend TLegend *leg = new TLegend(0.15,0.72,0.3,0.85); leg->Clear(); leg->SetTextFont(72); leg->SetTextSize(0.04); leg->AddEntry(h_Seed_TimeEBEB,"EB","lpe"); leg->AddEntry(fitFcn,"GAUS","l"); leg->Draw(); cBB->SaveAs("Seed_Time_DoubleElectron_Run2012A-EB-EB.png"); //EE seed h_Seed_TimeEEEE->SetTitle("Seed Time[ns]"); h_Seed_TimeEEEE->SetMarkerStyle(20); h_Seed_TimeEEEE->SetMarkerSize(0.8); h_Seed_TimeEEEE->SetStats(1); h_Seed_TimeEEEE->SetTitleSize(0.08, "x"); h_Seed_TimeEEEE->SetTitleOffset(1.0, "x"); h_Seed_TimeEEEE->SetTitleSize(0.06, "y"); h_Seed_TimeEEEE->SetTitleOffset(0.95, "y"); h_Seed_TimeEEEE->SetYTitle("Number of Seeds/0.05ns"); h_Seed_TimeEEEE->SetXTitle("t_{seed}[ns]"); h_Seed_TimeEEEE->GetXaxis()->SetRangeUser(FitLowRange, FitHighRange); h_Seed_TimeEEEE->GetXaxis()->SetNoExponent(kFALSE); /** Set parms as parms of Fit Fxn **/ fitFcn->SetParameters(500, h_Seed_TimeEEEE->GetMean(), h_Seed_TimeEEEE->GetRMS() ); fitFcn->SetParNames("CONST", "#mu(ns)", "#sigma(ns)"); h_Seed_TimeEEEE->Fit("fitFcn", "LL"); /**Fit with improved LL**/ std::cout << "Printing Fit Parameters for EEEE ...... " << std::endl; printf("Integral of function in EEEE = %g\n", fitFcn->Integral( FitLowRange, FitHighRange)); //*** retrive fit results***// int npar2 = fitFcn->GetNpar(); TVirtualFitter *fit2 = TVirtualFitter::GetFitter(); fit2->PrintResults(2,0.); TMatrixD *CovMatrix2 = new TMatrixD ( npar2, npar2, fit2->GetCovarianceMatrix() ); CovMatrix2->Print(); TCanvas *cEE = new TCanvas("cEE","EE-EE",200,10,800,900); cEE->SetGridx(); cEE->SetGridy(); cEE->GetFrame()->SetFillColor(21); cEE->GetFrame()->SetBorderMode(-1); cEE->GetFrame()->SetBorderSize(5); /* c1->Divide(2,1); */ cEE->cd(); h_Seed_TimeEEEE->Draw(); fitFcn->Draw("sames"); cEE->SetLogy(0); // draw the legend TLegend *leg1 = new TLegend(0.15,0.72,0.3,0.85); leg1->Clear(); leg1->SetTextFont(72); leg1->SetTextSize(0.04); leg1->AddEntry(h_Seed_TimeEEEE,"EE","lpe"); leg1->AddEntry(fitFcn,"GAUS","l"); leg1->Draw(); cEE->SaveAs("Seed_Time_DoubleElectron_Run2012A-EE-EE.png"); //EB TOF-corr seed Diff h_TofCor_TimeEBEB->SetTitle("TOF-Corrected(t_{1}-t_{2})[ns]"); h_TofCor_TimeEBEB->SetMarkerStyle(20); h_TofCor_TimeEBEB->SetMarkerSize(0.8); h_TofCor_TimeEBEB->SetStats(1); h_TofCor_TimeEBEB->SetTitleSize(0.08, "x"); h_TofCor_TimeEBEB->SetTitleOffset(1.0, "x"); h_TofCor_TimeEBEB->SetTitleSize(0.06, "y"); h_TofCor_TimeEBEB->SetTitleOffset(0.95, "y"); h_TofCor_TimeEBEB->SetYTitle("Number Of Seed Pair/0.05ns"); h_TofCor_TimeEBEB->SetXTitle("(t_{seed1} - t_{seed2})TOF-Corrected[ns]"); h_TofCor_TimeEBEB->GetXaxis()->SetRangeUser(FitLowRange, FitHighRange); h_TofCor_TimeEBEB->GetXaxis()->SetNoExponent(kFALSE); /** Set parms as parms of Fit Fxn **/ fitFcn->SetParameters(500, h_TofCor_TimeEBEB->GetMean(), h_TofCor_TimeEBEB->GetRMS() ); fitFcn->SetParNames("CONST", "#mu(ns)", "#sigma(ns)"); h_TofCor_TimeEBEB->Fit("fitFcn", "LL"); /**Fit with improved LL**/ std::cout << "Printing Fit Parameters for EBEB-Tof ...... " << std::endl; printf("Integral of function in EBEB Tof = %g\n", fitFcn->Integral( FitLowRange, FitHighRange)); //*** retrive fit results***// int npar3 = fitFcn->GetNpar(); TVirtualFitter *fit3 = TVirtualFitter::GetFitter(); fit3->PrintResults(2,0.); TMatrixD *CovMatrix3 = new TMatrixD ( npar3, npar3, fit3->GetCovarianceMatrix() ); CovMatrix3->Print(); TCanvas *cBB1 = new TCanvas("cBB1","EB-EB TOF-corr",200,10,800,900); cBB1->SetGridx(); cBB1->SetGridy(); cBB1->GetFrame()->SetFillColor(21); cBB1->GetFrame()->SetBorderMode(-1); cBB1->GetFrame()->SetBorderSize(5); /* c1->Divide(2,1); */ cBB1->cd(); h_TofCor_TimeEBEB->Draw(); fitFcn->Draw("sames"); cBB1->SetLogy(0); // draw the legend TLegend *leg2 = new TLegend(0.15,0.72,0.3,0.85); leg2->SetTextFont(72); leg2->SetTextSize(0.04); leg2->AddEntry(h_TofCor_TimeEBEB,"EB","lpe"); leg2->AddEntry(fitFcn,"GAUS","l"); leg2->Draw(); cBB1->SaveAs("TOF-Corrected-Seed_Time_DoubleElectron_Run2012A-EB-EB.png"); //EE: TOF-corr seed Diff h_TofCor_TimeEEEE->SetTitle("TOF-Corrected(t_{1}-t_{2})[ns]"); h_TofCor_TimeEEEE->SetMarkerStyle(20); h_TofCor_TimeEEEE->SetMarkerSize(0.8); h_TofCor_TimeEEEE->SetStats(1); h_TofCor_TimeEEEE->SetTitleSize(0.08, "x"); h_TofCor_TimeEEEE->SetTitleOffset(1.0, "x"); h_TofCor_TimeEEEE->SetTitleSize(0.06, "y"); h_TofCor_TimeEEEE->SetTitleOffset(0.95, "y"); h_TofCor_TimeEEEE->SetYTitle("Number Of Seed Pair/0.05ns"); h_TofCor_TimeEEEE->SetXTitle("(t_{seed1} - t_{seed2})TOF-Corrected[ns]"); h_TofCor_TimeEEEE->GetXaxis()->SetRangeUser(FitLowRange, FitHighRange); h_TofCor_TimeEEEE->GetXaxis()->SetNoExponent(kFALSE); /** Set parms as parms of Fit Fxn **/ fitFcn->SetParameters(500, h_TofCor_TimeEEEE->GetMean(), h_TofCor_TimeEEEE->GetRMS() ); fitFcn->SetParNames("CONST", "#mu(ns)", "#sigma(ns)"); h_TofCor_TimeEEEE->Fit("fitFcn", "LL"); /**Fit with improved LL**/ std::cout << "Printing Fit Parameters for EEEE-Tof ...... " << std::endl; printf("Integral of function in EEEE Tof = %g\n", fitFcn->Integral( FitLowRange, FitHighRange)); //*** retrive fit results***// int npar4 = fitFcn->GetNpar(); TVirtualFitter *fit4 = TVirtualFitter::GetFitter(); fit4->PrintResults(2,0.); TMatrixD *CovMatrix4 = new TMatrixD ( npar4, npar4, fit4->GetCovarianceMatrix() ); CovMatrix4->Print(); TCanvas *cEE1 = new TCanvas("cEE1","EE-EE TOF-corr",200,10,800,900); cEE1->SetGridx(); cEE1->SetGridy(); cEE1->GetFrame()->SetFillColor(21); cEE1->GetFrame()->SetBorderMode(-1); cEE1->GetFrame()->SetBorderSize(5); /* c1->Divide(2,1); */ cEE1->cd(); h_TofCor_TimeEEEE->Draw(); fitFcn->Draw("sames"); cEE1->SetLogy(0); // draw the legend TLegend *leg3 = new TLegend(0.15,0.72,0.3,0.85); leg3->SetTextFont(72); leg3->SetTextSize(0.04); leg3->AddEntry(h_TofCor_TimeEEEE,"EE","lpe"); leg3->AddEntry(fitFcn,"GAUS","l"); leg3->Draw(); cEE1->SaveAs("TOF-Corrected-Seed_Time_DoubleElectron_Run2012A-EE-EE.png"); }
void showFunctions1d(std::vector<TF1*>& functions, const std::vector<std::string>& legendEntries, const TString& xAxisTitle, double yMin, double yMax, const TString& yAxisTitle, const std::string& outputFileName) { assert(functions.size() == legendEntries.size()); TCanvas* canvas = new TCanvas("canvas", "canvas", 800, 600); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetLeftMargin(0.12); canvas->SetBottomMargin(0.12); assert(functions.size() > 0); TF1* refFunction = functions[0]; TH1* dummyHistogram = new TH1F("dummyHistogram", "dummyHistogram", 10, refFunction->GetXmin(), refFunction->GetXmax()); dummyHistogram->SetStats(false); dummyHistogram->SetTitle(""); dummyHistogram->SetMinimum(-TMath::Log(yMax)); dummyHistogram->SetMaximum(-TMath::Log(yMax) + 5.); TAxis* xAxis = dummyHistogram->GetXaxis(); xAxis->SetTitle(xAxisTitle.Data()); xAxis->SetTitleOffset(1.15); TAxis* yAxis = dummyHistogram->GetYaxis(); yAxis->SetTitle(Form("-log(%s)", yAxisTitle.Data())); yAxis->SetTitleOffset(1.30); dummyHistogram->Draw("axis"); int colors[] = { 1, 2, 3, 4, 5, 6, 7, 15 }; int numFunctions = functions.size(); if ( numFunctions > 8 ) { std::cerr << "<showFunctions1d>:" << std::endl; std::cerr << "Number of functions must not exceed 8 !!" << std::endl; assert(0); } for ( int iFunction = 0; iFunction < numFunctions; ++iFunction ) { TF1* function = functions[iFunction]; function->SetLineColor(colors[iFunction]); function->SetLineWidth(2); function->Draw("same"); } TLegend* legend = new TLegend(0.68, 0.89 - (0.03 + 0.040*numFunctions), 0.89, 0.89, "", "brNDC"); legend->SetBorderSize(0); legend->SetFillColor(0); legend->SetTextSize(0.035); for ( int iFunction = 0; iFunction < numFunctions; ++iFunction ) { TF1* function = functions[iFunction]; const std::string& legendEntry = legendEntries[iFunction]; legend->AddEntry(function, legendEntry.data(), "l"); } legend->Draw(); canvas->Update(); size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data()); canvas->Print(std::string(outputFileName_plot).append(".png").data()); canvas->Print(std::string(outputFileName_plot).append(".pdf").data()); delete dummyHistogram; delete legend; delete canvas; }
TF1* fit(TH1D* h, TH1D* hMCSignal, TH1D* hMCSwapped, Float_t ptmin, Float_t ptmax, Int_t j) { TCanvas* c = new TCanvas(Form("c_%.0f_%.0f_%d",ptmin,ptmax,j),"",600,600); TF1* f = new TF1(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"[0]*([7]*([9]*Gaus(x,[1],[2]*(1+[11]))/(sqrt(2*3.14159)*[2]*(1+[11]))+(1-[9])*Gaus(x,[1],[10]*(1+[11]))/(sqrt(2*3.14159)*[10]*(1+[11])))+(1-[7])*Gaus(x,[1],[8]*(1+[11]))/(sqrt(2*3.14159)*[8]*(1+[11])))+[3]+[4]*x+[5]*x*x+[6]*x*x*x", 1.7, 2.0); f->SetParLimits(4,-1000,1000); f->SetParLimits(10,0.001,0.05); f->SetParLimits(2,0.01,0.5); f->SetParLimits(8,0.02,0.2); f->SetParLimits(7,0,1); f->SetParLimits(9,0,1); f->SetParameter(0,setparam0); f->SetParameter(1,setparam1); f->SetParameter(2,setparam2); f->SetParameter(10,setparam10); f->SetParameter(9,setparam9); f->FixParameter(8,setparam8); f->FixParameter(7,1); f->FixParameter(1,fixparam1); f->FixParameter(3,0); f->FixParameter(4,0); f->FixParameter(5,0); f->FixParameter(6,0); f->FixParameter(11,0); h->GetEntries(); hMCSignal->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"q","",minhisto,maxhisto); hMCSignal->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"q","",minhisto,maxhisto); f->ReleaseParameter(1); hMCSignal->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); hMCSignal->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); hMCSignal->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L m","",minhisto,maxhisto); f->FixParameter(1,f->GetParameter(1)); f->FixParameter(2,f->GetParameter(2)); f->FixParameter(10,f->GetParameter(10)); f->FixParameter(9,f->GetParameter(9)); f->FixParameter(7,0); f->ReleaseParameter(8); f->SetParameter(8,setparam8); hMCSwapped->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); hMCSwapped->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L m","",minhisto,maxhisto); f->FixParameter(7,hMCSignal->Integral(0,1000)/(hMCSwapped->Integral(0,1000)+hMCSignal->Integral(0,1000))); f->FixParameter(8,f->GetParameter(8)); f->ReleaseParameter(3); f->ReleaseParameter(4); f->ReleaseParameter(5); f->ReleaseParameter(6); f->SetLineColor(kRed); h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"q","",minhisto,maxhisto); f->ReleaseParameter(1); f->SetParLimits(1,1.86,1.87); /* f->ReleaseParameter(11); f->SetParLimits(11,-1.,1.); */ h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L q","",minhisto,maxhisto); h->Fit(Form("f_%.0f_%.0f_%d",ptmin,ptmax,j),"L m","",minhisto,maxhisto); TF1* background = new TF1(Form("background_%.0f_%.0f_%d",ptmin,ptmax,j),"[0]+[1]*x+[2]*x*x+[3]*x*x*x"); background->SetParameter(0,f->GetParameter(3)); background->SetParameter(1,f->GetParameter(4)); background->SetParameter(2,f->GetParameter(5)); background->SetParameter(3,f->GetParameter(6)); background->SetLineColor(4); background->SetRange(minhisto,maxhisto); background->SetLineStyle(2); TF1* mass = new TF1(Form("mass_%.0f_%.0f_%d",ptmin,ptmax,j),"[0]*([3]*([4]*Gaus(x,[1],[2]*(1+[6]))/(sqrt(2*3.14159)*[2]*(1+[6]))+(1-[4])*Gaus(x,[1],[5]*(1+[6]))/(sqrt(2*3.14159)*[5]*(1+[6]))))"); mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(9),f->GetParameter(10),f->GetParameter(11)); mass->SetParError(0,f->GetParError(0)); mass->SetParError(1,f->GetParError(1)); mass->SetParError(2,f->GetParError(2)); mass->SetParError(3,f->GetParError(7)); mass->SetParError(4,f->GetParError(9)); mass->SetParError(5,f->GetParError(10)); mass->SetFillColor(kOrange-3); mass->SetFillStyle(3002); mass->SetLineColor(kOrange-3); mass->SetLineWidth(3); mass->SetLineStyle(2); TF1* massSwap = new TF1(Form("massSwap_%.0f_%.0f_%d",ptmin,ptmax,j),"[0]*(1-[2])*Gaus(x,[1],[3]*(1+[4]))/(sqrt(2*3.14159)*[3]*(1+[4]))"); massSwap->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(7),f->GetParameter(8),f->GetParameter(11)); massSwap->SetParError(0,f->GetParError(0)); massSwap->SetParError(1,f->GetParError(1)); massSwap->SetParError(2,f->GetParError(7)); massSwap->SetParError(3,f->GetParError(8)); massSwap->SetFillColor(kGreen+4); massSwap->SetFillStyle(3005); massSwap->SetLineColor(kGreen+4); massSwap->SetLineWidth(3); massSwap->SetLineStyle(1); h->SetXTitle("m_{#piK} (GeV/c^{2})"); h->SetYTitle("Entries / (5 MeV/c^{2})"); h->GetXaxis()->CenterTitle(); h->GetYaxis()->CenterTitle(); h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y"); h->GetXaxis()->SetTitleOffset(1.3); h->GetYaxis()->SetTitleOffset(1.8); h->GetXaxis()->SetLabelOffset(0.007); h->GetYaxis()->SetLabelOffset(0.007); h->GetXaxis()->SetTitleSize(0.045); h->GetYaxis()->SetTitleSize(0.045); h->GetXaxis()->SetTitleFont(42); h->GetYaxis()->SetTitleFont(42); h->GetXaxis()->SetLabelFont(42); h->GetYaxis()->SetLabelFont(42); h->GetXaxis()->SetLabelSize(0.04); h->GetYaxis()->SetLabelSize(0.04); h->SetMarkerSize(0.8); h->SetMarkerStyle(20); h->SetStats(0); h->Draw("e"); background->Draw("same"); mass->SetRange(minhisto,maxhisto); mass->Draw("same"); massSwap->SetRange(minhisto,maxhisto); massSwap->Draw("same"); f->Draw("same"); Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass; Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0); std::cout<<"YIELD="<<yield<<std::endl; TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextSize(0.04); leg->SetTextFont(42); leg->SetFillStyle(0); leg->AddEntry(h,"Data","pl"); leg->AddEntry(f,"Fit","l"); leg->AddEntry(mass,"D^{0}+#bar{D^{#lower[0.2]{0}}} Signal","f"); leg->AddEntry(massSwap,"K-#pi swapped","f"); leg->AddEntry(background,"Combinatorial","l"); leg->Draw("same"); DrawCmsTlatex("PbPb"); TLatex* tex; tex = new TLatex(0.22,0.83,"|y| < 1.0"); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.22,0.78,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax)); tex->SetNDC(); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); TString texper="%"; tex = new TLatex(0.22,0.72,Form("Centrality %.0f-%.0f%s",centMin,centMax,texper.Data())); tex->SetNDC(); tex->SetTextColor(1); tex->SetTextFont(42); tex->SetTextSize(0.045); tex->SetLineWidth(2); tex->Draw(); c->SaveAs(Form("plots/Mass_cent_%.0f_%.0f_pt_%.0f_%.0f_%s.pdf",centMin,centMax,ptmin,ptmax,tfend[j].Data())); return mass; }
// Determine sensitivity to tracker dynamic inefficiency // by studying ratio of jet responses in Runs G and F (and BCD / F, E / F) void drawAvsB() { setTDRStyle(); string epocha = "BCD";//"BCD";//"H";//"F";//"BCD";//"F";//"E";//"BCD";//"F"; string epochb = "GH";//"G";//"BCD";//"G";//"E";//"E";//"F";//"G"; // Add the rest as well string epocha2 = "";//"EF"; string epochb2 = "";//"G"; string type = "data"; vector<string> methods; methods.push_back("mpfchs1"); methods.push_back("ptchs"); bool nozjptb = false; bool nogjmpf = false; bool nogjptb = true; bool mjvsjes = false; vector<string> samples; samples.push_back("zeejet"); samples.push_back("zmmjet"); samples.push_back("gamjet"); //samples.push_back("multijet"); cout << "draw"<<epocha<<"vs"<<epochb<<endl; const char *ct = type.c_str(); const char *pa = epocha.c_str(); const char *pb = epochb.c_str(); const char *pa2 = epocha2.c_str(); const char *pb2 = epochb2.c_str(); TFile *fg = new TFile(Form("rootfiles/jecdata%s.root",pb),"READ"); assert(fg && !fg->IsZombie()); TFile *ff = new TFile(Form("rootfiles/jecdata%s.root",pa),"READ"); assert(ff && !ff->IsZombie()); TFile *fg2(0), *ff2(0); if (epochb2!="") fg2 = new TFile(Form("rootfiles/jecdata%s.root",pb2),"READ"); if (epocha2!="") ff2 = new TFile(Form("rootfiles/jecdata%s.root",pa2),"READ"); TH1D *h = new TH1D("h", Form(";p_{T,ref} (GeV);%s ratio (%s / %s)", (type=="ratio" ? "Data/MC" : type=="data" ? "Data/data" : "MC/MC"), (epocha + (epocha2!="" ? "+"+epocha2 : "")).c_str(), (epochb + (epochb2!="" ? "+"+epochb2 : "")).c_str()), 3470,30,3500); h->SetMinimum(0.90); h->SetMaximum(1.15); h->GetXaxis()->SetMoreLogLabels(); h->GetXaxis()->SetNoExponent(); if (epocha=="F" && epochb=="G") lumi_13TeV = "Run2016F+G, 3.1+7.1 fb^{-1}"; if (epocha=="BCD" && epochb=="G") lumi_13TeV = "Run2016BCD+H, 12.9+8.8 fb^{-1}"; if (epocha=="BCD" && epochb=="G") lumi_13TeV = "Run2016BCD+FearlyGH, 12.9+16.8 fb^{-1}"; if (epocha=="BCD" && epochb=="F") lumi_13TeV = "Run2016BCD+F, 13+3.1 fb^{-1}"; if (epocha=="BCD" && epochb=="E") lumi_13TeV = "Run2016BCD+E, 13+4.0 fb^{-1}"; if (epocha=="E" && epochb=="F") lumi_13TeV = "Run2016E+F, 4.0+3.1 fb^{-1}"; if (epocha=="F" && epochb=="E") lumi_13TeV = "Run2016E+F, 4.0+3.1 fb^{-1}"; if ((epocha=="BCDEF" && epochb=="GH") || (epocha=="BCD" && epocha2=="EF" && epochb=="H" && epochb2=="G")) lumi_13TeV = "Run2016BCDEF+GH, 19.7+16.8 fb^{-1}"; if (epocha=="EF" && epochb=="BCD") lumi_13TeV = "Run2016BCD+EF, 12.9+6.8 fb^{-1}"; if (epocha=="H" && epochb=="G") lumi_13TeV = "Run2016G+H, 8.0+8.8 fb^{-1}"; if ((epocha=="BCD" && epocha2=="EF" && epochb=="G" && epochb2=="H")) lumi_13TeV = "Run2016BCDFearly+FlateGH, 19.7+16.8 fb^{-1}"; if ((epocha=="BCD" && epocha2=="" && ((epochb=="GH" && epochb2=="") || (epochb=="G" && epochb2=="H")))) lumi_13TeV = "Run2016BCD+FlateGH, 12.9+16.8 fb^{-1}"; if ((epocha=="EF" && epocha2=="" && ((epochb=="GH" && epochb2=="") || (epochb=="G" && epochb2=="H")))) lumi_13TeV = "Run2016EF+FlateGH, 6.8+16.8 fb^{-1}"; if ((epocha=="EF" && epocha2=="" && epochb=="G" && epochb2=="H")) lumi_13TeV = "Run2016EFearly+FlateGH, 6.8+16.8 fb^{-1}"; TCanvas *c1 = tdrCanvas("c1",h,4,11,true); c1->SetLogx(); TLatex *tex = new TLatex(); tex->SetNDC(); tex->SetTextSize(0.045); TMultiGraph *mg = new TMultiGraph(); string s = "draw"+epocha+(epocha2!="" ? "p" + epocha2 : "") +"vs"+epochb+(epochb2!="" ? "p" + epochb2 : ""); TGraphErrors *gmjb(0), *gmpf(0); for (unsigned int im = 0; im != methods.size(); ++im) { const char *cm = methods[im].c_str(); tex->DrawLatex(0.20,0.75-0.06*im,cm); s += "_" + methods[im]; for (unsigned int is = 0; is != samples.size(); ++is) { const char *cs = samples[is].c_str(); TGraphErrors *gg = (TGraphErrors*)fg->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs)); cout << cm << " " << cs << endl << flush; assert(gg); if (fg2) { TGraphErrors *gg2 = (TGraphErrors*)fg2->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs)); assert(gg2); gg = addGraph(gg,gg2); } TGraphErrors *gf = (TGraphErrors*)ff->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs)); assert(gf); if (ff2) { TGraphErrors *gf2 = (TGraphErrors*)ff2->Get(Form("%s/eta00-13/%s_%s_a30",ct,cm,cs)); assert(gf2); gf = addGraph(gf,gf2); } if (!(gf->GetN()==gg->GetN())) { // Remove highest pT point is that is the offender (BCD vs GH) if (gg->GetN()>gf->GetN() && fabs(gg->GetX()[gg->GetN()-1]/gf->GetX()[gf->GetN()-1]-1)>0.1 && fabs(gg->GetX()[gg->GetN()-2]/gf->GetX()[gf->GetN()-1]-1)<0.1) { cout << "Remove point B(N-1)" << endl; gg->RemovePoint(gg->GetN()-1); } else { cout << "sample " << samples[is] << " method " << methods[im] << " gf->N: " << gf->GetN() << " gg->N: " << gg->GetN() << endl; cout << " x_gf(N-1)=" << gf->GetX()[gf->GetN()-1] << " x_gg(N-1)=" << gg->GetX()[gg->GetN()-1] << " x_gg(N-2)=" << gg->GetX()[gg->GetN()-2] << endl; } assert(gf->GetN()==gg->GetN()); } TGraphErrors *g = (TGraphErrors*)gg->Clone(Form("ge_%s_%s",cm,cs)); for (int i = 0; i != g->GetN(); ++i) { double yg = gg->GetY()[i]; double yf = gf->GetY()[i]; g->SetPoint(i, gg->GetX()[i], yf / yg); double ex = gg->GetEX()[i]; double eg = gg->GetEY()[i]; double ef = gf->GetEY()[i]; g->SetPointError(i, ex, yf/yg*sqrt(pow(eg/yg,2)+pow(ef/yf,2))); } //g->Draw(is==0 ? "AP" : "SAMEP"); g->SetLineWidth(1+is); g->Draw("SAMEPZ"); if (samples[is]=="gamjet" && methods[im]=="mpfchs1" && nogjmpf) { tex->SetTextColor(kBlue); tex->DrawLatex(0.20,0.63,"#gamma+jet MPF excl. from fit"); tex->SetTextColor(kBlack); } else if (samples[is]=="gamjet" && methods[im]=="ptchs" && nogjptb) { tex->SetTextColor(kBlue); tex->DrawLatex(0.20,0.63,"#gamma+jet p_{T}^{bal} excl. from fit"); tex->SetTextColor(kBlack); } else if ((samples[is]=="zmmjet" || samples[is]=="zeejet") && methods[im]=="ptchs" && nozjptb) { tex->SetTextColor(kRed); tex->DrawLatex(0.20,0.63,"Z+jet p_{T}^{bal} excl. from fit"); tex->SetTextColor(kBlack); } else if (samples[is]=="multijet") { g->SetMarkerColor(kGray+1); g->SetLineColor(kGray+1); if (methods[im]=="ptchs") gmjb = g; if (methods[im]=="mpfchs1") gmpf = g; } else mg->Add(g); } // for is } // for im if (nogjmpf) s += "_nogjmpf"; if (nogjptb) s += "_nogptb"; if (nozjptb) s += "_nozptb"; if (mjvsjes) { s += "_mjvsjes"; tex->SetTextColor(kBlack); tex->DrawLatex(0.20,0.58,"Multijet vs JES fit"); } TF1 *fjes = new TF1("fjes",jesFit,30,2200,2); fjes->SetParameters(0.99,0.05); mg->Fit(fjes,"RN"); fjes->SetLineColor(kBlack); fjes->SetLineStyle(kDashed); fjes->SetLineWidth(2); fjes->SetRange(10.,3500.); fjes->Draw("SAME"); //TF1 *ft = new TF1("ft","1-[0]-[1]*pow(x,[2]) + ([3]+[4]*log(x))/x",30,2200); //ft->SetParameters(0,0.05,-0.5,1,0.1); //ft->FixParameter(3,0); // Logarithmic sigmoid //TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-log(abs([1])))" // "/(log(abs([2])+abs([1]))-log(abs([1])))))", 30,2200); //ft->SetParameters(0.98, 150, 50); TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-[1])/[2]))",30,2200); //ft->SetParameters(0.98,log(145),log(190)-log(145)); //ft->SetParameters(0.982,4.967,0.271); //ft->SetParameters(0.976,5.040,0.370); // ENDCAP //ft->SetParameters(0.985,5.0,0.3); ft->SetParameters(0.985,5.025,0.3); //ft->FixParameter(1,5.03); // semi-weighted average of BCD and EF //ft->FixParameter(2,0.395); // combined fit to BCD+EF / G+H // ( 12.9*5.055+6.8*5.000)/(12.9+6.8) ft->FixParameter(1,5.036); // semi-weighted average of BCD/GH and EF/GH // ( 12.9*0.344 + 6.8*0.455)/(12.9+6.8) ft->FixParameter(2,0.391); // combined fit to BCD+EF / GH // Log-sigmoid + powerlaw //TF1 *ft = new TF1("ft","[0]+(1-[0])/(1. + exp(-(log(x)-[1])/[2]))" // "*(1-[3]*pow(x,[4]))",30,2200); //ft->SetParameters(0.982,4.967,0.271,0.1,-0.2); // Double powerlaw //TF1 *ft = new TF1("ft","[4]-[0]*pow(x,[1])-[2]*pow(x,[3])",30,2200); //ft->SetParameters(0.05,-0.15,0.01,-0.3,1); mg->Fit(ft,"RN"); ft->SetLineColor(kBlue); ft->SetLineWidth(2); ft->SetRange(10.,3500.); ft->Draw("SAME"); // Map multijet with response ratio if (gmpf) { // we have multijet available TGraphErrors *gmpf2 = (TGraphErrors*)gmpf->Clone("gmpf2"); gmpf2->SetMarkerColor(kBlack);//kGray+1); gmpf2->SetLineColor(kBlack);//kGray+1); for (int i = 0; i != gmpf->GetN(); ++i) { if (mjvsjes) { gmpf2->SetPoint(i, 0.4*gmpf->GetX()[i], fjes->Eval(gmpf->GetX()[i])/gmpf->GetY()[i]); gmpf2->SetPointError(i, 0.4*gmpf->GetEX()[i], gmpf->GetEY()[i]); } else { gmpf2->SetPoint(i, 0.4*gmpf->GetX()[i], ft->Eval(gmpf->GetX()[i])/gmpf->GetY()[i]); gmpf2->SetPointError(i, 0.4*gmpf->GetEX()[i], gmpf->GetEY()[i]); } } gmpf2->Draw("SAMEPz"); } // multijet tex->SetTextColor(kBlue); tex->DrawLatex(0.50,0.85,Form("#chi^{2} / NDF = %1.1f / %d", ft->GetChisquare(), ft->GetNDF())); tex->SetTextColor(kBlack); tex->SetTextSize(0.040); tex->DrawLatex(0.50,0.80,Form("(#chi^{2} / NDF = %1.1f / %d)", fjes->GetChisquare(), fjes->GetNDF())); tex->SetTextColor(kBlue-9); tex->SetTextSize(0.030); tex->DrawLatex(0.20,0.25,ft->GetExpFormula()); tex->DrawLatex(0.20,0.20, Form("p_{0}=%1.3f#pm%1.3f" ", p_{1}=%1.3f#pm%1.3f" ", p_{2}=%1.3f#pm%1.3f", ft->GetParameter(0),ft->GetParError(0), ft->GetParameter(1),ft->GetParError(1), ft->GetParameter(2),ft->GetParError(2))); if (ft->GetNpar()>3) tex->DrawLatex(0.20,0.17, Form("p_{3}=%1.3f#pm%1.3f" ", p_{4}=%1.3f#pm%1.3f", ft->GetParameter(3),ft->GetParError(3), ft->GetParameter(4),ft->GetParError(4))); c1->SaveAs(Form("pdf/%s.pdf",s.c_str())); for (int i = 0; i != ft->GetNpar(); ++i) { cout << Form("%s%1.4g",i==0 ? "{" : ", ",ft->GetParameter(i)); } cout << "}" << endl; }
void gen5() { gROOT->SetStyle("HALLA"); TCanvas *cn = new TCanvas("cn"); cn->Draw(); cn->UseCurrentStyle(); TH1F *frm = new TH1F("frm","",100,0.,10.); frm->GetXaxis()->SetTitle("Q^{2} [GeV^{2}]"); frm->GetYaxis()->SetTitle("G_{E}^{n}/Gd"); frm->SetMinimum(-.1); frm->SetMaximum(1.); frm->UseCurrentStyle(); frm->Draw(); frm->SetAxisRange(0.,5.,"X"); TF1* galstergd = new TF1("galstergd", "(1.+x/.71)*(1.+x/.71)*x/(4.*0.938*.938)*1.91/(1.+x/.71)^2/(1.+5.6*x/(4.*.938*.938))", 0.,4.); galstergd->SetLineColor(6); galstergd->SetLineStyle(3); galstergd->SetLineWidth(2); TF1 *genf = new TF1("genf",genff,1.,10.,1); genf->SetLineColor(2); genf->SetLineStyle(2); genf->SetParameter(0,1.); // match to Madey point just below 1.5 // genf->SetParameter(0,.0411/genf->Eval(1.45)); genf->SetParameter(0,-0.558645); TF1 *bbba05 = new TF1("BBBA05",gen_bbba05,0.,10.,0); bbba05->SetLineColor(7); bbba05->SetLineStyle(3); TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}/Gd"); TLegend *legDta = new TLegend(.54,.6,.875,.90,"","brNDC"); TMultiGraph* wgr = mgrDta; TLegend *wlg = legDta; // the data legDta->SetBorderSize(0); // turn off border legDta->SetFillStyle(0); datafile_t *f = datafiles; TGraph* gr=0; TGraph* ogr=0; while ( f && f->filename ) { ogr=OneGraph(f); if (ogr) { gr=fromGEntoGEnGd(ogr); if (f->lnpt) { mgrDta->Add(gr,f->lnpt); legDta->AddEntry(gr,f->label,f->lnpt); } else if (gr->GetMarkerStyle()>=20) { mgrDta->Add(gr,"p"); legDta->AddEntry(gr,f->label,"p"); } else { mgrDta->Add(gr,"l"); legDta->AddEntry(gr,f->label,"l"); } } f++; } mgrDta->Draw("p"); // legDta->Draw(); don't draw the data legend TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}/Gd"); TLegend *legThry = new TLegend(.54,.6,.875,.9,"","brNDC"); wgr = mgrThry; wlg = legThry; // the theory wlg->SetBorderSize(0); // turn off border wlg->SetFillStyle(0); f = theoryfiles1; ogr=0; gr=0; while ( f && f->filename ) { ogr=OneGraph(f); if (ogr) { gr=fromGEntoGEnGd(ogr); TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr); if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) { gr = toerror_band(egr); gr->SetFillStyle(3000+f->style); } if (f->lnpt) { wgr->Add(gr,f->lnpt); wlg->AddEntry(gr,f->label,f->lnpt); } else if (gr->GetMarkerStyle()>=20) { wgr->Add(gr,"p"); wlg->AddEntry(gr,f->label,"p"); } else { wgr->Add(gr,"l"); wlg->AddEntry(gr,f->label,"l"); } } f++; } genf->Draw("same"); mgrThry->Draw("c"); galstergd->Draw("same"); bbba05->Draw("same"); legThry->AddEntry(genf,"F_{2}/F_{1} #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l"); legThry->AddEntry(galstergd,"Galster fit","l"); legThry->AddEntry(bbba05,"BBBA05","l"); legThry->Draw(); legDta->Draw(); // draw a line at 1 cn->Modified(); cn->Update(); cn->SaveAs(Form("%s.eps",psfile)); cn->SaveAs(Form("%s.root",psfile)); gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile)); return; // LEAVING HERE }
int fitfunc(int *energy, int *gopt, int append, char* addname){ if(setlogy==0){ //double labelx[6]={380,800,1200,1700,2400,5000}, labely[6]={80,45,25,21,25,15}; //Position }else{ //double labelx[6]={300,750,1400,1800,2700,5000}, labely[6]={130,75,50,30,25,5}; //Position } //void fitfunc(int energy[5], int gopt[5]){ for(int i=0; i<6; i++){ cout<<energy[i]<<" "<<gopt[i]<<endl; } if(histname=="p2p"){ char* dirsim = "../output/rec"; }else if(histname=="p3p"){ //char* dirsim = "../output/rec_p3p"; char* dirsim = "../output/rec"; //char* direxp = "../expout/Feb12/h_SpectrumMINOS_wAdBk.root"; //char* outname = Form("../output/fit/%i%i%i%i%i_%s%i",gopt[0],gopt[1],gopt[2],gopt[3],gopt[4],histname,energy[4]); // .pdf .png .C .root will be created }else{// if(histname=="h23"){ char* dirsim = "../output/rec"; //char* direxp = "../expout/Feb12/h_SpectrumMINOS_wAdBk.root"; //char* outname = Form("../output/fit/%i%i%i%i%i_%s%i",gopt[0],gopt[1],gopt[2],gopt[3],gopt[4],histname,energy[4]); // .pdf .png .C .root will be created } char* outname = Form("../output/fit/%s_%i_%i_%i_%i_%i_%i%s",histname, energy[0],energy[1],energy[2],energy[3],energy[4],energy[5],addname); // .pdf .png .C .root will be created ofstream fpara(Form("%s_fitresult.txt",outname)); if(append == 1){ ofstream fitlist(Form("../output/fit/fitlist_%s%s.csv",histname,addname),ios_base::app); }else{ ofstream fitlist(Form("../output/fit/fitlist_%s%s.csv",histname,addname)); fitlist<<"E0, E1, E2, E3, E4, E5, CS0, CS1, CS2, CS3, CS4, CS5, ER0, ER1, ER2, ER3, ER4, ER5, Chi-sq"<<endl; } gStyle->SetOptStat(kFALSE); gROOT->ProcessLine( ".L fit78Ni.h" ); gStyle->SetOptStat(kFALSE); gStyle->SetPadGridX(false); gStyle->SetPadGridY(false); //gStyle->SetOptLogy(1); char temp[300]; int minBin = 0; //int maxBin = 5500; int maxBin = 6000; int binning = 100; int numBin = (maxBin-minBin)/binning; //Id starts with one!!! int daliIDMin = 1; int daliIDMax = 186; //**************************************************************************** // The simulated peaks TFile *sim[6]; for(int i=0; i<6; i++){ if(energy[i]>0){ sim[i] = new TFile(Form("%s/%ikeV.root",dirsim,energy[i])); }else{ sim[i] = new TFile(Form("%s/%ikeV.root",dirsim,2620));//dummy gopt[i] = 0; } } //The experimental data: TFile *exp[1]; //exp[0] = new TFile(Form("%s/MINOStest.root",direxp)); exp[0] = new TFile(direxp); TCanvas *fCanvas=new TCanvas("Canvas","Response function",700,700); fCanvas->SetBorderSize(0); fCanvas->SetBorderMode(0); fCanvas->SetFrameBorderMode(0); fCanvas->SetFrameFillColor(0); fCanvas->SetBottomMargin(0.15); fCanvas->SetLeftMargin(0.15); fCanvas->cd(); TFile *fout = new TFile(Form("%s.root",outname),"RECREATE"); fout->cd(); // Main TPad *c_m = new TPad("c_m", "c_m",0.0,0.0,1.0,1.0); c_m->Draw(); c_m->cd(); c_m->SetFillColor(0); //c_m->SetFillStyle(0); c_m->SetBorderSize(0); c_m->SetRightMargin(0.05); c_m->SetTopMargin(0.03); c_m->SetBottomMargin(0.15); c_m->SetLeftMargin(0.15); if(setlogy>0) c_m->SetLogy(); fCanvas->cd(); //**************************************************************************** //The simulated spectra: TH1F *hsim[6]; for(int i=0;i<6;i++) { sprintf(temp,"hsim[%i]",i); hsim[i] = new TH1F(temp,temp,numBin,minBin,maxBin); hsim[i] = (TH1F*)sim[i]->Get("h_doppler_addback[0]"); } /* hsim[0] = (TH1F*)sim[0]->Get("h_doppler_addback[0]"); hsim[1] = (TH1F*)sim[1]->Get("h_doppler_addback[0]"); hsim[2] = (TH1F*)sim[2]->Get("h_doppler_addback[0]"); hsim[3] = (TH1F*)sim[3]->Get("h_doppler_addback[0]"); hsim[4] = (TH1F*)sim[4]->Get("h_doppler_addback[0]"); */ //The experimental spectra: TH1F *hexp[1]; for(int i=0;i<1;i++) { sprintf(temp,"hexp[%i]",i); hexp[i] = new TH1F(temp,temp,numBin,minBin,maxBin); } //Getting the experimental spectrum //78Ni hexp[0] = (TH1F*)exp[0]->Get(histname); //hexp[0] = (TH1F*)exp[0]->Get("h23;1"); //hexp[0]->Rebin(2); for(int i=0;i<1;i++) { hexp[i]->SetStats(0); hexp[i]->SetFillColor(0); hexp[i]->SetLineColor(kBlue); hexp[i]->SetLineStyle(0); //hexp[i]->GetXaxis()->SetRangeUser(0,maxBin); hexp[i]->GetXaxis()->SetRangeUser(minBin,maxBin); //hexp[i]->GetXaxis()->SetRangeUser(0,6000); if(setlogy==0){ hexp[i]->GetYaxis()->SetRangeUser(0,yrangemax); }else { hexp[i]->GetYaxis()->SetRangeUser(0.5,yrangemax); } hexp[i]->GetXaxis()->SetNdivisions(305); hexp[i]->GetYaxis()->SetNdivisions(305); hexp[i]->GetYaxis()->SetTitle(Form("Counts / %i keV",binning)); hexp[i]->GetXaxis()->SetTitle("Energy (keV)"); hexp[i]->GetXaxis()->SetTitleOffset(0.9); hexp[i]->GetYaxis()->SetTitleOffset(0.9); hexp[i]->GetXaxis()->SetTitleFont(132); hexp[i]->GetYaxis()->SetTitleFont(132); /* hexp[i]->GetXaxis()->SetTitleSize(0.08); hexp[i]->GetYaxis()->SetTitleSize(0.08); hexp[i]->GetXaxis()->SetLabelSize(0.08); hexp[i]->GetYaxis()->SetLabelSize(0.08); */ hexp[i]->GetXaxis()->SetTitleSize(0.05); hexp[i]->GetYaxis()->SetTitleSize(0.05); hexp[i]->GetXaxis()->SetLabelSize(0.05); hexp[i]->GetYaxis()->SetLabelSize(0.05); //How to get error bar for each bin hexp[i]->SetDefaultSumw2(kTRUE); hexp[i]->SetTitle(""); } //***************************************************************************** peak1g = new TGraph(hsim[0]); peak2g = new TGraph(hsim[1]); peak3g = new TGraph(hsim[2]); peak4g = new TGraph(hsim[3]); peak5g = new TGraph(hsim[4]); peak6g = new TGraph(hsim[5]); /*TGraph *peak1g = new TGraph(hsim[0]); TGraph *peak2g = new TGraph(hsim[1]); TGraph *peak3g = new TGraph(hsim[2]); TGraph *peak4g = new TGraph(hsim[3]); TGraph *peak5g = new TGraph(hsim[4]); */ //******************Function Definition**************************************** //***************************************************************************** const Double_t fitmin=300.; const Double_t fitmax=(Double_t)maxBin;//4000.; c_m->cd(); TF1 *whole = new TF1( "whole", ex_respf,fitmin,fitmax,10); whole->SetParameters(0.0001,0.01,0.00,0.0001,0.001,0.001,3.,-1e-03,3,-1.e-3); //whole->SetParameters(0.0001,0.0001,0.0001, 5.9,-0.00080 ); for(int i=0; i<6; i++){ if(gopt[i]==1){ whole->SetParLimits(i,0.0,parlimit[i]); }else{ whole->FixParameter(i,0.0); } } whole->SetParLimits(6,0,10); whole->SetParLimits(7,-1e-02,0.); whole->SetParLimits(8,0,5); whole->SetParLimits(9,-1e-02,-1e-5); //whole->FixParameter(8,1.426); //whole->FixParameter(9,-8.1e-5); whole->SetLineColor(1); whole->SetLineWidth(2); whole->SetNpx(200); hexp[0]->Fit(whole,"R LL"); //hexp[0]->Fit(whole,""); //cout<<"test"<<endl; //hexp[0]->Draw(""); //hexp[0]->GetXaxis()->SetRangeUser(0,5000); //fCanvas->Print(Form("%s.png",outname)); fpara<<"Chisquare\t"<< whole->GetChisquare()<<endl; fpara<<"para\tvalue\terror\tfilename"<<endl; for(int para=0;para<10;para++){ fpara<<para<<"\t"<<whole->GetParameter(para)<<"\t"<<whole->GetParError(para); if(para<6) { string strenergy =sim[para]->GetName(); int itr = strenergy.find_last_of("/"); strenergy.erase(0,itr+1); fpara<<"\t"<<strenergy; } fpara<<endl; } // fitlist<<"E0, E1, E2, E3, E4, CS0, CS1, CS2, CS3, CS4, ER0, ER1, ER2, ER3, ER4, Chi-sq"<<endl; for(int i=0; i<6; i++) gopt[i]==1? fitlist<<energy[i]<<", ": fitlist<<"0, "; for(int i=0; i<6; i++) gopt[i]==1? fitlist<<genevts*whole->GetParameter(i)*CSincl/tot78Ni<<", ": fitlist<<"0, "; for(int i=0; i<6; i++){gopt[i]==1? fitlist<<sqrt(pow(whole->GetParError(i)*CSincl,2.) //Error from fitting //+whole->GetParameter(i)*pow(CSincl,2) //Statistical error for the events (included? //+pow(whole->GetParameter(i)*CSinclerr,2) // Inclusive cross section error )*genevts/tot78Ni<<", " :fitlist<<"0, "; } fitlist<<whole->GetChisquare()<<endl; //RT end TF1 *peak1f= new TF1( "peak1f", resp1,fitmin,fitmax,1); peak1f->SetParameter(0,whole->GetParameter(0) ); peak1f->SetLineColor(2); peak1f->SetLineWidth(2); peak1f->SetLineStyle(9); peak1f->Draw("same"); TF1 *peak2f= new TF1( "peak2f", resp2,fitmin,fitmax,1); peak2f->SetParameter(0,whole->GetParameter(1) ); peak2f->SetLineColor(2); peak2f->SetLineWidth(2); peak2f->SetLineStyle(9); peak2f->Draw("same"); // TF1 *peak3f= new TF1( "peak3f", resp3,fitmin,fitmax,1); peak3f->SetParameter(0,whole->GetParameter(2) ); peak3f->SetLineColor(2); peak3f->SetLineWidth(2); peak3f->SetLineStyle(9); peak3f->Draw("same"); TF1 *peak4f= new TF1( "peak4f", resp4,fitmin,fitmax,1); peak4f->SetParameter(0,whole->GetParameter(3) ); peak4f->SetLineColor(2); peak4f->SetLineWidth(2); peak4f->SetLineStyle(9); peak4f->Draw("same"); TF1 *peak5f= new TF1( "peak5f", resp5,fitmin,fitmax,1); peak5f->SetParameter(0,whole->GetParameter(4) ); peak5f->SetLineColor(2); peak5f->SetLineWidth(2); peak5f->SetLineStyle(9); peak5f->Draw("same"); TF1 *peak6f= new TF1( "peak6f", resp6,fitmin,fitmax,1); peak6f->SetParameter(0,whole->GetParameter(5) ); peak6f->SetLineColor(2); peak6f->SetLineWidth(2); peak6f->SetLineStyle(9); peak6f->Draw("same"); TF1 *expon= new TF1( "expon",expf ,fitmin,fitmax,4); //expon->SetParameters(whole->GetParameter(5),whole->GetParameter(6),whole->GetParameter(7),whole->GetParameter(8)); expon->SetParameters(whole->GetParameter(6),whole->GetParameter(7),whole->GetParameter(8),whole->GetParameter(9)); expon->SetLineColor(4); expon->SetLineWidth(2); expon->SetLineStyle(7); expon->Draw("same"); //hexp[0]->Draw("same"); hexp[0]->Draw("EL same"); /*TLatex *tex = new TLatex(2000,setlogy?130:60,Form("^{78}Ni (%s)",histname)); tex->SetTextFont(132); tex->SetTextSize(0.07); tex->SetLineWidth(2); tex->Draw(); */ /*TLatex *tex = new TLatex(2700,setlogy?80:55,Form("Incl: %2.1f mbarn for %d cnts", CSincl, (int)tot78Ni)); tex->SetTextFont(132); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); */ for(int i =0; i<6; i++){ if(gopt[i]==1){ TLatex *tex = new TLatex(labelx[i],labely[i], //Form("#splitline{%d keV }{%2.2f mbarn (%3.1f cnts)}",energy[i], genevts*whole->GetParameter(i)*CSincl/tot78Ni, genevts*whole->GetParameter(i))); Form("%d keV",energy[i])); tex->SetTextFont(132); tex->SetTextSize(0.05); tex->SetLineWidth(2); tex->Draw(); } } fCanvas->Print(Form("%s.C",outname)); fCanvas->Print(Form("%s.png",outname)); fCanvas->Print(Form("%s.pdf",outname)); fCanvas->Write(); hexp[0]->Write(); fout->Write(); fout->Close(); }
void newBrezilianflagneventstGu2(){ TF1 *fa = new TF1("fa","(4/9)*67.2*x*x",0,0.065); TCanvas *c1 = new TCanvas("c1","upper limit results ",200,10,700,500); c1->SetGrid(); const int N=2; /* double X[N]={0.001,0.05}; double nO[N]={0.0298,0.0298}; double nE[N]={0.0408,0.0408}; */ double X[N]={0,0.065}; double nO[N]={0.0234,0.0234}; double nE[N]={0.0404,0.0404}; cout<<"jadid"<<endl; cout<<"expected tgammau coupling"<<1.5*sqrt(nE[0]/67.2)<<endl; cout<<"observed tgammau coupling"<<1.5*sqrt(nO[0]/67.2)<<endl; cout<<"ghadimi"<<endl; cout<<"expected tgammau coupling"<<sqrt(nE[0]/67.2)<<endl; cout<<"observed tgammau coupling"<<sqrt(nO[0]/67.2)<<endl; double nE1sigmaup[N]={0.0587,0.0587}; double nE1sigmadown[N]={0.0304,0.0304}; double nE2sigmaup[N]={0.0816,0.0816}; double nE2sigmadown[N]={0.0231,0.0231}; /* cout<<"expected tgammac coupling including k-factor"<<sqrt(nE[0]/(67.2))<<endl; cout<<"expected 1sigma up tgammau coupling including k-factor"<<sqrt(nE1sigmaup[0]/(67.2))<<endl; cout<<"expected 1sigma down tgammau coupling including k-factor"<<sqrt(nE1sigmadown[0]/(67.2))<<endl; cout<<"expected 2sigma up tgammau coupling including k-factor"<<sqrt(nE2sigmaup[0]/(67.2))<<endl; cout<<"expected 2sigma down tgammau coupling including k-factor"<<sqrt(nE2sigmadown[0]/(67.2))<<endl; */ double sigma1up[N]; double sigma1down[N]; double sigma2up[N]; double sigma2down[N]; for (int idx=0; idx<N; ++idx){ sigma1up[idx]=nE1sigmaup[idx]-nE[idx]; sigma1down[idx]=nE[idx]-nE1sigmadown[idx]; sigma2up[idx]=nE2sigmaup[idx]-nE[idx]; sigma2down[idx]=nE[idx]-nE2sigmadown[idx]; } TGraphAsymmErrors *grafexp1sigma=new TGraphAsymmErrors(N); grafexp1sigma->SetName("grafexp1sigma"); grafexp1sigma->SetTitle("Graph"); grafexp1sigma->SetFillColor(1); //grafexp1sigma->SetPoint(point number ,x value,y value); //grafexp1sigma->SetPointError(point number ,0,0,y lower error ,y upper error); grafexp1sigma->SetPoint(0,X[0],nE[0]); grafexp1sigma->SetPointError(0,0,0,sigma1down[0],sigma1up[0]); grafexp1sigma->SetPoint(1,X[1],nE[1]); grafexp1sigma->SetPointError(1,0,0,sigma1down[1],sigma1up[1]); /* grafexp1sigma->SetPoint(2,X[2],nE[2]); grafexp1sigma->SetPointError(2,0,0,sigma1down[2],sigma1up[2]); grafexp1sigma->SetPoint(3,X[3],nE[3]); grafexp1sigma->SetPointError(3,0,0,sigma1down[3],sigma1up[3]); grafexp1sigma->SetPoint(4,X[4],nE[4]); grafexp1sigma->SetPointError(4,0,0,sigma1down[4],sigma1up[4]); */ grafexp1sigma->SetFillColor(kGreen); // grafexp1sigma-> // grafexp1sigma-> // grafexp1sigma-> // grafexp1sigma-> TGraphAsymmErrors *grafexp2sigma=new TGraphAsymmErrors(N); grafexp2sigma->SetPoint(0,X[0],nE[0]); grafexp2sigma->SetPointError(0,0,0,sigma2down[0],sigma2up[0]); grafexp2sigma->SetPoint(1,X[1],nE[1]); grafexp2sigma->SetPointError(1,0,0,sigma2down[1],sigma2up[1]); /* grafexp2sigma->SetPoint(2,X[2],nE[2]); grafexp2sigma->SetPointError(2,0,0,sigma2down[2],sigma2up[2]); grafexp2sigma->SetPoint(3,X[3],nE[3]); grafexp2sigma->SetPointError(3,0,0,sigma2down[3],sigma2up[3]); grafexp2sigma->SetPoint(4,X[4],nE[4]); grafexp2sigma->SetPointError(4,0,0,sigma2down[4],sigma2up[4]); */ grafexp2sigma->SetFillColor(kYellow); // grafexp2sigma->GetXaxis()->SetLabelFont(62); grafexp2sigma->GetXaxis()->SetLabelOffset(0.007); grafexp2sigma->GetXaxis()->SetLabelSize(0.044); grafexp2sigma->GetXaxis()->SetTitleSize(0.075); grafexp2sigma->GetXaxis()->SetTitleFont(62); grafexp2sigma->GetXaxis()->SetTitleOffset(0.7); grafexp2sigma->GetXaxis()->SetRangeUser(0, 0.065); grafexp2sigma->GetYaxis()->SetRangeUser(0, 0.15); grafexp2sigma->GetYaxis()->SetTitle("#sigma_{tu#gamma} #times Br(w#rightarrowl#nu) (pb)"); // grafexp2sigma->GetYaxis()->SetLabelFont(22); grafexp2sigma->GetYaxis()->SetLabelOffset(0.007); grafexp2sigma->GetYaxis()->SetLabelSize(0.044); grafexp2sigma->GetYaxis()->SetTitleSize(0.055); grafexp2sigma->GetYaxis()->SetTitleOffset(0.8); grafexp2sigma->GetYaxis()->SetTitleFont(62); grafexp2sigma->GetXaxis()->SetTitle("#kappa_{tu#gamma}"); grafexp2sigma->SetTitle(""); // grafexp2sigma->SetMaximum(8); TGraph *Expected= new TGraph(N,X,nE); Expected->SetLineColor(4); Expected->SetLineWidth(3); Expected->SetMarkerColor(1); Expected->SetMarkerStyle(20); Expected->SetLineStyle(2); Expected->GetYaxis()->SetTitle("Cross Section [pb]"); Expected->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); Expected->SetTitle("with "); Expected->SetFillColor(10); TGraph *Observed= new TGraph(N,X,nO); Observed->SetLineColor(1); Observed->SetLineWidth(3); Observed->SetMarkerColor(1); Observed->SetMarkerStyle(20); // Observed->SetLineStyle(2); Observed->GetYaxis()->SetTitle("Cross Section [pb]"); Observed->GetXaxis()->SetTitle("#Lambda_{T} [GeV]"); Observed->SetTitle("with "); Observed->SetFillColor(10); TPad *pad1 = new TPad("pad1","pad1",0,0,1,1); pad1->SetFillStyle(0); pad1->SetFrameFillStyle(0); pad1->SetLeftMargin(0.115); pad1->SetBottomMargin(0.115); pad1->SetGrid(); pad1->Draw(); pad1->cd(); grafexp2sigma->Draw("AL3"); grafexp1sigma->Draw("L3same"); Expected->Draw("L"); Observed->Draw("L"); fa->SetLineColor(2); fa->SetLineWidth(3); fa->SetMarkerColor(1); fa->Draw("same"); Observed->GetHistogram()->Draw("AXISSAMEY+"); Observed->GetHistogram()->Draw("AXISSAMEX+"); TLegend *leg1 = new TLegend(0.2, 0.6, 0.5, 0.85); leg1->SetBorderSize(0); leg1->SetLineColor(0); leg1->SetLineWidth(0); leg1->SetFillColor(kWhite); leg1->AddEntry(fa, "Predicted", "L"); leg1->AddEntry(Observed, "95% CL Observed Limit", "L"); leg1->AddEntry(Expected, "95% CL Expected Limit", "L"); leg1->AddEntry(grafexp1sigma, "#pm1#sigma Exp.Limit", "F"); leg1->AddEntry(grafexp2sigma, "#pm2#sigma Exp.Limit", "F"); leg1->SetTextSize(0.04); leg1->SetTextFont(22); leg1->Draw(); TLine *line1 = new TLine(5, 1, 40, 1); line1->SetLineColor(2); line1->SetLineWidth(2); // line1->Draw("same"); TPaveText *pt = new TPaveText(0.1,0.95,0.4,0.95, "NDC"); // NDC sets coords pt->SetLineColor(10); // relative to pad dimensions pt->SetFillColor(10); // text is black on white pt->SetTextSize(0.045); pt->SetTextAlign(12); pt->AddText("CMS Preliminary, 19.1 fb^{-1}, #sqrt{s} = 8 TeV"); pt->SetShadowColor(10); pt->Draw("same"); pad1->Draw(); }
void eta1(double pt1min, double pt2min, double METmin){ TLegend* leg = new TLegend(0.13,0.6,0.87,0.87); leg->SetNColumns(3); leg->SetBorderSize(0); leg->SetFillStyle(0); gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); TFile *data = TFile::Open("./25ns_2246inv_v3/DoubleEG.root","READ"); TFile *sig1 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP600.root","READ"); TFile *sig2 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP800.root","READ"); TFile *sig3 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1000.root","READ"); TFile *sig4 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1200.root","READ"); TFile *sig5 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1400.root","READ"); TFile *sig6 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ"); TFile *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP2500.root","READ"); TFile *bkg1 = TFile::Open("./25ns_2246inv_v3/DiPhoton.root","READ"); TFile *bkg2 = TFile::Open("./25ns_2246inv_v3/DYJetsToLL.root","READ"); TFile *bkg3 = TFile::Open("./25ns_2246inv_v3/GJets.root","READ"); TFile *bkg4 = TFile::Open("./25ns_2246inv_v3/GluGluHToGG.root","READ"); TFile *bkg5 = TFile::Open("./25ns_2246inv_v3/QCD.root","READ"); TFile *bkg6 = TFile::Open("./25ns_2246inv_v3/VH.root","READ"); TFile *bkg7 = TFile::Open("./25ns_2246inv_v3/ttHJetToGG.root","READ"); TFile *bkg8 = TFile::Open("./25ns_2246inv_v3/VBFHToGG.root","READ"); TFile *bkg9 = TFile::Open("./25ns_2246inv_v3/TGJets.root","READ"); TFile *bkg10 = TFile::Open("./25ns_2246inv_v3/TTGJets.root","READ"); TFile *bkg11 = TFile::Open("./25ns_2246inv_v3/WGToLNuG.root","READ"); TFile *bkg12 = TFile::Open("./25ns_2246inv_v3/ZGTo2LG.root","READ"); TTree *tree_data = (TTree*) data->Get("DiPhotonTree"); TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree"); TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree"); TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree"); TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree"); TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree"); TTree *tree_sig6 = (TTree*) sig6->Get("DiPhotonTree"); TTree *tree_sig7 = (TTree*) sig7->Get("DiPhotonTree"); TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree"); TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree"); TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree"); TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree"); TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree"); TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree"); TTree *tree_bkg7 = (TTree*) bkg7->Get("DiPhotonTree"); TTree *tree_bkg8 = (TTree*) bkg8->Get("DiPhotonTree"); TTree *tree_bkg9 = (TTree*) bkg9->Get("DiPhotonTree"); TTree *tree_bkg10 = (TTree*) bkg10->Get("DiPhotonTree"); TTree *tree_bkg11 = (TTree*) bkg11->Get("DiPhotonTree"); TTree *tree_bkg12 = (TTree*) bkg12->Get("DiPhotonTree"); TCanvas *c1 = new TCanvas("c1","",500,600); TPad *mainPad = new TPad("mainPad","",0,0.3,1,1); TPad *smallPad = new TPad("smallPad","",0,0.05,1,0.3); mainPad->SetBottomMargin(0.015); smallPad->SetTopMargin(0.05); smallPad->SetBottomMargin(0.25); c1->cd(); mainPad->Draw(); mainPad->cd(); // gPad->SetLogy(); TCut mggmax = "mgg<180"; TCut mggmin = "mgg>100"; TCut mggblind = "((mgg<115)||(mgg>135))"; TCut pt1Cut = Form("pt1/mgg>%lf",pt1min); TCut pt2Cut = Form("pt2/mgg>%lf",pt2min); TCut METCut = Form("t1pfmet>%lf",METmin); TCut eveto1 = "eleveto1 == 1"; TCut eveto2 = "eleveto2 == 1"; TCut eveto = eveto1 && eveto2; TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))"; TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))"; tree_data->Draw("(eta1)>>hdata(15,-3,3)",(mggmax && mggmin && metF&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata"); tree_sig1->Draw("(eta1)>>h1(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1"); tree_sig2->Draw("(eta1)>>h2(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2"); tree_sig3->Draw("(eta1)>>h3(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3"); tree_sig4->Draw("(eta1)>>h4(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4"); tree_sig5->Draw("(eta1)>>h5(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5"); tree_sig6->Draw("(eta1)>>h6(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6"); tree_sig7->Draw("(eta1)>>h7(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7"); tree_bkg1->Draw("(eta1)>>hbkg1(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1"); tree_bkg2->Draw("(eta1)>>hbkg2(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2"); tree_bkg3->Draw("(eta1)>>hbkg3(15,-3,3)","weight"*(mggmin && mggmax && genmatch&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3"); tree_bkg4->Draw("(eta1)>>hbkg4(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); //weight also on BR = 0.002 if using the 50ns samples TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4"); tree_bkg5->Draw("(eta1)>>hbkg5(15,-3,3)","weight"*(mggmin && mggmax && genmatch&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5"); tree_bkg6->Draw("(eta1)>>hbkg6(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6"); tree_bkg7->Draw("(eta1)>>hbkg7(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7"); tree_bkg8->Draw("(eta1)>>hbkg8(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8"); tree_bkg9->Draw("(eta1)>>hbkg9(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9"); tree_bkg10->Draw("(eta1)>>hbkg10(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10"); tree_bkg11->Draw("(eta1)>>hbkg11(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11"); tree_bkg12->Draw("(eta1)>>hbkg12(15,-3,3)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12"); hdata->SetMarkerColor(kBlack); hdata->SetMarkerStyle(15); hdata->SetLineColor(kBlack); h1->SetLineColor(kRed+3); h2->SetLineColor(kRed+1); h3->SetLineColor(kRed); h4->SetLineColor(kPink+2); h5->SetLineColor(kPink+4); h6->SetLineColor(kPink+7); h7->SetLineColor(kMagenta+2); h1->SetLineWidth(2); h2->SetLineWidth(2); h3->SetLineWidth(2); h4->SetLineWidth(2); h5->SetLineWidth(2); h6->SetLineWidth(2); h7->SetLineWidth(2); THStack *hs= new THStack("hs",""); hbkg7->SetFillColor(kGreen+2); hbkg6->SetFillColor(kGreen); hbkg8->SetFillColor(kYellow); hbkg4->SetFillColor(kOrange); hbkg9->SetFillColor(kOrange+7); hbkg10->SetFillColor(kOrange+4); hbkg11->SetFillColor(kCyan); hbkg12->SetFillColor(kCyan+1); hbkg5->SetFillColor(kBlue+2); hbkg2->SetFillColor(kBlue); hbkg3->SetFillColor(kMagenta-2); hbkg1->SetFillColor(kViolet); hbkg1->SetLineColor(kBlack); hbkg2->SetLineColor(kBlack); hbkg3->SetLineColor(kBlack); hbkg4->SetLineColor(kBlack); hbkg5->SetLineColor(kBlack); hbkg6->SetLineColor(kBlack); hbkg7->SetLineColor(kBlack); hbkg8->SetLineColor(kBlack); hbkg9->SetLineColor(kBlack); hbkg10->SetLineColor(kBlack); hbkg11->SetLineColor(kBlack); hbkg12->SetLineColor(kBlack); hs->Add(hbkg7); hs->Add(hbkg6); hs->Add(hbkg8); hs->Add(hbkg4); hs->Add(hbkg9); hs->Add(hbkg10); hs->Add(hbkg11); hs->Add(hbkg12); hs->Add(hbkg2); hs->Add(hbkg5); hs->Add(hbkg3); hs->Add(hbkg1); TH1F *hsum = (TH1F*)hbkg1->Clone("hsum"); hsum->Add(hbkg2); hsum->Add(hbkg3); hsum->Add(hbkg4); hsum->Add(hbkg5); hsum->Add(hbkg6); hsum->Add(hbkg7); hsum->Add(hbkg8); hsum->Add(hbkg9); hsum->Add(hbkg10); hsum->Add(hbkg11); hsum->Add(hbkg12); // hs->SetMaximum(1000000); hs->SetMaximum(5000); // hs->SetMinimum(0.1); hs->SetTitle(""); hs->Draw("HIST"); hsum->SetMarkerStyle(1); hsum->SetFillColor(kGray+3); hsum->SetFillStyle(3002); hsum->Draw("same e2"); h2->Draw("same hist"); h3->Draw("same hist"); h4->Draw("same hist"); h1->Draw("same hist"); h5->Draw("same hist"); h6->Draw("same hist"); h7->Draw("same hist"); hdata->Draw("same E1"); hs->GetXaxis()->SetLabelOffset(999); hs->GetYaxis()->SetTitle("Events/0.4"); hs->GetYaxis()->SetTitleOffset(1.4); gPad->Modified(); leg->AddEntry(hdata,"Data","lep"); leg->AddEntry(hbkg1,"#gamma #gamma","f"); leg->AddEntry(h1,"m_{Z'} = 600 GeV","l"); leg->AddEntry(hbkg2,"Drell Yann","f"); leg->AddEntry(hbkg3,"#gamma + Jets","f"); leg->AddEntry(h2,"m_{Z'} = 800 GeV","l"); leg->AddEntry(hbkg5,"QCD","f"); leg->AddEntry(hbkg4,"ggH","f"); leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l"); leg->AddEntry(hbkg6,"VH","f"); leg->AddEntry(hbkg7,"ttH","f"); leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l"); leg->AddEntry(hbkg8,"VBF H","f"); leg->AddEntry(hbkg9,"t + #gamma + Jets","f"); leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); leg->AddEntry(hbkg10,"tt + #gamma +Jets","f"); leg->AddEntry(hbkg11,"#gamma+W","f"); leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l"); leg->AddEntry(hbkg12,"#gamma+Z","f"); leg->AddEntry(hsum,"Bkg uncertainty","f"); leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l"); leg->Draw("same"); c1->cd(); smallPad->Draw(); smallPad->cd(); TGraphErrors *gr = new TGraphErrors(0); double integralData=hdata->Integral(); double integralBKG=hsum->Integral(); double error, ratio; for(int w=1; w<15; w++){ if((hdata->GetBinContent(w)!=0) && (hsum->GetBinContent(w)!=0)){ gr->SetPoint(w, hdata->GetBinCenter(w),(hdata->GetBinContent(w))/(hsum->GetBinContent(w))); ratio= (hdata->GetBinContent(w))/(hsum->GetBinContent(w)); error= (hdata->GetBinContent(w)*sqrt(hsum->GetBinContent(w))/(hsum->GetBinContent(w)*hsum->GetBinContent(w)) + sqrt(hdata->GetBinContent(w))/hsum->GetBinContent(w)); std::cout<<"VALUE: "<<ratio<<" ERROR: "<<error<<std::endl; gr->SetPointError(w, hdata->GetBinWidth(w)/2,error); }else{ gr->SetPoint(w, hdata->GetBinCenter(w),10); } } gStyle->SetPadTickY(1); gStyle->SetPadTickX(1); gr->GetHistogram()->SetMaximum(2); gr->GetHistogram()->SetMinimum(0.1); gStyle->SetTextSize(14); gROOT->ForceStyle(); gr->GetXaxis()->SetLabelFont(43); gr->GetXaxis()->SetLabelSize(15); gr->GetYaxis()->SetLabelFont(43); gr->GetYaxis()->SetLabelSize(15); gr->GetXaxis()->SetLimits(-3,3); gPad->SetGrid(); gStyle->SetStripDecimals(kTRUE); gr->SetMarkerStyle(20); gr->SetMarkerSize(0.7); gr->Draw("AZP"); gr->GetXaxis()->SetTitle("#eta_{1}"); gr->GetXaxis()->SetTitleSize(0.1); gr->GetYaxis()->SetTitleSize(0.1); gr->GetYaxis()->SetNdivisions(505); gr->GetXaxis()->SetTitleOffset(1); gr->GetYaxis()->SetTitle("Data/MC"); gr->GetYaxis()->SetTitleOffset(0.4); gr->SetTitle(""); smallPad->Update(); TF1* line = new TF1("line","1",-3,3); line->SetLineColor(kRed); line->SetLineWidth(2); line->Draw("L same"); gr->Draw("ZP SAME"); if(pt1min==0 && pt2min == 0 && METmin == 0){ c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/eta1.png"); c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/eta1.pdf"); } if(pt1min==0.65 && pt2min == 0.25){ c1->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/eta1_optcuts_MET%.0lf.png",METmin)); c1->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/eta1_optcuts_MET%.0lf.pdf",METmin)); } }