int main(){ std::vector<double> RMSmeas; std::vector<double> RMSmin; //std::vector<double> RMSelim; std::vector<double> initP; std::vector<double> RMSmin2; //placeholder vectors for quick and easy parsing of txt file (this isnt that efficient) //the initP and meas values for the plot come from minimalist1 std::vector<double> RMSmeas2; std::vector<double>initP2; std::ifstream f1("RMSmin.txt"); std::ifstream f2("RMSmin2.txt"); double temp; while(f1>>temp){ RMSmeas.push_back(temp); f1>>temp; RMSmin.push_back(temp); //f1>>temp; //RMSelim.push_back(temp); f1>>temp; initP.push_back(temp); } while(f2>>temp){ RMSmeas2.push_back(temp); f2>>temp; RMSmin2.push_back(temp); f2>>temp; initP2.push_back(temp); } int n = RMSmeas.size(); double measured[n], minimalist[n], elimination[n], inp[n], minimalist2[n], err_min[n], err_min2[n]; //copy to double arrays because it would be too convenient to use vectors with root for(int i=0; i<n; i++){ measured[i] = RMSmeas[i]; minimalist[i] = RMSmin[i]; //elimination[i] = RMSelim[i]; minimalist2[i] = RMSmin2[i]; inp[i] = initP[i]; //err_min[i] = RMSmin[i]/ } TCanvas *c1 = new TCanvas("c1","Epi RMS vs initial momentum",200,10,800,600); //TMultiGraph *mg = new TMultiGraph(); TGraph *meas = new TGraph(n,inp,measured); TGraph *min = new TGraph(n,inp,minimalist); TGraph *min2 = new TGraph(n,inp,minimalist2); //TGraph *elim = new TGraph(n,inp,elimination); meas->SetName("meas"); min->SetName("min"); min2->SetName("min2"); //measured rms options meas->SetTitle("E_{#pi^{0}} RMS vs |P_{#pi^{0}}|;Initial Momentum P_{#pi^{0}} GEV;RMS (GEV)"); meas->SetMarkerStyle(21); meas->SetMarkerColor(2); meas->SetLineColor(4); meas->Draw("AP"); //meas->GetXaxis()->SetTitle("GEV"); //meas->GetYaxis()->SetTitle("RMS"); min->SetMarkerColor(4); min->SetMarkerStyle(22); min->SetLineColor(3); min->Draw("P"); //elim->SetMarkerColor(3); //elim->SetMarkerStyle(3); //elim->SetLineColor(2); //elim->Draw("CP"); min2->SetMarkerColor(5); min2->SetMarkerStyle(20); min2->SetLineColor(5); min2->Draw("P"); TLegend* legend = new TLegend(0.1,0.7,0.48,0.9); legend->AddEntry("meas", "Measured", "p"); legend->AddEntry("min", "Minimalist", "p"); legend->AddEntry("min2", "Minimalist2", "p"); legend->Draw(); //mg->Add(meas); //mg->Add(min); //mg->Add(elim); //mg->Draw("AC"); c1->Print("E_PIrms_vs_intial_momentum.pdf"); }
void simulateResponse() { TF1 MyPoisson("MyPoisson", PoissonReal, 0., 20, 1); gStyle->SetPadLeftMargin(0.15); gStyle->SetPadRightMargin(0.05); int NEVT = 10000; // the mean number of photons from clas6 // was 9. // For pions however, depending on momemntum, // this number will change. // Taking 9 as the number of photons for pions at 7.5 GeV // and calculating the ratio of pi3 for each momentum double mean7 = 9; double means[MNP]; double pion_ratio_1[MNP]; // no changes: same mirror, same PMT, same wc (so-so) double pion_ratio_2[MNP]; // recoated mirror, same PMT, same wc (so-so) double pion_ratio_3[MNP]; // recoated mirror, improved PMT, same wc (so-so) double pion_ratio_4[MNP]; // recoated mirror, improved PMT, coated wc (good) double pion_ratio_5[MNP]; // recoated mirror, improved PMT, bad wc double pion_ratio_6[MNP]; // recoated mirror, improved PMT, perfect wc (2 // reflections only) TH1D* perfec[MNP]; TH1D* doNoth[MNP]; TH1D* fixBad[MNP]; TH1D* fixAll[MNP]; // assuming show_ration has been run (need to re-run if RECALC is 1) ifstream in("pionYield.txt"); for (int i = 0; i < MNP; i++) { in >> pion_ratio_1[i] >> pion_ratio_2[i] >> pion_ratio_3[i] >> pion_ratio_4[i] >> pion_ratio_5[i] >> pion_ratio_6[i]; } in.close(); if (RECALC2 == 0) { TFile f("dist.root"); for (int i = 0; i < MNP; i++) { perfec[i] = (TH1D*)f.Get(Form("perfec%d", i)); doNoth[i] = (TH1D*)f.Get(Form("doNoth%d", i)); fixBad[i] = (TH1D*)f.Get(Form("fixBad%d", i)); fixAll[i] = (TH1D*)f.Get(Form("fixAll%d", i)); perfec[i]->SetDirectory(0); doNoth[i]->SetDirectory(0); fixBad[i]->SetDirectory(0); fixAll[i]->SetDirectory(0); } f.Close(); } else { for (int i = 0; i < MNP; i++) { perfec[i] = new TH1D(Form("perfec%d", i), Form("perfec%d", i), 250, 0, 25); doNoth[i] = new TH1D(Form("doNoth%d", i), Form("doNoth%d", i), 250, 0, 25); fixBad[i] = new TH1D(Form("fixBad%d", i), Form("fixBad%d", i), 250, 0, 25); fixAll[i] = new TH1D(Form("fixAll%d", i), Form("fixAll%d", i), 250, 0, 25); } for (int i = 2; i < MNP; i++) { // means[i] = mean7*pion_ratio_2[i]/pion_ratio_2[11]; means[i] = mean7 * pion_ratio_3[i] / pion_ratio_3[11]; for (int e = 1; e < NEVT; e++) { if (e % 1000 == 0) { cout << " Event number " << e << " for momentum: " << i << endl; } MyPoisson.SetParameter(0, means[i]); double r = MyPoisson.GetRandom(); perfec[i]->Fill(r); int nr = calculateNReflection(gRandom->Uniform(0, 1)); int gr = calculateWCgroup(gRandom->Uniform(0, 1)); // only 2 reflections // wc are "perfect" if (nr == 2) { doNoth[i]->Fill(r * pion_ratio_4[i]); fixBad[i]->Fill(r * pion_ratio_4[i]); fixAll[i]->Fill(r * pion_ratio_4[i]); } if (nr == 3) { // bad if (gr == 1) { doNoth[i]->Fill(r * pion_ratio_5[i]); fixBad[i]->Fill(r * pion_ratio_4[i]); fixAll[i]->Fill(r * pion_ratio_4[i]); } // so-so if (gr == 2) { doNoth[i]->Fill(r * pion_ratio_3[i]); fixBad[i]->Fill(r * pion_ratio_3[i]); fixAll[i]->Fill(r * pion_ratio_4[i]); } // good if (gr == 3) { doNoth[i]->Fill(r * pion_ratio_4[i]); fixBad[i]->Fill(r * pion_ratio_4[i]); fixAll[i]->Fill(r * pion_ratio_4[i]); } } if (nr == 4) { r = r * 0.8; // bad if (gr == 1) { doNoth[i]->Fill(r * pion_ratio_5[i]); fixBad[i]->Fill(r * pion_ratio_4[i]); fixAll[i]->Fill(r * pion_ratio_4[i]); } // so-so if (gr == 2) { doNoth[i]->Fill(r * pion_ratio_3[i]); fixBad[i]->Fill(r * pion_ratio_3[i]); fixAll[i]->Fill(r * pion_ratio_4[i]); } // good if (gr == 3) { doNoth[i]->Fill(r * pion_ratio_4[i]); fixBad[i]->Fill(r * pion_ratio_4[i]); fixAll[i]->Fill(r * pion_ratio_4[i]); } } } } // saving histos TFile f("dist.root", "RECREATE"); for (int i = 0; i < MNP; i++) { perfec[i]->Write(); doNoth[i]->Write(); fixBad[i]->Write(); fixAll[i]->Write(); } f.Close(); } // histos loaded, now plotting for (int i = 0; i < MNP; i++) { doNoth[i]->SetLineColor(kRed); fixBad[i]->SetLineColor(kBlue); fixAll[i]->SetLineColor(kGreen); perfec[i]->GetXaxis()->SetLabelSize(0.08); perfec[i]->GetYaxis()->SetLabelSize(0.08); perfec[i]->GetXaxis()->SetLabelOffset(-0.02); perfec[i]->GetYaxis()->SetLabelOffset(0.02); } double xmom[10]; double ymomA[10]; double ymomB[10]; double ymomC[10]; TCanvas* res = new TCanvas("res", "Photon Yields", 1500, 1200); TPad* pres = new TPad("pres", "pres", 0.01, 0.01, 0.98, 0.9); pres->Divide(5, 2); pres->Draw(); TLatex lab; lab.SetTextFont(102); lab.SetTextColor(kBlue + 2); lab.SetTextSize(0.06); lab.SetNDC(); for (int i = 2; i < 12; i++) { pres->cd(i - 1); perfec[i]->Draw(); fixAll[i]->Draw("same"); doNoth[i]->Draw("same"); fixBad[i]->Draw("same"); double perfectCounts = perfec[i]->Integral(40, 250); double donothCounts = doNoth[i]->Integral(40, 250); double fixBadCounts = fixBad[i]->Integral(40, 250); double fixAllCounts = fixAll[i]->Integral(40, 250); double dmom = (max_m - min_m) / MNP; double mom = min_m + i * dmom; xmom[i - 2] = mom; ymomA[i - 2] = 100 * donothCounts / perfectCounts; ymomB[i - 2] = 100 * fixBadCounts / perfectCounts; ymomC[i - 2] = 100 * fixAllCounts / perfectCounts; cout << " momentum: " << mom << " perfect: " << perfectCounts << " nothing: " << donothCounts << " fix bad: " << fixBadCounts << " fix all " << fixAllCounts << endl; lab.DrawLatex(.5, .82, Form(" mom: %2.1f GeV", mom)); lab.DrawLatex(.5, .75, Form(" do nothing: %3.1f%%", 100 * donothCounts / perfectCounts)); lab.DrawLatex( .5, .68, Form(" fix bad: %3.1f%%", 100 * fixBadCounts / perfectCounts)); lab.DrawLatex( .5, .60, Form(" fix all: %3.1f%%", 100 * fixAllCounts / perfectCounts)); } // res->Print("allMoms.png"); TCanvas* res2 = new TCanvas("res2", "Photon Yields", 1000, 1000); // perfec[5]->Draw(); // fixAll[5]->Draw("same"); // doNoth[5]->Draw("same"); // fixBad[5]->Draw("same"); // // res2->Print("fixAll.png"); TGraph* mresA = new TGraph(10, xmom, ymomA); TGraph* mresB = new TGraph(10, xmom, ymomB); TGraph* mresC = new TGraph(10, xmom, ymomC); mresA->SetMarkerStyle(8); mresB->SetMarkerStyle(21); mresC->SetMarkerStyle(8); mresA->SetMarkerSize(1.6); mresB->SetMarkerSize(1.6); mresC->SetMarkerSize(1.6); mresA->SetMarkerColor(kBlack); mresB->SetMarkerColor(kRed); mresC->SetMarkerColor(kBlue); mresA->Draw("AP"); mresB->Draw("Psame"); mresC->Draw("Psame"); TLegend* lstudy = new TLegend(0.6, 0.35, 0.95, 0.58); lstudy->AddEntry(mresA, "Current Situation", "P"); lstudy->AddEntry(mresB, "Fix Bad", "P"); lstudy->AddEntry(mresC, "Fix So-So", "P"); lstudy->SetBorderSize(0); lstudy->SetFillColor(0); lstudy->Draw(); }
void validation() { msglvl[DBG] = SILENT; msglvl[INF] = VISUAL; msglvl[WRN] = VISUAL; msglvl[ERR] = VISUAL; msglvl[FAT] = VISUAL; TDirectory* oldDir = gDirectory; // remember old directory style(); Int_t g4bin = (ng4bins/g4max+1); //==> g^4=1 ==> SSM ! TString suffix = ""; if(doTruth) suffix = "_truth"; TString mctype = (isMC11c) ? "mc11c" : "mc11a"; // TString fBGname = "plots/ZP_2dtemplates_"+mctype+"_33st_overallEWkF_noInAmpSigEWkF_noHighMbins_wthOfficialZP_Xmass2000.root"; // TString fBGname = "plots/ZP_2dtemplates_"+mctype+"_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_noTruth_wthOfficialZP_treeLevelMass_Xmass2000.root"; // TString fBGname = "plots/ZP_2dtemplates_"+mctype+"_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_wthOfficialZP_treeLevelMass_Xmass2000.root"; // TString fBGname = "plots/ZP_2dtemplates_mc11c_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_wthOfficialZP_fixedBWwidth_treeLevelMass_Xmass2000.root"; // TString fBGname = "plots/ZP_2dtemplates_mc11c_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_noTruth_wthOfficialZP_treeLevelMass_Xmass2000.root"; // TString fBGname = "plots/ZP_2dtemplates_"+mctype+"_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_noTruth_wthOfficialZP_treeLevelMass_Xmass2000.root"; // TString fBGname = "plots/ZP_2dtemplates_"+mctype+"_33st_noKKtmplates_overallEWkF_noInAmpSigEWkF_noTruth_wthOfficialZP_fixedBWwidth_treeLevelMass_Xmass2000.root"; TLegend* legR = new TLegend(0.15,0.75,0.35,0.85,NULL,"brNDC"); legR->SetFillStyle(4000); //will be transparent legR->SetFillColor(0); legR->SetTextFont(42); TH1D* hDummy = new TH1D("","",1,0.,1.); hDummy->SetMarkerStyle(20); hDummy->SetMarkerSize(0.8); hDummy->SetMarkerColor(kBlack); if(!doResiduals) legR->AddEntry(hDummy,"#frac{template}{official}","lep"); else legR->AddEntry(hDummy,"#frac{template - official}{#sqrt{#delta^{2}template + #delta^{2}official}}","lep"); TPaveText* ptxt = new TPaveText(0.145,0.35,0.245,0.55,"NDC"); TText* txt; ptxt->SetTextSize(0.03); ptxt->SetBorderSize(0); ptxt->SetFillStyle(4000); //will be transparent ptxt->SetFillColor(0); ptxt->SetTextAlign(12); txt = ptxt->AddText("This range"); txt = ptxt->AddText("is chopped"); txt = ptxt->AddText("before the"); txt = ptxt->AddText("template is"); txt = ptxt->AddText("handed to"); txt = ptxt->AddText("BAT (limit)."); oldDir->cd(); TString fBGname = "plots/validation/ZP_2dtemplates_mc11c_33st_noKKtmplates_wthOfficialZP_treeLevelMass_Xmass2000.root"; TFile* fD = new TFile(fBGname,"READ"); TH1D* hDY = NULL; if(doTruth) hDY = (TH1D*)fD->Get("hMass_DYmumu_truth")->Clone(); else hDY = (TH1D*)fD->Get("hMass_DYmumu")->Clone(); hDY->SetLineColor(kMagenta-5); hDY->SetMarkerColor(kMagenta-5); oldDir->cd(); TFile* fDYrozmin = new TFile("plots/mass_plot_tables_3st.root","READ"); TH1D* hDYrozmin = (TH1D*)fDYrozmin->Get("mass_log_dy")->Clone(); hDYrozmin = (TH1D*)hGeV2TeV(hDYrozmin)->Clone(); hDYrozmin = (TH1D*)hChopper(hDYrozmin,bins2chop)->Clone(); oldDir->cd(); TFile* f1dTemplates = new TFile("plots/ZpSignal_MM_MC11c_5points.root","READ"); TObjArray* toarr1d = new TObjArray(); toarr1d->Read("template"); TMapTSP2TH1D h1dBrandeisTmpltMap; double Nflat = 399948; double sigmaflat = 4.3988E+07*nb2fb; double Lmcflat = Nflat/sigmaflat; double scale = luminosity/Lmcflat; TH1D* h1dTmp = NULL; h1dTmp = (TH1D*)((TObjArray*)toarr1d->At(0/*22*/))->Clone(); h1dTmp->Scale(scale); h1dTmp = (TH1D*)hChopper(h1dTmp,bins2chop)->Clone(); h1dTmp->Add(hDYrozmin); h1dBrandeisTmpltMap.insert( make_pair("1000",(TH1D*)resetErrors(h1dTmp)->Clone("1000")) ); h1dTmp = NULL; h1dTmp = (TH1D*)((TObjArray*)toarr1d->At(1/*28*/))->Clone(); h1dTmp->Scale(scale); h1dTmp = (TH1D*)hChopper(h1dTmp,bins2chop)->Clone(); h1dTmp->Add(hDYrozmin); h1dBrandeisTmpltMap.insert( make_pair("1250",(TH1D*)resetErrors(h1dTmp)->Clone("1250")) ); h1dTmp = NULL; h1dTmp = (TH1D*)((TObjArray*)toarr1d->At(2/*34*/))->Clone(); h1dTmp->Scale(scale); h1dTmp = (TH1D*)hChopper(h1dTmp,bins2chop)->Clone(); h1dTmp->Add(hDYrozmin); h1dBrandeisTmpltMap.insert( make_pair("1500",(TH1D*)resetErrors(h1dTmp)->Clone("1500")) ); h1dTmp = NULL; h1dTmp = (TH1D*)((TObjArray*)toarr1d->At(3/*40*/))->Clone(); h1dTmp->Scale(scale); h1dTmp = (TH1D*)hChopper(h1dTmp,bins2chop)->Clone(); h1dTmp->Add(hDYrozmin); h1dBrandeisTmpltMap.insert( make_pair("1750",(TH1D*)resetErrors(h1dTmp)->Clone("1750")) ); h1dTmp = NULL; h1dTmp = (TH1D*)((TObjArray*)toarr1d->At(4/*47*/))->Clone(); h1dTmp->Scale(scale); h1dTmp = (TH1D*)hChopper(h1dTmp,bins2chop)->Clone(); h1dTmp->Add(hDYrozmin); h1dBrandeisTmpltMap.insert( make_pair("2000",(TH1D*)resetErrors(h1dTmp)->Clone("2000")) ); oldDir->cd(); TMapTSP2TH1D h1Map; h1Map.insert( make_pair("1000o", (TH1D*)fD->Get("hMass_Zprime_SSM1000"+suffix)->Clone()) ); h1Map.insert( make_pair("1000t", (TH1D*)fD->Get("hMass_Zprime_SSM1000_template"+suffix)->Clone()) ); if(isMC11c) { h1Map.insert( make_pair("1250o", (TH1D*)fD->Get("hMass_Zprime_SSM1250"+suffix)->Clone()) ); h1Map.insert( make_pair("1250t", (TH1D*)fD->Get("hMass_Zprime_SSM1250_template"+suffix)->Clone()) ); } h1Map.insert( make_pair("1500o", (TH1D*)fD->Get("hMass_Zprime_SSM1500"+suffix)->Clone()) ); h1Map.insert( make_pair("1500t", (TH1D*)fD->Get("hMass_Zprime_SSM1500_template"+suffix)->Clone()) ); h1Map.insert( make_pair("1750o", (TH1D*)fD->Get("hMass_Zprime_SSM1750"+suffix)->Clone()) ); h1Map.insert( make_pair("1750t", (TH1D*)fD->Get("hMass_Zprime_SSM1750_template"+suffix)->Clone()) ); h1Map.insert( make_pair("2000o", (TH1D*)fD->Get("hMass_Zprime_SSM2000"+suffix)->Clone()) ); h1Map.insert( make_pair("2000t", (TH1D*)fD->Get("hMass_Zprime_SSM2000_template"+suffix)->Clone()) ); TMapTSP2TH1D h1rMap; h1rMap.insert( make_pair("1000", (TH1D*)fD->Get("hMass_Zprime_SSM1000"+suffix)->Clone()) ); if(isMC11c) h1rMap.insert( make_pair("1250", (TH1D*)fD->Get("hMass_Zprime_SSM1250"+suffix)->Clone()) ); h1rMap.insert( make_pair("1500", (TH1D*)fD->Get("hMass_Zprime_SSM1500"+suffix)->Clone()) ); h1rMap.insert( make_pair("1750", (TH1D*)fD->Get("hMass_Zprime_SSM1750"+suffix)->Clone()) ); h1rMap.insert( make_pair("2000", (TH1D*)fD->Get("hMass_Zprime_SSM2000"+suffix)->Clone()) ); for(TMapTSP2TH1D::iterator it=h1rMap.begin() ; it!=h1rMap.end() ; ++it) { it->second->Reset(); if(!doResiduals) it->second->Divide(h1Map[it->first+"o"],h1Map[it->first+"t"],1.,1.,"B"); else residuals(h1Map[it->first+"o"], h1Map[it->first+"t"], it->second); // for(Int_t i=0 ; i<=it->second->GetNbinsX()+1 ; i++) it->second->SetBinError(i,0); it->second->SetMarkerStyle(20); it->second->SetMarkerSize(0.5); it->second->GetXaxis()->SetLabelSize(0.073); it->second->GetYaxis()->SetLabelSize(0.073); it->second->GetXaxis()->SetTitleSize(0.073); it->second->GetYaxis()->SetTitleSize(0.073); it->second->SetTitleSize(0.075); it->second->GetYaxis()->SetTitleOffset(0.5); if(!doResiduals) { it->second->SetMinimum(0.2); it->second->SetMaximum(1.8); } else { it->second->SetMinimum(-5.); it->second->SetMaximum(+5.); } it->second->SetTitle(""); if(!doResiduals) it->second->GetYaxis()->SetTitle("ratio"); else it->second->GetYaxis()->SetTitle("residuals"); } TMapTSP2TGAE poissonGraphMap; TMapTSP2TLeg legMap; _INFO(""); oldDir->cd(); fD->cd(); TH1D* h1Template = (TH1D*)fD->Get("hMass_DYmumu"+suffix)->Clone(); h1Template->Reset(); TObjArray* toarr = new TObjArray(); if(doTruth) toarr->Read("truth_template2d"); else toarr->Read("template2d"); TH2D* h2SSM2000 = (TH2D*)((TObjArray*)toarr->At(0))->Clone("hMass"+suffix+"_Zprime_SSM2000_template2d"); for(Int_t bin=1 ; bin<=h2SSM2000->GetNbinsX() ; bin++) { h1Template->SetBinContent(bin, h2SSM2000->GetBinContent(bin,g4bin)); h1Template->SetBinError(bin, h2SSM2000->GetBinError(bin,g4bin)); } h1Template->SetLineColor(kViolet); h1Template->SetLineWidth(1); h1Template->SetMarkerStyle(20); h1Template->SetMarkerSize(0.3); h1Template->SetMarkerColor(kViolet); // the functions h2Template = (TH2D*)h2SSM2000->Clone(); vector<TF1*> vfunc; unsigned int nmllbins = h2Template->GetNbinsX(); for(unsigned int mll=1 ; mll<=(nmllbins-bins2chop) ; mll++) // 1...(56-9 = 47) { TString mllname = (TString)_s(mll); TString mllval = (TString)_s(h2Template->GetXaxis()->GetBinCenter(mll+bins2chop)); TF1* f = new TF1("fNominal_mll"+mllname,fTH1toTF1,g4min,g4max,1); f->SetParameter(0,mll); f->SetParNames("mll"); // f->SetLineColor(kBlue); // f->SetLineWidth(1); f->SetNpx(400); vfunc.push_back(f); } TGraph* graphDY = new TGraph(); graphDY->SetMarkerStyle(25); graphDY->SetMarkerSize(0.6); graphDY->SetMarkerColor(kGreen+2); TGraph* graphSSM = new TGraph(); graphSSM->SetMarkerStyle(24); graphSSM->SetMarkerSize(0.6); graphSSM->SetMarkerColor(kOrange+8); for(unsigned int i=0 ; i<vfunc.size() ; i++) { double DY = vfunc[i]->Eval(0.0); double SSM = vfunc[i]->Eval(1.0); graphDY->SetPoint(i,h2Template->GetXaxis()->GetBinCenter(bins2chop+i+1),DY); graphSSM->SetPoint(i,h2Template->GetXaxis()->GetBinCenter(bins2chop+i+1),SSM); } oldDir->cd(); TObjArray* toarr1dTLV = new TObjArray(); TMapTSP2TH1D h1dTlvTmpltMap; TFile* fT = NULL; TString fTname = "plots/validation/ZP_2dtemplates_mc11c_33st_noInterference_noKKtmplates_noOverallEWkF_wthOfficialZP_treeLevelMass_Xmass"; fT = new TFile(fTname+"1000.root","READ"); toarr1dTLV->Read("template"); h1dTmp = (TH1D*)((TObjArray*)toarr1dTLV->At(0))->Clone(); h1dTmp->Add(hDY); h1dTlvTmpltMap.insert( make_pair("1000",(TH1D*)resetErrors(h1dTmp)->Clone("1000")) ); fT = new TFile(fTname+"1250.root","READ"); toarr1dTLV->Read("template"); h1dTmp = (TH1D*)((TObjArray*)toarr1dTLV->At(0))->Clone(); h1dTmp->Add(hDY); h1dTlvTmpltMap.insert( make_pair("1250",(TH1D*)resetErrors(h1dTmp)->Clone("1250")) ); fT = new TFile(fTname+"1500.root","READ"); toarr1dTLV->Read("template"); h1dTmp = (TH1D*)((TObjArray*)toarr1dTLV->At(0))->Clone(); h1dTmp->Add(hDY); h1dTlvTmpltMap.insert( make_pair("1500",(TH1D*)resetErrors(h1dTmp)->Clone("1500")) ); fT = new TFile(fTname+"1750.root","READ"); toarr1dTLV->Read("template"); h1dTmp = (TH1D*)((TObjArray*)toarr1dTLV->At(0))->Clone(); h1dTmp->Add(hDY); h1dTlvTmpltMap.insert( make_pair("1750",(TH1D*)resetErrors(h1dTmp)->Clone("1750")) ); fT = new TFile(fTname+"2000.root","READ"); toarr1dTLV->Read("template"); h1dTmp = (TH1D*)((TObjArray*)toarr1dTLV->At(0))->Clone(); h1dTmp->Add(hDY); h1dTlvTmpltMap.insert( make_pair("2000",(TH1D*)resetErrors(h1dTmp)->Clone("2000")) ); oldDir->cd(); for(TMapTSP2TH1D::iterator it=h1Map.begin() ; it!=h1Map.end() ; ++it) { if(it->first.Contains("o")) { TString name = it->first; name.ReplaceAll("o",""); it->second->SetFillColor(kAzure-9); if(doTruth) it->second->SetTitle("m_{Z'} = "+name+" GeV (truth)"); else it->second->SetTitle("m_{Z'} = "+name+" GeV"); } if(it->first.Contains("t")) { //TGraphAsymmErrors* poisson(TH1D* h) it->second->SetLineColor(kBlue); it->second->SetMarkerStyle(20); it->second->SetMarkerSize(0.4); it->second->SetMarkerColor(kBlue); it->second->SetLineWidth(1); TString name = it->first; name.ReplaceAll("t",""); poissonGraphMap.insert( make_pair(name, (TGraphAsymmErrors*)poisson(it->second)->Clone()) ); poissonGraphMap[name]->SetMarkerStyle(20); poissonGraphMap[name]->SetMarkerSize(0.3); poissonGraphMap[name]->SetMarkerColor(kBlue); poissonGraphMap[name]->SetLineWidth(1); poissonGraphMap[name]->SetLineColor(kBlue); } } Double_t yLine = (!doResiduals) ? 1. : 0.; TLine* line = new TLine(0.07,yLine,3.,yLine); line->SetLineColor(kRed); line->SetLineWidth(2); TMapTSP2TCNV cnvMap; cnvMap.insert( make_pair("1000", new TCanvas("1000","1000",600,550)) ); if(isMC11c) cnvMap.insert( make_pair("1250", new TCanvas("1250","1250",600,550)) ); cnvMap.insert( make_pair("1500", new TCanvas("1500","1500",600,550)) ); cnvMap.insert( make_pair("1750", new TCanvas("1750","1750",600,550)) ); cnvMap.insert( make_pair("2000", new TCanvas("2000","2000",600,550)) ); for(TMapTSP2TCNV::iterator it=cnvMap.begin() ; it!=cnvMap.end() ; ++it) { _INFO("starting "+(string)it->first); if(it->first=="2000") legMap.insert( make_pair(it->first, new TLegend(0.35,0.55,0.83,0.84,NULL,"brNDC")) ); else legMap.insert( make_pair(it->first, new TLegend(0.35,0.60,0.83,0.84,NULL,"brNDC")) ); legMap[it->first]->SetFillStyle(4000); //will be transparent legMap[it->first]->SetFillColor(0); legMap[it->first]->SetTextFont(42); legMap[it->first]->AddEntry(h1Map[it->first+"o"],"Official Z'_{SSM}","F"); legMap[it->first]->AddEntry(hDY,"Official DY#mu#mu","lep"); legMap[it->first]->AddEntry(h1Map[it->first+"t"],"ME^{2} method: Template w/o couplings scale","lep"); if(it->first=="2000") { legMap[it->first]->AddEntry(h1Template,"ME^{2} method: Template histogram at #it{g=1} (SSM)","lep"); legMap[it->first]->AddEntry(graphSSM, "ME^{2} method: Template function at #it{g=1} (SSM)","p"); legMap[it->first]->AddEntry(graphDY, "ME^{2} method: Template function at #it{g=0} (DY)","p"); } if(!doTruth) { h1dTlvTmpltMap[it->first]->SetLineColor(kCyan+2); h1dTlvTmpltMap[it->first]->SetMarkerColor(kCyan+2); h1dTlvTmpltMap[it->first]->SetMarkerStyle(5); h1dTlvTmpltMap[it->first]->SetMarkerSize(0.5); legMap[it->first]->AddEntry(h1dTlvTmpltMap[it->first],"ME^{2} method: DY+Template (no interference)","p"); h1dBrandeisTmpltMap[it->first]->SetLineColor(kRed); h1dBrandeisTmpltMap[it->first]->SetMarkerColor(kRed); h1dBrandeisTmpltMap[it->first]->SetMarkerStyle(27); h1dBrandeisTmpltMap[it->first]->SetMarkerSize(0.5); legMap[it->first]->AddEntry(h1dBrandeisTmpltMap[it->first],"Flat Z' method: DY+Template (no interference)","p"); } it->second->Divide(1,2); TVirtualPad* ph = it->second->cd(1); TVirtualPad* pr = it->second->cd(2); ph->SetPad(0.00, 0.35, 1.00, 1.00); pr->SetPad(0.00, 0.00, 1.00, 0.35); ph->SetBottomMargin(0.012); pr->SetBottomMargin(0.20); pr->SetTopMargin(0.012); ph->cd(); ph->Draw(); ph->SetTicks(1,1); ph->SetLogy(); ph->SetLogx(); // h1Map[it->first+"o"]->SetMaximum( h1Map[it->first+"t"]->GetMaximum()*1.5 ); // h1Map[it->first+"o"]->Draw(); TH1D* hTmpNoErr = (TH1D*)resetErrors(h1Map[it->first+"o"])->Clone(); hTmpNoErr->SetMaximum( h1Map[it->first+"t"]->GetMaximum()*1.5 ); hTmpNoErr->SetLineStyle(1); hTmpNoErr->SetLineColor(kBlack); hTmpNoErr->SetFillColor(kAzure-9); hTmpNoErr->Draw(); TH1D* hTmpErr = (TH1D*)ShiftLog(h1Map[it->first+"o"],0.2)->Clone(); hTmpErr->SetFillStyle(4000); //will be transparent hTmpErr->SetFillColor(0); hTmpErr->DrawCopy("epx0SAMES"); hDY->Draw("SAMES"); h1Map[it->first+"t"]->Draw("epSAMES"); //poissonGraphMap[it->first]->Draw("pSAMES"); if(it->first=="2000") { graphDY->Draw("SAMESp"); graphSSM->Draw("SAMESp"); h1Template->Draw("epSAMES"); } _INFO(""); h1dTlvTmpltMap[it->first]->Draw("SAMESp"); h1dBrandeisTmpltMap[it->first]->Draw("SAMESp"); TLine* chopline = new TLine(0.12805,getYmin(h1Map[it->first+"o"]),0.12805,7.e5); chopline->SetLineStyle(2); chopline->SetLineColor(kBlack); chopline->Draw("SAMES"); ptxt->Draw("SAMES"); legMap[it->first]->Draw("SAMES"); ph->RedrawAxis(); ph->Update(); _INFO(""); pr->cd(); pr->Draw(); pr->SetTicks(1,1); pr->SetGridy(); pr->SetLogx(); h1rMap[it->first]->Draw("ep"); line->Draw("SAMES"); h1rMap[it->first]->Draw("epSAMES"); legR->Draw("SAMES"); pr->RedrawAxis(); pr->Update(); unsigned int savestate = 1; if(it->first=="1000") savestate = 0; else if(it->first=="2000") savestate = 2; else savestate = 1; TString testType = (doResiduals) ? "_residuals" : "_ratio"; mutype = (doTruth) ? "_truth" : "_recon"; savemultipdf(it->second, "plots/validation/validation"+mutype+testType+"_"+mctype+"_all.pdf", savestate); saveas(it->second, "plots/validation/validation"+mutype+testType+"_"+mctype+"_"+it->first); TCanvas* c = new TCanvas(it->first,"",600,400); c->cd(); c->Draw(); c->SetTicks(1,1); c->SetLogy(); c->SetLogx(); hTmpNoErr->Draw(); hTmpErr->DrawCopy("epx0SAMES"); hDY->Draw("SAMES"); h1Map[it->first+"t"]->Draw("epSAMES"); //poissonGraphMap[it->first]->Draw("pSAMES"); if(it->first=="2000") { graphDY->Draw("SAMESp"); graphSSM->Draw("SAMESp"); h1Template->Draw("epSAMES"); } h1dTlvTmpltMap[it->first]->Draw("SAMESp"); h1dBrandeisTmpltMap[it->first]->Draw("SAMESp"); legMap[it->first]->Draw("SAMES"); chopline->Draw("SAMES"); ptxt->Draw("SAMES"); c->RedrawAxis(); c->Update(); saveas(c,"plots/validation/validation_"+it->first+"_"+mutype+testType); _INFO("done "+(string)it->first); } }
void ProcessingTime(const char *inputFile) { TChain *chain = new TChain("Delphes"); chain->Add(inputFile); TH1F hist("time", "time", 50, 0, 0.01); Int_t i; TDirectory *currentDirectory = gDirectory; // Graphics style parameters to avoid grey background on figures gStyle->SetCanvasColor(kExRootBackgroundColor); gStyle->SetStatColor(kExRootBackgroundColor); // gStyle->SetTitleColor(kExRootBackgroundColor); gStyle->SetPadColor(kExRootBackgroundColor); gStyle->SetPadTopMargin(0.10); gStyle->SetPadRightMargin(0.10); gStyle->SetPadBottomMargin(0.15); gStyle->SetPadLeftMargin(0.15); gStyle->SetStatFont(kExRootFont); gStyle->SetStatFontSize(kExRootFontSize); gStyle->SetTitleFont(kExRootFont, ""); gStyle->SetTitleFont(kExRootFont, "X"); gStyle->SetTitleFont(kExRootFont, "Y"); gStyle->SetTitleFont(kExRootFont, "Z"); gStyle->SetTitleSize(kExRootFontSize, ""); gStyle->SetTitleSize(kExRootFontSize, "X"); gStyle->SetTitleSize(kExRootFontSize, "Y"); gStyle->SetTitleSize(kExRootFontSize, "Z"); gStyle->SetLabelFont(kExRootFont, "X"); gStyle->SetLabelFont(kExRootFont, "Y"); gStyle->SetLabelFont(kExRootFont, "Z"); gStyle->SetLabelSize(kExRootFontSize, "X"); gStyle->SetLabelSize(kExRootFontSize, "Y"); gStyle->SetLabelSize(kExRootFontSize, "Z"); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); gStyle->SetTextFont(kExRootFont); gStyle->SetTextSize(kExRootFontSize); gStyle->SetOptStat(111110); // gStyle->SetOptFit(101); canvas = static_cast<TCanvas*>(gROOT->FindObject("c1")); if(canvas) { canvas->Clear(); canvas->UseCurrentStyle(); canvas->SetWindowSize(800, 650); } else { canvas = new TCanvas("c1", "c1", 800, 650); } canvas->SetGrid(); canvas->SetHighLightColor(kExRootBackgroundColor); currentDirectory->cd(); for(i = 0; i < 9; ++i) { chain->Draw("Event.ProcTime >> time", TString::Format("Jet_size == %d", i+2)); gr.SetPoint(i, i+2, hist.GetMean()*1000); grerr.SetPoint(i, i+2, hist.GetMean()*1000); grerr.SetPointError(i, 0, hist.GetRMS()*1000); } grerr.GetXaxis()->SetLimits(1.0, 11.0); grerr.GetXaxis()->SetTitleOffset(1.5); grerr.GetYaxis()->SetTitleOffset(1.75); grerr.GetXaxis()->SetTitle("jet multiplicity"); grerr.GetYaxis()->SetTitle("processing time per event, ms"); gr.SetMarkerStyle(kFullCircle); gr.SetMarkerColor(kBlack); gr.SetMarkerSize(1); gr.SetLineColor(kBlack); gr.SetLineWidth(2); grerr.SetFillStyle(1001); grerr.SetFillColor(17); grerr.Draw("A3"); gr.Draw("P"); comment.SetTextSize(kExRootFontSize); comment.SetTextFont(kExRootFont); comment.SetTextAlign(22); comment.SetFillColor(kExRootBackgroundColor); comment.SetBorderSize(0); comment.AddText("ttbar + jets events"); comment.Draw(); }
void plot() { TGraph * FWHM = new TGraph( "plot.txt" , "%lg %lg %*lg %*lg" ); TGraph * FWTM = new TGraph( "plot.txt" , "%lg %*lg %lg %*lg" ); TGraph * FWFM = new TGraph( "plot.txt" , "%lg %*lg %*lg %lg" ); TGraph * ratioTH = new TGraph(); TGraph * ratioFH = new TGraph(); ratioTH->SetName("ratioTH"); ratioFH->SetName("ratioFH"); double * x = FWHM->GetX(); double * yH = FWHM->GetY(); double * yT = FWTM->GetY(); double * yF = FWFM->GetY(); for ( int i = 0 ; i < FWHM->GetN() ; i++ ) { ratioTH->SetPoint( i , x[i] , yT[i]/yH[i] ); ratioFH->SetPoint( i , x[i] , yF[i]/yH[i] ); } ratioTH->SetTitle("Gaussianity"); ratioTH->GetXaxis()->SetTitle("Energy Width [us]"); ratioTH->SetMarkerStyle(20); ratioTH->SetMarkerColor(kViolet+2); ratioTH->SetMarkerSize(1.5); ratioTH->SetLineColor(kViolet+2); ratioFH->SetMarkerStyle(29); ratioFH->SetMarkerColor(kYellow+2); ratioFH->SetMarkerSize(1.5); ratioFH->SetLineColor(kYellow+2); ratioTH->GetYaxis()->SetRangeUser(1,6); FWHM->SetTitle("Resolution"); FWHM->GetYaxis()->SetRangeUser(0,17); FWHM->GetYaxis()->SetTitle("[keV]"); FWHM->GetXaxis()->SetTitle("Energy Width [us]"); FWHM->SetMarkerStyle(33); FWHM->SetMarkerColor(kGreen+3); FWHM->SetMarkerSize(1.5); FWHM->SetLineColor(kGreen+3); FWTM->SetMarkerStyle(22); FWTM->SetMarkerColor(kBlue); FWTM->SetMarkerSize(1.5); FWTM->SetLineColor(kBlue); FWFM->SetMarkerStyle(23); FWFM->SetMarkerColor(kRed); FWFM->SetMarkerSize(1.5); FWFM->SetLineColor(kRed); TCanvas * can = new TCanvas("can","can",1); can->Divide(2,1); can->cd(1); gPad->SetGrid(); FWHM->Draw("AP"); FWTM->Draw("PSAME"); FWFM->Draw("PSAME"); TLegend * leg = new TLegend(0.24,0.77,0.42,0.88); leg->SetTextAlign(22); leg->SetTextSize(0.037); leg->AddEntry(FWHM,"FWHM","p"); leg->AddEntry(FWTM,"FWTM","p"); leg->AddEntry(FWFM,"FWFM","p"); leg->Draw(); can->cd(2); gPad->SetGrid(); ratioTH->Draw("AP"); ratioFH->Draw("PSAME"); TLine * lineTH = new TLine( ratioTH->GetXaxis()->GetXmin() , 1.82 , ratioTH->GetXaxis()->GetXmax() , 1.82 ); TLine * lineFH = new TLine( ratioTH->GetXaxis()->GetXmin() , 2.38 , ratioTH->GetXaxis()->GetXmax() , 2.38 ); lineTH->SetLineWidth(2); lineTH->SetLineStyle(9); lineTH->SetLineColor(kViolet+2); lineFH->SetLineWidth(2); lineFH->SetLineStyle(9); lineFH->SetLineColor(kYellow+2); lineTH->Draw(); lineFH->Draw(); TLegend * leg2 = new TLegend(0.14,0.77,0.45,0.88); leg2->SetTextAlign(22); leg2->SetTextSize(0.037); leg2->AddEntry(ratioTH,"FWTM/FWHM","p"); leg2->AddEntry(ratioFH,"FWFM/FWHM","p"); leg2->Draw(); return; }
void DoEvolutions( const TString &sim, Int_t time, Int_t Nbins=1, const TString &options="") { #ifdef __CINT__ gSystem->Load("libptools.so"); #endif PGlobals::Initialize(); // Palettes! gROOT->Macro("PPalettes.C"); TString opt = options; // cout << "options = " << opt << endl; // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; Bool_t CYL = kFALSE; if(sim.Contains("cyl")) { CYL = kTRUE; opt += "cyl"; } Bool_t ThreeD = kFALSE; if(sim.Contains("3D")) ThreeD = kTRUE; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.0; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Some initial beam properties: Float_t Ebeam = pData->GetBeamEnergy() * PUnits::MeV; Float_t gamma = pData->GetBeamGamma(); Float_t vbeam = pData->GetBeamVelocity(); Double_t rms0 = pData->GetBeamRmsY() * kp; if(CYL) rms0 = pData->GetBeamRmsR() * kp; // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart() * kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart() * kp; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } // Beam charge 2D and 1D histogram (on-axis) // ------------------------------------------------------------------ TH2F *hDen2D = NULL; if(pData->GetChargeFileName(1)) { char hName[24]; sprintf(hName,"hDen2D"); hDen2D = (TH2F*) gROOT->FindObject(hName); if(hDen2D) { delete hDen2D; hDen2D = NULL; } if(!ThreeD) hDen2D = pData->GetCharge(1,opt); else hDen2D = pData->GetCharge2DSliceZY(1,-1,1,opt+"avg"); hDen2D->SetName(hName); hDen2D->GetXaxis()->CenterTitle(); hDen2D->GetYaxis()->CenterTitle(); hDen2D->GetZaxis()->CenterTitle(); if(opt.Contains("comov")) hDen2D->GetXaxis()->SetTitle("k_{p}#zeta"); else hDen2D->GetXaxis()->SetTitle("k_{p}z"); if(CYL) hDen2D->GetYaxis()->SetTitle("k_{p}r"); else hDen2D->GetYaxis()->SetTitle("k_{p}y"); hDen2D->GetZaxis()->SetTitle("n_{b}/n_{0}"); } // Define ranges from the charge 2D histogram: // Binning for 2D histograms: // We get this values from the 2D density histogram. Int_t x1Nbin = hDen2D->GetNbinsX(); Float_t x1Range = (hDen2D->GetXaxis()->GetXmax() - hDen2D->GetXaxis()->GetXmin()); Float_t x1Mid = (hDen2D->GetXaxis()->GetXmax() + hDen2D->GetXaxis()->GetXmin())/2.; Float_t x1Min = hDen2D->GetXaxis()->GetXmin(); Float_t x1Max = hDen2D->GetXaxis()->GetXmax(); Int_t x2Nbin = hDen2D->GetNbinsY(); Float_t x2Range = (hDen2D->GetYaxis()->GetXmax() - hDen2D->GetYaxis()->GetXmin()); Float_t x2Mid = (hDen2D->GetYaxis()->GetXmax() + hDen2D->GetYaxis()->GetXmin())/2.; Float_t x2Min = x2Mid - x2Range/2; Float_t x2Max = x2Mid + x2Range/2; if(Nbins==0) { Nbins = TMath::Nint(rms0 / hDen2D->GetYaxis()->GetBinWidth(1)) ; // cout << Form(" Rms0 = %6.2f Dx = %6.2f Nbins = %4i .", // rms0, hDen2D->GetYaxis()->GetBinWidth(1), Nbins) << endl; } // Slice width limits. Int_t FirstyBin = 0; Int_t LastyBin = 0; if(!CYL) { FirstyBin = hDen2D->GetNbinsY()/2 + 1 - Nbins; LastyBin = hDen2D->GetNbinsY()/2 + Nbins; } else { FirstyBin = 1; LastyBin = Nbins; } // OUTPUT ROOT FILE WITH THE PLOTS: TString filename = Form("./%s/Plots/Evolutions/Evolutions-%s.root",sim.Data(),sim.Data()); TFile * ifile = (TFile*) gROOT->GetListOfFiles()->FindObject(filename); // if doesn't exist the directory should be created if (!ifile) { TString f = filename; TString dir2 = f.Remove( f.Last( '/' ), f.Length() - f.Last( '/' ) ); TString dir1 = f.Remove( f.Last( '/' ), f.Length() - f.Last( '/' ) ); gSystem->mkdir( dir1 ); gSystem->mkdir( dir2 ); ifile = new TFile(filename,"UPDATE"); } // Charge 1D histogram on axis TH1F *hDen1D = NULL; if(pData->GetChargeFileName(1)) { TString opth1 = opt; opth1 += "avg"; char hName[24]; sprintf(hName,"hDen1D"); hDen1D = (TH1F*) gROOT->FindObject(hName); if(hDen1D) delete hDen1D; if(ThreeD) { hDen1D = pData->GetH1SliceZ3D(pData->GetChargeFileName(1)->c_str(),"charge",-1,Nbins,-1,Nbins,opth1.Data()); } else if(CYL) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0). hDen1D = pData->GetH1SliceZ(pData->GetChargeFileName(1)->c_str(),"charge",1,Nbins,opth1.Data()); } else { // 2D cartesian hDen1D = pData->GetH1SliceZ(pData->GetChargeFileName(1)->c_str(),"charge",-1,Nbins,opth1.Data()); } hDen1D->SetName(hName); if(opt.Contains("comov")) hDen1D->GetXaxis()->SetTitle("k_{p}#zeta"); else hDen1D->GetXaxis()->SetTitle("k_{p}z"); hDen1D->GetYaxis()->SetTitle("n_{b}/n_{0}"); } // On-axis beam density vs \zeta vs time! _________________________________ TH2F *hDen1DvsTime = NULL; if(hDen1D) { char hName[24]; sprintf(hName,"hDen1DvsTime"); TH2F *hDen1DvsTimeOld = (TH2F*) ifile->Get(hName); Int_t nBins = 1; Float_t edge0 = Time-0.5; Float_t edge1 = Time+0.5; if(hDen1DvsTimeOld!=NULL) { nBins = hDen1DvsTimeOld->GetNbinsX()+1; Float_t binwidth = (Time - hDen1DvsTimeOld->GetXaxis()->GetBinCenter(1))/(nBins-1); edge0 = hDen1DvsTimeOld->GetXaxis()->GetBinCenter(1) - binwidth/2.; edge1 = Time + binwidth/2.; } hDen1DvsTime = new TH2F("temp","",nBins,edge0,edge1, hDen1D->GetNbinsX(), hDen1D->GetBinLowEdge(1), hDen1D->GetBinLowEdge(hDen1D->GetNbinsX()+1)); for(Int_t ix=1;ix<hDen1DvsTime->GetNbinsX();ix++) { for(Int_t iy=1;iy<hDen1DvsTime->GetNbinsY();iy++) { hDen1DvsTime->SetBinContent(ix,iy,hDen1DvsTimeOld->GetBinContent(ix,iy)); } } delete hDen1DvsTimeOld; // Fill last bin with the newest values. for(Int_t iy=1;iy<=hDen1D->GetNbinsX();iy++) { hDen1DvsTime->SetBinContent(nBins,iy,hDen1D->GetBinContent(iy)); } hDen1DvsTime->GetZaxis()->SetTitle("n_{b}/n_{0}"); hDen1DvsTime->GetYaxis()->SetTitle("k_{p}#zeta"); hDen1DvsTime->GetXaxis()->SetTitle("k_{p}z"); hDen1DvsTime->GetZaxis()->CenterTitle(); hDen1DvsTime->GetYaxis()->CenterTitle(); hDen1DvsTime->GetXaxis()->CenterTitle(); hDen1DvsTime->SetName(hName); // Change the range of z axis Float_t Denmax = hDen1DvsTime->GetMaximum(); hDen1DvsTime->GetZaxis()->SetRangeUser(0,Denmax); hDen1DvsTime->Write(hName,TObject::kOverwrite); } // RMS (vs z) of the beam's charge distribution: TProfile *hDen2Dprof = NULL; TH1F *hRms = NULL; Double_t axisPos = x2Mid; if(hDen2D) { TString pname = hDen2D->GetName(); pname += "_pfx"; hDen2Dprof = (TProfile*) gROOT->FindObject(pname.Data()); if(hDen2Dprof) { delete hDen2Dprof; hDen2Dprof = NULL; } hDen2Dprof = hDen2D->ProfileX("_pfx",1,-1,"s"); hRms = (TH1F*) gROOT->FindObject("hRms"); if(hRms) delete hRms; hRms = new TH1F("hRms","",x1Nbin,x1Min,x1Max); if(CYL) axisPos = 0.0; for(Int_t j=0;j<hRms->GetNbinsX();j++) { Double_t rms = 0; Double_t total = 0; for(Int_t k=1;k<=x2Nbin;k++) { Double_t value = hDen2D->GetBinContent(j,k); Double_t radius = hDen2D->GetYaxis()->GetBinCenter(k) - axisPos; if(CYL) { rms += radius*radius*radius*value; total += radius*value; } else { rms += radius*radius*value; total += value; } // cout << Form(" (%i,%i) -> radius = %7.4f , density = %7.4f",j,k,radius,value) << endl; } rms /= total; rms = sqrt(rms); hRms->SetBinContent(j,rms); } hRms->GetXaxis()->SetTitle("k_{p}z"); if(opt.Contains("comov")) hRms->GetXaxis()->SetTitle("k_{p}#zeta"); hRms->GetYaxis()->SetTitle("k_{p}#LTr#GT_{rms}"); } // Transverse charge RMS vs \zeta vs time! _________________________________ TH2F *hRmsvsTime = NULL; if(hRms) { char hName[24]; sprintf(hName,"hRmsvsTime"); TH2F *hRmsvsTimeOld = (TH2F*) ifile->Get(hName); Int_t nBins = 1; Float_t edge0 = Time-0.5; Float_t edge1 = Time+0.5; if(hRmsvsTimeOld!=NULL) { nBins = hRmsvsTimeOld->GetNbinsX()+1; Float_t binwidth = (Time - hRmsvsTimeOld->GetXaxis()->GetBinCenter(1))/(nBins-1); edge0 = hRmsvsTimeOld->GetXaxis()->GetBinCenter(1) - binwidth/2.; edge1 = Time + binwidth/2.; } hRmsvsTime = new TH2F("temp","",nBins,edge0,edge1, hRms->GetNbinsX(), hRms->GetBinLowEdge(1), hRms->GetBinLowEdge(hRms->GetNbinsX()+1)); for(Int_t ix=1;ix<hRmsvsTime->GetNbinsX();ix++) { for(Int_t iy=1;iy<hRmsvsTime->GetNbinsY();iy++) { hRmsvsTime->SetBinContent(ix,iy,hRmsvsTimeOld->GetBinContent(ix,iy)); } } delete hRmsvsTimeOld; // Fill last bin with the newest values. for(Int_t iy=1;iy<=hRms->GetNbinsX();iy++) { hRmsvsTime->SetBinContent(nBins,iy,hRms->GetBinContent(iy)); } hRmsvsTime->GetZaxis()->SetTitle("#LTr#GT_{rms}"); hRmsvsTime->GetYaxis()->SetTitle("k_{p}#zeta"); hRmsvsTime->GetXaxis()->SetTitle("k_{p}z"); hRmsvsTime->GetZaxis()->CenterTitle(); hRmsvsTime->GetYaxis()->CenterTitle(); hRmsvsTime->GetXaxis()->CenterTitle(); hRmsvsTime->SetName(hName); // Change the range of z axis Float_t Rmsmax = hRmsvsTime->GetMaximum(); hRmsvsTime->GetZaxis()->SetRangeUser(0,Rmsmax); hRmsvsTime->Write(hName,TObject::kOverwrite); } // INTEGRATED Beam's Charge: // Total charge vs time : TGraph *gQvsTime = NULL; if(hDen2D) { Double_t Q = 0; for(Int_t i=1;i<=x1Nbin;i++) { for(Int_t j=1;j<=x2Nbin;j++) { Double_t value = hDen2D->GetBinContent(i,j); if(CYL) { Double_t radius = hDen2D->GetYaxis()->GetBinCenter(j); Q += radius * value; // cout << Form(" (%i,%i) -> radius = %7.4f , value = %7.4f",i,j,radius,value) << endl; } else { Q += value; } } } Double_t xbinsize = hDen2D->GetXaxis()->GetBinWidth(1); Double_t ybinsize = hDen2D->GetYaxis()->GetBinWidth(1); Q *= xbinsize * ybinsize; if(!CYL && !ThreeD) { Q *= TMath::Sqrt(2*TMath::Pi()) * rms0; } else if(CYL) { Q *= 2*TMath::Pi(); } if(opt.Contains("units")) { Double_t dV = skindepth * skindepth * skindepth; Q *= n0 * dV; Q *= (PConst::ElectronCharge/PUnits::picocoulomb); cout << Form(" Integrated charge = %8i pC", TMath::Nint(Q)) << endl; } else { cout << Form(" Integrated charge = %8.4f n0 * kp^-3",Q) << endl; } Int_t nPoints = 0; char gName[32]; sprintf(gName,"gQvsTime"); gQvsTime = (TGraph*) ifile->Get(gName); if(gQvsTime==NULL) { gQvsTime = new TGraph(); gQvsTime->SetName(gName); nPoints = 0; // Some cosmetics at creation time: gQvsTime->SetLineWidth(3); gQvsTime->SetLineColor(PGlobals::fieldLine); gQvsTime->SetMarkerStyle(20); gQvsTime->SetMarkerSize(0.4); gQvsTime->SetMarkerColor(PGlobals::fieldLine); gQvsTime->GetYaxis()->SetTitle("charge [n_{0}/k_{p}^{3}]"); gQvsTime->GetXaxis()->SetTitle("k_{p}z"); } else { nPoints = gQvsTime->GetN(); } gQvsTime->Set(nPoints+1); gQvsTime->SetPoint(nPoints,Time,Q); gQvsTime->Write(gName,TObject::kOverwrite); } // ------------------------------------------------------------------------------------ // Longitudinal phasespace Int_t gNbin = 100; // Float_t gMin = 80; // Float_t gMax = 120; Float_t gMin = 43.07 - 1.2; Float_t gMax = 43.07 + 1.2; TH2F *hGvsZ = NULL; if(pData->GetRawFileName(1)) { char hName[24]; sprintf(hName,"hGvsZ"); hGvsZ = (TH2F*) gROOT->FindObject(hName); if(hGvsZ) { delete hGvsZ; hGvsZ = NULL; } hGvsZ = new TH2F(hName,"",x1Nbin,x1Min,x1Max,gNbin,gMin,gMax); pData->GetH2Raw(pData->GetRawFileName(1)->c_str(),"x1","gamma",hGvsZ,opt); hGvsZ->GetXaxis()->CenterTitle(); hGvsZ->GetYaxis()->CenterTitle(); hGvsZ->GetZaxis()->CenterTitle(); hGvsZ->GetYaxis()->SetTitle("#gamma"); if(opt.Contains("comov")) { hGvsZ->GetXaxis()->SetTitle("k_{p}#zeta"); hGvsZ->GetZaxis()->SetTitle("dN/d#zetad#gamma [a.u.]"); } else { hGvsZ->GetXaxis()->SetTitle("k_{p}z"); hGvsZ->GetZaxis()->SetTitle("dN/dzd#gamma [a.u.]"); } } else { cout << Form("--> No RAW data file is present for species 1") << endl; } TH2F *hGvsTime = NULL; TProfile *hGvsZprof = NULL; TGraphErrors *gGvsZ = NULL; if(hGvsZ) { TString pname = hGvsZ->GetName(); pname += "_pfx"; hGvsZprof = (TProfile*) gROOT->FindObject(pname.Data()); if(hGvsZprof) delete hGvsZprof; hGvsZprof = hGvsZ->ProfileX("_pfx",1,-1,"s"); gGvsZ = (TGraphErrors*) gROOT->FindObject("gGvsZ"); if(gGvsZ) delete gGvsZ; Int_t Npoints = hGvsZprof->GetNbinsX(); Double_t *x = new Double_t[Npoints]; Double_t *y = new Double_t[Npoints]; Double_t *ex = new Double_t[Npoints]; Double_t *ey = new Double_t[Npoints]; for(Int_t j=0;j<Npoints;j++) { x[j] = hGvsZprof->GetBinCenter(j); y[j] = hGvsZprof->GetBinContent(j); ex[j] = 0; ey[j] = hGvsZprof->GetBinError(j); } gGvsZ = new TGraphErrors(Npoints,x,y,ex,ey); gGvsZ->SetName("gGvsZ"); // PGlobals::SetH1Style((TH1*)gGvsZ,1); PGlobals::SetGraphStyle(gGvsZ,1); if(opt.Contains("comov")) gGvsZ->GetXaxis()->SetTitle("k_{p}#zeta"); else gGvsZ->GetXaxis()->SetTitle("k_{p}z"); gGvsZ->GetYaxis()->SetTitle("#LT#gamma#GT [MeV]"); char hName[24]; sprintf(hName,"hGvsTime"); TH2F *hGvsTimeOld = (TH2F*) ifile->Get(hName); Int_t nBins = 1; Float_t edge0 = Time-0.5; Float_t edge1 = Time+0.5; if(hGvsTimeOld!=NULL) { nBins = hGvsTimeOld->GetNbinsX()+1; Float_t binwidth = (Time - hGvsTimeOld->GetXaxis()->GetBinCenter(1))/(nBins-1); edge0 = hGvsTimeOld->GetXaxis()->GetBinCenter(1) - binwidth/2.; edge1 = Time + binwidth/2.; } hGvsTime = new TH2F("temp","",nBins,edge0,edge1, hGvsZprof->GetNbinsX(), hGvsZprof->GetBinLowEdge(1), hGvsZprof->GetBinLowEdge(hGvsZprof->GetNbinsX()+1)); for(Int_t ix=1;ix<hGvsTime->GetNbinsX();ix++) { for(Int_t iy=1;iy<hGvsTime->GetNbinsY();iy++) { hGvsTime->SetBinContent(ix,iy,hGvsTimeOld->GetBinContent(ix,iy)); } } delete hGvsTimeOld; // Fill last bin with the newest values. for(Int_t iy=1;iy<=hGvsZprof->GetNbinsX();iy++) { hGvsTime->SetBinContent(nBins,iy,hGvsZprof->GetBinContent(iy)); } hGvsTime->GetZaxis()->SetTitle("#LT#gamma#GT"); hGvsTime->GetYaxis()->SetTitle("k_{p}#zeta"); hGvsTime->GetXaxis()->SetTitle("k_{p}z"); hGvsTime->GetZaxis()->CenterTitle(); hGvsTime->GetYaxis()->CenterTitle(); hGvsTime->GetXaxis()->CenterTitle(); hGvsTime->SetName(hName); // Change the range of z axis Float_t Gmax = hGvsTime->GetMaximum(); Float_t Gmin = hGvsTime->GetMinimum(); hGvsTime->GetZaxis()->SetRangeUser(Gmin,Gmax); hGvsTime->Write(hName,TObject::kOverwrite); } // --------------------------------------------------------------------------------- // EM fields on - axis : TString opth1 = opt; opth1 += "avg"; // Get electric fields const Int_t Nfields = 2; TH1F **hE1D = new TH1F*[Nfields]; for(Int_t i=0;i<Nfields;i++) { hE1D[i] = NULL; if(!pData->GetEfieldFileName(i)) continue; char nam[3]; sprintf(nam,"e%i",i+1); if(ThreeD) { if(i==0) hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,-1,Nbins,opth1.Data()); else hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,-Nbins,Nbins,opth1.Data()); } else if(CYL) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0). if(i==0) hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,1,Nbins,opth1.Data()); else hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,1,Nbins,opth1.Data()); } else { // 2D cartesian if(i==0) hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,opth1.Data()); else hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,opth1.Data()); } char hName[24]; sprintf(hName,"hE_%i_%i",i,time); hE1D[i]->SetName(hName); if(opt.Contains("comov")) hE1D[i]->GetXaxis()->SetTitle("k_{p}#zeta"); else hE1D[i]->GetXaxis()->SetTitle("k_{p}z"); if(i==0) hE1D[i]->GetYaxis()->SetTitle("E_{z}/E_{0}"); else if(i==1) hE1D[i]->GetYaxis()->SetTitle("E_{y}/E_{0}"); else if(i==2) hE1D[i]->GetYaxis()->SetTitle("E_{x}/E_{0}"); hE1D[i]->GetYaxis()->CenterTitle(); hE1D[i]->GetXaxis()->CenterTitle(); } // Calculate wave positions: // ---------------------------------------------------------------- // Calculate the crossings and the extremes of the Electric fields Float_t Ecross[Nfields][100] = {{0.0}}; Float_t Eextr[Nfields][100] = {{0.0}}; Int_t Ncross[Nfields] = {0}; for(Int_t i=0;i<Nfields;i++) { Ncross[i] = 0; if(!hE1D[i]) continue; // Only smooths the focusing if flag activated.. if(i>0 && opt.Contains("smooth")) { // cout << " Smoothing fields on axis..." << endl; hE1D[i]->Smooth(10); } Float_t maxZeta = zStartBeam; if(opt.Contains("center")) maxZeta -= zStartBeam; for(Int_t ip=hE1D[i]->GetNbinsX();ip>1;ip--) { Float_t Z2 = hE1D[i]->GetBinCenter(ip-1); if(Z2 > maxZeta) continue; Float_t E1 = hE1D[i]->GetBinContent(ip); Float_t E2 = hE1D[i]->GetBinContent(ip-1); Float_t Z1 = hE1D[i]->GetBinCenter(ip); // cout << Form("Z1 = %6.4f Z2 = %6.4f E1 = %6.4f E2 = %6.4f", Z1, Z2, E1, E2) << endl; if(E1*E2 >= 0) { // No change of sign means we are in a side of the zero axis. if(fabs(E2)>fabs(Eextr[i][Ncross[i]])) { Eextr[i][Ncross[i]] = E2; } } if(E1*E2 < 0) { // change of sign means a crossing! // The next crossing has to be far enough from the previous one: Float_t zcross = -E1 * ( (Z2-Z1)/(E2-E1) ) + Z1; if(Ncross[i]>0 && fabs(Ecross[i][Ncross[i]-1]-zcross)<TMath::PiOver2() ) continue; // cout << " CROSS! " << endl; // add the point Ecross[i][Ncross[i]] = zcross; Ncross[i]++; } } cout << " -> Number of crossings for field " << i << " : " << Ncross[i] << endl; for(Int_t ic=0;ic<Ncross[i];ic++) { // cout << Form(" %2i: zeta = %6.4f E = %6.4f", ic, Ecross[i][ic], Eextr[i][ic]) << endl; } hE1D[i]->SetLineColor(kRed); hE1D[i]->Write(hE1D[i]->GetName(),TObject::kOverwrite); } // Get the Graphs and histos from file Int_t nPoints = 0; TGraph ***gEcross = new TGraph**[Nfields]; TGraph ***gEextr = new TGraph**[Nfields]; TH2F **hEvsTime = new TH2F*[Nfields]; for(Int_t i=0;i<Nfields;i++) { char hName[24]; sprintf(hName,"hEvsTime_%i",i); TH2F *hEvsTimeOld = (TH2F*) ifile->Get(hName); Int_t nBins = 1; Float_t edge0 = Time-0.5; Float_t edge1 = Time+0.5; if(hEvsTimeOld!=NULL) { nBins = hEvsTimeOld->GetNbinsX()+1; Float_t binwidth = (Time - hEvsTimeOld->GetXaxis()->GetBinCenter(1))/(nBins-1); edge0 = hEvsTimeOld->GetXaxis()->GetBinCenter(1) - binwidth/2.; edge1 = Time + binwidth/2.; } hEvsTime[i] = new TH2F("temp","",nBins,edge0,edge1, hE1D[i]->GetNbinsX(), hE1D[i]->GetBinLowEdge(1), hE1D[i]->GetBinLowEdge(hE1D[i]->GetNbinsX()+1)); for(Int_t ix=1;ix<hEvsTime[i]->GetNbinsX();ix++) { for(Int_t iy=1;iy<hEvsTime[i]->GetNbinsY();iy++) { hEvsTime[i]->SetBinContent(ix,iy,hEvsTimeOld->GetBinContent(ix,iy)); } } delete hEvsTimeOld; // Fill last bin with the newest values. for(Int_t iy=1;iy<=hE1D[i]->GetNbinsX();iy++) { hEvsTime[i]->SetBinContent(nBins,iy,hE1D[i]->GetBinContent(iy)); } if(i==0) hEvsTime[i]->GetZaxis()->SetTitle("E_{z}/E_{0}"); else if(i==1) hEvsTime[i]->GetZaxis()->SetTitle("E_{y}/E_{0}"); else if(i==2) hEvsTime[i]->GetZaxis()->SetTitle("E_{x}/E_{0}"); hEvsTime[i]->GetYaxis()->SetTitle("k_{p}#zeta"); hEvsTime[i]->GetXaxis()->SetTitle("k_{p}z"); hEvsTime[i]->GetZaxis()->CenterTitle(); hEvsTime[i]->GetYaxis()->CenterTitle(); hEvsTime[i]->GetXaxis()->CenterTitle(); hEvsTime[i]->SetName(hName); // Change the range of z axis for the fields to be symmetric. Float_t Emax = hEvsTime[i]->GetMaximum(); Float_t Emin = hEvsTime[i]->GetMinimum(); if(Emax > TMath::Abs(Emin)) Emin = -Emax; else Emax = -Emin; hEvsTime[i]->GetZaxis()->SetRangeUser(Emin,Emax); hEvsTime[i]->Write(hName,TObject::kOverwrite); // --- gEcross[i] = new TGraph*[Ncross[i]]; gEextr[i] = new TGraph*[Ncross[i]]; char gName[24]; Int_t ifail = 0; for(Int_t ic=0;ic<Ncross[i];ic++) { sprintf(gName,"gEcross_%i_%i",i,ic); gEcross[i][ic] = (TGraph*) ifile->Get(gName); if(gEcross[i][ic]==NULL) { gEcross[i][ic] = new TGraph(); gEcross[i][ic]->SetName(gName); nPoints = 0; // Some cosmetics at creation time: if(i==1) gEcross[i][ic]->SetLineStyle(2); else gEcross[i][ic]->SetLineStyle(1); gEcross[i][ic]->SetLineWidth(1); gEcross[i][ic]->SetLineColor(kGray+1); gEcross[i][ic]->SetMarkerStyle(20); gEcross[i][ic]->SetMarkerSize(0.4); gEcross[i][ic]->SetMarkerColor(kGray+1); gEcross[i][ic]->GetYaxis()->SetTitle("k_{p}#zeta]"); gEcross[i][ic]->GetXaxis()->SetTitle("k_{p}z"); } else { nPoints = gEcross[i][ic]->GetN(); } // Check the new crossings respect the previous ones: // Double_t t,zeta; // if(nPoints>0) { // gEcross[i][ic]->GetPoint(nPoints-1,t,zeta); // if(fabs(zeta-Ecross[i][ic+ifail])>TMath::Pi()) { // ic--; // ifail++; // continue; // } // } gEcross[i][ic]->Set(nPoints+1); gEcross[i][ic]->SetPoint(nPoints,Time,Ecross[i][ic+ifail]); gEcross[i][ic]->Write(gName,TObject::kOverwrite); // if(ic==Ncross[i]-1) continue; sprintf(gName,"gEextr_%i_%i",i,ic); gEextr[i][ic] = (TGraph*) ifile->Get(gName); if(gEextr[i][ic]==NULL) { gEextr[i][ic] = new TGraph(); gEextr[i][ic]->SetName(gName); nPoints = 0; // Some cosmetics at creation time: if(i==0) { gEextr[i][ic]->SetLineWidth(3); gEextr[i][ic]->SetLineColor(PGlobals::fieldLine); gEextr[i][ic]->SetMarkerStyle(20); gEextr[i][ic]->SetMarkerSize(0.4); gEextr[i][ic]->SetMarkerColor(PGlobals::fieldLine); gEextr[i][ic]->GetYaxis()->SetTitle("E_{z}/E_{0}"); gEextr[i][ic]->GetXaxis()->SetTitle("k_{p}z"); } else if(i==1) { gEextr[i][ic]->SetLineWidth(1); gEextr[i][ic]->SetLineColor(kGray+2); gEextr[i][ic]->SetMarkerStyle(20); gEextr[i][ic]->SetMarkerSize(0.4); gEextr[i][ic]->SetMarkerColor(kGray+2); gEextr[i][ic]->GetYaxis()->SetTitle("E_{y}/E_{0}"); gEextr[i][ic]->GetXaxis()->SetTitle("k_{p}z"); } } else { nPoints = gEextr[i][ic]->GetN(); } gEextr[i][ic]->Set(nPoints+1); gEextr[i][ic]->SetPoint(nPoints,Time,Eextr[i][ic]); gEextr[i][ic]->Write(gName,TObject::kOverwrite); } } ifile->Close(); }
void plotVBTFWP(const string tau_ = "HPS"){ TCanvas *c1 = new TCanvas("c1","Canvas",10,30,650,600); c1->SetGrid(0,0); c1->SetFillStyle(4000); c1->SetFillColor(10); c1->SetTicky(); c1->SetObjectStat(0); c1->SetLogx(1); TLegend* leg = new TLegend(0.36,0.15,0.80,0.5,NULL,"brNDC"); leg->SetFillStyle(4000); leg->SetBorderSize(0); leg->SetFillColor(10); leg->SetTextSize(0.03); TFile* f_Zee = new TFile("/data_CMS/cms/lbianchini/35pb/testNewWriteFromPAT_DYToEE-PYTHIA-TAUEFF.root"); TFile* f_Ztautau = new TFile("/data_CMS/cms/lbianchini/35pb/testNewWriteFromPAT_DYToTauTau-PYTHIA-TAUEFF.root"); f_Zee->cd(); TTree* tree_Zee = (TTree*) gDirectory->Get( ("tauFakeRateAnalyzer"+tau_+"/tree").c_str() ); f_Ztautau->cd(); TTree* tree_Ztautau = (TTree*) gDirectory->Get( ("tauFakeRateAnalyzer"+tau_+"/tree").c_str() ); TH2F* h2 = new TH2F("h2","",220,0,1.1,220,0,1.1); float vxF[45]; float vyF[45]; float vxF_VBTF[6]; float vyF_VBTF[6]; float ZeeAll = (float)tree_Zee->GetEntries(""); float ZtautauAll = (float)tree_Ztautau->GetEntries(""); std::cout << ZtautauAll << std::endl; for(int i = 0; i<=44; i++){ float cut = 0.025*i; float ZeeCut = (float) tree_Zee->GetEntries(Form("leadPFChargedHadrMva<=%f",-0.1+cut)); float ZtautauCut = (float) tree_Ztautau->GetEntries(Form("leadPFChargedHadrMva<=%f",-0.1+cut)); std::cout << ZtautauCut << std::endl; vxF[i]=ZeeCut/ZeeAll; vyF[i]=ZtautauCut/ZtautauAll; //h2->Fill(ZeeCut/ZeeAll,ZtautauCut/ZtautauAll); std::cout << Form("leadPFChargedHadrMva<=%f: ",-0.1+cut) <<ZeeCut/ZeeAll << " --- " << ZtautauCut/ZtautauAll << std::endl; } h2->SetXTitle("e#rightarrow #tau_{had} fake-rate"); h2->SetYTitle("#tau_{had} efficiency"); h2->SetAxisRange(0.02,1.0,"X"); h2->SetAxisRange(0.95,1.01,"Y"); h2->Draw(); float ids[] = {1.0,.95,.90,.85,.80,.70,.60}; for(int i = 0; i<6; i++){ float ZeeCut_i = (float) tree_Zee->GetEntries( Form("matchedID>%f",ids[i]-0.025)); float ZtautauCut_i = (float) tree_Ztautau->GetEntries(Form("matchedID>%f",ids[i]-0.025)); vxF_VBTF[i]=ZeeCut_i/ZeeAll; vyF_VBTF[i]=ZtautauCut_i/ZtautauAll; std::cout << Form("matchedID>%f",ids[i]-0.025) << " " << ZeeCut_i/ZeeAll << " <-- VBTF Zee ---- VBTF Ztautau ---> " << ZtautauCut_i/ZtautauAll << std::endl; } TVectorF vx_VBTF(6,vxF_VBTF); TVectorF vy_VBTF(6,vyF_VBTF); TVectorF vx(45,vxF); TVectorF vy(45,vyF); TGraph* graph = new TGraph(vx,vy); TGraph* graph_VBTF = new TGraph(vx_VBTF,vy_VBTF); if( tau_.find("HPS")!=string::npos) graph->SetMarkerStyle(kOpenCircle); else graph->SetMarkerStyle(kOpenSquare); graph->SetMarkerSize(1.2); if( tau_.find("HPS")!=string::npos) graph->SetMarkerColor(kRed); else graph->SetMarkerColor(kBlue); graph_VBTF->SetMarkerStyle(kFullStar); graph_VBTF->SetMarkerSize(1.8); graph_VBTF->SetMarkerColor(kBlack); graph->Draw("P"); graph_VBTF->Draw("P"); string tau = tau_.find("HPS")!=string::npos ? "HPS" : "Shrinking Cone"; leg->SetHeader( ("#splitline{Simulation: "+tau+" #tau_{had}-candidates}{passing tau-ID and loose isolation}").c_str() ); leg->AddEntry(graph,"#splitline{discriminator by #xi^{lch}}{-0.1#leq #xi^{lch}_{cut} #leq1.0}","P"); leg->AddEntry(graph_VBTF,"#splitline{cut-based discriminator}{WP95,90,85,80,70,60 (ID-only)}","P"); leg->Draw(); }
void errftest() { gSystem->Load("libRooFitCore.so"); gSystem->Load("libRooFitModels.so"); // Define some free parameters to use Double_t t = 2; Double_t t0 = 1.51; Double_t dm = 0.51; Double_t s = 0.5; Double_t tag = 1; //Define the timers Double_t timer1R[20]=0; Double_t timer1C[20]=0; Double_t timer2R[20]=0; Double_t timer2C[20]=0; Double_t xi[20]=0; //Declare everything so we don't have to redeclare in loop Double_t tcompare,aa,bb,cc,evilterm1,evilterm2,wzreneg1,wzreneg2,func1,func2; Complex_t wz1; RooComplex wz2; //loop over t for (Int_t ij = 0.; ij<20; ij++){ // do the test!!! //complexmath calculation TStopwatch *time1 = new TStopwatch(); time1.Start(); for(Int_t n = 0.; n<50; n++){ t = -4 + 0.36*n; aa = (t/(TMath::Sqrt(2.)*s)) - (s/(TMath::Sqrt(2.)*t0)); bb = (s*s/(2.*t0*t0)) - t/t0; cc = s*dm/(TMath::Sqrt(2.)); if(t >= tcompare){ evilterm1=TMath::Exp(-(cc*cc))*2*TMath::Cos(2*aa*cc); evilterm2=TMath::Exp(-(cc*cc))*2*TMath::Cos(2*aa*cc); }else if(t<= -tcompare){ evilterm1=0; evilterm2=0; }else{ wz1 = cxerf(cc,-aa); wzreneg1 = re(wz1); evilterm1=TMath::Exp(-(aa*aa))*wzreneg1; func1 = 1./(2.*t0)*TMath::Exp(bb)*( 1 + TMath::Erf(aa) - tag*evilterm1 ); } } time1.Stop(); timer1R[ij] = time1.RealTime(); timer1C[ij] = time1.CpuTime(); //roomath calculation TStopwatch *time2 = new TStopwatch(); time2.Start(); for(Int_t n = 0.; n<50; n++){ t = -4 + 0.36*n; aa = (t/(TMath::Sqrt(2.)*s)) - (s/(TMath::Sqrt(2.)*t0)); bb = (s*s/(2.*t0*t0)) - t/t0; cc = s*dm/(TMath::Sqrt(2.)); if(t >= tcompare){ evilterm1=TMath::Exp(-(cc*cc))*2*TMath::Cos(2*aa*cc); evilterm2=TMath::Exp(-(cc*cc))*2*TMath::Cos(2*aa*cc); }else if(t<= -tcompare){ evilterm1=0; evilterm2=0; }else{ wz2 = RooMath::ComplexErrFunc(cc,-aa); wzreneg2 = wz2.re(); evilterm2=TMath::Exp(-(aa*aa))*wzreneg2; func2 = 1./(2.*t0)*TMath::Exp(bb)*( 1 + TMath::Erf(aa) - tag*evilterm2 ); } } time2.Stop(); timer2R[ij] = time2.RealTime(); timer2C[ij] = time2.CpuTime(); xi[ij]=ij; } gROOT->SetStyle("Plain"); TCanvas *realtime = new TCanvas("realtime", "realtime_compare", 500,500); realtime->SetGrid(); TGraph *complextestRT = new TGraph(20,xi,timer1R); complextestRT->SetName("complextest-RT"); complextestRT->SetTitle("Complexmath Test: Real Time"); complextestRT->SetMarkerStyle(30); complextestRT->SetMarkerSize(2); complextestRT->Draw("ALP"); TGraph *roofittestRT = new TGraph(20,xi,timer2R); roofittestRT->SetName("roofittest-RT"); roofittestRT->SetMarkerStyle(29); roofittestRT->SetMarkerSize(1); roofittestRT->SetMarkerColor(4); roofittestRT->Draw("LP"); TCanvas *cputime = new TCanvas("cputime", "cputime_compare", 500,500); cputime->SetGrid(); TGraph *complextestCT = new TGraph(20,xi,timer1C); complextestCT->SetName("complextest-CT"); complextestCT->SetTitle("Complexmath Test: CPU Time"); complextestCT->SetMarkerStyle(30); complextestCT->SetMarkerSize(2); complextestCT->Draw("ALP"); TGraph *roofittestCT = new TGraph(20,xi,timer2C); roofittestCT->SetName("roofittest-CT"); roofittestCT->SetMarkerStyle(29); roofittestCT->SetMarkerSize(1); roofittestCT->SetMarkerColor(4); roofittestCT->Draw("LP"); }
void V_t_continuous_grp7() { TCanvas *c1 = new TCanvas("c1", "Vxt", 800, 600); TGraph *gr; //TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500); c1->SetFillColor(42); c1->SetGrid(); const Int_t n = 20; Double_t x[n], y[n]; //10 for -5 to +5V, 1 to -500mV to + 500 mV, 100 to -50 mv to + 50 mV int scale = 1; char FileName[200]; char ErrFile[200]; char Command[300]; //string err; // Sweep timer: time_t start; bool started; while(1) { //Need to be fixed to use the driver example program we adapted //sprintf(Command,"./fald-acq -a 400000 -b 0 -n 1 -l 1 -g 1 -e -t 10 0100 > Data.txt"); sprintf(FileName,"%s/Data.txt",gSystem->pwd()); sprintf(ErrFile,"%s/Err.txt",gSystem->pwd()); gSystem->Exec("echo 0 > /sys/devices/hw-adc-100m14b-0100/adc-100m14b-0100/enable"); gSystem->Exec("echo 1 > /sys/devices/hw-adc-100m14b-0100/adc-100m14b-0100/enable"); //sleep(1); //system("program args 1>/tmp/program.stdout 2>/tmp/program.stderr as in //http://docstore.mik.ua/orelly/perl/cookbook/ch16_08.htm //sprintf(Command,"%s/fald-acq -a 1000 -b 0 -n 1 -l 1 -g 1 -e -r 10 0100 1> %s 2> %s",gSystem->pwd(), FileName,ErrFile ); //sprintf(Command,"./fald-acq -a 100 -b 0 -n 1 -l 1 -g 1 -c 1 -t 10000 -r 10 0100 > %s",FileName); //sprintf(Command,"%s/fald-acq -a 1000 -b 0 -n 1 -l 1 -g 1 -e -r 10 0100",gSystem->pwd()); //gSystem->Exec(Command); sprintf(Command,"%s/fald-acq -a 500 -b 0 -n 1 -l 1 -g 1 -e -r 1 0100 1> %s 2> %s",gSystem->pwd(), FileName,ErrFile ); FILE *test = gSystem->OpenPipe(Command,"r"); gSystem->ClosePipe(test); //gr = new TGraph("/tmp/fmcadc.0x0100.ch1.dat", "%lg %lg %*lg %*lg %*lg"); //gSystem->Sleep(100); //if (TFile::SizeOf(FileName)<=0) break; //cin >> err; //cout << err << endl; //strcmp(err,"./fald-acq: cannot start acquisition: Input/output error"); //cout <<"running" <<endl; //cout << "TGraph *G1 = new TGraph(FileName = " << FileName << ") , loop i = " << i << endl; //See the columns configuration in FileName gr = new TGraph("/tmp/fmcadc.0x0100.ch1.dat", "%lg %lg"); //c1->cd(); // Get very first point of graph: #define THRESHOLD 0.1 Double_t sample, value1, value2; gr->GetPoint(0,sample,value1); gr->GetPoint(3,sample,value2); if(value1 < 0 && value2 > 0) { std::cout << "Triggered!" << std::endl; if(!started) { // FIXME: use nicer timing function! start = time(NULL); started = true; } else { double diff = time(NULL) - start; started = false; std::cout << "dT: " << diff << " / " << (1/diff) << "Hz" << std::endl; } } gSystem->ProcessEvents(); //TGraph *G2 = new TGraph(); //cout <<"2" <<endl; gr->SetLineColor(2); gr->SetLineWidth(4); gr->SetMarkerColor(4); gr->SetMarkerStyle(21); //cout <<"a simple graph" <<endl; gr->SetTitle("Vxt"); gr->GetXaxis()->SetTitle("time sample"); gr->GetYaxis()->SetTitle("Volts"); //cout <<"3" <<endl; gr->Draw("ACP"); gSystem->ProcessEvents(); //cout << "Draw" << endl; //cout <<"4" <<endl; // TCanvas::Update() draws the frame, after which one can change it c1->Update(); c1->GetFrame()->SetFillColor(21); c1->GetFrame()->SetBorderSize(12); c1->Modified(); //cout <<"5" <<endl; gSystem->ProcessEvents(); } //gr = new TGraph(n,x,y); delete gr; cout << "Bye" << endl; delete c1; // return; }
void showGraphs(double canvasSizeX, double canvasSizeY, const std::vector<std::string>& entriesToPlot, std::map<std::string, TGraph*>& graphs, std::map<std::string, std::string>& legendEntries, int colors[], int lineWidths[], int lineStyles[], double legendTextSize, double legendPosX, double legendPosY, double legendSizeX, double legendSizeY, double xMin, double xMax, const std::string& xAxisTitle, double xAxisOffset, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, const std::string& outputFileName) { TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetLeftMargin(0.14); canvas->SetBottomMargin(0.12); TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", 100, xMin, xMax); dummyHistogram->SetTitle(""); dummyHistogram->SetStats(false); dummyHistogram->SetMinimum(yMin); dummyHistogram->SetMaximum(yMax); TAxis* xAxis = dummyHistogram->GetXaxis(); xAxis->SetTitle(xAxisTitle.data()); xAxis->SetTitleSize(0.045); xAxis->SetTitleOffset(xAxisOffset); TAxis* yAxis = dummyHistogram->GetYaxis(); yAxis->SetTitle(yAxisTitle.data()); yAxis->SetTitleSize(0.045); yAxis->SetTitleOffset(yAxisOffset); dummyHistogram->Draw("axis"); TLegend* legend = new TLegend(legendPosX, legendPosY, legendPosX + legendSizeX, legendPosY + legendSizeY, "", "brNDC"); legend->SetBorderSize(0); legend->SetFillColor(0); legend->SetTextSize(legendTextSize); size_t numEntriesToPlot = entriesToPlot.size(); for ( size_t iEntryToPlot = 0; iEntryToPlot < numEntriesToPlot; ++iEntryToPlot ) { const std::string& entryToPlot = entriesToPlot[iEntryToPlot]; TGraph* graph = graphs[entryToPlot]; assert(graph); graph->SetLineColor(colors[iEntryToPlot]); graph->SetLineWidth(lineWidths[iEntryToPlot]); graph->SetLineStyle(lineStyles[iEntryToPlot]); graph->SetMarkerColor(colors[iEntryToPlot]); graph->Draw("L"); legend->AddEntry(graph, legendEntries[entryToPlot].data(), "l"); } legend->Draw(); canvas->Update(); std::string outputFileName_plot = "plots/"; size_t idx = outputFileName.find_last_of('.'); outputFileName_plot.append(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; }
void fit(){ //int NumberOfLines(); string input_name; cout << "Archivo de datos sin extension \n"; cin >> input_name; //const char *input_name = "para_grafica"; string name = input_name+".txt"; cout << name; ifstream file(name.c_str()); if (!file) { cout << "Archivo no encontado \n"; } else{ int N_Lines = NumberOfLines(file); printf("Number of lines: %i \n", N_Lines); int j = 0; float t, P; //int LinesCont = NumberOfLines(archivo); TVectorD X(N_Lines+1); TVectorD Y(N_Lines+1); while (!file.eof()){ file >> t >> P; //printf("%i, %f, %f \n", j, t, P); //getchar(); X(j) = t; Y(j) = P; ++j; } TCanvas *Grafico = new TCanvas("Grafico", "Grafico de P contra t", 200, 10, 700, 500); TGraph *gr = new TGraph(X,Y); TF1 *f = new TF1 ("fit", FitFunction, 20, 3000, 2); f -> SetParameters(700, 0.5); f -> SetParNames("PresionControl", "VelocidadEfectiva"); f ->SetLineStyle(1); f ->SetLineColor(kBlue); gr -> Fit("fit", "R"); gr->SetMarkerColor(kPink - 9); gr->SetMarkerStyle(23); gr->SetMarkerSize(0.5); gr->SetTitle("P(t) Muestra I"); gr->GetXaxis()->SetTitle("Tiempo (s)"); gr->GetYaxis()->SetTitle("Presion (Torr)"); gr->GetYaxis()->SetRange(-100, 800); gr->Draw("AP"); leg = new TLegend(0.63,0.70,0.87,0.88); leg->SetHeader("Muestra"); leg->AddEntry("f","P=P_{0} e^{-S t/V}", "l"); leg->AddEntry("gr","P(t)","lep"); leg->AddEntry((TObject*)0, Form("S = %f", f->GetParameter(1)), ""); leg->AddEntry((TObject*)0, Form("#sigma_{S} = %f", f->GetParError(1)), ""); leg->Draw(); //Grafico.SetLogy(); Grafico->SetGrid(); Grafico->Update(); string save_file = input_name+".png"; Grafico->Print(save_file.c_str()); //printf("%i", cont); } cout << "Funciona" << endl; Hola(); }
void AnalysisSparse(Bool_t save_output = kFALSE) { gStyle->SetGridColor(kGray); // TString tmpstr(fname); // if (tmpstr.Contains("data")) { // Printf("!!! Real Data !!!"); // mc = kFALSE; // } TString gtitle = Form("Monte Carlo, %s", graph_name.Data()); grapht = graph_name.Data(); Double_t grx[999], gry[999], gry2[999], gry3[999], gry4[999], gry_eff[999], gry_fix[999], grxE[999]; Double_t gry22[999], gry22E[999], grx22E[999]; Double_t gry_true[999], gry_true_eff[999], gry_true_effE[999]; TH1::AddDirectory(kFALSE); TFile::SetCacheFileDir(gSystem->HomeDirectory()); TFile *f = TFile::Open(fname.Data(), "CACHEREAD"); if (!f) return; TList *l; f->GetObject(lname.Data(), l); if (!l) return; Int_t bf[999], bl[999]; Int_t nn = FindExactRange(((THnSparse *)(l->FindObject(s1name.Data())))-> Projection(1), del_step, bf, bl); // Int_t nn = FindRange5(bf, bl); Bool_t binhaluska = kFALSE; if (binAnders) { nn = 8; bf[0] = 6;bf[1] = 9;bf[2] = 11;bf[3] = 16;bf[4] = 21;bf[5] = 26; bl[0] = 8;bl[1] = 10;bl[2] = 15;bl[3] = 20;bl[4] = 25;bl[5] = 30; bf[6] = 31;bf[7] = 41; bl[6] = 40;bl[7] = 50; } Printf("number of intervals = %d =>", nn); Int_t count = 0; Double_t ptmean = 0, value = 0; Int_t fitStatus = -1; gStyle->SetOptStat(0); TCanvas *c = new TCanvas("c", "Signal & Background"); c->Divide(5, 5); c->Modified(); c->Draw(); TCanvas *c2 = (TCanvas *)c->DrawClone("c2"); c2->SetTitle("Phi mesons (raw)"); c2->Modified(); c2->Draw(); TCanvas *c3, *c4; if (mc) { c3 = (TCanvas *)c->DrawClone("c3"); c3->SetTitle("Phi mesons (gen)"); c3->Modified(); c3->Draw(); c4 = (TCanvas *)c->DrawClone("c4"); c4->SetTitle("Phi mesons (true)"); c4->Modified(); c4->Draw(); } for (Int_t i = 0; i < nn; i++) { c->cd(count + 1)->SetGrid(); h1 = (TH1D *)PullHisto(l, s1name.Data(), bf[i], bl[i], ptmean); h1->SetLineColor(kRed); h1->GetXaxis()->SetTitle("inv. mass, GeV/c^2"); h1->Draw("hist"); h3_p = (TH1D *)PullHisto(l, s3name_p.Data(), bf[i], bl[i], ptmean); h3_m = (TH1D *)PullHisto(l, s3name_m.Data(), bf[i], bl[i], ptmean); // !!!!!!!!!!!!!!!!!!!!!!!! if (count==0) h3_p = h1; // !!!!!!!!!!!!!!!!!!!!!!!! else { h3_p->Add(h3_m); // h3_p->Add((TH1D *)PullHisto(l, smix.Data(), bf[i], bl[i], ptmean)); // h3_p->Add((TH1D *)PullHisto(l, smixpp.Data(), bf[i], bl[i], ptmean)); // h3_p->Add((TH1D *)PullHisto(l, smixmm.Data(), bf[i], bl[i], ptmean)); Norm(h1, h3_p, norm[0], norm[1]); } h3_p->SetLineColor(kBlue); h3_p->Draw("hist, same"); if (mc) { c3->cd(count + 1)->SetGrid(); Printf("%s", s1namegen.Data()); hg = (TH1D *)PullHisto(l, s1namegen.Data(), bf[i], bl[i], ptmean); hg->SetLineColor(kMagenta); hg->GetXaxis()->SetTitle("inv. mass, GeV/c^2"); hg->Draw("hist"); c4->cd(count + 1)->SetGrid(); ht = (TH1D *)PullHisto(l, s1nametrue.Data(), bf[i], bl[i], ptmean); ht->SetLineColor(kMagenta-5); ht->GetXaxis()->SetTitle("inv. mass, GeV/c^2"); ht->Draw("hist"); } c2->cd(count + 1)->SetGrid(); TH1 *hh = (TH1 *)h1->Clone("hh"); hh->SetLineColor(kRed+1); hh->Add(h3_p, -1); /// !!!!!!!!!!!!!!!!!!!!!! ////////// if ((ilist == 3) && (count < 2)) hh->Reset(); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!! hh->Draw("hist"); // !!!!!!!!!!!!!!!!!! ff->SetParameters(0.1, 1.02, 0.004, -25000., 0., 0., 0.); ff->SetLineColor(hh->GetLineColor()); ff->SetLineWidth(1); // ff->SetLineStyle(kDashed); // where fit Double_t fmin = 1.02-2*0.004; Double_t fmax = 1.02+2*0.004; // Double_t fmin = 0.995; // Double_t fmax = 1.185; // !!!!!!!!!!!!!!!!!! Bool_t hisfun = kFALSE; // kFALSE = integral from function Double_t hisfun_k = 1.0/hh->GetBinWidth(10); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if (binhaluska) if (i > 9) hisfun_k = 0.5/hh->GetBinWidth(10); Printf("======= %f", hisfun_k); // !!!!!!!!!!!!!!!!!! // wehere integral (his or fun) Double_t fmini = 1.02-2*0.004; Double_t fmaxi = 1.02+2*0.004; hh->Fit(ff, "Q", "", fmin, fmax); hh->Fit(ff, "Q", "", fmin, fmax); fitStatus = hh->Fit(ff, "Q", "", fmin, fmax); TF1 *pp3 = new TF1("pp3", "[0]+x*[1]+x*x*[2]+x*x*x*[3]", fmin, fmax); pp3->SetParameters(ff->GetParameter(3), ff->GetParameter(4), ff->GetParameter(5), ff->GetParameter(6)); pp3->SetLineWidth(1); pp3->SetLineColor(h3_p->GetLineColor()); pp3->Draw("same"); // ff->SetRange(fmin, fmax); // ff->DrawCopy("same"); value = hh->Integral(hh->FindBin(fmini), hh->FindBin(fmaxi)); if (!hisfun) value = ff->Integral(fmini, fmaxi)*hisfun_k - pp3->Integral(fmini, fmaxi)*hisfun_k; if (value < 0) value = 0; if ((fitStatus != 0) || (ff->GetParameter(2) > 0.1)) { printf(" SKIP Data"); value = 0; } grx[count] = ptmean; if (binhaluska) { if (count < 10) grxE[count] = 0.25; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! else grxE[count] = 0.50; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } else // grxE[count] = (1.30-1.10)/2.0; // !!!!!!!!!!!!!!!!!!!!!!!!!! grxE[count] = 0.05; gry[count] = value; Double_t tmp1 = h1->Integral(h1->FindBin(fmini), h1->FindBin(fmaxi)); Double_t tmp2 = h3_p->Integral(h3_p->FindBin(fmini), h3_p->FindBin(fmaxi)); Double_t tmp_sg = tmp1 - tmp2; Double_t tmp_bg = tmp2; // if ((tmp_sg <= -tmp_bg) || (tmp_bg < 33.0)) { // gry3[count] = 0.0; // gry4[count] = 0.0; // } // else { gry3[count] = tmp_sg/tmp_bg; gry4[count] = tmp_sg/TMath::Sqrt(tmp_sg + tmp_bg); // } // Printf("%4.2f, %10f, %10f, %10f", ptmean, tmp1, tmp2, gry3[count]); if (mc) { c3->cd(count + 1); // !!!!!!!!!!!!!!!! ff->SetParameters(1, 1.02, 0.004, 0., 0., 0., 0.); hg->Fit(ff, "Q", "", fmin, fmax); hg->Fit(ff, "Q", "", fmin, fmax); fitStatus = hg->Fit(ff, "Q", "", fmin, fmax); /* TF1 *pp3 = new TF1("pp3", "[0]+x*[1]+x*x*[2]+x*x*x*[3]", fmin, fmax); pp3->SetParameters(ff->GetParameter(3), ff->GetParameter(4), ff->GetParameter(5), ff->GetParameter(6)); pp3->SetLineWidth(1); pp3->SetLineColor(h3_p->GetLineColor()); pp3->Draw("same"); */ value = hg->Integral(hg->FindBin(fmini), hg->FindBin(fmaxi)); if (!hisfun) value = ff->Integral(fmini, fmaxi)*hisfun_k; //!!!!!!!!!!!!!!!!!!!pp3->Integral(fmini, fmaxi)*hisfun_k; if (value <= 0) value = -1; if ((fitStatus != 0) || (ff->GetParameter(2) > 0.1)) { printf(" SKIP MC"); value = -1; } gry2[count] = value; Double_t superfactor = CalculateFactor(l, 0.1); if (useCF) { gry22E[i] = TMath::Sqrt(gry2[i])*superfactor; // gry22E[i] = 0.0001; gry22[i] = gry2[i]*superfactor; grx22E[i] = 0.05; } gry_eff[count] = gry[count]/gry2[count]; c4->cd(count + 1); // !!!!!!!!!!!!!!!! ff->SetParameters(1, 1.02, 0.004, 0., 0., 0., 0.); ht->Fit(ff, "Q", "", fmin, fmax); ht->Fit(ff, "Q", "", fmin, fmax); fitStatus = ht->Fit(ff, "Q", "", fmin, fmax); /* TF1 *pp3 = new TF1("pp3", "[0]+x*[1]+x*x*[2]+x*x*x*[3]", fmin, fmax); pp3->SetParameters(ff->GetParameter(3), ff->GetParameter(4), ff->GetParameter(5), ff->GetParameter(6)); pp3->SetLineWidth(1); pp3->SetLineColor(h3_p->GetLineColor()); pp3->Draw("same"); */ value = ht->Integral(ht->FindBin(fmini), ht->FindBin(fmaxi)); if (!hisfun) value = ff->Integral(fmini, fmaxi)*hisfun_k; //!!!!!!!!!!!!!!!!!!!pp3->Integral(fmini, fmaxi)*hisfun_k; if (value <= 0) value = -1; if ((fitStatus != 0) || (ff->GetParameter(2) > 0.1)) { printf(" SKIP true"); value = -1; } gry_true[count] = value; gry_true_eff[count] = gry_true[count]/gry2[count]; // Propagation of uncertainty (A/B) Double_t AAA = gry_true[count]; Double_t AAAE = TMath::Sqrt(AAA); Double_t BBB = gry2[count]; Double_t BBBE = TMath::Sqrt(BBB); Double_t EEE = TMath::Sqrt((AAAE/AAA)*(AAAE/AAA)+(BBBE/BBB)*(BBBE/BBB)); EEE = EEE*gry_true_eff[count]; gry_true_effE[count] = EEE; } Printf("=> %6.4f", ptmean); count++; } new TCanvas(); TGraph *gr = new TGraph(count, grx, gry); gr->SetMarkerStyle(8); gr->SetMarkerColor(hh->GetLineColor()); gr->GetXaxis()->SetTitle("p_{t}, GeV/c"); gr->SetTitle(Form("raw phi, %s", gtitle.Data())); gr->Draw("AP"); cc3 = new TCanvas(); TGraph *gr3 = new TGraph(count, grx, gry3); gr3->SetMarkerStyle(22); gr3->SetMarkerColor(kBlue+1); gr3->GetXaxis()->SetTitle("p_{t}, GeV/c"); gr3->SetTitle(Form("SIG / BKG, %s", gtitle.Data())); gr3->SetMinimum(0); gr3->Draw("AP"); cc4 = new TCanvas(); TGraph *gr4 = new TGraph(count, grx, gry4); gr4->SetMarkerStyle(23); gr4->SetMarkerColor(kBlue-1); gr4->GetXaxis()->SetTitle("p_{t}, GeV/c"); gr4->SetTitle(Form("Significance, %s", gtitle.Data())); gr4->SetMinimum(0); gr4->Draw("AP"); ccc = new TCanvas("ccc","ccc",0,0,900,300); ccc->Divide(2, 1, 0.001, 0.001); ccc->cd(1); gr3->Draw("AP"); ccc->cd(2); gr4->Draw("AP"); TString blabla = "mc"; if (!mc) blabla = "data"; // gr3->SaveAs(Form("SB_%s_%s.C", blabla.Data(), grapht.Data())); // gr4->SaveAs(Form("Sig_%s_%s.C", blabla.Data(), grapht.Data())); // ccc->SaveAs(Form("%s_%s_2.eps", blabla.Data(), grapht.Data())); // c->SaveAs(Form("%s_%s_0.eps", blabla.Data(), grapht.Data())); // c2->SaveAs(Form("%s_%s_1.eps", blabla.Data(), grapht.Data())); // cc3->SaveAs(Form("%s_%s_2.eps", blabla.Data(), grapht.Data())); // gr3->SaveAs(Form("sig_bck_%s_%s.C", blabla.Data(), grapht.Data())); if (mc) { new TCanvas(); TGraph *gr2 = new TGraph(count, grx, gry2); gr2->SetMarkerStyle(8); gr2->SetMarkerColor(hg->GetLineColor()); gr2->GetXaxis()->SetTitle("p_{t}, GeV/c"); gr2->SetTitle(Form("gen phi, %s", gtitle.Data())); gr2->Draw("AP"); new TCanvas(); TGraphErrors *gr22 = new TGraphErrors(count, grx, gry22, grx22E, gry22E); gr22->SetMarkerStyle(8); gr22->SetMarkerColor(kCyan); gr22->GetXaxis()->SetTitle("p_{t}, GeV/c"); gr22->SetTitle(Form("gen phi, %s", gtitle.Data())); gr22->Draw("AP"); c = new TCanvas(); c->SetGrid(); TGraph *gr_e = new TGraph(count, grx, gry_eff); gr_e->SetMarkerStyle(22); gr_e->SetMarkerColor(kBlack); gr_e->GetXaxis()->SetTitle("p_{t}, GeV/c"); gr_e->SetTitle(Form("efficiency (raw), %s", grapht.Data())); gr_e->Draw("AP"); Printf("Save as '\033[1meffi_raw_%s\033[0m' file", grapht.Data()); for (Int_t i = 0; i < gr_e->GetN(); i++) Printf("%f %f", gr_e->GetX()[i], gr_e->GetY()[i]); cvb = new TCanvas(); cvb->cd(); TGraph *gr_true = new TGraph(count, grx, gry_true); gr_true->SetMarkerStyle(8); gr_true->SetMarkerColor(ht->GetLineColor()); gr_true->GetXaxis()->SetTitle("p_{t}, GeV/c"); gr_true->SetTitle(Form("true phi, %s", gtitle.Data())); gr_true->Draw("AP"); c = new TCanvas(); c->cd(); c->SetGrid(); TGraphErrors *gr_true_eff = new TGraphErrors(count, grx, gry_true_eff, grxE, gry_true_effE); gr_true_eff->SetMarkerStyle(20); // gr_true_eff->SetMarkerSize(0.75); gr_true_eff->SetMarkerColor(kBlack); gr_true_eff->GetXaxis()->SetTitle("p_{t}, GeV/c"); gr_true_eff->SetTitle(Form("efficiency (true), %s", grapht.Data())); gr_true_eff->Draw("AEP"); m_gr->Add(gr_true_eff); Printf("Save as '\033[1meffi_true_%s\033[0m' file", grapht.Data()); TString tout; Double_t oux, ouy, ouxe, ouye; for (Int_t i = 0; i < gr_true_eff->GetN(); i++) { oux = gr_true_eff->GetX()[i]; ouy = gr_true_eff->GetY()[i]; ouy = MinusCheck(ouy); ouxe = gr_true_eff->GetErrorX(i); ouye = gr_true_eff->GetErrorY(i); ouye = NanCheck(ouye); Printf("%f %f %f %f", gr_true_eff->GetX()[i], gr_true_eff->GetY()[i], gr_true_eff->GetErrorX(i), gr_true_eff->GetErrorY(i)); if (!save_output) continue; gSystem->mkdir(dir_prefix.Data()); tout = Form("%f %f %f %f", oux, ouy, ouxe, ouye); if (i == 0) tout = Form("Printf(\"%s\"); > %s/effi_%s", tout.Data(), dir_prefix.Data(), grapht.Data()); else tout = Form("Printf(\"%s\"); >> %s/effi_%s", tout.Data(), dir_prefix.Data(), grapht.Data()); // Printf(":::::: %s", tout.Data()); gROOT->ProcessLine(tout.Data()); } // ------------------ c = new TCanvas("cfinal", "mc_effi", 1200, 450); c->Divide(2, 1, 0.001, 0.001); c->Modified(); c->Draw(); c->cd(1); gr_true->SetMinimum(0); gr_true->SetTitle(Form("phi (true & raw), %s", gtitle.Data())); gr_true->SetMarkerColor(kGreen+1); gr_true->Draw("AP"); gr->SetMarkerColor(kRed+1); gr->Draw("P"); c->cd(2)->SetGrid(); gr_true_eff->SetMinimum(0); gr_true_eff->SetTitle(Form("efficiency, %s", grapht.Data())); gr_true_eff->SetMarkerColor(kGreen+1); gr_true_eff->Draw("AP"); gr_e->SetMarkerColor(kRed+1); gr_e->Draw("P"); // c->SaveAs(Form("%s_%s.eps", blabla.Data(), grapht.Data())); return; } // TGraph *geff = new TGraph(Form("effi_raw_%s", grapht.Data())); // TGraph *geff = new TGraph(Form("effi_true_%s", grapht.Data())); // TGraph *geff = new TGraph("effi_true_Phi2010_qualityonly"); TGraph *geff = new TGraph("effi_true_PhiNsigma_qualityonly"); if (geff->IsZombie()) return; geff->SetMarkerStyle(22); geff->SetMarkerColor(kBlack); geff->GetXaxis()->SetTitle("p_{t}, GeV/c"); geff->SetTitle(Form("efficiency, %s", grapht.Data())); c = new TCanvas(); c->SetGrid(); geff->Draw("AP"); Double_t tpcsigma = 9999.9; if (ilist == 1) tpcsigma = 1.0; if (ilist == 2) tpcsigma = 1.5; if (ilist == 3) tpcsigma = 2.0; if (ilist == 4) tpcsigma = 2.5; if (ilist == 5) tpcsigma = 3.0; Double_t sss = TMath::Erf(tpcsigma/TMath::Sqrt(2.0)); if (noSigma) sss = 1.0; Printf("sigma = %10f", sss); // for (Int_t i = 0; i < count; i++) // geff->GetY()[i] = (sss*sss)/(geff->GetY()[i]); // geff->SetMaximum(1.0); // geff->Draw("AP"); for (Int_t i = 0; i < count; i++) { Double_t deno = geff->Eval(grx[i])*sss*sss; if (deno < 0.00001) deno = 1; gry_fix[i] = gry[i]/deno; } new TCanvas; TGraph *gr_fix = new TGraph(count, grx, gry_fix); gr_fix->SetMarkerStyle(21); gr_fix->SetMarkerColor(hh->GetLineColor()); gr_fix->GetXaxis()->SetTitle("p_{t}, GeV/c"); gr_fix->SetTitle(Form("corrected phi * #sigma^{2}, %s", gtitle.Data())); if (noSigma) gr_fix->SetTitle(Form("corrected phi (no #sigma), %s", gtitle.Data())); gr_fix->Draw("AP"); //--------------------- c = new TCanvas("cfinald", "data_correct", 1200, 450); c->Divide(2, 1, 0.001, 0.001); c->Modified(); c->Draw(); c->cd(1); gr->SetMinimum(0); gr->SetMarkerColor(kBlack); gr->Draw("AP"); c->cd(2); gr_fix->SetMinimum(0); gr_fix->SetMarkerColor(kGreen+3); gr_fix->Draw("AP"); TString bla9 = Form("qualityonly_PID2_%s", grapht.Data()); if (noSigma) bla9 = Form("%s_noSig.C", bla9.Data()); else bla9 = Form("%s.C", bla9.Data()); // gr_fix->SaveAs(bla9.Data()); // TPad *cp = new TPad("cpf", "", 0.45,0.45,0.99,0.92); TPad *cp = new TPad("cpf", "", 0.60,0.55,0.99,0.93); cp->SetLogy(); cp->Draw(); cp->cd(); TGraph *cloneg = ((TGraph *)gr_fix->Clone()); cloneg->SetTitle(); cloneg->SetMarkerSize(0.8); cloneg->Draw("AP"); // c->SaveAs(Form("%s_%s.eps", blabla.Data(), grapht.Data())); f->Close(); }
void PlotBlowoutScalings(Int_t time, const TString &options="") { #ifdef __CINT__ gSystem->Load("libptools.so"); #endif PGlobals::Initialize(); TString opt = options; const Int_t Nsim = 11; char sName[Nsim][36] = {"rake-v1.0kA.G.SR2.MC01.3D", "rake-v2.5kA.G.SR2.MC01.3D", "rake-v04kA.G.SR2.MC01.3D", "rake-v06kA.G.SR2.MC01.3D", "rake-v08kA.G.SR2.MC01.3D", "rake-v10kA.G.SR2.MC01.3D", "rake-v15kA.G.SR2.MC01.3D", "rake-v20kA.G.MC01.3D", "rake-v30kA.G.SR2.MC01.3D", "rake-v45kA.G.SR2.MC01.3D", "rake-v60kA.G.SR2.MC01.3D"}; // Load first simulation data (for instance) PData *pData = PData::Get(sName[0]); pData->LoadFileNames(time); if(!pData->IsInit()) return; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); Double_t lightspeed = PConst::c_light; // Some beam properties: Float_t gamma = pData->GetBeamGamma(); // Trapping potential Float_t trapPotential = 1.0 - (1.0/gamma); // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; // Compulsory options opt += "comovcenter"; // Centering time and z position: Double_t shiftz = pData->Shift(opt); if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } TFile *sFile[Nsim]; TString *sPath[Nsim]; Int_t color[Nsim]; // histos and graphs TH2F *hEz2D[Nsim]; TH2F *hDen2D[Nsim]; TH1F *hCur1D[Nsim]; TH1F *hEz1D[Nsim]; TH1F *hV1D[Nsim]; TH1F *hFocus1D[Nsim]; TH1F *hDenx1D[Nsim]; // Arrays with the quantities Float_t Current[Nsim]; Float_t Zeta0[Nsim]; Float_t RadiusX[Nsim]; Float_t RadiusZ[Nsim]; Float_t RadiusPsi[Nsim]; Float_t EzMax[Nsim]; Float_t EzMaxUse[Nsim]; Float_t EzLimit[Nsim]; Float_t EzMaxFocus[Nsim]; Float_t EzSlope[Nsim]; Float_t EzSlopeMaxFocus[Nsim]; Float_t EzMaxBeam[Nsim]; Float_t DeltaPsi[Nsim]; Float_t DeltaPsiFocus[Nsim]; Float_t TransRatio[Nsim]; Float_t TransRatioFocus[Nsim]; // Theory Float_t EzMaxLU[Nsim]; Float_t EzMaxLO[Nsim]; Float_t EzMaxUseBO[Nsim]; Float_t EzMaxBeamLO[Nsim]; Float_t EzSlopeLO[Nsim]; Float_t RadiusLO[Nsim]; Float_t RadiusLU[Nsim]; Float_t RadiusPsiBO[Nsim]; Float_t PsiMaxLO[Nsim]; Float_t DeltaPsiLO[Nsim]; Float_t DeltaPsiLU[Nsim]; // Maximums and minimums for plotting Float_t maxCur = -999.; Float_t minCur = 999.; Float_t maxRadius = -999.; Float_t minRadius = 999.; Float_t maxEz = -999.; Float_t minEz = 999.; Float_t maxEzSlope = -999.; Float_t minEzSlope = 999.; Float_t maxPsi = -999.; Float_t minPsi = 999.; Float_t maxTR = -999.; Float_t minTR = 999.; for(Int_t i=0;i<Nsim;i++) { TString filename = Form("./%s/Plots/Snapshots/Snapshot-%s_%i.root",sName[i],sName[i],time); sFile[i] = new TFile(filename,"READ"); // Load histos and graphs hEz2D[i] = (TH2F*) sFile[i]->Get("hE2D_0"); hDen2D[i] = (TH2F*) sFile[i]->Get("hDen2D_0"); hEz1D[i] = (TH1F*) sFile[i]->Get("hE1D_0"); hCur1D[i] = (TH1F*) sFile[i]->Get("hCur1D_1"); hV1D[i] = (TH1F*) sFile[i]->Get("hV1D"); hFocus1D[i] = (TH1F*) sFile[i]->Get("hFocus1D"); hDen2D[i]->ResetStats(); hEz1D[i]->ResetStats(); hCur1D[i]->ResetStats(); hV1D[i]->ResetStats(); cout << Form("\n Analyzing simulation %s : \n",sName[i]) << endl; // Driver RMS Double_t rmslength = hCur1D[i]->GetRMS(); // Find the first point on-axis where Ez changes from positive to negative: Int_t MAXCROSS = 2; Float_t *EzCross = new Float_t[MAXCROSS]; Float_t *EzExtr = new Float_t[MAXCROSS]; memset(EzCross,0,sizeof(Float_t)*MAXCROSS); memset(EzExtr,0,sizeof(Float_t)*MAXCROSS); Int_t auxNcross = PGlobals::HCrossings(hEz1D[i],EzCross,EzExtr,MAXCROSS,0.0,2*rmslength); // for(Int_t j=0;j<auxNcross;j++) { // if(opt.Contains("units")) // cout << Form(" %i Ez crossing found at zeta = %.2f um -> Ez maximum = %.2f GV/m",j,EzCross[j],EzExtr[j]) << endl; // else // cout << Form(" %i Ez crossing found at zeta = %.2f kp^-1 -> Ez maximum = %.2f E0",j,EzCross[j],EzExtr[j]) << endl; // } Zeta0[i] = EzCross[0]; Int_t bin0 = hEz1D[i]->FindBin(Zeta0[i]); hDenx1D[i] = (TH1F*) hDen2D[i]->ProjectionY("_py",bin0); RadiusX[i] = fabs(hDenx1D[i]->GetBinCenter(hDenx1D[i]->GetMaximumBin())); RadiusZ[i] = fabs(hV1D[i]->GetBinCenter(hV1D[i]->GetMinimumBin()) - Zeta0[i]); DeltaPsi[i] = hV1D[i]->GetBinContent(hV1D[i]->GetMaximumBin()) - hV1D[i]->GetBinContent(hV1D[i]->GetMinimumBin()); Float_t zshift = 0.5; if(opt.Contains("units")) zshift *= PUnits::um * kp; Int_t bin1 = hEz1D[i]->FindBin(Zeta0[i]-zshift); Int_t bin2 = hEz1D[i]->FindBin(Zeta0[i]+zshift); EzSlope[i] = (hEz1D[i]->GetBinContent(bin1)-hEz1D[i]->GetBinContent(bin2))/ (hEz1D[i]->GetBinCenter(bin1)-hEz1D[i]->GetBinCenter(bin2)); EzMaxUse[i] = EzSlope[i] * RadiusZ[i]; EzMaxBeam[i] = EzExtr[0]; EzMax[i] = fabs(EzExtr[1]); Current[i] = hCur1D[i]->GetMaximum(); if(opt.Contains("units")) { Current[i] *= PUnits::kA / PConst::I0; rmslength *= PUnits::um * kp; } RadiusLO[i] = PFunc::RadiusBO(Current[i],rmslength); RadiusLU[i] = 2.0 * TMath::Sqrt(Current[i]); EzMaxLU[i] = PFunc::EzMaxLu(Current[i]); EzMaxBeamLO[i] = PFunc::EzMaxBeamLo(Current[i]); EzMaxLO[i] = RadiusLO[i]/2.0; Float_t RadiusLO2 = RadiusLO[i]*RadiusLO[i]; Float_t RadiusLU2 = RadiusLU[i]*RadiusLU[i]; // EzSlopeLO[i] = RadiusLO2 * (RadiusLO2 + 8.0) / (2.0 * (RadiusLO2 + 4.0) * (RadiusLO2 + 4.0)); EzSlopeLO[i] = RadiusLU2 * (RadiusLU2 + 8.0) / (2.0 * (RadiusLU2 + 4.0) * (RadiusLU2 + 4.0)); PsiMaxLO[i] = RadiusLO[i]*RadiusLO[i]/4.0; DeltaPsiLO[i] = RadiusLO[i]*RadiusLO[i]/4.0; DeltaPsiLU[i] = RadiusLU[i]*RadiusLU[i]/4.0; RadiusPsiBO[i] = TMath::Sqrt(2*(DeltaPsiLO[i]-1)); EzMaxUseBO[i] = RadiusPsiBO[i]/2.0; if(opt.Contains("units")) { Current[i] /= PUnits::kA / PConst::I0; rmslength /= PUnits::um * kp; RadiusLO[i] *= skindepth / PUnits::um; RadiusLU[i] *= skindepth / PUnits::um; RadiusPsiBO[i] *= skindepth / PUnits::um; EzMaxLU[i] *= E0 / (PUnits::GV/PUnits::m); EzMaxBeamLO[i] *= E0 / (PUnits::GV/PUnits::m); EzMaxUseBO[i] *= E0 / (PUnits::GV/PUnits::m); EzSlope[i] *= (E0 / (PUnits::GV/PUnits::m)) * skindepth / PUnits::um; cout << Form(" Beam max. current = %.2f kA RMS = %.2f um",Current[i],rmslength) << endl; cout << Form(" Radius of the bubble (Lotov): R = %.2f um",RadiusLO[i]) << endl; cout << Form(" Radius of the bubble (Lu) : R = %.2f um",RadiusLU[i]) << endl; cout << Form(" Ez max beam (Lo) = %.2f GV/m",EzMaxBeamLO[i]) << endl; cout << Form(" Ez max (Lu) = %.2f GV/m",-EzMaxLU[i]) << endl; cout << Form(" Ez slope at crossing = %.2f (GV/m)/um ",EzSlope[i]) << endl; } else { cout << Form(" Beam max. current = %.2f I0 RMS = %.2f kp^-1",Current[i],rmslength) << endl; cout << Form(" Radius of the bubble (Lotov): R = %.2f kp^-1",RadiusLO[i]) << endl; cout << Form(" Radius of the bubble (Lu) : R = %.2f kp^-1",RadiusLU[i]) << endl; cout << Form(" Ez max beam (Lo) = %.2f E0",EzMaxBeamLO[i]) << endl; cout << Form(" Ez max (Lu) = %.2f E0",-EzMaxLU[i]) << endl; cout << Form(" Ez slope at crossing = %.2f ",EzSlope[i]) << endl; } if(opt.Contains("kA")) { Current[i] /= PUnits::kA / PConst::I0; } // Find the first Focusing crossing after the maximum MAXCROSS = 1; Float_t *FocusCross = new Float_t[MAXCROSS]; Float_t *FocusExtr = new Float_t[MAXCROSS]; memset(FocusCross,0,sizeof(Float_t)*MAXCROSS); memset(FocusExtr,0,sizeof(Float_t)*MAXCROSS); auxNcross = PGlobals::HCrossings(hFocus1D[i],FocusCross,FocusExtr,MAXCROSS,0.0,Zeta0[i]); if(opt.Contains("units") && n0) { trapPotential *= ( E0 * skindepth / (PUnits::MV) ); } Int_t binFcross = hFocus1D[i]->FindBin(FocusCross[0]); Float_t potValueFin = hV1D[i]->GetBinContent(binFcross); EzMaxFocus[i] = fabs(hEz1D[i]->GetBinContent(binFcross)); TransRatio[i] = EzMax[i]/EzMaxBeam[i]; TransRatioFocus[i] = EzMaxFocus[i]/EzMaxBeam[i]; cout << Form(" Max. R = %.2f ",TransRatio[i]) << endl; cout << Form(" Max. R focus = %.2f ",TransRatioFocus[i]) << endl; Int_t binPotValueIni = -99; Float_t potValueIni = -99; for(Int_t j=binFcross;j<hV1D[i]->GetNbinsX();j++) { if(hV1D[i]->GetBinContent(j)>=potValueFin+trapPotential) { binPotValueIni = j; potValueIni = hV1D[i]->GetBinContent(j); //break; } } // Ez slope at max focusing Ez zshift = 0.1; bin1 = hEz1D[i]->FindBin(FocusCross[0]-zshift); bin2 = hEz1D[i]->FindBin(FocusCross[0]+zshift); EzSlopeMaxFocus[i] = (hEz1D[i]->GetBinContent(bin1)-hEz1D[i]->GetBinContent(bin2))/ (hEz1D[i]->GetBinCenter(bin1)-hEz1D[i]->GetBinCenter(bin2)); cout << Form(" Ez slope at max focus = %.2f ",EzSlopeMaxFocus[i]) << endl; // Difference between psi maximum and psi final focus DeltaPsiFocus[i] = hV1D[i]->GetBinContent(hV1D[i]->GetMaximumBin()) - potValueFin; // Find the first Psi crossing after the maximum MAXCROSS = 1; Float_t *PsiCross = new Float_t[MAXCROSS]; Float_t *PsiExtr = new Float_t[MAXCROSS]; memset(PsiCross,0,sizeof(Float_t)*MAXCROSS); memset(PsiExtr,0,sizeof(Float_t)*MAXCROSS); auxNcross = PGlobals::HCrossings(hV1D[i],PsiCross,PsiExtr,MAXCROSS,potValueIni,Zeta0[i]); Int_t binVcross = -1; EzLimit[i] = 0.0; RadiusPsi[i] = 0.0; if(auxNcross>0) { binVcross = hEz1D[i]->FindBin(PsiCross[0]); EzLimit[i] = fabs(hEz1D[i]->GetBinContent(binVcross)); RadiusPsi[i] = fabs(PsiCross[0]- Zeta0[i]); } cout << Form(" Trapping zone radius = %.2f ",RadiusPsi[i]) << endl; if(RadiusX[i]>maxRadius) maxRadius = RadiusX[i]; if(RadiusZ[i]>maxRadius) maxRadius = RadiusZ[i]; if(RadiusLO[i]>maxRadius) maxRadius = RadiusLO[i]; if(RadiusLU[i]>maxRadius) maxRadius = RadiusLU[i]; if(RadiusX[i]<minRadius) minRadius = RadiusX[i]; if(RadiusZ[i]<minRadius) minRadius = RadiusZ[i]; if(RadiusLO[i]<minRadius) minRadius = RadiusLO[i]; if(RadiusLU[i]<minRadius) minRadius = RadiusLU[i]; if(EzMax[i]>maxEz) maxEz = EzMax[i]; if(EzMaxUse[i]>maxEz) maxEz = EzMaxUse[i]; if(EzLimit[i]>maxEz) maxEz = EzLimit[i]; if(EzMaxFocus[i]>maxEz) maxEz = EzMaxFocus[i]; if(EzMaxBeam[i]>maxEz) maxEz = EzMaxBeam[i]; if(EzMaxLO[i]>maxEz) maxEz = EzMaxLO[i]; if(EzMaxLU[i]>maxEz) maxEz = EzMaxLU[i]; if(EzMaxBeamLO[i]>maxEz) maxEz = EzMaxBeamLO[i]; if(EzMax[i]<minEz) minEz = EzMax[i]; if(EzMaxUse[i]<minEz) minEz = EzMaxUse[i]; if(EzLimit[i]<minEz) minEz = EzLimit[i]; if(EzMaxFocus[i]<minEz) minEz = EzMaxFocus[i]; if(EzMaxBeam[i]<minEz) minEz = EzMaxBeam[i]; if(EzMaxLO[i]<minEz) minEz = EzMaxLO[i]; if(EzMaxLU[i]<minEz) minEz = EzMaxLU[i]; if(EzMaxBeamLO[i]<minEz) minEz = EzMaxBeamLO[i]; if(EzSlope[i]>maxEzSlope) maxEzSlope = EzSlope[i]; if(EzSlope[i]<minEzSlope) minEzSlope = EzSlope[i]; // if(EzSlopeMaxFocus[i]>maxEzSlope) maxEzSlope = EzSlopeMaxFocus[i]; // if(EzSlopeMaxFocus[i]<minEzSlope) minEzSlope = EzSlopeMaxFocus[i]; if(DeltaPsi[i]>maxPsi) maxPsi = DeltaPsi[i]; if(DeltaPsiFocus[i]>maxPsi) maxPsi = DeltaPsiFocus[i]; if(DeltaPsiLO[i]>maxPsi) maxPsi = DeltaPsiLO[i]; if(DeltaPsiLU[i]>maxPsi) maxPsi = DeltaPsiLU[i]; if(DeltaPsi[i]<minPsi) minPsi = DeltaPsi[i]; if(DeltaPsiFocus[i]<minPsi) minPsi = DeltaPsiFocus[i]; if(DeltaPsiLO[i]<minPsi) minPsi = DeltaPsiLO[i]; if(DeltaPsiLU[i]<minPsi) minPsi = DeltaPsiLU[i]; if(TransRatio[i]<minTR) minTR = TransRatio[i]; if(TransRatio[i]>maxTR) maxTR = TransRatio[i]; if(TransRatioFocus[i]<minTR) minTR = TransRatioFocus[i]; if(TransRatioFocus[i]>maxTR) maxTR = TransRatioFocus[i]; if(Current[i]<minCur) minCur = Current[i]; if(Current[i]>maxCur) maxCur = Current[i]; } Float_t xMin = minCur - (maxCur-minCur)*0.1; Float_t xMax = maxCur + (maxCur-minCur)*0.1; // Graphs for the max. current dependence TGraph *gRadiusX = new TGraph(Nsim,Current,RadiusX); TGraph *gRadiusZ = new TGraph(Nsim,Current,RadiusZ); TGraph *gRadiusPsi = new TGraph(Nsim,Current,RadiusPsi); TGraph *gRadiusLO = new TGraph(Nsim,Current,RadiusLO); TGraph *gRadiusLU = new TGraph(Nsim,Current,RadiusLU); TGraph *gRadiusPsiBO = new TGraph(Nsim,Current,RadiusPsiBO); TGraph *gEzMax = new TGraph(Nsim,Current,EzMax); TGraph *gEzMaxUse = new TGraph(Nsim,Current,EzMaxUse); TGraph *gEzMaxBeam = new TGraph(Nsim,Current,EzMaxBeam); TGraph *gEzLimit = new TGraph(Nsim,Current,EzLimit); TGraph *gEzMaxFocus = new TGraph(Nsim,Current,EzMaxFocus); TGraph *gEzMaxLU = new TGraph(Nsim,Current,EzMaxLU); TGraph *gEzMaxLO = new TGraph(Nsim,Current,EzMaxLO); TGraph *gEzMaxUseBO = new TGraph(Nsim,Current,EzMaxUseBO); TGraph *gEzMaxBeamLO = new TGraph(Nsim,Current,EzMaxBeamLO); TGraph *gDeltaPsi = new TGraph(Nsim,Current,DeltaPsi); TGraph *gDeltaPsiFocus = new TGraph(Nsim,Current,DeltaPsiFocus); TGraph *gDeltaPsiLO = new TGraph(Nsim,Current,DeltaPsiLO); TGraph *gDeltaPsiLU = new TGraph(Nsim,Current,DeltaPsiLU); TGraph *gEzSlope = new TGraph(Nsim,Current,EzSlope); TGraph *gEzSlopeMaxFocus = new TGraph(Nsim,Current,EzSlopeMaxFocus); TGraph *gEzSlopeLO = new TGraph(Nsim,Current,EzSlopeLO); TGraph *gTransRatio = new TGraph(Nsim,Current,TransRatio); TGraph *gTransRatioFocus = new TGraph(Nsim,Current,TransRatioFocus); // Int_t color1 = kMagenta-8; // Int_t color2 = kMagenta-2; // Int_t color3 = kMagenta-4; // Int_t color4 = kAzure+1; // Int_t color5 = kGray+2; // Int_t markersty = 20; // Float_t markersiz = 1.0; // Int_t linewit = 2; Int_t color1 = kGray+3; Int_t color2 = kGray+2; Int_t color3 = kAzure+1; Int_t color4 = kRed; Int_t color5 = kGray+1; Int_t markersty = 20; Float_t markersiz = 1.0; Int_t linewit = 1; gRadiusX->SetLineColor(color1); gRadiusX->SetLineWidth(linewit); gRadiusX->SetMarkerColor(color1); gRadiusX->SetMarkerStyle(markersty); gRadiusX->SetMarkerSize(markersiz); gRadiusLU->SetLineColor(color1); gRadiusLU->SetLineWidth(1); gRadiusLU->SetLineStyle(4); gRadiusLU->SetMarkerColor(color1); gRadiusLU->SetMarkerStyle(markersty); gRadiusLU->SetMarkerSize(0.0); gRadiusZ->SetLineColor(color2); gRadiusZ->SetLineWidth(linewit); gRadiusZ->SetMarkerColor(color2); gRadiusZ->SetMarkerStyle(markersty); gRadiusZ->SetMarkerSize(markersiz); gRadiusLO->SetLineColor(color2); gRadiusLO->SetLineWidth(1); gRadiusLO->SetLineStyle(3); gRadiusLO->SetMarkerColor(color2); gRadiusLO->SetMarkerStyle(markersty); gRadiusLO->SetMarkerSize(0.0); gRadiusPsi->SetLineColor(color3); gRadiusPsi->SetLineWidth(linewit); gRadiusPsi->SetMarkerColor(color3); gRadiusPsi->SetMarkerStyle(markersty); gRadiusPsi->SetMarkerSize(markersiz); gEzMax->SetLineColor(color2); gEzMax->SetLineWidth(linewit); gEzMax->SetMarkerColor(color2); gEzMax->SetMarkerStyle(markersty); gEzMax->SetMarkerSize(markersiz); gEzMaxUse->SetLineColor(color2); gEzMaxUse->SetLineWidth(linewit); gEzMaxUse->SetMarkerColor(color2); gEzMaxUse->SetMarkerStyle(markersty); gEzMaxUse->SetMarkerSize(markersiz); gEzLimit->SetLineColor(color3); gEzLimit->SetLineWidth(linewit); gEzLimit->SetMarkerColor(color3); gEzLimit->SetMarkerStyle(markersty); gEzLimit->SetMarkerSize(markersiz); gEzMaxFocus->SetLineColor(color1); gEzMaxFocus->SetLineWidth(linewit); gEzMaxFocus->SetMarkerColor(color1); gEzMaxFocus->SetMarkerStyle(markersty); gEzMaxFocus->SetMarkerSize(markersiz); gEzSlope->SetLineColor(color2); gEzSlope->SetLineWidth(linewit); gEzSlope->SetMarkerColor(color2); gEzSlope->SetMarkerStyle(markersty); gEzSlope->SetMarkerSize(markersiz); gEzSlopeMaxFocus->SetLineColor(color1); gEzSlopeMaxFocus->SetLineWidth(linewit); gEzSlopeMaxFocus->SetMarkerColor(color1); gEzSlopeMaxFocus->SetMarkerStyle(markersty); gEzSlopeMaxFocus->SetMarkerSize(markersiz); gEzSlopeLO->SetLineColor(color2); gEzSlopeLO->SetLineWidth(1); gEzSlopeLO->SetLineStyle(3); gEzSlopeLO->SetMarkerColor(color2); gEzSlopeLO->SetMarkerStyle(markersty); gEzSlopeLO->SetMarkerSize(0); gDeltaPsi->SetLineColor(color2); gDeltaPsi->SetLineWidth(linewit); gDeltaPsi->SetMarkerColor(color2); gDeltaPsi->SetMarkerStyle(markersty); gDeltaPsi->SetMarkerSize(markersiz); gDeltaPsiFocus->SetLineColor(color1); gDeltaPsiFocus->SetLineWidth(linewit); gDeltaPsiFocus->SetMarkerColor(color1); gDeltaPsiFocus->SetMarkerStyle(markersty); gDeltaPsiFocus->SetMarkerSize(markersiz); gEzMaxBeam->SetLineColor(color4); gEzMaxBeam->SetLineWidth(linewit); gEzMaxBeam->SetMarkerColor(color4); gEzMaxBeam->SetMarkerStyle(markersty); gEzMaxBeam->SetMarkerSize(markersiz); gRadiusPsiBO->SetLineColor(color3); gRadiusPsiBO->SetLineWidth(1); gRadiusPsiBO->SetLineStyle(3); gRadiusPsiBO->SetMarkerColor(color3); gRadiusPsiBO->SetMarkerStyle(markersty); gRadiusPsiBO->SetMarkerSize(0.0); gEzMaxLU->SetLineColor(color5); gEzMaxLU->SetLineWidth(1); gEzMaxLU->SetLineStyle(4); gEzMaxLU->SetMarkerColor(color5); gEzMaxLU->SetMarkerStyle(markersty); gEzMaxLU->SetMarkerSize(0.0); gEzMaxLO->SetLineColor(color2); gEzMaxLO->SetLineWidth(1); gEzMaxLO->SetLineStyle(3); gEzMaxLO->SetMarkerColor(color2); gEzMaxLO->SetMarkerStyle(markersty); gEzMaxLO->SetMarkerSize(0.0); gEzMaxUseBO->SetLineColor(color3); gEzMaxUseBO->SetLineWidth(1); gEzMaxUseBO->SetLineStyle(3); gEzMaxUseBO->SetMarkerColor(color3); gEzMaxUseBO->SetMarkerStyle(markersty); gEzMaxUseBO->SetMarkerSize(0.0); gEzMaxBeamLO->SetLineColor(color4); gEzMaxBeamLO->SetLineWidth(1); gEzMaxBeamLO->SetLineStyle(3); gEzMaxBeamLO->SetMarkerColor(color4); gEzMaxBeamLO->SetMarkerStyle(markersty); gEzMaxBeamLO->SetMarkerSize(0.0); gDeltaPsiLO->SetLineColor(color2); gDeltaPsiLO->SetLineWidth(1); gDeltaPsiLO->SetLineStyle(3); gDeltaPsiLO->SetMarkerColor(color2); gDeltaPsiLO->SetMarkerStyle(markersty); gDeltaPsiLO->SetMarkerSize(0.0); gDeltaPsiLU->SetLineColor(color2); gDeltaPsiLU->SetLineWidth(1); gDeltaPsiLU->SetLineStyle(4); gDeltaPsiLU->SetMarkerColor(color2); gDeltaPsiLU->SetMarkerStyle(markersty); gDeltaPsiLU->SetMarkerSize(0.0); gTransRatio->SetLineColor(color2); gTransRatio->SetLineWidth(linewit); gTransRatio->SetMarkerColor(color2); gTransRatio->SetMarkerStyle(markersty); gTransRatio->SetMarkerSize(markersiz); gTransRatioFocus->SetLineColor(color1); gTransRatioFocus->SetLineWidth(linewit); gTransRatioFocus->SetMarkerColor(color1); gTransRatioFocus->SetMarkerStyle(markersty); gTransRatioFocus->SetMarkerSize(markersiz); // Canvas setup // Create the canvas and the pads before the Frame loop // Resolution: Int_t sizex = 800; Int_t sizey = 1000; char cName[32]; sprintf(cName,"C"); TCanvas *C = (TCanvas*) gROOT->FindObject(cName); if(C==NULL) C = new TCanvas("C","",sizex,sizey); C->cd(); C->Clear(); // Setup Pad layout: const Int_t Npads = 5; // Text objects // TPaveText **textLabel = new TPaveText*[Npads]; TPad **pad = new TPad*[Npads]; TH1F *hFrame[Npads]; TGaxis *axis[Npads]; TLegend *Leg[Npads]; // Setup Pad layout: Double_t lMargin = 0.14; Double_t rMargin = 0.05; Double_t bMargin = 0.10; Double_t tMargin = 0.04; Float_t mMargin = 0.01; PGlobals::CanvasPartition(C,Npads,lMargin,rMargin,bMargin,tMargin,mMargin); //PGlobals::CanvasAsymPartition(C,Npads,lMargin,rMargin,bMargin,tMargin,1.,mMargin); // Define the frames for plotting Int_t fonttype = 43; Int_t fontsize = 24; Int_t tfontsize = 28; Float_t txoffset = 3.8; Float_t lxoffset = 0.02; Float_t tyoffset = 2.0; Float_t lyoffset = 0.01; Float_t tylength = 0.02; Float_t txlength = 0.04; for(Int_t i=0;i<Npads;i++) { char name[16]; sprintf(name,"pad_%i",i); pad[i] = (TPad*) gROOT->FindObject(name); pad[i]->SetFrameLineWidth(2); // pad[i]->SetTickx(1); // pad[i]->SetTicky(1); sprintf(name,"hFrame_%i",i); hFrame[i] = (TH1F*) gROOT->FindObject(name); if(hFrame[i]) delete hFrame[i]; hFrame[i] = new TH1F(name,"",100,xMin,xMax); hFrame[i]->Reset(); Float_t xFactor = pad[0]->GetAbsWNDC()/pad[i]->GetAbsWNDC(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[i]->GetAbsHNDC(); // Format for y axis hFrame[i]->GetYaxis()->SetTitleFont(fonttype); hFrame[i]->GetYaxis()->SetTitleSize(tfontsize); hFrame[i]->GetYaxis()->SetTitleOffset(tyoffset); hFrame[i]->GetYaxis()->SetLabelFont(fonttype); hFrame[i]->GetYaxis()->SetLabelSize(fontsize); hFrame[i]->GetYaxis()->SetLabelOffset(lyoffset); hFrame[i]->GetYaxis()->SetTickLength(xFactor*tylength/yFactor); hFrame[i]->GetYaxis()->CenterTitle(); // Format for x axis hFrame[i]->GetXaxis()->SetTitleFont(fonttype); hFrame[i]->GetXaxis()->SetTitleSize(tfontsize+2); hFrame[i]->GetXaxis()->SetTitleOffset(txoffset); hFrame[i]->GetXaxis()->SetLabelFont(fonttype); hFrame[i]->GetXaxis()->SetLabelSize(fontsize+2); hFrame[i]->GetXaxis()->SetLabelOffset(lxoffset); hFrame[i]->GetXaxis()->CenterTitle(); hFrame[i]->GetXaxis()->SetTickLength(yFactor*txlength/xFactor); } C->cd(0); pad[0]->Draw(); pad[0]->cd(); // gPad->SetLogx(1); Float_t yMin = minTR - (maxTR-minTR)*0.2; Float_t yMax = maxTR + (maxTR-minTR)*0.2; if(yMin<0.0) yMin = 0.001; hFrame[0]->GetYaxis()->SetRangeUser(yMin,yMax); hFrame[0]->GetXaxis()->SetTitle("#Lambda_{b}"); if(opt.Contains("kA")) hFrame[0]->GetXaxis()->SetTitle("I_{b}^{ 0} [kA]"); hFrame[0]->GetYaxis()->SetTitle("R"); hFrame[0]->Draw("AXIS"); // if(opt.Contains("theo")) { // gDeltaPsiLO->Draw("PL"); // gDeltaPsiLU->Draw("PL"); // } gTransRatio->Draw("PL"); gTransRatioFocus->Draw("PL"); Int_t fontsizeleg = 20; if(opt.Contains("leg")) { Leg[0]=new TLegend(1 - gPad->GetRightMargin() - 0.26, gPad->GetBottomMargin() + 0.40, 1 - gPad->GetRightMargin() - 0.02, gPad->GetBottomMargin() + 0.55); PGlobals::SetPaveStyle(Leg[0]); Leg[0]->SetTextAlign(13); Leg[0]->SetTextColor(kGray+3); Leg[0]->SetTextFont(43); Leg[0]->SetTextSizePixels(fontsizeleg); Leg[0]->SetLineColor(1); Leg[0]->SetBorderSize(0); Leg[0]->SetFillColor(0); Leg[0]->SetFillStyle(1001); Leg[0]->SetFillStyle(0); // Hollow Leg[0]->AddEntry(gTransRatio,"Max R","LP"); Leg[0]->AddEntry(gTransRatioFocus,"Max R in focus","LP"); Leg[0]->Draw(); } C->cd(0); pad[1]->Draw(); pad[1]->cd(); // gPad->SetLogx(1); yMin = minPsi - (maxPsi-minPsi)*0.2; yMax = maxPsi + (maxPsi-minPsi)*0.2; //if(yMin<0.0) yMin = 0.001; hFrame[1]->GetYaxis()->SetRangeUser(yMin,yMax); hFrame[1]->GetXaxis()->SetTitle("#Lambda_{b}"); if(opt.Contains("kA")) hFrame[1]->GetXaxis()->SetTitle("I_{b} [kA]"); hFrame[1]->GetYaxis()->SetTitle("#Delta#psi"); hFrame[1]->Draw("AXIS"); TLine *line1 = new TLine(xMin,1.0,xMax,1.0); line1->SetLineColor(kGray+2); line1->SetLineStyle(2); line1->Draw(); if(opt.Contains("theo")) { gDeltaPsiLO->Draw("PL"); gDeltaPsiLU->Draw("PL"); } gDeltaPsi->Draw("PL"); gDeltaPsiFocus->Draw("PL"); if(opt.Contains("leg")) { Leg[1]=new TLegend(gPad->GetLeftMargin() + 0.03, 1 - gPad->GetTopMargin() - 0.32, gPad->GetLeftMargin() + 0.24, 1 - gPad->GetTopMargin() - 0.08); PGlobals::SetPaveStyle(Leg[1]); Leg[1]->SetTextAlign(13); Leg[1]->SetTextColor(kGray+3); Leg[1]->SetTextFont(43); Leg[1]->SetTextSizePixels(fontsizeleg); Leg[1]->SetLineColor(1); Leg[1]->SetBorderSize(0); Leg[1]->SetFillColor(0); Leg[1]->SetFillStyle(1001); Leg[1]->SetFillStyle(0); // Hollow Leg[1]->AddEntry(gDeltaPsi,"Max #Delta#psi","LP"); Leg[1]->AddEntry(gDeltaPsiFocus,"Max #Delta#psi in focus","LP"); // Leg[1]->AddEntry(gDeltaPsiLO,"Max #Psi Lotov","L"); // Leg[1]->AddEntry(gDeltaPsiLU,"Max #Psi Lu","L"); Leg[1]->Draw(); } C->cd(0); pad[2]->Draw(); pad[2]->cd(); // gPad->SetLogx(1); yMin = minEz - (maxEz-minEz)*0.2; yMax = maxEz + (maxEz-minEz)*0.2; if(yMin<=0.0) yMin = -0.999; hFrame[2]->GetYaxis()->SetRangeUser(yMin,yMax); hFrame[2]->GetYaxis()->SetTitle("|E_{z}/E_{0}|"); hFrame[2]->Draw("AXIS"); TLine *line0 = new TLine(xMin,0.0,xMax,0.0); line0->SetLineColor(kGray+2); line0->SetLineStyle(2); line0->Draw(); if(opt.Contains("theo")) { gEzMaxLO->Draw("PL"); //gEzMaxUseBO->Draw("PL"); gEzMaxBeamLO->Draw("PL"); // gEzMaxLU->Draw("PL"); } gEzMax->Draw("PL"); // gEzMaxUse->Draw("PL"); gEzMaxBeam->Draw("PL"); gEzLimit->Draw("PL"); gEzMaxFocus->Draw("PL"); if(opt.Contains("leg")) { Leg[2]=new TLegend(gPad->GetLeftMargin() + 0.03, 1 - gPad->GetTopMargin() - 0.4, gPad->GetLeftMargin() + 0.24, 1 - gPad->GetTopMargin() - 0.04); PGlobals::SetPaveStyle(Leg[2]); Leg[2]->SetTextAlign(13); Leg[2]->SetTextColor(kGray+3); Leg[2]->SetTextFont(43); Leg[2]->SetTextSizePixels(fontsizeleg-2); Leg[2]->SetLineColor(1); Leg[2]->SetBorderSize(0); Leg[2]->SetFillColor(0); Leg[2]->SetFillStyle(1001); Leg[2]->SetFillStyle(0); // Hollow Leg[2]->AddEntry(gEzMax,"Min E_{z}","LP"); Leg[2]->AddEntry(gEzMaxFocus,"Min E_{z} in focus","LP"); Leg[2]->AddEntry(gEzLimit,"Min E_{z} trapping","LP"); Leg[2]->AddEntry(gEzMaxBeam,"Max E_{z} beam","LP"); Leg[2]->Draw(); } C->cd(0); pad[3]->Draw(); pad[3]->cd(); // gPad->SetLogx(1); yMin = minEzSlope - (maxEzSlope-minEzSlope)*0.25; yMax = maxEzSlope + (maxEzSlope-minEzSlope)*0.25; if(yMin<=0.0) yMin = -0.999; // hFrame[3]->GetYaxis()->SetRangeUser(yMin,yMax); hFrame[3]->GetYaxis()->SetRangeUser(-0.0499,0.5499); hFrame[3]->GetYaxis()->SetNdivisions(510); hFrame[3]->GetYaxis()->SetTitle("#partial_{#zeta}E_{z}^{0}/k_{p}E_{0}"); hFrame[3]->Draw("AXIS"); TLine *line05 = new TLine(xMin,0.5,xMax,0.5); line05->SetLineColor(kGray+2); line05->SetLineStyle(2); line05->Draw(); line0->Draw(); if(opt.Contains("theo")) { // gEzSlopeLO->Draw("PL"); } gEzSlope->Draw("PL"); // gEzSlopeMaxFocus->Draw("PL"); if(opt.Contains("leg")) { Leg[3]=new TLegend(1 - gPad->GetRightMargin() - 0.26, gPad->GetBottomMargin() + 0.14,1- gPad->GetRightMargin() - 0.02, gPad->GetBottomMargin() + 0.24); PGlobals::SetPaveStyle(Leg[3]); Leg[3]->SetTextAlign(12); Leg[3]->SetTextColor(kGray+3); Leg[3]->SetTextFont(43); Leg[3]->SetTextSizePixels(fontsizeleg); Leg[3]->SetLineColor(1); Leg[3]->SetBorderSize(0); Leg[3]->SetFillColor(0); Leg[3]->SetFillStyle(1001); Leg[3]->SetFillStyle(0); // Hollow Leg[3]->AddEntry(gEzSlope,"E_{z} slope at #zeta_{m}","LP"); Leg[3]->Draw(); } C->cd(0); pad[4]->Draw(); pad[4]->cd(); // gPad->SetLogx(1); yMin = minRadius - (maxRadius-minRadius)*0.2; yMax = maxRadius + (maxRadius-minRadius)*0.2; if(yMin<=0.0) yMin = -0.999; hFrame[4]->GetYaxis()->SetRangeUser(yMin,yMax); hFrame[4]->GetYaxis()->SetTitle("k_{p} x"); hFrame[4]->Draw("AXIS"); line0->Draw(); if(opt.Contains("theo")) { gRadiusLO->Draw("PL"); gRadiusLU->Draw("PL"); // gRadiusPsiBO->Draw("PL"); } gRadiusPsi->Draw("PL"); gRadiusX->Draw("PL"); gRadiusZ->Draw("PL"); if(opt.Contains("leg")) { Leg[4]=new TLegend(1 - gPad->GetRightMargin() - 0.15, gPad->GetBottomMargin() + 0.15, 1 - gPad->GetRightMargin() + 0.09, gPad->GetBottomMargin() + 0.45); PGlobals::SetPaveStyle(Leg[4]); Leg[4]->SetTextAlign(12); Leg[4]->SetTextColor(kGray+3); Leg[4]->SetTextFont(43); Leg[4]->SetTextSizePixels(fontsizeleg); Leg[4]->SetLineColor(1); Leg[4]->SetBorderSize(0); Leg[4]->SetFillColor(0); Leg[4]->SetFillStyle(1001); Leg[4]->SetFillStyle(0); // Hollow // Leg[4]->AddEntry(gRadiusZ,"Longitudinal radius","LP"); // Leg[4]->AddEntry(gRadiusX,"Transverse radius","LP"); // Leg[4]->AddEntry(gRadiusPsi,"Trapping radius","LP"); Leg[4]->AddEntry(gRadiusZ,"l_{m}","LP"); Leg[4]->AddEntry(gRadiusX,"r_{m}","LP"); Leg[4]->AddEntry(gRadiusPsi,"l_{t}","LP"); Leg[4]->Draw(); } C->cd(); // Output file TString fOutName = Form("./Blowout/Blowout-Scalings"); fOutName += Form("_%i",time); PGlobals::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void drawCMSresponse() { // New style settings // #include "tdrstyle_mod14.C" setTDRStyle(); // call cmsPrel(iPeriod, iPos); // int iPeriod = 2; // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV // second parameter in example_plot is iPos, which drives the position of the CMS logo in the plot // iPos=11 : top-left, left-aligned // iPos=33 : top-right, right-aligned // iPos=22 : center, centered // mode generally : // iPos = 10*(alignement 1/2/3) + position (1/2/3 = left/center/right) if (!_jec) { const char *sd = "CondFormats/JetMETObjects/data"; const char *st = "Winter14_V5_MC"; const char *s; //s = Form("%s/%s_L1FastJet_AK5PFchs.txt",sd,st); cout << s << endl; //JetCorrectorParameters *l1 = new JetCorrectorParameters(s); s = Form("%s/%s_L2Relative_AK5PFchs.txt",sd,st); cout << s << endl; JetCorrectorParameters *l2 = new JetCorrectorParameters(s); s = Form("%s/%s_L3Absolute_AK5PFchs.txt",sd,st); cout << s << endl; JetCorrectorParameters *l3 = new JetCorrectorParameters(s); vector<JetCorrectorParameters> v; //v.push_back(l1); v.push_back(*l2); v.push_back(*l3); _jec = new FactorizedJetCorrector(v); } if (!_jecpt) { _jecpt = new TF1("jecpt",fJECPt,0,4000,3); } //double ergs[] = {30, 60, 110, 400, 2000}; //const int ne = sizeof(ergs)/sizeof(ergs[0]); double pts[] = {10, 30, 100, 400, 2000}; const int npt = sizeof(pts)/sizeof(pts[0]); const int neta = 48;//52; const int jeta = TMath::Pi()*0.5*0.5; const int mu = 0; TGraph *gs[npt]; //for (int ie = 0; ie != ne; ++ie) { for (int ipt = 0; ipt != npt; ++ipt) { //double energy = ergs[ie]; double pt = pts[ipt]; TGraph *g = new TGraph(0); gs[ipt] = g; for (int ieta = 0; ieta != neta; ++ieta) { double eta = (ieta+0.5)*0.1; //double pt = energy / cosh(eta); double energy = pt * cosh(eta); if (pt >= 10. && energy < 4000.) { double jes = getResp(pt, eta, jeta, mu); int n = g->GetN(); g->SetPoint(n, eta, jes); } } // for ie } // for ieta // Draw results TH1D *h = new TH1D("h",";Jet |#eta|;Simulated jet response",40,0,4.8); h->SetMaximum(1.25); h->SetMinimum(0.5); TCanvas *c1 = tdrCanvas("c1",h,2,0,kSquare); TLegend *leg1 = tdrLeg(0.25,0.25,0.55,0.30); TLegend *leg2 = tdrLeg(0.25,0.20,0.55,0.25); TLegend *leg3 = tdrLeg(0.25,0.15,0.55,0.20); TLegend *leg4 = tdrLeg(0.55,0.25,0.85,0.30); TLegend *leg5 = tdrLeg(0.55,0.20,0.85,0.25); TLegend *legs[npt] = {leg1, leg2, leg3, leg4, leg5}; int colors[] = {kGreen+2, kBlack, kOrange+1, kBlue, kRed+1}; int markers[] = {kFullCircle, kOpenCircle, kFullSquare, kOpenSquare, kFullTriangleUp}; for (int ipt = 0; ipt != npt; ++ipt) { TGraph *g = gs[ipt]; g->SetMarkerColor(colors[ipt]); g->SetMarkerStyle(markers[ipt]); g->Draw("SAMEP"); //TLegend *leg = (ie<3 ? leg1 : leg2); TLegend *leg = legs[ipt]; leg->SetTextColor(colors[ipt]); //leg->AddEntry(g, Form("E = %1.0f GeV",ergs[ie]), "P"); leg->AddEntry(g, Form("p_{T} = %1.0f GeV",pts[ipt]), "P"); } TLatex *tex = new TLatex(); tex->SetNDC(); tex->SetTextSize(0.045); TLine *l = new TLine(); l->DrawLine(1.3,0.7,1.3,1.1); l->DrawLine(2.5,0.7,2.5,1.1); l->DrawLine(3.0,0.7,3.0,1.1); l->DrawLine(4.5,0.7,4.5,1.1); l->SetLineStyle(kDashed); l->DrawLine(3.2,0.7,3.2,1.1); tex->DrawLatex(0.30,0.86,"2012 JES: Anti-k_{t} R = 0.5, PF+CHS"); tex->DrawLatex(0.19,0.78,"Barrel"); tex->DrawLatex(0.47,0.78,"Endcap"); //0.42 tex->DrawLatex(0.73,0.78,"Forward"); tex->DrawLatex(0.21,0.73,"BB"); tex->DrawLatex(0.43,0.73,"EC1"); tex->DrawLatex(0.57,0.73,"EC2"); tex->DrawLatex(0.77,0.73,"HF"); c1->SaveAs("pdf/drawCMSresponse.pdf"); } // drawCMSresponse
void bjetefficiency() { std::vector<string> samples_; //samples_.push_back("WPHJET.root"); //samples_.push_back("WW.root"); //samples_.push_back("WZ.root"); //samples_.push_back("ZZ.root"); samples_.push_back("SIGNALtGC.root"); samples_.push_back("SIGNALtGu.root"); //open files std::vector<TFile*> files; for(unsigned int idx=0; idx<samples_.size(); ++idx){ files.push_back(new TFile(samples_[idx].c_str()));} std::vector<string> variables2_; /* variables2_.push_back("btageffL"); variables2_.push_back("btageffM"); variables2_.push_back("btageffT"); variables2_.push_back("ctageffL"); variables2_.push_back("ctageffM"); variables2_.push_back("ctageffT"); */ variables2_.push_back("btageffL"); variables2_.push_back("btageffM"); variables2_.push_back("btageffT"); std::vector<double> finaleff; Double_t bdiscriminator[35]; for (unsigned int i=0; i<15; ++i){ bdiscriminator[i] =0.244-0.1+i*0.02; } for (unsigned int i=0; i<10; ++i){ bdiscriminator[15+i] = 0.679-0.1+i*0.02;} for (unsigned int i=0; i<10; ++i){ bdiscriminator[25+i] = 0.898-0.1+i*0.02;} Double_t count[3]; count[0]=15; count[1]=10; count[2]=10; for(unsigned int ii=0; ii<variables2_.size(); ++ii){ std::vector<TH1F*> hists; for(unsigned int idx=0; idx<files.size(); ++idx){hists.push_back((TH1F*)files[idx]->Get((std::string("STEP1/").append(variables2_[ii]).c_str())));} for(unsigned int idx=1; idx<files.size(); ++idx){ hists[idx]->Add(hists[idx-1]);} //hists[files.size()-1]->Draw(); std::vector<double> eff; int bin; for ( bin=1; bin<count[ii]*2+1; ++bin){eff.push_back(hists[files.size()-1]->GetBinContent(bin));} for (unsigned int i=0; i<count[ii]; ++i){finaleff.push_back(eff[2*i+1]/(eff[2*i]+eff[2*i+1])); //cout<< eff[2*i+1]<<" "<<eff[2*i+1]/(eff[2*i]+eff[2*i+1])<<endl; } } // TGraph *gr = new TGraph(30,bdiscriminator,finaleff); Double_t effi[35]; for (unsigned int i=0; i<35; ++i){ effi[i] =finaleff[i]; } TGraph *gr = new TGraph(35,effi,bdiscriminator); TGraph *grREV = new TGraph(35,bdiscriminator,effi); cout<<"the new working points for nominal SF"<<endl; cout<<"loose "<<gr->Eval(1.008*grREV->Eval(0.244))<<endl; cout<<"medium "<<gr->Eval(0.963*grREV->Eval(0.679))<<endl; cout<<"tight "<<gr->Eval(0.947*grREV->Eval(0.898))<<endl; cout<<"the new working points for SF UP"<<endl; cout<<"loose "<<gr->Eval((1.008+0.023)*grREV->Eval(0.244))<<endl; cout<<"medium "<<gr->Eval((0.963+0.020)*grREV->Eval(0.679))<<endl; cout<<"tight "<<gr->Eval((0.947+0.025)*grREV->Eval(0.898))<<endl; cout<<"the new working points for SF DOWN"<<endl; cout<<"loose "<<gr->Eval((1.008-0.023)*grREV->Eval(0.244))<<endl; cout<<"medium "<<gr->Eval((0.963-0.020)*grREV->Eval(0.679))<<endl; cout<<"tight "<<gr->Eval((0.947-0.025)*grREV->Eval(0.898))<<endl; // cout<<gr->Eval(1.008*grREV->Eval(0.244))<<endl; // cout<<gr->Eval(0.966*grREV->Eval(0.679))<<endl; // cout<<gr->Eval(0.931*grREV->Eval(0.898))<<endl; // cout<<gr->Eval(0.0990)<<endl; // cout<<gr->Eval(0.0142)<<endl; // cout<<gr->Eval(0.00155)<<endl; // cout<<gr->Eval(0.0142)<<endl; // cout<<gr->Eval(0.0016)<<endl; gr->SetLineColor(4); gr->SetLineWidth(4); gr->SetMarkerColor(4); gr->SetMarkerStyle(21); gr->Draw("AP"); }
void gptoy(){ int n = 100; TRandom3 rand(0); // sampling points double x [n]; for(int i=0; i < n; i++) x[i] = 1.0*i/n; // construct covariance matrix TMatrixD C(n,n); for(int i=0; i < n; i++) for(int j=0; j < n; j++) C[i][j] = kern(x[i],x[j],1); // add small number to diagonal (positive definite) for(int i=0; i < n; i++) C[i][i] += 0.00001; // use Cholesky decomposition to obtain vector distributed as multivariate gaussian TDecompChol D(C); TMatrixD L(n,n); L = D.GetU(); // random rumbers TVectorD u(n); for(int i=0; i < n; i++) u[i] = rand.Gaus(0,1); // result -- random vector TVectorD y(n); y = L*u; // plot /* TGraph *grand = new TGraph(); for(int i=0; i < n; i++){ grand->SetPoint(i, x[i], y[i]); } grand->SetLineWidth(2); grand->Draw("ACP"); */ // // prediction w/ noise-free observables // int m = 6; double t [m]; t[0] = 0.05; t[1] = 0.29; t[2] = 0.31; t[3] = 0.50; t[4] = 0.75; t[5] = 0.95; TVectorD ft(m); ft[0] = 1.0; ft[1] = 1.0; ft[2] = 2.0; ft[3] = 1.0; ft[4] = 1.0; ft[5] = 1.0; TMatrixD K11(m,m); TMatrixD K12(m,n); TMatrixD K21(n,m); TMatrixD K22(n,n); for(int i=0; i < n; i++){ for(int j=0; j < n; j++){ if( i < m and j < m ){ K11[i][j] = kern(t[i],t[j],1); if( i==j ) K11[i][j] += 0.00001; } if( i < m and j < n ){ K12[i][j] = kern(t[i],x[j],1); if( i==j ) K12[i][j] += 0.00001; } if( i < n and j < m ){ K21[i][j] = kern(x[i],t[j],1); if( i==j ) K21[i][j] += 0.00001; } if( i < n and j < n ){ K22[i][j] = kern(x[i],x[j],1); if( i==j ) K22[i][j] += 0.00001; } } } K11[2][2] += 0.1; // use Cholesky decomposition to obtain vector distributed as multivariate gaussian // compute covariance matrix TMatrixD fC(n,n); TMatrixD K11inv(m,m); K11inv = K11; K11inv.Invert(); fC = K22 - K21*K11inv*K12; TDecompChol fD(fC); TMatrixD fL(n,n); fL = fD.GetU(); // // result // TVectorD v(n); TVectorD fy(n); TVectorD fy_err(n); // mean value and error band for(int i=0; i < n; i++) v[i] = 1.0; fy = K21*K11inv*ft; fy_err = fL*v; TGraphErrors *gtest = new TGraphErrors(); for(int i=0; i < n; i++){ gtest->SetPoint(i, x[i], fy[i]); gtest->SetPointError(i, 0.0, fy_err[i]); } TCanvas * canvas = new TCanvas("canvas","canvas",800,800); canvas->cd(); TGraph *gtrain = new TGraph(); for(int i=0; i < m; i++) gtrain->SetPoint(i, t[i], ft[i]); gtest->SetFillStyle(3002); gtest->SetMinimum(-3.5); gtest->SetMaximum(4.5); gtest->Draw("AC3"); gtrain->SetMarkerStyle(20); gtrain->SetMarkerColor(2); gtrain->Draw("P"); canvas->Draw(); return; }
int main (int argc, char** argv) { TChain *chain = new TChain ("myanalysis/EcalAnalysisTree") ; // input files chain->Add("/tmp/malberti/SpikesCommissioning10_GOODCOLLV8.root"); chain->Add("/tmp/malberti/SpikesCommissioning10_Apr1Skim_GOODCOLL-v1.root"); int nEntries = chain->GetEntries () ; std::cout << "FOUND " << nEntries << " ENTRIES\n" ; //ecalVariables variables unsigned int BX; unsigned int lumiId; unsigned int runId; unsigned int eventId; unsigned int eventNaiveId; int nEcalRecHits; float ecalRecHitType[1000]; float ecalRecHitEnergy[1000]; float ecalRecHitOutOfTimeEnergy[1000]; float ecalRecHitIEta[1000]; float ecalRecHitIPhi[1000]; float ecalRecHitTime[1000]; float ecalRecHitChi2[1000]; float ecalRecHitOutOfTimeChi2[1000]; int ecalRecHitRawId[1000]; float ecalRecHitCoeff[1000]; int ecalRecHitRecoFlag[1000]; float ecalRecHitR9[1000]; float ecalRecHitS4oS1[1000]; float ecalRecHitIso03[1000][2]; float ecalRecHitIso04[1000][2]; int ecalDigis[1000][10]; int ecalGainId[1000][10]; float ecalRecHitMatrix[1000][5][5]; float ecalRecHitMatrixFlag[1000][5][5]; // L1 trigger variables int techL1Bit[64]; int algoL1Bit[128]; chain -> SetBranchAddress("BX", &BX); chain -> SetBranchAddress("lumiId", &lumiId); chain -> SetBranchAddress("runId", &runId); chain -> SetBranchAddress("eventId", &eventId); chain -> SetBranchAddress("eventNaiveId", &eventNaiveId); chain -> SetBranchAddress("nEcalRecHits", &nEcalRecHits); chain -> SetBranchAddress("ecalRecHitType", ecalRecHitType); chain -> SetBranchAddress("ecalRecHitEnergy", ecalRecHitEnergy); chain -> SetBranchAddress("ecalRecHitOutOfTimeEnergy", ecalRecHitOutOfTimeEnergy); chain -> SetBranchAddress("ecalRecHitIEta", ecalRecHitIEta); chain -> SetBranchAddress("ecalRecHitIPhi", ecalRecHitIPhi); chain -> SetBranchAddress("ecalRecHitTime", ecalRecHitTime); chain -> SetBranchAddress("ecalRecHitChi2", ecalRecHitChi2); chain -> SetBranchAddress("ecalRecHitOutOfTimeChi2", ecalRecHitOutOfTimeChi2); chain -> SetBranchAddress("ecalRecHitRawId", ecalRecHitRawId); chain -> SetBranchAddress("ecalRecHitCoeff", ecalRecHitCoeff); chain -> SetBranchAddress("ecalRecHitRecoFlag", ecalRecHitRecoFlag); chain -> SetBranchAddress("ecalRecHitR9", ecalRecHitR9); chain -> SetBranchAddress("ecalRecHitS4oS1", ecalRecHitS4oS1); chain -> SetBranchAddress("ecalRecHitIso03", ecalRecHitIso03); chain -> SetBranchAddress("ecalRecHitIso04", ecalRecHitIso04); chain -> SetBranchAddress("ecalDigis", ecalDigis); chain -> SetBranchAddress("ecalGainId", ecalGainId); chain -> SetBranchAddress("ecalRecHitMatrix", ecalRecHitMatrix); chain -> SetBranchAddress("ecalRecHitMatrixFlag", ecalRecHitMatrixFlag); chain -> SetBranchAddress("techL1Bit", techL1Bit); chain -> SetBranchAddress("algoL1Bit", algoL1Bit); // output file std::string outputRootName = "spikeEfficiency_3GeV.root" ; // output histos TH1F *hRun = new TH1F("hRun","hRun",300,132400,132700); TH1F *hS1oS9 = new TH1F("hS1oS9","S1oS9 all Rec Hits",120,0,1.2); hS1oS9 -> GetXaxis()-> SetTitle("S1/S9"); TH1F *hTime[2]; hTime[0] = new TH1F("hTimeSpike","hTimeSpike",800,-100,100); hTime[0]->SetLineColor(2); hTime[0]-> GetXaxis()-> SetTitle("t(ns)"); hTime[1] = new TH1F("hTimeNormal","hTimeNormal",800,-100,100); hTime[1]->SetLineColor(3); hTime[1]-> GetXaxis()-> SetTitle("t(ns)"); TH1F *hChi2[2]; hChi2[0] = new TH1F("hChi2Spike","hChi2Spike",100,0,100); hChi2[0] -> SetLineColor(2); hChi2[0] -> GetXaxis()-> SetTitle("chi^{2}"); hChi2[1] = new TH1F("hChi2Normal","hChi2Normal",100,0,100); hChi2[1] ->SetLineColor(3); hChi2[1] -> GetXaxis()-> SetTitle("chi^{2}"); TH1F *hOutOfTimeChi2[2]; hOutOfTimeChi2[0] = new TH1F("hOutOfTimeChi2Spike","hOutOfTimeChi2Spike",100,0,100); hOutOfTimeChi2[0] -> SetLineColor(2); hOutOfTimeChi2[0] -> GetXaxis()-> SetTitle("OutOfTime chi^{2}"); hOutOfTimeChi2[1] = new TH1F("hOutOfTimeChi2Normal","hOutOfTimeChi2Normal",100,0,100); hOutOfTimeChi2[1] ->SetLineColor(3); hOutOfTimeChi2[1] -> GetXaxis()-> SetTitle("OutOfTime chi^{2}"); int nSpikeTot = 0 ; int nNormalTot = 0 ; int nSpikeTotEB[2] = {0} ; int nNormalTotEB[2] = {0} ; int n = 1000; int nSpikeChi2[1000] = {0.}; int nNormalChi2[1000]= {0}; int nSpikeChi2OutOfTime[1000] = {0}; int nNormalChi2OutOfTime[1000]= {0}; int nSpikeTime[1000] = {0}; int nNormalTime[1000]= {0}; int nSpikeChi2EB[1000][2] ; int nNormalChi2EB[1000][2]; int nSpikeChi2OutOfTimeEB[1000][2] ; int nNormalChi2OutOfTimeEB[1000][2]; int nSpikeTimeEB[1000][2] ; int nNormalTimeEB[1000][2]; for (int i = 0; i < n ; i++){ for (int j = 0; j < 2; j++){ nSpikeChi2EB[i][j] = 0; nSpikeChi2OutOfTimeEB[i][j] = 0; nSpikeTimeEB[i][j] = 0; nNormalChi2EB[i][j] = 0; nNormalChi2OutOfTimeEB[i][j] = 0; nNormalTimeEB[i][j] = 0; } } //for time resolution parametrization float N = 31.; float ADCtoGeV = 0.03865 ; float rmsNoise = 1.1; float cterm = 0.7; // loop over entries for (int entry = 0; entry < nEntries; ++entry) { chain->GetEntry (entry) ; if(entry%500000 == 0) std::cout << "event n. " << entry << std::endl; if ((techL1Bit[40]+techL1Bit[41])==0) continue; // c'e' gia' // select the good collisions runs + good lumi sections (no ecal time scans, etc...) bool goodrun = false; if (runId==132440 && lumiId >=86 && lumiId <= 138) goodrun = true; if (runId==132440 && lumiId >=141 && lumiId <= 401) goodrun = true; if (runId==132473 && lumiId >=1 && lumiId <= 29 ) goodrun = true; if (runId==132476 && lumiId >=23 && lumiId <= 28 ) goodrun = true; if (runId==132476 && lumiId >=54 && lumiId <= 57 ) goodrun = true; if (runId==132477 && lumiId >=34 && lumiId <= 35 ) goodrun = true; if (runId==132477 && lumiId >=63 && lumiId <= 64 ) goodrun = true; if (runId==132477 && lumiId >=90 && lumiId <= 93 ) goodrun = true; if (runId==132477 && lumiId >=118 && lumiId <= 121) goodrun = true; if (runId==132477 && lumiId >=148 && lumiId <= 149) goodrun = true; if (runId==132477 && lumiId >=176 && lumiId <= 179) goodrun = true; if (runId==132477 && lumiId >=225 && lumiId <= 236) goodrun = true; if (runId==132477 && lumiId >=368 && lumiId <= 384) goodrun = true; if (runId==132477 && lumiId >=517 && lumiId <= 520) goodrun = true; if (runId==132569 && lumiId >=222 && lumiId <= 224) goodrun = true; if (runId==132569 && lumiId >=310 && lumiId <= 310) goodrun = true; if (runId==132569 && lumiId >=411 && lumiId <= 419) goodrun = true; if (runId==132569 && lumiId >=529 && lumiId <= 582) goodrun = true; if (runId==132596 && lumiId >=383 && lumiId <= 383) goodrun = true; if (runId==132596 && lumiId >=447 && lumiId <= 453) goodrun = true; if (runId==132598 && lumiId >=80 && lumiId <= 82 ) goodrun = true; if (runId==132598 && lumiId >=174 && lumiId <= 188) goodrun = true; if (runId==132599 && lumiId >=1 && lumiId <= 74 ) goodrun = true; if (runId==132601 && lumiId >=261 && lumiId <= 1131)goodrun = true; if (runId==132602 && lumiId >=1 && lumiId <= 83) goodrun = true; if (runId==132605 && lumiId >=446 && lumiId <= 622) goodrun = true; if (runId==132605 && lumiId >=624 && lumiId <= 829) goodrun = true; if (runId==132605 && lumiId >=831 && lumiId <= 968) goodrun = true; if (runId==132606 && lumiId >=1 && lumiId <= 37 ) goodrun = true; if (!goodrun) continue; for (int ihit =0 ; ihit < nEcalRecHits; ihit++){ if (ecalRecHitEnergy[ihit] < 3) continue; // check gain switch bool gainSwitch = false; for (int isample = 0; isample < 10 ; isample++){ if ( (isample > 0 && ecalGainId[ihit][isample]!= ecalGainId[ihit][isample-1]) || ecalGainId[ihit][isample] !=1 ) { gainSwitch = true; break; } } if (gainSwitch) continue; hRun->Fill(runId); // c'e' un canale con problemi? if ( ecalRecHitIEta[ihit]==58 && ecalRecHitIPhi[ihit]==97 && runId==132569) continue; if (ecalRecHitR9[ihit] > 0.95 ) { nSpikeTot++; if (ecalRecHitIEta[ihit] < 0) nSpikeTotEB[0]++; if (ecalRecHitIEta[ihit] > 0) nSpikeTotEB[1]++; hTime[0]->Fill(ecalRecHitTime[ihit]); } if (ecalRecHitR9[ihit] < 0.80 ) { nNormalTot++; if (ecalRecHitIEta[ihit] < 0) nNormalTotEB[0]++; if (ecalRecHitIEta[ihit] > 0) nNormalTotEB[1]++; hTime[1]->Fill(ecalRecHitTime[ihit]); //if (ecalRecHitTime[ihit]> 8) std::cout << ecalRecHitIEta[ihit] << " " << ecalRecHitIPhi[ihit] << " " << runId<< std::endl; } for (int i = 0 ; i < n ; i++){ float chi2cut = (i+1) * 65./n ; // for the time cut , use parametrization by Giovanni et al. float A = ecalRecHitEnergy[ihit]/ADCtoGeV; float sigmat = sqrt(pow(N/(A/rmsNoise),2) + cterm*cterm ); float timecut = (i+1)*20./n; if ( ecalRecHitR9[ihit] > 0.95 ){ if (ecalRecHitChi2[ihit] < chi2cut) nSpikeChi2[i]++; if (ecalRecHitChi2[ihit] < chi2cut && ecalRecHitIEta[ihit] < 0) nSpikeChi2EB[i][0]++; if (ecalRecHitChi2[ihit] < chi2cut && ecalRecHitIEta[ihit] > 0) nSpikeChi2EB[i][1]++; if (ecalRecHitOutOfTimeChi2[ihit] < chi2cut) nSpikeChi2OutOfTime[i]++; if (ecalRecHitOutOfTimeChi2[ihit] < chi2cut && ecalRecHitIEta[ihit] < 0) nSpikeChi2OutOfTimeEB[i][0]++; if (ecalRecHitOutOfTimeChi2[ihit] < chi2cut && ecalRecHitIEta[ihit] > 0) nSpikeChi2OutOfTimeEB[i][1]++; if (fabs(ecalRecHitTime[ihit]/sigmat) < timecut) nSpikeTime[i]++; if (fabs(ecalRecHitTime[ihit]/sigmat ) < timecut && ecalRecHitIEta[ihit] < 0) nSpikeTimeEB[i][0]++; if (fabs(ecalRecHitTime[ihit]/sigmat ) < timecut && ecalRecHitIEta[ihit] > 0) nSpikeTimeEB[i][1]++; } if ( ecalRecHitR9[ihit] < 0.80 ){ if (ecalRecHitChi2[ihit] < chi2cut) nNormalChi2[i]++; if (ecalRecHitChi2[ihit] < chi2cut && ecalRecHitIEta[ihit] < 0) nNormalChi2EB[i][0]++; if (ecalRecHitChi2[ihit] < chi2cut && ecalRecHitIEta[ihit] > 0) nNormalChi2EB[i][1]++; if (ecalRecHitOutOfTimeChi2[ihit] < chi2cut) nNormalChi2OutOfTime[i]++; if (ecalRecHitOutOfTimeChi2[ihit] < chi2cut && ecalRecHitIEta[ihit] < 0) nNormalChi2OutOfTimeEB[i][0]++; if (ecalRecHitOutOfTimeChi2[ihit] < chi2cut && ecalRecHitIEta[ihit] > 0) nNormalChi2OutOfTimeEB[i][1]++; if (fabs(ecalRecHitTime[ihit]/sigmat ) < timecut) nNormalTime[i]++; if (fabs(ecalRecHitTime[ihit]/sigmat ) < timecut && ecalRecHitIEta[ihit] < 0) nNormalTimeEB[i][0]++; if (fabs(ecalRecHitTime[ihit]/sigmat ) < timecut && ecalRecHitIEta[ihit] > 0) nNormalTimeEB[i][1]++; } } } } // loop over entries TGraph *gTime = new TGraph(); gTime->SetMarkerStyle(21); gTime->SetMarkerSize(0.6); gTime->SetMarkerColor(2); TGraph *gChi2 = new TGraph(); gChi2->SetMarkerStyle(21); gChi2->SetMarkerSize(0.6); gChi2->SetMarkerColor(3); TGraph *gOutOfTimeChi2 = new TGraph(); gOutOfTimeChi2->SetMarkerStyle(21); gOutOfTimeChi2->SetMarkerSize(0.6); gOutOfTimeChi2->SetMarkerColor(4); TGraph *gTimeEBP = new TGraph(); gTimeEBP->SetMarkerStyle(20); gTimeEBP->SetMarkerSize(0.7); gTimeEBP->SetMarkerColor(2); TGraph *gChi2EBP = new TGraph(); gChi2EBP->SetMarkerStyle(20); gChi2EBP->SetMarkerSize(0.7); gChi2EBP->SetMarkerColor(3); TGraph *gOutOfTimeChi2EBP = new TGraph(); gOutOfTimeChi2EBP->SetMarkerStyle(20); gOutOfTimeChi2EBP->SetMarkerSize(0.7); gOutOfTimeChi2EBP->SetMarkerColor(4); TGraph *gTimeEBM = new TGraph(); gTimeEBM->SetMarkerStyle(24); gTimeEBM->SetMarkerSize(0.7); gTimeEBM->SetMarkerColor(2); TGraph *gChi2EBM = new TGraph(); gChi2EBM->SetMarkerStyle(24); gChi2EBM->SetMarkerSize(0.7); gChi2EBM->SetMarkerColor(3); TGraph *gOutOfTimeChi2EBM = new TGraph(); gOutOfTimeChi2EBM->SetMarkerStyle(24); gOutOfTimeChi2EBM->SetMarkerSize(0.7); gOutOfTimeChi2EBM->SetMarkerColor(4); float effS, effN; for (int i = 0; i < n ; i++){ effN = (float)nNormalTime[i]/(float)nNormalTot; effS = (float)nSpikeTime[i]/(float)nSpikeTot; gTime->SetPoint(i,effS,effN); effN = (float)nNormalChi2[i]/(float)nNormalTot; effS = (float)nSpikeChi2[i]/(float)nSpikeTot; gChi2->SetPoint(i,effS,effN); effN = (float)nNormalChi2OutOfTime[i]/(float)nNormalTot; effS = (float)nSpikeChi2OutOfTime[i]/(float)nSpikeTot; gOutOfTimeChi2->SetPoint(i,effS,effN); //EB- effN = (float)nNormalTimeEB[i][0]/(float)nNormalTotEB[0]; effS = (float)nSpikeTimeEB[i][0]/(float)nSpikeTotEB[0]; gTimeEBM->SetPoint(i,effS,effN); effN = (float)nNormalChi2EB[i][0]/(float)nNormalTotEB[0]; effS = (float)nSpikeChi2EB[i][0]/(float)nSpikeTotEB[0]; gChi2EBM->SetPoint(i,effS,effN); effN = (float)nNormalChi2OutOfTimeEB[i][0]/(float)nNormalTotEB[0]; effS = (float)nSpikeChi2OutOfTimeEB[i][0]/(float)nSpikeTotEB[0]; gOutOfTimeChi2EBM->SetPoint(i,effS,effN); //EB+ effN = (float)nNormalTimeEB[i][1]/(float)nNormalTotEB[1]; effS = (float)nSpikeTimeEB[i][1]/(float)nSpikeTotEB[1]; gTimeEBP->SetPoint(i,effS,effN); effN = (float)nNormalChi2EB[i][1]/(float)nNormalTotEB[1]; effS = (float)nSpikeChi2EB[i][1]/(float)nSpikeTotEB[1]; gChi2EBP->SetPoint(i,effS,effN); effN = (float)nNormalChi2OutOfTimeEB[i][1]/(float)nNormalTotEB[1]; effS = (float)nSpikeChi2OutOfTimeEB[i][1]/(float)nSpikeTotEB[1]; gOutOfTimeChi2EBP->SetPoint(i,effS,effN); } TFile saving (outputRootName.c_str (),"recreate") ; saving.cd () ; // saving distributions hRun->Write(); gTime->Write("g_Time"); gChi2->Write("g_Chi2"); gOutOfTimeChi2->Write("g_OutOfTimeChi2"); gTimeEBP->Write("g_Time_EBP"); gChi2EBP->Write("g_Chi2_EBP"); gOutOfTimeChi2EBP->Write("g_OutOfTimeChi2_EBP"); gTimeEBM->Write("g_Time_EBM"); gChi2EBM->Write("g_Chi2_EBM"); gOutOfTimeChi2EBM->Write("g_OutOfTimeChi2_EBM"); hTime[0]->Write(); hTime[1]->Write(); saving.Close () ; return 0 ; }
void wmj_fit_stack() { //=========Macro generated from canvas: default_Canvas/defaultCanvas //========= (Tue May 3 07:35:30 2016) by ROOT version6.04/10 TCanvas *default_Canvas = new TCanvas("default_Canvas", "defaultCanvas",0,0,700,500); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); default_Canvas->SetHighLightColor(2); default_Canvas->Range(0,0,1,1); default_Canvas->SetFillColor(0); default_Canvas->SetBorderMode(0); default_Canvas->SetBorderSize(2); default_Canvas->SetTickx(1); default_Canvas->SetTicky(1); default_Canvas->SetLeftMargin(0.14); default_Canvas->SetRightMargin(0.05); default_Canvas->SetTopMargin(0.05); default_Canvas->SetBottomMargin(0.16); default_Canvas->SetFrameLineWidth(2); default_Canvas->SetFrameBorderMode(0); // ------------>Primitives in pad: upperPad TPad *upperPad = new TPad("upperPad", "upperPad",0.005,0.05,0.995,0.995); upperPad->Draw(); upperPad->cd(); upperPad->Range(-0.1730123,-5358.989,1.06279,32919.5); upperPad->SetFillColor(0); upperPad->SetFillStyle(4000); upperPad->SetBorderMode(0); upperPad->SetBorderSize(2); upperPad->SetTickx(1); upperPad->SetTicky(1); upperPad->SetLeftMargin(0.14); upperPad->SetRightMargin(0.05); upperPad->SetTopMargin(0.05); upperPad->SetBottomMargin(0.14); upperPad->SetFrameLineWidth(2); upperPad->SetFrameBorderMode(0); upperPad->SetFrameLineWidth(2); upperPad->SetFrameBorderMode(0); Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fx3005[20] = { 0.025, 0.075, 0.125, 0.175, 0.225, 0.275, 0.325, 0.375, 0.425, 0.475, 0.525, 0.575, 0.625, 0.675, 0.725, 0.775, 0.825, 0.875, 0.925, 0.975}; Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fy3005[20] = { 0, 0, 9, 26, 118, 315, 881, 1812, 3086, 4575, 5856, 6537, 6824, 6348, 5662, 4769, 4941, 6726, 13179, 28019}; Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_felx3005[20] = { 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025}; Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fely3005[20] = { 0, 0, 2.943461, 5.066015, 10.37428, 17.25528, 29.18586, 42.07053, 55.05403, 67.14059, 76.02614, 80.35326, 82.10902, 79.17591, 74.74792, 68.55976, 69.79403, 81.51372, 114.3009, 166.8895}; Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fehx3005[20] = { 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025}; Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fehy3005[20] = { 1.147874, 1.147874, 4.110204, 6.164324, 11.37428, 18.25528, 30.18586, 43.07053, 56.05403, 68.14059, 77.02614, 81.35326, 83.10902, 80.17591, 75.74792, 69.55976, 70.79403, 82.51372, 115.3009, 167.8895}; TGraphAsymmErrors *grae = new TGraphAsymmErrors(20,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fx3005,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fy3005,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_felx3005,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fehx3005,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fely3005,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fehy3005); grae->SetName("h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]"); grae->SetTitle("Histogram of combData_plot__muminus_ISO_"); grae->SetFillColor(1); grae->SetFillStyle(0); grae->SetLineWidth(2); grae->SetMarkerStyle(20); TH1F *Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005 = new TH1F("Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005","Histogram of combData_plot__muminus_ISO_",100,0,1.1); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->SetMinimum(0); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->SetMaximum(31005.58); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->SetDirectory(0); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->SetStats(0); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->SetLineWidth(2); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->SetMarkerStyle(0); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetXaxis()->SetTitle("#it{p}_{T}^{#it{#mu}} / #it{p}_{T}^{#it{#mu}-jet} "); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetXaxis()->SetRange(1,91); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetXaxis()->SetNdivisions(1005); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetXaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetXaxis()->SetLabelOffset(0.02); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetXaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetXaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetXaxis()->SetTitleFont(132); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetYaxis()->SetTitle("Events / (0.05)"); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetYaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetYaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetYaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetYaxis()->SetTitleOffset(1.1); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetYaxis()->SetTitleFont(132); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetZaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetZaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetZaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005->GetZaxis()->SetTitleFont(132); grae->SetHistogram(Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]56300130023005); grae->Draw("e1pa"); Double_t h5_fx7[47] = { -0.02439024, -0.02439024, 0, 1.0201e-08, 0.04999999, 0.05000001, 0.09999999, 0.1, 0.15, 0.15, 0.2, 0.2, 0.25, 0.25, 0.3, 0.3, 0.35, 0.35, 0.4, 0.4, 0.45, 0.45, 0.5, 0.5, 0.55, 0.55, 0.6, 0.6, 0.65, 0.65, 0.7, 0.7, 0.75, 0.75, 0.8, 0.8, 0.85, 0.85, 0.9, 0.9, 0.95, 0.95, 1, 1, 1, 1.02439, 1.02439}; Double_t h5_fy7[47] = { 0, 0, 0, 8.630173e-06, 8.630173e-06, 8.630173e-06, 8.630173e-06, 8.630173e-06, 8.630173e-06, 3.789762, 3.789762, 71.12063, 71.12063, 211.4394, 211.4394, 857.7007, 857.7007, 1798.534, 1798.534, 3099.609, 3099.609, 4425.901, 4425.901, 5601.584, 5601.584, 6533.687, 6533.687, 6910.208, 6910.208, 6392.171, 6392.171, 5777.193, 5777.193, 5020.919, 5020.919, 5207.834, 5207.834, 6798.159, 6798.159, 13033.98, 13033.98, 27939.27, 27939.27, 0, 0, 0, 0}; TGraph *graph = new TGraph(47,h5_fx7,h5_fy7); graph->SetName("h5"); graph->SetTitle("Projection of "); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#3333ff"); graph->SetFillColor(ci); ci = TColor::GetColor("#3333ff"); graph->SetLineColor(ci); graph->SetLineWidth(2); ci = TColor::GetColor("#3333ff"); graph->SetMarkerColor(ci); graph->SetMarkerStyle(0); TH1F *Graph_h57 = new TH1F("Graph_h57","Projection of ",100,-0.1292683,1.129268); Graph_h57->SetMinimum(0); Graph_h57->SetMaximum(30733.2); Graph_h57->SetDirectory(0); Graph_h57->SetStats(0); Graph_h57->SetLineWidth(2); Graph_h57->SetMarkerStyle(0); Graph_h57->GetXaxis()->SetTitle("#it{p}_{T}^{#it{#mu}} / #it{p}_{T}^{#it{#mu}-jet} "); Graph_h57->GetXaxis()->SetRange(11,90); Graph_h57->GetXaxis()->SetNdivisions(1005); Graph_h57->GetXaxis()->SetLabelFont(132); Graph_h57->GetXaxis()->SetLabelOffset(0.02); Graph_h57->GetXaxis()->SetLabelSize(0.05); Graph_h57->GetXaxis()->SetTitleSize(0.06); Graph_h57->GetXaxis()->SetTitleFont(132); Graph_h57->GetYaxis()->SetTitle("Events / (0.05)"); Graph_h57->GetYaxis()->SetLabelFont(132); Graph_h57->GetYaxis()->SetLabelSize(0.05); Graph_h57->GetYaxis()->SetTitleSize(0.06); Graph_h57->GetYaxis()->SetTitleFont(132); Graph_h57->GetZaxis()->SetLabelFont(132); Graph_h57->GetZaxis()->SetLabelSize(0.05); Graph_h57->GetZaxis()->SetTitleSize(0.06); Graph_h57->GetZaxis()->SetTitleFont(132); graph->SetHistogram(Graph_h57); graph->Draw("f"); Double_t sumBkgPdf_totbkg_fitW_fx8[47] = { -0.02439024, -0.02439024, 0, 1.0201e-08, 0.04999999, 0.05000001, 0.09999999, 0.1, 0.15, 0.15, 0.2, 0.2, 0.25, 0.25, 0.3, 0.3, 0.35, 0.35, 0.4, 0.4, 0.45, 0.45, 0.5, 0.5, 0.55, 0.55, 0.6, 0.6, 0.65, 0.65, 0.7, 0.7, 0.75, 0.75, 0.8, 0.8, 0.85, 0.85, 0.9, 0.9, 0.95, 0.95, 1, 1, 1, 1.02439, 1.02439}; Double_t sumBkgPdf_totbkg_fitW_fy8[47] = { 0, 0, 0, 2.878569e-06, 2.878569e-06, 2.878569e-06, 2.878569e-06, 2.878569e-06, 2.878569e-06, 3.789757, 3.789757, 71.12063, 71.12063, 211.4394, 211.4394, 855.0132, 855.0132, 1794.513, 1794.513, 3088.88, 3088.88, 4399.772, 4399.772, 5568.272, 5568.272, 6460.972, 6460.972, 6790.725, 6790.725, 6142.168, 6142.168, 5333.208, 5333.208, 4062.953, 4062.953, 3103.771, 3103.771, 2394.858, 2394.858, 1734.507, 1734.507, 1650.883, 1650.883, 0, 0, 0, 0}; graph = new TGraph(47,sumBkgPdf_totbkg_fitW_fx8,sumBkgPdf_totbkg_fitW_fy8); graph->SetName("sumBkgPdf_totbkg_fitW"); graph->SetTitle("Projection of "); ci = TColor::GetColor("#ffff66"); graph->SetFillColor(ci); ci = TColor::GetColor("#ffff66"); graph->SetLineColor(ci); graph->SetLineWidth(2); ci = TColor::GetColor("#ffff66"); graph->SetMarkerColor(ci); graph->SetMarkerStyle(0); TH1F *Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618 = new TH1F("Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618","Projection of ",100,-0.1292683,1.129268); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->SetMinimum(0); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->SetMaximum(7469.797); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->SetDirectory(0); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->SetStats(0); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->SetLineWidth(2); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->SetMarkerStyle(0); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetXaxis()->SetTitle("#it{p}_{T}^{#it{#mu}} / #it{p}_{T}^{#it{#mu}-jet} "); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetXaxis()->SetRange(11,90); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetXaxis()->SetNdivisions(1005); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetXaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetXaxis()->SetLabelOffset(0.02); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetXaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetXaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetXaxis()->SetTitleFont(132); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetYaxis()->SetTitle("Events / (0.05)"); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetYaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetYaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetYaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetYaxis()->SetTitleFont(132); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetZaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetZaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetZaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618->GetZaxis()->SetTitleFont(132); graph->SetHistogram(Graph_Graph_Graph_Graph_sumBkgPdf_totbkg_fitW131618); graph->Draw("f"); Double_t sumPdf_Norm[muminus_ISO_]_fx9[47] = { -0.02439024, -0.02439024, 0, 1.0201e-08, 0.04999999, 0.05000001, 0.09999999, 0.1, 0.15, 0.15, 0.2, 0.2, 0.25, 0.25, 0.3, 0.3, 0.35, 0.35, 0.4, 0.4, 0.45, 0.45, 0.5, 0.5, 0.55, 0.55, 0.6, 0.6, 0.65, 0.65, 0.7, 0.7, 0.75, 0.75, 0.8, 0.8, 0.85, 0.85, 0.9, 0.9, 0.95, 0.95, 1, 1, 1, 1.02439, 1.02439}; Double_t sumPdf_Norm[muminus_ISO_]_fy9[47] = { 0, 0, 0, 8.630165e-06, 8.630165e-06, 8.630165e-06, 8.630165e-06, 8.630165e-06, 8.630165e-06, 3.789756, 3.789756, 71.12054, 71.12054, 211.4391, 211.4391, 857.6998, 857.6998, 1798.532, 1798.532, 3099.606, 3099.606, 4425.897, 4425.897, 5601.578, 5601.578, 6533.68, 6533.68, 6910.201, 6910.201, 6392.164, 6392.164, 5777.187, 5777.187, 5020.914, 5020.914, 5207.829, 5207.829, 6798.152, 6798.152, 13033.97, 13033.97, 27939.24, 27939.24, 0, 0, 0, 0}; graph = new TGraph(47,sumPdf_Norm[muminus_ISO_]_fx9,sumPdf_Norm[muminus_ISO_]_fy9); graph->SetName("sumPdf_Norm[muminus_ISO_]"); graph->SetTitle("Projection of "); ci = TColor::GetColor("#ff0000"); graph->SetFillColor(ci); graph->SetFillStyle(0); ci = TColor::GetColor("#ff0000"); graph->SetLineColor(ci); graph->SetLineWidth(2); ci = TColor::GetColor("#ff0000"); graph->SetMarkerColor(ci); graph->SetMarkerStyle(0); TH1F *Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839 = new TH1F("Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839","Projection of ",100,-0.1292683,1.129268); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->SetMinimum(0); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->SetMaximum(30733.17); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->SetDirectory(0); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->SetStats(0); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->SetLineWidth(2); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->SetMarkerStyle(0); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetXaxis()->SetTitle("#it{p}_{T}^{#it{#mu}} / #it{p}_{T}^{#it{#mu}-jet} "); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetXaxis()->SetRange(11,90); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetXaxis()->SetNdivisions(1005); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetXaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetXaxis()->SetLabelOffset(0.02); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetXaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetXaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetXaxis()->SetTitleFont(132); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetYaxis()->SetTitle("Events / (0.05)"); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetYaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetYaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetYaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetYaxis()->SetTitleFont(132); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetZaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetZaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetZaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839->GetZaxis()->SetTitleFont(132); graph->SetHistogram(Graph_Graph_Graph_Graph_sumPdf_Norm[muminus_ISO_]151839); graph->Draw(""); Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fx3006[20] = { 0.025, 0.075, 0.125, 0.175, 0.225, 0.275, 0.325, 0.375, 0.425, 0.475, 0.525, 0.575, 0.625, 0.675, 0.725, 0.775, 0.825, 0.875, 0.925, 0.975}; Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fy3006[20] = { 0, 0, 9, 26, 118, 315, 881, 1812, 3086, 4575, 5856, 6537, 6824, 6348, 5662, 4769, 4941, 6726, 13179, 28019}; Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_felx3006[20] = { 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025}; Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fely3006[20] = { 0, 0, 2.943461, 5.066015, 10.37428, 17.25528, 29.18586, 42.07053, 55.05403, 67.14059, 76.02614, 80.35326, 82.10902, 79.17591, 74.74792, 68.55976, 69.79403, 81.51372, 114.3009, 166.8895}; Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fehx3006[20] = { 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025, 0.025}; Double_t h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fehy3006[20] = { 1.147874, 1.147874, 4.110204, 6.164324, 11.37428, 18.25528, 30.18586, 43.07053, 56.05403, 68.14059, 77.02614, 81.35326, 83.10902, 80.17591, 75.74792, 69.55976, 70.79403, 82.51372, 115.3009, 167.8895}; grae = new TGraphAsymmErrors(20,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fx3006,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fy3006,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_felx3006,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fehx3006,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fely3006,h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]_fehy3006); grae->SetName("h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]"); grae->SetTitle("Histogram of combData_plot__muminus_ISO_"); grae->SetFillColor(1); grae->SetFillStyle(0); grae->SetLineWidth(2); grae->SetMarkerStyle(20); TH1F *Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006 = new TH1F("Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006","Histogram of combData_plot__muminus_ISO_",100,0,1.1); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->SetMinimum(0); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->SetMaximum(31005.58); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->SetDirectory(0); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->SetStats(0); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->SetLineWidth(2); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->SetMarkerStyle(0); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetXaxis()->SetTitle("#it{p}_{T}^{#it{#mu}} / #it{p}_{T}^{#it{#mu}-jet} "); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetXaxis()->SetRange(1,91); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetXaxis()->SetNdivisions(1005); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetXaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetXaxis()->SetLabelOffset(0.02); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetXaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetXaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetXaxis()->SetTitleFont(132); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetYaxis()->SetTitle("Events / (0.05)"); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetYaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetYaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetYaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetYaxis()->SetTitleOffset(1.1); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetYaxis()->SetTitleFont(132); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetZaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetZaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetZaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006->GetZaxis()->SetTitleFont(132); grae->SetHistogram(Graph_Graph_Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]563001300230053006); grae->Draw("e1p"); TLegend *leg = new TLegend(0.2,0.53,0.6,0.78,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextFont(132); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(2); leg->SetFillColor(10); leg->SetFillStyle(0); TLegendEntry *entry=leg->AddEntry("h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]","Data, #sqrt{s}=8 TeV","lep"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerStyle(20); entry->SetMarkerSize(1); entry->SetTextFont(132); entry=leg->AddEntry("h5","Electroweak","f"); ci = TColor::GetColor("#3333ff"); entry->SetFillColor(ci); entry->SetFillStyle(1001); ci = TColor::GetColor("#3333ff"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(132); entry=leg->AddEntry("sumBkgPdf_totbkg_fitW","QCD","f"); ci = TColor::GetColor("#ffff66"); entry->SetFillColor(ci); entry->SetFillStyle(1001); ci = TColor::GetColor("#ffff66"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(132); entry=leg->AddEntry("sumPdf_Norm[muminus_ISO_]","Fit","l"); ci = TColor::GetColor("#ff0000"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(2); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(132); leg->Draw(); TPaveText *pt = new TPaveText(0.2,0.8,0.4,0.87,"brNDC"); pt->SetBorderSize(0); pt->SetFillStyle(0); pt->SetLineWidth(2); pt->SetTextFont(132); TText *AText = pt->AddText("LHCb"); pt->Draw(); TH1F *Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy = new TH1F("Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy","Histogram of combData_plot__muminus_ISO_",100,0,1.1); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->SetMinimum(0); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->SetMaximum(31005.58); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->SetDirectory(0); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->SetStats(0); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->SetLineWidth(2); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->SetMarkerStyle(0); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetXaxis()->SetTitle("#it{p}_{T}^{#it{#mu}} / #it{p}_{T}^{#it{#mu}-jet} "); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetXaxis()->SetRange(1,91); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetXaxis()->SetNdivisions(1005); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetXaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetXaxis()->SetLabelOffset(0.02); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetXaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetXaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetXaxis()->SetTitleFont(132); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetYaxis()->SetTitle("Events / (0.05)"); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetYaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetYaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetYaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetYaxis()->SetTitleOffset(1.1); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetYaxis()->SetTitleFont(132); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetZaxis()->SetLabelFont(132); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetZaxis()->SetLabelSize(0.05); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetZaxis()->SetTitleSize(0.06); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->GetZaxis()->SetTitleFont(132); Graph_Graph_Graph_Graph_h_combData_Cut[samples == samples::fitW_etam_0 || samples == samples::fitW_etam_1 || samples == samples::fitW_etam_2 || samples == samples::fitW_etam_3]5630013002_copy->Draw("sameaxis"); upperPad->Modified(); default_Canvas->cd(); default_Canvas->Modified(); default_Canvas->cd(); default_Canvas->SetSelected(default_Canvas); }
void bSplineGSLOriginalDemo () { const size_t n = N; const size_t ncoeffs = NCOEFFS; const size_t nbreak = NBREAK; size_t i, j; gsl_bspline_workspace *bw; gsl_vector *B; double dy; gsl_rng *r; gsl_vector *c, *w; gsl_vector *x, *y; gsl_matrix *X, *cov; gsl_multifit_linear_workspace *mw; double chisq, Rsq, dof, tss; vector<double> xControl, yControl, xFit, yFit; gsl_rng_env_setup(); r = gsl_rng_alloc(gsl_rng_default); /* allocate a cubic bspline workspace (k = 4) */ bw = gsl_bspline_alloc(4, nbreak); B = gsl_vector_alloc(ncoeffs); x = gsl_vector_alloc(n); y = gsl_vector_alloc(n); X = gsl_matrix_alloc(n, ncoeffs); c = gsl_vector_alloc(ncoeffs); w = gsl_vector_alloc(n); cov = gsl_matrix_alloc(ncoeffs, ncoeffs); mw = gsl_multifit_linear_alloc(n, ncoeffs); printf("#m=0,S=0\n"); /* this is the data to be fitted */ for (i = 0; i < n; ++i) { double sigma; double xi = (15.0 / (N - 1)) * i; double yi = cos(xi) * exp(-0.1 * xi); sigma = 0.1 * yi; dy = gsl_ran_gaussian(r, sigma); yi += dy; gsl_vector_set(x, i, xi); xControl.push_back(xi); gsl_vector_set(y, i, yi); yControl.push_back(yi); gsl_vector_set(w, i, 1.0 / (sigma * sigma)); printf("%f %f\n", xi, yi); } /* use uniform breakpoints on [0, 15] */ gsl_bspline_knots_uniform(0.0, 15.0, bw); /* construct the fit matrix X */ for (i = 0; i < n; ++i) { double xi = gsl_vector_get(x, i); /* compute B_j(xi) for all j */ gsl_bspline_eval(xi, B, bw); /* fill in row i of X */ for (j = 0; j < ncoeffs; ++j) { double Bj = gsl_vector_get(B, j); gsl_matrix_set(X, i, j, Bj); } } /* do the fit */ gsl_multifit_wlinear(X, w, y, c, cov, &chisq, mw); dof = n - ncoeffs; tss = gsl_stats_wtss(w->data, 1, y->data, 1, y->size); Rsq = 1.0 - chisq / tss; fprintf(stderr, "chisq/dof = %e, Rsq = %f\n", chisq / dof, Rsq); /* output the smoothed curve */ { double xi, yi, yerr; printf("#m=1,S=0\n"); for (xi = 0.0; xi < 15.0; xi += 0.1) { gsl_bspline_eval(xi, B, bw); gsl_multifit_linear_est(B, c, cov, &yi, &yerr); xFit.push_back(xi); yFit.push_back(yi); printf("%f %f\n", xi, yi); } } gsl_rng_free(r); gsl_bspline_free(bw); gsl_vector_free(B); gsl_vector_free(x); gsl_vector_free(y); gsl_matrix_free(X); gsl_vector_free(c); gsl_vector_free(w); gsl_matrix_free(cov); gsl_multifit_linear_free(mw); TGraph *gr = LoadGraphFromVectors(xControl, yControl); TGraph *grFit = LoadGraphFromVectors(xFit, yFit); gr->SetMarkerColor(kRed); TCanvas *c1 = new TCanvas("c1", "Graph", 200, 10, 700, 500); gr->Draw("apz"); grFit->Draw("SAME"); c1->Update(); }
/* root -l 'sigmapeak.C+(0.025)' // Processing sigmapeak.C+(0.025)... background only: bkg_nsigma_0_99 = -0.352803 sig_nsigma_0_59 = -0.608621 sig_nsigma_0_99 = 2.1472 sig_nsigma_60_99 = 4.14042 sig_nsigma_70_90 = 5.57689 sig_nsigma_75_85 = 8.056 */ void sigmapeak(Double_t signal_area=0.025) { Double_t bkg_mean = 0; Double_t bkg_sigma = 0.001; Double_t x[100]; Double_t y[100]; Int_t np = 100; TRandom3 rand; for (int i=0; i<np; ++i) { x[i] = i; y[i] = rand.Gaus(bkg_mean,bkg_sigma); } TGraph* gr = new TGraph(np,x,y); gr->SetNameTitle("gr",Form("#sigma = %0.1f",bkg_sigma)); gr->SetMarkerStyle(7); gr->SetMarkerColor(46); new TCanvas(); gr->Draw("ap"); Double_t bkg_nsigma_0_99 = Nsigma(gr->GetY(), 0,99, bkg_sigma); cout<< "background only: bkg_nsigma_0_99 = " << bkg_nsigma_0_99 <<endl; // add signal Double_t signal_mean = 80; Double_t signal_sigma = 3; for (int i=0; i<gr->GetN(); ++i) { Double_t xx = (gr->GetX()[i] - signal_mean)/signal_sigma; Double_t arg = 0.5*xx*xx; Double_t exp = arg < 50? TMath::Exp(-arg): 0; Double_t signal = signal_area/(TMath::Sqrt(TMath::TwoPi())*signal_sigma) * exp; gr->SetPoint(i, gr->GetX()[i], gr->GetY()[i] + signal); } gr->SetTitle(Form("#sigma_{bkg} = %0.3f signal: area = %0.3f mean = %0.0f sigma = %0.1f", bkg_sigma,signal_area,signal_mean,signal_sigma)); gr->Draw("apl"); gr->Fit("gaus", "R", "", signal_mean - 5*signal_sigma, signal_mean+5*signal_sigma); Double_t fit_area = 2.5 * gr->GetFunction("gaus")->GetParameter("Constant") * gr->GetFunction("gaus")->GetParameter("Sigma"); cout<< "Area under fitted gaussian = " << fit_area <<endl; // titmax(); gPad->Modified(); // to create box (NB: the pad was not drawn yet at this point!) gPad->Update(); TPaveText* tit = (TPaveText*)gPad->GetPrimitive("title"); tit->SetX1NDC(0.); tit->SetX2NDC(1.); tit->SetY1NDC(0.9); tit->SetY2NDC(1.); gPad->Modified(); // to update the pad gPad->Update(); Double_t sig_nsigma_0_59 = Nsigma(gr->GetY(), 0,59, bkg_sigma); cout<< "sig_nsigma_0_59 = " << sig_nsigma_0_59 <<endl; Double_t sig_nsigma_0_99 = Nsigma(gr->GetY(), 0,99, bkg_sigma); cout<< "sig_nsigma_0_99 = " << sig_nsigma_0_99 <<endl; Double_t sig_nsigma_60_99 = Nsigma(gr->GetY(), 60,99, bkg_sigma); cout<< "sig_nsigma_60_99 = " << sig_nsigma_60_99 <<endl; Double_t sig_nsigma_70_90 = Nsigma(gr->GetY(), 70,90, bkg_sigma); cout<< "sig_nsigma_70_90 = " << sig_nsigma_70_90 <<endl; Double_t sig_nsigma_75_85 = Nsigma(gr->GetY(), 75,85, bkg_sigma); cout<< "sig_nsigma_75_85 = " << sig_nsigma_75_85 <<endl; Double_t ys5[100]; smooth5(np, gr->GetY(), ys5); TGraph* gr5 = new TGraph(np, x, ys5); gr5->SetNameTitle("gr5","smoothed on 5 points"); gr5->SetMarkerStyle(7); gr5->SetMarkerColor(2); gr5->SetLineColor(2); new TCanvas; gr5->Draw("apl"); Double_t ys7[100]; smooth7(np, gr->GetY(), ys7); TGraph* gr7 = new TGraph(np, x, ys7); gr7->SetNameTitle("gr7","smoothed on 7 points"); gr7->SetMarkerStyle(7); gr7->SetMarkerColor(8); gr7->SetLineColor(8); new TCanvas; gr7->Draw("apl"); Double_t ys7a[100]; smooth7a(np, gr->GetY(), ys7a); TGraph* gr7a = new TGraph(np, x, ys7a); gr7a->SetNameTitle("gr7a","smoothed on 7a points"); gr7a->SetMarkerStyle(7); gr7a->SetMarkerColor(3); gr7a->SetLineColor(3); new TCanvas; gr7a->Draw("apl"); Double_t ys5g[100]; smooth5g(np, gr->GetY(), ys5g); TGraph* gr5g = new TGraph(np, x, ys5g); gr5g->SetNameTitle("gr5g","smoothed on 5g points"); gr5g->SetMarkerStyle(7); gr5g->SetMarkerColor(4); gr5g->SetLineColor(4); new TCanvas; gr5g->Draw("apl"); Double_t ys5a[100]; smooth5a(np, gr->GetY(), ys5a); TGraph* gr5a = new TGraph(np, x, ys5a); gr5a->SetNameTitle("gr5a","smoothed on 5a points"); gr5a->SetMarkerStyle(7); gr5a->SetMarkerColor(6); gr5a->SetLineColor(6); new TCanvas; gr5a->Draw("apl"); }
void mssm_xs_times_acc_scan(char* path, std::string filepath, double tanb, std::string category) { mssm_xs_tools xs; xs.SetInput(path); //TGraph *SM = new TGraph(); TGraph *ggH = new TGraph(); TGraph *bbH = new TGraph(); TGraph *ggA = new TGraph(); TGraph *gg = new TGraph(); TGraph *bbA = new TGraph(); TGraph *ggh = new TGraph(); TGraph *bbh = new TGraph(); TGraph *bb = new TGraph(); TGraph *signi = new TGraph(); TGraph *ggHacc = new TGraph(); TGraph *bbHacc = new TGraph(); TGraph *ggAacc = new TGraph(); TGraph *ggacc = new TGraph(); TGraph *bbAacc = new TGraph(); TGraph *gghacc = new TGraph(); TGraph *bbhacc = new TGraph(); TGraph *bbacc = new TGraph(); double xs_eff_ggH[4]; double xs_eff_bbH[4]; double masses[19]; masses[0]= 90; masses[1]= 100; masses[2]= 120; masses[3]= 130; masses[4]= 140; masses[5]= 160; masses[6]= 180; masses[7]= 200; masses[8]= 250; masses[9]= 300; masses[10]= 350; masses[11]= 400; masses[12]= 450; masses[13]= 500; masses[14]= 600; masses[15]= 700; masses[16]= 800; masses[17]= 900; masses[18]=1000; TFile* inputFile = new TFile(std::string(filepath+"/"+"htt_mt.inputs-mssm-8TeV-0.root").c_str()); TH1F* h_background = new TH1F(); double ggH_value, bbH_value, ggA_value, bbA_value, ggh_value, bbh_value;; double mA; h_background=get<TH1F>(inputFile, std::string("muTau_"+category+"/ZTT").c_str()); h_background->Add(get<TH1F>(inputFile, std::string("muTau_"+category+"/QCD").c_str())); h_background->Add(get<TH1F>(inputFile, std::string("muTau_"+category+"/W").c_str())); h_background->Add(get<TH1F>(inputFile, std::string("muTau_"+category+"/ZL").c_str())); h_background->Add(get<TH1F>(inputFile, std::string("muTau_"+category+"/ZJ").c_str())); h_background->Add(get<TH1F>(inputFile, std::string("muTau_"+category+"/TT").c_str())); h_background->Add(get<TH1F>(inputFile, std::string("muTau_"+category+"/VV").c_str())); TH1F* h_ggH = new TH1F(); TH1F* h_bbH = new TH1F(); TH1F* h_ggh = new TH1F(); TH1F* h_bbh = new TH1F(); TH1F* h_ggA = new TH1F(); TH1F* h_bbA = new TH1F(); for(unsigned int idx=0; idx<19; idx++){ mA=masses[idx]; std::cout << "mh = " << xs.Give_Mass_h(mA, tanb) << " mA = " << mA << " mH = " << xs.Give_Mass_H(mA, tanb) << std::endl; std::cout << "mh = " << closest_mass(xs.Give_Mass_h(mA, tanb)) << " mA = " << mA << " mH = " << closest_mass(xs.Give_Mass_H(mA, tanb)) << std::endl; //SM->SetPoint(tanb-1, tanb, 1.21*1000); std::cout << "MSSM Cross Section [ggH]:" << std::endl; xs_eff_ggH[0] = xs.Give_Xsec_ggFA(mA, tanb)*xs.Give_BR_A_tautau(mA, tanb); std::cout << " -> xsec(ggA):\t" << xs.Give_Xsec_ggFA(mA, tanb) << "\t --- \t" << xs.Give_BR_A_tautau(mA, tanb) << std::endl; xs_eff_ggH[1] = xs.Give_Xsec_ggFH(mA, tanb)*xs.Give_BR_H_tautau(mA, tanb); std::cout << " -> xsec(ggH):\t" << xs.Give_Xsec_ggFH(mA, tanb) << "\t --- \t" << xs.Give_BR_H_tautau(mA, tanb) << std::endl; xs_eff_ggH[2] = xs.Give_Xsec_ggFh(mA, tanb)*xs.Give_BR_h_tautau(mA, tanb); std::cout << " -> xsec(ggh):\t" << xs.Give_Xsec_ggFh(mA, tanb) << "\t --- \t" << xs.Give_BR_h_tautau(mA, tanb) << std::endl; xs_eff_ggH[3] = (xs_eff_ggH[0]+xs_eff_ggH[1]+xs_eff_ggH[2]);//*1.237; std::cout << "mA: "<< mA << " tanb: "<<tanb<<" -> ggH_xsec(cmb):\t" << xs_eff_ggH[3] << std::endl; char mass_help[50]; sprintf (mass_help, "%0.0f", mA); h_ggA = get<TH1F>(inputFile, std::string("muTau_"+category+"/ggH"+mass_help).c_str()); ggA_value=h_ggA->Integral(); std::cout << "acc of ggA " << h_ggA->Integral() << std::endl; ggA->SetPoint(idx, mA, xs_eff_ggH[0]); ggAacc->SetPoint(idx, mA, ggA_value); sprintf (mass_help, "%0.0f", closest_mass(xs.Give_Mass_H(mA, tanb))); h_ggH = get<TH1F>(inputFile, std::string("muTau_"+category+"/ggH"+mass_help).c_str()); ggH_value=h_ggH->Integral(); std::cout << "acc of ggH " << h_ggH->Integral() << std::endl; ggH->SetPoint(idx, mA, xs_eff_ggH[1]); ggHacc->SetPoint(idx, mA, ggH_value); sprintf (mass_help, "%0.0f", closest_mass(xs.Give_Mass_h(mA, tanb))); h_ggh = get<TH1F>(inputFile, std::string("muTau_"+category+"/ggH"+mass_help).c_str()); ggh_value=h_ggh->Integral(); std::cout << "acc of ggh " << h_ggh->Integral() << std::endl; ggh->SetPoint(idx, mA, xs_eff_ggH[2]); gghacc->SetPoint(idx, mA, ggh_value); //gg->SetPoint(idx, mA, xs_eff_ggH[2]+xs_eff_ggH[1]+xs_eff_ggH[0]); if(mA<130) gg->SetPoint(idx, mA, xs_eff_ggH[2]+xs_eff_ggH[0]); else if(mA==130) gg->SetPoint(idx, mA, xs_eff_ggH[2]+xs_eff_ggH[1]+xs_eff_ggH[0]); else gg->SetPoint(idx, mA, xs_eff_ggH[1]+xs_eff_ggH[0]); //ggacc->SetPoint(idx, mA, ggh_value+ggH_value+ggA_value); if(mA<130) ggacc->SetPoint(idx, mA, ggh_value+ggA_value); else if(mA==130) ggacc->SetPoint(idx, mA, ggh_value+ggH_value+ggA_value); else ggacc->SetPoint(idx, mA, ggH_value+ggA_value); std::cout << std::endl; std::cout << "MSSM Cross Section [bbH]:" << std::endl; xs_eff_bbH[0] = xs.GiveXsec_Santander_A(mA, tanb)*xs.Give_BR_A_tautau(mA, tanb); std::cout << " -> xsec(ggA):\t" << xs.GiveXsec_Santander_A(mA, tanb) << "\t --- \t" << xs.Give_BR_A_tautau(mA, tanb) << std::endl; xs_eff_bbH[1] = xs.GiveXsec_Santander_H(mA, tanb)*xs.Give_BR_H_tautau(mA, tanb); std::cout << " -> xsec(bbH):\t" << xs.GiveXsec_Santander_H(mA, tanb) << "\t --- \t" << xs.Give_BR_H_tautau(mA, tanb) << std::endl; xs_eff_bbH[2] = xs.GiveXsec_Santander_h(mA, tanb)*xs.Give_BR_h_tautau(mA, tanb); std::cout << " -> xsec(ggh):\t" << xs.GiveXsec_Santander_h(mA, tanb) << "\t --- \t" << xs.Give_BR_h_tautau(mA, tanb) << std::endl; xs_eff_bbH[3] = (xs_eff_bbH[0]+xs_eff_bbH[1]+xs_eff_bbH[2]);//*1.627; std::cout << "mA: "<< mA << " tanb: "<<tanb<<" -> bbH_xsec(cmb):\t" << xs_eff_bbH[3] << std::endl; sprintf (mass_help, "%0.0f", mA); h_bbA = get<TH1F>(inputFile, std::string("muTau_"+category+"/bbH"+mass_help).c_str()); bbA_value=h_bbA->Integral(); std::cout << "acc of bbA " << h_bbA->Integral() << std::endl; bbA->SetPoint(idx, mA, xs_eff_bbH[0]); bbAacc->SetPoint(idx, mA, bbA_value); sprintf (mass_help, "%0.0f", closest_mass(xs.Give_Mass_H(mA, tanb))); h_bbH = get<TH1F>(inputFile, std::string("muTau_"+category+"/bbH"+mass_help).c_str()); bbH_value=h_bbH->Integral(); std::cout << "acc of bbH " << h_bbH->Integral() << std::endl; bbH->SetPoint(idx, mA, xs_eff_bbH[1]); bbHacc->SetPoint(idx, mA, bbH_value); sprintf (mass_help, "%0.0f", closest_mass(xs.Give_Mass_h(mA, tanb))); h_bbh = get<TH1F>(inputFile, std::string("muTau_"+category+"/bbH"+mass_help).c_str()); bbh_value=h_bbh->Integral(); std::cout << "acc of bbh " << h_bbh->Integral() << std::endl; bbh->SetPoint(idx, mA, xs_eff_bbH[2]); bbhacc->SetPoint(idx, mA, bbh_value); //bb->SetPoint(idx, mA, xs_eff_bbH[2]+xs_eff_bbH[1]+xs_eff_bbH[0]); if(mA<130) bb->SetPoint(idx, mA, xs_eff_bbH[2]+xs_eff_bbH[0]); else if(mA==130) bb->SetPoint(idx, mA, xs_eff_bbH[2]+xs_eff_bbH[1]+xs_eff_bbH[0]); else bb->SetPoint(idx, mA, xs_eff_bbH[1]+xs_eff_bbH[0]); //bbacc->SetPoint(idx, mA, bbh_value+bbH_value+bbA_value); if(mA<130) bbacc->SetPoint(idx, mA, bbh_value+bbA_value); else if(mA==130) bbacc->SetPoint(idx, mA, bbh_value+bbH_value+bbA_value); else bbacc->SetPoint(idx, mA, bbH_value+bbA_value); std::cout << std::endl; std::cout << std::endl; h_ggA->Scale(xs_eff_ggH[0]); h_ggH->Scale(xs_eff_ggH[1]); h_ggh->Scale(xs_eff_ggH[2]); h_bbA->Scale(xs_eff_bbH[0]); h_bbH->Scale(xs_eff_bbH[1]); h_bbh->Scale(xs_eff_bbH[2]); h_ggA->Add(h_ggH); h_ggA->Add(h_ggh); h_bbA->Add(h_bbH); h_bbA->Add(h_bbh); h_bbA->Add(h_ggA); double significance=0; double significance_help=0; for(int nbin=0; nbin<h_bbA->GetNbinsX()+1; nbin++){ if(h_background->GetBinContent(nbin)+h_bbA->GetBinContent(nbin)!=0) significance=h_bbA->GetBinContent(nbin)/sqrt(h_background->GetBinContent(nbin)+h_bbA->GetBinContent(nbin)); else significance=0; //if(significance>significance_help){ significance_help+=significance; //} } std::cout << "significance " << significance_help << std::endl; signi->SetPoint(idx, mA, significance_help); //destruct TH1Fs h_ggA->~TH1F(); h_ggH->~TH1F(); h_ggh->~TH1F(); h_bbA->~TH1F(); h_bbH->~TH1F(); h_bbh->~TH1F(); std::cout << std::endl; std::cout << std::endl; } /// do the drawing TCanvas* canv1 = new TCanvas("canv1", "xs*BR", 600, 600); canv1->cd(); //canv1->SetGridx(1); //canv1->SetGridy(1); canv1->SetLeftMargin(0.15); canv1->SetLogy(1); // draw a frame to define the range TH1F* hr=canv1->DrawFrame(ggA->GetX()[0]-.01, 0.0001, ggA->GetX()[ggA->GetN()-1]+.01, 10000); // format x axis hr->SetXTitle("m_{A}"); hr->GetXaxis()->SetLabelSize(0.045); hr->GetXaxis()->SetTitleFont(62); hr->GetXaxis()->SetLabelFont(62); hr->GetXaxis()->SetTitleColor(1); hr->GetXaxis()->SetTitleOffset(1.08); // format y axis hr->SetYTitle("#sigma*BR and acc*signal_{eff}*lumi"); hr->GetXaxis()->SetTitleFont(62); hr->GetYaxis()->SetLabelFont(62); hr->GetYaxis()->SetLabelSize(0.045); hr->GetYaxis()->SetTitleOffset(1.6); hr->GetXaxis()->SetTitleColor(1); hr->SetNdivisions(505, "X"); //ggA->Draw("PLsame"); ggA->SetLineStyle(3.); ggA->SetLineWidth(2.); ggA->SetLineColor(kBlue); ggA->SetMarkerStyle(23); ggA->SetMarkerSize(0); ggA->SetMarkerColor(kBlue); //ggH->Draw("PLsame"); ggH->SetLineStyle(2.); ggH->SetLineWidth(2.); ggH->SetLineColor(kBlue); ggH->SetMarkerStyle(22); ggH->SetMarkerSize(0); ggH->SetMarkerColor(kBlue); //ggh->Draw("PLsame"); ggh->SetLineStyle(1.); ggh->SetLineWidth(2.); ggh->SetLineColor(kBlue); ggh->SetMarkerStyle(20); ggh->SetMarkerSize(0); ggh->SetMarkerColor(kBlue); //ggAacc->Draw("PLsame"); ggAacc->SetLineStyle(3.); ggAacc->SetLineWidth(2.); ggAacc->SetLineColor(kMagenta); ggAacc->SetMarkerStyle(23); ggAacc->SetMarkerSize(0); ggAacc->SetMarkerColor(kMagenta); //ggHacc->Draw("PLsame"); ggHacc->SetLineStyle(2.); ggHacc->SetLineWidth(2.); ggHacc->SetLineColor(kMagenta); ggHacc->SetMarkerStyle(22); ggHacc->SetMarkerSize(0); ggHacc->SetMarkerColor(kMagenta); //gghacc->Draw("PLsame"); gghacc->SetLineStyle(1.); gghacc->SetLineWidth(2.); gghacc->SetLineColor(kMagenta); gghacc->SetMarkerStyle(20); gghacc->SetMarkerSize(0); gghacc->SetMarkerColor(kMagenta); //bbA->Draw("PLsame"); bbA->SetLineStyle(3.); bbA->SetLineWidth(2.); bbA->SetLineColor(kRed); bbA->SetMarkerStyle(23); bbA->SetMarkerSize(0); bbA->SetMarkerColor(kRed); //bbH->Draw("PLsame"); bbH->SetLineStyle(2.); bbH->SetLineWidth(2.); bbH->SetLineColor(kRed); bbH->SetMarkerStyle(22); bbH->SetMarkerSize(0); bbH->SetMarkerColor(kRed); //bbh->Draw("PLsame"); bbh->SetLineStyle(1.); bbh->SetLineWidth(2.); bbh->SetLineColor(kRed); bbh->SetMarkerStyle(20); bbh->SetMarkerSize(0); bbh->SetMarkerColor(kRed); //bbAacc->Draw("PLsame"); bbAacc->SetLineStyle(3.); bbAacc->SetLineWidth(2.); bbAacc->SetLineColor(kOrange); bbAacc->SetMarkerStyle(23); bbAacc->SetMarkerSize(0); bbAacc->SetMarkerColor(kOrange); //bbHacc->Draw("PLsame"); bbHacc->SetLineStyle(2.); bbHacc->SetLineWidth(2.); bbHacc->SetLineColor(kOrange); bbHacc->SetMarkerStyle(22); bbHacc->SetMarkerSize(0); bbHacc->SetMarkerColor(kOrange); //bbhacc->Draw("PLsame"); bbhacc->SetLineStyle(1.); bbhacc->SetLineWidth(2.); bbhacc->SetLineColor(kOrange); bbhacc->SetMarkerStyle(20); bbhacc->SetMarkerSize(0); bbhacc->SetMarkerColor(kOrange); gg->Draw("PLsame"); gg->SetLineStyle(1.); gg->SetLineWidth(3.); gg->SetLineColor(kBlue+2); gg->SetMarkerStyle(20); gg->SetMarkerSize(0); gg->SetMarkerColor(kBlue+2); ggacc->Draw("PLsame"); ggacc->SetLineStyle(1.); ggacc->SetLineWidth(3.); ggacc->SetLineColor(kMagenta); ggacc->SetMarkerStyle(20); ggacc->SetMarkerSize(0); ggacc->SetMarkerColor(kMagenta); bb->Draw("PLsame"); bb->SetLineStyle(1.); bb->SetLineWidth(3.); bb->SetLineColor(kRed+2); bb->SetMarkerStyle(20); bb->SetMarkerSize(0); bb->SetMarkerColor(kRed+2); bbacc->Draw("PLsame"); bbacc->SetLineStyle(1.); bbacc->SetLineWidth(3.); bbacc->SetLineColor(kOrange); bbacc->SetMarkerStyle(20); bbacc->SetMarkerSize(0); bbacc->SetMarkerColor(kOrange); /*SM->Draw("PLsame"); SM->SetLineStyle(8.); SM->SetLineWidth(3.); SM->SetLineColor(kGreen+1); SM->SetMarkerStyle(20); SM->SetMarkerSize(0); SM->SetMarkerColor(kGreen+1);*/ // signi->Draw("PLsame"); signi->SetLineStyle(1.); signi->SetLineWidth(2.); signi->SetLineColor(kBlack); signi->SetMarkerStyle(20); signi->SetMarkerSize(0); signi->SetMarkerColor(kBlack); TLegend* leg0; /// setup the CMS Preliminary //std::ostringstream ss; //ss << mA; //std::string s(ss.str()); std::string tanb_string = std::to_string((int)tanb); CMSPrelim(std::string("#events, m^{h}_{max} scenario, tan#beta = " + tanb_string).c_str(), "", 0.15, 0.835); leg0 = new TLegend(0.58, 0.12, 0.90, 0.32); leg0->SetBorderSize( 0 ); leg0->SetFillStyle ( 1001 ); leg0->SetFillColor (kWhite); //leg0->SetHeader( "#sigma * BR" ); //leg0->AddEntry( SM, "ggH_{SM} #rightarrow #tau#tau", "PL" ); //leg0->AddEntry( gghacc, "ggh #sigma*BR", "PL" ); //leg0->AddEntry( ggAacc, "ggA #sigma*BR", "PL" ); //leg0->AddEntry( ggHacc, "ggH #sigma*BR", "PL" ); leg0->AddEntry( gg, "gg #sigma*BR", "PL" ); //leg0->AddEntry( ggh, "ggh acc*s_{eff}*lumi", "PL" ); //leg0->AddEntry( ggA, "ggA acc*s_{eff}*lumi", "PL" ); //leg0->AddEntry( ggH, "ggH acc*sl_{eff}*lumi", "PL" ); leg0->AddEntry( ggacc, "gg acc*s_{eff}*lumi", "PL" ); //leg0->AddEntry( bbh, "bbh #sigma*BR", "PL" ); //leg0->AddEntry( bbA, "bbA #sigma*BR", "PL" ); //leg0->AddEntry( bbH, "bbH #sigma*BR", "PL" ); leg0->AddEntry( bb, "bb #sigma*BR", "PL" ); //leg0->AddEntry( bbhacc, "bbh acc*s_{eff}*lumi", "PL" ); //leg0->AddEntry( bbAacc, "bbA acc*s_{eff}*lumi", "PL" ); //leg0->AddEntry( bbHacc, "bbH acc*s_{eff}*lumi", "PL" ); leg0->AddEntry( bbacc, "bb acc*s_{eff}*lumi", "PL" ); //leg0->AddEntry( signi, "sum of all bins: s/sqrt(s+b)", "PL" ); leg0->Draw("same"); canv1->Print("xsBRtimesacc.png"); canv1->Print("xsBRtimesacc.pdf"); return; }
void quantiles() { // demo for quantiles // Author; Rene Brun const Int_t nq = 100; const Int_t nshots = 10; Double_t xq[nq]; // position where to compute the quantiles in [0,1] Double_t yq[nq]; // array to contain the quantiles for (Int_t i=0;i<nq;i++) xq[i] = Float_t(i+1)/nq; TGraph *gr70 = new TGraph(nshots); TGraph *gr90 = new TGraph(nshots); TGraph *gr98 = new TGraph(nshots); TH1F *h = new TH1F("h","demo quantiles",50,-3,3); for (Int_t shot=0;shot<nshots;shot++) { h->FillRandom("gaus",50); h->GetQuantiles(nq,yq,xq); gr70->SetPoint(shot,shot+1,yq[70]); gr90->SetPoint(shot,shot+1,yq[90]); gr98->SetPoint(shot,shot+1,yq[98]); } //show the original histogram in the top pad TCanvas *c1 = new TCanvas("c1","demo quantiles",10,10,600,900); c1->SetFillColor(41); c1->Divide(1,3); c1->cd(1); h->SetFillColor(38); h->Draw(); // show the final quantiles in the middle pad c1->cd(2); gPad->SetFrameFillColor(33); gPad->SetGrid(); TGraph *gr = new TGraph(nq,xq,yq); gr->SetTitle("final quantiles"); gr->SetMarkerStyle(21); gr->SetMarkerColor(kRed); gr->SetMarkerSize(0.3); gr->Draw("ap"); // show the evolution of some quantiles in the bottom pad c1->cd(3); gPad->SetFrameFillColor(17); gPad->DrawFrame(0,0,nshots+1,3.2); gPad->SetGrid(); gr98->SetMarkerStyle(22); gr98->SetMarkerColor(kRed); gr98->Draw("lp"); gr90->SetMarkerStyle(21); gr90->SetMarkerColor(kBlue); gr90->Draw("lp"); gr70->SetMarkerStyle(20); gr70->SetMarkerColor(kMagenta); gr70->Draw("lp"); // add a legend TLegend *legend = new TLegend(0.85,0.74,0.95,0.95); legend->SetTextFont(72); legend->SetTextSize(0.05); legend->AddEntry(gr98," q98","lp"); legend->AddEntry(gr90," q90","lp"); legend->AddEntry(gr70," q70","lp"); legend->Draw(); }
double thetaOpt2(double *par){ int upperAntNums[NUM_PHI]={8,0,9,1,10,2,11,3,12,4,13,5,14,6,15,7}; int lowerAntNums[NUM_PHI]={16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; int lowerAntFromUpper[NUM_PHI]={17,19,21,23,25,27,29,31,16,18,20,22,24,26,28,30}; int nadirAntNums[NUM_PHI]={32,-1,33,-1,34,-1,35,-1,36,-1,37,-1,38,-1,39,-1}; int bottomFromNadir[8]={16,18,20,22,24,26,28,30}; Double_t deltaR[40]={0}; Double_t deltaZ[40]={0}; Double_t deltaPhi[40]={0}; Double_t deltaHeading[1]={0}; double deltaTArrayMod[40]={0}; int count3 = 0; // for(int i = 0; i<32;i++){ // deltaR[i]=par[i]; // deltaZ[i]=par[i+32]; // deltaPhi[i]=par[i+64]; // cout << i << " " <<0 << " " << deltaR[i] << " " << deltaPhi[i] << " " << deltaZ[i] << endl; // } for(int i = 7; i<8;i++){ deltaR[7]=par[0]; deltaZ[7]=par[1]; deltaPhi[7]=par[2]; cout << i << " " <<0 << " " << deltaR[i] << " " << deltaPhi[i] << " " << deltaZ[i] << endl; } // for(int i = 0; i<16;i++){ // deltaPhi[i]=deltaPhi[i] + par[16]; // deltaPhi[i+16]=deltaPhi[i+16] + par[17]; // } double theReturn = 0; double sumMean = 0; double sumMean2 = 0; int count8 = 0; double sumGrads = 0; TMultiGraph *myMG = new TMultiGraph; TMultiGraph *myMG3 = new TMultiGraph; TMultiGraph *myMG2 = new TMultiGraph;; AnitaGeomTool *fGeomTool = AnitaGeomTool::Instance(); char eventName[FILENAME_MAX]; char headerName[FILENAME_MAX]; char hkName[FILENAME_MAX]; char gpsName[FILENAME_MAX]; char corrName[FILENAME_MAX]; char outName[FILENAME_MAX]; char baseDir[FILENAME_MAX]; char *corTreeDir = "../../../Outfiles"; double dummyArray[40][1] ={{0}}; TGraph *tempAntGraph; vector<vector<double> > phiAngle; vector<vector<double> > deltaTVec; vector<vector<int> > firstAntVec; vector<vector<int> > secondAntVec; vector<vector<double> > phiAngleArray2; vector<vector<double> > deltaTArray2; vector<double> temp; vector<int> temp2; temp.push_back(0); temp2.push_back(0); double deltaTArrayLoop[6000] ={0}; double phiAngleArrayLoop[6000] = {0}; int leftOpt, rightOpt; double meanPhi[40] = {0}; meanPhi[0] =22.5-12.5; meanPhi[1] =67.5-12.5; meanPhi[2] =112.5-12.5; meanPhi[3] =157.5-12.5; meanPhi[4] =202.5-12.5; meanPhi[5] =247.5-12.5; meanPhi[6] =292.5-12.5; meanPhi[7] =337.5-12.5; meanPhi[8] =45-12.5; meanPhi[9] =90-12.5; meanPhi[10] =135-12.5; meanPhi[11] =180-12.5; meanPhi[12] =225-12.5; meanPhi[13] =270-12.5; meanPhi[14] =315-12.5; meanPhi[15] =360-12.5; meanPhi[16] = 22.5-12.5; meanPhi[17] = 45-12.5; meanPhi[18] = 67.5-12.5; meanPhi[19] = 90-12.5; meanPhi[20] = 112.5-12.5; meanPhi[21] = 135-12.5; meanPhi[22] = 157.5-12.5; meanPhi[23] = 180-12.5; meanPhi[24] = 202.5-12.5; meanPhi[25] = 225-12.5; meanPhi[26] = 247.5-12.5; meanPhi[27] = 270-12.5; meanPhi[28] = 292.5-12.5; meanPhi[29] = 315-12.5; meanPhi[30] = 337.5-12.5; meanPhi[31] = 360-12.5; meanPhi[32] = 22.5-12.5; meanPhi[33] = 67.5-12.5; meanPhi[34] = 112.5-12.5; meanPhi[35] = 157.5-12.5; meanPhi[36] = 202.5-12.5; meanPhi[37] = 247.5-12.5; meanPhi[38] = 292.5-12.5; meanPhi[39] = 337.5-12.5; for(int i =0; i < 40; i++){ phiAngleArray2.push_back(temp); deltaTArray2.push_back(temp); } for(int loop = 1; loop <4; loop++){ int run = 16+loop; //int run = 18; canSurf->cd(loop+1); phiAngle.clear(); deltaTVec.clear(); firstAntVec.clear(); secondAntVec.clear(); for(int i = 0; i < 40; i++){ phiAngle.push_back(temp); deltaTVec.push_back(temp); firstAntVec.push_back(temp2); secondAntVec.push_back(temp2); } //sprintf(baseDir,"http://www.hep.ucl.ac.uk/uhen/anita/private/monitor2/runs/fromLoki/"); sprintf(baseDir,"/Users/simonbevan/Desktop/"); sprintf(eventName,"%s/run%d/eventFile%d.root",baseDir,run,run); sprintf(headerName,"%s/run%d/headFile%d.root",baseDir,run,run); sprintf(gpsName,"%s/run%d/gpsFile%d.root",baseDir,run,run); sprintf(corrName,"%s/corRun%d.root",corTreeDir,run); RawAnitaEvent *event = 0; PrettyAnitaHk *hk = 0; RawAnitaHeader *header =0; Adu5Pat *pat =0; CorrelationSummary *corSum =0; TFile *fpHead = TFile::Open(headerName); TTree *headTree = (TTree*) fpHead->Get("headTree"); headTree->SetBranchAddress("header",&header); headTree->BuildIndex("eventNumber"); TFile *fpGps = TFile::Open(gpsName); TTree *adu5PatTree = (TTree*) fpGps->Get("adu5PatTree"); adu5PatTree->BuildIndex("realTime"); adu5PatTree->SetBranchAddress("pat",&pat); Int_t labChip; TFile *fpCor = new TFile(corrName); TTree *corTree = (TTree*) fpCor->Get("corTree"); corTree->SetBranchAddress("cor",&corSum); corTree->SetBranchAddress("labChip",&labChip); Long64_t numEntries=corTree->GetEntries(); int counter=0; Long64_t entry=0; UInt_t eventNumber, triggerTime, triggerTimeNs; Int_t firstAnt,secondAnt,maxAnt,corInd; Double_t deltaT,deltaTExpected; Double_t phiWave, phiMaxAnt; Double_t corPeak, corRMS; Double_t balloonLat, balloonLon, balloonAlt; Double_t heading,pitch,roll; Double_t thetaWave; for(entry=0;entry<numEntries;entry++) { corTree->GetEntry(entry); Long64_t headEntry=headTree->GetEntryNumberWithIndex(corSum->eventNumber); if(headEntry<0) continue; headTree->GetEntry(headEntry); if( (header->triggerTimeNs>0.5e6) || (header->triggerTimeNs<0.2e6) ) continue; triggerTimeNs=header->triggerTimeNs; triggerTime=header->triggerTime; eventNumber=header->eventNumber; Long64_t bestEntry = adu5PatTree->GetEntryNumberWithBestIndex(header->triggerTime); if(bestEntry>-1) adu5PatTree->GetEntry(bestEntry); else continue; balloonLat=pat->latitude; balloonLon=pat->longitude; balloonAlt=pat->altitude; heading=pat->heading; pat->pitch=0.64; pat->roll=0.14; pitch=pat->pitch; roll=pat->roll; UsefulAdu5Pat usefulPat(pat); for(corInd=0;corInd<19;corInd++) { firstAnt=corSum->firstAnt[corInd]; secondAnt=corSum->secondAnt[corInd]; //replace taylor dome usefulPat.fSourceLongitude=0; // deltaTExpected=usefulPat.getDeltaTTaylor(corSum->firstAnt[corInd],corSum->secondAnt[corInd]); deltaTExpected=usefulPat.getDeltaTTaylorOpt(corSum->firstAnt[corInd],corSum->secondAnt[corInd],deltaR,deltaZ,deltaPhi); deltaT=corSum->maxCorTimes[corInd]; maxAnt=corSum->centreAntenna; phiWave=usefulPat.getPhiWave()*TMath::RadToDeg(); phiMaxAnt=fGeomTool->getAntPhiPositionRelToAftFore(corSum->centreAntenna)*TMath::RadToDeg(); corPeak=corSum->maxCorVals[corInd]; corRMS=corSum->rmsCorVals[corInd]; if((deltaT - deltaTExpected)*(deltaT - deltaTExpected) < 1 && (corPeak/corRMS)>8 ){ phiAngle[0].push_back(phiWave); deltaTVec[0].push_back(deltaT - deltaTExpected + deltaTArrayMod[firstAnt] - deltaTArrayMod[secondAnt]); firstAntVec[0].push_back(firstAnt); secondAntVec[0].push_back(secondAnt); } } counter++; } double deltaTArray[40][3000] = {{0}}; double phiAngleArray[40][3000]= {{0}}; double deltaTArrayCut[40][3000]= {{0}}; double phiAngleArrayCut[40][3000]= {{0}}; int whichCut[40][3000] = {{0}}; int middleAnt; int leftAnt,rightAnt; int countArray[40] = {0}; //fill arrays //for(int ants = par[0]; ants < par[0]+1; ants++){ for(int ants = 0; ants < 32; ants++){ double lower = meanPhi[ants] - 20; double upper = meanPhi[ants] + 10; // double lower = 0; // double upper = 360; if(ants<8){ lower = lower; upper=upper; if(lower < 0){ lower = 0; upper = 20; } if(upper > 360){ lower = 330; upper = 360; } }else if(ants<16){ lower = lower; upper= upper; if(lower < 0){ lower = 330; upper = 355; } if(upper > 360){ lower = 330; upper = 360; } } int count = 0; int count2 = 0; count3 = 0; double sumPhi = 0; bool true1 = false; bool true2 = false; if(ants <32){ fGeomTool->getThetaPartners(ants,leftAnt,rightAnt); }else{ leftAnt = ants; rightAnt = ants +1; if(ants == 39){ leftAnt = ants; rightAnt = 32; } } for(int events = 1; events < phiAngle[0].size(); events++){ int firstAntTemp = (int)firstAntVec[0][events]; int secondAntTemp = (int)secondAntVec[0][events]; int rightTemp = int(rightAnt); int aboveTemp = 0; if(ants <16){ aboveTemp = lowerAntFromUpper[ants]; }else{ aboveTemp = upperAntNums[ants-16]; } if(firstAntTemp < 32){ if( ((firstAntTemp == ants) && (secondAntTemp == rightTemp))){ //if((firstAntTemp == ants) && (secondAntTemp == rightTemp)){ if((phiAngle[0][events] > lower ) && (phiAngle[0][events]< upper)){ deltaTArray[ants][count] = deltaTVec[0][events]; phiAngleArray[ants][count] = phiAngle[0][events]; whichCut[ants][count] = 1; count++; } } else if(((firstAntTemp == ants) && (secondAntTemp == aboveTemp))){ // //if((firstAntTemp == ants) && (secondAntTemp == rightTemp)){ double lower = meanPhi[ants] - 20; double upper = meanPhi[ants] + 10; // double lower = 0; // double upper = 360; if(ants<8){ lower = lower; upper=upper; if(lower < 0){ lower = 0; upper = 20; } if(upper > 360){ lower = 330; upper = 360; } }else if(ants<16){ lower = lower - 45; upper= upper - 45; if(lower < 0){ lower = 330; upper = 355; } if(upper > 360){ lower = 330; upper = 360; } } // if((phiAngleArray[ants][events] > lower ) && (phiAngleArray[ants][events]< upper)){ if((phiAngle[0][events] > lower ) && (phiAngle[0][events]< upper)){ deltaTArray[ants][count] = deltaTVec[0][events]; phiAngleArray[ants][count] = phiAngle[0][events]; whichCut[ants][count] = 0; count++; } } }else{ rightTemp = firstAntTemp+1; if(rightTemp>39){ rightTemp = 32; } if(firstAntTemp == ants){ } if((firstAntTemp == ants) && (secondAntTemp == rightTemp)){ deltaTArray[ants][count] = deltaTVec[0][events]; phiAngleArray[ants][count] = phiAngle[0][events]; whichCut[ants][count] = 3; count++; } } } countArray[ants] = count; } //make cuts for(int ants = 0; ants < 32; ants++){ count3 = 0; if(ants <32){ fGeomTool->getThetaPartners(ants,leftAnt,rightAnt); }else{ leftAnt = ants -1; rightAnt = ants +1; if(ants == 39){ leftAnt = ants - 1; rightAnt = 32; } } double sumPhi = 0; double lower = meanPhi[ants] - 20; double upper = meanPhi[ants] + 10; // double lower = 0; // double upper = 360; if(ants<8){ lower = lower; upper=upper; if(lower < 0){ lower = 0; upper = 20; } if(upper > 360){ lower = 330; upper = 360; } }else if(ants<16){ lower = lower; upper= upper; if(lower < 0){ lower = 330; upper = 355; } if(upper > 360){ lower = 330; upper = 360; } } for(int events = 0; events < countArray[ants]; events++){ // if(whichCut[ants][events]==1){ // lower = meanPhi[ants] - 20; // upper = meanPhi[ants] + 20; // if(lower < 0){ // lower = 0; // upper = 20; // } // if(upper > 360){ // lower = 330; // upper = 360; // } // } // if((phiAngleArray[ants][events] > lower ) && (phiAngleArray[ants][events]< upper)){ phiAngleArrayCut[ants][count3] = phiAngleArray[ants][events]; deltaTArrayCut[ants][count3] = deltaTArray[ants][events]; count3++; // } } for(int events = 0; events < count3-1; events++){ phiAngleArray2[ants].push_back(phiAngleArrayCut[ants][events]); deltaTArray2[ants].push_back(deltaTArrayCut[ants][events]); } } delete event; delete hk; delete header; delete pat; delete corSum; delete fpHead; delete fpGps ; delete fpCor; } sumMean = 0; sumMean2 = 0; sumGrads = 0; for(int ants = 0; ants < 32; ants++){ count8 = 0; for(int events = 1; events < phiAngleArray2[ants].size(); events++){ if( deltaTArrayLoop[count8]<1){ deltaTArrayLoop[count8] = deltaTArray2[ants][events]; phiAngleArrayLoop[count8] = phiAngleArray2[ants][events]; count8++; } } if(count8==0){ tempAntGraph = new TGraph(1, dummyArray[ants], dummyArray[ants]); }else{ tempAntGraph = new TGraph(count8-1, phiAngleArrayLoop, deltaTArrayLoop); if(ants == 7){ canSurf->cd(1); tempAntGraph->SetMinimum(-0.5); tempAntGraph->SetMaximum(0.5); tempAntGraph->Draw("ap"); tempAntGraph->SetMarkerStyle(1); tempAntGraph->GetXaxis()->SetLimits(0,360); sumMean = sumMean + tempAntGraph->GetMean(2)*tempAntGraph->GetMean(2); if(ants == 8 || ants == 16 || ants == 12 || ants == 24){ tempAntGraph->SetMarkerColor(8); } if(ants == 3 || ants == 7 || ants == 23 || ants == 31){ tempAntGraph->SetMarkerColor(1); } if(ants == 9 || ants == 13 || ants == 18 || ants == 26){ tempAntGraph->SetMarkerColor(2); } if(ants == 10 || ants == 14 || ants == 20 || ants == 28){ tempAntGraph->SetMarkerColor(3); } if(ants == 11 || ants == 15 || ants == 22 || ants == 30){ tempAntGraph->SetMarkerColor(4); } if(ants == 0 || ants == 4 || ants == 17 || ants == 25){ tempAntGraph->SetMarkerColor(5); } if(ants == 2 || ants == 6 || ants == 21 || ants == 29){ tempAntGraph->SetMarkerColor(6); } if(ants == 1 || ants == 5 || ants == 19 || ants == 27){ tempAntGraph->SetMarkerColor(7); } tempAntGraph->GetXaxis()->SetTitle("phi (degrees)"); tempAntGraph->GetYaxis()->SetTitle("actual - expected time"); myMG2->Add(tempAntGraph); myMG2->Draw("p"); vector<double> myFit = leastSquares(phiAngleArrayLoop, deltaTArrayLoop, count8-1); double slope = myFit[0]; double intercept = myFit[1]; double tempX[2] = {slope*(meanPhi[ants]-20)+intercept,slope*(meanPhi[ants]+20)+intercept}; double tempY[2] = {(meanPhi[ants]-20),(meanPhi[ants]+20)}; sumGrads = sumGrads + myFit[0]*myFit[0]*10000; } } } cout << " " << endl; cout << sumMean << " " << sumGrads <<endl; canSurf->Update(); cout << " " << endl; theReturn = sumMean+sumGrads; return theReturn; }
void BiasDiff () { vector<TH1F*> AIC; for (UInt_t i = 1 ; i <= 7; i++){ AIC.push_back( new TH1F( Form("AIC_%d",i), " ", 9, 0,10 )); AIC[i-1]->GetXaxis()->SetBinLabel(1,"category 0"); AIC[i-1]->GetXaxis()->SetBinLabel(2,""); AIC[i-1]->GetXaxis()->SetBinLabel(3,"category 1"); AIC[i-1]->GetXaxis()->SetBinLabel(4,""); AIC[i-1]->GetXaxis()->SetBinLabel(5,"category 2"); AIC[i-1]->GetXaxis()->SetBinLabel(6,""); AIC[i-1]->GetXaxis()->SetBinLabel(7,"category 3"); AIC[i-1]->GetXaxis()->SetBinLabel(8,""); AIC[i-1]->GetXaxis()->SetBinLabel(9,"Inclusive"); AIC[i-1]->SetFillColor(bkgColors[i-1]); AIC[i-1]->SetLineColor(bkgColors[i-1]); } AIC[0]->Fill(1.0,0.02); AIC[0]->Fill(3.0,0.3089); AIC[0]->Fill(5.0,0.62); AIC[0]->Fill(7.0,0.36); AIC[0]->Fill(9.0,0.03); AIC[1]->Fill(1.0,0.08); AIC[1]->Fill(3.0,0.21); AIC[1]->Fill(5.0,0.08); AIC[1]->Fill(7.0,0.16); AIC[1]->Fill(9.0,0.33); AIC[2]->Fill(1.0,0.01); AIC[2]->Fill(3.0,0.02); AIC[2]->Fill(5.0,0.01); AIC[2]->Fill(7.0,0.02); AIC[2]->Fill(9.0,0.04); AIC[3]->Fill(1.0,0.20); AIC[3]->Fill(3.0,0.38); AIC[3]->Fill(5.0,0.24); AIC[3]->Fill(7.0,0.451); AIC[3]->Fill(9.0,0.60); AIC[4]->Fill(1.0,0.03); AIC[4]->Fill(3.0,0.08); AIC[4]->Fill(5.0,0.017); AIC[4]->Fill(7.0,0.001); AIC[4]->Fill(9.0,0.0001); AIC[5]->Fill(1.0,0.58); AIC[5]->Fill(3.0,0.001); AIC[5]->Fill(5.0,0.03); AIC[5]->Fill(7.0,0.007); AIC[5]->Fill(9.0,0.000003); AIC[6]->Fill(1.0,0.08); AIC[6]->Fill(3.0,0.0001); AIC[6]->Fill(5.0,0.003); AIC[6]->Fill(7.0,0.001); AIC[6]->Fill(9.0,0.0000004); TCanvas *cv = 0; TLegend *legend = 0; bool firstdrawn = false; // =================================== // AIC // =================================== cv = new TCanvas("cv","cv",800,600); legend = new TLegend(0.64,0.64,0.90,0.84); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); THStack *stackAIC = new THStack(); for (Int_t i = AIC.size()-1; i>=0; i--) { if (AIC[i]->Integral()>0) { stackAIC->Add(AIC[i]); legend->AddEntry(AIC[i],modelLegendLabels[i].c_str(),"F"); } } stackAIC->Draw(); stackAIC->GetHistogram()->GetXaxis()->SetTitle(((TH1F*)(stackAIC->GetHists()->At(0)))->GetXaxis()->GetTitle()); legend->Draw(); cv->SaveAs("AICvalues.pdf"); // ======================================================= //double x[7] = {1.0,2.0,3.0,4.0,5.0,6.0,7.0}; double x[4] = {1.0,2.0,3.0,4.0}; double comps[4],singEs[4],doubEs[4],tripEs[4],modEs[4],polys[4],pows[4],dpows[4]; //Composite //comps[0] = ( (0.0042-0.0033)/0.0033+(0.0007-0.0036)/0.0036+(0.0180-0.012)/0.012+(0.0090-0.0023)/0.0023+ (0.0033-0.0031)/0.0031 ) /5; comps[0] = ( (0.0045-0.0043)/0.0043 + (0.0035-0.0018)/0.0018 + (0.0074-0.0084)/0.0084 + (0.0053-0.0065)/0.0065 + (0.0016-0.0029)/0.0029 ) /5; //comps[2] = ( (0.0036-0.0049)/0.0049 + (0.0075-0.0029)/0.0029 + (0.0125-0.0126)/0.0126 + (0.0041-0.0031)/0.0031 + (0.0053-0.0027)/0.0027 )/ 5; comps[1] = ( (0.0088-0.0122)/0.0122 + (0.0072-0.0064)/0.0064 + (0.0064-0.0057)/0.0057 ) / 3; comps[2] = ( (0.0142-0.0254)/0.0254 + (0.0118-0.0120)/0.0120 + (0.0024-0.0105)/0.0105 + (0.0057-0.0102)/0.0102 ) / 4; //comps[5] = ((0.0047 - 0.0043)/0.0043 + (0.0091 - 0.0083)/0.0083 + (0.0062 - 0.0071)/0.0071 + (0.0129-0.0120)/0.0120 + (0.0035 - 0.0014)/0.0014 ) / 5; comps[3] = ( (0.0040 - 0.0059)/0.0059 + (0.004 - 0.0009)/0.0009 + (0.0088 - 0.0046)/0.0046 + (0.0026 - 0.0033)/0.0033 + (0.0014 - 0.0022)/0.0022 ) / 5; //singE singEs[0] = ( (0.0221-0.0043)/0.0043 + (0.0079-0.0018)/0.0018 + (0.0084-0.0084)/0.0084 + (0.0033-0.0065)/0.0065 + (0.0082-0.0029)/0.0029 ) /5; singEs[1] = ( (0.0050-0.0122)/0.0122 + (0.0084-0.0064)/0.0064 + (0.0114-0.0057)/0.0057 ) / 3; singEs[2] = ( (0.0196-0.0254)/0.0254 + (0.0024-0.0120)/0.0120 + (0.0008-0.0105)/0.0105 + (0.0003-0.0102)/0.0102 ) / 4; //singEs[3] = ( (0.0126 - 0.0059)/0.0059 + (0.0174 - 0.0009)/0.0009 + (0.0129 - 0.0046)/0.0046 + (0.0193 - 0.0033)/0.0033 + (0.0181 - 0.0022)/0.0022 ) / 5; singEs[3] = 3.0; //doubE doubEs[0] = 0; doubEs[1] = ( (0.0079-0.0122)/0.0122 + (0.0084-0.0064)/0.0064 + (0.0073-0.0057)/0.0057 ) / 3; doubEs[2] = ( (0.0069-0.0254)/0.0254 + (0.0002-0.0120)/0.0120 + (0.0016-0.0105)/0.0105 + (0.0093-0.0102)/0.0102 ) / 4; doubEs[3] = ( (0.0035 - 0.0059)/0.0059 + (0.004 - 0.0009)/0.0009 + (0.0097 - 0.0046)/0.0046 + (0.0041 - 0.0033)/0.0033 + (0.0052 - 0.0022)/0.0022 ) / 5; //tripE tripEs[0] = ( (0.0045-0.0043)/0.0043 + (0.0035-0.0018)/0.0018 + (0.0074-0.0084)/0.0084 + (0.0053-0.0065)/0.0065 + (0.0016-0.0029)/0.0029 ) /5; tripEs[1] = ( (0.0079-0.0122)/0.0122 + (0.0084-0.0064)/0.0064 + (0.0073-0.0057)/0.0057 ) / 3; tripEs[2] = ( (0.0069-0.0254)/0.0254 + (0.0004-0.0120)/0.0120 + (0.0017-0.0105)/0.0105 + (0.0027-0.0102)/0.0102 ) / 4; tripEs[3] = ( (0.0039 - 0.0059)/0.0059 + (0.0043 - 0.0009)/0.0009 + (0.0092 - 0.0046)/0.0046 + (0.0015 - 0.0033)/0.0033 + (0.0039 - 0.0022)/0.0022 ) / 5; //modE modEs[0] = ( (0.0076-0.0043)/0.0043 + (0.0022-0.0018)/0.0018 + (0.0022-0.0084)/0.0084 + (0.0071-0.0065)/0.0065 + (0.0008-0.0029)/0.0029 ) /5; modEs[1] = 0; modEs[2] = ( (0.0051-0.0254)/0.0254 + (0.001-0.0120)/0.0120 + (0.0017-0.0105)/0.0105 + (0.0041-0.0102)/0.0102 ) / 4; modEs[3] = ( (0.0026 - 0.0059)/0.0059 + (0.0037 - 0.0009)/0.0009 + (0.0088 - 0.0046)/0.0046 + (0.0072 - 0.0033)/0.0033 + (0.0049 - 0.0022)/0.0022 ) / 5; //poly **** polys[0] = ( (0.0094-0.0043)/0.0043 + (0.0041-0.0018)/0.0018 + (0.0178-0.0084)/0.0084 + (0.0019-0.0065)/0.0065 + (0.0036-0.0029)/0.0029 ) /5; polys[1] = ( (0.0088-0.0122)/0.0122 + (0.0050-0.0064)/0.0064 + (0.0544-0.0057)/0.0057 ) / 3; polys[2] = 0; polys[3] = ( (0.0111 - 0.0059)/0.0059 + (0.0070 - 0.0009)/0.0009 + (0.0091 - 0.0046)/0.0046 + (0.0055 - 0.0033)/0.0033 + (0.0099 - 0.0022)/0.0022 ) / 5; //pow pows[0] = ( (0.0042-0.0043)/0.0043 + (0.0093-0.0018)/0.0018 + (0.026-0.0084)/0.0084 + (0.0183-0.0065)/0.0065 + (0.0082-0.0029)/0.0029 ) /5; pows[1] = ( (0.0022-0.0122)/0.0122 + (0.0031-0.0064)/0.0064 + (0.0052-0.0057)/0.0057 ) / 3; pows[2] = ( (0.0018-0.0254)/0.0254 + (0.0153-0.0120)/0.0120 + (0.0194-0.0105)/0.0105 + (0.0149-0.0102)/0.0102 ) / 4; pows[3] = ( (0.0058 - 0.0059)/0.0059 + (0.0009 - 0.0009)/0.0009 + (0.0045 - 0.0046)/0.0046 + (0.0047 - 0.0033)/0.0033 + (0.0021 - 0.0022)/0.0022 ) / 5; //dpow **** dpows[0] = ( (0.0005-0.0043)/0.0043 + (0.0093-0.0018)/0.0018 + (0.0261-0.0084)/0.0084 + (0.0183-0.0065)/0.0065 + (0.0082-0.0029)/0.0029 ) /5; dpows[1] = ( (0.0022-0.0122)/0.0122 + (0.0030-0.0064)/0.0064 + (0.0052-0.0057)/0.0057 ) / 3; dpows[2] = ( (0.0018-0.0254)/0.0254 + (0.0153-0.0120)/0.0120 + (0.0194-0.0105)/0.0105 + (0.0097-0.0102)/0.0102 ) / 4; dpows[3] = 0; TMultiGraph *mg = new TMultiGraph(); TGraph *comp = new TGraph(4, x,comps); TGraph *singE = new TGraph(4,x,singEs); TGraph *doubE = new TGraph(4,x,doubEs); TGraph *tripE = new TGraph(4,x,tripEs); TGraph *modE = new TGraph(4,x,modEs); TGraph *poly = new TGraph(4,x,polys); TGraph *pow = new TGraph(4,x,pows); TGraph *dpow = new TGraph(4,x,dpows); legend = new TLegend(0.64,0.64,0.92,0.94); //comp->GetXaxis()->SetBinLabel(1,"Single Exp."); dpow->GetXaxis()->SetBinLabel(1,"Double Exp."); //comp->GetXaxis()->SetBinLabel(3,"Triple Exp."); dpow->GetXaxis()->SetBinLabel(2,"Modified Exp."); dpow->GetXaxis()->SetBinLabel(3,"Polynomial"); //comp->GetXaxis()->SetBinLabel(6,"Single Power"); dpow->GetXaxis()->SetBinLabel(4,"Double Power"); singE->SetMarkerColor(bkgColors[0]); doubE->SetMarkerColor(bkgColors[1]); tripE->SetMarkerColor(bkgColors[2]); modE->SetMarkerColor(bkgColors[3]); poly->SetMarkerColor(bkgColors[4]); pow->SetMarkerColor(bkgColors[5]); dpow->SetMarkerColor(bkgColors[6]); comp->SetMarkerColor(28); singE->SetLineColor(bkgColors[0]); doubE->SetLineColor(bkgColors[1]); tripE->SetLineColor(bkgColors[2]); modE->SetLineColor(bkgColors[3]); poly->SetLineColor(bkgColors[4]); pow->SetLineColor(bkgColors[5]); dpow->SetLineColor(bkgColors[6]); comp->SetLineColor(28); legend->AddEntry(comp,"Composite","p"); legend->AddEntry(singE,"Single Exponential","p"); legend->AddEntry(doubE,"Double Exponential","p"); legend->AddEntry(tripE,"Triple Exponential","p"); legend->AddEntry(modE,"Modified Exponential","p"); legend->AddEntry(poly,"Polynomial","p"); legend->AddEntry(pow,"Power Law","p"); legend->AddEntry(dpow,"Double Power Law","p"); mg->Add(comp); mg->Add(singE); mg->Add(doubE); mg->Add(tripE); mg->Add(modE); mg->Add(poly); mg->Add(pow); mg->Add(dpow); //mg->GetYaxis()->SetRangeUser(-1,3); cv = new TCanvas("cv","cv",800,600); mg->Draw("apl"); legend->Draw(); cv->Update(); cv->SaveAs("BiasAverages.pdf"); }
void makePlots( const char * model, const char * src, const char * infile , const char * option ) { //Output path TString path("./paper01-plots/probs/"); TString dataPee = TString( model ) + TString("_") + TString( src ) + TString("_Pee/data"); TString dataPem = TString( model ) + TString("_") + TString( src ) + TString("_Pem/data"); TString dataPet = TString( model ) + TString("_") + TString( src ) + TString("_Pet/data"); TString dataAPee = TString( model ) + TString("_") + TString( src ) + TString("_aPee/data"); TString dataAPem = TString( model ) + TString("_") + TString( src ) + TString("_aPem/data"); TString dataAPet = TString( model ) + TString("_") + TString( src ) + TString("_aPet/data"); TList * v_Labels = new TList(); TObjString *label; label = new TObjString( "Pee" ); v_Labels->Add( label ); label = new TObjString( "Pe#mu" ); v_Labels->Add( label ); label = new TObjString( "Pe#tau" ); v_Labels->Add( label ); TFile * f1 = new TFile(infile); f1->cd(); TTree * PeeTreeNu = (TTree*)gDirectory->Get( dataPee.Data() ); TTree * PemTreeNu = (TTree*)gDirectory->Get( dataPem.Data() ); TTree * PetTreeNu = (TTree*)gDirectory->Get( dataPet.Data() ); TTree * PeeTreeANu = (TTree*)gDirectory->Get( dataAPee.Data() ); TTree * PemTreeANu = (TTree*)gDirectory->Get( dataAPem.Data() ); TTree * PetTreeANu = (TTree*)gDirectory->Get( dataAPet.Data() ); //Branches double xx = 0.0; double yy = 0.0; TCanvas * c1 = new TCanvas(model, "Oscillation probabilities", 184, 60, 861, 670); c1->Divide(1,3); TGraph * ProbNu[3]; ProbNu[0] = new TGraph(); ProbNu[1] = new TGraph(); ProbNu[2] = new TGraph(); TGraph * ProbANu[3]; ProbANu[0] = new TGraph(); ProbANu[1] = new TGraph(); ProbANu[2] = new TGraph(); TGraph * Psum = new TGraph(); TGraph * aPsum = new TGraph(); TLegend * leg = new TLegend(0.14,0.69,0.24,0.85); PeeTreeNu->SetBranchAddress("Ex",&xx); PeeTreeNu->SetBranchAddress("Pb",&yy); Long64_t nentries = PeeTreeNu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PeeTreeNu->GetEntry(i); ProbNu[0]->SetPoint( i, xx, yy); } PeeTreeANu->SetBranchAddress("Ex",&xx); PeeTreeANu->SetBranchAddress("Pb",&yy); nentries = PeeTreeANu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PeeTreeANu->GetEntry(i); ProbANu[0]->SetPoint( i, xx, yy); } ///Pem PemTreeNu->SetBranchAddress("Ex",&xx); PemTreeNu->SetBranchAddress("Pb",&yy); nentries = PemTreeNu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PemTreeNu->GetEntry(i); ProbNu[1]->SetPoint( i, xx, yy); } PemTreeANu->SetBranchAddress("Ex",&xx); PemTreeANu->SetBranchAddress("Pb",&yy); nentries = PemTreeANu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PemTreeANu->GetEntry(i); ProbANu[1]->SetPoint( i, xx, yy); } ///Pet PetTreeNu->SetBranchAddress("Ex",&xx); PetTreeNu->SetBranchAddress("Pb",&yy); nentries = PetTreeNu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PetTreeNu->GetEntry(i); ProbNu[2]->SetPoint( i, xx, yy); } PetTreeANu->SetBranchAddress("Ex",&xx); PetTreeANu->SetBranchAddress("Pb",&yy); nentries = PetTreeANu->GetEntries(); for (Long64_t i=0;i<nentries;i++) { PetTreeANu->GetEntry(i); ProbANu[2]->SetPoint( i, xx, yy); } for( int k=0; k < 3; ++k) { ProbNu[k]->SetLineColor(4); ProbNu[k]->SetMarkerColor(4); ProbNu[k]->SetMarkerStyle(7); ProbNu[k]->SetFillColor(10); ProbNu[k]->SetMaximum(1.0); ProbNu[k]->SetMinimum(0.0); TString yaxis = ((TObjString*)v_Labels->At(k))->GetString(); ProbNu[k]->GetYaxis()->SetTitle( yaxis.Data() ); ProbNu[k]->GetXaxis()->SetTitle("E [eV]"); ProbNu[k]->GetYaxis()->CenterTitle(true); ProbNu[k]->GetXaxis()->CenterTitle(true); ProbNu[k]->GetXaxis()->SetLabelOffset(0.007); ProbNu[k]->GetXaxis()->SetLabelSize(0.08); ProbNu[k]->GetXaxis()->SetTitleSize(0.07); ProbNu[k]->GetXaxis()->SetTitleOffset(0.9); ProbNu[k]->GetXaxis()->SetLabelFont(42); ProbNu[k]->GetYaxis()->SetLabelOffset(0.007); ProbNu[k]->GetYaxis()->SetLabelSize(0.08); ProbNu[k]->GetYaxis()->SetLabelFont(42); ProbNu[k]->GetYaxis()->SetTitleSize(0.09); ProbNu[k]->GetYaxis()->SetTitleOffset(0.45); ProbNu[k]->GetYaxis()->SetTitleFont(42); ProbANu[k]->SetMarkerColor(42); ProbANu[k]->SetMarkerStyle(23); ProbANu[k]->SetMarkerSize(0.3); ProbANu[k]->SetFillColor(10); ProbANu[k]->SetMaximum(1.0); ProbANu[k]->SetMinimum(0.0); } leg->AddEntry( ProbNu[0], "#nu"); leg->AddEntry( ProbANu[0], "#bar{#nu}"); leg->SetBorderSize(0); leg->SetTextSize(0.1); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); c1->cd(1); gPad->SetGridx(); gPad->SetGridy(); gPad->SetLogx(); if ( std::string(model).compare("EarthB") == 0 ) ProbNu[0]->GetXaxis()->SetLimits(0.98e9, 1.0e10); ProbNu[0]->Draw("APL"); ProbANu[0]->Draw("PL"); topTitle(model); leg->DrawClone(); c1->cd(2); gPad->SetGridx(); gPad->SetGridy(); gPad->SetLogx(); if ( std::string(model).compare("EarthB") == 0 ) ProbNu[1]->GetXaxis()->SetLimits(0.98e9, 1.0e10); ProbNu[1]->Draw("APL"); ProbANu[1]->Draw("PL"); leg->DrawClone(); c1->cd(3); gPad->SetGridx(); gPad->SetGridy(); gPad->SetLogx(); if ( std::string(model).compare("EarthB") == 0 ) ProbNu[2]->GetXaxis()->SetLimits(0.98e9, 1.0e10); ProbNu[2]->Draw("APL"); ProbANu[2]->Draw("PL"); leg->DrawClone(); c1->cd(); std::stringstream saveAs; saveAs.str(""); saveAs << path << model << "/pdf/" << "nueosc_probs_" << model << "_" << option << ".pdf"; c1->SaveAs( saveAs.str().c_str() ); saveAs.str(""); saveAs << path << model << "/png/" << "nueosc_probs_" << model << "_" << option << ".png"; c1->SaveAs( saveAs.str().c_str() ); saveAs.str(""); saveAs << path << model << "/eps/" << "nueosc_probs_" << model << "_" << option << ".eps"; c1->SaveAs( saveAs.str().c_str() ); TH1D * h_Psum = new TH1D("Psum.Histo","",100, 0.99999, 1.0001); TH1D * h_aPsum = h_Psum->Clone("aPsum.Histo"); for (Long64_t i=0;i<nentries;i++) { double xx = 0.0; double yy = 0.0; double p1 = 0.0; double p2 = 0.0; double p3 = 0.0; ProbNu[0]->GetPoint(i, xx, p1); ProbNu[1]->GetPoint(i, xx, p2); ProbNu[2]->GetPoint(i, xx, p3); yy = p1 + p2 + p3; if ( xx < 1.0e14 ) { Psum->SetPoint( i, xx, yy); h_Psum->Fill( yy ); } else break; } for (Long64_t i=0;i<nentries;i++) { double xx = 0.0; double yy = 0.0; double p1 = 0.0; double p2 = 0.0; double p3 = 0.0; ProbANu[0]->GetPoint(i, xx, p1); ProbANu[1]->GetPoint(i, xx, p2); ProbANu[2]->GetPoint(i, xx, p3); yy = p1 + p2 + p3; if ( xx < 1.0e14 ) { aPsum->SetPoint( i, xx, yy); h_aPsum->Fill( yy ); } else break; } TCanvas * c2 = new TCanvas("Sums", "Oscillation probabilities - SUMS", 184,112,394,472); c2->Divide(2,2); c2->cd(1); gPad->SetLogx(); Psum->SetMaximum(1.1); Psum->SetMinimum(0.0); Psum->SetMarkerStyle(21); Psum->SetMarkerSize(0.2); if ( std::string(model).compare("EarthB") == 0 ) Psum->GetXaxis()->SetLimits(0.98e9, 1.0e10); Psum->Draw("APL"); TLatex * tex = new TLatex(1.823945e+11,0.8753448,"Nu"); tex->SetLineWidth(2); tex->Draw(); c2->Modified(); c2->cd(); //Now the histogram c2->cd(2); // h_Psum->GetXaxis()->SetRange(6,14); h_Psum->GetXaxis()->SetNdivisions(501); h_Psum->GetXaxis()->SetLabelFont(42); h_Psum->GetXaxis()->SetLabelOffset(0.007); h_Psum->GetXaxis()->SetLabelSize(0.05); h_Psum->GetXaxis()->SetTitleSize(0.06); h_Psum->GetXaxis()->SetTitleOffset(0.9); h_Psum->GetXaxis()->SetTitleFont(42); h_Psum->Draw(""); h_Psum->Draw(); ///// c2->cd(3); gPad->SetLogx(); aPsum->SetMaximum(1.1); aPsum->SetMinimum(0.0); aPsum->SetMarkerStyle(21); aPsum->SetMarkerSize(0.2); aPsum->SetMarkerColor(2); aPsum->GetXaxis()->SetTitle("E [eV]"); aPsum->GetXaxis()->CenterTitle(true); aPsum->GetXaxis()->SetLabelFont(42); aPsum->GetXaxis()->SetLabelOffset(0.007); aPsum->GetXaxis()->SetLabelSize(0.05); aPsum->GetXaxis()->SetTitleSize(0.06); aPsum->GetXaxis()->SetTitleOffset(1.06); if ( std::string(model).compare("EarthB") == 0 ) aPsum->GetXaxis()->SetLimits(0.98e9, 1.0e10); aPsum->Draw("APL"); tex = new TLatex(1.56236e+11,0.8214771,"anti-Nu"); tex->SetLineWidth(2); tex->Draw(); //Now the histogram c2->cd(4); h_aPsum->Draw(); ///// c2->Modified(); c2->cd(); saveAs.str(""); saveAs << path << model << "/png/" << "nueosc_sum_of_probs_" << model << "_" << option << ".png"; c2->SaveAs( saveAs.str().c_str() ); }
void PlotLimit ( string LimitFile , string filePrefix, string LimTitle , bool DoObsLim , bool DoExpLim ) { setTDRStyle(); vector<float> vMass ; vector<float> vObsLimit ; vector<float> vMeanExpLimit ; vector<float> vMedianExpLimit ; vector<float> vExpLim68Down ; vector<float> vExpLim68Up ; vector<float> vExpLim95Down ; vector<float> vExpLim95Up ; ifstream indata; indata.open(LimitFile.c_str()); if(!indata) { // file couldn't be opened cerr << "Error: file could not be opened" << endl; return; } float Mass ; float ObsLimit ; float MeanExpLimit ; float MedianExpLimit ; float ExpLim68Down ; float ExpLim68Up ; float ExpLim95Down ; float ExpLim95Up ; while ( indata >> Mass >> ObsLimit >> MeanExpLimit >> MedianExpLimit >> ExpLim95Down >> ExpLim68Down >> ExpLim68Up >> ExpLim95Up ) { cout << Mass << " " << MeanExpLimit << " " << MedianExpLimit <<" "<< ExpLim68Down <<" "<< ExpLim68Up <<" "<< ExpLim95Down <<" "<< ExpLim95Up << endl; vMass .push_back(Mass ); vObsLimit .push_back(ObsLimit ); vMeanExpLimit .push_back(MeanExpLimit ); vMedianExpLimit .push_back(MedianExpLimit ); vExpLim68Down .push_back(ExpLim68Down ); vExpLim68Up .push_back(ExpLim68Up ); vExpLim95Down .push_back(ExpLim95Down ); vExpLim95Up .push_back(ExpLim95Up ); } TCanvas* cLimit = new TCanvas("c1","c1",900,600); cLimit->cd(); float x1 = vMass.at(0) - 5. ; float x2 = vMass.at(vMass.size()-1) + 5. ; // Expected Limit TGraph* ExpLim = NULL ; TGraphAsymmErrors* ExpBand68 = NULL ; TGraphAsymmErrors* ExpBand95 = NULL ; float min = 999999., max = 0; float minZoom = 999999., maxZoom = 0; if ( DoExpLim ) { float x[100]; float ex[100]; float y[100]; float yu68[100]; float yd68[100]; float yu95[100]; float yd95[100]; for ( int i = 0 ; i < (signed) vMass.size() ; ++i ) { x[i] = vMass.at(i) ; ex[i] = 0 ; y[i] = vMedianExpLimit.at(i) ; if(y[i] > max) max = y[i] ; if(y[i] < min) min = y[i] ; if(x[i]<=250){ if(y[i] > maxZoom) maxZoom = y[i] ; if(y[i] < minZoom) minZoom = y[i] ;} yu68[i] = vExpLim68Up.at(i) -y[i]; if(yu68[i] > max) max = yu68[i]; if(yu68[i] < min) min = yu68[i]; yd68[i] = y[i] - vExpLim68Down.at(i); if(yd68[i] > max) max = yd68[i]; if(yd68[i] < min) min = yd68[i]; yu95[i] = vExpLim95Up.at(i) -y[i]; if(yu95[i] > max) max = yu95[i]; if(yu95[i] < min) min = yu95[i]; yd95[i] = y[i] - vExpLim95Down.at(i); if(yd95[i] > max) max = yd95[i]; if(yd95[i] < min) min = yd95[i]; } ExpBand95 = new TGraphAsymmErrors((signed) vMass.size(),x,y,ex,ex,yd95,yu95); ExpBand95->SetFillColor(kYellow); ExpBand95->GetYaxis()->SetRangeUser(0.,50); ExpBand95->GetXaxis()->SetRangeUser(x1,x2); ExpBand95->GetXaxis()->SetTitle("Higgs mass [GeV/c^{2}]"); ExpBand95->GetYaxis()->SetTitle("95% Limit on #sigma/#sigma_{SM} "); ExpBand95->Draw("A3"); ExpBand95->GetYaxis()->SetRangeUser(0.,50); ExpBand95->Draw("A3"); ExpBand68 = new TGraphAsymmErrors((signed) vMass.size(),x,y,ex,ex,yd68,yu68); ExpBand68->SetFillColor(kGreen); ExpBand68->Draw("3"); ExpLim = new TGraph((signed) vMass.size(),x,y); ExpLim->SetLineWidth(2); ExpLim->SetLineStyle(1); ExpLim->Draw("l"); } // Observed Limit TGraph* ObsLim = NULL ; if ( DoObsLim ) { float x[100]; float y[100]; for ( int i = 0 ; i < (signed) vMass.size() ; ++i ) { x[i] = vMass.at(i) ; y[i] = vObsLimit.at(i) ; if(y[i] > max) max = y[i]; if(y[i] < min) min = y[i]; if(x[i]<=250){ if(y[i] > maxZoom) maxZoom = y[i] ; if(y[i] < minZoom) minZoom = y[i] ;} } ObsLim = new TGraph((signed) vMass.size(),x,y); ObsLim->SetMarkerColor(kBlue); ObsLim->SetLineWidth(2); ObsLim->SetLineColor(kBlue); //ObsLim->SetLineStyle(2); ObsLim->SetMarkerStyle(kFullCircle); if (DoExpLim) ObsLim->Draw("lp"); else { ObsLim->GetYaxis()->SetRangeUser(0.,10); ObsLim->GetXaxis()->SetRangeUser(x1,x2); ObsLim->GetXaxis()->SetTitle("Higgs mass [GeV/c^{2}]"); ObsLim->GetYaxis()->SetTitle("95% CL Limit on #sigma/#sigma_{SM} "); ObsLim->Draw("alp"); } } TLine *l = new TLine(x1,1,x2,1); l->SetLineWidth(2); l->SetLineColor(kBlack); l->Draw("same"); TLatex* title = new TLatex(.19,.82,LimTitle.c_str()); title->SetTextSize(.04); title->SetNDC(1); title->Draw("same"); TText* CMS = new TText(.19,.88,"CMS Preliminary"); CMS ->SetTextSize(.05); CMS ->SetNDC(1); CMS ->Draw("same"); //TLatex* Lumi = new TLatex(.19,.84,"Lumi = 1.5 fb^{-1} "); //Lumi ->SetTextSize(.03); //Lumi ->SetNDC(1); //Lumi ->Draw("same"); TLegend* leg = NULL ; leg = new TLegend(0.60,0.75,0.9,0.88,""); if (DoExpLim) leg->AddEntry(ExpLim, "95% CL: median","l"); if (DoExpLim) leg->AddEntry(ExpBand68,"95% CL: 68% band","f"); if (DoExpLim) leg->AddEntry(ExpBand95,"95% CL: 95% band","f"); if (DoObsLim) leg->AddEntry(ObsLim,"Observed","lp"); leg->SetTextSize(.03); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetShadowColor(0); leg->SetFillColor(0); leg->Draw("same"); vector<string> extensions; extensions.push_back(".png"); extensions.push_back(".pdf"); extensions.push_back(".eps"); ExpBand95->GetXaxis()->SetRangeUser(x1,x2); ExpBand95->GetYaxis()->SetRangeUser(min-0.2,max+2); cLimit->Update(); for(size_t i=0;i<extensions.size();++i) cLimit->Print( ("plots/"+filePrefix+"_lin"+extensions[i]).c_str() ); ExpBand95->GetXaxis()->SetRangeUser(x1,250); ExpBand95->GetYaxis()->SetRangeUser(minZoom/3.,maxZoom+0.2*maxZoom); cLimit->Update(); for(size_t i=0;i<extensions.size();++i) cLimit->Print( ("plots/"+filePrefix+"_zoom_lin"+extensions[i]).c_str() ); cLimit->SetLogy(); ExpBand95->GetXaxis()->SetRangeUser(x1,x2); ExpBand95->GetYaxis()->SetRangeUser(min/3.,max*10); cLimit->Update(); for(size_t i=0;i<extensions.size();++i) cLimit->Print( ("plots/"+filePrefix+"_log"+extensions[i]).c_str() ); ExpBand95->GetXaxis()->SetRangeUser(x1,250); ExpBand95->GetYaxis()->SetRangeUser(minZoom/3.,maxZoom*10); cLimit->Update(); for(size_t i=0;i<extensions.size();++i) cLimit->Print( ("plots/"+filePrefix+"_zoom_log"+extensions[i]).c_str() ); // ExpBand95->GetXaxis()->SetRangeUser(x1,300.); // gPad->WaitPrimitive(); // figName = "LimitPlots/" + LimTitle + "_zoom.gif" ; // cLimit->SaveAs(figName.c_str()) ; return; }
void plot3(TString infile = "fp-d", TString pltmd = "cos") { // CHECK FOR RIGHT INPUT //////////////////////////////////////////////// string strpltmd = pltmd, filename = infile, strfile = infile; if( (strpltmd.compare("cos") != 0 ) && (strpltmd.compare("sin") != 0 ) && (strpltmd.compare("tan") != 0 ) && (strpltmd.compare("mmp") != 0 ) ) {error(4);}; // GLOBAL VARIABLES //////////////////////////////////////////////////// Int_t file, point, color, style; Float_t fits2b, fittph, tphold, fitsph, fitcph, fitx, fitxmin, fitxmax = -1.0; Float_t xVal, yVal; Float_t xMin = 100000, xMax = -1.0, yMin = 100000, yMax = -1.0; Float_t MZ, MZmin, MW, MWmin, Mmin = 100000; Float_t Cz1, Cz2, Cz3, Cw1, Cw2, Cw3, Cw4, C1, C2; Float_t phiMin, phiMax, cphmin, cphmax, sphmin, sphmax; // CUSTOMIZE PLOT /////////////////////////////////////////////////////// gROOT->Reset(); gROOT->SetStyle("Plain"); gStyle->SetTitleBorderSize(0); gStyle->SetPalette(1); TCanvas *MyC = new TCanvas("MyC","Plot of the GAPP fit results",200,10,700,500); Float_t mmlegxmin, mmlegxmax, mmlegymin, mmlegymax; Float_t s2blegxmin, s2blegymin, s2blegxmax, s2blegymax; Float_t lblxmin, lblxmax, lblymin, lblymax; string plottitle = infile; //"Model: " + infile + " | Plot: "; sToUpper(plottitle); string xtitle, ytitle, NPleg, SMleg, display; NPleg = "#font[52]{M_{H}^{(NP)}, #bar{m}_{t}^{(NP)}}"; SMleg = "#font[52]{M_{H}^{(SM)}, #bar{m}_{t}^{(SM)}}"; if (strpltmd.compare("tan") == 0) { // plottitle += "#font[42]{tan^{2}(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}"; xtitle = "#font[52]{#tilde{x}}"; ytitle = "#font[42]{tan^{2}(#tilde{#phi})}"; display = "C"; mmlegxmin = 0.15; mmlegxmax = 0.30; mmlegymin = 0.75; mmlegymax = 0.85; s2blegxmin = 0.15; s2blegxmax = 0.40; s2blegymin = 0.30; s2blegymax = 0.50; lblxmin = 0.88; lblxmax = 0.88; lblymin = 0.60; lblymax = 0.65; } else if (strpltmd.compare("cos") == 0) { // plottitle += "#font[42]{cos(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}"; xtitle = "#font[52]{#tilde{x}}"; ytitle = "#font[42]{cos(#tilde{#phi})}"; display = "C"; mmlegxmin = 0.65; mmlegxmax = 0.80; mmlegymin = 0.65; mmlegymax = 0.75; s2blegxmin = 0.60; s2blegxmax = 0.85; s2blegymin = 0.30; s2blegymax = 0.50; lblxmin = 0.35; lblxmax = 0.50; lblymin = 0.45; lblymax = 0.50; } else if (strpltmd.compare("sin") == 0) { // plottitle += "#font[42]{sin(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}"; xtitle = "#font[52]{#tilde{x}}"; ytitle = "#font[42]{sin(#tilde{#phi})}"; display = "C"; mmlegxmin = 0.15; mmlegxmax = 0.30; mmlegymin = 0.75; mmlegymax = 0.85; s2blegxmin = 0.60; s2blegxmax = 0.85; s2blegymin = 0.30; s2blegymax = 0.50; lblxmin = 0.65; lblxmax = 0.80; lblymin = 0.60; lblymax = 0.65; } else if (strpltmd.compare("mmp") == 0) { // plottitle += "#font[42]{Masses of the new heavy gauge bosons.}"; xtitle = "#font[52]{M_{Z'}}#font[42]{ (TeV)}"; ytitle = "#font[52]{M_{W'}}#font[42]{ (TeV)}"; display = "C"; mmlegxmin = 0.20; mmlegxmax = 0.35; mmlegymin = 0.45; mmlegymax = 0.55; s2blegxmin = 0.20; s2blegxmax = 0.45; s2blegymin = 0.60; s2blegymax = 0.80; lblxmin = 0.65; lblxmax = 0.80; lblymin = 0.30; lblymax = 0.35; }; // PREPARE BOSON MASSES AND PHI BOUNDS ////////////////////////////////// string mdl(filename,0,2); if ( (mdl.compare("lr") == 0) || (mdl.compare("lp") == 0) || (mdl.compare("hp") == 0) || (mdl.compare("fp") == 0) ) { phiMin = 5.600; phiMax = 84.400; string Higgs(filename,3,1); if (Higgs.compare("d") == 0) { Cz1 = 11.95349795785275; Cz2 = 30.63269990028513; Cz3 = 42.58619785813789; Cw1 = 21.29309892906894; Cw2 = 9.339600971216193; Cw3 = 30.63269990028513; Cw4 = 42.58619785813789; } else if (Higgs.compare("t") == 0) { Cz1 = 5.976748978926375; Cz2 = 30.63269990028513; Cz3 = 85.17239571627579; Cw1 = 15.05649464522066; Cw2 = 3.302047590161717; Cw3 = 21.66058982554409; Cw4 = 60.22597858088265; } } else if ( (mdl.compare("uu") == 0) || (mdl.compare("nu") == 0) ) { phiMin = 10.179, phiMax = 79.821; C1 = 94.0397928463607; C2 = 77.1253849720165; } else {error(6);} cphmin = cos(TMath::Pi()*phiMin/180.0)*cos(TMath::Pi()*phiMin/180.0); cphmax = cos(TMath::Pi()*phiMax/180.0)*cos(TMath::Pi()*phiMax/180.0); sphmin = sin(TMath::Pi()*phiMin/180.0)*sin(TMath::Pi()*phiMin/180.0); sphmax = sin(TMath::Pi()*phiMax/180.0)*sin(TMath::Pi()*phiMax/180.0); // LOOP OVER ROOT FILES //////////////////////////////////////////////// for(file=0; file<=1; file++) { if(file==0) string epsfile = filename + "_" + strpltmd + ".eps"; if(file==1) string filename = filename + "_sm"; string rootname = filename + ".root"; TFile *rootfile = TFile::Open(rootname.c_str()); if(rootfile == NULL) error(1); TTree *tree = (TTree*)rootfile->Get(filename.c_str()); if(tree == NULL) error(2); TBranch *fits2bbranch = (TBranch*)tree->GetBranch("fits2b"); TBranch *fittphbranch = (TBranch*)tree->GetBranch("fittph"); TBranch *fitxbranch = (TBranch*)tree->GetBranch("fitx"); if( (fits2bbranch == NULL) || (fittphbranch == NULL) || (fitxbranch == NULL) ) error(3); tree->SetBranchAddress("fits2b",&fits2b); tree->SetBranchAddress("fittph",&fittph); tree->SetBranchAddress("fitx", &fitx); // GET ARRAYS /////////////////////////////////////////////////////////// Int_t Npoints = (Int_t)tree->GetEntries(); Int_t tphStep = 0; Float_t tphMax = -1.0; for(point=0; point<Npoints; point++) { tree->GetEntry(point); if( fittph > tphMax ) {tphStep++; tphMax = fittph;} }; const int tphSteps = tphStep; Float_t xArray[tphSteps], yArray[tphSteps], zArray[tphSteps]; tphStep = -1, tphold = -1.0, fitxmin = 100000; for(point=0; point<Npoints; point++) { tree->GetEntry(point); if(fittph > tphold) {tphStep++; fitxmin = 100000;} fitsph = fittph / (1.0 + fittph); fitcph = 1.0 - fitsph; if (strpltmd.compare("tan") == 0) { xVal = fitx; yVal = fittph; } else if (strpltmd.compare("cos") == 0) { xVal = fitx; yVal = sqrt(fitcph); } else if (strpltmd.compare("sin") == 0) { xVal = fitx; yVal = sqrt(fitsph); } else if (strpltmd.compare("mmp") == 0) { if (fitsph != 0.0) { if ( (mdl.compare("lr") == 0) || (mdl.compare("lp") == 0) || (mdl.compare("hp") == 0) || (mdl.compare("fp") == 0) ) { MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,fitsph,fitcph,fits2b,xVal,yVal); } else if ( (mdl.compare("uu") == 0) || (mdl.compare("nu") == 0) ) { MMII(C1,C2,fitx,fitsph,fitcph,xVal,yVal); } } } if( (strpltmd.compare("mmp") == 0) && (tphStep==1) ) { xArray[0] = xArray[1]; yArray[0] = yArray[1]; zArray[0] = zArray[1]; } if(fitx>fitxmax) fitxmax = fitx; if(fitx<fitxmin) { xArray[tphStep] = xVal; yArray[tphStep] = yVal; zArray[tphStep] = fits2b; fitxmin = fitx; } tphold = fittph; } if(file==0) TGraph *NPplot = new TGraph(tphSteps,xArray,yArray); if(file==1) TGraph *SMplot = new TGraph(tphSteps,xArray,yArray); TMarker *NPmrk[tphSteps], *SMmrk[tphSteps]; MZmin = 100000, MWmin = 100000; for(tphStep=0; tphStep<tphSteps; tphStep++){ marker(zArray[tphStep],color,style); if(file==0) { NPmrk[tphStep] = new TMarker(xArray[tphStep],yArray[tphStep],style); NPmrk[tphStep]->SetMarkerSize(0.8); NPmrk[tphStep]->SetMarkerColor(color);} if(file==1) { SMmrk[tphStep] = new TMarker(xArray[tphStep],yArray[tphStep],style); SMmrk[tphStep]->SetMarkerSize(0.8); SMmrk[tphStep]->SetMarkerColor(color);} if( (strpltmd.compare("mmp") != 0) || (tphStep !=0 )) { if (xArray[tphStep] < xMin) xMin = xArray[tphStep]; if (xArray[tphStep] > xMax) xMax = xArray[tphStep]; if (yArray[tphStep] < yMin) yMin = yArray[tphStep]; if (yArray[tphStep] > yMax) yMax = yArray[tphStep]; } if( ((strfile.compare("uu-d") != 0) || (strfile.compare("nu-d") != 0)) && (strpltmd.compare("cos") == 0) ) { fitx = xArray[tphStep]; fitcph = yArray[tphStep]*yArray[tphStep]; fitsph = 1.0 - fitcph; if( (cphmax < fitcph) && (fitcph < cphmin) ) { MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,fitsph,fitcph,fits2b,MZ,MW); if(MZ < MZmin) MZmin = MZ; if(MW < MWmin) MWmin = MW; } } if( ((strfile.compare("uu-d") == 0) || (strfile.compare("nu-d") == 0)) && (strpltmd.compare("sin") == 0) ) { fitx = xArray[tphStep]; fitsph = yArray[tphStep]*yArray[tphStep]; fitcph = 1.0 - fitsph; if( (sphmin < fitsph) && (fitsph<sphmax) ) { MMII(C1,C2,fitx,fitsph,fitcph,MZ,MW); if(MZ < Mmin) { Mmin = MZ; cout << MZ << "\t" << sqrt(fitsph) << endl;} } } } cout << "(" << file << ") " << "MZmin: " << MZmin << endl; cout << "(" << file << ") " << "MWmin: " << MWmin << endl; } // CREATE PLOTS ///////////////////////////////////////////////////////// NPplot->SetLineStyle(2); NPplot->SetMarkerStyle(20); NPplot->SetMarkerSize(0.4); SMplot->SetMarkerStyle(20); SMplot->SetMarkerSize(0.4); if(strpltmd.compare("cos") == 0) {xMin = 0.0; yMin = 0.0; yMax = 1.0;} if(strpltmd.compare("sin") == 0) {yMin = 0.0; yMax = 1.0;} if(strpltmd.compare("mmp") == 0) {xMin = 0.0; xMax = 5.8/1.1; yMin = 0.0; yMax = 5;} TH1F* frame = MyC->DrawFrame(0.9*xMin,0.9*yMin,1.1*xMax,1.0*yMax); frame->SetTitle(plottitle.c_str()); TAxis *xaxis = frame->GetXaxis(); TAxis *yaxis = frame->GetYaxis(); xaxis->SetTitle(xtitle.c_str()); xaxis->CenterTitle(); xaxis->SetTitleOffset(1.); xaxis->SetDecimals(); xaxis->SetLabelSize(0.03); xaxis->SetLabelOffset(0.01); yaxis->SetNdivisions(505); yaxis->SetTitle(ytitle.c_str()); yaxis->CenterTitle(); yaxis->SetTitleOffset(1.2); yaxis->SetDecimals(); yaxis->SetLabelSize(0.03); yaxis->SetLabelOffset(0.01); TLegend *mmleg = new TLegend(mmlegxmin,mmlegymin,mmlegxmax,mmlegymax); mmleg->AddEntry(NPplot,NPleg.c_str(),"l"); mmleg->AddEntry(SMplot,SMleg.c_str(),"l"); mmleg->SetTextSize(0.025); mmleg->SetFillStyle(0); if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) { for(tphStep=0; tphStep<tphSteps; tphStep++){NPmrk[tphStep]->Draw(); SMmrk[tphStep]->Draw();} } Float_t xdummy[1] = {0.0}, ydummy[1] = {0.0}; TGraph *circle = new TGraph(1,xdummy,ydummy); circle->SetMarkerStyle(24); circle->SetMarkerColor(kGreen+1); circle->SetMarkerSize(0.8); TGraph *square = new TGraph(1,xdummy,ydummy); square->SetMarkerStyle(25); square->SetMarkerColor(kCyan+1); square->SetMarkerSize(0.8); TGraph *triangle = new TGraph(1,xdummy,ydummy); triangle->SetMarkerStyle(26); triangle->SetMarkerColor(kBlue+1); triangle->SetMarkerSize(0.8); TGraph *diamond = new TGraph(1,xdummy,ydummy); diamond->SetMarkerStyle(27); diamond->SetMarkerColor(kMagenta+1); diamond->SetMarkerSize(0.8); TLegend *s2bleg = new TLegend(s2blegxmin,s2blegymin,s2blegxmax,s2blegymax); s2bleg->AddEntry(circle,"#font[42]{0.00 < sin^{2}(2#tilde{#beta}) #leq 0.25}","p"); s2bleg->AddEntry(square,"#font[42]{0.25 < sin^{2}(2#tilde{#beta}) #leq 0.50}","p"); s2bleg->AddEntry(triangle,"#font[42]{0.50 < sin^{2}(2#tilde{#beta}) #leq 0.75}","p"); s2bleg->AddEntry(diamond,"#font[42]{0.75 < sin^{2}(2#tilde{#beta}) #leq 1.00}","p"); s2bleg->SetTextSize(0.025); s2bleg->SetFillStyle(0); NPplot->Draw(display.c_str()); SMplot->Draw(display.c_str()); mmleg->Draw(); if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) s2bleg->Draw(); // BOUNDS ON PHI ////////////////////////////////////////////////////// Int_t i; const int iSteps = 100; fitxmin = 1.0, fitxmax *= 1.5; Float_t deltax = (fitxmax-fitxmin)/iSteps; Float_t phixmin0[iSteps], phixmax0[iSteps], phixmin1[iSteps], phixmax1[iSteps]; Float_t phiymin0[iSteps], phiymax0[iSteps], phiymin1[iSteps], phiymax1[iSteps]; if ( (strpltmd.compare("tan") == 0) || (strpltmd.compare("cos") == 0) || (strpltmd.compare("sin") == 0) ) { for(i=0; i<100; i++) { fitx = fitxmin + i*deltax; phixmin0[i] = fitx; if (strpltmd.compare("tan") == 0) { phiymin0[i] = sphmin / cphmin; phiymax0[i] = sphmax / cphmax; } if (strpltmd.compare("cos") == 0) { phiymin0[i] = sqrt(cphmin); phiymax0[i] = sqrt(cphmax); } if (strpltmd.compare("sin") == 0) { phiymin0[i] = sqrt(sphmin); phiymax0[i] = sqrt(sphmax); } } TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0); TGraph *phiMax0 = new TGraph(iSteps,phixmin0,phiymax0); } else if (strpltmd.compare("mmp") == 0) { if ( (mdl.compare("lr") == 0) || (mdl.compare("lp") == 0) || (mdl.compare("hp") == 0) || (mdl.compare("fp") == 0) ) { for(i=0; i<100; i++) { fitx = fitxmin + i*deltax; MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmin,cphmin,0.0,phixmin0[i],phiymin0[i]); MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmin,cphmin,1.0,phixmin1[i],phiymin1[i]); MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmax,cphmax,0.0,phixmax0[i],phiymax0[i]); MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmax,cphmax,1.0,phixmax1[i],phiymax1[i]); } TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0); TGraph *phiMin1 = new TGraph(iSteps,phixmin1,phiymin1); TGraph *phiMax0 = new TGraph(iSteps,phixmax0,phiymax0); TGraph *phiMax1 = new TGraph(iSteps,phixmax1,phiymax1); phiMin1->SetLineStyle(7); phiMin1->SetMarkerStyle(22); phiMin1->SetMarkerSize(1.0); phiMax1->SetLineStyle(7); phiMax1->SetMarkerStyle(22); phiMax1->SetMarkerSize(1.0); // phiMin1->Draw("C"); // phiMax1->Draw("C"); } else if ( (mdl.compare("uu") == 0) || (mdl.compare("nu") == 0) ) { for(i=0; i<100; i++) { fitx = fitxmin + i*deltax; MMII(C1,C2,fitx,sphmin,cphmin,phixmin0[i],phiymin0[i]); MMII(C1,C2,fitx,sphmax,cphmax,phixmax0[i],phiymax0[i]); } TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0); TGraph *phiMax0 = new TGraph(iSteps,phixmax0,phiymax0); } } phiMin0->SetLineStyle(3); phiMin0->SetMarkerStyle(20); phiMin0->SetMarkerSize(0.4); phiMax0->SetLineStyle(3); phiMax0->SetMarkerStyle(20); phiMax0->SetMarkerSize(0.4); phiMin0->Draw("C"); phiMax0->Draw("C"); // LABEL ALLOWED REGION /////////////////////////////////////////////// TPaveText *allowed = new TPaveText(lblxmin,lblymin,lblxmax,lblymax,"NDC"); TText *text = allowed->AddText("#font[42]{allowed (95% CL)}"); allowed->SetTextSize(0.04); if (strpltmd.compare("tan") == 0) text->SetTextAngle(270); allowed->SetFillStyle(0); allowed->SetLineColor(0); allowed->SetBorderSize(1); allowed->Draw(); // SAVE GRAPHIC /////////////////////////////////////////////////////// MyC->Print(epsfile.c_str());
void drawIntegratedSpectrum( std::string beam, std::string target, std::string secondary, std::string histo ) { // std::cout << "About to load Reader" << std::endl; // if ( isReadNA49Loaded <= 0 ) // { // gROOT->LoadMacro("ReadNA49Data.C"); // isReadNA49Loaded = 1; // } // std::cout << "Reader loaded" << std::endl; readIntegratedSpectra( beam, target, secondary ); double ymin = 10000.; // something big... don't know if I can use FLT_MAX double ymax = -1. ; float* Value = new float[NPoints]; float* Error = new float[NPoints]; for ( int i=0; i<NPoints; i++ ) { if ( histo == "dNdxF" ) { Value[i] = dNdxF[i]; Error[i] = err_dNdxF[i]; } else if ( histo == "pT" ) { Value[i] = pT[i]; Error[i] = err_pT[i]; } else if ( histo == "pT2" ) { Value[i] = pT2[i]; Error[i] = err_pT2[i]; } if ( Value[i]+Error[i] > ymax ) ymax = Value[i] + Error[i]; if ( Value[i]-Error[i] < ymin ) ymin = Value[i] - Error[i]; if ( ymin < 0. ) ymin = 0.; } TH1F* hi[NModels]; std::string YTitle; if ( histo == "dNdxF" ) { YTitle = "dN/dxF"; } else if ( histo == "pT" ) { YTitle = "dpT/dxF, GeV/c"; } else if ( histo == "pT2" ) { YTitle = "dpT^2/dxF, (GeV/c)^2"; } for ( int m=0; m<NModels; m++ ) { std::string histofile = "./na49-histo/" + beam + target + "158.0GeV" + ModelName[m] + ".root"; TFile* f = new TFile( histofile.c_str() ); std::string histoname = secondary + "_" + histo ; hi[m] = (TH1F*)f->Get( histoname.c_str() ); /* if ( histo == "pT" && m<3 ) { hi[m]->Scale(32.); } */ hi[m]->SetStats(0); hi[m]->SetLineColor(ColorModel[m]); hi[m]->SetLineWidth(2); if ( m == 0 ) hi[m]->SetLineWidth(3.5); int nx = hi[m]->GetNbinsX(); for (int k=1; k <= nx; k++) { double yy = hi[m]->GetBinContent(k); if ( yy > ymax ) ymax = yy; if ( yy < ymin && yy > 0. ) ymin = yy; } if ( m == 0 ) { hi[m]->Draw(); hi[m]->GetXaxis()->SetTitle("xF"); hi[m]->GetYaxis()->SetTitle( YTitle.c_str() ); hi[m]->GetYaxis()->SetTitleOffset(1.5); } else hi[m]->Draw("same"); } TLegend* leg = new TLegend(0.55, 0.65, 0.9, 0.9); leg->SetTextSize(0.025); for ( int m=0; m<NModels; m++ ) { hi[m]->GetYaxis()->SetRangeUser(ymin,ymax*1.1); // hi[m]->SetTitle(""); leg->AddEntry( hi[m], ModelName[m].c_str(), "L" ); } TGraph* gr = new TGraphErrors( NPoints, xF, Value, 0, Error ); // gr->GetYaxis()->SetRangeUser( 0., 2.5 ); // gr->GetXaxis()->SetRangeUser( -0.3, 0.4 ); // gr->SetRangeUser( 0., 2.5 ); gr->SetMarkerColor(kBlue); gr->SetMarkerStyle(22); gr->SetMarkerSize(1.5); gr->Draw("p"); leg->AddEntry( gr, "exp.data", "p"); leg->Draw(); leg->SetFillColor(kWhite); return; }
int main(int argc, char* argv[]) { // initialize globalArgs globalArgs.data_folder = " "; globalArgs.arg_pathToSetupFile = " "; globalArgs.results_folder = " "; globalArgs.save_all = 0; // Get paremeter from the command int opt =0; opt = getopt(argc, argv, optString); if(opt == -1){ std::cerr << "There is no opption in the command! Type \"output -h\" for help." << std::endl; exit(EXIT_FAILURE); } while(opt != -1){ switch(opt){ case 'd': globalArgs.data_folder= optarg; //std::cout<<"-p option path= "<<globalArgs.arg_pathToData<<std::endl; break; case 'S': globalArgs.arg_pathToSetupFile = optarg; break; case 'o': globalArgs.results_folder = optarg; break; case 'a': globalArgs.save_all = 1; break; case 'h': case '?': std::cerr << "Usage: output -d pathToData -S pathToSetupFile -o pathToResultsFolder [-a]" << std::endl; std::cerr << "----------------------------------------------------------------------------------------------------"<<std::endl; std::cerr << " '-d'+'-S'+'-o' options are necessary!"<<std::endl; std::cerr << "-----------------------------------------------------------------------------------------------------"<<std::endl; std::cerr << " use '-a' option afterwards to save all the plots of the analysis to further check."<<std::endl; std::cerr << "-----------------------------------------------------------------------------------------------------"<<std::endl; std::cerr << "Example: ./output -d /Users/Analysis_waveforms/ov_scan_pde_H2014/ -S /Users/Analysis_waveforms/config_file.txt -o /Users/Analysis_waveforms/Plots/ [-a]"<<std::endl; exit(EXIT_FAILURE); break; default: break; } opt = getopt(argc, argv, optString); } if((strncmp(globalArgs.data_folder," ",1) == 0|| strncmp(globalArgs.arg_pathToSetupFile," ",1) == 0)){ std::cerr << "ERROR: -d or -S option is not set! Both of them has to be set correctly!"<<std::endl; exit(EXIT_FAILURE); } if(strncmp(globalArgs.results_folder," ",1) == 0){ std::cerr << "ERROR: -o option is not set! It has to be set up correctly!"<<std::endl; exit(EXIT_FAILURE); } ifstream setupFile(globalArgs.arg_pathToSetupFile); if(!setupFile){ std::cerr << "Failure: could not open file: \"" << globalArgs.arg_pathToSetupFile << "\"." << std::endl; std::cerr << "Please check if the path is correct or not!" << std::endl; exit(EXIT_FAILURE); } //////////////// //Define thresholds //////////////// //in nanoseconds const double reject_time = 4; vector <Double_t> reject_time_v; //used for AP, delayed x-talk and long tau fit //in percentage of pe const double after_pulse_th = 0.38; vector <Double_t> after_pulse_th_v; const double direct_xtalk_th = 1.17; vector <Double_t> direct_xtalk_th_v; const double xtalk_th = 0.85; vector <Double_t> xtalk_th_v; const double time_dist_th = 0.4; vector <Double_t> time_dist_th_v; //////////////// //////////////// //Read setup file: string s; vector <TString> vol_folders; Int_t data_size; while (true) { Double_t rt; Double_t ap; Double_t delay; Double_t imme; getline(setupFile, s); if (setupFile.eof()) break; const char* searchString = s.c_str(); char volt [20]; Int_t numfiles; if (s.find("#") == 0 || s=="") { continue; // Skip commented or empty lines } //Find the voltages if(sscanf(searchString, "V || %s ||", volt)==1){ vol_folders.push_back(volt); reject_time_v.push_back(reject_time); after_pulse_th_v.push_back(after_pulse_th); direct_xtalk_th_v.push_back(direct_xtalk_th); xtalk_th_v.push_back(xtalk_th); time_dist_th_v.push_back(time_dist_th); } if(sscanf(searchString, "V/th || %s ||", volt)==1){ vol_folders.push_back(volt); getline(setupFile, s); const char* thresholds_string = s.c_str(); sscanf(thresholds_string, "Rej_t: %lf, AP_th: %lf, Delay_th: %lf, Imm_th: %lf", &rt,&ap,&delay,&imme); reject_time_v.push_back(rt); after_pulse_th_v.push_back(ap); direct_xtalk_th_v.push_back(imme); xtalk_th_v.push_back(delay); time_dist_th_v.push_back(time_dist_th); } //Find data size if(sscanf(searchString, "Files at each voltage || %d ||", &numfiles)==1){ data_size = numfiles; } } //Initialize variables const Int_t vol_size = vol_folders.size(); int singleplot=0; Int_t Event=0; Char_t Category[15]; TGraph* waveform = 0; Double_t Amp; Double_t V_meas; double pe = 0.07; int row = 0; int full_n_file = 0; int ap_n_file = 0; int xtalk_n_file = 0; int dxtalk_n_file = 0; int time_dist_n_file = 0; int direct_xtalk_pulse; Double_t direct_xtalk_pulse_cnt=0; int xtalk_pulse; Double_t xtalk_pulse_cnt = 0; int after_pulse; Double_t after_pulse_cnt=0; Double_t event_cnt = 0; double sig_max = 0; double time_of_max = 0; double sig_max_first = 0; double time_of_max_first = 0; int max_cnt = 0; int max_noise_cnt = 0; int max_found = 0; /*const char * Voltage="56.5V"; int event=0; if (singleplot) { single_plot(Voltage,event); }*/ //Create a root tree with the graph of the waveform of each event and //classify them TString filename = globalArgs.results_folder; filename.Append("noiseanalysis.root"); TFile *hfile = 0; hfile = TFile::Open(filename,"RECREATE"); TTree *tree = new TTree("T","Noise Analysis"); tree->Branch("Event",&Event,"Event/I"); tree->Branch("Category",Category,"Category/C"); //Uncomment if every single waveform is desired to be saved by its own on the root file //tree->Branch("waveform","TGraph",&waveform); tree->Branch("V_meas",&V_meas,"V_meas/D"); //OV of the measurement TGraph* Correl_noise[4]; Correl_noise[0] = new TGraph(); Correl_noise[1] = new TGraph(); Correl_noise[2] = new TGraph(); Correl_noise[3] = new TGraph(); TGraph *Expfit_longtau[vol_size]; TGraph *Expfit_AP[vol_size]; //Fiting functions of long tau and AP recharge TF1 *exp_longtau= new TF1("exptau","[0]*exp(-x/[1])",0,180 * ns); TF1 *exp= new TF1("exp","[0]*(1-exp(-x/[1]))+[2]*exp(-x/[3])",0,180 * ns); TCanvas* c1[vol_size]; TCanvas* c2[vol_size]; TCanvas* c3[vol_size]; TCanvas* c4[vol_size]; TMultiGraph *Cleanwaves[vol_size]; TCanvas* expfit_longtau_c[vol_size]; TCanvas* expfit_AP_c[vol_size]; cout<<"////////////"<< endl; cout<<"****----->Voltage Breakdown calculation ***"<< endl; vector <Double_t> pe_volt; TGraph *Vbias_ver= new TGraph(); //Change to not recalculate the pe //pe_volt.push_back(6.87435e-02); /*pe_volt.push_back( 1.20426e-01); pe_volt.push_back(1.75262e-01); pe_volt.push_back(2.30936e-01); pe_volt.push_back(2.87958e-01);*/ //pe_volt.push_back( 3.44156e-01); //Double_t VBD=55.9006; //Calculate Voltage breakdown and value of pe for (int i=0; i<vol_size; i++) { pe_volt.push_back(Amplitude_calc(vol_folders.at(i).Data(), data_size)); V_meas = vol_folders.at(i).Atof(); Vbias_ver->SetPoint(i, pe_volt.at(i), V_meas); } TCanvas* ca= new TCanvas("Voltage Breakdown calculation","Voltage Breakdown calculation",100,100,900,700); Vbias_ver->SetTitle("Voltage Breakdown calculation"); Vbias_ver->GetYaxis()->SetTitle("Bias Volatge [V]"); Vbias_ver->GetYaxis()->SetTitleOffset(1.2); Vbias_ver->GetXaxis()->SetTitle("Mean peak amplitude [V]"); Vbias_ver->Draw("AP*"); ca->SetGrid(); TPaveText * pv = new TPaveText(0.2,0.65,0.35,0.74,"brNDC"); cout<<"////////////"<< endl; cout<<"****----->Voltage Breakdown fit ***"<< endl; TFitResultPtr fit = Vbias_ver->Fit("pol1","S"); Double_t VBD= fit->Value(0); Char_t VBD_text[20]; sprintf(VBD_text,"V_{BD} = %2.2f",VBD); pv->AddText(VBD_text); pv->Draw(); if (globalArgs.save_all==1) ca->Write(); cout<<"////////////"<< endl; cout<<"****----->Noise analysis ***"<< endl; cout<<"////////////"<< endl; ///////////////// // Loop over all Voltages measured ///////////////// for (int i=0; i<vol_size; i++) { //Important to reinitialize, the value color* = kOrange-11 is used to plot axis of TGraph() int color1 = kOrange-11; int color2 = kOrange-11; int color3 = kOrange-11; int color4 = kOrange-11; direct_xtalk_pulse_cnt = 0; xtalk_pulse_cnt = 0; after_pulse_cnt = 0; event_cnt = 0; //Events on the Voltage measured cout<<"****----->Voltage analyzed: "<< vol_folders.at(i) << endl; //Define amplitude measured at which OV Double_t pe = pe_volt.at(i); V_meas = vol_folders.at(i).Atof()-VBD; //Define canvases to save and check results Char_t canvas_title[40]; sprintf(canvas_title,"Direct CrossTalk OV = %2.2f V",V_meas); c1[i] = new TCanvas(canvas_title,canvas_title,100,100,900,700); sprintf(canvas_title,"Delayed CrossTalk OV = %2.2f V",V_meas); c2[i] = new TCanvas(canvas_title,canvas_title,100,100,900,700); sprintf(canvas_title,"After Pulse OV = %2.2f V",V_meas); c3[i] = new TCanvas(canvas_title,canvas_title,100,100,900,700); sprintf(canvas_title,"Clean OV = %2.2f V",V_meas); c4[i] = new TCanvas(canvas_title,canvas_title,100,100,900,700); Cleanwaves[i]=new TMultiGraph(); sprintf(canvas_title,"Exponential fit, #tau_l OV = %2.2f V",V_meas); expfit_longtau_c[i] = new TCanvas(canvas_title,canvas_title,300,100,900,500); sprintf(canvas_title,"Exponential fit OV = %2.2f V",V_meas); expfit_AP_c[i] = new TCanvas(canvas_title,canvas_title,300,100,900,500); Expfit_longtau[i]= new TGraph(); Expfit_AP[i]= new TGraph(); //loop over every measurement on a folder for (int j=0; j<data_size; j++) { Char_t datafilename[200]; Char_t datashortfilename[100]; sprintf(datafilename,"%s%s/C1H%05i.csv",globalArgs.data_folder,vol_folders.at(i).Data(),j); sprintf(datashortfilename,"%s_C1H%05i",vol_folders.at(i).Data(),j); //Get the data of a single file: waveform = new TGraph(datafilename,"%lg %lg","/t;,"); if (waveform->IsZombie()) continue; waveform->SetName(datashortfilename); waveform->SetTitle(""); Int_t ROWS_DATA = waveform->GetN(); Double_t *time = waveform->GetX(); Double_t *volts = waveform->GetY(); Amp = waveform->GetY()[0]; ///////////////////////////////////////////////////// // Data filtering into the different type of events // direct x-talk AP delayed x-talk ///////////////////////////////////////////////////// after_pulse = 0; xtalk_pulse = 0; direct_xtalk_pulse = 0; sig_max = 0; max_cnt = 0; max_found = 0; ///////////////////////////////////////////////////// // direct x-talk for (row = 0; row < ROWS_DATA; row++) { if ((time[row]>0 * ns)&(volts[row] > direct_xtalk_th_v.at(i) * pe)) {// time larger 0ns direct_xtalk_pulse++; } } ///////////////////////////////////////////////////// // after-pulse threshold for (row = 0; row < ROWS_DATA; row++) { if ((time[row]>reject_time_v.at(i)*ns)&(volts[row] > after_pulse_th_v.at(i) * pe)) {// time larger 4ns and ap_th after_pulse++; } } ///////////////////////////////////////////////////// // delayed x-talk for (row = 0; row < ROWS_DATA; row++) { if ((time[row]>reject_time_v.at(i)*ns)&(volts[row] > xtalk_th_v.at(i) * pe)) {// time larger 4ns and larger xtalk_th xtalk_pulse++; } } ///////////////////////////////////////////////////////////////////// // Detect peaks in data after 4ns, count the number of maxima and // measure the time of arrival of first maxima, used later for AP exp fit ///////////////////////////////////////////////////////////////////// max_noise_cnt = 0; for (row = 0; row < ROWS_DATA; row++) { if (time[row] > reject_time_v.at(i)*ns) {// time larger 4ns if (volts[row] > sig_max) { sig_max = volts[row]; // set the max time_of_max = time[row]; // time max max_noise_cnt++; // set the histeresis cnt }else if (max_noise_cnt > 0) max_noise_cnt--; // count down if no new max is reached // decide if real max or only noise, threshold has to be reached in case of a real max if (max_noise_cnt>2 && sig_max > time_dist_th_v.at(i) * pe) { max_cnt++; if (max_cnt == 1) { sig_max_first = sig_max; // sig max time_of_max_first = time_of_max; // time max max_found = 1; //printf("First max found: sig=%f time=%f ns max_noise_cnt=%d\n", sig_max, time_of_max / ns, max_noise_cnt); } //printf("Max number is: %d cnt=%d\n", max_cnt, max_noise_cnt); } } // 4ns } //loop over time bool clean = true; //The pulse is clean until the contrary can be demonstrated char graph_title[50]; //Check for imm x-talk and plot if (direct_xtalk_pulse > 0){ direct_xtalk_pulse_cnt++; sprintf(Category,"ImmCrosstalk"); c1[i]->cd(); //Set graph color, and counting to draw axis and title color1=color1+2; if (color1>kOrange+110) { color1=kOrange-8; }else if (color1>kOrange+109){ color1=kOrange-7; } waveform->SetLineColor(color1); waveform->SetMarkerColor(color1); //Format the graph sprintf(graph_title,"Direct CrossTalk OV = %2.2f V",V_meas); waveform = format_graph(waveform,graph_title,2.5*pe); if (color1>kOrange-8) { waveform->Draw("SAME"); }else{ waveform->Draw("AL"); c1[i]->SetGrid(); } clean = false; } // only delayed x-talk if (xtalk_pulse > 0 && direct_xtalk_pulse == 0){ xtalk_pulse_cnt++; sprintf(Category,"DelCrosstalk"); c2[i]->cd(); //Set graph color, and counting to draw axis and title color2=color2+2; if (color2>kOrange+110) { color2=kOrange-8; }else if (color2>kOrange+109){ color2=kOrange-7; } waveform->SetLineColor(color2); waveform->SetMarkerColor(color2); //Format the graph sprintf(graph_title,"Delayed cross-talk OV = %2.2f V",V_meas); waveform = format_graph(waveform,graph_title,1.2*pe); if (color2>kOrange-8) { waveform->Draw("SAME"); }else{ waveform->Draw("AL"); c2[i]->SetGrid(); } clean = false; } // Only after pulse if (after_pulse > 0 && xtalk_pulse == 0 && direct_xtalk_pulse == 0){ after_pulse_cnt++; sprintf(Category,"AfterPulse"); c3[i]->cd(); //Set graph color, and counting to draw axis and title color3=color3+2; if (color3>kOrange+110) { color3=kOrange-8; }else if (color3>kOrange+109){ color3=kOrange-7; } waveform->SetLineColor(color3); waveform->SetMarkerColor(color3); //Format the graph sprintf(graph_title,"After pulse OV = %2.2f V",V_meas); waveform = format_graph(waveform,graph_title,1.2*pe); if (color3>kOrange-8) { waveform->Draw("SAME"); }else{ waveform->Draw("AL"); c3[i]->SetGrid(); } clean = false; //Fill for the exponential fit Expfit_AP[i]->SetPoint(after_pulse_cnt-1,time_of_max,sig_max); } // Only clean graphs for the sample if (clean){ sprintf(Category,"Clean"); if (color4 < 860 && j <100) { //Max 100 clean graphs on the plot Cleanwaves[i]->Add(waveform); c4[i]->cd(); //Set graph color, and counting to draw axis and title color4=color4+2; if (color4>kOrange+110) { color4=kOrange-8; }else if (color4>kOrange+109){ color4=kOrange-7; } waveform->SetLineColor(color4); waveform->SetMarkerColor(color4); //Format the graph sprintf(graph_title,"Clean pulse OV = %2.2f V",V_meas); waveform = format_graph(waveform,graph_title,1.2*pe); if (color4>kOrange-8) { waveform->Draw("SAME"); }else{ waveform->Draw("AL"); c4[i]->SetGrid(); } } } tree->Fill(); Event ++;//Total number of events analyzed on the run if (Event%500==0) { cout<<"****----->Events analyzed:"<< Event << endl; } event_cnt++; } cout<<"////////////"<< endl; cout<<"****----->Long tau fit ***"<< endl; expfit_longtau_c[i]->cd(); Cleanwaves[i]->Draw("AP*"); // Fit parameters and limits to calculate slow component of the pulse exp_longtau->SetParameter(0,pe*0.2); exp_longtau->SetParLimits(0,0.05*pe,0.5*pe); exp_longtau->SetParameter(1,80*ns); exp_longtau->SetParLimits(1,4*ns,200*ns); Cleanwaves[i]->Fit("exptau","","",reject_time_v.at(i)*ns,60*ns); // Fit boundaries for the slow component of the pulse Double_t amp0 = exp_longtau->GetParameter(0); Double_t tau = exp_longtau->GetParameter(1); if (globalArgs.save_all==1) expfit_longtau_c[i]->Write(); c4[i]->cd(); TF1* exp_tau_plot =(TF1*) exp_longtau->Clone(); exp_tau_plot->Draw("SAME");//Draw fit-line over clean waveforms cout<<"////////////"<< endl; cout<<"****----->After pulse fit ***"<< endl; expfit_AP_c[i]->cd(); Expfit_AP[i]->Draw("AP*"); // Fit parameters and limits to calculate AP recharge exp->SetParameter(0,pe); exp->SetParLimits(0,0.5*pe,1.5*pe); exp->SetParameter(1,30*ns); exp->SetParLimits(1,4*ns,500*ns); exp->SetParameter(2,amp0); exp->FixParameter(2,amp0); exp->SetParameter(3,tau); exp->FixParameter(3,tau); Expfit_AP[i]->Fit("exp"); if (globalArgs.save_all==1) expfit_AP_c[i]->Write(); c3[i]->cd(); TF1* exp_plot =(TF1*) exp->Clone(); exp_plot->Draw("SAME"); //Draw fit-line over AP waveforms //Final result: Correlated noise Correl_noise[0]->SetPoint(i,V_meas,direct_xtalk_pulse_cnt/event_cnt*100); Correl_noise[1]->SetPoint(i,V_meas,after_pulse_cnt/event_cnt*100); Correl_noise[2]->SetPoint(i,V_meas,xtalk_pulse_cnt/event_cnt*100); Correl_noise[3]->SetPoint(i,V_meas, Correl_noise[0]->GetY()[i]+Correl_noise[1]->GetY()[i]+Correl_noise[2]->GetY()[i]); //Save/print reults: if (globalArgs.save_all==1){ c1[i]->Write(); c2[i]->Write(); c3[i]->Write(); c4[i]->Write(); } sprintf(canvas_title,"%sImmcrosstalk_%s.pdf",globalArgs.results_folder,vol_folders.at(i).Data()); c1[i]->Print(canvas_title,"pdf"); sprintf(canvas_title,"%sDelcrosstalk_%s.pdf",globalArgs.results_folder,vol_folders.at(i).Data()); c2[i]->Print(canvas_title,"pdf"); sprintf(canvas_title,"%sAfterpulse_%s.pdf",globalArgs.results_folder,vol_folders.at(i).Data()); c3[i]->Print(canvas_title,"pdf"); sprintf(canvas_title,"%sClean_%s.pdf",globalArgs.results_folder,vol_folders.at(i).Data()); c4[i]->Print(canvas_title,"pdf"); } //Save TTree with hist of noise //Save each event with its OV and the noise classification tree->Write(); //Create final plot of total correlated noise TCanvas* c5 = new TCanvas("Correlated Noise","Correlated Noise",100,100,900,700); Double_t tot_max_noise = TMath::MaxElement(Correl_noise[3]->GetN(),Correl_noise[3]->GetY()); Correl_noise[3]->SetTitle("Correlated Noise"); Correl_noise[3]->SetMarkerColor(kRed); Correl_noise[3]->SetLineColor(kRed); Correl_noise[3]->GetYaxis()->SetRangeUser(0,tot_max_noise+2); Correl_noise[3]->GetYaxis()->SetTitle("Noise [%]"); Correl_noise[3]->GetXaxis()->SetTitle("OverVoltage [V]"); Correl_noise[3]->Draw("ALP*"); Correl_noise[0]->SetTitle("Direct Cross-Talk"); Correl_noise[1]->SetTitle("After Pulse"); Correl_noise[2]->SetTitle("Delayed Cross-Talk"); Correl_noise[0]->SetLineColor(kBlue); Correl_noise[1]->SetLineColor(kOrange+7); Correl_noise[2]->SetLineColor(kGreen+2); Correl_noise[0]->SetMarkerColor(kBlue); Correl_noise[1]->SetMarkerColor(kOrange+7); Correl_noise[2]->SetMarkerColor(kGreen+2); Correl_noise[0]->Draw("LP*"); Correl_noise[1]->Draw("LP*"); Correl_noise[2]->Draw("LP*"); TLegend* leg = new TLegend(0.15,0.65,0.47,0.87); leg->AddEntry(Correl_noise[3],"Total","lp"); leg->AddEntry(Correl_noise[0],"Direct Cross-Talk","lp"); leg->AddEntry(Correl_noise[1],"After Pulse","lp"); leg->AddEntry(Correl_noise[2],"Delayed Cross-Talk","lp"); leg->Draw(); c5->SetGrid(); TString final_plot_name = globalArgs.results_folder; final_plot_name.Append("Correlated Noise.pdf"); c5->Print(final_plot_name,"pdf"); c5->Write(); delete hfile; return 0; }
TGraph* newShiftChi2Graph(const T* const dat1, const Int_t nd1, const U* const dat2, const Int_t nd2, const Int_t minbin=-1, // -1 => 0 const Int_t maxbin=-1, // -1 => nd1-1 const Bool_t useSqrtErrs=kFALSE) { const Int_t minb = (minbin<0) ? 0 : minbin; const Int_t maxb = (maxbin<0) ? nd1-1 : maxbin; if ( (maxb<=minb) || (maxb>=nd1) || (maxb>=nd2) ) { Fatal("newShiftChi2Graph", "Invalid maxb=%d. (minb=%d, nd1=%d, nd2=%d)", maxb, minb, nd1, nd2); } const T* c1 = dat1; const U* c2 = dat2; Int_t pos, j(0); const Int_t ndh = (maxb-minb+1)/2; TGraphErrors* gc = new TGraphErrors; for (Int_t sh=1-ndh; sh<ndh; ++sh) { Double_t x=0, t=0, cmp=0; c1 = dat1+minb; c2 = dat2+minb-sh; for (Int_t i=minb; i<=maxb; ++i, ++c1, ++c2) { pos = c2 - dat2; #ifdef SHIFT_INTO_WINDOW if (pos<nd2) { if (pos>=0) { #else if (pos<=maxb) { if (pos>=minb) { #endif t = (*c1) - (*c2); t *= t; if (useSqrtErrs) { t /= TMath::Abs(static_cast<Double_t>(*c2)); } x += t; cmp += 1.0; } } else { break; } } if (cmp>1.0) { x /= cmp-1.0; gc->SetPoint(j, static_cast<Double_t>(sh), x); ++j; } } return gc; } void noAveBounceStdy(const Char_t* rtfn, const Char_t* wvfn, const Char_t* FPNfn, const Char_t* outfn, const Int_t fitType=0, const Int_t fitOpt=0, const Char_t* minner="Minuit2", const Char_t* algo="Migrad", const Int_t shiftminb=-1, const Int_t shiftmaxb=-1, const Bool_t applyFilter=kTRUE) { // fitType: // 0 = fit theta phi with getShiftLL // 5 = fit theta phi with getShiftChi2 // 20 = fit 3 deltaT's; use contraints for other 3 // // fitOpt: // 0 = fit (filtered) waveforms // 10 = fit envelope of (filtered) waveforms // // minner algo // Minuit /Minuit2 Migrad,Simplex,Combined,Scan (default is Migrad) // Minuit2 Fumili2 // Fumili // GSLMultiMin ConjugateFR, ConjugatePR, BFGS, // BFGS2, SteepestDescent // GSLMultiFit // GSLSimAn // Genetic if (mini==0) { mini = ROOT::Math::Factory::CreateMinimizer(minner, algo); mini->SetMaxFunctionCalls(1000000); mini->SetMaxIterations(10000); mini->SetTolerance(0.001); mini->SetPrintLevel(0); } nt = new TChain("runtree"); nt->Add(rtfn); const Long64_t nents = nt->GetEntries(); if (nents==0) { Error("noAveBunceStdy","No events in tree from [%s].",rtfn); return; } ns = new TChain("nShifts"); ns->Add(wvfn); if (nents>ns->GetEntries()) { Error("bounceStudy","%lld entries in runtree but " "%lld entries in shift tree",nents,ns->GetEntries()); return; } fpnf = TFile::Open(FPNfn); if ( (fpnf==0) || (fpnf->IsZombie()) ) { Error("bounceStudy","Could not open FPN file [%s]",FPNfn); return; } for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { gPed[ch] = dynamic_cast<TGraphErrors*>( fpnf->Get(Form("gExlPed_ch%d",ch))); gNoise[ch] = dynamic_cast<TGraphErrors*>( fpnf->Get(Form("gExlRms_ch%d",ch))); if ( (gPed[ch]==0) || (gNoise[ch]==0) ) { Error("bounceStudy", "Couldn't get FPN/noise graphs from [%s]",FPNfn); return; } } // read from tree into... Float_t pedsubs[NSnConstants::kNchans][NSnConstants::kNsamps]; Float_t psshift[NSnConstants::kNchans][NSnConstants::kNsamps]; Float_t filtered[NSnConstants::kNchans][NSnConstants::kNsamps]; Float_t envelope[NSnConstants::kNchans][NSnConstants::kNsamps]; UShort_t samples[NSnConstants::kNchans][NSnConstants::kNsamps]; UInt_t evnum, utime, utimeus, mbchksum; nt->SetBranchAddress("mbChecksum",&mbchksum); nt->SetBranchAddress("EvtNum",&evnum); nt->SetBranchAddress("unixTime",&utime); nt->SetBranchAddress("unixTimeUS",&utimeus); for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { nt->SetBranchAddress(Form("data%02d",ch), &(samples[ch][0])); } // shift for stop tree Int_t nsent; UInt_t nsevn; Int_t aveShift(0), aveLen(0); Int_t shift[NSnConstants::kNchans]; Int_t len[NSnConstants::kNchans]; ns->SetBranchAddress("Ent",&nsent); ns->SetBranchAddress("EvtNum",&nsevn); for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { ns->SetBranchAddress(Form("shift%02d",ch),&(shift[ch])); ns->SetBranchAddress(Form("len%02d",ch),&(len[ch])); } ns->BuildIndex("EvtNum"); // output TString hn; outf = TFile::Open(outfn,"recreate"); if (fitType==20) { hn = "EvtNum:"; for (Int_t i=1; i<NSnConstants::kNchans; ++i) { hn += Form("dt%d%d:",i,i-1); } hn += "chi2"; tChanDTsFit = new TNtuple("tChanDTsFit", "fit of channel dts", hn.Data()); } else { tThetaPhiFit = new TNtuple("tThetaPhiFit","theta phi fit tree", "EvtNum:theta:phi:chi2"); } for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { for (Int_t xc=0; xc<ch; ++xc) { hn = Form("hFiltCorrCoefShiftVsEvt_ch%02d_ch%02d",ch,xc); hFiltCorrCoefShiftVsEvt[ch][xc] = new TH2F(hn.Data(), Form("corr coef for offset between ch%d and ch%d of filtered " "wvfms vs event;event;offset (ch%d-ch%d);correlation coef", ch,xc,ch,xc), nents, -0.5, nents-0.5, NSnConstants::kNsamps, 1-(NSnConstants::kNsamps/2)-0.5, (NSnConstants::kNsamps/2)+0.5); hFiltCorrCoefShiftVsEvt[ch][xc]->SetDirectory(outf); hn = Form("hFiltShiftChi2VsEvt_ch%02d_ch%02d",ch,xc); hFiltShiftChi2VsEvt[ch][xc] = new TH2F(hn.Data(), Form("#chi^{2} of offset between ch%d and ch%d of filtered " "wvfms vs event;event;offset (ch%d-ch%d);#chi^{2}", ch,xc,ch,xc), nents, -0.5, nents-0.5, NSnConstants::kNsamps, 1-(NSnConstants::kNsamps/2)-0.5, (NSnConstants::kNsamps/2)+0.5); hFiltShiftChi2VsEvt[ch][xc]->SetDirectory(outf); } } Long64_t ne(0); for (Long64_t ev=0; ev<nents; ++ev) { //for (Long64_t ev=0; ev<250; ++ev) { if ( (ev%500)==0 ) { fprintf(stderr,"Processing %lld / %lld (%02.2f%%) \r", ev, nents, 100.*static_cast<Float_t>(ev)/static_cast<Float_t>(nents)); } nt->GetEntry(ev); ne = ns->GetEntryNumberWithIndex(evnum); if (ne>-1) { ns->GetEntry(ne); // find the stop shift aveShift = aveLen = 0; for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { aveShift += shift[ch]; aveLen += len[ch]; } aveShift = TMath::Nint( static_cast<Float_t>(aveShift)/ static_cast<Float_t>(NSnConstants::kNchans) ); aveLen = TMath::Nint( static_cast<Float_t>(aveLen)/ static_cast<Float_t>(NSnConstants::kNchans) ); const Int_t shiftStart = NSnConstants::kNsamps-1 - aveShift - aveLen; for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { // subtract FPN const Double_t* pd = gPed[ch]->GetY(); const UShort_t* sp = &(samples[ch][0]); Float_t* ps = &(pedsubs[ch][0]); Float_t* ph = &(psshift[ch][ shiftStart ]); for (Int_t sm=0; sm<NSnConstants::kNsamps; ++sm, ++pd, ++sp, ++ps, ++ph) { *ps = *sp - *pd; while ( (ph-&(psshift[ch][0])) >= NSnConstants::kNsamps) { ph -= NSnConstants::kNsamps; } *ph = *ps; } // apply filter memcpy(&(filtered[ch][0]), &(psshift[ch][0]), NSnConstants::kNsamps*sizeof(Float_t)); if (applyFilter) { filterWaveform(&(filtered[ch][0]), NSnConstants::kNsamps); } // find envelope memcpy(&(envelope[ch][0]), &(filtered[ch][0]), NSnConstants::kNsamps*sizeof(Float_t)); TSnSpectral::EnvelopeReal(&(envelope[ch][0]), NSnConstants::kNsamps); #ifdef DEBUG_SHIFTS TCanvas* cdbgsh = new TCanvas; cdbgsh->cd(); Float_t xsm[NSnConstants::kNsamps], rsmp[NSnConstants::kNsamps]; for (Int_t i=0; i<NSnConstants::kNsamps; ++i) { xsm[i] = i; rsmp[i] = samples[ch][i]; } TGraph* gsmp = new TGraph(NSnConstants::kNsamps, xsm, rsmp); TGraph* gps = new TGraph(NSnConstants::kNsamps, xsm, &(pedsubs[ch][0])); TGraph* gph = new TGraph(NSnConstants::kNsamps, xsm, &(psshift[ch][0])); TGraph* gfl = new TGraph(NSnConstants::kNsamps, xsm, &(filtered[ch][0])); TGraph* gen = new TGraph(NSnConstants::kNsamps, xsm, &(envelope[ch][0])); gsmp->SetMarkerStyle(7); gsmp->SetMarkerColor(kBlack); gsmp->SetLineColor(kBlack); gps->SetMarkerStyle(7); gps->SetMarkerColor(kRed); gps->SetLineColor(kRed); gph->SetMarkerStyle(7); gph->SetMarkerColor(kAzure-7); gph->SetLineColor(kAzure-7); gfl->SetMarkerStyle(7); gfl->SetMarkerColor(kGreen+2); gfl->SetLineColor(kGreen+2); gen->SetMarkerStyle(7); gen->SetMarkerColor(kViolet-1); gen->SetLineColor(kViolet-1); gsmp->SetMinimum(-1500); gsmp->SetMaximum(2500); Printf("ch%d: shift=%d, len=%d", ch, shift[ch], len[ch]); gsmp->Draw("apc"); gps->Draw("pc"); gph->Draw("pc"); gfl->Draw("pc"); gen->Draw("pc"); cdbgsh->WaitPrimitive(); delete gsmp; delete gps; delete gph; delete gfl; delete gen; delete cdbgsh; #endif } if (shiftmaxb!=shiftminb) { maxdt = (shiftmaxb - shiftminb) / (2.0*kSmpRate); } else { maxdt = NSnConstants::kNsamps / (2.0*kSmpRate); } const Float_t* chdat(0), * xcdat(0); for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { if (fitOpt==0) { chdat = &(filtered[ch][0]); } else if (fitOpt==10) { chdat = &(envelope[ch][0]); } else { Fatal("noAveBounceStdy","Unknown fitOpt [%d]",fitOpt); } for (Int_t xc=0; xc<ch; ++xc) { if (fitOpt==0) { xcdat = &(filtered[xc][0]); } else if (fitOpt==10) { xcdat = &(envelope[xc][0]); } else { Fatal("noAveBounceStdy","Unknown fitOpt [%d]",fitOpt); } gcor[ch][xc] = newCorrCoefGraph(chdat, xcdat, NSnConstants::kNsamps, shiftminb, shiftmaxb); gspl[ch][xc] = new TSpline3(Form("spl_%d_%d",ch,xc), gcor[ch][xc]); gchi[ch][xc] = newShiftChi2Graph(chdat, NSnConstants::kNsamps, xcdat, NSnConstants::kNsamps, shiftminb, shiftmaxb); gspc[ch][xc] = new TSpline3(Form("spc_%d_%d",ch,xc), gchi[ch][xc]); #ifdef DEBUG_CORRELS TCanvas* cdbgcl = new TCanvas("cdbgcl","cdbgcl",800,1000); cdbgcl->Divide(1,3); cdbgcl->cd(1); Float_t xxsm[NSnConstants::kNsamps]; for (Int_t i=0; i<NSnConstants::kNsamps; ++i) { xxsm[i] = i; } TGraph* gcfl = new TGraph(NSnConstants::kNsamps, xxsm, &(filtered[ch][0])); TGraph* gxfl = new TGraph(NSnConstants::kNsamps, xxsm, &(filtered[xc][0])); TGraph* gcen = new TGraph(NSnConstants::kNsamps, xxsm, &(envelope[ch][0])); TGraph* gxen = new TGraph(NSnConstants::kNsamps, xxsm, &(envelope[xc][0])); gcfl->SetMarkerStyle(7); gcfl->SetMarkerColor(kBlack); gcfl->SetLineColor(kBlack); gxfl->SetMarkerStyle(7); gxfl->SetMarkerColor(kRed); gxfl->SetLineColor(kRed); gcen->SetMarkerStyle(7); gcen->SetMarkerColor(kGray); gcen->SetLineColor(kGray); gxen->SetMarkerStyle(7); gxen->SetMarkerColor(kViolet-1); gxen->SetLineColor(kViolet-1); gcfl->Draw("apc"); gxfl->Draw("pc"); gcen->Draw("pc"); gxen->Draw("pc"); cdbgcl->cd(2); gspl[ch][xc]->SetMarkerStyle(7); gspl[ch][xc]->SetMarkerColor(kAzure-7); gspl[ch][xc]->SetLineColor(kAzure-7); gspl[ch][xc]->Draw("pc"); cdbgcl->cd(3); gspc[ch][xc]->SetMarkerStyle(7); gspc[ch][xc]->SetMarkerColor(kViolet-6); gspc[ch][xc]->SetLineColor(kViolet-6); gspc[ch][xc]->Draw("pc"); cdbgcl->cd(); cdbgcl->Update(); cdbgcl->WaitPrimitive(); delete gcfl; delete gxfl; delete cdbgcl; delete gcen; delete gxen; #endif const Int_t gn = gcor[ch][xc]->GetN(); const Double_t* gx = gcor[ch][xc]->GetX(), * gy = gcor[ch][xc]->GetY(), * cx = gchi[ch][xc]->GetX(), * cy = gchi[ch][xc]->GetY(); for (Int_t k=0; k<gn; ++k, ++gx, ++gy, ++cx, ++cy) { hFiltCorrCoefShiftVsEvt[ch][xc]->Fill(ev, *gx, *gy); hFiltShiftChi2VsEvt[ch][xc]->Fill(ev, *cx, *cy); } } } if (fitType==20) { // fit for the best, consistent time offsets mini->Clear(); ROOT::Math::Functor f(&getDeltaTsLL, NSnConstants::kNchans-1); mini->SetFunction(f); for (Int_t ch=1; ch<NSnConstants::kNchans; ++ch) { if (strcmp(minner,"Genetic")==0) { mini->SetLimitedVariable(ch-1, Form("dt%d%d",ch,ch-1), 0, 0.01, -maxdt, maxdt); } else { mini->SetVariable(ch-1, Form("dt%d%d",ch,ch-1), 0, 0.01); } } mini->Minimize(); const Double_t* result = mini->X(); const Double_t* rs = result; Float_t* tofil = new Float_t[NSnConstants::kNchans+2]; Float_t* tf = tofil; *tf++ = ev; for (Int_t ch=1; ch<NSnConstants::kNchans; ++ch, ++tf, ++rs) { *tf = *rs; } *tf = mini->MinValue(); tChanDTsFit->Fill(tofil); delete[] tofil; #ifdef DEBUG_DTS for (Int_t ch=1; ch<NSnConstants::kNchans; ++ch) { Printf("result[%d]=%g",ch-1,result[ch-1]); } TCanvas* cdbgdt = new TCanvas("cdbgdt","cdbgdt",1000,1000); cdbgdt->Divide(2,3); Float_t xxsm[NSnConstants::kNsamps]; for (Int_t i=0; i<NSnConstants::kNsamps; ++i) { xxsm[i] = i; } TGraph* gorg[NSnConstants::kNchans]; TGraph* gocp[NSnConstants::kNchans]; TGraph* goen[NSnConstants::kNchans]; TGraph* gshf[NSnConstants::kNchans][NSnConstants::kNchans]; TGraph* gshe[NSnConstants::kNchans][NSnConstants::kNchans]; for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { gorg[ch] = new TGraph(NSnConstants::kNsamps, xxsm, &(filtered[ch][0])); gocp[ch] = new TGraph(NSnConstants::kNsamps, xxsm, &(filtered[ch][0])); goen[ch] = new TGraph(NSnConstants::kNsamps, xxsm, &(envelope[ch][0])); for (Int_t xc=0; xc<ch; ++xc) { Double_t dt=0; for (Int_t i=(ch-xc); i>0; --i) { dt += result[ch-i]; } dt *= kSmpRate; // convert to samples Printf("dt[%d][%d]=%g",ch,xc,dt); gshf[ch][xc] = new TGraph(NSnConstants::kNsamps); gshe[ch][xc] = new TGraph(NSnConstants::kNsamps); for (Int_t i=0; i<NSnConstants::kNsamps; ++i) { gshf[ch][xc]->SetPoint(i, xxsm[i]+dt, filtered[xc][i]); gshe[ch][xc]->SetPoint(i, xxsm[i]+dt, envelope[xc][i]); } gshf[ch][xc]->SetMarkerStyle(7); gshf[ch][xc]->SetLineColor(kRed); gshf[ch][xc]->SetMarkerColor(kRed); gshe[ch][xc]->SetMarkerStyle(7); gshe[ch][xc]->SetLineColor(kViolet-1); gshe[ch][xc]->SetMarkerColor(kViolet-1); } gorg[ch]->SetMarkerStyle(7); gorg[ch]->SetLineColor(kBlack); gorg[ch]->SetMarkerColor(kBlack); goen[ch]->SetMarkerStyle(7); goen[ch]->SetLineColor(kGray); goen[ch]->SetMarkerColor(kGray); gocp[ch]->SetMarkerStyle(7); gocp[ch]->SetLineStyle(7); gocp[ch]->SetLineColor(kGreen+2); gocp[ch]->SetMarkerColor(kGreen+2); } gStyle->SetOptStat(0); Int_t pp=0; for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { for (Int_t xc=0; xc<ch; ++xc) { cdbgdt->cd(++pp); hn = Form("hd_%d_%d",ch,xc); TH2F* hd = new TH2F(hn.Data(), Form("black=ch%d, red/green=ch%d;" "sample;ADC",ch,xc), NSnConstants::kNsamps, -0.5, NSnConstants::kNsamps-0.5, 200, -900, 900); hd->SetBit(TH1::kCanDelete); hd->Draw(); gorg[ch]->Draw("pc"); goen[ch]->Draw("pc"); gocp[xc]->Draw("pc"); gshf[ch][xc]->Draw("pc"); gshe[ch][xc]->Draw("pc"); } } cdbgdt->cd(); cdbgdt->Update(); cdbgdt->WaitPrimitive(); for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { delete gorg[ch]; delete gocp[ch]; delete goen[ch]; for (Int_t xc=0; xc<ch; ++xc) { delete gshf[ch][xc]; delete gshe[ch][xc]; } } delete cdbgdt; #endif } else { Int_t npars(2); Double_t (*fitFunction)(const Double_t*) = 0; if (fitType==0) { fitFunction = &getShiftLL; } else if (fitType==5) { fitFunction = &getShiftChi2; } else { Fatal("bounceStudy","Unknown fit type %d",fitType); } mini->Clear(); ROOT::Math::Functor f(fitFunction, npars); mini->SetFunction(f); if (strcmp(minner,"Genetic")==0) { mini->SetLimitedVariable(0, "theta", 3, 0.01, 0, TMath::Pi()); mini->SetLimitedVariable(1, "phi" , 5.5, 0.01, 0, TMath::TwoPi()); } else { //mini->SetVariable(0, "theta", TMath::Pi(), 0.01); //mini->SetVariable(1, "phi" , (gRandom->Rndm()-0.5), 0.01); mini->SetVariable(0, "theta", 3, 0.01); mini->SetVariable(1, "phi" , 5.5, 0.01); //mini->SetVariable(0, "theta", 3, 0.05); //mini->SetVariable(1, "phi" , 5.5, 0.05); } mini->Minimize(); const Double_t* result = mini->X(); tThetaPhiFit->Fill(ev, result[0], result[1], mini->MinValue()); #ifdef DEBUG_THETAPHI // regularize the angles Double_t theta = TVector2::Phi_mpi_pi(result[0]); Double_t phi = result[1]; if (theta<0) { theta *= -1.0; phi += TMath::Pi(); } phi = TVector2::Phi_0_2pi(phi); Printf("theta=%g, phi=%g (%g, %g)", theta*TMath::RadToDeg(), phi*TMath::RadToDeg(), result[0], result[1]); TCanvas* cdbgtp = new TCanvas("cdbgtp","cdbgtp",1000,1000); cdbgtp->Divide(2,3); Float_t xxsm[NSnConstants::kNsamps]; for (Int_t i=0; i<NSnConstants::kNsamps; ++i) { xxsm[i] = i; } TGraph* gorg[NSnConstants::kNchans]; TGraph* gocp[NSnConstants::kNchans]; TGraph* gshf[NSnConstants::kNchans][NSnConstants::kNchans]; for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { gorg[ch] = new TGraph(NSnConstants::kNsamps, xxsm, &(filtered[ch][0])); gocp[ch] = new TGraph(NSnConstants::kNsamps, xxsm, &(filtered[ch][0])); for (Int_t xc=0; xc<ch; ++xc) { Double_t dtcor=0; for (Int_t i=(ch-xc); i>0; --i) { dtcor += dtCorrs[ch-i]; } const TVector3& posCh = getStnPos(ch); const TVector3& posXc = getStnPos(xc); TVector3 norm; norm.SetMagThetaPhi(1.0, result[0], result[1]); //norm.SetMagThetaPhi(1.0, 2.95833, 5.497787); const Double_t disCh = -(posCh.Dot(norm)); const Double_t disXc = -(posXc.Dot(norm)); // !!! check sign of delta(distance) and dtcor! const Double_t dt = kSmpRate * ( ( (disCh-disXc) * kNgTopFern / kC_m_ns ) // from m to ns + dtcor ); Printf("dt[%d,%d]=%g (dis[%d]=%g, dis[%d]=%g)", ch,xc,dt, ch,disCh,xc,disXc); gshf[ch][xc] = new TGraph(NSnConstants::kNsamps); for (Int_t i=0; i<NSnConstants::kNsamps; ++i) { gshf[ch][xc]->SetPoint(i, xxsm[i]+dt, filtered[xc][i]); } gshf[ch][xc]->SetMarkerStyle(7); gshf[ch][xc]->SetLineColor(kRed); gshf[ch][xc]->SetMarkerColor(kRed); } gorg[ch]->SetMarkerStyle(7); gorg[ch]->SetLineColor(kBlack); gorg[ch]->SetMarkerColor(kBlack); gocp[ch]->SetMarkerStyle(7); gocp[ch]->SetLineStyle(7); gocp[ch]->SetLineColor(kGreen+2); gocp[ch]->SetMarkerColor(kGreen+2); } gStyle->SetOptStat(0); Int_t pp=0; for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { for (Int_t xc=0; xc<ch; ++xc) { cdbgtp->cd(++pp); hn = Form("hd_%d_%d",ch,xc); TH2F* hd = new TH2F(hn.Data(), Form("black=ch%d, red/green=ch%d;" "sample;ADC",ch,xc), NSnConstants::kNsamps, -0.5, NSnConstants::kNsamps-0.5, 200, -900, 900); hd->SetBit(TH1::kCanDelete); hd->Draw(); gorg[ch]->Draw("pc"); gocp[xc]->Draw("pc"); gshf[ch][xc]->Draw("pc"); } } cdbgtp->cd(); cdbgtp->Update(); cdbgtp->WaitPrimitive(); for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { delete gorg[ch]; delete gocp[ch]; for (Int_t xc=0; xc<ch; ++xc) { delete gshf[ch][xc]; } } delete cdbgtp; #endif } for (Int_t ch=0; ch<NSnConstants::kNchans; ++ch) { for (Int_t xc=0; xc<ch; ++xc) { delete gspl[ch][xc]; delete gcor[ch][xc]; delete gchi[ch][xc]; delete gspc[ch][xc]; } } } } // event loop outf->Write(); }