diff --git a/FirstAnalysis/Correlations/doPhiProjections.C b/FirstAnalysis/Correlations/doPhiProjections.C deleted file mode 100644 index 2f714291..00000000 --- a/FirstAnalysis/Correlations/doPhiProjections.C +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -////////////////////////////////////////////////////////////// -// Macro to obtain projections of two-particle correlations for flow studies -// -// For reference and pT-differential flow do -// 1) a projection on deltaeta axis of the away and near side region separately -// 2) a projection on deltaphi axis of the near-side ridge region (excluding the jet peak) -// -// Input: file with 2D correlation histograms produced by extract2D.C macro in this folder -// -// Usage: root -l doPhiProjections.C -// -// Parameters: -// - inFileName: name of the input file -// - absDeltaEtaMin: lower edge of deltaeta range when integrating the near-side ridge region -// - absDeltaEtaMax: upper edge of deltaeta range when integrating the near-side ridge region -// - outFileName: name of the output file with histograms of projections -// - outputPlotsName: name of the folder to store plots -// - drawPlots: flag to draw the projections -// - savePlots: flag to save the drawn projections -// -// Contributors: -// Katarina Krizkova Gajdosova -// Gian Michele Innocenti -// Jan Fiete Grosse-Oetringhaus -////////////////////////////////////////////////////////////// - -bool wingCorrection = false; // correct for increase of correlation signal at large deltaeta values - -// Note: if a canvas is drawn with an empty pad, it is probably because -// the TFile took ownership of the histogram and deleted it when -// it went out of scope -// To fix it, call h->SetDirectory(0) before drawing - -int nBinspTtrig = 6; -double binspTtrig[] = {0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0}; - -int nBinspTref = 1; -double binspTref[] = {0.2, 3.0}; - -void doPhiProjections( - const char* inFileName = "dphi_corr.root", - double absDeltaEtaMin = 1.4, - double absDeltaEtaMax = 1.8, - const char* outFileName = "phi_proj.root", - const char* outputPlotsName = "./plots", - bool drawPlots = false, - bool savePlots = false) -{ - // Nch represents the multiplicity interval of the analysis - static Double_t Nch[] = {0, 10, 20, 30, 40, 50, 60, 80, 100, 200}; - // Nbins is the number of multiplicity bins - static const uint Nbins = 9; - // static const uint Nbins = sizeof(Nch) / sizeof(Nch[0]); - const double absDeltaPhi = 1.3; // y-projection range (it is only needed for jet yield calculation from delta eta projection) - - TFile* infile = new TFile(inFileName, "read"); - TFile* outfile = new TFile(outFileName, "recreate"); - - const uint assocCount = 1; - const uint trigCount = 6; - - for (uint imult = 0; imult < Nbins; ++imult) { - - // do reference flow - - // 2D histogram of two-particle correlation: same/mixed event ratio (normalised as it should be: Ntrig, B(0,0)) - TH2D* hdphidetaRidge_ref = reinterpret_cast(infile->Get(Form("dphi_ref_%u", imult))); - if (!hdphidetaRidge_ref) { - printf("No histograms corresponding mult bin %u \n", imult); - continue; - } - - // projection of near-side ridge on delta phi axis (positive side of the jet peak) - int aridgeP_ref = hdphidetaRidge_ref->GetYaxis()->FindBin(absDeltaEtaMin); - int bridgeP_ref = hdphidetaRidge_ref->GetYaxis()->FindBin(absDeltaEtaMax); - TH1D* hdphiRidgeP_ref = hdphidetaRidge_ref->ProjectionX(Form("proj_dphi_P_ref_%u", imult), aridgeP_ref, bridgeP_ref, "e"); - outfile->cd(); - hdphiRidgeP_ref->Write(); - - // projection of near-side ridge on delta phi axis (negative side of the jet peak) - int aridgeN_ref = hdphidetaRidge_ref->GetYaxis()->FindBin(-absDeltaEtaMax); - int bridgeN_ref = hdphidetaRidge_ref->GetYaxis()->FindBin(-absDeltaEtaMin); - TH1D* hdphiRidgeN_ref = hdphidetaRidge_ref->ProjectionX(Form("proj_dphi_N_ref_%u", imult), aridgeN_ref, bridgeN_ref, "e"); - outfile->cd(); - hdphiRidgeN_ref->Write(); - - // add the projections positive + negative - TH1D* hdphiRidge_ref = reinterpret_cast(hdphiRidgeP_ref->Clone(Form("proj_dphi_ref_%u", imult))); - hdphiRidge_ref->Add(hdphiRidgeP_ref, hdphiRidgeN_ref, 0.5, 0.5); - - outfile->cd(); - hdphiRidge_ref->Write(); - - if (drawPlots) { - - TCanvas* cTemplate = new TCanvas("cTemplate", "", 1200, 800); - gPad->SetMargin(0.12, 0.01, 0.12, 0.01); - hdphiRidge_ref->SetTitle(""); - hdphiRidge_ref->SetStats(0); - hdphiRidge_ref->GetYaxis()->SetTitleOffset(1.1); - hdphiRidge_ref->GetXaxis()->SetTitleSize(0.05); - hdphiRidge_ref->GetYaxis()->SetTitle("Y(#Delta#varphi)"); - hdphiRidge_ref->GetYaxis()->SetTitleSize(0.05); - hdphiRidge_ref->SetLineColor(kBlue + 1); - hdphiRidge_ref->SetMarkerStyle(kFullCircle); - hdphiRidge_ref->SetMarkerColor(kBlue + 1); - hdphiRidge_ref->SetMarkerSize(1.3); - hdphiRidge_ref->Draw(""); - - TLatex* latex = 0; - latex = new TLatex(); - latex->SetTextSize(0.038); - latex->SetTextFont(42); - latex->SetTextAlign(21); - latex->SetNDC(); - - latex->DrawLatex(0.3, 0.93, "pp #sqrt{s} = 13 TeV"); - latex->DrawLatex(0.3, 0.86, Form("%.1f < p_{T, trig, assoc} < %.1f", binspTref[0], binspTref[1])); - latex->DrawLatex(0.3, 0.79, Form("%.1f < N_{ch} < %.1f", Nch[imult], Nch[imult + 1])); - - if (savePlots) - cTemplate->SaveAs(Form("%s/dphiRidge_ref_%d.png", outputPlotsName, imult)); - } - - // do pT-differential flow - for (uint itrig = 0; itrig < trigCount; ++itrig) { - for (uint iassoc = 0; iassoc < assocCount; ++iassoc) { - - // 2D histogram of two-particle correlation: same/mixed event ratio (normalised as it should be: Ntrig, B(0,0)) - TH2D* hdphidetaRidge = reinterpret_cast(infile->Get(Form("dphi_%u_%u_%u", itrig, iassoc, imult))); - if (!hdphidetaRidge) { - printf("No histograms corresponding mult bin %u. (itrig=%u, iassoc=%u)\n", imult, itrig, iassoc); - continue; - } // if histogram not existing - - // Clone hdphidetaJet: hdphidetaRidge will be used for phi projection; hdphidetaJet for eta projection - TH2D* hdphidetaJet = reinterpret_cast(hdphidetaRidge->Clone("hdphidetaJet")); - - // Normalise hdphidetaRidge used for delta phi projection with the width of the long-range region - double norm = 2.0 * (absDeltaEtaMax - absDeltaEtaMin); - hdphidetaRidge->Scale(1.0 / norm); - - // projection of the away-side ridge on delta eta axis - int ajetaway = hdphidetaJet->GetXaxis()->FindBin(TMath::Pi() - 1.5); - int bjetaway = hdphidetaJet->GetXaxis()->FindBin(TMath::Pi() + 1.5); - TH1D* hdetaJetAway = hdphidetaJet->ProjectionY(Form("proj_deta_%u_%u_%u", itrig, iassoc, imult), ajetaway, bjetaway, "e"); - outfile->cd(); - hdetaJetAway->Write(); - - // projection of the near-side region (peak+ridge) on delta eta axis - int ajetpeak = hdphidetaJet->GetXaxis()->FindBin(-1.5); - int bjetpeak = hdphidetaJet->GetXaxis()->FindBin(+1.5); - TH1D* hdetaJetPeak = hdphidetaJet->ProjectionY(Form("proj_detaJetPeak_%u_%u_%u", itrig, iassoc, imult), ajetpeak, bjetpeak, "e"); - outfile->cd(); - hdetaJetPeak->Write(); - - // wing correction (switched off for now) - if (wingCorrection) { - // project the away side onto delta eta, fit with polynomial, and scale the 2D histogram by the difference - // between the projected histogram and the fit - int a = hdphidetaRidge->GetXaxis()->FindBin(TMath::Pi() - 1.5); - int b = hdphidetaRidge->GetXaxis()->FindBin(TMath::Pi() + 1.5); - TH1D* hdetaAwayProj = hdphidetaRidge->ProjectionY(Form("proj_deta_%u_%u_%u_scaler", itrig, iassoc, imult), a, b, "e"); - hdetaAwayProj->Fit("pol0", "0QSE"); - hdetaAwayProj->Divide(hdetaAwayProj->GetFunction("pol0")); - for (uint i = 1; i < hdphidetaRidge->GetNbinsX(); ++i) - for (uint j = 1; j < hdphidetaRidge->GetNbinsY(); ++j) { - double z = hdetaAwayProj->GetBinContent(j); - if (z <= 0.0) - continue; - hdphidetaRidge->SetBinContent(i, j, hdphidetaRidge->GetBinContent(i, j) / z); - hdphidetaRidge->SetBinError(i, j, hdphidetaRidge->GetBinError(i, j) / z); - } - } - - // projection of near-side ridge on delta phi axis (positive side of the jet peak) - int aridgeP = hdphidetaRidge->GetYaxis()->FindBin(absDeltaEtaMin); - int bridgeP = hdphidetaRidge->GetYaxis()->FindBin(absDeltaEtaMax); - TH1D* hdphiRidgeP = hdphidetaRidge->ProjectionX(Form("proj_dphi_P_%u_%u_%u", itrig, iassoc, imult), aridgeP, bridgeP, "e"); - outfile->cd(); - hdphiRidgeP->Write(); - - // projection of near-side ridge on delta phi axis (negative side of the jet peak) - int aridgeN = hdphidetaRidge->GetYaxis()->FindBin(-absDeltaEtaMax); - int bridgeN = hdphidetaRidge->GetYaxis()->FindBin(-absDeltaEtaMin); - TH1D* hdphiRidgeN = hdphidetaRidge->ProjectionX(Form("proj_dphi_N_%u_%u_%u", itrig, iassoc, imult), aridgeN, bridgeN, "e"); - outfile->cd(); - hdphiRidgeN->Write(); - - // add the projections positive + negative - TH1D* hdphiRidge = reinterpret_cast(hdphiRidgeP->Clone(Form("proj_dphi_%u_%u_%u", itrig, iassoc, imult))); - hdphiRidge->Add(hdphiRidgeP, hdphiRidgeN, 0.5, 0.5); - - outfile->cd(); - hdphiRidge->Write(); - - if (drawPlots) { - TCanvas* cTemplate = new TCanvas("cTemplate", "", 1200, 800); - gPad->SetMargin(0.12, 0.01, 0.12, 0.01); - hdphiRidge->SetTitle(""); - hdphiRidge->SetStats(0); - hdphiRidge->GetYaxis()->SetTitleOffset(1.1); - hdphiRidge->GetXaxis()->SetTitleSize(0.05); - hdphiRidge->GetYaxis()->SetTitle("Y(#Delta#varphi)"); - hdphiRidge->GetYaxis()->SetTitleSize(0.05); - hdphiRidge->SetLineColor(kBlue + 1); - hdphiRidge->SetMarkerStyle(kFullCircle); - hdphiRidge->SetMarkerColor(kBlue + 1); - hdphiRidge->SetMarkerSize(1.3); - hdphiRidge->Draw(""); - - TLatex* latex = 0; - latex = new TLatex(); - latex->SetTextSize(0.038); - latex->SetTextFont(42); - latex->SetTextAlign(21); - latex->SetNDC(); - - latex->DrawLatex(0.3, 0.93, "pp #sqrt{s} = 13 TeV"); - latex->DrawLatex(0.3, 0.86, Form("%.1f < p_{T, trig} < %.1f", binspTtrig[itrig], binspTtrig[itrig + 1])); - latex->DrawLatex(0.3, 0.79, Form("%.1f < N_{ch} < %.1f", Nch[imult], Nch[imult + 1])); - - if (savePlots) - cTemplate->SaveAs(Form("%s/dphiRidge_%d_%d.png", outputPlotsName, itrig, imult)); - } - - } // loop over the index of the associated particle - } // loop over the index of the trigger particle - } // loop over the index of the multiplicity interval - - outfile->Close(); - -} // end of doPhiProjections diff --git a/FirstAnalysis/Correlations/doTemplate.C b/FirstAnalysis/Correlations/doTemplate.C deleted file mode 100644 index 198143d5..00000000 --- a/FirstAnalysis/Correlations/doTemplate.C +++ /dev/null @@ -1,409 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -/////////////////////////////////////////////////////////////////////////// -// Macro to perform a template fit on 1D histograms of projected correlations on delta phi -// -// This macro allows you to fit the correlation vs. delta phi and extract V_nDelta coefficients -// for both reference and differential flow. -// v_n = sqrt{V_nDelta} -> this is done in the final macro getFlow.C -// -// Input: file with histograms produced by doPhiProjections.C -// -// Usage: root -l doTemplate.C -// -// Parameters: -// - inputFileName: input file -// - outputFileName: output file containing V_nDelta results -// - outputPlotsName: name of the folder to store plots -// - drawSeparatevn: flag to draw the template fit result for v2 and v3 separately instead of sum of vn -// - drawTemplate: flag to draw the result of the template fit with the correlation -// - savePlots: flag to save drawn plots -// -// Contributors: -// Katarina Krizkova Gajdosova -// Gian Michele Innocenti -/////////////////////////////////////////////////////////////////////////// - -int nBinspTtrig = 6; -double binspTtrig[] = {0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0}; - -int nBinspTref = 1; -double binspTref[] = {0.2, 3.0}; - -const int nBinsMult = 7; -double binsMult[] = {0, 10, 20, 30, 40, 50, 60, 80, 100, 200}; - -TFile* outputFile; - -TH1D *hminuit, *hminuit_periph; - -TH1D* hDifferentialV2[nBinsMult]; - -void tempMinuit(double* fParamVal, double* fParamErr); -void minuitFunction(int& npar, double* gin, double& ff, double* par, int iflag); -double templateFitFunction(double* x, double* par); - -/////////////////////////////////////////////////////////////////////////// -// Main function -/////////////////////////////////////////////////////////////////////////// -void doTemplate( - const char* inputFileName = "./phi_proj.root", - const char* outputFileName = "./templateResult.root", - const char* outputPlotsName = "./plots", - bool drawSeparatevn = false, - bool drawTemplate = true, - bool savePlots = true) -{ - - TFile* inFile = TFile::Open(Form("%s", inputFileName), "read"); - - // V_nDelta (v_2^2) for reference flow vs. multiplicity - TH1D* hReferenceV2 = new TH1D("hReferenceV2", "v_{2#delta}; Multiplicity; v_{2#Delta}", nBinsMult, binsMult); - - // perform template for reference and differential flow in respective bins of pTtrig, pTassoc and mult - for (int iMult = 0; iMult < nBinsMult; iMult++) { - - // do reference flow here - // get the histograms projected to delta phi, - // we need to distinguish histogram with desired (high) multiplicity - // from a histogram with low multiplicity used as the peripheral baseline - hminuit = reinterpret_cast(inFile->Get(Form("proj_dphi_ref_%d", iMult))->Clone("hminuit")); - hminuit_periph = reinterpret_cast(inFile->Get("proj_dphi_ref_0")->Clone("hminuit_periph")); - - // do the template fit - double par[4], parerr[4]; - tempMinuit(par, parerr); - - // fill the resulting V_2delta into histogram vs. pT - hReferenceV2->SetBinContent(iMult + 1, par[2]); - hReferenceV2->SetBinError(iMult + 1, parerr[2]); - - // draw the result of the template fit - if (drawTemplate) { - - // F*Y_peripheral(deltaphi) + Y_ridge = template fit - TF1* fTemplate = new TF1("fTemplate", templateFitFunction, -0.5 * TMath::Pi() + 1e-6, 1.5 * TMath::Pi() - 1e-6, 4); - fTemplate->SetParameters(par); // set the parameters obtained from template fit above using tempMinuit() - // fTemplate->SetLineStyle(kSolid); - // fTemplate->SetLineColor(kBlue+1); - - TH1F* hTemplate = reinterpret_cast(hminuit->Clone()); - hTemplate->Reset(); - for (int iBin = 1; iBin < hTemplate->GetNbinsX() + 1; iBin++) { - hTemplate->SetBinContent(iBin, fTemplate->Eval(hTemplate->GetBinCenter(iBin))); - } - hTemplate->SetLineColor(kBlue + 1); - hTemplate->SetLineWidth(3); - hTemplate->SetLineStyle(kSolid); - - // F*Y_peripheral(0) + Y_ridge v2 - TF1* fRidge; - if (drawSeparatevn) { - fRidge = new TF1("fRidge", "[0]*[3] + [1]*(1 + 2*[2]*cos(2*x))", -5, 5); - } else { - fRidge = new TF1("fRidge", "[0]*[4] + [1]*(1 + 2*[2]*cos(2*x) + 2*[3]*cos(3*x))", -5, 5); - } - fRidge->SetParameter(0, par[0]); // F - fRidge->SetParameter(1, par[1]); // G - fRidge->SetParameter(2, par[2]); // v_2^2 - fRidge->SetParameter(3, par[3]); // v_3^2 - fRidge->SetParameter(4, hminuit_periph->GetBinContent(hminuit_periph->FindFixBin(0))); // Y_peripheral(0) - fRidge->SetLineStyle(kSolid); - fRidge->SetLineWidth(3); - fRidge->SetLineColor(kRed + 1); - - if (drawSeparatevn) { - // F*Y_peripheral(0) + Y_ridge v3 - TF1* fRidgev3 = new TF1("fRidgev3", "[0]*[3] + [1]*(1 + 2*[2]*cos(3*x))", -5, 5); - fRidgev3->SetParameter(0, par[0]); // F - fRidgev3->SetParameter(1, par[1]); // G - fRidgev3->SetParameter(2, par[3]); // v_3^2 - fRidgev3->SetParameter(3, hminuit_periph->GetBinContent(hminuit_periph->FindFixBin(0))); // Y_peripheral(0) - fRidgev3->SetLineStyle(kDashed); - fRidgev3->SetLineWidth(3); - fRidgev3->SetLineColor(kRed + 1); - } - - // F*Y_peripheral(deltaphi) + G - TF1* fPeripheral = new TF1("fPeripheral", templateFitFunction, -0.5 * TMath::Pi() + 1e-6, 1.5 * TMath::Pi() - 1e-6, 5); - par[2] = 0; // v2^2 = 0 - par[3] = 0; // v3^2 = 0 - fPeripheral->SetParameters(par); - fPeripheral->SetLineStyle(kSolid); - fPeripheral->SetLineWidth(3); - fPeripheral->SetLineColor(kGreen + 2); - - TH1F* hPeripheral = reinterpret_cast(hminuit->Clone()); - hPeripheral->Reset(); - for (int iBin = 1; iBin < hPeripheral->GetNbinsX() + 1; iBin++) { - hPeripheral->SetBinContent(iBin, fPeripheral->Eval(hPeripheral->GetBinCenter(iBin))); - } - hPeripheral->SetLineColor(kGreen + 2); - hPeripheral->SetLineWidth(2); - hPeripheral->SetLineStyle(kSolid); - hPeripheral->SetMarkerStyle(kOpenSquare); - hPeripheral->SetMarkerColor(kGreen + 2); - hPeripheral->SetMarkerSize(1.2); - - // draw the HM projection with the template fits together - TCanvas* cTemplate = new TCanvas("cTemplate", "", 1200, 800); - gPad->SetMargin(0.12, 0.01, 0.12, 0.01); - hminuit->SetTitle(""); - hminuit->SetStats(0); - hminuit->GetYaxis()->SetTitleOffset(1.1); - hminuit->GetXaxis()->SetTitleSize(0.05); - hminuit->GetYaxis()->SetTitle("Y(#Delta#varphi)"); - hminuit->GetYaxis()->SetTitleSize(0.05); - hminuit->SetLineColor(kBlack); - hminuit->SetMarkerStyle(kFullCircle); - hminuit->SetMarkerColor(kBlack); - hminuit->SetMarkerSize(1.4); - hminuit->Draw(""); - hTemplate->Draw("hist same"); - hPeripheral->Draw("hist same"); - fRidge->Draw("same"); - if (drawSeparatevn) { - fRidgev3->Draw("same"); - } - - TLegend* legend = new TLegend(0.15, 0.55, 0.5, 0.75); - legend->SetFillColor(0); - legend->SetBorderSize(0); - legend->SetTextSize(0.035); - - legend->AddEntry(hTemplate, "FY(#Delta#varphi)^{peri} + G(1 + #Sigma_{n=2}^{3} 2V_{n#Delta} cos(n#Delta#varphi))", "L"); - legend->AddEntry(hPeripheral, "FY(#Delta#varphi)^{peri} + G", "L"); - legend->AddEntry(fRidge, "FY(0)^{peri} + G(1 + #Sigma_{n=2}^{3} 2V_{n#Delta} cos(n#Delta#varphi))", "L"); - legend->Draw("same"); - - TLatex* latex = 0; - latex = new TLatex(); - latex->SetTextSize(0.038); - latex->SetTextFont(42); - latex->SetTextAlign(21); - latex->SetNDC(); - - latex->DrawLatex(0.3, 0.93, "pp #sqrt{s} = 13 TeV"); - latex->DrawLatex(0.3, 0.86, Form("%.1f < p_{T, trig, assoc} < %.1f", binspTref[0], binspTref[1])); - latex->DrawLatex(0.3, 0.79, Form("%.1f < N_{ch} < %.1f", binsMult[iMult], binsMult[iMult + 1])); - // latex->DrawLatex(0.3,0.72,Form("%.1f < #Delta#eta < %.1f",etaMin,etaMax)); - - if (savePlots) - cTemplate->SaveAs(Form("%s/template_ref_%d.png", outputPlotsName, iMult)); - } - - // do differential flow here - // V_nDelta (v_2^2) for differential flow vs. pT and in bins of multiplicity - hDifferentialV2[iMult] = new TH1D(Form("hDifferentialV2_%d", iMult), "v_{2#delta}; p_T; v_{2#Delta}", nBinspTtrig, binspTtrig); - - for (int ipTtrig = 0; ipTtrig < nBinspTtrig; ipTtrig++) { - - // get the histograms projected to delta phi, - // we need to distinguish histogram with desired (high) multiplicity - // from a histogram with low multiplicity used as the peripheral baseline - hminuit = reinterpret_cast(inFile->Get(Form("proj_dphi_%d_0_%d", ipTtrig, iMult))->Clone("hminuit")); - hminuit_periph = reinterpret_cast(inFile->Get(Form("proj_dphi_%d_0_0", ipTtrig))->Clone("hminuit_periph")); - - // do the template fit - double par[4], parerr[4]; - tempMinuit(par, parerr); - - // fill the resulting V_2delta into histogram vs. pT - hDifferentialV2[iMult]->SetBinContent(ipTtrig + 1, par[2]); - hDifferentialV2[iMult]->SetBinError(ipTtrig + 1, parerr[2]); - - // draw the result of the template fit - if (drawTemplate) { - - // F*Y_peripheral(deltaphi) + Y_ridge = template fit - TF1* fTemplate = new TF1("fTemplate", templateFitFunction, -0.5 * TMath::Pi() + 1e-6, 1.5 * TMath::Pi() - 1e-6, 4); - fTemplate->SetParameters(par); // set the parameters obtained from template fit above using tempMinuit() - fTemplate->SetLineStyle(kSolid); - fTemplate->SetLineColor(kRed); - - TH1F* hTemplate = reinterpret_cast(hminuit->Clone()); - hTemplate->Reset(); - for (int iBin = 1; iBin < hTemplate->GetNbinsX() + 1; iBin++) { - hTemplate->SetBinContent(iBin, fTemplate->Eval(hTemplate->GetBinCenter(iBin))); - } - hTemplate->SetLineColor(kBlue + 1); - hTemplate->SetLineWidth(3); - hTemplate->SetLineStyle(kSolid); - - // F*Y_peripheral(0) + Y_ridge - TF1* fRidge = new TF1("fRidge", "[0]*[4] + [1]*(1 + 2*[2]*cos(2*x) + 2*[3]*cos(3*x))", -5, 5); - fRidge->SetParameter(0, par[0]); // F - fRidge->SetParameter(1, par[1]); // G - fRidge->SetParameter(2, par[2]); // v_2^2 - fRidge->SetParameter(3, par[3]); // v_3^2 - fRidge->SetParameter(4, hminuit_periph->GetBinContent(hminuit_periph->FindFixBin(0))); // Y_peripheral(0) - fRidge->SetLineStyle(kSolid); - fRidge->SetLineWidth(3); - fRidge->SetLineColor(kRed + 1); - - // F*Y_peripheral(deltaphi) + G - TF1* fPeripheral = new TF1("fPeripheral", templateFitFunction, -0.5 * TMath::Pi() + 1e-6, 1.5 * TMath::Pi() - 1e-6, 5); - par[2] = 0; // v2^2 = 0 - par[3] = 0; // v3^2 = 0 - fPeripheral->SetParameters(par); - fPeripheral->SetLineStyle(kSolid); - fPeripheral->SetLineColor(kMagenta); - - TH1F* hPeripheral = reinterpret_cast(hminuit->Clone()); - hPeripheral->Reset(); - for (int iBin = 1; iBin < hPeripheral->GetNbinsX() + 1; iBin++) { - hPeripheral->SetBinContent(iBin, fPeripheral->Eval(hPeripheral->GetBinCenter(iBin))); - } - hPeripheral->SetLineColor(kGreen + 2); - hPeripheral->SetLineWidth(2); - hPeripheral->SetLineStyle(kSolid); - hPeripheral->SetMarkerStyle(kOpenSquare); - hPeripheral->SetMarkerColor(kGreen + 2); - hPeripheral->SetMarkerSize(1.2); - - // draw the HM projection with the template fits together - TCanvas* cTemplate = new TCanvas("cTemplate", "", 1200, 800); - gPad->SetMargin(0.12, 0.01, 0.12, 0.01); - hminuit->SetTitle(""); - hminuit->SetStats(0); - hminuit->GetYaxis()->SetTitleOffset(1.1); - hminuit->GetXaxis()->SetTitleSize(0.05); - hminuit->GetYaxis()->SetTitle("Y(#Delta#varphi)"); - hminuit->GetYaxis()->SetTitleSize(0.05); - hminuit->SetLineColor(kBlack); - hminuit->SetMarkerStyle(kFullCircle); - hminuit->SetMarkerColor(kBlack); - hminuit->SetMarkerSize(1.4); - hminuit->Draw(""); - hTemplate->Draw("hist same"); - hPeripheral->Draw("hist same"); - fRidge->Draw("same"); - - TLegend* legend = new TLegend(0.15, 0.55, 0.5, 0.75); - legend->SetFillColor(0); - legend->SetBorderSize(0); - legend->SetTextSize(0.035); - - legend->AddEntry(hTemplate, "FY(#Delta#varphi)^{peri} + G(1 + #Sigma_{n=2}^{3} 2V_{n#Delta} cos(n#Delta#varphi))", "L"); - legend->AddEntry(hPeripheral, "FY(#Delta#varphi)^{peri} + G", "L"); - legend->AddEntry(fRidge, "FY(0)^{peri} + G(1 + #Sigma_{n=2}^{3} 2V_{n#Delta} cos(n#Delta#varphi))", "L"); - legend->Draw("same"); - - TLatex* latex = 0; - latex = new TLatex(); - latex->SetTextSize(0.038); - latex->SetTextFont(42); - latex->SetTextAlign(21); - latex->SetNDC(); - - latex->DrawLatex(0.3, 0.93, "pp #sqrt{s} = 13 TeV"); - latex->DrawLatex(0.3, 0.86, Form("%.1f < p_{T, trig} < %.1f", binspTtrig[ipTtrig], binspTtrig[ipTtrig + 1])); - latex->DrawLatex(0.3, 0.79, Form("%.1f < N_{ch} < %.1f", binsMult[iMult], binsMult[iMult + 1])); - // latex->DrawLatex(0.3,0.72,Form("%.1f < #Delta#eta < %.1f",etaMin,etaMax)); - - if (savePlots) - cTemplate->SaveAs(Form("%s/template_%d_%d.png", outputPlotsName, ipTtrig, iMult)); - } - } // end of pT trig loop - } // end of mult loop - - // save the results - outputFile = new TFile(Form("%s", outputFileName), "recreate"); - hReferenceV2->Write(); - for (int iMult = 0; iMult < nBinsMult; iMult++) { - hDifferentialV2[iMult]->Write(); - } - outputFile->Close(); - -} // end of main function - -/////////////////////////////////////////////////////////////////////////// -// template fit function used for drawing the result of the minimization -/////////////////////////////////////////////////////////////////////////// -double templateFitFunction(double* x, double* par) -{ - float xx = x[0]; - - int iBin = hminuit_periph->GetXaxis()->FindBin(xx); - double Y_periph = hminuit_periph->GetBinContent(iBin); - - // Explanation of the parameters: - // par[0] = F - // Y_periph = Y_peripheral (delta phi) - // par[3] = G - // par[1] = V_2delta = v_2,2 = v_2^2 - // par[2] = V_3delta = v_3,3 = v_3^2 - return par[0] * Y_periph + par[1] * (1 + 2 * par[2] * cos(2 * xx) + 2 * par[3] * cos(3 * xx)); -} - -/////////////////////////////////////////////////////////////////////////// -// this function provides the first initial value of chi2 -// to start the minimization procedure done in tempMinuit() -/////////////////////////////////////////////////////////////////////////// -void minuitFunction(int& npar, double* gin, double& ff, double* par, int iflag) -{ - TH1D* h = reinterpret_cast(hminuit->Clone("h")); - TH1D* hperi = reinterpret_cast(hminuit_periph->Clone("hperi")); - - double f = par[0]; - double gv = par[1]; - double v2 = par[2]; - double v3 = par[3]; - - double lnQ = 0; - - // get chi2 as a starting point - for (int ibin = 1; ibin < h->GetNbinsX(); ibin++) { - double x = h->GetBinCenter(ibin + 1); // delta phi - double data = h->GetBinContent(ibin + 1); // value of the correlation (high-mult) - double exp = f * hperi->GetBinContent(ibin + 1) + gv * (1. + 2. * v2 * cos(2. * x) + 2. * v3 * cos(3. * x)); // template fit prescription - double hoge = sqrt(hperi->GetBinError(ibin + 1) * hperi->GetBinError(ibin + 1) + h->GetBinError(ibin + 1) * h->GetBinError(ibin + 1)); // error:sqrt(sig*sig + peri*peri) - lnQ += (data - exp) * (data - exp) / (hoge * hoge); // chi2 - } - - ff = lnQ; -} - -/////////////////////////////////////////////////////////////////////////// -// this function performs the minimization to obtain template fit -// at the beginning it needs to be provided with initial values -// of parameters and a chi2 (chi2 value is provided with minuitFunction()) -/////////////////////////////////////////////////////////////////////////// -void tempMinuit(double* fParamVal, double* fParamErr) -{ - TFitter* minimizer = new TFitter(4); - minimizer->SetFCN(minuitFunction); // set some initial chi2 value? - minimizer->SetParameter(0, "F", 0, 10, 0, 0); - minimizer->SetParameter(1, "G", 0, 10, 0, 0); - minimizer->SetParameter(2, "v2", 0, 1, 0, 0); - minimizer->SetParameter(3, "v3", 0, 1, 0, 0); - - // minimizer->ExecuteCommand("SIMPLEX",0,0); - minimizer->ExecuteCommand("MIGRAD", 0, 0); - - fParamVal[0] = minimizer->GetParameter(0); // F - fParamVal[1] = minimizer->GetParameter(1); // G - fParamVal[2] = minimizer->GetParameter(2); // v2 - fParamVal[3] = minimizer->GetParameter(3); // v3 - - fParamErr[0] = minimizer->GetParError(0); - fParamErr[1] = minimizer->GetParError(1); - fParamErr[2] = minimizer->GetParError(2); - fParamErr[3] = minimizer->GetParError(3); - - cout << "F = " << fParamVal[0] << "+/-" << fParamErr[0] << "\n"; - cout << "G = " << fParamVal[1] << "+/-" << fParamErr[1] << "\n"; - cout << "v2 = " << fParamVal[2] << "+/-" << fParamErr[2] << "\n"; - cout << "v3 = " << fParamVal[3] << "+/-" << fParamErr[3] << "\n"; - - delete minimizer; -} diff --git a/FirstAnalysis/Correlations/extract2D.C b/FirstAnalysis/Correlations/extract2D.C deleted file mode 100644 index 98a9307d..00000000 --- a/FirstAnalysis/Correlations/extract2D.C +++ /dev/null @@ -1,402 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -/////////////////////////////////////////////////////////////////////////// -// Macro to produce 2D histograms of correlations vs. delta phi and delta eta -// -// This macro allows you to process the content of the CorrelationContainer -// for both same-event and mixed-event correlations and obtain the 2D correlation plot. -// 1/N_trig * dN/ddeltaphi*ddeltaeta = dN_same/ddeltaphi*ddeltaeta / dN_mixed/ddeltaphi*ddeltaeta -// Both numerator (same-event) and denominator (mixed-event) are properly normalised. -// -// Input: file with histograms produced by o2-analysis-hf-task-flow -// -// Usage: root -l extract2D.C -// -// Parameters: -// - fileName: input file -// - folder: name of the folder created by the o2-analysis-hf-task-flow, -// contains the results stored in CorrelationContainer -// - outputFile: output file containing final 2D correlation histograms in delta phi, delta eta -// - outputPlots: folder to store produced plots -// - plotExamplePlots: flag to draw correlation plots in "surf" mode in selected (wide) ranges of multiplicity and pT -// - saveSameEventDis: flag to also save 2D histograms of same-event correlations -// - hfcase: flag to perform these calculations for HF-h correlations -// -// Contributors: -// Katarina Krizkova Gajdosova -// Gian Michele Innocenti -// Jan Fiete Grosse-Oetringhaus -/////////////////////////////////////////////////////////////////////////// - -Float_t gpTMin = 0.21; -Float_t gpTMax = 2.99; -Float_t gEtaMin = -0.8; -Float_t gEtaMax = 0.8; -Float_t gZVtxMin = -10; -Float_t gZVtxMax = 10; - -void setupRanges(CorrelationContainer* obj) -{ - obj->setEtaRange(0, 0); - // obj->setEtaRange(gEtaMin, gEtaMax); - obj->setPtRange(gpTMin, gpTMax); - obj->setZVtxRange(gZVtxMin + 0.01, gZVtxMax - 0.01); -} - -/////////////////////////////////////////////////////////////////////////// -// Function to average the 2D correlations over Vz bins normalised for -// the value in (0,0) bin. It is also divided by the number of trigger particles. -// Note: instead of just taking a value in one (0,0) bin, there is an option to -// do an average of values in delta eta = 0 over all delta phi bins -// to account for fluctuations -/////////////////////////////////////////////////////////////////////////// -void getSumOfRatios(CorrelationContainer* h, CorrelationContainer* hMixed, TH1** hist, CorrelationContainer::CFStep step, Float_t centralityBegin, Float_t centralityEnd, Float_t ptBegin, Float_t ptEnd, Bool_t normalizePerTrigger = kTRUE) -{ - Printf("getSumOfRatios | step %d | %.1f-%.1f%% | %.1f - %.1f GeV/c | %.1f - %.1f GeV/c", step, centralityBegin, centralityEnd, gpTMin, gpTMax, ptBegin, ptEnd); - - h->setCentralityRange(0.01 + centralityBegin, -0.01 + centralityEnd); - hMixed->setCentralityRange(0.01 + centralityBegin, -0.01 + centralityEnd); - *hist = h->getSumOfRatios(hMixed, step, ptBegin, ptEnd, normalizePerTrigger); - - TString str; - str.Form("%.1f < p_{T,trig} < %.1f", ptBegin - 0.01, ptEnd + 0.01); - - TString str2; - str2.Form("%.2f < p_{T,assoc} < %.2f", gpTMin - 0.01, gpTMax + 0.01); - - TString newTitle; - newTitle.Form("%s - %s - %.0f-%.0f", str.Data(), str2.Data(), centralityBegin, centralityEnd); - if ((*hist)) - (*hist)->SetTitle(newTitle); -} - -/////////////////////////////////////////////////////////////////////////// -// Function to plot same-event 2D correlations in a particular Vz bin -// It is also divided by the number of trigger particles and dphi bin width. -/////////////////////////////////////////////////////////////////////////// -void getSameEventCorrelation(CorrelationContainer* h, TH2** hist, CorrelationContainer::CFStep step, Float_t centralityBegin, Float_t centralityEnd, Float_t ptBegin, Float_t ptEnd, Bool_t normalizePerTrigger = kTRUE) -{ - Printf("getSameEventCorrelation | step %d | %.1f < Nch < %.1f | %.1f - %.1f GeV/c | %.1f - %.1f GeV/c \n", step, centralityBegin, centralityEnd, ptBegin, ptEnd, gpTMin, gpTMax); - - h->setCentralityRange(0.01 + centralityBegin, -0.01 + centralityEnd); - - *hist = h->getPerTriggerYield(step, ptBegin, ptEnd, normalizePerTrigger); - - TString str; - str.Form("%.1f < p_{T,trig} < %.1f", ptBegin - 0.01, ptEnd + 0.01); - - TString str2; - str2.Form("%.1f < p_{T,assoc} < %.1f", gpTMin - 0.01, gpTMax + 0.01); - - TString newTitle; - newTitle.Form("%s - %s , mult %.0f-%.0f, vz %.0f - %.0f", str.Data(), str2.Data(), centralityBegin, centralityEnd, gZVtxMin, gZVtxMax); - if ((*hist)) - (*hist)->SetTitle(newTitle); -} - -/////////////////////////////////////////////////////////////////////////// -// Function to draw a projection of specific axis of the CorrelationContainer -// It is mostly meant as a quick QA of the filled distributions -/////////////////////////////////////////////////////////////////////////// -TH1* getProjectionOfAxis(CorrelationContainer* h, CorrelationContainer::CFStep step, bool pairhist = false, int naxis = 6) -{ - THnBase* sparse; - if (pairhist) - sparse = h->getPairHist()->getTHn(step); - else - sparse = h->getTriggerHist()->getTHn(step); - - TH1* hprojection = reinterpret_cast(sparse->Projection(naxis)); - return hprojection; -} - -/////////////////////////////////////////////////////////////////////////// -// Main function -/////////////////////////////////////////////////////////////////////////// -void extract2D( - const char* fileName = "AnalysisResults.root", - const char* folder = "hf-task-flow", - const char* outputFile = "dphi_corr.root", - const char* outputPlots = "./plots", - bool plotExamplePlots = false, - bool saveSameEventDis = false, - bool hfcase = false) -{ - gStyle->SetOptStat(1111111); - - CorrelationContainer::CFStep step = CorrelationContainer::kCFStepReconstructed; - Bool_t normalizePerTrigger = kTRUE; // don't do this if histograms are to be merged with other periods later -> Use MergeDPhiFiles below - - auto file = TFile::Open(outputFile, "RECREATE"); - file->Close(); - - // the interval below defines the pttrig, ptass and multiplicity (or - // centrality in which the analysis will be performed. One "ridge" plot - // with the correct normalization will be obtained for each of these - // combinations (with the condition that the selection on the associated pt - // has to be looser than the one on the trigger particle. - - Int_t maxLeadingPtReferenceFlow = 1; - Float_t leadingPtReferenceFlowArr[] = {0.2, 3.0}; // reference flow is done in one wide pT bin - - Int_t maxLeadingPt = 6; - Float_t leadingPtArr[] = {0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0}; - - Int_t maxAssocPt = 1; - Float_t assocPtArr[] = {0.2, 3.0}; - - Int_t maxCentrality = 9; - Float_t centralityArr[] = {0, 10, 20, 30, 40, 50, 60, 80, 100, 200}; - - // h is the container of the same event - // hMixed is the container of the mixed event - auto inputFile = TFile::Open(fileName); - const char* directoryh = ""; - const char* directoryhMixed = ""; - if (hfcase) { - directoryh = Form("%s/sameEventHFHadrons", folder); - directoryhMixed = Form("%s/mixedEventHFHadrons", folder); - } else { - directoryh = Form("%s/sameEventTPCTPCChHadrons", folder); - directoryhMixed = Form("%s/mixedEventTPCTPCChHadrons", folder); - } - auto h = reinterpret_cast(inputFile->Get(Form("%s", directoryh))); - auto hMixed = reinterpret_cast(inputFile->Get(Form("%s", directoryhMixed))); - - // auto proj = getProjectionOfAxis(h, step, false, 0); - // proj->Draw(); - // printf("entires proj: %g \n", proj->GetEntries()); - // return; - - // the number of events for each multiplicity/centrality class is calculated and printed. - auto eventHist = h->getEventCount(); - Printf("Events with centrality: %d", static_cast(eventHist->Integral(eventHist->GetXaxis()->FindBin(6.)), eventHist->GetXaxis()->FindBin(6.), eventHist->GetYaxis()->FindBin(0.), eventHist->GetYaxis()->FindBin(99.9))); - Printf("Events: %d", static_cast(eventHist->ProjectionX()->Integral(eventHist->GetXaxis()->FindBin(6.)), eventHist->GetXaxis()->FindBin(6.))); - // eventHist->ProjectionX()->Draw(); - // return; - - if (plotExamplePlots) { - // low multiplicity illustrative histograms - h->setPtRange(gpTMin, gpTMax); - h->setCentralityRange(10, 20); - h->setZVtxRange(-10, 10); - hMixed->setPtRange(gpTMin, gpTMax); - hMixed->setCentralityRange(10, 20); - hMixed->setZVtxRange(-10, 10); - - TH2* sameTwoD = reinterpret_cast(h->getPerTriggerYield(step, 0.2, 2.99, true)); - auto c1 = new TCanvas; - sameTwoD->Draw("SURF1"); - sameTwoD->SetStats(0); - sameTwoD->SetTitle(""); - sameTwoD->GetXaxis()->SetTitleOffset(1.5); - c1->SaveAs(Form("%s/general/sameCorr.png", outputPlots)); - - // Note: this is not normalised for the bin (0,0), - TH2* mixedTwoD = reinterpret_cast(hMixed->getPerTriggerYield(step, 0.2, 2.99, false)); - auto c2 = new TCanvas; - mixedTwoD->Draw("SURF1"); - mixedTwoD->SetStats(0); - mixedTwoD->SetTitle(""); - mixedTwoD->GetXaxis()->SetTitleOffset(1.5); - c2->SaveAs(Form("%s/general/mixedCorr.png", outputPlots)); - - auto ratio = reinterpret_cast(sameTwoD->Clone("ratio")); - ratio->Divide(mixedTwoD); - - auto c3 = new TCanvas; - ratio->GetYaxis()->SetRangeUser(-1.59, 1.59); - ratio->GetXaxis()->SetTitleOffset(1.5); - ratio->SetStats(0); - ratio->SetTitle(""); - ratio->Draw("SURF1"); - c3->SaveAs(Form("%s/general/pertriggeryield.png", outputPlots)); - - auto c4 = new TCanvas; - ratio->SetMaximum(0.46e-09); - ratio->Draw("SURF1"); - c4->SaveAs(Form("%s/general/pertriggeryield_zoom.png", outputPlots)); - - // high multiplicity illustrative histograms - h->setPtRange(gpTMin, gpTMax); - h->setCentralityRange(40, 100); - h->setZVtxRange(-10, 10); - hMixed->setPtRange(gpTMin, gpTMax); - hMixed->setCentralityRange(40, 100); - hMixed->setZVtxRange(-10, 10); - - TH2* sameTwoDHM = reinterpret_cast(h->getPerTriggerYield(step, 0.2, 2.99, true)); - auto c1HM = new TCanvas; - sameTwoDHM->Draw("SURF1"); - sameTwoDHM->SetStats(0); - sameTwoDHM->SetTitle(""); - sameTwoDHM->GetXaxis()->SetTitleOffset(1.5); - c1HM->SaveAs(Form("%s/general/sameCorr_HM.png", outputPlots)); - - // Note: this is not normalised for the bin (0,0) - TH2* mixedTwoDHM = reinterpret_cast(hMixed->getPerTriggerYield(step, 0.2, 2.99, false)); - auto c2HM = new TCanvas; - mixedTwoDHM->Draw("SURF1"); - mixedTwoDHM->SetStats(0); - mixedTwoDHM->SetTitle(""); - mixedTwoDHM->GetXaxis()->SetTitleOffset(1.5); - c2HM->SaveAs(Form("%s/general/mixedCorr_HM.png", outputPlots)); - - auto ratioHM = reinterpret_cast(sameTwoDHM->Clone("ratioHM")); - ratioHM->Divide(mixedTwoDHM); - - auto c3HM = new TCanvas; - ratioHM->GetYaxis()->SetRangeUser(-1.59, 1.59); - ratioHM->GetXaxis()->SetTitleOffset(1.5); - ratioHM->SetStats(0); - ratioHM->SetTitle(""); - ratioHM->Draw("SURF1"); - c3HM->SaveAs(Form("%s/general/pertriggeryield_HM.png", outputPlots)); - - auto c4HM = new TCanvas; - ratioHM->SetMaximum(0.1e-06); - ratioHM->Draw("SURF1"); - c4HM->SaveAs(Form("%s/general/pertriggeryield_HM_zoom.png", outputPlots)); - } - // TODO: when doing HF correlations, make sure to project/integrate the correct inv. mass range/axis - - // do correlations for reference flow - // Correlation is made for each choice of multiplicity. - // The same event correlations is divided by mixed event after normalization - // for each mult bin (will be integrated over all Vz) - gpTMin = assocPtArr[0] + 0.01; - gpTMax = assocPtArr[1] - 0.01; - gZVtxMin = -10; - gZVtxMax = 10; - - setupRanges(h); - setupRanges(hMixed); - - for (int mult = 0; mult < maxCentrality; mult++) { - TH1* hist1 = 0; - getSumOfRatios(h, hMixed, &hist1, step, centralityArr[mult], centralityArr[mult + 1], leadingPtReferenceFlowArr[0] + 0.01, leadingPtReferenceFlowArr[1] - 0.01, normalizePerTrigger); - - file = TFile::Open(outputFile, "UPDATE"); - - if (hist1) { - hist1->SetName(Form("dphi_ref_%d", mult)); - hist1->Write(); - } - - file->Close(); - - delete hist1; - } - - // Get same-event 2D distributions (may be useful for some checks) - if (saveSameEventDis) { - setupRanges(h); - - for (Int_t mult = 0; mult < maxCentrality; mult++) { - - TH2* histSame2D = 0; - getSameEventCorrelation(h, &histSame2D, step, centralityArr[mult], centralityArr[mult + 1], leadingPtReferenceFlowArr[0] + 0.01, leadingPtReferenceFlowArr[1] - 0.01, normalizePerTrigger); - - file = TFile::Open(outputFile, "UPDATE"); - - if (histSame2D) { - histSame2D->SetName(Form("same_ref_%d", mult)); - histSame2D->Write(); - } - - file->Close(); - - delete histSame2D; - } - } - - // do correlations for pT-differential flow - // Correlation is made for each choice of pttrig, ptassoc and multiplicity. - // The same event correlations is divided by mixed event after normalization - // for each pTtrig, pTassoc and mult bin (will be integrated over all Vz) - for (Int_t i = 0; i < maxLeadingPt; i++) { - for (Int_t j = 0; j < maxAssocPt; j++) { - if (assocPtArr[j] >= leadingPtArr[i + 1]) { - continue; - } - - gpTMin = assocPtArr[j] + 0.01; - gpTMax = assocPtArr[j + 1] - 0.01; - gZVtxMin = -10; - gZVtxMax = 10; - - setupRanges(h); - setupRanges(hMixed); - - for (Int_t mult = 0; mult < maxCentrality; mult++) { - - TH1* hist1 = 0; - getSumOfRatios(h, hMixed, &hist1, step, centralityArr[mult], centralityArr[mult + 1], leadingPtArr[i] + 0.01, leadingPtArr[i + 1] - 0.01, normalizePerTrigger); - - file = TFile::Open(outputFile, "UPDATE"); - - if (hist1) { - hist1->SetName(Form("dphi_%d_%d_%d", i, j, mult)); - hist1->Write(); - } - - file->Close(); - - delete hist1; - } - - // Below, get same-event 2D distributions (may be useful for some checks) - if (!saveSameEventDis) - continue; - - setupRanges(h); - - for (Int_t mult = 0; mult < maxCentrality; mult++) { - - TH2* histSame2D = 0; - getSameEventCorrelation(h, &histSame2D, step, centralityArr[mult], centralityArr[mult + 1], leadingPtArr[i] + 0.01, leadingPtArr[i + 1] - 0.01, normalizePerTrigger); - - file = TFile::Open(outputFile, "UPDATE"); - - if (histSame2D) { - histSame2D->SetName(Form("same_%d_%d_%d", i, j, mult)); - histSame2D->Write(); - } - - file->Close(); - - delete histSame2D; - } - } - - // triggers contain the information about the number of trigger particles - // in each interval of multiplicity (used for the result normalization) - - gZVtxMin = -10; - gZVtxMax = 10; - - setupRanges(h); - - TH1* triggers = h->getTriggersAsFunctionOfMultiplicity(step, leadingPtArr[i] + 0.01, leadingPtArr[i + 1] - 0.01); - triggers->SetName(Form("triggers_%d", i)); - TString str; - str.Form("%.1f < p_{T,trig} < %.1f", leadingPtArr[i], leadingPtArr[i + 1]); - triggers->SetTitle(str); - - file = TFile::Open(outputFile, "UPDATE"); - triggers->Write(); - file->Close(); - } - - delete h; - delete hMixed; -} diff --git a/FirstAnalysis/Correlations/getFlow.C b/FirstAnalysis/Correlations/getFlow.C deleted file mode 100644 index 5671f1f3..00000000 --- a/FirstAnalysis/Correlations/getFlow.C +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -/////////////////////////////////////////////////////////////////////////// -// Macro to calculate final flow coefficients based on v_nDelta results -// obtained from template fits in doTemplate.C macro -// -// v_n = sqrt{V_nDelta} -// -// Input: file with histograms produced by doTemplate.C -// -// Usage: root -l getFlow.C -// -// Parameters: -// - inputFileName: input file -// - outputFileName: output file containing final flow coefficients -// - outputPlotsName: name of the folder to store plots -// - savePlots: flag to save drawn plots -// -// Contributors: -// Katarina Krizkova Gajdosova -// Gian Michele Innocenti -/////////////////////////////////////////////////////////////////////////// - -int nBinspTtrig = 6; -double binspTtrig[] = {0.2, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0}; - -int nBinspTref = 1; -double binspTref[] = {0.2, 3.0}; - -const int nBinsMult = 7; -double binsMult[] = {0, 10, 20, 30, 40, 50, 60, 80, 100, 200}; - -TH1D* hDifferentialV2[nBinsMult]; -TH1D* hDiffFlow_v2[nBinsMult]; - -void drawHist(TH1D* h, Style_t marker, Color_t color, const char* draw); - -/////////////////////////////////////////////////////////////////////////// -// Main function -/////////////////////////////////////////////////////////////////////////// -void getFlow( - const char* inputFileName = "./templateResult.root", - const char* outputFileName = "./flow.root", - const char* outputPlotsName = "./plots", - bool savePlots = true) -{ - - TFile* inFile = TFile::Open(Form("%s", inputFileName), "read"); - - // DO REFERENCE FLOW - TH1D* hReferenceV2 = reinterpret_cast(inFile->Get("hReferenceV2")); - - TH1D* hRefFlow_v2 = new TH1D("hRefFlow_v2", "reference flow; multiplicity; v_{2}", nBinsMult, binsMult); - - for (int iMult = 1; iMult < nBinsMult; iMult++) { - // get content of input histograms (V_nDelta) and make the sqrt(V_nDelta) - double Vdelta2 = hReferenceV2->GetBinContent(iMult + 1); - double Vdelta2err = hReferenceV2->GetBinError(iMult + 1); - - double v2, v2err; - if (Vdelta2 > 0) { - v2 = TMath::Sqrt(Vdelta2); - v2err = (1. / 2) * (1. / TMath::Sqrt(Vdelta2)) * Vdelta2err; - } else { - v2 = 0; - v2err = 0; - } - - printf("iMult = %d: vn = %f +- %f \n", iMult, v2, v2err); - - // set the v_n = sqrt(V_nDelta) values to new (final) histograms - hRefFlow_v2->SetBinContent(iMult + 1, v2); - hRefFlow_v2->SetBinError(iMult + 1, v2err); - - // DO DIFFERENTIAL FLOW - hDifferentialV2[iMult] = reinterpret_cast(inFile->Get(Form("hDifferentialV2_%d", iMult))); - - hDiffFlow_v2[iMult] = new TH1D(Form("hDiffFlow_v2_%d", iMult), Form("differential flow, %.0f < N_{ch} < %.0f; p_{T}; v_{2}", binsMult[iMult], binsMult[iMult + 1]), nBinspTtrig, binspTtrig); - - for (int ipTtrig = 0; ipTtrig < nBinspTtrig; ipTtrig++) { - // get content of input histograms (V_nDelta) and make the sqrt(V_nDelta) - double Vdelta2Diff = hDifferentialV2[iMult]->GetBinContent(ipTtrig + 1); - double Vdelta2Differr = hDifferentialV2[iMult]->GetBinError(ipTtrig + 1); - - double v2diff, v2differr; - if (Vdelta2Diff > 0 && Vdelta2 > 0) { - v2diff = Vdelta2Diff / TMath::Sqrt(Vdelta2); - v2differr = TMath::Sqrt(TMath::Power(1. / TMath::Sqrt(Vdelta2), 2) * TMath::Power(Vdelta2err, 2) + TMath::Power(0.5 * (Vdelta2Diff / TMath::Power(Vdelta2, 3. / 2)), 2) * TMath::Power(Vdelta2Differr, 2)); - } else { - v2diff = 0; - v2differr = 0; - } - - printf("iMult = %d, ipT = %d: vn = %f +- %f \n", iMult, ipTtrig, v2diff, v2differr); - - // set the v_n = sqrt(V_nDelta) values to new (final) histograms - hDiffFlow_v2[iMult]->SetBinContent(ipTtrig, v2diff); - hDiffFlow_v2[iMult]->SetBinError(ipTtrig, v2differr); - } - - // PLOT DIFFERENTIAL FLOW - auto canDiffFlow_v2 = new TCanvas; - drawHist(hDiffFlow_v2[iMult], kFullCircle, kBlue + 1, "ep"); - if (savePlots) - canDiffFlow_v2->SaveAs(Form("%s/flow/v2_mult%d.png", outputPlotsName, iMult)); - } - - // PLOT REFERENCE FLOW - auto canRefFlow_v2 = new TCanvas; - drawHist(hRefFlow_v2, kFullCircle, kBlue + 1, "ep"); - if (savePlots) - canRefFlow_v2->SaveAs(Form("%s/flow/v2.png", outputPlotsName)); -} - -/////////////////////////////////////////////////////////////////////////// -// this is a helper function to adjust histogram settings and draw it -/////////////////////////////////////////////////////////////////////////// -void drawHist(TH1D* h, Style_t marker, Color_t color, const char* draw) -{ - h->SetMarkerStyle(marker); - h->SetMarkerColor(color); - h->SetLineColor(color); - h->GetXaxis()->SetTitleSize(0.05); - h->GetYaxis()->SetTitleSize(0.05); - h->GetYaxis()->SetTitleOffset(1.0); - - h->SetStats(0); - - h->Draw(draw); -} diff --git a/FirstAnalysis/Correlations/plotYield.C b/FirstAnalysis/Correlations/plotYield.C deleted file mode 100644 index 961aca52..00000000 --- a/FirstAnalysis/Correlations/plotYield.C +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -////////////////////////////////////////////////////////////// -// Macro to plot deltaphi projections of two-particle correlations and yields -// -// For different bins in pT (of trigger and associated particles) plot -// 1) the projection on deltaphi axis of the near-side ridge region (excluding the jet peak) -// + the fit with Fourier expansion -// 2) the integrated yield as a function of multiplicity -// -// Input: file with projection histograms produced by yieldExtraction.C macro in this folder -// -// Usage: root -l plotYield.C -// -// Parameters: -// - inFileName: name of the input file -// - savePlots: flag to save the plots -// -// Contributors: -// Katarina Krizkova Gajdosova -// Gian Michele Innocenti -// Jan Fiete Grosse-Oetringhaus -////////////////////////////////////////////////////////////// - -float ptTrig[] = {1.0, 2.0, 3.0, 4.0}; -float ptAssoc[] = {1.0, 2.0, 3.0, 4.0}; -static Double_t Nch[] = {0.0, 2.750, 5.250, 7.750, 12.750, 17.750, 22.750, 27.750, 32.750, 37.750, 42.750, 47.750, 52.750, 57.750, 62.750, 67.750, 72.750, 77.750, 82.750, 87.750, 92.750, 97.750, 250.1}; - -void drawText(double xmin, double ymin, double textSize, TString text); - -////////////////////////////////////////////////////////////// -// main function -////////////////////////////////////////////////////////////// -void plotYield(const char* inFileName = "yield.root", bool savePlots = false) -{ - - gStyle->SetLegendBorderSize(-1); - - TFile* infile = new TFile(inFileName, "read"); - TFile* infileAll = new TFile("yieldAll.root", "read"); - - // plot deltaphi projections in bins of Nch - const uint ntrig = 1; - const uint nassoc = 1; - const uint nmult = 13; - TCanvas* cdphiRidge[ntrig][nassoc]; - TCanvas* cdphiRidge2[ntrig][nassoc]; - TH1D* hdphiRidge[ntrig][nassoc][nmult]; - TF1* fdphiRidge[ntrig][nassoc][nmult]; - TCanvas* cRidge[ntrig][nassoc]; - TGraphErrors* gRidge[ntrig][nassoc]; - - for (uint itrig = 0; itrig < ntrig; itrig++) { - for (uint iassoc = 0; iassoc < nassoc; iassoc++) { - - // since we have a lot mult bins, we define 2 canvases with 4x2 pads - cdphiRidge[itrig][iassoc] = new TCanvas(Form("cdphiRidge_%u_%u", itrig, iassoc), "", 1200, 600); - cdphiRidge[itrig][iassoc]->Divide(4, 2); - cdphiRidge2[itrig][iassoc] = new TCanvas(Form("cdphiRidge2_%u_%u", itrig, iassoc), "", 1200, 600); - cdphiRidge2[itrig][iassoc]->Divide(4, 2); - - for (uint imult = 0; imult < nmult; imult++) { - - // get the deltaphi projection and its fit (the fit was performed in yieldExtraction.C) - hdphiRidge[itrig][iassoc][imult] = reinterpret_cast(infile->Get(Form("proj_dphi_%u_%u_%u", itrig, iassoc, imult))); - fdphiRidge[itrig][iassoc][imult] = reinterpret_cast(infile->Get(Form("fit_%u_%u_%u", itrig, iassoc, imult))); - - // draw a line that shows 0 baseline - double xbinlowedge = hdphiRidge[itrig][iassoc][imult]->GetBinLowEdge(1); - double xbinupperedge = hdphiRidge[itrig][iassoc][imult]->GetBinLowEdge(hdphiRidge[itrig][iassoc][imult]->GetNbinsX() + 1); - TLine* line = new TLine(xbinlowedge, 0, xbinupperedge, 0); - line->SetLineStyle(2); - line->SetLineColor(kGray + 2); - - // first pad of the first canvas will be emtpy, used for legend only - if (imult == 0) { - cdphiRidge[itrig][iassoc]->cd(imult + 1); - drawText(0.2, 0.8, 0.06, Form("%.1f < p_{T,trig} < %.1f", ptTrig[itrig], ptTrig[itrig + 1])); - drawText(0.2, 0.7, 0.06, Form("%.1f < p_{T,assoc} < %.1f", ptAssoc[iassoc], ptAssoc[iassoc + 1])); - - TLegend* leg = new TLegend(0.2, 0.4, 0.6, 0.65); - leg->SetTextSize(0.06); - leg->AddEntry(hdphiRidge[itrig][iassoc][imult], "Data", "lp"); - leg->AddEntry(fdphiRidge[itrig][iassoc][imult], "Fit", "l"); - leg->Draw("same"); - - continue; - } - - // first pad of the second canvas will be empty, used for legend only - if (imult == 8) { - cdphiRidge2[itrig][iassoc]->cd((imult + 1) - 8); - drawText(0.2, 0.8, 0.06, Form("%.1f < p_{T,trig} < %.1f", ptTrig[itrig], ptTrig[itrig + 1])); - drawText(0.2, 0.7, 0.06, Form("%.1f < p_{T,assoc} < %.1f", ptAssoc[iassoc], ptAssoc[iassoc + 1])); - - TLegend* leg = new TLegend(0.2, 0.4, 0.6, 0.65); - leg->SetTextSize(0.06); - leg->AddEntry(hdphiRidge[itrig][iassoc][imult], "Data", "lp"); - leg->AddEntry(fdphiRidge[itrig][iassoc][imult], "Fit", "l"); - leg->Draw("same"); - } - - // draw the projectionsa and fits on different pads of the same canvas - if (imult < 8) { - cdphiRidge[itrig][iassoc]->cd(imult + 1); - hdphiRidge[itrig][iassoc][imult]->SetStats(0); - hdphiRidge[itrig][iassoc][imult]->SetTitle(""); - hdphiRidge[itrig][iassoc][imult]->Draw(); - fdphiRidge[itrig][iassoc][imult]->Draw("same"); - line->Draw("same"); - drawText(0.2, 0.8, 0.06, Form("#LT N #GT = %.1f", (Nch[imult + 1] + Nch[imult]) / 2.0)); - } else { - cdphiRidge2[itrig][iassoc]->cd((imult + 1) - 7); - hdphiRidge[itrig][iassoc][imult]->SetStats(0); - hdphiRidge[itrig][iassoc][imult]->SetTitle(""); - hdphiRidge[itrig][iassoc][imult]->Draw(); - fdphiRidge[itrig][iassoc][imult]->Draw("same"); - line->Draw("same"); - drawText(0.2, 0.8, 0.06, Form("#LT N #GT = %.1f", (Nch[imult + 1] + Nch[imult]) / 2.0)); - } - - } // end of loop over multiplicity - - if (savePlots) { - cdphiRidge[itrig][iassoc]->SaveAs(Form("./plots/dPhiRidge_%u_%u.png", itrig, iassoc)); - cdphiRidge2[itrig][iassoc]->SaveAs(Form("./plots/dPhiRidge2_%u_%u.png", itrig, iassoc)); - } - - // plot the yield vs. multiplicity - gRidge[itrig][iassoc] = reinterpret_cast(infile->Get(Form("ridgeYield_%u_%u", itrig, iassoc))); - - cRidge[itrig][iassoc] = new TCanvas(Form("cRidge_%u_%u", itrig, iassoc), "", 700, 500); - - TH1D* histempty = new TH1D("histempty", "", 100, 0, 100); - histempty->GetXaxis()->SetTitle("#LT N #GT"); - histempty->GetYaxis()->SetTitle("Y_{ridge}"); - histempty->SetMaximum(0.2); - histempty->SetStats(0); - histempty->Draw(); - - gRidge[itrig][iassoc]->SetTitle(""); - gRidge[itrig][iassoc]->SetMarkerStyle(kFullCircle); - gRidge[itrig][iassoc]->SetMarkerColor(kBlue + 1); - gRidge[itrig][iassoc]->SetLineColor(kBlue + 1); - gRidge[itrig][iassoc]->Draw("Psame"); - - if (savePlots) - cRidge[itrig][iassoc]->SaveAs(Form("./plots/ridge_%u_%u.png", itrig, iassoc)); - } - } -} -////////////////////////////////////////////////////////////// -void drawText(double xmin, double ymin, double textSize, TString text) -{ - TLatex* tl = new TLatex(xmin, ymin, Form("%s", text.Data())); - tl->SetNDC(); - tl->SetTextFont(42); - tl->SetTextSize(textSize); - tl->Draw(); -} diff --git a/FirstAnalysis/Correlations/yieldExtraction.C b/FirstAnalysis/Correlations/yieldExtraction.C deleted file mode 100644 index 65316cbc..00000000 --- a/FirstAnalysis/Correlations/yieldExtraction.C +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -////////////////////////////////////////////////////////////// -// Macro to obtain projections of two-particle correlations and yield -// -// For different bins in pT (of trigger and associated particles) do -// 1) a projection on deltaeta axis of the away and near side region separately -// 2) a projection on deltaphi axis of the near-side ridge region (excluding the jet peak) -// 3) fit the deltaphi projection with Fourier expansion -// 4) get ZYAM (=zero yield at minimum) -// 5) subtract ZYAM -// 6) integrate near-side deltaphi projection within ZYAM region to get the yield -// -// Input: file with 2D correlation histograms produced by extract2D.C macro in this folder -// -// Usage: root -l yieldExtraction.C -// -// Parameters: -// - inFileName: name of the input file -// - absDeltaEtaMin: lower edge of deltaeta range when integrating the near-side ridge region -// - absDeltaEtaMax: upper edge of deltaeta range when integrating the near-side ridge region -// - outFileName: name of the output file with histograms/graphs of projections and yields -// -// Contributors: -// Katarina Krizkova Gajdosova -// Gian Michele Innocenti -// Jan Fiete Grosse-Oetringhaus -////////////////////////////////////////////////////////////// - -bool wingCorrection = false; // correct for increase of correlation signal at large deltaeta values - -// Note: if a canvas is drawn with an empty pad, it is probably because -// the TFile took ownership of the histogram and deleted it when -// it went out of scope -// To fix it, call h->SetDirectory(0) before drawing - -void yieldExtraction(const char* inFileName = "dphi_corr.root", double absDeltaEtaMin = 1.4, double absDeltaEtaMax = 1.8, const char* outFileName = "yield.root") -{ - // Nch represents the multiplicity interval of the analysis - // static Double_t Nch[] = {0.0, 2.750, 5.250, 7.750, 12.750, 17.750, 22.750, 27.750, 32.750, 37.750, 42.750, 47.750, 52.750, 57.750, 62.750, 67.750, 72.750, 77.750, 82.750, 87.750, 92.750, 97.750, 250.1}; - static Double_t Nch[] = {0, 10, 20, 30, 40, 50, 60, 80, 100, 200}; - // Nbins is the number of multiplicity bins - static const uint Nbins = 9; - // static const uint Nbins = sizeof(Nch) / sizeof(Nch[0]); - const double absDeltaPhi = 1.3; // y-projection range (it is only needed for jet yield calculation from delta eta projection) - - TFile* infile = new TFile(inFileName, "read"); - TFile* outfile = new TFile(outFileName, "recreate"); - - const uint trigCount = 1; // 4 - - for (uint itrig = 0; itrig < trigCount; ++itrig) { - for (uint iassoc = 0; iassoc <= itrig; ++iassoc) { - - TGraphErrors* gridgeYield = new TGraphErrors(Nbins); - - for (uint imult = 0; imult < Nbins; ++imult) { - - // 2D histogram of two-particle correlation: same/mixed event ratio (normalised as it should be: Ntrig, B(0,0)) - TH2D* hdphidetaRidge = reinterpret_cast(infile->Get(Form("dphi_%u_%u_%u", itrig, iassoc, imult))); - if (!hdphidetaRidge) { - printf("No histograms corresponding mult bin %u. (itrig=%u, iassoc=%u)\n", imult, itrig, iassoc); - continue; - } // if histogram not existing - - // Clone hdphidetaJet: hdphidetaRidge will be used for phi projection; hdphidetaJet for eta projection - TH2D* hdphidetaJet = reinterpret_cast(hdphidetaRidge->Clone("hdphidetaJet")); - - // Normalise hdphidetaRidge used for delta phi projection with the width of the long-range region - double norm = 2.0 * (absDeltaEtaMax - absDeltaEtaMin); - hdphidetaRidge->Scale(1.0 / norm); - - // projection of the away-side ridge on delta eta axis - int ajetaway = hdphidetaJet->GetXaxis()->FindBin(TMath::Pi() - 1.5); - int bjetaway = hdphidetaJet->GetXaxis()->FindBin(TMath::Pi() + 1.5); - TH1D* hdetaJetAway = hdphidetaJet->ProjectionY(Form("proj_deta_%u_%u_%u", itrig, iassoc, imult), ajetaway, bjetaway, "e"); - outfile->cd(); - hdetaJetAway->Write(); - - // projection of the near-side region (peak+ridge) on delta eta axis - int ajetpeak = hdphidetaJet->GetXaxis()->FindBin(-1.5); - int bjetpeak = hdphidetaJet->GetXaxis()->FindBin(+1.5); - TH1D* hdetaJetPeak = hdphidetaJet->ProjectionY(Form("proj_detaJetPeak_%u_%u_%u", itrig, iassoc, imult), ajetpeak, bjetpeak, "e"); - outfile->cd(); - hdetaJetPeak->Write(); - - // wing correction (switched off for now) - if (wingCorrection) { - // project the away side onto delta eta, fit with polynomial, and scale the 2D histogram by the difference - // between the projected histogram and the fit - int a = hdphidetaRidge->GetXaxis()->FindBin(TMath::Pi() - 1.5); - int b = hdphidetaRidge->GetXaxis()->FindBin(TMath::Pi() + 1.5); - TH1D* hdetaAwayProj = hdphidetaRidge->ProjectionY(Form("proj_deta_%u_%u_%u_scaler", itrig, iassoc, imult), a, b, "e"); - hdetaAwayProj->Fit("pol0", "0QSE"); - hdetaAwayProj->Divide(hdetaAwayProj->GetFunction("pol0")); - for (uint i = 1; i < hdphidetaRidge->GetNbinsX(); ++i) - for (uint j = 1; j < hdphidetaRidge->GetNbinsY(); ++j) { - double z = hdetaAwayProj->GetBinContent(j); - if (z <= 0.0) - continue; - hdphidetaRidge->SetBinContent(i, j, hdphidetaRidge->GetBinContent(i, j) / z); - hdphidetaRidge->SetBinError(i, j, hdphidetaRidge->GetBinError(i, j) / z); - } - } - - // projection of near-side ridge on delta phi axis (positive side of the jet peak) - int aridgeP = hdphidetaRidge->GetYaxis()->FindBin(absDeltaEtaMin); - int bridgeP = hdphidetaRidge->GetYaxis()->FindBin(absDeltaEtaMax); - TH1D* hdphiRidgeP = hdphidetaRidge->ProjectionX(Form("proj_dphi_P_%u_%u_%u", itrig, iassoc, imult), aridgeP, bridgeP, "e"); - outfile->cd(); - hdphiRidgeP->Write(); - - // projection of near-side ridge on delta phi axis (negative side of the jet peak) - int aridgeN = hdphidetaRidge->GetYaxis()->FindBin(-absDeltaEtaMax); - int bridgeN = hdphidetaRidge->GetYaxis()->FindBin(-absDeltaEtaMin); - TH1D* hdphiRidgeN = hdphidetaRidge->ProjectionX(Form("proj_dphi_N_%u_%u_%u", itrig, iassoc, imult), aridgeN, bridgeN, "e"); - outfile->cd(); - hdphiRidgeN->Write(); - - // add the projections positive + negative - TH1D* hdphiRidge = reinterpret_cast(hdphiRidgeP->Clone(Form("proj_dphi_%u_%u_%u", itrig, iassoc, imult))); - hdphiRidge->Add(hdphiRidgeP, hdphiRidgeN, 0.5, 0.5); - - // fit the projection to get ZYAM - TF1* fdphiRidge = new TF1(Form("fit_%u_%u_%u", itrig, iassoc, imult), - "[0]+[1]*(1+2*[2]*TMath::Cos(x)+2*[3]*TMath::Cos(2*x)+2*[4]*TMath::Cos(3*x))", - -TMath::Pi() / 2.0, 3.0 / 2.0 * TMath::Pi()); - fdphiRidge->SetParNames("czyam", "c", "v1", "v2", "v3"); - fdphiRidge->FixParameter(0, 0.0); // TODO: this is because otherwise it could bias the C_ZYAM extraction? the result doesn't change much - TFitResultPtr r = hdphiRidge->Fit(fdphiRidge, "0SE", "", -TMath::Pi() / 2.0, 3.0 / 2.0 * TMath::Pi()); - - // get C_ZYAM: value at bin with minimum - double phiMinX = fdphiRidge->GetMinimumX(-TMath::Pi() / 2.0, 3.0 / 2.0 * TMath::Pi()); - double phiMin = fdphiRidge->Eval(phiMinX); - double czyam = phiMin; - - double fitErr; - r->GetConfidenceIntervals(1, 1, 1, &phiMinX, &fitErr, 0.683, false); - - // subtract the C_ZYAM - for (uint idphi = 1; idphi < hdphiRidge->GetXaxis()->GetNbins() + 1; ++idphi) { - double y = hdphiRidge->GetBinContent(idphi); - double yerr = hdphiRidge->GetBinError(idphi); - hdphiRidge->SetBinContent(idphi, TMath::Max(y - czyam, 0.0)); - hdphiRidge->SetBinError(idphi, TMath::Sqrt(yerr * yerr + fitErr * fitErr)); - } - - int phiIntShift = 0; // TODO: check what was the meaning of this - - // write the ZYAM-subtracted histogram and function for later plotting - outfile->cd(); - hdphiRidge->Write(); - - fdphiRidge->SetParameter(0, fdphiRidge->GetParameter(0) - czyam); - outfile->cd(); - fdphiRidge->Write(); - - // near-side yield integration -> Y_ridge^near - int aridge = hdphiRidge->GetXaxis()->FindBin(-TMath::Abs(phiMinX)) + phiIntShift; - int bridge = hdphiRidge->GetXaxis()->FindBin(TMath::Abs(phiMinX)) + phiIntShift; - double YridgeErr; - double Yridge = hdphiRidge->IntegralAndError(aridge, bridge, YridgeErr, "width"); - printf(" = %.1lf, C_ZYAM = %.4f, Yridge = %.4lf pm %.6lf\n", (Nch[imult + 1] + Nch[imult]) / 2.0, czyam, Yridge, YridgeErr); - - gridgeYield->SetPoint(imult, (Nch[imult + 1] + Nch[imult]) / 2.0, Yridge); // saving in the bin center (though later it should be properly corrected) - gridgeYield->SetPointError(imult, 0.0, YridgeErr); - - } // loop over the index of the multiplicity interval - - outfile->cd(); - gridgeYield->Write(Form("ridgeYield_%u_%u", itrig, iassoc)); - - } // loop over the index of the associated particle - } // loop over the index of the trigger particle - - outfile->Close(); - -} // end of processYield diff --git a/FirstAnalysis/FONLLpred/DmesonLcPredictions_13TeV_y05_FFee_BRpythia8_SepContr_PDG2020.root b/FirstAnalysis/FONLLpred/DmesonLcPredictions_13TeV_y05_FFee_BRpythia8_SepContr_PDG2020.root deleted file mode 100644 index b51683bd..00000000 Binary files a/FirstAnalysis/FONLLpred/DmesonLcPredictions_13TeV_y05_FFee_BRpythia8_SepContr_PDG2020.root and /dev/null differ diff --git a/FirstAnalysis/FONLLpred/DmesonLcPredictions_13TeV_y05_FFptDepLHCb_BRpythia8_PDG2020.root b/FirstAnalysis/FONLLpred/DmesonLcPredictions_13TeV_y05_FFptDepLHCb_BRpythia8_PDG2020.root deleted file mode 100644 index bde1db13..00000000 Binary files a/FirstAnalysis/FONLLpred/DmesonLcPredictions_13TeV_y05_FFptDepLHCb_BRpythia8_PDG2020.root and /dev/null differ diff --git a/FirstAnalysis/FONLLpred/DmesonLcPredictions_502TeV_y05_FFee_BRpythia8_SepContr_PDG2020.root b/FirstAnalysis/FONLLpred/DmesonLcPredictions_502TeV_y05_FFee_BRpythia8_SepContr_PDG2020.root deleted file mode 100644 index 4d6329a9..00000000 Binary files a/FirstAnalysis/FONLLpred/DmesonLcPredictions_502TeV_y05_FFee_BRpythia8_SepContr_PDG2020.root and /dev/null differ diff --git a/FirstAnalysis/FONLLpred/DmesonLcPredictions_502TeV_y05_FFptDepLHCb_BRpythia8_PDG2020.root b/FirstAnalysis/FONLLpred/DmesonLcPredictions_502TeV_y05_FFptDepLHCb_BRpythia8_PDG2020.root deleted file mode 100644 index 1d56cb68..00000000 Binary files a/FirstAnalysis/FONLLpred/DmesonLcPredictions_502TeV_y05_FFptDepLHCb_BRpythia8_PDG2020.root and /dev/null differ diff --git a/FirstAnalysis/HFmcvalidation.py b/FirstAnalysis/HFmcvalidation.py deleted file mode 100644 index 8aa216fb..00000000 --- a/FirstAnalysis/HFmcvalidation.py +++ /dev/null @@ -1,132 +0,0 @@ -from ROOT import TCanvas, TFile, TGaxis, TLegend, gStyle - - -def printCanvas(canvas, title): - format_list = [".png", ".pdf", ".root"] - for fileFormat in format_list: - canvas.SaveAs(title + fileFormat) - - -def count_HFquarks_perColl(file, var): - cquark = TCanvas("cquark", "%s per collision" % var) - cquark.SetCanvasSize(900, 700) - cquark.Divide(2, 1) - hq = file.Get("hf-task-mc-validation-gen/hCountAverage%s" % var) - hq.GetXaxis().SetRangeUser(0.0, 8.0) - hq.SetTitle("Number of %s quarks per collision" % var) - hq.Draw("") - printCanvas(cquark, "QuarkCountsPerCollision%s" % var) - - -def count_Particle_perColl(file, var): - cparticle = TCanvas("cparticle", "%s per collision" % var) - cparticle.SetCanvasSize(900, 700) - cparticle.Divide(2, 1) - hp = file.Get("hf-task-mc-validation-gen/hCouterPerCollision%s" % var) - hp.Draw("") - printCanvas(cparticle, "%sPerCollision" % var) - - -def momentum_Conservation(file, var): - cmomentum = TCanvas("cmomentum", "Momentum Conservation %s" % var) - cmomentum.SetCanvasSize(900, 700) - cmomentum.Divide(2, 1) - if var == "P": - hp = file.Get("hf-task-mc-validation-gen/h%sdiffMotherDaughterGen" % var) - hp.SetTitle("Momentum Conservtion: magnitude (Gen)") - else: - hp = file.Get("hf-task-mc-validation-gen/h%sDiffMotherDaughterGen" % var) - hp.SetTitle("Momentum Conservation: %s component" % var) - hp.Draw("") - printCanvas(cmomentum, "%sconservation" % var) - - -def momentum_check(file): - cMomCheck = TCanvas("cMomCheck", "Momentum Conservation Check") - cMomCheck.SetCanvasSize(900, 700) - hMomCheck = file.Get("hf-task-mc-validation-gen/hMomentumCheck") - hMomCheck.Draw() - printCanvas(cMomCheck, "MomentumCheck") - - -def p_diff_reco_MC(file): - gStyle.SetOptStat(0) - components_list = ["x", "y", "z"] - color_list = [1, 2, 4] - cpt = TCanvas("c1", "Momentum Difference") - cpt.SetCanvasSize(1500, 1500) - cpt.cd() - mom_list = [] - leg = TLegend(0.1, 0.7, 0.4, 0.9, "") - leg.SetFillColor(0) - for i, comp in enumerate(components_list): - hp = file.Get("hf-task-mc-validation-rec/histP%s" % comp) - hp.Rebin(2) - hp.SetLineColor(color_list[i]) - hp.SetLineWidth(2) - mom_list.append(hp) - if i != 0: - hp.Draw("same") - else: - hp.SetTitle("Momentum difference Rec-Gen") - hp.GetXaxis().SetTitle("p_{i}^{reco}-p_{i}^{gen} (MeV/#it{c})") - hp.GetXaxis().SetRangeUser(-0.3, 0.3) - hp.Draw() - leg.AddEntry(mom_list[i], "P%s component" % comp) - leg.Draw() - printCanvas(cpt, "p_recoMC_diff") - - -def secondary_vertex_reco_MC(file): - gStyle.SetOptStat(0) - TGaxis.SetMaxDigits(3) - components_list = ["x", "y", "z"] - color_list = [1, 2, 4] - csecvertex = TCanvas("c1", "Secondary Vertex Difference") - csecvertex.SetCanvasSize(1000, 700) - csecvertex.cd() - secvertex_list = [] - leg = TLegend(0.1, 0.7, 0.4, 0.9, "Sec. Vertex:") - leg.SetFillColor(0) - for i, comp in enumerate(components_list): - hsecvertex = file.Get("hf-task-mc-validation-rec/histSecV%s" % comp) - hsecvertex.Rebin(1) - hsecvertex.SetLineColor(color_list[i]) - hsecvertex.SetLineWidth(2) - secvertex_list.append(hsecvertex) - if i != 0: - hsecvertex.Draw("same") - else: - hsecvertex.SetTitle("Secondary Vertex difference Rec-Gen") - hsecvertex.GetXaxis().SetTitle("V_{i}^{reco}-V_{i}^{gen} (cm)") - hsecvertex.Draw() - leg.AddEntry(secvertex_list[i], "%s component" % comp) - leg.Draw() - printCanvas(csecvertex, "SecVertex_recoMC_diff") - - -def decayLength_reco_MC(file): - cDecLenRes = TCanvas("cDecLenRes", "Decay Length") - cDecLenRes.SetCanvasSize(900, 700) - hDecLenRes = file.Get("hf-task-mc-validation-rec/histDecLen") - hDecLenRes.Rebin(2) - hDecLenRes.Draw() - printCanvas(cDecLenRes, "Resolution_DecayLength") - - -fileo2 = TFile("../codeHF/CCbar_pp_AnalysisResults_O2_500files.root") -# Generated Level Validation -quark_list = ["C", "Cbar", "B", "Bbar"] -for quark in quark_list: - count_HFquarks_perColl(fileo2, quark) -particle_list = ["Dzero", "Dplus", "Dstar", "LambdaC"] -for particle in particle_list: - count_Particle_perColl(fileo2, particle) -momentum_check(fileo2) -mom_list = ["P", "Px", "Py", "Pz", "Pt"] -for comp in mom_list: - momentum_Conservation(fileo2, comp) -# Reconstructed Level Validation -p_diff_reco_MC(fileo2) -secondary_vertex_reco_MC(fileo2) -decayLength_reco_MC(fileo2) diff --git a/FirstAnalysis/README.md b/FirstAnalysis/README.md deleted file mode 100644 index 65d3f00f..00000000 --- a/FirstAnalysis/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# O2 first analysis utilities - -## Introduction -The main purpose of this folder is to provide analysis tools to perform analysis of O2 analysis task outputs. -It includes for the moment a set of QA plotting macros to inspect `AnalysisResults.root` of MC and data samples. -It also includes some preliminary functionalities for performing efficiency corrections of HF analyses. -It is currently being used also for performing Run5 analysis. - -## Instructions for contributors - -* Write documentation comments to make the code easy to understand. -* Every file should contain the following details at the top: - * what the code does, - * which input it needs (e.g. output of which O2 workflow), - * how to run it (in case simply executing the script is not enough), - * names of authors, contributors, maintainers (to contact in case of problems or questions). -* Follow [PEP 8 naming conventions](https://www.python.org/dev/peps/pep-0008/#naming-conventions) in Python code. -* Do not use hard-coded paths! A default path should point to a file directly produced by the framework (e.g. `../codeHF/AnalysisResults_O2.root`). -* Handle errors and report them clearly. - -## Available samples ALICE3 -* D2H KrKr production (X events): - * AOD O2 tables: `/data/Run5data/EMBEDDING_KrKr_CCBARLc_scenario3/TEST` - * Analysis result: `/data/Run5data_samples/EMBEDDING_KrKr_CCBARLc_scenario3_20210224/AnalysisResults_O2.root` - -## Plotting -The analyses validation is supposed to use the [HFPlot tool](https://github.com/benedikt-voelkel/HFPlot) for plotting purposes in the future. -It is basically a *pythonic* wrapper around `ROOT` with some automated features. -As a first use case it is implemented in [distrib_studies.py](distrib_studies.py). -A more extensive README can be found [here](https://github.com/benedikt-voelkel/HFPlot) and there are also some examples provided. diff --git a/FirstAnalysis/alice3.png b/FirstAnalysis/alice3.png deleted file mode 100644 index a040eac2..00000000 Binary files a/FirstAnalysis/alice3.png and /dev/null differ diff --git a/FirstAnalysis/config/config_ptspectrum_Dplus_pp5TeV.yml b/FirstAnalysis/config/config_ptspectrum_Dplus_pp5TeV.yml deleted file mode 100644 index 1d0bf6df..00000000 --- a/FirstAnalysis/config/config_ptspectrum_Dplus_pp5TeV.yml +++ /dev/null @@ -1,25 +0,0 @@ -# example config for cross section calculation of D+ mesons - -observable: dsigmadpt # options: dsigmadpt, dNdpt -channel: DplustoKpipi # options: D0toKpi, DplustoKpipi, DstoKKpi, DstartoD0pi, LctopKpi, LctopK0S -system: pp # options: pp, pPb, PbPb -energy: 5TeV # options: 5TeV, 13TeV -period: Run2 # options: Run2 - -fraction: Nb # options: Nb, fc - -FONLL: FONLLpred/DmesonLcPredictions_502TeV_y05_FFee_BRpythia8_SepContr_PDG2020.root - -rawyield: - filename: test/RawYields_Dplus_pp5TeV_prompt_central.root - rawyieldhist: hRawYields - normhist: hEvForNorm - -acceff: - filename: test/Eff_times_Acc_Dplus_pp5TeV_central_newAcc.root - prompthist: hAccEffPrompt - nonprompthist: hAccEffFD - -output: - directory: '.' - filename: CrossSectionDplus_pp_5TeV # without extension diff --git a/FirstAnalysis/config/config_selopt.yml b/FirstAnalysis/config/config_selopt.yml deleted file mode 100644 index 6215f301..00000000 --- a/FirstAnalysis/config/config_selopt.yml +++ /dev/null @@ -1,24 +0,0 @@ -# example config for optimisation of preselections - -# input files -inputs: - background: ../../optimisation/run5/AnalysisResults_pp_GP_eta4_2T.root - prompt: ../../optimisation/run5/AnalysisResults_pp_HF_eta4_2T.root - nonprompt: null - -# list of enabled origins to be plot -origins: [Prompt, Bkg] - -# list of 2-prong candidates enabled -# options: D0ToPiK, JpsiToEE -cands2Prong: [D0ToPiK, JpsiToEE] -# list of variables to test for 2-prong candidates -# options: Cosp, DecLen, ImpParProd, MinDCAxy, MinTrackPt -vars2Prong: [Cosp, DecLen, ImpParProd, MinDCAxy, MinTrackPt] - -# list of 3-prong candidates enabled -# options: DPlusToPiKPi, DsToKKPi, LcToPKPi, XicToPKPi -cands3Prong: [DPlusToPiKPi, DsToKKPi, LcToPKPi, XicToPKPi] -# list of variables to test for 3-prong candidates -# options: Cosp, DecLen, MinDCAxy, MinTrackPt -vars3Prong: [Cosp, DecLen, MinDCAxy, MinTrackPt] diff --git a/FirstAnalysis/config/norm_database.yml b/FirstAnalysis/config/norm_database.yml deleted file mode 100644 index ce9f5cba..00000000 --- a/FirstAnalysis/config/norm_database.yml +++ /dev/null @@ -1,70 +0,0 @@ -# database with normalisation constants for cross section and RAA calculation - -BR: # PDG 2020 - D0toKpi: - value: 0.03950 - unc: 0.00011 - DplustoKpipi: - value: 0.0938 - unc: 0.0016 - DstoKKpi: - value: 0.0224 - unc: 0.0008 - LctopKpi: - value: 0.0628 - unc: 0.0032 - LctopK0S: - value: 0.0159 - unc: 0.0008 - -sigma: # MB cross section in pb - Run2: - pp: - 5TeV: 50.87e+9 - 13TeV: 57.8e+9 - -taa: - Run2: - PbPb: - 5TeV: - V0: - Cent010: - value: 23.07 - unc: 0.44 - Cent3050: - value: 3.897 - unc: 0.11 - Cent6080: - value: 0.4173 - unc: 0.014 - pPb: - 5TeV: - V0A: - Cent020: - value: 0.183 - unc: 0.006245 - Cent2040: - value: 0.134 - unc: 0.004899 - Cent4060: - value: 0.092 - unc: 0.004796 - Cent60100: - value: 0.041 - unc: 0.008832 - ZNA: - Cent010: - value: 0.172 - unc: 0.012 - Cent1020: - value: 0.158 - unc: 0.006 - Cent2040: - value: 0.137 - unc: 0.003 - Cent4060: - value: 0.102 - unc: 0.005 - Cent60100: - value: 0.0459 - unc: 0.0024 diff --git a/FirstAnalysis/contamination.py b/FirstAnalysis/contamination.py deleted file mode 100644 index 11e961e9..00000000 --- a/FirstAnalysis/contamination.py +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/env python - -from ROOT import TCanvas, TFile, gROOT, gStyle - -path_file = "../codeHF/AnalysisResults_O2.root" - -gStyle.SetOptStat(0) -gStyle.SetErrorX(0) -gStyle.SetFrameLineWidth(1) -gStyle.SetTitleSize(0.045, "x") -gStyle.SetTitleSize(0.045, "y") -gStyle.SetMarkerSize(1) -gStyle.SetLabelOffset(0.015, "x") -gStyle.SetLabelOffset(0.02, "y") -gStyle.SetTickLength(-0.02, "x") -gStyle.SetTickLength(-0.02, "y") -gStyle.SetTitleOffset(1.1, "x") -gStyle.SetTitleOffset(1.0, "y") - -gROOT.SetBatch(True) - - -def saveCanvas(canvas, title): - format_list = [".pdf", ".png"] - for fileFormat in format_list: - canvas.SaveAs(title + fileFormat) - - -def kinematic_plots(var, particle, detector, hp): - fileo2 = TFile(path_file) - cres = TCanvas("cres", "resolution distribution") - cres.SetCanvasSize(1600, 1000) - cres.cd() - num = fileo2.Get( - "qa-tracking-rejection-%s/tracking%ssel%s/%seta" % (particle, detector, hp, var) - ) - den = fileo2.Get("qa-tracking-rejection-%s/tracking/%seta" % (particle, var)) - # gPad.SetLogz() - num.Divide(den) - num.Draw("coltz") - num.GetYaxis().SetTitle("#eta") - num.GetYaxis().SetTitleOffset(1.0) - num.GetZaxis().SetRangeUser(0.01, 1) - num.SetTitle("Fraction of %s selected by %s as %s" % (particle, detector, hp)) - saveCanvas( - cres, "contamination/%seta_%sSelfrom%sas%s" % (var, particle, detector, hp) - ) - - -def ratioparticle( - var="pt", - numname="Electron", - selnum="RICHSelHpElLoose", - denname="Pion", - selden="RICHSelHpElLoose", - label="e/#pi", -): - fileo2 = TFile(path_file) - cres = TCanvas("cres", "resolution distribution") - cres.SetCanvasSize(1600, 1000) - cres.cd() - cres.SetLogy() - - num2d = fileo2.Get("task-qa-pid-rejection-general/h%s%s/%seta" % (numname, selnum, var)) - den2d = fileo2.Get("task-qa-pid-rejection-general/h%s%s/%seta" % (denname, selden, var)) - num = num2d.ProjectionX("num", 1, num2d.GetXaxis().GetNbins()) - den = den2d.ProjectionX("den", 1, den2d.GetXaxis().GetNbins()) - num.Divide(den) - num.Draw("coltz") - num.GetYaxis().SetTitle(label) - num.GetXaxis().SetTitle("p_{T}") - # num.SetMinimum(0.001) - # num.SetMaximum(2.0) - num.GetYaxis().SetTitleOffset(1.0) - # num.GetZaxis().SetRangeUser(0.01, 1) - # nameresult = "Fraction of %s selected by %s over %s selected by %s" % (num,selnum,den,selden) - canvas = "Fractionof%s%sOver%s%s" % (numname, selnum, denname, selden) - # num.SetTitle(nameresult) - saveCanvas(cres, "rejection/%s" % (canvas)) - - -def is_e_not_pi_plots(particle): - fileo2 = TFile(path_file) - task = "task-qa-pid-rejection-general" - folder_gm = "h%sRICHSelHpElTight" % particle - folder_alt = "h%sRICHSelHpElTightAlt" % particle - folder_diff = "h%sRICHSelHpElTightAltDiff" % particle - hist = "pteta" - hist_gm = fileo2.Get("%s/%s/%s" % (task, folder_gm, hist)) - hist_gm.SetTitle("%s isRICHElTight" % particle) - hist_alt = fileo2.Get("%s/%s/%s" % (task, folder_alt, hist)) - hist_alt.SetTitle("%s isElectronAndNotPion" % particle) - hist_diff = fileo2.Get("%s/%s/%s" % (task, folder_diff, hist)) - hist_diff.SetTitle("%s isRICHElTight != isElectronAndNotPion" % particle) - cepi = TCanvas("cepi", "e not pi selection") - cepi.SetCanvasSize(1600, 1000) - cepi.Divide(2, 2) - cepi.cd(1) - hist_gm.Draw("colz") - cepi.cd(2) - hist_alt.Draw("colz") - cepi.cd(3) - hist_diff.Draw("colz") - # num.GetYaxis().SetTitleOffset(1.0) - # num.GetZaxis().SetRangeUser(0.01, 1) - saveCanvas(cepi, "contamination/is_e_not_pi_%s" % particle) - - -# kinematic_plots("p", "pion", "MID", "Muon") -# kinematic_plots("p", "mu", "MID", "Muon") -# kinematic_plots("p", "pion", "TOF", "Electron") -# kinematic_plots("p", "pion", "RICH", "Electron") -# kinematic_plots("pt", "pion", "RICH", "Electron") -# kinematic_plots("p", "kaon", "RICH", "Electron") -# kinematic_plots("pt", "kaon", "RICH", "Electron") -# kinematic_plots("p", "pion", "TOF", "Kaon") -# kinematic_plots("p", "pion", "RICH", "Kaon") - -ratioparticle( - "pt", "Electron", "RICHSelHpElTight", "Electron", "NoSel", "e/e RICHSelHpElTight" -) -ratioparticle("pt", "Electron", "NoSel", "Pion", "NoSel", "e/#pi No cuts") -ratioparticle( - "pt", "Electron", "RICHSelHpElTight", "Pion", "RICHSelHpElTight", "Tight e/#pi " -) -ratioparticle("pt", "Muon", "MID", "Pion", "MID", "MIDSel") -ratioparticle("pt", "Pion", "RICHSelHpElTight", "Pion", "NoSel", "Contamination") -ratioparticle("pt", "Pion", "MID", "Pion", "NoSel", "Contamination MID") - -ratioparticle( - "pt", - "Electron", - "RICHSelHpElTightAlt", - "Electron", - "RICHSelHpElTight", - "e isElectronAndNotPion/RICHSelHpElTight", -) -ratioparticle( - "pt", - "Electron", - "RICHSelHpElTightAlt", - "Pion", - "RICHSelHpElTightAlt", - "isElectronAndNotPion e/#pi", -) - - -for p in ("Electron", "Pion", "Kaon", "Muon"): - is_e_not_pi_plots(p) diff --git a/FirstAnalysis/database.yaml b/FirstAnalysis/database.yaml deleted file mode 100644 index 0cf290d3..00000000 --- a/FirstAnalysis/database.yaml +++ /dev/null @@ -1,62 +0,0 @@ -Xi_cc: - pp14p0: - absy1p44: - latexcand: "#Xi_{cc}" - inputBkg: /data/Run5/results/20200602_9am_loosecuts/AnalysisResults_O2_MB.root - inputSig: /data/Run5/results/20200602_9am_loosecuts/AnalysisResults_O2_enriched.root - dirname: hf-task-xicc-mc - normalized: 1 - varlist: ["mass", "d0Prong0", "d0Prong1", "CPA", "Y", "DecLength", "Ct", "Eta", "chi2PCA"] - varlatex: ["inv. mass (GeV)", "d_{0} prong 0 (cm)", "d_{0} prong 1 (cm)", "cos(#theta_{p})", "rapidity", "dec. length (cm)", "c#tau (cm)", "#eta", "chi^{2} decay"] - histonamesig: ["hMassSig", "hd0Prong0Sig", "hd0Prong1Sig", "hCPASig", "hYSig", "hDecLengthSig", "hCtSig", "hEtaSig", "hChi2PCASig"] - histonamebkg: ["hMassBg", "hd0Prong0Bg", "hd0Prong1Bg", "hCPABg", "hYBg", "hDecLengthBg", "hCtBg", "hEtaBg", "hChi2PCABg"] - ymin: [0.0001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001] - ymax: [0.4, 5., 5., 5., 5., 5., 10., 5., 5.] - xmin: [3.2, -0.01, -0.01, 0.5, -3., 0.00001, 0., -3., 0.] - xmax: [4., 0.04, 0.04, 1.1, 3., 3., 0.1, 3., 0.1] - rebin: [5, 2, 5, 2, 5, 5, 5, 5, 5] - dolog: [0, 1, 1, 1, 1, 1, 1, 1, 1] - dologx: [0, 1, 0, 0, 0, 1, 0, 0, 1] - legtoleft: [1, 1, 1, 1, 1, 1, 1, 1, 1] - -X3872: - pp14p0: - absy1p44: - latexcand: "X(3872)" - inputBkg: /data/Run5/results/Xanalysis_0p7pt_RICHTOF/AnalysisResults_O2_MB.root - inputSig: /data/Run5/results/Xanalysis_0p7pt_RICHTOF/AnalysisResults_O2_enriched.root - dirname: hf-task-x-mc - normalized: 1 - varlist: ["mass", "d0Prong0", "d0Prong1", "CPA", "Y", "DecLength", "Ct", "Eta", "chi2PCA"] - varlatex: ["inv. mass (GeV)", "d_{0} prong 0 (cm)", "d_{0} prong 1 (cm)", "cos(#theta_{p})", "rapidity", "dec. length (cm)", "c#tau (cm)", "#eta", "chi^{2} decay"] - histonamesig: ["hMassRecSig", "hd0Prong0RecSig", "hd0Prong1RecSig", "hCPARecSig", "hYSig", "hDeclengthRecSig", "hCtSig", "hEtaRecSig", "hChi2PCASig"] - histonamebkg: ["hMassRecBg", "hd0Prong0RecBg", "hd0Prong1RecBg", "hCPARecBg", "hYBg", "hDeclengthRecBg", "hCtBg", "hEtaRecBg", "hChi2PCABg"] - ymin: [0.0001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001] - ymax: [0.4, 5., 5., 5., 5., 5., 10., 5., 5.] - xmin: [3.2, -0.01, -0.01, 0.5, -3., 0.00001, 0., -3., 1.e-6] - xmax: [4., 0.04, 0.04, 1.1, 3., 3., 0.1, 3., 0.1] - rebin: [5, 2, 5, 5, 5, 5, 5, 5, 5] - dolog: [0, 1, 1, 1, 1, 1, 1, 1, 1] - dologx: [0, 1, 0, 0, 0, 1, 0, 0, 1] - legtoleft: [1, 1, 1, 1, 1, 1, 1, 1, 1] - -Jpsi: - pp14p0: - absy1p44: - latexcand: "Jpsi" - inputBkg: /data/Run5/results/Xanalysis_0p7pt_RICHTOF/AnalysisResults_O2_MB.root - inputSig: /data/Run5/results/Xanalysis_0p7pt_RICHTOF/AnalysisResults_O2_enriched.root - dirname: hf-task-jpsi-mc - normalized: 1 - varlist: ["mass", "d0Prong0", "d0Prong1", "Y", "DecLength", "Ct", "d0xd0", "chi2PCA"] - varlatex: ["inv. mass (GeV)", "d_{0} prong 0 (cm)", "d_{0} prong 1 (cm)", "rapidity", "dec. length (cm)", "c#tau (cm)", "d_{0} x d_{1}", "chi^{2} decay"] - histonamesig: ["hMassSig", "hd0Prong0Sig", "hd0Prong1Sig", "hYSig", "hDecLengthSig", "hCtSig", "hd0d0Sig", "hChi2PCASig"] - histonamebkg: ["hMassBg", "hd0Prong0Bg", "hd0Prong1Bg", "hYBg", "hDecLengthBg", "hCtBg", "hd0d0Bg", "hChi2PCABg"] - ymin: [0.0001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001] - ymax: [0.4, 5., 5., 5., 5., 10., 5., 5.] - xmin: [3.2, -0.01, -0.01, -3., 0.00001, 0., -0.02, 1.e-6] - xmax: [4., 0.04, 0.04, 3., 3., 0.1, 0.02, 0.1] - rebin: [5, 5, 5, 5, 1, 5, 5, 1] - dolog: [0, 1, 1, 1, 1, 1, 1, 1] - dologx: [0, 1, 0, 0, 1, 0, 0, 1] - legtoleft: [1, 1, 1, 1, 1, 1, 1, 1] diff --git a/FirstAnalysis/distrib_studies.py b/FirstAnalysis/distrib_studies.py deleted file mode 100644 index 294ec1b5..00000000 --- a/FirstAnalysis/distrib_studies.py +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env python -import os -from math import ceil, sqrt - -import yaml -from hfplot.plot_spec_root import ROOTFigure -from hfplot.style import StyleObject1D -from ROOT import TFile - - -def makeSavePaths(title, *fileFormats, outputdir="outputPlots"): - """ - Saves the canvas as the desired output format in an output directory (default = outputPlots) - """ - if not os.path.exists(outputdir): - os.makedirs(outputdir) - return [outputdir + "/" + title + fileFormat for fileFormat in fileFormats] - - -def distr_studies(hadron="Xi_cc", collision="pp14p0", yrange="absy1p44"): - """ - Make distribution comparisons - """ - with open(r"database.yaml") as database: - param = yaml.safe_load(database) - latexcand = param[hadron][collision][yrange]["latexcand"] - inputBkg = param[hadron][collision][yrange]["inputBkg"] - inputSig = param[hadron][collision][yrange]["inputSig"] - dirname = param[hadron][collision][yrange]["dirname"] - normalized = param[hadron][collision][yrange]["normalized"] - lvarlist = param[hadron][collision][yrange]["varlist"] - lvarlatex = param[hadron][collision][yrange]["varlatex"] - lhistonamesig = param[hadron][collision][yrange]["histonamesig"] - lhistonamebkg = param[hadron][collision][yrange]["histonamebkg"] - lrebin = param[hadron][collision][yrange]["rebin"] - ldolog = param[hadron][collision][yrange]["dolog"] - ldologx = param[hadron][collision][yrange]["dologx"] - - formats = [".pdf", ".root", ".C"] # fileformats - fileBkg = TFile(inputBkg) - fileSig = TFile(inputSig) - - lhistosig = [] - lhistobkg = [] - nPtBins = 0 - lptMin = [] - lptMax = [] - - # Define some styles - style_sig = StyleObject1D() - style_sig.markercolor = 2 - style_sig.markerstyle = 21 - style_sig.markersize = 2 - style_sig.draw_options = "P" - style_bkg = StyleObject1D() - style_bkg.markerstyle = 23 - style_bkg.markersize = 2 - style_bkg.draw_options = "P" - - for index, var in enumerate(lvarlist): - - lhistosigvar = [] - lhistobkgvar = [] - hsig = fileSig.Get(f"{dirname}/{lhistonamesig[index]}") - hbkg = fileBkg.Get(f"{dirname}/{lhistonamebkg[index]}") - - nPtBins = hsig.GetNbinsY() - print(var) - for iptBin in range(nPtBins): - # Collect the histogram projections in bins of pT for each variable - hsig_px = hsig.ProjectionX( - f"hsig_px_var{var}_pt{iptBin}", iptBin + 1, iptBin + 1 - ) - hbkg_px = hbkg.ProjectionX( - f"hbkg_px_var{var}_pt{iptBin}", iptBin + 1, iptBin + 1 - ) - lhistosigvar.append(hsig_px) - lhistobkgvar.append(hbkg_px) - if index == 0: - ptMin = hsig.GetYaxis().GetBinLowEdge(iptBin + 1) - ptMax = ptMin + hsig.GetYaxis().GetBinWidth(iptBin + 1) - lptMin.append(ptMin) - lptMax.append(ptMax) - - lhistosig.append(lhistosigvar) - lhistobkg.append(lhistobkgvar) - - for index, var in enumerate(lvarlist): - # sort out required number of columns and rows for a squared grid and create a figure - n_cols_rows = ceil(sqrt(nPtBins)) - column_margin = [(0.05, 0.01)] * n_cols_rows - row_margin = [(0.05, 0.01)] * n_cols_rows - figure = ROOTFigure( - n_cols_rows, - n_cols_rows, - row_margin=row_margin, - column_margin=column_margin, - size=(1500, 900), - ) - # can adjust some axis properties globally - figure.axes(label_size=0.02, title_size=0.02) - # here we use the feature to only apply to certain axes - figure.axes("x", title=lvarlatex[index], title_offset=1) - figure.axes("y", title="Entries", title_offset=1.08) - # legend positioning, default would be "top right", so just put left (top will be added by default) - figure.legend(position=(0.05, 0.6, 0.7, 0.8)) - - rebin = lrebin[index] - - for iptBin in range(nPtBins): - hist_sig = lhistosig[index][iptBin] - hist_bkg = lhistobkg[index][iptBin] - - if rebin > 1: - hist_sig.RebinX(rebin) - hist_bkg.RebinX(rebin) - - nSigEntries = hist_sig.Integral() - nBkgEntries = hist_bkg.Integral() - - if not nSigEntries or not nBkgEntries: - print( - f"ERROR: Found empty signal or background distribution for variable={var} in pT bin={iptBin}" - ) - continue - - if normalized: - for ibin in range(hist_sig.GetNbinsX()): - bincontent = hist_sig.GetBinContent(ibin + 1) - hist_sig.SetBinContent(ibin + 1, bincontent / nSigEntries) - hist_sig.SetBinError(ibin + 1, 0.0) - - for ibin in range(hist_bkg.GetNbinsX()): - bincontent = hist_bkg.GetBinContent(ibin + 1) - hist_bkg.SetBinContent(ibin + 1, bincontent / nBkgEntries) - hist_bkg.SetBinError(ibin + 1, 0.0) - - figure.define_plot(x_log=ldologx[index], y_log=ldolog[index]) - figure.add_object( - hist_sig, - style=style_sig, - label=f"Sig before norm ({int(nSigEntries)} entries)", - ) - figure.add_object( - hist_bkg, - style=style_bkg, - label=f"Bkg before norm ({int(nBkgEntries)} entries)", - ) - figure.add_text( - f"{lptMin[iptBin]:.1f} GeV < p_{{T}} ({latexcand}) < {lptMax[iptBin]:.1f} GeV", - 0.0, - 0.8, - ) - - figure.create() - for save_paths in makeSavePaths( - f"distribution_{var}", *formats, outputdir=f"output_{hadron}" - ): - figure.save(save_paths) - - -distr_studies() diff --git a/FirstAnalysis/efficiency_studies.py b/FirstAnalysis/efficiency_studies.py deleted file mode 100755 index a69dbba0..00000000 --- a/FirstAnalysis/efficiency_studies.py +++ /dev/null @@ -1,295 +0,0 @@ -#!/usr/bin/env python -""" -file: efficiency_studies.py -brief: Plotting macro for the qa-efficiency task. -usage: ./efficiency_studies.py AnalysisResults_O2.root [--plot_sel | --dump_eff] -author: Maja Kabus , CERN / Warsaw University of Technology -""" - -import argparse - -from ROOT import ( # pylint: disable=import-error,no-name-in-module - TH1F, - TCanvas, - TEfficiency, - TFile, - TLatex, - TLegend, - gPad, - gROOT, - gStyle, - kGreen, - kOrange, -) - - -def save_canvas(canvas, title): - """ - Save canvas in png, pdf, root. - """ - format_list = [".png", ".pdf", ".root"] - for file_format in format_list: - canvas.SaveAs(title + file_format) - - -def get_titles(var, sign, had, det): - """ - Compose titles and names for histograms and canvas. - """ - hname = f"hempty_{sign}_{had}_{det}_{var}" - cname = f"c_{sign}_{had}_{det}_{var}" - ctitle = f"Efficiency for {sign} {had}, {det} primaries" - return hname, cname, ctitle - - -def prepare_canvas(var, titles): - """ - Initialize canvas, axes, legend. - `hempty` must be captured at return, otherwise ROOT crashes. - """ - hname, cname, ctitle = titles - - def get_pt_hist(): - hempty = TH1F( - hname, f"{ctitle};Transverse Momentum (GeV/c);Efficiency", 16, 0.00, 16 - ) - # gPad.SetLogx() - return hempty - - def get_eta_hist(): - return TH1F(hname, f"{ctitle};Pseudorapidity;Efficiency", 16, -1.5, 1.5) - - def get_phi_hist(): - return TH1F( - hname, - f"{ctitle};Azimuthal angle (rad);Efficiency", - 16, - -2 * 3.1416 - 0.5, - 2 * 3.1416 + 0.5, - ) - - hists = {"Pt": get_pt_hist, "Eta": get_eta_hist, "Phi": get_phi_hist} - - canv = TCanvas(cname, "Efficiency") - canv.SetCanvasSize(800, 600) - canv.cd() - canv.SetGridy() - canv.SetGridx() - - hempty = hists[var]() - hempty.GetYaxis().CenterTitle() - hempty.GetXaxis().CenterTitle() - hempty.GetXaxis().SetNoExponent() - hempty.GetXaxis().SetMoreLogLabels(1) - hempty.GetYaxis().SetNdivisions(11) - hempty.Draw() - - latexa = TLatex() - latexa.SetTextSize(0.04) - latexa.SetTextFont(42) - latexa.SetTextAlign(3) - latexa.DrawLatexNDC(0.15, 0.3, "-0.9 #geq #eta #geq 0.9") - latexa.DrawLatexNDC(0.15, 0.25, "-2#pi #geq #varphi #geq 2#pi") - - leg = TLegend(0.55, 0.15, 0.89, 0.35, "P") - leg.SetNColumns(2) - leg.SetHeader("Minimum bias pp #sqrt{s} = 5.02TeV", "C") - leg.SetFillColor(0) - - return canv, leg, hempty - - -def get_efficiency_all_charges(infile, det, var, had): - """ - Calculate efficiency for positive and negative particles together. - """ - det_str = det.lower().replace("-", "_") - prm_str = "" if var == "Phi" else "prm/" - num_pos = infile.Get(f"qa-efficiency/MC/{had}/pos/{var.lower()}/{prm_str}{det_str}") - num_neg = infile.Get(f"qa-efficiency/MC/{had}/neg/{var.lower()}/{prm_str}{det_str}") - den_pos = infile.Get(f"qa-efficiency/MC/{had}/pos/{var.lower()}/{prm_str}generated") - den_neg = infile.Get(f"qa-efficiency/MC/{had}/neg/{var.lower()}/{prm_str}generated") - num = num_pos.Clone() - num.Add(num_neg) - den = den_pos.Clone() - den.Add(den_neg) - - axis = num.GetXaxis() - efftitle = f"Efficiency for {had}, {det} primaries;{axis.GetTitle()};Efficiency" - if axis.IsVariableBinSize(): - eff = TEfficiency( - f"{det}_vs{var}_Prm", efftitle, axis.GetNbins(), axis.GetXbins().GetArray() - ) - else: - eff = TEfficiency( - f"{det}_vs{var}_Prm", - efftitle, - axis.GetNbins(), - axis.GetXmin(), - axis.GetXmax(), - ) - - eff.SetTotalHistogram(den, "f") - eff.SetPassedHistogram(num, "f") - return eff - - -def efficiency_tracking( - infile, heff, det, sign, var, err_y -): # pylint: disable=too-many-locals, too-many-arguments - """ - Plot efficiency vs pT, eta and phi for all hadron species. - Pt plots are drawn for primaries. - If sign = "All", efficiency is plot for pos+neg together. - """ - hadron_list = ["All", "Pion", "Kaon", "Proton", "Electron"] - hist_hadron_list = ["all", "pi", "ka", "pr", "el"] - # Other hadrons: "Deuteron", "Triton", "He3", "Alpha" - color_list = [1, 2, 4, kGreen + 2, kOrange - 3] - marker_list = [20, 21, 22, 21, 22] - eff_objs = { - "Pt": f"{det}_vsPt_Prm", - "Eta": f"{det}_vsEta_Prm", - "Phi": f"{det}_vsPhi_Prm", - } - - gStyle.SetOptStat(0) - gStyle.SetFrameLineWidth(2) - gStyle.SetTitleSize(0.045, "x") - gStyle.SetTitleSize(0.045, "y") - gStyle.SetMarkerSize(1) - gStyle.SetLabelOffset(0.015, "x") - gStyle.SetLabelOffset(0.02, "y") - gStyle.SetTitleOffset(1.1, "x") - gStyle.SetTitleOffset(1.0, "y") - - results = prepare_canvas(var, get_titles(var, sign, "all", det)) - c_all = results[0] - leg_all = results[1] - eff_list = [] - - for i, (had, hhad) in enumerate(zip(hadron_list, hist_hadron_list)): - if sign == "All": - eff = get_efficiency_all_charges(infile, det, var, hhad) - else: - eff = heff.FindObject(f"{sign} {had}").FindObject(eff_objs[var]) - c_all.cd() - eff.Paint("p") - graph = eff.GetPaintedGraph().Clone() - c_all.GetListOfPrimitives().Remove(eff) - c_all.Modified() - for j in range(0, graph.GetN()): - graph.GetEXlow()[j] = 0 - graph.GetEXhigh()[j] = 0 - if not err_y: - graph.GetEYlow()[j] = 0 - graph.GetEYhigh()[j] = 0 - - graph.SetLineColor(color_list[i]) - graph.SetMarkerColor(color_list[i]) - graph.SetMarkerStyle(marker_list[i]) - eff_list.append(graph) - graph.Draw(" same p") - leg_all.AddEntry(eff_list[i], had, "p") - - leg_all.Draw() - save_canvas(c_all, f"efficiency_tracking_{det}_{sign}_{var}") - - -def efficiency_hadron(had, var): - """ - Extract efficiency vs pT for single species (D0, Lc, Jpsi). - This is not updated, it cannot be produced from QAEfficiency output. - """ - fileo2 = TFile("../codeHF/AnalysisResults_O2.root") - ceffhf = TCanvas("ceffhf", "A Simple Graph Example") - ceffhf.SetCanvasSize(1500, 700) - ceffhf.Divide(2, 1) - gPad.SetLogy() - # hnum = fileo2.Get("qa-tracking-efficiency-%s/%s/num" % (had, var)) - hnum = fileo2.Get(f"hf-task-{had}-mc/h{var}RecSig") - # hden = fileo2.Get("qa-tracking-efficiency-%s/%s/den" % (had, var)) - hden = fileo2.Get(f"hf-task-{had}-mc/h{var}Gen") - hnum.Rebin(4) - hden.Rebin(4) - eff = TEfficiency(hnum, hden) - eff.Draw() - save_canvas(ceffhf, f"efficiency_hfcand_{had}_{var}") - - -def plot_selections(infile): - """ - Plot track and MC particle selections. - """ - track_sel = infile.Get("qa-efficiency/MC/trackSelection") - part_sel = infile.Get("qa-efficiency/MC/particleSelection") - - canv = TCanvas("Track selection", "Track selection") - canv.SetCanvasSize(800, 600) - canv.cd() - track_sel.Draw() - - canv2 = TCanvas("Particle selection", "Particle selection") - canv2.SetCanvasSize(800, 600) - canv2.cd() - part_sel.Draw() - - save_canvas(canv, "efficiency_tracking_track_selection") - save_canvas(canv2, "efficiency_tracking_particle_selection") - - -def main(): - """ - Main function. - """ - gROOT.SetBatch(True) - - parser = argparse.ArgumentParser(description="Arguments to pass") - parser.add_argument("input_file", help="input AnalysisResults.root file") - parser.add_argument( - "--plot_erry", - default=False, - action="store_true", - help="Plot efficiency with y error bars", - ) - parser.add_argument( - "--plot_sel", - default=False, - action="store_true", - help="Plot track and particle selections", - ) - parser.add_argument( - "--dump_eff", default=False, action="store_true", help="Dump efficiency tree" - ) - args = parser.parse_args() - - var_list = ["Pt", "Eta", "Phi"] - sign_list = ["Positive", "Negative", "All"] - det_list = ["ITS-TPC", "ITS-TPC-TOF"] - - infile = TFile(args.input_file) - heff = infile.Get("qa-efficiency/EfficiencyMC") - - if args.dump_eff: - heff.Print() - for i in range(heff.GetEntries()): - teff = heff.At(i) - teff.Print() - - if args.plot_sel: - plot_selections(infile) - - for var in var_list: - for sign in sign_list: - for det in det_list: - efficiency_tracking(infile, heff, det, sign, var, args.plot_erry) - for sign in sign_list: - efficiency_tracking(infile, heff, "ITS", sign, "Pt", args.plot_erry) - - # hfhadron_list = ["d0", "dplus", "lc", "xic", "jpsi"] - # for had in hfhadron_list: - # efficiency_hadron(had, "Pt") - - -if __name__ == "__main__": - main() diff --git a/FirstAnalysis/hf_analysis_utils.py b/FirstAnalysis/hf_analysis_utils.py deleted file mode 100644 index 862dce80..00000000 --- a/FirstAnalysis/hf_analysis_utils.py +++ /dev/null @@ -1,238 +0,0 @@ -#!/usr/bin/env python3 - -""" -file: hf_analysis_utils.py -brief: script with miscellanea utils methods for the HF analyses -author: Fabrizio Grosa , CERN -""" - -import numpy as np # pylint: disable=import-error - - -def make_list(object) -> list: - """ - Returns the object as a list if it is not a list already. - """ - return object if isinstance(object, list) else list(object) - - -# pylint: disable=too-many-arguments -def compute_crosssection( - rawy, - rawy_unc, - frac, - eff_times_acc, - delta_pt, - delta_y, - sigma_mb, - n_events, - br, - method_frac="Nb", -): - """ - Method to compute cross section and its statistical uncertainty - Only the statistical uncertainty on the raw yield and prompt (non-prompt) - fraction are considered (the others are systematics) - - Parameters - ---------- - - rawy: raw yield - - rawy_unc: raw-yield statistical uncertainty - - frac: either prompt or non-prompt fraction - - eff_times_acc: efficiency times acceptance for prompt or non-prompt - - delta_pt: pT interval - - delta_y: Y interval - - sigma_mb: hadronic cross section for MB - - n_events: number of events - - br: branching ratio of the decay channel - - method_frac: method used to compute frac needed to propoer compute uncertainty - - Returns - ---------- - - crosssection: cross section - - crosssec_unc: cross-section statistical uncertainty - """ - - crosssection = rawy * frac * sigma_mb / (2 * delta_pt * delta_y * eff_times_acc * n_events * br) - if method_frac == "Nb": - crosssec_unc = rawy_unc / (rawy * frac) * crosssection - else: - crosssec_unc = rawy_unc / rawy * crosssection - - return crosssection, crosssec_unc - - -# pylint: disable=too-many-branches,too-many-arguments,too-many-locals -def compute_fraction_fc( - acc_eff_prompt, - acc_eff_fd, - cross_sec_prompt, - cross_sec_fd, - raa_prompt=1.0, - raa_fd=1.0, -) -> "tuple[list[float], list[float]]": - """ - Method to get fraction of prompt / FD fraction with fc method - - Parameters - ---------- - - acc_eff_prompt: efficiency times acceptance of prompt D - - acc_eff_fd: efficiency times acceptance of non-prompt D - - cross_sec_prompt: list of production cross sections (cent, min, max) - of prompt D in pp collisions from theory - - cross_sec_fd: list of production cross sections (cent, min, max) - of non-prompt D in pp collisions from theory - - raa_prompt: list of nuclear modification factors (cent, min, max) of prompt D from theory - - raa_fd: list of nuclear modification factors of (cent, min, max) non-prompt D from theory - - Returns - ---------- - - frac_prompt: list of fraction of prompt D (central, min, max) - - frac_fd: list of fraction of non-prompt D (central, min, max) - """ - - cross_sec_prompt = make_list(cross_sec_prompt) - cross_sec_fd = make_list(cross_sec_fd) - raa_prompt = make_list(raa_prompt) - raa_fd = make_list(raa_fd) - - frac_prompt: list[float] = [] - frac_fd: list[float] = [] - if acc_eff_prompt == 0: - frac_fd_cent = 1.0 - frac_prompt_cent = 0.0 - frac_prompt = [frac_prompt_cent, frac_prompt_cent, frac_prompt_cent] - frac_fd = [frac_fd_cent, frac_fd_cent, frac_fd_cent] - return frac_prompt, frac_fd - if acc_eff_fd == 0: - frac_fd_cent = 0.0 - frac_prompt_cent = 1.0 - frac_prompt = [frac_prompt_cent, frac_prompt_cent, frac_prompt_cent] - frac_fd = [frac_fd_cent, frac_fd_cent, frac_fd_cent] - return frac_prompt, frac_fd - - for i_sigma, (sigma_p, sigma_f) in enumerate(zip(cross_sec_prompt, cross_sec_fd)): - for i_raa, (raa_p, raa_f) in enumerate(zip(raa_prompt, raa_fd)): - if i_sigma == 0 and i_raa == 0: - frac_prompt_cent = 1.0 / (1 + acc_eff_fd / acc_eff_prompt * sigma_f / sigma_p * raa_f / raa_p) - frac_fd_cent = 1.0 / (1 + acc_eff_prompt / acc_eff_fd * sigma_p / sigma_f * raa_p / raa_f) - else: - frac_prompt.append(1.0 / (1 + acc_eff_fd / acc_eff_prompt * sigma_f / sigma_p * raa_f / raa_p)) - frac_fd.append(1.0 / (1 + acc_eff_prompt / acc_eff_fd * sigma_p / sigma_f * raa_p / raa_f)) - - if frac_prompt and frac_fd: - frac_prompt.sort() - frac_fd.sort() - frac_prompt = [frac_prompt_cent, frac_prompt[0], frac_prompt[-1]] - frac_fd = [frac_fd_cent, frac_fd[0], frac_fd[-1]] - else: - frac_prompt = [frac_prompt_cent, frac_prompt_cent, frac_prompt_cent] - frac_fd = [frac_fd_cent, frac_fd_cent, frac_fd_cent] - - return frac_prompt, frac_fd - - -# pylint: disable=too-many-branches,too-many-arguments,too-many-locals,invalid-name -def compute_fraction_nb( - rawy, - acc_eff_same, - acc_eff_other, - crosssection, - delta_pt, - delta_y, - br, - n_events, - sigma_mb, - raa_ratio=1.0, - taa=1.0, -) -> "list[float]": - """ - Method to get fraction of prompt / FD fraction with Nb method - - Parameters - ---------- - - acc_eff_same: efficiency times acceptance of prompt (non-prompt) D - - acc_eff_other: efficiency times acceptance of non-prompt (prompt) D - - crosssection: list of production cross sections (cent, min, max) of non-prompt (prompt) - D in pp collisions from theory - - delta_pt: width of pT interval - - delta_y: width of Y interval - - br: branching ratio for the chosen decay channel - - n_events: number of events corresponding to the raw yields - - sigma_mb: MB cross section - - raa_ratio: list of D nuclear modification factor ratios - non-prompt / prompt (prompt / non-prompt) (cent, min, max) (=1 in case of pp) - - taa: average nuclear overlap function (=1 in case of pp) - - Returns - ---------- - - frac: list of fraction of prompt (non-prompt) D (central, min, max) - """ - - crosssection = make_list(crosssection) - raa_ratio = make_list(raa_ratio) - - frac: list[float] = [] - for i_sigma, sigma in enumerate(crosssection): - for i_raa_ratio, raa_rat in enumerate(raa_ratio): - raa_other = 1.0 - if i_sigma == 0 and i_raa_ratio == 0: - if raa_rat == 1.0 and taa == 1.0: # pp - frac_cent = 1 - sigma * delta_pt * delta_y * acc_eff_other * br * n_events * 2 / rawy / sigma_mb - else: # p-Pb or Pb-Pb: iterative evaluation of Raa needed - delta_raa = 1.0 - while delta_raa > 1.0e-3: - raw_fd = ( - taa * raa_rat * raa_other * sigma * delta_pt * delta_y * acc_eff_other * br * n_events * 2 - ) - frac_cent = 1 - raw_fd / rawy - raa_other_old = raa_other - raa_other = frac_cent * rawy * sigma_mb / 2 / acc_eff_same / delta_pt / delta_y / br / n_events - delta_raa = abs((raa_other - raa_other_old) / raa_other) - else: - if raa_rat == 1.0 and taa == 1.0: # pp - frac.append(1 - sigma * delta_pt * delta_y * acc_eff_other * br * n_events * 2 / rawy / sigma_mb) - else: # p-Pb or Pb-Pb: iterative evaluation of Raa needed - delta_raa = 1.0 - frac_tmp = 1.0 - while delta_raa > 1.0e-3: - raw_fd = ( - taa * raa_rat * raa_other * sigma * delta_pt * delta_y * acc_eff_other * br * n_events * 2 - ) - frac_tmp = 1 - raw_fd / rawy - raa_other_old = raa_other - raa_other = frac_tmp * rawy * sigma_mb / 2 / acc_eff_same / delta_pt / delta_y / br / n_events - delta_raa = abs((raa_other - raa_other_old) / raa_other) - frac.append(frac_tmp) - - if frac: - frac.sort() - frac = [frac_cent, frac[0], frac[-1]] - else: - frac = [frac_cent, frac_cent, frac_cent] - - return frac - - -def get_hist_binlimits(histo): - """ - Method to retrieve bin limits of ROOT.TH1 - - Parameters - ---------- - - histo: ROOT.TH1 - - Returns - ---------- - - bin_limits: numpy array of bin limits - """ - - if np.array(histo.GetXaxis().GetXbins(), "d").any(): # variable binning - bin_limits = np.array(histo.GetXaxis().GetXbins(), "d") - else: # constant binning - n_limits = histo.GetNbinsX() + 1 - low_edge = histo.GetBinLowEdge(1) - bin_width = histo.GetBinWidth(1) - bin_limits = np.array([low_edge + i_bin * bin_width for i_bin in range(n_limits)], "d") - - return bin_limits diff --git a/FirstAnalysis/hf_pt_spectrum.py b/FirstAnalysis/hf_pt_spectrum.py deleted file mode 100644 index 488a3308..00000000 --- a/FirstAnalysis/hf_pt_spectrum.py +++ /dev/null @@ -1,320 +0,0 @@ -#!/usr/bin/env python3 - -""" -file: hf_pt_spectrum.py -brief: script for computation of pT-differential yields (cross sections) -usage: python3 HfPtSpectrum.py CONFIG -author: Fabrizio Grosa , CERN -""" - -import argparse -import os -import sys - -import numpy as np # pylint: disable=import-error -import yaml # pylint: disable=import-error -from hf_analysis_utils import ( - compute_crosssection, - compute_fraction_fc, - compute_fraction_nb, - get_hist_binlimits, -) -from ROOT import ( # pylint: disable=import-error,no-name-in-module - TH1, - TH1F, - TCanvas, - TFile, - TGraphAsymmErrors, - TStyle, - gPad, - gROOT, - kAzure, - kFullCircle, -) - - -# pylint: disable=too-many-locals,too-many-statements -def load_inputs(input_cfg): - """ - Helper method to load inputs - - Parameters - ---------- - - input_cfg: dictionary from yaml config file - - Returns - ---------- - - histos: dictionary with input histos, keys (rawyields, acceffp, acceffnp) - - norm: dictionary with normalisations, keys (BR, events, sigmaMB) - """ - - observable = input_cfg["observable"] - if observable not in ["dsigmadpt", "dNdpt"]: - print(f"\033[91mERROR: observable {observable} not supported. Exit\033[0m") - sys.exit(1) - - channel = input_cfg["channel"] - if channel not in [ - "D0toKpi", - "DplustoKpipi", - "DstoKpipi", - "DstartoD0pi", - "LctopKpi", - "LctopK0S", - ]: - print(f"\033[91mERROR: channel {channel} not supported. Exit\033[0m") - sys.exit(2) - - system = input_cfg["system"] - if system not in ["pp", "pPb", "PbPb"]: - print(f"\033[91mERROR: channel {channel} not supported. Exit\033[0m") - sys.exit(3) - if system in ["pPb", "PbPb"] and observable == "dsigmadpt": - print("\033[93mWARNING: switching from dsigmadpt to dNdpt\033[0m") - - energy = input_cfg["energy"] - if energy not in ["5TeV", "13TeV"]: - print(f"\033[91mERROR: energy {energy} not supported. Exit\033[0m") - sys.exit(4) - - frac_method = input_cfg["fraction"] - if frac_method not in ["Nb", "fc"]: - print(f"\033[91mERROR: method to subtract nonprompt" f" {frac_method} not supported. Exit\033[0m") - sys.exit(5) - - rawy_file_name = input_cfg["rawyield"]["filename"] - rawy_hist_name = input_cfg["rawyield"]["rawyieldhist"] - norm_hist_name = input_cfg["rawyield"]["normhist"] - - eff_file_name = input_cfg["acceff"]["filename"] - effprompt_hist_name = input_cfg["acceff"]["prompthist"] - effnonprompt_hist_name = input_cfg["acceff"]["nonprompthist"] - - pred_file_name = input_cfg["FONLL"] - - # load histos from root files - histos = {} - infile_rawy = TFile.Open(rawy_file_name) - histos["rawyields"] = infile_rawy.Get(rawy_hist_name) - if not histos["rawyields"]: - print(f"\033[91mERROR: raw-yield histo {rawy_hist_name}" f" not found in {rawy_file_name}. Exit\033[0m") - sys.exit(6) - histos["rawyields"].SetDirectory(0) - h_events = infile_rawy.Get(norm_hist_name) - if not h_events: - print(f"\033[91mERROR: normalisation histo {norm_hist_name}" f" not found in {rawy_file_name}. Exit\033[0m") - sys.exit(7) - h_events.SetDirectory(0) - infile_rawy.Close() - - infile_eff = TFile.Open(eff_file_name) - histos["acceffp"] = infile_eff.Get(effprompt_hist_name) - if not histos["acceffp"]: - print( - f"\033[91mERROR: prompt (acc x eff) histo {effprompt_hist_name}" - f" not found in {eff_file_name}. Exit\033[0m" - ) - sys.exit(8) - histos["acceffp"].SetDirectory(0) - histos["acceffnp"] = infile_eff.Get(effnonprompt_hist_name) - if not histos["acceffnp"]: - print( - f"\033[91mERROR: nonprompt (acc x eff) histo {effprompt_hist_name}" - f"not found in {eff_file_name}. Exit\033[0m" - ) - sys.exit(9) - histos["acceffnp"].SetDirectory(0) - infile_eff.Close() - - fonll_hist_name = { - "D0toKpi": "hD0Kpi", - "DplustoKpipi": "hDpluskpipi", - "DstoKKpi": "hDsPhipitoKkpi", - "DstartoD0pi": "hDstarD0pi", - "LctopKpi": "hLcpkpi", - "LctopK0S": "hLcK0sp", - } - histos["FONLL"] = {"prompt": {}, "nonprompt": {}} - infile_fonll = TFile.Open(pred_file_name) - for pred in ("central", "min", "max"): - histos["FONLL"]["nonprompt"][pred] = infile_fonll.Get(f"{fonll_hist_name[channel]}fromBpred_{pred}_corr") - histos["FONLL"]["nonprompt"][pred].SetDirectory(0) - if frac_method == "fc": - histos["FONLL"]["prompt"][pred] = infile_fonll.Get(f"{fonll_hist_name[channel]}pred_{pred}") - histos["FONLL"]["prompt"][pred].SetDirectory(0) - infile_fonll.Close() - - # load normalisation info from common database - norm = {} - with open("config/norm_database.yml", "r") as yml_norm_db: - norm_db = yaml.safe_load(yml_norm_db) - norm["BR"] = norm_db["BR"][channel]["value"] - norm["events"] = h_events.GetBinContent(1) - norm["sigmaMB"] = norm_db["sigma"]["Run2"][system][energy] if observable == "dsigmadpt" else 1.0 - - return histos, norm - - -def main(): - """ - Main function - """ - - parser = argparse.ArgumentParser(description="Arguments to pass") - parser.add_argument( - "configfile_name", - metavar="text", - default="config_Dplus_pp5TeV.yml", - help="input yaml config file", - ) - parser.add_argument("--batch", action="store_true", default=False, help="suppress video output") - args = parser.parse_args() - - if args.batch: - gROOT.SetBatch(True) - - # final plots style settings - style_hist = TStyle("style_hist", "Histo graphics style") - style_hist.SetOptStat("n") - style_hist.SetMarkerColor(kAzure + 4) - style_hist.SetMarkerStyle(kFullCircle) - style_hist.SetMarkerSize(1) - style_hist.SetHistLineColor(kAzure + 4) - style_hist.SetHistLineWidth(2) - style_hist.SetLabelSize(0.030) - style_hist.SetLabelOffset(0.010) - style_hist.SetTitleXOffset(1.3) - style_hist.SetTitleYOffset(1.3) - style_hist.SetDrawOption("AP") - gROOT.SetStyle("style_hist") - gROOT.ForceStyle() - - # load info from config file - with open(args.configfile_name, "r") as yml_configfile: - cfg = yaml.safe_load(yml_configfile) - frac_method = cfg["fraction"] - - histos, norm = load_inputs(cfg) - - # consistency check of bins - ptlims = {} - for histo in ["rawyields", "acceffp", "acceffnp"]: - ptlims[histo] = get_hist_binlimits(histos[histo]) - if histo != "rawyields" and not np.equal(ptlims[histo], ptlims["rawyields"]).all(): - print("\033[91mERROR: histo binning not consistent. Exit\033[0m") - sys.exit(10) - - # compute cross section - axistit_cross = "d#sigma/d#it{p}_{T} (pb GeV^{-1} #it{c})" - axistit_cross_times_br = "d#sigma/d#it{p}_{T} #times BR (pb GeV^{-1} #it{c})" - axistit_pt = "#it{p}_{T} (GeV/#it{c})" - axistit_fprompt = "#if{f}_{prompt}" - gfraction = TGraphAsymmErrors() - gfraction.SetNameTitle("gfraction", f";{axistit_pt};{axistit_fprompt}") - - hptspectrum = TH1F( - "hptspectrum", - f";{axistit_pt};{axistit_cross}", - len(ptlims["rawyields"]) - 1, - ptlims["rawyields"], - ) - hptspectrum_wo_br = TH1F( - "hptspectrum_wo_br", - f";{axistit_pt};{axistit_cross_times_br}", - len(ptlims["rawyields"]) - 1, - ptlims["rawyields"], - ) - - for i_pt, (ptmin, ptmax) in enumerate(zip(ptlims["rawyields"][:-1], ptlims["rawyields"][1:])): - pt_cent = (ptmax + ptmin) / 2 - pt_delta = ptmax - ptmin - rawy = histos["rawyields"].GetBinContent(i_pt + 1) - rawy_unc = histos["rawyields"].GetBinError(i_pt + 1) - eff_times_acc_prompt = histos["acceffp"].GetBinContent(i_pt + 1) - eff_times_acc_nonprompt = histos["acceffnp"].GetBinContent(i_pt + 1) - ptmin_fonll = histos["FONLL"]["nonprompt"]["central"].GetXaxis().FindBin(ptmin * 1.0001) - ptmax_fonll = histos["FONLL"]["nonprompt"]["central"].GetXaxis().FindBin(ptmax * 0.9999) - crosssec_nonprompt_fonll = [ - histos["FONLL"]["nonprompt"][pred].Integral(ptmin_fonll, ptmax_fonll, "width") / (ptmax - ptmin) - for pred in histos["FONLL"]["nonprompt"] - ] - - # compute prompt fraction - frac = [0.0, 0.0, 0.0] - if frac_method == "Nb": - frac = compute_fraction_nb( # BR already included in FONLL prediction - rawy, - eff_times_acc_prompt, - eff_times_acc_nonprompt, - crosssec_nonprompt_fonll, - pt_delta, - 1.0, - 1.0, - norm["events"], - norm["sigmaMB"], - ) - elif frac_method == "fc": - crosssec_prompt_fonll = [ - histos["FONLL"]["prompt"][pred].Integral(ptmin_fonll, ptmax_fonll, "width") / (ptmax - ptmin) - for pred in histos["FONLL"]["prompt"] - ] - frac, _ = compute_fraction_fc( - eff_times_acc_prompt, - eff_times_acc_nonprompt, - crosssec_prompt_fonll, - crosssec_nonprompt_fonll, - ) - - # compute cross section times BR - crosssec, crosssec_unc = compute_crosssection( - rawy, - rawy_unc, - frac[0], - eff_times_acc_prompt, - ptmax - ptmin, - 1.0, - norm["sigmaMB"], - norm["events"], - 1.0, - frac_method, - ) - - hptspectrum.SetBinContent(i_pt + 1, crosssec / norm["BR"]) - hptspectrum.SetBinError(i_pt + 1, crosssec_unc / norm["BR"]) - hptspectrum_wo_br.SetBinContent(i_pt + 1, crosssec) - hptspectrum_wo_br.SetBinError(i_pt + 1, crosssec_unc) - gfraction.SetPoint(i_pt, pt_cent, frac[0]) - gfraction.SetPointError(i_pt, pt_delta / 2, pt_delta / 2, frac[0] - frac[1], frac[2] - frac[0]) - - c = TCanvas("c", "c", 600, 800) - c.Divide(1, 2) - c.cd(1) - gPad.SetLogy(True) - hptspectrum.Draw() - c.cd(2) - gPad.SetLogy(True) - hptspectrum_wo_br.Draw() - - output_dir = cfg["output"]["directory"] - if not os.path.exists(output_dir): - os.makedirs(output_dir) - - c.Print(os.path.join(output_dir, f'{cfg["output"]["filename"]}.pdf')) - - # save output file - output_file = TFile(os.path.join(output_dir, f'{cfg["output"]["filename"]}.root'), "recreate") - hptspectrum.Write() - hptspectrum_wo_br.Write() - gfraction.Write() - for hist in histos: - if isinstance(histos[hist], TH1): - histos[hist].Write() - else: - for flav in histos[hist]: - for pred in histos[hist][flav]: - histos[hist][flav][pred].Write() - output_file.Close() - - -# call main function -main() diff --git a/FirstAnalysis/homogenize_output.py b/FirstAnalysis/homogenize_output.py deleted file mode 100755 index 639dae03..00000000 --- a/FirstAnalysis/homogenize_output.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python3 - -""" -Script to split the directories of a file into several ones with the same structure, useful for ML processing -""" - -import argparse -import os -import time -from multiprocessing import Pool - -from ROOT import TFile, gROOT # pylint: disable=import-error - -g_verbose = False -g_out_path = "" -g_base_dir = "" - - -def split_file(input_name): - processing_time = time.time() - print(" > Processing file", input_name) - if g_verbose: - print("Homogenizing file", f"'{input_name}'", "for ML processing") - f = TFile(input_name, "READ") - if g_verbose: - f.ls() - lk = f.GetListOfKeys() - files_created = 0 - for i in lk: - obj = f.Get(i.GetName()) - if obj.ClassName() == "TDirectoryFile": - fout = input_name.replace(".root", f"_sub{files_created}.root") - fout = os.path.join(g_out_path, fout.split("/")[-1]) - if os.path.isfile(fout): - raise RuntimeError("File", fout, "already there!") - fout = TFile(fout, "RECREATE") - if not fout.IsOpen(): - raise RuntimeError("File", fout, "is not open!") - if g_verbose: - print("Creating omogenized file to", fout) - files_created += 1 - fout.mkdir(g_base_dir + "0") - fout.cd(g_base_dir + "0") - for j in obj.GetListOfKeys(): - if g_verbose: - print("Writing", j.ClassName(), j) - t = obj.Get(j.GetName()) - if t.ClassName() == "TTree": - t.CloneTree().Write() - else: - t.Clone().Write() - if g_verbose: - fout.ls() - fout.Close() - print( - " < Processed file", - input_name, - "split into", - files_created, - "files, in", - time.time() - processing_time, - "seconds", - ) - - -def main(input_files, verbose=True, base_dir="TF_", out_path="", jobs=20): - global g_verbose - g_verbose = verbose - global g_out_path - g_out_path = out_path - global g_base_dir - g_base_dir = base_dir - - print("Omogenizing", len(input_files), "files") - processing_time = time.time() - with Pool(jobs) as p: - p.map(split_file, input_files) - print("Done, in", time.time() - processing_time, "seconds") - - -if __name__ == "__main__": - gROOT.SetBatch(True) - - parser = argparse.ArgumentParser(description="Omogenizer for ML processing") - parser.add_argument("input_files", type=str, nargs="+", help="Input files") - parser.add_argument( - "--base_dir", - type=str, - default="TF_", - help="Name of the base directory, usually `TF_` or `DF_`", - ) - parser.add_argument("--out_dir", "-o", type=str, default="./tmp/", help="Name of the output path") - parser.add_argument("--jobs", "-j", type=int, default=5, help="Number of parallel jobs") - parser.add_argument("-v", action="store_true", help="Verbose mode") - args = parser.parse_args() - main(args.input_files, verbose=args.v, base_dir=args.base_dir, jobs=args.jobs) diff --git a/FirstAnalysis/kinematic2D_run5.py b/FirstAnalysis/kinematic2D_run5.py deleted file mode 100644 index bd674fdd..00000000 --- a/FirstAnalysis/kinematic2D_run5.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -from ROOT import TCanvas, TFile, gPad, gStyle - -gStyle.SetOptStat(0) -gStyle.SetErrorX(0) -gStyle.SetFrameLineWidth(1) -gStyle.SetTitleSize(0.045, "x") -gStyle.SetTitleSize(0.045, "y") -gStyle.SetMarkerSize(1) -gStyle.SetLabelOffset(0.015, "x") -gStyle.SetLabelOffset(0.02, "y") -gStyle.SetTickLength(-0.02, "x") -gStyle.SetTickLength(-0.02, "y") -gStyle.SetTitleOffset(1.1, "x") -gStyle.SetTitleOffset(1.0, "y") - - -def saveCanvas(canvas, title): - format_list = ["png", ".pdf", ".root"] - for fileFormat in format_list: - canvas.SaveAs(title + fileFormat) - - -def kinematic_plots(var1): - fileo2 = TFile("../codeHF/AnalysisResults_O2.root") - cres = TCanvas("cres", "resolution distribution") - cres.SetCanvasSize(1600, 1200) - cres.Divide(1, 3) - sig = fileo2.Get("hf-task-jpsi-mc/h%sSig" % var1) - bkg = fileo2.Get("hf-task-jpsi-mc/h%sBg" % var1) - gen = fileo2.Get("hf-task-jpsi-mc/h%sGen" % var1) - cres.cd(1) - gPad.SetLogz() - sig.Draw("coltz") - sig.SetTitle("%s Signal distribution(Rec. Level)" % var1) - cres.cd(2) - gPad.SetLogz() - bkg.Draw("coltz") - bkg.SetTitle("%s Background distribution(Rec. Level)" % var1) - cres.cd(3) - gPad.SetLogz() - gen.Draw("coltz") - gen.SetTitle("%s Gen distribution(Gen. Level)" % var1) - saveCanvas(cres, "%s" % var1) - ceff = TCanvas("ceff", "2D efficiencies") - ceff.SetCanvasSize(1600, 1200) - ceff.cd() - eff = sig.Clone("eff") - den = gen.Clone("den") - eff.Divide(den) - eff.Draw("COLZ") - eff.SetTitle("%s Jpsi reco and sel. efficiency (Reco pt / Gen pt)" % var1) - saveCanvas(ceff, "efficiencyYpt") - - -var_list = ["Y"] - -for var in var_list: - kinematic_plots(var) diff --git a/FirstAnalysis/plot_seleff_vs_cuts.py b/FirstAnalysis/plot_seleff_vs_cuts.py deleted file mode 100644 index 4ede0f4d..00000000 --- a/FirstAnalysis/plot_seleff_vs_cuts.py +++ /dev/null @@ -1,307 +0,0 @@ -#!/usr/bin/env python3 - -""" -file: plot_seleff_vs_cuts.py -brief: script to plot selection efficiencies vs cut obtained with taskSelOptimisation.cxx task -usage: python3 plot_seleff_vs_cuts.py CONFIG [--batch] -author: Fabrizio Grosa , CERN -""" - -import argparse -from typing import Dict - -import yaml # pylint: disable=import-error -from ROOT import ( # pylint: disable=import-error,no-name-in-module - TCanvas, - TFile, - TLegend, - gROOT, - gStyle, - kAzure, - kBlack, - kBlue, - kFullCircle, - kGreen, - kMagenta, - kOrange, - kRed, -) - - -def set_hist_style(histo, color=kBlack, marker=kFullCircle, markersize=1.0): - """ - Helper method to set histo graphic style - """ - histo.SetLineColor(color) - histo.SetMarkerColor(color) - histo.SetMarkerStyle(marker) - histo.SetMarkerSize(markersize) - - -gStyle.SetPadBottomMargin(0.15) -gStyle.SetPadLeftMargin(0.14) -gStyle.SetPadRightMargin(0.12) -gStyle.SetPadTickX(1) -gStyle.SetPadTickY(1) -gStyle.SetTitleSize(0.045, "xy") -gStyle.SetLabelSize(0.045, "y") -gStyle.SetLabelSize(0.055, "x") -gStyle.SetTitleOffset(1.4, "x") -gStyle.SetOptStat(0) - -cand_types = ["2Prong", "3Prong"] -colors = {"Prompt": kRed + 1, "NonPrompt": kAzure + 4, "Bkg": kBlack} -colors_channel = { - "D0ToPiK": kRed + 1, - "JpsiToEE": kMagenta + 1, - "2Prong": kBlack, - "DPlusToPiKPi": kGreen + 2, - "DsToKKPi": kOrange + 7, - "LcToPKPi": kAzure + 4, - "XicToPKPi": kBlue + 3, - "3Prong": kBlack, -} -leg_orig_names = {"Prompt": "prompt", "NonPrompt": "non-prompt", "Bkg": "background"} -leg_channel_names = { - "D0ToPiK": "D^{0} #rightarrow K^{#minus}#pi^{#plus}", - "JpsiToEE": "J/#psi #rightarrow e^{#minus}e^{#plus}", - "DPlusToPiKPi": "D^{#plus} #rightarrow K^{#minus}#pi^{#plus}#pi^{#plus}", - "DsToKKPi": "D_{s}^{#plus} #rightarrow K^{#plus}K^{#minus}#pi^{#plus}", - "LcToPKPi": "#Lambda_{c}^{#plus} #rightarrow pK^{#minus}#pi^{#plus}", - "XicToPKPi": "#Xi_{c}^{#plus} #rightarrow pK^{#minus}#pi^{#plus}", -} - -parser = argparse.ArgumentParser(description="Arguments") -parser.add_argument( - "cfgfilename", metavar="text", default="config.yml", help="input yaml config file" -) -parser.add_argument("--batch", action="store_true", help="suppress video output") -args = parser.parse_args() - -with open(args.cfgfilename, "r") as yml_file: - cfg = yaml.safe_load(yml_file) - -infile_names = { - "Prompt": cfg["inputs"]["prompt"], - "NonPrompt": cfg["inputs"]["nonprompt"], - "Bkg": cfg["inputs"]["background"], -} - -origins = cfg["origins"] -cands = {"2Prong": cfg["cands2Prong"], "3Prong": cfg["cands3Prong"]} -for cand_type in cand_types: - cands[cand_type].insert(0, cand_type) -vars_to_plot = {"2Prong": cfg["vars2Prong"], "3Prong": cfg["vars3Prong"]} - -if args.batch: - gROOT.SetBatch(True) - -hvar_vs_pt = {} # type: Dict[str, Dict] -hvar = {} # type: Dict[str, Dict] -hvar_perevent = {} # type: Dict[str, Dict] -hvar_fracs = {} # type: Dict[str, Dict] -hnorm_vs_pt = {} # type: Dict[str, Dict] -for cand_type in cand_types: - for cand in cands[cand_type]: - ( - hvar_vs_pt[cand], - hvar[cand], - hvar_perevent[cand], - hvar_fracs[cand], - hnorm_vs_pt[cand], - ) = ({} for _ in range(5)) - - for iVar, var in enumerate(vars_to_plot[cand_type]): - ( - hvar_vs_pt[cand][var], - hvar[cand][var], - hvar_perevent[cand][var], - hvar_fracs[cand][var], - ) = ({} for _ in range(4)) - - for orig in origins: - infile = TFile.Open(infile_names[orig]) - hvar_vs_pt[cand][var][orig] = infile.Get( - f"hf-task-sel-optimisation/h{orig}{var}VsPt{cand}" - ) - if iVar == 0: - hnorm_vs_pt[cand][orig] = infile.Get( - f"hf-task-sel-optimisation/h{orig}VsPt{cand}" - ) - hEvents = infile.Get("hf-tag-sel-collisions/hEvents") - hvar_vs_pt[cand][var][orig].SetDirectory(0) - hnorm_vs_pt[cand][orig].SetDirectory(0) - hEvents.SetDirectory(0) - nEvents = hEvents.GetBinContent(2) - - hvar[cand][var][orig] = [] - hvar_perevent[cand][var][orig] = [] - hvar_fracs[cand][var][orig] = [] - nPtBins = hvar_vs_pt[cand][var][orig].GetXaxis().GetNbins() - - for iPtBin in range(1, nPtBins + 1): - hvar[cand][var][orig].append( - hvar_vs_pt[cand][var][orig].ProjectionY( - f"h{orig}{var}{cand}_pTbin{iPtBin}", iPtBin, iPtBin - ) - ) - hvar[cand][var][orig][iPtBin - 1].SetDirectory(0) - hvar[cand][var][orig][iPtBin - 1].GetXaxis().SetRangeUser( - 1.0, hvar_vs_pt[cand][var][orig].GetYaxis().GetNbins() - ) - hvar_fracs[cand][var][orig].append( - hvar[cand][var][orig][iPtBin - 1].Clone( - f"h{orig}{var}{cand}_Frac_pTbin{iPtBin}" - ) - ) - hvar_fracs[cand][var][orig][iPtBin - 1].SetDirectory(0) - hvar_fracs[cand][var][orig][iPtBin - 1].GetXaxis().SetRangeUser( - 1.0, hvar_vs_pt[cand][var][orig].GetYaxis().GetNbins() - ) - set_hist_style( - hvar[cand][var][orig][iPtBin - 1], - colors[orig], - kFullCircle, - 1.0, - ) - set_hist_style( - hvar_fracs[cand][var][orig][iPtBin - 1], - colors_channel[cand], - kFullCircle, - 1.0, - ) - hvar_perevent[cand][var][orig].append( - hvar[cand][var][orig][iPtBin - 1].Clone( - f"h{orig}{var}{cand}_perEvent_pTbin{iPtBin}" - ) - ) - hvar_perevent[cand][var][orig][iPtBin - 1].SetDirectory(0) - norm = hnorm_vs_pt[cand][orig].GetBinContent(iPtBin) - normCandType = hnorm_vs_pt[cand_type][orig].GetBinContent(iPtBin) - if norm == 0: - norm = 1 - if normCandType == 0: - normCandType = 1 - hvar[cand][var][orig][iPtBin - 1].Scale(1.0 / norm) - hvar_fracs[cand][var][orig][iPtBin - 1].Divide( - hvar[cand][var][orig][iPtBin - 1], - hvar[cand_type][var][orig][iPtBin - 1], - norm, - normCandType, - "", - ) - hvar_perevent[cand][var][orig][iPtBin - 1].Scale(1.0 / nEvents) - -# plots -leg_orig = TLegend(0.35, 0.2, 0.7, 0.35) -leg_orig.SetTextSize(0.045) -leg_orig.SetBorderSize(0) -leg_orig.SetFillStyle(0) - -leg_channels = {} # type: Dict[str, TLegend] - -ceff = {} # type: Dict[str, TCanvas] -ccand_perevent = {} # type: Dict[str, TCanvas] -cfracs = {} # type: Dict[str, TCanvas] -for cand_type in cand_types: - leg_channels[cand_type] = TLegend(0.35, 0.2, 0.7, 0.45) - leg_channels[cand_type].SetTextSize(0.045) - leg_channels[cand_type].SetBorderSize(0) - leg_channels[cand_type].SetFillStyle(0) - for cand in cands[cand_type]: - ceff[cand], ccand_perevent[cand] = ({} for _ in range(2)) - - for iVar, var in enumerate(vars_to_plot[cand_type]): - ceff[cand][var] = TCanvas(f"c{var}{cand}", "", 1200, 400) - ccand_perevent[cand][var] = TCanvas(f"c{var}{cand}_perEvent", "", 1200, 400) - - nCutsTested = hvar[cand][var][origins[0]][-1].GetNbinsX() - varTitle = hvar[cand][var][origins[0]][-1].GetXaxis().GetTitle() - ceff[cand][var].Divide(nPtBins, 1) - ccand_perevent[cand][var].Divide(nPtBins, 1) - - for iPtBin in range(nPtBins): - # fill legend - for orig in origins: - if iPtBin == 1 and leg_orig.GetNRows() < len(origins): - leg_orig.AddEntry( - hvar[cand][var][orig][iPtBin - 1], - leg_orig_names[orig], - "pl", - ) - - ptMin = ( - hvar_vs_pt[cand][var][origins[0]] - .GetXaxis() - .GetBinLowEdge(iPtBin + 1) - ) - ptMax = ( - hvar_vs_pt[cand][var][origins[0]] - .GetXaxis() - .GetBinUpEdge(iPtBin + 1) - ) - h_frame = hvar[cand][var][origins[0]][iPtBin].Clone( - f"h_frame{var}{cand}_pTbin{iPtBin}" - ) - h_frame.Reset() - h_frame.SetTitle( - f"{ptMin}<#it{{p}}_{{T}}<{ptMax} GeV/#it{{c}};{varTitle};selection efficiency;" - ) - h_frame.GetYaxis().SetRangeUser( - hvar[cand][var]["Bkg"][iPtBin].GetMinimum() / 10, 1.2 - ) - ceff[cand][var].cd(iPtBin + 1).SetLogy() - h_frame.DrawCopy() - for orig in origins: - hvar[cand][var][orig][iPtBin].DrawCopy("same") - leg_orig.Draw() - ccand_perevent[cand][var].cd(iPtBin + 1).SetLogy() - h_frame.GetYaxis().SetRangeUser( - hvar_perevent[cand][var]["Bkg"][iPtBin].GetMinimum() / 10, - hvar_perevent[cand][var]["Bkg"][iPtBin].GetMaximum() * 20, - ) - h_frame.GetYaxis().SetTitle("candidates/event") - h_frame.DrawCopy() - hvar_perevent[cand][var]["Bkg"][iPtBin].DrawCopy("same") - ceff[cand][var].SaveAs(f"c{var}{cand}.pdf") - ccand_perevent[cand][var].SaveAs(f"c{var}{cand}_perEvent.pdf") - - for iVar, var in enumerate(vars_to_plot[cand_type]): - cfracs[var] = {} - nCutsTested = hvar[cand][var][origins[0]][-1].GetNbinsX() - varTitle = hvar[cand][var][origins[0]][-1].GetXaxis().GetTitle() - for orig in origins: - cfracs[var][orig] = TCanvas(f"c{orig}{var}{cand_type}_Fracs", "", 1200, 400) - cfracs[var][orig].Divide(nPtBins, 1) - for iPtBin in range(nPtBins): - ptMin = ( - hvar_vs_pt[cand_type][var][orig] - .GetXaxis() - .GetBinLowEdge(iPtBin + 1) - ) - ptMax = ( - hvar_vs_pt[cand_type][var][orig].GetXaxis().GetBinUpEdge(iPtBin + 1) - ) - h_frame = hvar_fracs[cand][var][origins[0]][iPtBin].Clone( - f"h_frame_frac{var}{cand}_pTbin{iPtBin}" - ) - h_frame.Reset() - cfracs[var][orig].cd(iPtBin + 1).SetLogy() - h_frame.GetYaxis().SetRangeUser(1.0e-3, 1.2) - h_frame.GetYaxis().SetTitle("fraction") - h_frame.DrawCopy() - for cand in cands[cand_type]: - if cand != cand_type: - n_rows_leg = leg_channels[cand_type].GetNRows() - if iPtBin == 1 and n_rows_leg < len(cands[cand_type]) - 1: - leg_channels[cand_type].AddEntry( - hvar_fracs[cand][var][orig][iPtBin], - leg_channel_names[cand], - "pl", - ) - hvar_fracs[cand][var][orig][iPtBin].DrawCopy("same") - leg_channels[cand_type].Draw() - cfracs[var][orig].SaveAs(f"c{cand_type}{orig}{var}_Frac.pdf") - -if not args.batch: - input("Press enter to exit") diff --git a/FirstAnalysis/plotsinglevar.py b/FirstAnalysis/plotsinglevar.py deleted file mode 100644 index 28e557cc..00000000 --- a/FirstAnalysis/plotsinglevar.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env python -import os - -from ROOT import ( # pylint: disable=import-error - TF1, - TH2F, - TCanvas, - TFile, - TLatex, - gROOT, - gStyle, -) - - -def makeSavePaths(title, *fileFormats, outputdir="outputPlots"): - """ - Saves the canvas as the desired output format in an output directory (default = outputPlots) - """ - if not os.path.exists(outputdir): - os.makedirs(outputdir) - return [outputdir + "/" + title + fileFormat for fileFormat in fileFormats] - - -def plotsinglevar( - mode="MM", - filename="../codeHF/AnalysisResults_O2.root", - dirname="hf-task-xicc-mc", - latex="Xi_{cc}", - iptBin=2, - histonmasssig="hPtRecGenDiff", # hPtRecGenDiff hXSecVtxPosDiff - xmin=-2.0, - xmax=2.0, - ymin=0.1, - ymax=1.0e6, - rebin=4, - logx=1, - logy=1, - xminfit=-2.0, - xmaxfit=2.0, - title="", - xaxis="Xi_{cc} X vertex reco - gen (cm)", - dofit=0, -): - gStyle.SetOptStat(0) - gROOT.SetBatch(1) - - fileSig = TFile(filename) - histo2d = fileSig.Get("%s/%s" % (dirname, histonmasssig)) - hvar = histo2d.ProjectionX("hvar", iptBin + 1, iptBin + 1) - hvar.GetXaxis().SetRangeUser(xmin, xmax) - hvar.Draw() - ptMin = histo2d.GetYaxis().GetBinLowEdge(iptBin + 1) - ptMax = ptMin + histo2d.GetYaxis().GetBinWidth(iptBin + 1) - # ymax = hvar.GetMaximum() * 10 - # ymin = hvar.GetMinimum() - hempty = TH2F("hempty", ";%s; Entries" % xaxis, 100, xmin, xmax, 100, ymin, ymax) - hempty.GetXaxis().SetLabelFont(42) - hempty.GetXaxis().SetTitleOffset(1) - hempty.GetXaxis().SetLabelSize(0.03) - hempty.GetXaxis().SetTitleFont(42) - hempty.GetYaxis().SetLabelFont(42) - hempty.GetYaxis().SetTitleOffset(1.35) - hempty.GetYaxis().SetTitleFont(42) - hempty.GetZaxis().SetLabelFont(42) - hempty.GetZaxis().SetTitleOffset(1) - hempty.GetZaxis().SetTitleFont(42) - - canvas = TCanvas("canvas", "A Simple Graph Example", 881, 176, 668, 616) - gStyle.SetOptStat(0) - canvas.SetHighLightColor(2) - canvas.Range(-1.25, -4.625, 11.25, 11.625) - canvas.SetFillColor(0) - canvas.SetBorderMode(0) - canvas.SetBorderSize(2) - canvas.SetFrameBorderMode(0) - canvas.SetFrameBorderMode(0) - if logx == 1: - canvas.SetLogx() - if logy == 1: - canvas.SetLogy() - canvas.cd() - hempty.Draw("") - hvar.Draw("PEsame") - latexa = TLatex() - latexa.SetTextSize(0.04) - latexa.SetTextFont(42) - latexa.SetTextAlign(3) - xave = xmin + (xmax - xmin) / 4.0 - latexa.DrawLatex( - xave, ymax * 0.2, "%.1f < p_{T} (%s) < %.1f GeV" % (ptMin, latex, ptMax) - ) - if dofit: - f = TF1("f", "gaus") - hvar.Fit("f", "R", "", xminfit, xmaxfit) - latexb = TLatex() - latexb.SetTextSize(0.04) - latexb.SetTextFont(42) - latexb.SetTextAlign(3) - mean = f.GetParameter(1) - sigma = f.GetParameter(2) - latexb.DrawLatex(xave, ymax * 0.35, "#mu = %.5f, #sigma = %.5f" % (mean, sigma)) - canvas.SaveAs("%s%s.pdf" % (histonmasssig, mode)) - - -plotsinglevar( - "MuMu", - "/home/auras/analysis/AnalysisResults_O2_Signal_PID_mumu.root", - "hf-task-jpsi-mc", - "J/#psi", - 2, - "hMassBg", - 2.7, - 3.4, - 0.1, - 5e3, - 4, - 0, - 1, - 2.0, - 4.0, - "", - "Inv. Mass (GeV/c2)", - 0, -) diff --git a/FirstAnalysis/sig_vs_bkg.py b/FirstAnalysis/sig_vs_bkg.py deleted file mode 100644 index 113f67f8..00000000 --- a/FirstAnalysis/sig_vs_bkg.py +++ /dev/null @@ -1,283 +0,0 @@ -#!/usr/bin/env python3 - -""" -Produce plots of signal vs background distributions. - -Takes a signal file and background file and any number of variables. -Makes and saves signal vs background plots for each decay channel and each variable. -Creates one plot per pT bin and saves them all to one canvas per variable -or optionally in separate canvases (singlepad = True). -User can also manually set the options to normalise or rebin the histograms, -defaults are True and 1 (no rebin), respectively. - -Input: file with histograms produced by o2-analysis-hf-task-... in MC mode - -Usage: python3 sig_vs_bkg.py - -Parameters: -- path_file_sig: path to file with signal distributions -- path_file_bkg: path to file with background distributions -- variables: list of variable strings -- decays: list of decay channel strings (appearing in hf-task-{decay}...) - -Contributors: - Rik Spijkers - Luigi Dello Stritto - Vít Kučera -""" - -import os -import sys -from math import ceil, sqrt - -from ROOT import TCanvas, TFile, TLegend, gROOT, gStyle, kBlue, kRed - - -def create_canvas(n_plots, name, size_x=1500, size_y=800): - """ - Creates a canvas and automatically divides it in a nxn grid of subpads, - where n is the lowest value for which all the plots can be drawn - - Returns the canvas - """ - canvas = TCanvas(name, "canvas title") - # automatically determine the grid of plots based on the number of plots - n_div = ceil(sqrt(float(n_plots))) - canvas.SetCanvasSize(size_x, size_y) - canvas.Divide(n_div, n_div) - return canvas - - -def save_canvas(canvas, name, *file_formats, dir_output="outputPlots"): - """ - Saves the canvas as the desired output format in an output directory. - """ - if not os.path.exists(dir_output): - os.makedirs(dir_output) - for file_format in file_formats: - file_format = file_format.replace(".", "") - canvas.SaveAs(f"{dir_output}/{name}.{file_format}") - - -def set_histogram(his, y_min, y_max, margin_low, margin_high, logscale): - """ - Sets histogram axes labels and range. - """ - for ax in his.GetXaxis(), his.GetYaxis(): - ax.SetTitleFont(textfont) - ax.SetTitleSize(textsize) - ax.SetTitleOffset(1.0) - ax.SetLabelFont(textfont) - ax.SetLabelSize(labelsize) - k = 1.0 - margin_high - margin_low - if logscale and y_min > 0 and y_max > 0: - y_range = y_max / y_min - his.GetYaxis().SetRangeUser( - y_min / pow(y_range, margin_low / k), y_max * pow(y_range, margin_high / k) - ) - else: - logscale = False - y_range = y_max - y_min - his.GetYaxis().SetRangeUser( - y_min - margin_low / k * y_range, y_max + margin_high / k * y_range - ) - return logscale - - -def main(): - """ - Main plotting function - - Loops over decays, variables and pT bins. - """ - file_sig = TFile(path_file_sig) - if file_sig.IsZombie(): - print(f"Error: Failed to open file {path_file_sig}") - sys.exit(1) - file_bkg = TFile(path_file_bkg) - if file_bkg.IsZombie(): - print(f"Error: Failed to open file {path_file_bkg}") - sys.exit(1) - for decay in decays: - print(f"Decay: {decay}") - for var in variables: - print(f"Variable: {var}") - name_h_sig = f"hf-task-{decay}-mc/h{var}RecSig" - h_sig = file_sig.Get(name_h_sig) - if not h_sig: - print( - f"Error: Failed to get histogram {name_h_sig}! Skipping variable {var}" - ) - continue - name_h_bkg = f"hf-task-{decay}-mc/h{var}RecBg" - h_bkg = file_bkg.Get(name_h_bkg) - if not h_bkg: - print( - f"Error: Failed to get histogram {name_h_bkg}! Skipping variable {var}" - ) - continue - if type(h_sig) != type(h_bkg): - print( - f"Error: Histograms are not of the same type! Skipping variable {var}..." - ) - continue - n_bins_pt = h_sig.GetNbinsY() - print(f"pT bins: {n_bins_pt}") - if h_bkg.GetNbinsY() != n_bins_pt: - print( - f"Error: Histograms have different number of pT bins! Skipping variable {var}" - ) - continue - # rebin along the variable axis - if rebin > 1: - h_sig.RebinX(rebin) - h_bkg.RebinX(rebin) - # create canvas and legend - if not singlepad: - canvas_all = create_canvas(n_bins_pt, f"canvas_{decay}_{var}") - list_leg = [] # one legend for each pT bin - - for i in range(n_bins_pt): - bin_pt = i + 1 - if singlepad: - canvas_single = create_canvas(1, f"canvas_{decay}_{var}_{bin_pt}") - pad = canvas_single.cd(1) - else: - pad = canvas_all.cd(bin_pt) - # create a 1D histogram per pT bin - if h_sig.InheritsFrom("TH2"): - h_sig_px = h_sig.ProjectionX( - f"h_sig_px_{decay}_{var}_{bin_pt}", bin_pt, bin_pt - ) - h_bkg_px = h_bkg.ProjectionX( - f"h_bkg_px_{decay}_{var}_{bin_pt}", bin_pt, bin_pt - ) - elif h_sig.InheritsFrom("TH1"): - h_sig_px = h_sig - h_bkg_px = h_bkg - else: - print(f"Error: Unsupported histogram type: {type(h_sig)}") - sys.exit(1) - # get pT range - pt_min = h_sig.GetYaxis().GetBinLowEdge(bin_pt) - pt_max = h_sig.GetYaxis().GetBinLowEdge(bin_pt + 1) - title = labels[decay] if decay in labels else decay - if n_bins_pt > 1: - title += f", {pt_min:g} #leq #it{{p}}_{{T}}/(GeV/#it{{c}}) < {pt_max:g} (bin {bin_pt})" - h_bkg_px.SetTitle(title) - h_bkg_px.SetYTitle("entries") - # create legend and entries - list_leg.append(TLegend(0.5, 0.8, 0.95, 0.9)) - list_leg[i].SetNColumns(2) - n_entries_sig = h_sig_px.GetEntries() - n_entries_bkg = h_bkg_px.GetEntries() - list_leg[i].AddEntry(h_sig_px, f"Sig. ({int(n_entries_sig)})", "FL") - list_leg[i].AddEntry(h_bkg_px, f"Bkg. ({int(n_entries_bkg)})", "FL") - # normalise histograms - if normalise: - if n_entries_sig > 0 and n_entries_bkg > 0: - h_sig_px.Scale(1.0 / n_entries_sig, "nosw2") - h_bkg_px.Scale(1.0 / n_entries_bkg, "nosw2") - h_bkg_px.SetYTitle("normalised entries") - else: - print( - f"Warning: Signal or backgound histogram has no entries, " - f"so cannot be normalised! (ptbin = {bin_pt})" - ) - # determine y range - y_max = max( - h_bkg_px.GetBinContent(h_bkg_px.GetMaximumBin()), - h_sig_px.GetBinContent(h_sig_px.GetMaximumBin()), - ) - y_min = min(h_bkg_px.GetMinimum(0), h_sig_px.GetMinimum(0)) - logscale = set_histogram( - h_bkg_px, y_min, y_max, margin_low, margin_high, True - ) - if logscale: - pad.SetLogy() - - # draw the histograms and legend - h_bkg_px.SetLineColor(4) - h_bkg_px.SetLineWidth(2) - h_bkg_px.SetFillColorAlpha(kBlue, 0.35) - h_bkg_px.SetFillStyle(3345) - h_bkg_px.GetYaxis().SetMaxDigits(3) - h_bkg_px.DrawCopy("hist") - - h_sig_px.SetLineColor(2) - h_sig_px.SetLineWidth(2) - h_sig_px.SetFillColorAlpha(kRed + 1, 0.35) - h_sig_px.SetFillStyle(3354) - h_sig_px.DrawCopy("hist same") - - # lat.DrawLatex(0.17,0.88,"ALICE 3 Study, layout v1") - # lat3.DrawLatex(0.17,0.83,"PYTHIA 8.2, #sqrt{#it{s}} = 14 TeV") - # lat2.DrawLatex(0.17,0.78,"#Xi^{++}_{cc} #rightarrow #Xi_{c}^{+} #pi^{+} and charge conj.") - # lat2.DrawLatex(0.17,0.73,"|#it{y}_{#Xi_{cc}}| #leq 1.44, 4 < #it{p}_{T} < 6 GeV/#it{c}") - - list_leg[i].Draw() - - pad.RedrawAxis() - - if singlepad: - save_canvas( - canvas_single, - f"sig_vs_bkg_{var}_{bin_pt}", - *formats, - dir_output=f"output_{decay}", - ) - - if not singlepad: - save_canvas( - canvas_all, - f"sig_vs_bkg_{var}", - *formats, - dir_output=f"output_{decay}", - ) - - -# TLatex labels of decay channels -labels = {"d0": "D^{0} #rightarrow #pi K", "lc": "#Lambda^{+}_{c} #rightarrow p K #pi"} - -# general settings -gROOT.SetBatch(True) -gStyle.SetOptStat(0) -gStyle.SetPalette(0) -gStyle.SetFrameFillColor(0) - -# text attributes -textfont = 42 -textsize = 0.05 -labelsize = 0.05 - -# plotting range -margin_low = 0.05 -margin_high = 0.14 - -# canvas settings -gStyle.SetCanvasColor(0) -gStyle.SetPadLeftMargin(0.1) -gStyle.SetPadBottomMargin(0.12) -gStyle.SetPadRightMargin(0.05) -gStyle.SetPadTopMargin(0.1) -singlepad = False # make one canvas per pT bin - -# legend settings -gStyle.SetLegendFillColor(0) -# gStyle.SetLegendBorderSize(0) -gStyle.SetLegendFont(textfont) -gStyle.SetLegendTextSize(textsize) - -formats = ["pdf", "png", "root"] # output file formats -normalise = True -rebin = 1 - -path_file_sig = "../codeHF/AnalysisResults_O2.root" -path_file_bkg = "../codeHF/AnalysisResults_O2.root" - -# variables = ["d0Prong0", "d0Prong1", "d0Prong2", "PtProng0", "PtProng1", "PtProng2", "CPA", "Eta", "Declength"] -variables = ["CPA", "Pt", "Eta"] - -decays = ["d0"] - -main() diff --git a/FirstAnalysis/trackingstudies.py b/FirstAnalysis/trackingstudies.py deleted file mode 100644 index 4c03b7d7..00000000 --- a/FirstAnalysis/trackingstudies.py +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/env python -from ROOT import TCanvas, TFile, TLegend, gStyle - - -def saveCanvas(canvas, title): - format_list = ["png", ".pdf", ".root"] - for fileFormat in format_list: - canvas.SaveAs(title + fileFormat) - - -# superimposed reco and gen distributions per specie -def specie_distribution(had, var): - fileo2 = TFile("../codeHF/AnalysisResults_O2.root") - gStyle.SetOptStat(0) - cpt = TCanvas("cpt", "pT distribution") - cpt.SetCanvasSize(1500, 700) - cpt.Divide(2, 1) - hnum = fileo2.Get("qa-tracking-efficiency-%s/%s/num" % (had, var)) - hden = fileo2.Get("qa-tracking-efficiency-%s/%s/den" % (had, var)) - hden.Rebin(4) - hnum.Rebin(4) - hnum.SetLineColor(6) - hden.GetYaxis().SetRangeUser( - 0.7 * hnum.GetBinContent(hden.GetMinimumBin()), - 1.3 * hden.GetBinContent(hden.GetMaximumBin()), - ) - hden.Draw() - hnum.Draw("same") - hden.SetTitle("%s tracks %s distribution" % (had, var)) - leg = TLegend(0.7, 0.7, 0.9, 0.9, "") - leg.SetFillColor(0) - leg.AddEntry(hnum, "Rec. Level") - leg.AddEntry(hden, "Gen. Level") - leg.Draw() - saveCanvas(cpt, "%sdistribution_hfcand%s" % (var, had)) - - -def multiplicity(): - fileo2 = TFile("../codeHF/AnalysisResults_O2.root") - cmult = TCanvas("cmult", "mult distribution") - cmult.SetCanvasSize(1500, 700) - cmult.SetLogy() - cmult.Divide(2, 1) - hmult = fileo2.Get("qa-global-observables/multiplicity/numberOfTracks") - hmult.Rebin(4) - hmult.Draw() - hmult.SetTitle("Multiplicity Distribution") - saveCanvas(cmult, "multiplicity") - - -def var_tracking(var): - fileo2 = TFile("../codeHF/AnalysisResults_O2.root") - cvar = TCanvas("cvar", "var distribution") - cvar.SetCanvasSize(1800, 800) - cvar.Divide(2, 1) - hvar = fileo2.Get("qa-tracking-kine/tracking/%s" % var) - hvar.Rebin(4) - hvar.Draw() - saveCanvas(cvar, "tracking_%s" % var) - - -def tracking_resolution(var1, mode, var2, var3): - fileo2 = TFile("../codeHF/AnalysisResults_O2.root") - cres = TCanvas("cres", "resolution distribution") - cres.SetCanvasSize(1500, 700) - if var1 == "eta": - heta = fileo2.Get("qa-tracking-resolution/eta/etaDiffMCRecoVsEta%s" % mode) - heta.Draw("coltz") - heta.SetTitle("%s resolution" % var1) - saveCanvas(cres, "Resolution_%s_%s" % (var1, var2)) - - if var1 == "impactParameter": - himp_par = fileo2.Get( - "qa-tracking-resolution/%s/%s%sVs%s" % (var1, var1, var2, var3) - ) - himp_par.Draw("coltz") - himp_par.SetTitle("Impact Parameter resolution: %s Vs %s" % (var2, var3)) - saveCanvas(cres, "impact_parameter_resolution%sVs%s" % (var2, var3)) - if var1 == "impactParameterError": - himp_par_err = fileo2.Get( - "qa-tracking-resolution/impactParameter/%s%sVs%s" % (var1, var2, var3) - ) - himp_par_err.Draw("coltz") - himp_par_err.SetTitle( - "Impact Parameter Error resolution: %s Vs %s" % (var2, var3) - ) - saveCanvas(cres, "impactParameterError_resolution%sVs%s" % (var2, var3)) - if var1 == "phi": - hphi = fileo2.Get("qa-tracking-resolution/phi/phiDiffMCRec") - hphi.Draw() - saveCanvas(cres, "phi_resolution") - - if var1 == "pt": - h_pt = fileo2.Get("qa-tracking-resolution/pt/ptResolutionVs%s" % var2) - h_pt.Draw("coltz") - saveCanvas(cres, "ptResolutionVs%s" % var2) - - -def vertex_distributions(var): - fileo2 = TFile("../codeHF/AnalysisResults_O2.root") - cvertex = TCanvas("cvertex", "vertex ") - cvertex.SetCanvasSize(1800, 700) - cvertex.Divide(2, 1) - hvertex = fileo2.Get("qa-global-observables/collision/%s" % var) - cvertex.cd(1) - hvertex.Draw() - hvertex_res = fileo2.Get("qa-global-observables/collision/%svsNContrib" % var) - cvertex.cd(2) - hvertex_res.Draw("coltz") - saveCanvas(cvertex, "vertex_%s" % var) - - -multiplicity() -specie_list = ["pion", "proton", "kaon", "electron", "muon"] -var_list = ["pt", "eta", "phi"] -for specie in specie_list: - for var in var_list: - specie_distribution(specie, var) - -vertex_coord_list = ["X", "Y", "Z"] -for coord in vertex_coord_list: - vertex_distributions(coord) - -for var in var_list: - var_tracking(var) - -var1_list = ["RPhi", "Z"] -var2_list = ["Pt", "Phi", "Eta"] -tracking_resolution("eta", "MC", "", "") -tracking_resolution("pt", "", "Eta", "") -for var1 in var1_list: - for var2 in var2_list: - tracking_resolution("impactParameter", "MC", var1, var2) - tracking_resolution("impactParameterError", "MC", var1, var2) diff --git a/Upgrade/InputsExp/Chic1_ptdep_pp14p0_absy1p44_MIDECAL/AnalysisResults_O2_ONIAX.root b/Upgrade/InputsExp/Chic1_ptdep_pp14p0_absy1p44_MIDECAL/AnalysisResults_O2_ONIAX.root deleted file mode 100644 index e307a0af..00000000 Binary files a/Upgrade/InputsExp/Chic1_ptdep_pp14p0_absy1p44_MIDECAL/AnalysisResults_O2_ONIAX.root and /dev/null differ diff --git a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_RICH3sigma/BkgperEvents.root b/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_RICH3sigma/BkgperEvents.root deleted file mode 100644 index e0869a0b..00000000 Binary files a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_RICH3sigma/BkgperEvents.root and /dev/null differ diff --git a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_RICH3sigma/eff.root b/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_RICH3sigma/eff.root deleted file mode 100644 index b5d39f39..00000000 Binary files a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_RICH3sigma/eff.root and /dev/null differ diff --git a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_RICH3sigma/efficiencies.root b/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_RICH3sigma/efficiencies.root deleted file mode 100644 index b5d39f39..00000000 Binary files a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_RICH3sigma/efficiencies.root and /dev/null differ diff --git a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_noRICH/BkgperEvents.root b/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_noRICH/BkgperEvents.root deleted file mode 100644 index af53543a..00000000 Binary files a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_noRICH/BkgperEvents.root and /dev/null differ diff --git a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_noRICH/eff.root b/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_noRICH/eff.root deleted file mode 100644 index 2286453f..00000000 Binary files a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_noRICH/eff.root and /dev/null differ diff --git a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_noRICH/efficiencies.root b/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_noRICH/efficiencies.root deleted file mode 100644 index 2286453f..00000000 Binary files a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_noRICH/efficiencies.root and /dev/null differ diff --git a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy2p0_scenario3/bkgperevent.root b/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy2p0_scenario3/bkgperevent.root deleted file mode 100644 index 9b709296..00000000 Binary files a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy2p0_scenario3/bkgperevent.root and /dev/null differ diff --git a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy2p0_scenario3/efficiencies.root b/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy2p0_scenario3/efficiencies.root deleted file mode 100644 index b82ae764..00000000 Binary files a/Upgrade/InputsExp/Jpsi_ptdep_pp14p0_absy2p0_scenario3/efficiencies.root and /dev/null differ diff --git a/Upgrade/InputsExp/Lc_ptdep_pp14p0_absy3p0_scenario3/bkgperevent.root b/Upgrade/InputsExp/Lc_ptdep_pp14p0_absy3p0_scenario3/bkgperevent.root deleted file mode 100644 index ec3d4b84..00000000 Binary files a/Upgrade/InputsExp/Lc_ptdep_pp14p0_absy3p0_scenario3/bkgperevent.root and /dev/null differ diff --git a/Upgrade/InputsExp/Lc_ptdep_pp14p0_absy3p0_scenario3/efficiencies.root b/Upgrade/InputsExp/Lc_ptdep_pp14p0_absy3p0_scenario3/efficiencies.root deleted file mode 100644 index 788c8b2b..00000000 Binary files a/Upgrade/InputsExp/Lc_ptdep_pp14p0_absy3p0_scenario3/efficiencies.root and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/background_counts_decL_omegac_high.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/background_counts_decL_omegac_high.pdf deleted file mode 100644 index 68b66698..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/background_counts_decL_omegac_high.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/background_counts_decL_omegac_low.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/background_counts_decL_omegac_low.pdf deleted file mode 100644 index 455c985d..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/background_counts_decL_omegac_low.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/background_counts_decL_omegac_mid.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/background_counts_decL_omegac_mid.pdf deleted file mode 100644 index e8bdbd3d..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/background_counts_decL_omegac_mid.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/efficiency_decL_omegac_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/efficiency_decL_omegac_withSpecialCuts.pdf deleted file mode 100644 index 658bf905..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/efficiency_decL_omegac_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/generated_pt_distribution.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/generated_pt_distribution.pdf deleted file mode 100644 index bc787464..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/generated_pt_distribution.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/generated_rapidity_distribution.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/generated_rapidity_distribution.pdf deleted file mode 100644 index b53c46c8..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/generated_rapidity_distribution.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_background_decL_omegac_high_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_background_decL_omegac_high_withSpecialCuts.pdf deleted file mode 100644 index 3f4725fa..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_background_decL_omegac_high_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_background_decL_omegac_low_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_background_decL_omegac_low_withSpecialCuts.pdf deleted file mode 100644 index ac54bac5..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_background_decL_omegac_low_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_background_decL_omegac_mid_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_background_decL_omegac_mid_withSpecialCuts.pdf deleted file mode 100644 index c08644ca..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_background_decL_omegac_mid_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_signal_high.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_signal_high.pdf deleted file mode 100644 index ef9140ee..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_signal_high.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_signal_low.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_signal_low.pdf deleted file mode 100644 index cddd9741..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_signal_low.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_signal_mid.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_signal_mid.pdf deleted file mode 100644 index 4d0490bf..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/mass_signal_mid.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/minv_signal_fit_decL_omegac_high.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/minv_signal_fit_decL_omegac_high.pdf deleted file mode 100644 index f42165cf..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/minv_signal_fit_decL_omegac_high.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/minv_signal_fit_decL_omegac_low.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/minv_signal_fit_decL_omegac_low.pdf deleted file mode 100644 index 102ce4b9..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/minv_signal_fit_decL_omegac_low.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/minv_signal_fit_decL_omegac_mid.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/minv_signal_fit_decL_omegac_mid.pdf deleted file mode 100644 index 58e3ab9f..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/minv_signal_fit_decL_omegac_mid.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/reconstruction_decL_omegac_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/reconstruction_decL_omegac_withSpecialCuts.pdf deleted file mode 100644 index b857c6b9..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/reconstruction_decL_omegac_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/signif_estimate_shm_coal_omegacc_decL_omegac.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/signif_estimate_shm_coal_omegacc_decL_omegac.pdf deleted file mode 100644 index 715d51e0..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/signif_estimate_shm_coal_omegacc_decL_omegac.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/tablecuts_trial_decL_omegac_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/tablecuts_trial_decL_omegac_withSpecialCuts.pdf deleted file mode 100644 index e4fd99d8..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_oldLifetime/tablecuts_trial_decL_omegac_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/background_counts_decL_omegac_high.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/background_counts_decL_omegac_high.pdf deleted file mode 100644 index ad90d409..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/background_counts_decL_omegac_high.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/background_counts_decL_omegac_low.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/background_counts_decL_omegac_low.pdf deleted file mode 100644 index 5f03bc7e..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/background_counts_decL_omegac_low.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/background_counts_decL_omegac_mid.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/background_counts_decL_omegac_mid.pdf deleted file mode 100644 index 35928e7f..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/background_counts_decL_omegac_mid.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/efficiency_decL_omegac_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/efficiency_decL_omegac_withSpecialCuts.pdf deleted file mode 100644 index 6f4941cb..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/efficiency_decL_omegac_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/generated_pt_distribution.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/generated_pt_distribution.pdf deleted file mode 100644 index 0a96d522..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/generated_pt_distribution.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/generated_rapidity_distribution.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/generated_rapidity_distribution.pdf deleted file mode 100644 index a143b01b..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/generated_rapidity_distribution.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_background_decL_omegac_high_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_background_decL_omegac_high_withSpecialCuts.pdf deleted file mode 100644 index 6c50d27f..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_background_decL_omegac_high_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_background_decL_omegac_low_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_background_decL_omegac_low_withSpecialCuts.pdf deleted file mode 100644 index 21b1768f..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_background_decL_omegac_low_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_background_decL_omegac_mid_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_background_decL_omegac_mid_withSpecialCuts.pdf deleted file mode 100644 index dfbba17a..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_background_decL_omegac_mid_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_signal_high.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_signal_high.pdf deleted file mode 100644 index 65677978..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_signal_high.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_signal_low.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_signal_low.pdf deleted file mode 100644 index f445a750..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_signal_low.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_signal_mid.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_signal_mid.pdf deleted file mode 100644 index dff3ac22..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/mass_signal_mid.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/minv_signal_fit_decL_omegac_high.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/minv_signal_fit_decL_omegac_high.pdf deleted file mode 100644 index 03b69a08..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/minv_signal_fit_decL_omegac_high.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/minv_signal_fit_decL_omegac_low.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/minv_signal_fit_decL_omegac_low.pdf deleted file mode 100644 index 2305968a..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/minv_signal_fit_decL_omegac_low.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/minv_signal_fit_decL_omegac_mid.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/minv_signal_fit_decL_omegac_mid.pdf deleted file mode 100644 index eb359307..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/minv_signal_fit_decL_omegac_mid.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/reconstruction_decL_omegac_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/reconstruction_decL_omegac_withSpecialCuts.pdf deleted file mode 100644 index 6519d379..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/reconstruction_decL_omegac_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/signif_estimate_shm_coal_omegacc_decL_omegac.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/signif_estimate_shm_coal_omegacc_decL_omegac.pdf deleted file mode 100644 index 98407422..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/signif_estimate_shm_coal_omegacc_decL_omegac.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/significance_estimate_trial_decL_omegac.root b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/significance_estimate_trial_decL_omegac.root deleted file mode 100644 index 4c637ea6..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/significance_estimate_trial_decL_omegac.root and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/tablecuts_trial_decL_omegac_withSpecialCuts.pdf b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/tablecuts_trial_decL_omegac_withSpecialCuts.pdf deleted file mode 100644 index 98114538..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_4_updatedLifetime/tablecuts_trial_decL_omegac_withSpecialCuts.pdf and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_6/significance_estimate_trial_decL_omegac.root b/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_6/significance_estimate_trial_decL_omegac.root deleted file mode 100644 index 0b6dea32..00000000 Binary files a/Upgrade/InputsExp/Omega_cc_aliphysics/decay_length_omegac/trial_6/significance_estimate_trial_decL_omegac.root and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_ccc_aliphysics/README.md b/Upgrade/InputsExp/Omega_ccc_aliphysics/README.md deleted file mode 100644 index 090a0bb6..00000000 --- a/Upgrade/InputsExp/Omega_ccc_aliphysics/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# Omega_{ccc} -Significance estimate - -Introduction -There is a macro which takes in Inputs: -1. generated signal -2. reconstructed signal -3. reconstructed background - -The first two are used to estimate the "efficiency x acceptance" which is one of the ingredient needed to estimate the "raw-signal-per-event". - -The reconstructed background is needed to estimate the "background-per-event". - -Then, the significance/sqrt{events} is computed from the raw-signal-per-event and the background-per-event. - -The goal of the macro is to estimate the significance/sqrt{events} for different trial -The macro works in the following way: -- select the variable you want to study for the trial (e.g. d0(rphi) of Omega_c "d0rphi_omegac_cuts"); -- define inside the macro a set of cut values you want to apply on this variable; -- choose if you want to add an additional set of predefined cuts which are applied in all the trials (e.g. chi2/ndf < 4, cos(pointing angle)>0.99) --> "bool useSpecialCuts = true" to use the pre-defined set of cuts as default; -- then the macro runs over the signal trees (generated and reconstructed) to get the efficiency x acceptance for each trial; -- runs over the background tree to get the background-per-event for each trial; -- compute the raw-signal-per-event using the efficiency x acceptance, the theoretical inputs for dN/dy and the estimated B.R. -- finally computes the significance/sqrt{events} with the expected raw-signal-per-event and the. expected background-per-event -This procedure is done automatically for 3 pT bins: 0-2, 2-4, 4-10 GeV/c. - -Description of the output -For each variable a dedicated directory is created (e.g. d0rphi_omegac_cuts) and there inside all the related trials are stored (e.g. trial_4,5). -Each directory trial_* contains the following files: -- tablecuts_trial_*_*.pdf --> a pdf where all the applied selections are reported. Example: tablecuts_trial_d0rphi_omegac_withSpecialCuts.pdf --> there are some fixed cuts for Omega_c,cc,ccc applied to all the trials and at the bottom the list of the cut values for the trial on the d0(rphi) of Omega_c -- mass_signal_low/mid/high.pdf --> histograms of invariant mass distribution for reconstructed signal. Filled to check that the reconstruction is done properly. -- mass_background_*_*_low/mid/high.pdf --> histograms of invariant mass distribution obtained from the background tree -- minv_signal_fit_*_low/mid/high.pdf --> histograms of invariant mass distribution for reconstructed signal fitted with a gaussian. The width of this gaussian is used to define the +/-3 sigma region around the expected mass value where we take the background counts -- background_counts_*_*_high.pdf --> histograms with invariant mass distribution from background candidates. Here are reported the counts of background in the +/-3 sigma region around the mass peak, which are used to evaluate the background-per-event -- generated_pt/rapidity_distribution.pdf --> generated distributions of mother particle (e.g. Omega_ccc). In particular: - - Gen (top left): distribution with all generated mother particle without any selections - - GenAcc (top right): distribution with all mothers inside the rapidity gap and the daughters inside the pseudorapidity gap - - GenLimAcc (bottom left): distribution with all mothers inside the rapidity gap -- reconstruction_*_*_withSpecialCuts.pdf --> distribution of reconstructed mother particle for the different trial. The label "withSpecialCuts" means that the set of fixed cut is applied. -- efficiency_*_*_withSpecialCuts.pdf --> contains the efficiency and acceptance calculation. In particular: - - RecoCuts/GenAcc --> pure efficiency term - - GenAcc/GenLimAcc --> pure acceptance term - - RecoCuts/GenLimAcc --> efficiency x acceptance, which is used in the raw signal estimate -- signif_estimate_shm_coal_omegaccc_*_*.pdf --> contains the ingredients and the estimate of the significance/sqrt{events}. In particular: - - Raw signal (top left) --> raw signal per event obtained as S = dN/dy x (effXacc) x BR; the dashed line refers to dN/dy from coalescence, while the solid line from SHM; the different colors refer to the different trial (i.e. we estimate the raw signal per event for each trial) - - Background (top right) --> background per event - - Significance/sqrt{event} (bottom left) - - Inputs (bottom right) --> contains the details of the background and the theoretical inputs used in the calculation - -All what described here is referred to the studies for the Omega_ccc, but is also valid for the Omega_cc. - - diff --git a/Upgrade/InputsExp/Omega_ccc_aliphysics/d0rphi_omegac_cuts/trial_4_oldLifetime/significance_estimate_trial_d0rphi_omegac.root b/Upgrade/InputsExp/Omega_ccc_aliphysics/d0rphi_omegac_cuts/trial_4_oldLifetime/significance_estimate_trial_d0rphi_omegac.root deleted file mode 100644 index 7eca1e84..00000000 Binary files a/Upgrade/InputsExp/Omega_ccc_aliphysics/d0rphi_omegac_cuts/trial_4_oldLifetime/significance_estimate_trial_d0rphi_omegac.root and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_ccc_aliphysics/d0rphi_omegac_cuts/trial_5_updatedLifetime/significance_estimate_trial_d0rphi_omegac.root b/Upgrade/InputsExp/Omega_ccc_aliphysics/d0rphi_omegac_cuts/trial_5_updatedLifetime/significance_estimate_trial_d0rphi_omegac.root deleted file mode 100644 index 11e2e80f..00000000 Binary files a/Upgrade/InputsExp/Omega_ccc_aliphysics/d0rphi_omegac_cuts/trial_5_updatedLifetime/significance_estimate_trial_d0rphi_omegac.root and /dev/null differ diff --git a/Upgrade/InputsExp/Omega_ccc_aliphysics/d0rphi_omegac_cuts/trial_6/significance_estimate_trial_d0rphi_omegac.root b/Upgrade/InputsExp/Omega_ccc_aliphysics/d0rphi_omegac_cuts/trial_6/significance_estimate_trial_d0rphi_omegac.root deleted file mode 100644 index e5f70e50..00000000 Binary files a/Upgrade/InputsExp/Omega_ccc_aliphysics/d0rphi_omegac_cuts/trial_6/significance_estimate_trial_d0rphi_omegac.root and /dev/null differ diff --git a/Upgrade/InputsExp/X3872_ptdep_pp14p0_absy1p44_scenario3_noRICH/BkgperEvents.root b/Upgrade/InputsExp/X3872_ptdep_pp14p0_absy1p44_scenario3_noRICH/BkgperEvents.root deleted file mode 100644 index d794b17f..00000000 Binary files a/Upgrade/InputsExp/X3872_ptdep_pp14p0_absy1p44_scenario3_noRICH/BkgperEvents.root and /dev/null differ diff --git a/Upgrade/InputsExp/X3872_ptdep_pp14p0_absy1p44_scenario3_noRICH/eff.root b/Upgrade/InputsExp/X3872_ptdep_pp14p0_absy1p44_scenario3_noRICH/eff.root deleted file mode 100644 index caa73831..00000000 Binary files a/Upgrade/InputsExp/X3872_ptdep_pp14p0_absy1p44_scenario3_noRICH/eff.root and /dev/null differ diff --git a/Upgrade/InputsTheory/Bplus_ptdep_Pyhia8mode2_pp14p0_absy1p44.root b/Upgrade/InputsTheory/Bplus_ptdep_Pyhia8mode2_pp14p0_absy1p44.root deleted file mode 100644 index 666259b2..00000000 Binary files a/Upgrade/InputsTheory/Bplus_ptdep_Pyhia8mode2_pp14p0_absy1p44.root and /dev/null differ diff --git a/Upgrade/InputsTheory/Chic1_ptdep_Pyhia8monash_pp14p0_absy1p44.root b/Upgrade/InputsTheory/Chic1_ptdep_Pyhia8monash_pp14p0_absy1p44.root deleted file mode 100644 index 614eeccf..00000000 Binary files a/Upgrade/InputsTheory/Chic1_ptdep_Pyhia8monash_pp14p0_absy1p44.root and /dev/null differ diff --git a/Upgrade/InputsTheory/Jpsi_ptdep_Pyhia8monash_pp14p0_absy1p44.root b/Upgrade/InputsTheory/Jpsi_ptdep_Pyhia8monash_pp14p0_absy1p44.root deleted file mode 100644 index efc64462..00000000 Binary files a/Upgrade/InputsTheory/Jpsi_ptdep_Pyhia8monash_pp14p0_absy1p44.root and /dev/null differ diff --git a/Upgrade/InputsTheory/Lambda_c_ptdep_Pyhia8mode2_pp14p0_absy1p44.root b/Upgrade/InputsTheory/Lambda_c_ptdep_Pyhia8mode2_pp14p0_absy1p44.root deleted file mode 100644 index 3ce46d94..00000000 Binary files a/Upgrade/InputsTheory/Lambda_c_ptdep_Pyhia8mode2_pp14p0_absy1p44.root and /dev/null differ diff --git a/Upgrade/InputsTheory/Lambda_c_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv b/Upgrade/InputsTheory/Lambda_c_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv deleted file mode 100644 index 01f04bc1..00000000 --- a/Upgrade/InputsTheory/Lambda_c_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv +++ /dev/null @@ -1,26 +0,0 @@ -pt,cross -0.0, 3.17E-01 -0.3, 3.27E-01 -0.6, 3.21E-01 -0.9, 2.99E-01 -1.2, 2.61E-01 -1.5, 2.11E-01 -1.8, 1.56E-01 -2.1, 1.07E-01 -2.4, 6.75E-02 -2.7, 3.92E-02 -3.0, 2.16E-02 -3.3, 1.17E-02 -3.6, 6.61E-03 -3.9, 3.91E-03 -4.2, 2.41E-03 -4.5, 1.51E-03 -4.8, 9.59E-04 -5.1, 6.14E-04 -5.4, 3.96E-04 -5.7, 2.59E-04 -6.0, 1.72E-04 -6.5, 8.97E-05 -7.0, 4.95E-05 -7.5, 2.88E-05 -8.0, 1.77E-05 diff --git a/Upgrade/InputsTheory/Omega_cc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv b/Upgrade/InputsTheory/Omega_cc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv deleted file mode 100644 index f80ffd07..00000000 --- a/Upgrade/InputsTheory/Omega_cc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv +++ /dev/null @@ -1,26 +0,0 @@ -pt,cross -0.0, 0.00006646310783540042 -0.3, 0.00006646310783540042 -0.6, 0.00006404004271197282 -0.9, 0.00006170531598835199 -1.2, 0.000057288112837756064 -1.5, 0.00004937969317714344 -1.8, 0.00004256300264549499 -2.1, 0.000035349811050301094 -2.4, 0.000028288694346259665 -2.7, 0.000021017480113324872 -3.0, 0.000015045941012517134 -3.3, 0.000010378367193526983 -3.6, 0.000006404004271197283 -3.9, 0.0000039516110714498495 -4.2, 0.000002263803409521451 -4.5, 0.0000012496091412919893 -4.8, 6.646310783540055e-7 -5.1, 3.5349811050301095e-7 -5.4, 2.0251239642430092e-7 -5.7, 1.1178591777554069e-7 -6.0, 6.404004271197296e-8 -6.5, 2.7257365073673226e-8 -7.0, 1.2496091412919918e-8 -7.5, 5.945570708544431e-9 -8.0, 2.8288694346259783e-9 diff --git a/Upgrade/InputsTheory/Omega_ccc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv b/Upgrade/InputsTheory/Omega_ccc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv deleted file mode 100644 index 467143ed..00000000 --- a/Upgrade/InputsTheory/Omega_ccc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv +++ /dev/null @@ -1,26 +0,0 @@ -pt,cross -0.0, 1.90E-07 -0.3, 1.89E-07 -0.6, 1.87E-07 -0.9, 1.83E-07 -1.2, 1.76E-07 -1.5, 1.67E-07 -1.8, 1.55E-07 -2.1, 1.40E-07 -2.4, 1.24E-07 -2.7, 1.06E-07 -3.0, 8.74E-08 -3.3, 6.97E-08 -3.6, 5.33E-08 -3.9, 3.91E-08 -4.2, 2.75E-08 -4.5, 1.84E-08 -4.8, 1.18E-08 -5.1, 7.30E-09 -5.4, 4.34E-09 -5.7, 2.51E-09 -6.0, 1.43E-09 -6.5, 5.61E-10 -7.0, 2.27E-10 -7.5, 9.76E-11 -8.0, 4.49E-11 diff --git a/Upgrade/InputsTheory/X3872_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv b/Upgrade/InputsTheory/X3872_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv deleted file mode 100644 index bc0dc7e2..00000000 --- a/Upgrade/InputsTheory/X3872_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv +++ /dev/null @@ -1,26 +0,0 @@ -pt,cross -0.0, 0.0000168 -0.3, 0.0000162 -0.6, 0.0000162 -0.9, 0.0000156 -1.2, 0.0000145 -1.5, 0.0000140 -1.8, 0.0000125 -2.1, 0.0000108 -2.4, 0.00000928 -2.7, 0.00000715 -3.0, 0.00000551 -3.3, 0.00000394 -3.6, 0.00000271 -3.9, 0.00000180 -4.2, 0.00000107 -4.5, 6.10e-7 -4.8, 3.62e-7 -5.1, 1.99e-7 -5.4, 1.14e-7 -5.7, 6.76e-8 -6, 4.01e-8 -6.5, 1.64e-8 -7.0, 7.49e-9 -7.5, 3.55e-9 -8.0, 1.74e-9 diff --git a/Upgrade/InputsTheory/Xi_cc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv b/Upgrade/InputsTheory/Xi_cc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv deleted file mode 100644 index 0ed871bc..00000000 --- a/Upgrade/InputsTheory/Xi_cc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5.csv +++ /dev/null @@ -1,26 +0,0 @@ -pt,cross -0.0, 3.21E-04 -0.3, 3.19E-04 -0.6, 3.13E-04 -0.9, 3.02E-04 -1.2, 2.84E-04 -1.5, 2.58E-04 -1.8, 2.28E-04 -2.1, 1.91E-04 -2.4, 1.54E-04 -2.7, 1.17E-04 -3.0, 8.46E-05 -3.3, 5.73E-05 -3.6, 3.66E-05 -3.9, 2.21E-05 -4.2, 1.27E-05 -4.5, 7.13E-06 -4.8, 3.97E-06 -5.1, 2.25E-06 -5.4, 1.31E-06 -5.7, 7.83E-07 -6.0, 4.84E-07 -6.5, 2.31E-07 -7.0, 1.17E-07 -7.5, 6.15E-08 -8.0, 3.32E-08 diff --git a/Upgrade/InputsTheory/charm_sys_SHMC.txt b/Upgrade/InputsTheory/charm_sys_SHMC.txt deleted file mode 100644 index 7c975907..00000000 --- a/Upgrade/InputsTheory/charm_sys_SHMC.txt +++ /dev/null @@ -1,238 +0,0 @@ - -SHMC, 18.01.2021 (dN/dy, mass, 2J+1) - -n C=1, C=2, C=3 (part.only): 8.776e-05 3.395e-09 1.118e-12 * n_cc: 4.822e-08 - -System: Pb-Pb, V: 4997 -sigma_ccbar: 0.532, Ncc_dir: 13.05 => gc: 29.84 -In/I0 (26.17) C=1,2,3: 9.807e-01 9.251e-01 8.393e-01 - D^{0} 6.063e+00 1.865 1 - D^{+} 2.685e+00 1.869 1 - D^{*+} 2.373e+00 2.010 3 - D_{s}^{+} 2.164e+00 1.968 1 - #Lambda_{c}^{+} 1.312e+00 2.287 2 - #Sigma_{c}^{0} 1.429e-01 2.454 2 - #Xi_{c}^{0} 2.653e-01 2.470 2 - #Omega_{c}^{0} 5.680e-02 2.695 2 - c-d 1.613e-03 3.225 3 - c-t 3.893e-06 4.162 2 - X(2900) 3.657e-03 2.900 1 - J/#psi 1.096e-01 3.097 3 - #psi(2S) 3.083e-03 3.686 3 - #chi_{c1} 8.824e-03 3.511 3 - X(3872) 2.807e-03 3.843 7 - P_{c}(4320) 6.243e-05 4.380 4 - #Xi_{cc}^{+} 5.672e-03 3.620 4 - #Omega_{cc}^{+} 2.663e-03 3.746 4 -#Omega_{ccc}^{++} 1.246e-04 4.797 4 - -System: Xe-Xe, V: 3171 -sigma_ccbar: 0.532, Ncc_dir: 6.91 => gc: 25.38 -In/I0 (14.12) C=1,2,3: 9.639e-01 8.635e-01 7.194e-01 - D^{0} 3.216e+00 1.865 1 - D^{+} 1.424e+00 1.869 1 - D^{*+} 1.259e+00 2.010 3 - D_{s}^{+} 1.148e+00 1.968 1 - #Lambda_{c}^{+} 6.961e-01 2.287 2 - #Sigma_{c}^{0} 7.580e-02 2.454 2 - #Xi_{c}^{0} 1.407e-01 2.470 2 - #Omega_{c}^{0} 3.013e-02 2.695 2 - c-d 8.556e-04 3.225 3 - c-t 2.065e-06 4.162 2 - X(2900) 1.940e-03 2.900 1 - J/#psi 5.029e-02 3.097 3 - #psi(2S) 1.415e-03 3.686 3 - #chi_{c1} 4.049e-03 3.511 3 - X(3872) 1.288e-03 3.843 7 - P_{c}(4320) 2.865e-05 4.380 4 - #Xi_{cc}^{+} 2.430e-03 3.620 4 - #Omega_{cc}^{+} 1.141e-03 3.746 4 -#Omega_{ccc}^{++} 4.167e-05 4.797 4 - -System: Kr-Kr, V: 2018 -sigma_ccbar: 0.532, Ncc_dir: 3.62 => gc: 21.65 -In/I0 (7.67) C=1,2,3: 9.323e-01 7.568e-01 5.375e-01 - D^{0} 1.689e+00 1.865 1 - D^{+} 7.479e-01 1.869 1 - D^{*+} 6.611e-01 2.010 3 - D_{s}^{+} 6.028e-01 1.968 1 - #Lambda_{c}^{+} 3.655e-01 2.287 2 - #Sigma_{c}^{0} 3.980e-02 2.454 2 - #Xi_{c}^{0} 7.389e-02 2.470 2 - #Omega_{c}^{0} 1.582e-02 2.695 2 - c-d 4.493e-04 3.225 3 - c-t 1.084e-06 4.162 2 - X(2900) 1.019e-03 2.900 1 - J/#psi 2.330e-02 3.097 3 - #psi(2S) 6.554e-04 3.686 3 - #chi_{c1} 1.876e-03 3.511 3 - X(3872) 5.966e-04 3.843 7 - P_{c}(4320) 1.327e-05 4.380 4 - #Xi_{cc}^{+} 9.865e-04 3.620 4 - #Omega_{cc}^{+} 4.632e-04 3.746 4 -#Omega_{ccc}^{++} 1.231e-05 4.797 4 - -System: Ar-Ar, V: 961 -sigma_ccbar: 0.532, Ncc_dir: 1.26 => gc: 18.10 -In/I0 (3.05) C=1,2,3: 8.138e-01 4.668e-01 2.021e-01 - D^{0} 5.868e-01 1.865 1 - D^{+} 2.598e-01 1.869 1 - D^{*+} 2.297e-01 2.010 3 - D_{s}^{+} 2.095e-01 1.968 1 - #Lambda_{c}^{+} 1.270e-01 2.287 2 - #Sigma_{c}^{0} 1.383e-02 2.454 2 - #Xi_{c}^{0} 2.567e-02 2.470 2 - #Omega_{c}^{0} 5.497e-03 2.695 2 - c-d 1.561e-04 3.225 3 - c-t 3.767e-07 4.162 2 - X(2900) 3.540e-04 2.900 1 - J/#psi 7.752e-03 3.097 3 - #psi(2S) 2.181e-04 3.686 3 - #chi_{c1} 6.241e-04 3.511 3 - X(3872) 1.985e-04 3.843 7 - P_{c}(4320) 4.416e-06 4.380 4 - #Xi_{cc}^{+} 2.024e-04 3.620 4 - #Omega_{cc}^{+} 9.505e-05 3.746 4 -#Omega_{ccc}^{++} 1.287e-06 4.797 4 - -System: O-O, V: 384 -sigma_ccbar: 0.532, Ncc_dir: 0.33 => gc: 18.46 -In/I0 (1.25) C=1,2,3: 5.265e-01 1.542e-01 3.102e-02 - D^{0} 1.549e-01 1.865 1 - D^{+} 6.858e-02 1.869 1 - D^{*+} 6.062e-02 2.010 3 - D_{s}^{+} 5.528e-02 1.968 1 - #Lambda_{c}^{+} 3.352e-02 2.287 2 - #Sigma_{c}^{0} 3.650e-03 2.454 2 - #Xi_{c}^{0} 6.775e-03 2.470 2 - #Omega_{c}^{0} 1.451e-03 2.695 2 - c-d 4.120e-05 3.225 3 - c-t 9.943e-08 4.162 2 - X(2900) 9.342e-05 2.900 1 - J/#psi 3.225e-03 3.097 3 - #psi(2S) 9.071e-05 3.686 3 - #chi_{c1} 2.596e-04 3.511 3 - X(3872) 8.257e-05 3.843 7 - P_{c}(4320) 1.837e-06 4.380 4 - #Xi_{cc}^{+} 2.783e-05 3.620 4 - #Omega_{cc}^{+} 1.306e-05 3.746 4 -#Omega_{ccc}^{++} 8.380e-08 4.797 4 - - -*** sigma_ccbar +18% -> 0.628 mb *** - -System: Pb-Pb, V: 4997 -sigma_ccbar: 0.628, Ncc_dir: 15.40 => gc: 35.03 -In/I0 (30.72) C=1,2,3: 9.836e-01 9.360e-01 8.617e-01 - D^{0} 7.137e+00 1.865 1 - D^{+} 3.161e+00 1.869 1 - D^{*+} 2.794e+00 2.010 3 - D_{s}^{+} 2.548e+00 1.968 1 - #Lambda_{c}^{+} 1.545e+00 2.287 2 - #Sigma_{c}^{0} 1.682e-01 2.454 2 - #Xi_{c}^{0} 3.123e-01 2.470 2 - #Omega_{c}^{0} 6.686e-02 2.695 2 - c-d 1.899e-03 3.225 3 - c-t 4.583e-06 4.162 2 - X(2900) 4.306e-03 2.900 1 - J/#psi 1.510e-01 3.097 3 - #psi(2S) 4.248e-03 3.686 3 - #chi_{c1} 1.216e-02 3.511 3 - X(3872) 3.866e-03 3.843 7 - P_{c}(4320) 8.601e-05 4.380 4 - #Xi_{cc}^{+} 7.907e-03 3.620 4 - #Omega_{cc}^{+} 3.712e-03 3.746 4 -#Omega_{ccc}^{++} 2.069e-04 4.797 4 - -System: Xe-Xe, V: 3171 -sigma_ccbar: 0.628, Ncc_dir: 8.15 => gc: 29.72 -In/I0 (16.54) C=1,2,3: 9.693e-01 8.828e-01 7.558e-01 - D^{0} 3.787e+00 1.865 1 - D^{+} 1.677e+00 1.869 1 - D^{*+} 1.483e+00 2.010 3 - D_{s}^{+} 1.352e+00 1.968 1 - #Lambda_{c}^{+} 8.198e-01 2.287 2 - #Sigma_{c}^{0} 8.927e-02 2.454 2 - #Xi_{c}^{0} 1.657e-01 2.470 2 - #Omega_{c}^{0} 3.548e-02 2.695 2 - c-d 1.008e-03 3.225 3 - c-t 2.432e-06 4.162 2 - X(2900) 2.285e-03 2.900 1 - J/#psi 6.898e-02 3.097 3 - #psi(2S) 1.941e-03 3.686 3 - #chi_{c1} 5.554e-03 3.511 3 - X(3872) 1.766e-03 3.843 7 - P_{c}(4320) 3.930e-05 4.380 4 - #Xi_{cc}^{+} 3.407e-03 3.620 4 - #Omega_{cc}^{+} 1.600e-03 3.746 4 -#Omega_{ccc}^{++} 7.033e-05 4.797 4 - -System: Kr-Kr, V: 2018 -sigma_ccbar: 0.628, Ncc_dir: 4.27 => gc: 25.24 -In/I0 (8.94) C=1,2,3: 9.423e-01 7.892e-01 5.891e-01 - D^{0} 1.990e+00 1.865 1 - D^{+} 8.811e-01 1.869 1 - D^{*+} 7.789e-01 2.010 3 - D_{s}^{+} 7.103e-01 1.968 1 - #Lambda_{c}^{+} 4.307e-01 2.287 2 - #Sigma_{c}^{0} 4.690e-02 2.454 2 - #Xi_{c}^{0} 8.706e-02 2.470 2 - #Omega_{c}^{0} 1.864e-02 2.695 2 - c-d 5.293e-04 3.225 3 - c-t 1.278e-06 4.162 2 - X(2900) 1.200e-03 2.900 1 - J/#psi 3.166e-02 3.097 3 - #psi(2S) 8.906e-04 3.686 3 - #chi_{c1} 2.549e-03 3.511 3 - X(3872) 8.107e-04 3.843 7 - P_{c}(4320) 1.803e-05 4.380 4 - #Xi_{cc}^{+} 1.398e-03 3.620 4 - #Omega_{cc}^{+} 6.563e-04 3.746 4 -#Omega_{ccc}^{++} 2.137e-05 4.797 4 - -System: Ar-Ar, V: 961 -sigma_ccbar: 0.628, Ncc_dir: 1.48 => gc: 20.66 -In/I0 (3.48) C=1,2,3: 8.403e-01 5.177e-01 2.460e-01 - D^{0} 6.917e-01 1.865 1 - D^{+} 3.063e-01 1.869 1 - D^{*+} 2.708e-01 2.010 3 - D_{s}^{+} 2.469e-01 1.968 1 - #Lambda_{c}^{+} 1.497e-01 2.287 2 - #Sigma_{c}^{0} 1.630e-02 2.454 2 - #Xi_{c}^{0} 3.027e-02 2.470 2 - #Omega_{c}^{0} 6.480e-03 2.695 2 - c-d 1.840e-04 3.225 3 - c-t 4.441e-07 4.162 2 - X(2900) 4.173e-04 2.900 1 - J/#psi 1.010e-02 3.097 3 - #psi(2S) 2.843e-04 3.686 3 - #chi_{c1} 8.135e-04 3.511 3 - X(3872) 2.587e-04 3.843 7 - P_{c}(4320) 5.756e-06 4.380 4 - #Xi_{cc}^{+} 2.927e-04 3.620 4 - #Omega_{cc}^{+} 1.374e-04 3.746 4 -#Omega_{ccc}^{++} 2.332e-06 4.797 4 - -System: O-O, V: 384 -sigma_ccbar: 0.628, Ncc_dir: 0.39 => gc: 20.35 -In/I0 (1.37) C=1,2,3: 5.632e-01 1.797e-01 3.962e-02 - D^{0} 1.827e-01 1.865 1 - D^{+} 8.090e-02 1.869 1 - D^{*+} 7.152e-02 2.010 3 - D_{s}^{+} 6.522e-02 1.968 1 - #Lambda_{c}^{+} 3.954e-02 2.287 2 - #Sigma_{c}^{0} 4.306e-03 2.454 2 - #Xi_{c}^{0} 7.993e-03 2.470 2 - #Omega_{c}^{0} 1.711e-03 2.695 2 - c-d 4.860e-05 3.225 3 - c-t 1.173e-07 4.162 2 - X(2900) 1.102e-04 2.900 1 - J/#psi 3.923e-03 3.097 3 - #psi(2S) 1.103e-04 3.686 3 - #chi_{c1} 3.158e-04 3.511 3 - X(3872) 1.004e-04 3.843 7 - P_{c}(4320) 2.234e-06 4.380 4 - #Xi_{cc}^{+} 3.945e-05 3.620 4 - #Omega_{cc}^{+} 1.852e-05 3.746 4 -#Omega_{ccc}^{++} 1.436e-07 4.797 4 - diff --git a/Upgrade/InputsTheory/x3872_ptdep_PbPb5TeV_absy1p44.root b/Upgrade/InputsTheory/x3872_ptdep_PbPb5TeV_absy1p44.root deleted file mode 100644 index 18bee3df..00000000 Binary files a/Upgrade/InputsTheory/x3872_ptdep_PbPb5TeV_absy1p44.root and /dev/null differ diff --git a/Upgrade/InputsTheory/x3872_ptdep_Pyhia8monash_pp14p0_absy1p44.root b/Upgrade/InputsTheory/x3872_ptdep_Pyhia8monash_pp14p0_absy1p44.root deleted file mode 100644 index a8fb630e..00000000 Binary files a/Upgrade/InputsTheory/x3872_ptdep_Pyhia8monash_pp14p0_absy1p44.root and /dev/null differ diff --git a/Upgrade/README.md b/Upgrade/README.md deleted file mode 100644 index 93ad9510..00000000 --- a/Upgrade/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# ALICE3 HF performance studies - -## Introduction - -The purpose of this repository is to collect the macros and utilities to study the performances of the ALICE3 detector with heavy-flavoured hadrons, including charmed and beauty hadrons, HF jets and quarkonia. For these studies, the ALICE3 detector setup is simulated using the [DelphesO2](https://github.com/AliceO2Group/DelphesO2) package, while the heavy-flavour reconstruction is performed using the [O2](https://github.com/AliceO2Group/AliceO2) analysis framework. - -## Overview - -The repository now contains the following subfolders: - -### InputTheory -This folder contains pT-dependent predictions for charmed and multi-charm baryons, which are used to estimate the expected signal yields of each hadron. In particular: -* predictions in csv format from the coalescence calculations based on arXiv.1907.12786 in PbPb collisions at 2.76 TeV. These inputs can be converted in ROOT histograms by using the following [script](https://github.com/AliceUpgrades/ALICE3_HFperformance/blob/main/analysis/read_predictions_ptdep_stat_cholee_2_pbpb2p76_absy0p5.py), as discussed later. -* predictions for the Λc baryons in pp collisions from Pythia 8. - -### InputExp -This folder contains the experimental inputs for performing significance estimations for the different hadrons in both pp and AA collisions. -The name of the folder indicates whether these studies were performed with aliphysics or with the O2 simulation and analysis framework. Each folder typically contains: -* a histogram with the background content within 3 sigma from the peak mean normalized by the number of events extracted in MB Monte Carlo simulations -* a histogram with the efficiencies for each channel. - -### analysis -In this folder, we collect all the analysis macros for performing the final analyses and plots. In particular: -* The [script](https://github.com/AliceUpgrades/ALICE3_HFperformance/blob/main/analysis/read_predictions_ptdep_stat_cholee_2_pbpb2p76_absy0p5.py) already introduced above to convert the cvs predictions from arXiv.1907.12786 to ROOT histograms (the ROOT files are not pushed into the repository, but one needs to generate them when needed). -* A [script](https://github.com/AliceUpgrades/ALICE3_HFperformance/blob/main/analysis/expected_yields.py) to perform the comparison of the expected yields of charmed and multi-charmed hadrons in AA collisions. Few remarks: - * For the moment, we consider for each theoretical calculation the same pT-shape. We indeed consider the normalized pT-spectrum from arXiv.1907.12786 and we just multiply it for the expected dN/dy provided by each theory group (collected [here](https://github.com/AliceUpgrades/ALICE3_HFperformance/blob/main/analysis/databases/theory_yields.yaml)). - * Make sure you run the script descrive in the bullet above in advance in order to generate the ROOT histograms needed for the comparison. -* A [script](https://github.com/AliceUpgrades/ALICE3_HFperformance/blob/main/analysis/significance.py) that performs the significance estimation as a function of pT (currently working only for Λc baryons in pp collisions). The parameters needed are read from the following two databases, [significance.yaml](https://github.com/AliceUpgrades/ALICE3_HFperformance/blob/main/analysis/databases/significance.yaml) and [general.yaml](https://github.com/AliceUpgrades/ALICE3_HFperformance/blob/main/analysis/databases/general.yaml). - -## HowTo - -All the scripts can be run as simple python scripts from the folder "analysis" . E.g.: -```python -python read_predictions_ptdep_stat_cholee_2_pbpb2p76_absy0p5.py -``` -```python -python expected_yields.py -``` -```python -python significance.py -``` - diff --git a/Upgrade/analysis/GetBkgPerEventAndEff.C b/Upgrade/analysis/GetBkgPerEventAndEff.C deleted file mode 100644 index 88745e0f..00000000 --- a/Upgrade/analysis/GetBkgPerEventAndEff.C +++ /dev/null @@ -1,421 +0,0 @@ -#if !defined(__CINT__) || defined(__MAKECINT__) -#include "TFile.h" -#include "TH1D.h" -#include "TH2D.h" -#include "TMath.h" -#include "TCanvas.h" -#include "TDatabasePDG.h" -#include "TF1.h" -#include "TStyle.h" -#include "TLatex.h" -#include "TEfficiency.h" -#endif - -using namespace std; - -enum myProc_t { kJpsiToEE, - kJpsiToMuMu, - kXToPiPiEE, - kXToPiPiMuMu, - kXicc, - kBplus, - kChic1, - kChic2, - kNChannels }; - -const char* hfTaskLabel[kNChannels] = {"jpsi", "jpsiToMuMu", "x", "xToPiPiMuMu", "xicc", "bplus", "chic", "chic"}; -const char* histNameSig[kNChannels] = {"hMassSig", "hMassRecSig", "hMassRecSig", "hMassRecSig", "hMassSig", "hMassRecSig", "hMassRecSig", "hMassRecSig"}; -const char* histNameBkg[kNChannels] = {"hMass", "hMassRecBkg", "hMass", "hMassRecBkg", "hMass", "hMass", "hMass", "hMass"}; - -const char* label[kNChannels] = { - "J/#psi #rightarrow ee", - "J/#psi #rightarrow #mu#mu", - "X #rightarrow J/#psi(ee) #pi#pi", - "X #rightarrow J/#psi(#mu#mu) #pi#pi", - "#Xi_{cc}^{++} #rightarrow #Xi_{c}^{+}#pi^{+}", - "B^{+} #rightarrow D^{0}#pi^{+}", - "#chi_{c1} #rightarrow J/#psi #gamma", - "#chi_{c2} #rightarrow J/#psi #gamma"}; - -const Double_t massMin[kNChannels] = {2.60, 2.60, 3.60, 3.60, 3.30, 4.60, 3.10, 3.10}; -const Double_t massMax[kNChannels] = {3.55, 3.55, 4.10, 4.10, 3.90, 6.00, 4.00, 4.00}; - -const Double_t massMean[kNChannels] = { - TDatabasePDG::Instance()->GetParticle(443)->Mass(), - TDatabasePDG::Instance()->GetParticle(443)->Mass(), - 3.872, - 3.872, - TDatabasePDG::Instance()->GetParticle(4412)->Mass(), - TDatabasePDG::Instance()->GetParticle(521)->Mass(), - TDatabasePDG::Instance()->GetParticle(20443)->Mass(), - TDatabasePDG::Instance()->GetParticle(445)->Mass()}; - -const Double_t nsigma = 3; - -Int_t nPtBins = 0; -const Int_t nMaxPtBins = 1000; -Double_t ptBinLimits[nMaxPtBins] = {0}; - -Double_t sidebandCount[2] = {0}; // upper and lower limit of the signal window for bkg counting -Double_t sidebandFit[2] = {0}; // upper and lower limit of the signal window for bkg fitting - -// Control parameters for the description of the bkg with a polynomial function. -// The description starts with a pol2 model, and if the bkg fit has a larger chi2/ndf than the chi2OverNDF_limit parameter, -// the degree of the polynomial function describing it is increased by 1, with an upper limit given by maxPolDegree -const Double_t chi2OverNDF_limit = 3.; -const Int_t maxPolDegree = 4; - -TCanvas *cnvSig = 0, *cnvBkg = 0, *cnvBkgperEvents = 0, *cnvEfficiency = 0; - -TH1D *hBkgPerEvent = 0, *hEfficiency = 0, *hEfficiencyNoPID = 0, *hMassSig[nMaxPtBins] = {0}, *hMassBkg[nMaxPtBins] = {0}; -TH2D *hMassVsPtSig = 0, *hMassVsPtBkg = 0; - -TF1 *fitBkg[nMaxPtBins] = {0}, *fitBkgSideBands[nMaxPtBins] = {0}, *fitSig[nMaxPtBins] = {0}; - -Double_t fitPol(Double_t* var, Double_t* par); -Double_t fitPolSideBands(Double_t* var, Double_t* par); - -Double_t fitExpoWithThreshold(Double_t* var, Double_t* par); -Double_t fitExpoWithThresholdSideBands(Double_t* var, Double_t* par); - -void info(myProc_t channel); -void mystyle(); - -void BookCanvas(); -void BookHistos(); - -//==================================================================================================================================================== - -void GetBkgPerEventAndEff(const char* signalfilename, - const char* bkgfilename, - const myProc_t channel) -{ - - mystyle(); - - Double_t bkg, errBkg; - - //----------------------------------------------------------------------------------------------------------------------------- - - // Conneting directories from input files - - TFile* input_sig = new TFile(signalfilename, "read"); - TFile* input_bkg = new TFile(bkgfilename, "read"); - - TDirectory* dir_sig; - TDirectory* dir_bkg; - - if (channel == "lc") { - dir_sig = (TDirectory*)input_sig->GetDirectory("hf-task-lc/MC/reconstructed/signal/"); - dir_bkg = (TDirectory*)input_bkg->GetDirectory("hf-task-lc/MC/reconstructed/signal/"); - } else { - dir_sig = (TDirectory*)input_sig->GetDirectory(Form("hf-task-%s-mc", hfTaskLabel[channel])); - dir_bkg = (TDirectory*)input_bkg->GetDirectory(Form("hf-task-%s", hfTaskLabel[channel])); - } - - hMassVsPtSig = (TH2D*)dir_sig->Get(histNameSig[channel]); - hMassVsPtSig->SetName("hMassVsPtSig"); - - hMassVsPtBkg = (TH2D*)dir_bkg->Get(histNameBkg[channel]); - hMassVsPtBkg->SetName("hMassVsPtBkg"); - - Double_t nEventsBkg = -1; - TH1F* hCount = (TH1F*)input_bkg->Get("qa-global-observables/eventCount"); - if (!hCount) { - nEventsBkg = 20e6; - printf("\n********* WARNING: cannot retrieve bkg number of events, using nEventsBkg = %d *********\n\n", Int_t(nEventsBkg)); - } else { - nEventsBkg = hCount->GetBinContent(1); - printf("nEventsBkg = %d, read from qa-global-observables/eventCount\n", Int_t(nEventsBkg)); - } - - // check of consistency for hMassVsPtSig vs hMassVsPtBkg (same pt binning) - TH1D* hTmpSig = hMassVsPtSig->ProjectionY(); - TH1D* hTmpBkg = hMassVsPtBkg->ProjectionY(); - if (!(hTmpSig->Add(hTmpBkg))) { - printf("ERROR: sig and bkg histograms have different pt binning, quitting.\n"); - return; - } - - nPtBins = TMath::Min(hMassVsPtBkg->GetNbinsY(), nMaxPtBins); - BookCanvas(); - - for (int i = 0; i < nPtBins; i++) { - ptBinLimits[i] = hMassVsPtSig->GetYaxis()->GetBinLowEdge(i + 1); - ptBinLimits[i + 1] = hMassVsPtSig->GetYaxis()->GetBinLowEdge(i + 1) + hMassVsPtSig->GetYaxis()->GetBinWidth(i + 1); - } - - BookHistos(); - - auto hPtGenSig = (TH1F*)dir_sig->Get("hPtGen"); - auto hPtRecSig = (TH1F*)dir_sig->Get("hPtRecSig"); - - auto gp = (TH1D*)hPtGenSig->Rebin(nPtBins, "gp", ptBinLimits); - auto rp = (TH1D*)hPtRecSig->Rebin(nPtBins, "eff", ptBinLimits); - - gp->Sumw2(); - rp->Sumw2(); - rp->Divide(gp); - - hEfficiency = (TH1D*)rp->Clone(); - hEfficiency->SetTitle(";p_{T} (GeV/c); Reconstruction Efficiency"); - hEfficiency->SetLineColor(kRed); - hEfficiency->SetLineWidth(2); - hEfficiency->GetYaxis()->CenterTitle(); - - cnvEfficiency->cd(); - hEfficiency->Draw("e"); - - info(channel); - - //----------------------------------------------------------------------------------------------------------------------------- - - for (int i = 0; i < nPtBins; i++) { - - Int_t ptBin = i + 1; - - // Projecting sig and bkg histos form TH2D objects - - hMassSig[i] = hMassVsPtSig->ProjectionX(Form("hMassSig_PtBin_%d", ptBin), ptBin, ptBin, "e"); - hMassBkg[i] = hMassVsPtBkg->ProjectionX(Form("hMassBkg_PtBin_%d", ptBin), ptBin, ptBin, "e"); - - if (hMassSig[i]->GetMaximum() < 20) - hMassSig[i]->Rebin(2); - - hMassSig[i]->GetXaxis()->SetRangeUser(massMin[channel], massMax[channel]); - hMassBkg[i]->GetXaxis()->SetRangeUser(massMin[channel], massMax[channel]); - - hMassSig[i]->SetTitle(Form("%2.1f < p_{T} < %2.1f", ptBinLimits[i], ptBinLimits[i + 1])); - hMassBkg[i]->SetTitle(Form("%2.1f < p_{T} < %2.1f", ptBinLimits[i], ptBinLimits[i + 1])); - - // Setting the fit functions for bkg and sig - - fitSig[i] = new TF1(Form("fitSig_%d", i), "gaus", massMean[channel] - 5 * hMassSig[i]->GetRMS(), massMean[channel] + 5 * hMassSig[i]->GetRMS()); - fitSig[i]->SetNpx(10000); - - // Gaussian fit on the signal - - cnvSig->cd(i + 1); - - hMassSig[i]->Fit(fitSig[i], "Q", "", massMean[channel] - 5 * hMassSig[i]->GetRMS(), massMean[channel] + 5 * hMassSig[i]->GetRMS()); - Double_t sigmaSig = fitSig[i]->GetParameter(2); - - sidebandCount[0] = massMean[channel] - nsigma * sigmaSig; - sidebandCount[1] = massMean[channel] + nsigma * sigmaSig; - - // Fit of the bakground - - cnvBkg->cd(i + 1); - - if (channel != kChic1 && channel != kChic2) { - - sidebandFit[0] = sidebandCount[0]; - sidebandFit[1] = sidebandCount[1]; - - fitBkg[i] = new TF1(Form("fitBkg_%d", i), fitPol, massMin[channel], massMax[channel], maxPolDegree + 1); - fitBkgSideBands[i] = new TF1(Form("fitBkgSideBands_%d", i), fitPolSideBands, massMin[channel], massMax[channel], maxPolDegree + 1); - fitBkg[i]->SetNpx(10000); - fitBkgSideBands[i]->SetNpx(10000); - - // we start with a 2nd order polynomial - Int_t nPolDegree = 2; - for (Int_t j = nPolDegree + 1; j <= maxPolDegree; j++) - fitBkgSideBands[i]->FixParameter(j, 0); - - hMassBkg[i]->Fit(fitBkgSideBands[i], "Q", "", massMin[channel], massMax[channel]); - - while (fitBkgSideBands[i]->GetChisquare() / fitBkgSideBands[i]->GetNDF() > chi2OverNDF_limit && nPolDegree < maxPolDegree) { - nPolDegree++; - fitBkgSideBands[i]->ReleaseParameter(nPolDegree); - hMassBkg[i]->Fit(fitBkgSideBands[i], "Q", "", massMin[channel], massMax[channel]); - } - - } - - else { - - // adapting the sidebands to exlude the chi_c1 + chi_c2 region (2 sigma only, otherwise we loose too much arm leverage for the fit) - - sidebandFit[0] = massMean[kChic1] - 2 * sigmaSig; - sidebandFit[1] = massMean[kChic2] + 2 * sigmaSig; - - fitBkg[i] = new TF1(Form("fitBkg_%d", i), fitExpoWithThreshold, massMin[channel], massMax[channel], 5); - fitBkgSideBands[i] = new TF1(Form("fitBkgSideBands_%d", i), fitExpoWithThresholdSideBands, massMin[channel], massMax[channel], 5); - fitBkg[i]->SetNpx(10000); - fitBkgSideBands[i]->SetNpx(10000); - - double threshold = 0; - - for (int iBin = 1; iBin <= hMassBkg[i]->GetNbinsX(); iBin++) { - if (hMassBkg[i]->GetBinContent(iBin) > 0) { - threshold = hMassBkg[i]->GetBinCenter(iBin); - break; - } - } - - hMassBkg[i]->Fit("expo", "Q", "", 3.6, 4.0); - - fitBkgSideBands[i]->SetParameters(threshold, 0.02, 0, hMassBkg[i]->GetFunction("expo")->GetParameter(0), TMath::Min(hMassBkg[i]->GetFunction("expo")->GetParameter(1), 0.)); - fitBkgSideBands[i]->SetParLimits(0, threshold - 0.2, threshold + 0.2); - fitBkgSideBands[i]->SetParLimits(1, 0.001, 0.1); - fitBkgSideBands[i]->SetParLimits(2, 0, hMassBkg[i]->GetBinContent(hMassBkg[i]->GetNbinsX())); - fitBkgSideBands[i]->SetParLimits(4, -10, 0); - hMassBkg[i]->Fit(fitBkgSideBands[i], "Q", "", massMin[channel], massMax[channel]); - hMassBkg[i]->Fit(fitBkgSideBands[i], "Q", "", massMin[channel], massMax[channel]); - } - - for (Int_t j = 0; j <= fitBkgSideBands[i]->GetNpar(); j++) - fitBkg[i]->SetParameter(j, fitBkgSideBands[i]->GetParameter(j)); - - bkg = fitBkg[i]->Integral(sidebandCount[0], sidebandCount[1]) / hMassBkg[i]->GetBinWidth(1); - bkg /= nEventsBkg; // bkg is the expected background in the +/- 3 sigma window per MB event - - // Evaluating significance and filling histos - - hBkgPerEvent->SetBinContent(i + 1, bkg); - hBkgPerEvent->SetBinError(i + 1, 0.); - } - - TFile* fileOutEff = new TFile(Form("efficiency_%s.root", hfTaskLabel[channel]), "recreate"); - hEfficiency->Write(); - fileOutEff->Close(); - - TFile* fileOutBkgPerEvents = new TFile(Form("bkgPerEvents_%s.root", hfTaskLabel[channel]), "recreate"); - cnvBkgperEvents->cd(); - cnvBkgperEvents->SetLogy(); - hBkgPerEvent->Draw("e ]["); - info(channel); - hBkgPerEvent->Write(); - fileOutBkgPerEvents->Close(); -} - -//==================================================================================================================================================== - -Double_t fitPol(Double_t* var, Double_t* par) -{ - - Double_t result = par[0]; - for (Int_t i = 1; i <= maxPolDegree; i++) - result += par[i] * TMath::Power(var[0], i); - - return result; -} - -//==================================================================================================================================================== - -Double_t fitPolSideBands(Double_t* var, Double_t* par) -{ - - if (sidebandFit[0] < var[0] && var[0] < sidebandFit[1]) { - TF1::RejectPoint(); - return 0; - } - - return fitPol(var, par); -} - -//==================================================================================================================================================== - -Double_t fitExpoWithThreshold(Double_t* var, Double_t* par) -{ - - Double_t meanThreshold = par[0]; - Double_t x = var[0] - meanThreshold; - Double_t widthThreshold = par[1]; - Double_t offset = par[2]; - Double_t constExpo = par[3]; - Double_t slopeExpo = par[4]; - - return 0.5 * (1. + TMath::Erf(x / widthThreshold)) * (offset + TMath::Exp(x * slopeExpo + constExpo)); -} - -//==================================================================================================================================================== - -Double_t fitExpoWithThresholdSideBands(Double_t* var, Double_t* par) -{ - - if (sidebandFit[0] < var[0] && var[0] < sidebandFit[1]) { - TF1::RejectPoint(); - return 0; - } - - return fitExpoWithThreshold(var, par); -} - -//==================================================================================================================================================== - -void info(myProc_t channel) -{ - - TLatex* t = new TLatex(8, 8, "ALICE3 O2 Performance"); - t->SetNDC(); - t->SetTextSize(0.5); - t->SetTextAlign(10); - t->SetTextColor(1); - t->SetTextSize(0.03); - t->DrawLatex(0.5, 0.85, "ALICE3 O2 Performance"); - - t->SetTextSize(0.025); - t->SetTextAlign(12); - t->DrawLatex(0.5, 0.8, "PYTHIA 8 pp #sqrt{s} = 14TeV "); - // t->DrawLatex(0.5, 0.75, "Inclusive J/#psi #rightarrow ee "); - t->DrawLatex(0.5, 0.75, label[channel]); - t->DrawLatex(0.5, 0.7, "kinematic cuts"); -} - -//==================================================================================================================================================== - -void BookCanvas() -{ - - cnvSig = new TCanvas("cnvSig", "Signal fit", 2000, 800); - int nColums = 5; - int nRows = (nPtBins - 1) / nColums + 1; - cnvSig->Divide(nColums, nRows); - - cnvBkg = new TCanvas("cnvBkg", "Bkg fit", 2000, 800); - cnvBkg->Divide(nColums, nRows); - - cnvBkgperEvents = new TCanvas("BkgperEvents", "Bkg/nEvents"); - cnvEfficiency = new TCanvas("cnvEfficiency", "Efficiency", 800, 600); -} - -//==================================================================================================================================================== - -void BookHistos() -{ - - hBkgPerEvent = new TH1D("hBkgPerEvent", ";p_{T}(J/#psi)(GeV/c);Bkg/nEvents", nPtBins, ptBinLimits); - hEfficiency = new TH1D("hEfficiency", ";p_{T}(J/#psi)(GeV/c); Reconstruction Efficiency", nPtBins, ptBinLimits); - - hBkgPerEvent->SetLineColor(kRed); - hBkgPerEvent->SetLineWidth(3); - - hEfficiency->SetLineColor(kRed); - hEfficiency->SetLineWidth(3); - - hBkgPerEvent->GetYaxis()->CenterTitle(); -} - -//==================================================================================================================================================== - -void mystyle() -{ - - gROOT->ForceStyle(); - gStyle->SetOptStat(0); - gStyle->SetFrameLineWidth(2); - gStyle->SetTitleSize(0.045, "x"); - gStyle->SetTitleSize(0.045, "y"); - gStyle->SetMarkerSize(1); - gStyle->SetLineWidth(2); - gStyle->SetLabelOffset(0.015, "x"); - gStyle->SetLabelOffset(0.01, "y"); - gStyle->SetTitleOffset(1, "x"); - gStyle->SetTitleOffset(0.8, "y"); - gStyle->SetTextSize(0.03); - gStyle->SetTextAlign(5); - gStyle->SetTextColor(1); -} - -//==================================================================================================================================================== diff --git a/Upgrade/analysis/SOverBComp.C b/Upgrade/analysis/SOverBComp.C deleted file mode 100644 index 0e3f972a..00000000 --- a/Upgrade/analysis/SOverBComp.C +++ /dev/null @@ -1,179 +0,0 @@ -void SOverBComp() -{ - - TH1D* sig_sc3; - TH1D* sig_sc2; - - Int_t nBinsMerge = 6; - Double_t xAxis1[7] = {0, 1, 2, 4, 6, 8, 10}; - - TFile* fileSig3 = TFile::Open("Scenario3/foutputLambda_c.root", "READ"); - cout << "ok" << endl; - sig_sc3 = new TH1D(*((TH1D*)fileSig3->Get("histosigoverbkg"))); - - TFile* fileSig2 = TFile::Open("Scenario2/foutputLambda_c.root", "READ"); - cout << "ok" << endl; - sig_sc2 = new TH1D(*((TH1D*)fileSig2->Get("histosigoverbkg"))); - - int textfont = 42; - float textsize = 0.047; - float labelsize = 0.04; - - TLatex* lat = new TLatex(); - lat->SetNDC(); - lat->SetTextFont(textfont); - lat->SetTextSize(textsize); - - TLatex* lat2 = new TLatex(); - lat2->SetNDC(); - lat2->SetTextFont(textfont); - lat2->SetTextSize(textsize * 1.0); - - TLatex* lat3 = new TLatex(); - lat3->SetNDC(); - lat3->SetTextFont(textfont); - lat3->SetTextSize(textsize * 1.0); - - TCanvas* canvas3a = new TCanvas("canvas3a", "", 443, 100, 700, 700); - gStyle->SetOptStat(0); - gStyle->SetOptTitle(0); - gStyle->SetLegendBorderSize(0); - gStyle->SetLegendFont(textfont); - gStyle->SetLegendTextSize(textsize); - - canvas3a->Range(0, 0, 1, 1); - canvas3a->SetFillColor(0); - canvas3a->SetBorderMode(0); - canvas3a->SetBorderSize(2); - canvas3a->SetFrameBorderMode(0); - - // ------------>Primitives in pad: canvas3a_1 - TPad* canvas3a_1 = new TPad("canvas3a_1", "canvas3a_1", 0.01, 0.3, 0.99, 0.99); - canvas3a_1->Draw(); - canvas3a_1->cd(); - canvas3a_1->Range(-0.3750001, -2248.875, 13.375, 20249.88); - canvas3a_1->SetFillColor(0); - canvas3a_1->SetBorderMode(0); - canvas3a_1->SetBorderSize(2); - // canvas3a_1->SetGridx(); - // canvas3a_1->SetGridy(); - canvas3a_1->SetLeftMargin(0.15); - canvas3a_1->SetFrameBorderMode(0); - canvas3a_1->SetFrameBorderMode(0); - - cout << "ok" << endl; - - // sig_sc3->SetMarkerSize(1.25); - // sig_sc3->SetMinimum(2.27); - // sig_sc3->SetMaximum(2.30); - sig_sc3->SetEntries(7); - sig_sc3->SetStats(0); - sig_sc3->SetLineWidth(2); - sig_sc3->SetLineColor(4); - // sig_sc3->SetMarkerColor(1); - // sig_sc3->SetMarkerStyle(21); - sig_sc3->GetXaxis()->SetTitle("#it{p}_{T}(#Lambda_{c}) [GeV/#it{c}]"); - sig_sc3->GetXaxis()->SetNdivisions(511); - sig_sc3->GetXaxis()->SetRangeUser(0, 10); - sig_sc3->GetXaxis()->SetLabelFont(42); - sig_sc3->GetXaxis()->SetLabelSize(0.04); - sig_sc3->GetXaxis()->SetTitleSize(0.04); - sig_sc3->GetXaxis()->SetTitleOffset(1.0); - sig_sc3->GetYaxis()->SetRangeUser(0.000003, 5); - sig_sc3->GetXaxis()->SetTitleFont(42); - - // sig_sc3->GetYaxis()->SetTitle("#frac{d^{2}#sigma}{dy dp_{T}} [#frac{#mu b}{GeV/c}]"); - sig_sc3->GetYaxis()->SetTitle("Signal/Background (3#sigma)"); - sig_sc3->GetYaxis()->SetLabelFont(42); - sig_sc3->GetYaxis()->SetTitleFont(42); - sig_sc3->GetYaxis()->SetLabelSize(0.05); - sig_sc3->GetYaxis()->SetTitleSize(0.07); - sig_sc3->GetYaxis()->SetTitleOffset(0.9); - sig_sc3->GetYaxis()->SetDecimals(kTRUE); - - canvas3a_1->SetLogy(); - sig_sc3->Draw(""); - - sig_sc2->SetLineWidth(2); - sig_sc2->SetLineColor(2); - // sig_sc2->SetMarkerStyle(21); - // sig_sc2->SetMarkerSize(1.25); - // sig_sc2->SetMarkerColor(2); - sig_sc2->Draw("same"); - - lat->DrawLatex(0.2, 0.83, "ALICE3 projection, pp #sqrt{s}= 14 TeV"); - lat2->DrawLatex(0.2, 0.76, "Pythia 8, mode = 2"); - lat3->DrawLatex(0.2, 0.69, "#Lambda_{c} #rightarrow pK#pi, |y| < 1.44, BR=6.28%"); - - /////////////////////////////////////////////////////////////////////// RATIO ///////////////////////////////////////////////////////////////////// - - TLegend* leg = new TLegend(0.53, 0.25, 0.88, 0.40, 0, "NDC"); - leg->AddEntry(sig_sc3, "Scenario3", "lp"); - leg->AddEntry(sig_sc2, "Scenario2", "lp"); - leg->SetFillStyle(0); - leg->SetBorderSize(0); - leg->SetFillColor(0); - // leg->SetTextSize(22); - - leg->Draw(); - - canvas3a_1->Modified(); - canvas3a->cd(); - - // ------------>Primitives in pad: canvas3a_2 - TPad* canvas3a_2 = new TPad("canvas3a_2", "canvas3a_2", 0.01, 0.01, 0.99, 0.365); - canvas3a_2->Draw(); - canvas3a_2->cd(); - canvas3a_2->Range(-0.3750001, -0.7452094, 13.375, 0.6383566); - canvas3a_2->SetFillColor(0); - canvas3a_2->SetBorderMode(0); - canvas3a_2->SetBorderSize(2); - // canvas3a_2->SetGridx(); - canvas3a_2->SetGridy(); - canvas3a_2->SetLeftMargin(0.15); - canvas3a_2->SetBottomMargin(0.2); - canvas3a_2->SetFrameBorderMode(0); - canvas3a_2->SetFrameBorderMode(0); - - TH1F* SigRatio = new TH1F("SigRatio", "", 6, xAxis1); - SigRatio->Divide(sig_sc3, sig_sc2, 1., 1.); - - // SigRatio->SetMarkerStyle(1); - // SigRatio->SetMarkerSize(1); - SigRatio->SetMinimum(0.99); - SigRatio->SetMaximum(1.01); - SigRatio->SetEntries(7); - SigRatio->SetStats(0); - SigRatio->SetLineWidth(2); - SigRatio->SetLineColor(4); - SigRatio->GetXaxis()->SetTitle("p_{T}(#Lambda_{c}) [GeV/c]"); - // SigRatio->GetXaxis()->SetNdivisions(511); - SigRatio->GetXaxis()->SetLabelFont(42); - SigRatio->GetXaxis()->SetLabelSize(0.085); - SigRatio->GetXaxis()->SetTitleSize(0.095); - SigRatio->GetXaxis()->SetTitleOffset(1.0); - SigRatio->GetXaxis()->SetRangeUser(0, 10); - SigRatio->GetYaxis()->SetRangeUser(0., 15); - SigRatio->GetXaxis()->SetTitleFont(42); - SigRatio->GetYaxis()->SetTitle("Scenario3 / Scenario2"); - SigRatio->GetYaxis()->SetNdivisions(106); - SigRatio->GetYaxis()->SetLabelFont(42); - SigRatio->GetYaxis()->SetLabelSize(0.085); - SigRatio->GetYaxis()->SetTitleSize(0.08); - SigRatio->GetYaxis()->SetTitleOffset(0.7); - SigRatio->GetYaxis()->SetTitleFont(42); - SigRatio->GetYaxis()->SetDecimals(kTRUE); - SigRatio->Draw(""); - - TLine* line = new TLine(0, 1, 10., 1); - line->SetLineColor(1); - line->SetLineWidth(4); - line->SetLineStyle(2); - line->Draw("same"); - - canvas3a_2->Modified(); - canvas3a->cd(); - canvas3a->Modified(); - canvas3a->cd(); - canvas3a->SetSelected(canvas3a); -} diff --git a/Upgrade/analysis/clean.sh b/Upgrade/analysis/clean.sh deleted file mode 100644 index 1f1c233c..00000000 --- a/Upgrade/analysis/clean.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -rm .analysis.py.swp -rm .prediction.yaml.swp -rm .read_predictions.py.swp -rm ./*.root ./*.pdf ./*.C -rm plots/*.pdf -cd ../InputsTheory || exit -rm ./*.root ./*.pdf ./*.C -git checkout Lambda_c_ptdep_Pyhia8mode2_pp14p0_absy3p0.root -cd - || exit diff --git a/Upgrade/analysis/databases/general.yaml b/Upgrade/analysis/databases/general.yaml deleted file mode 100644 index ef761233..00000000 --- a/Upgrade/analysis/databases/general.yaml +++ /dev/null @@ -1,64 +0,0 @@ -latexparticle: - Lambda_c: "#Lambda_{c}" - Xi_cc: "#Xi_{cc}" - Omega_cc: "#Omega_{cc}" - Omega_ccc: "#Omega_{ccc}" - X3872: "X(3872)" - Jpsitoee: "J/#psi #rightarrow e^{#plus} e^{#minus}" - Chi_c: "#chi_{c1} #rightarrow J/#psi #gamma" - B_plus: "B^{#plus} #rightarrow #bar{D}^{0} #pi^{#plus}" -text_string: - PbPb5p52: "PbPb #sqrt{#it{s}_{NN}} = 5.52 TeV" - pp14p0: "pp #sqrt{#it{s}} = 14 TeV" - absy3p0: "|#it{y}| < 3.0" - absy2p0: "|#it{y}| < 2.0" - absy1p44: "|#it{y}| < 1.44" - absy0p33: "|#it{y}| < 0.33" - Pyhia8mode2: "Pythia 8, mode = 2" - Pyhia8monash: "Pythia 8, monash tune" - SHMC_2021: "SHMC_2021" -statistics: - PbPb2p76: - sigmaAA_b: 7.8 #FIXME these are copied from 5.52 TeV - lumiAA_monthi_invnb: 4.92 #FIXME these are copied from 5.52 TeV - PbPb5p5: - sigmaAA_b: 7.8 #FIXME these are copied from 5.52 TeV - lumiAA_monthi_invnb: 4.92 #FIXME these are copied from 5.52 TeV - PbPb5p52: - sigmaAA_b: 7.8 - lumiAA_monthi_invnb: 35 - KrKr6p46: - sigmaAA_b: 4.06 - lumiAA_monthi_invnb: 123. - ArAr6p3: - sigmaAA_b: 2.6 - lumiAA_monthi_invnb: 1080 - pp14p0: - sigmaAA_b: 0.070 - lumiAA_monthi_invnb: 18000000 - -branchingratio: - Jpsitoee: - central: 0.0594 - Chi_c: - central: 0.020374200 #0.343*0.0594 - Lambda_c: - central: 0.0628 - Xi_cc: #https://arxiv.org/abs/1703.09086 - central: 1.1e-3 - min: 2.2e-4 - max: 2.2e-3 - Omega_cc: - central: 1.08e-3 - min: 2.16e-4 - max: 2.16e-3 - Omega_ccc: - central: 5.4e-05 - min: 2.16e-6 - max: 2.16e-4 - X3872: - # https://pdg.lbl.gov/2020/tables/rpp2020-tab-mesons-c-cbar.pdf - # https://journals.aps.org/prd/pdf/10.1103/PhysRevD.100.094003 - central: 0.0024440100 #0.041 * 0.05961 - B_plus: - central: 0.00018467280 diff --git a/Upgrade/analysis/databases/significance.yaml b/Upgrade/analysis/databases/significance.yaml deleted file mode 100644 index 0bfea591..00000000 --- a/Upgrade/analysis/databases/significance.yaml +++ /dev/null @@ -1,102 +0,0 @@ ---- -Lambda_c: - pp14p0: - absy1p44: - ymin: 40 - ymax: 10000000 - binning: [0., 1., 2., 4., 6., 8., 10.] - efffile: ../InputsExp/Lc_ptdep_pp14p0_absy1p44_scenario3/efficiencies.root - histoeff: eff - bkgfile: ../InputsExp/Lc_ptdep_pp14p0_absy1p44_scenario3/bkgperevent.root - histobkg: hbkg_fromsidebands - theoryfile: ../InputsTheory/Lambda_c_ptdep_Pyhia8mode2_pp14p0_absy1p44.root - histoyield: hLccrossvspt - histoyield_norm: hLccrossvspt -Jpsitoee: - pp14p0: - absy1p44: - ymin: 10 - ymax: 100000 - binning: [0., 1., 2., 3., 4., 5., 7., 10.] - efffile: ../InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_noRICH/efficiencies.root # this is temporarily the Lc files - # efffile: ../InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_RICH3sigma/efficiencies.root # this is temporarily the Lc files - histoeff: eff.root - bkgfile: ../InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_noRICH/BkgperEvents.root # this is temporarily the Lc files - # bkgfile: ../InputsExp/Jpsi_ptdep_pp14p0_absy1p44_scenario3_RICH3sigma/BkgperEvents.root # this is temporarily the Lc files - histobkg: BkgperEvents.root - theoryfile: ../InputsTheory/Jpsi_ptdep_Pyhia8monash_pp14p0_absy1p44.root # this is temporarely the Lc file - histoyield: hJpsicrossvspt # to be replaced with the name of the jpsi th histogram - histoyield_norm: hJpsiyieldsvspt_unnorm # to be replaced with the name of the jpsi th histogram -Chi_c: - pp14p0: - absy1p44: - ymin: 0.1 - ymax: 10000 - binning: [0., 0.5, 1., 2., 3., 4., 5., 7., 10., 15.] - efffile: ../InputsExp/Chic1_ptdep_pp14p0_absy1p44_MIDECAL/efficiency_chic.root - histoeff: eff - bkgfile: ../InputsExp/Chic1_ptdep_pp14p0_absy1p44_MIDECAL/bkgPerEvents_chic.root - histobkg: hBkgPerEvent - theoryfile: ../InputsTheory/Chic1_ptdep_Pyhia8monash_pp14p0_absy1p44.root - histoyield: hChic1crossvspt - histoyield_norm: hChic1yieldsvspt_unnorm - absy0p33: - ymin: 0.1 - ymax: 10000 - binning: [0., 0.5, 1., 2., 3., 4., 5., 7., 10., 15.] - efffile: ../InputsExp/Chic1_ptdep_pp14p0_absy1p44_MIDECAL/efficiency_chic.root - histoeff: eff - bkgfile: ../InputsExp/Chic1_ptdep_pp14p0_absy1p44_MIDECAL/bkgPerEvents_chic.root - histobkg: hBkgPerEvent - theoryfile: ../InputsTheory/Chic1_ptdep_Pyhia8monash_pp14p0_absy1p44.root - histoyield: hChic1crossvspt - histoyield_norm: hChic1crossvspt - PbPb5p52: - absy1p44: - ymin: 0.001 - ymax: 100 - binning: [0., 0.5, 1., 2., 3., 4., 5., 7., 10., 15.] - efffile: ../InputsExp/Chic1_ptdep_PbPb5p52_absy1p44_MIDECAL/efficiency_chic.root - histoeff: eff - bkgfile: ../InputsExp/Chic1_ptdep_PbPb5p52_absy1p44_MIDECAL/bkgPerEvents_chic.root - histobkg: hBkgPerEvent - theoryfile: ../InputsTheory/Chic1_ptdep_Pyhia8monash_pp14p0_absy1p44.root - histoyield: hChic1crossvspt - histoyield_norm: hChic1crossvspt - absy0p33: - ymin: 0.001 - ymax: 100 - binning: [0., 0.5, 1., 2., 3., 4., 5., 7., 10., 15.] - efffile: ../InputsExp/Chic1_ptdep_PbPb5p52_absy1p44_MIDECAL/efficiency_chic.root - histoeff: eff - bkgfile: ../InputsExp/Chic1_ptdep_PbPb5p52_absy1p44_MIDECAL/bkgPerEvents_chic.root - histobkg: hBkgPerEvent - theoryfile: ../InputsTheory/Chic1_ptdep_Pyhia8monash_pp14p0_absy1p44.root - histoyield: hChic1crossvspt - histoyield_norm: hChic1crossvspt -X3872: - pp14p0: - absy1p44: - ymin: 0.00001 - ymax: 100 - binning: [0., 0.5, 1., 2., 3., 4., 5., 7., 10.] - efffile: ../InputsExp/X3872_ptdep_pp14p0_absy1p44_scenario3_noRICH/eff.root - histoeff: eff - bkgfile: ../InputsExp/X3872_ptdep_pp14p0_absy1p44_scenario3_noRICH/BkgperEvents.root - histobkg: hBkgPerEvent - theoryfile: ../InputsTheory/x3872_ptdep_Pyhia8monash_pp14p0_absy1p44.root # this is temporarely the Lc file - histoyield: hx3872crossvspt # to be replaced with the name of the jpsi th histogram - histoyield_norm: hx3872crossvspt # to be replaced with the name of the jpsi th histogram -B_plus: - pp14p0: - absy1p44: - ymin: 0.001 - ymax: 10000 - binning: [0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 7.0, 10.0, 13.0, 16.0, 20.0, 24.0] - efffile: ../InputsExp/Bplus_ptdep_pp14p0_absy1p44_scenario3/efficiency_bplus.root - histoeff: eff - bkgfile: ../InputsExp/Bplus_ptdep_pp14p0_absy1p44_scenario3/bkgPerEvents_bplus.root - histobkg: hBkgPerEvent - theoryfile: ../InputsTheory/Bplus_ptdep_Pyhia8mode2_pp14p0_absy1p44.root - histoyield: hBpluscrossvspt # to be replaced with the name of the jpsi th histogram - histoyield_norm: hBpluscrossvspt # to be replaced with the name of the jpsi th histogram diff --git a/Upgrade/analysis/databases/theory_yields.yaml b/Upgrade/analysis/databases/theory_yields.yaml deleted file mode 100644 index 9af59243..00000000 --- a/Upgrade/analysis/databases/theory_yields.yaml +++ /dev/null @@ -1,126 +0,0 @@ ---- -SHMC_2021: - PbPb5p52: - absy0p5: - Lambda_c: 1.312e+00 - Xi_cc: 5.672e-03 - Omega_cc: 2.663e-03 - Omega_ccc: 1.246e-04 - X3872: 2.807e-03 - absy1p44: - Chi_c: 5.62e-03 #FIXME approximated - absy0p33: - Chi_c: 5.62e-03 #FIXME approximated - KrKr6p46: - absy0p5: - Lambda_c: 3.655e-01 - Xi_cc: 9.865e-04 - Omega_cc: 4.632e-04 - Omega_ccc: 1.231e-05 - X3872: 5.966e-04 - ArAr6p3: - absy0p5: - Lambda_c: 1.270e-01 - Xi_cc: 2.024e-04 - Omega_cc: 9.505e-05 - Omega_ccc: 1.287e-06 - X3872: 1.985e-04 - -Stat_ChoLee_1: - PbPb2p76: - absy0p5: - Xi_cc: 4.90e-03 - Omega_ccc: 5.3e-06 - -Stat_ChoLee_2: - PbPb2p76: - absy0p5: - Xi_cc: 6.70e-03 - Omega_ccc: 5.9e-06 - -Stat_ChoLee_tetra: - PbPb2p76: - absy0p5: - X3872: 3.80e-4 - -Stat_ChoLee_molecule: - PbPb2p76: - absy0p5: - X3872: 4.50e-3 - -Stat_Becc_min: - PbPb5p5: - absy0p5: - Xi_cc: 1.9e-02 - Omega_ccc: 1.0e-03 - -Stat_Becc_max: - PbPb5p5: - absy0p5: - Xi_cc: 0.38 - Omega_ccc: 0.03 - -Catania: - PbPb5p5: - absy0p5: - Xi_cc: 1.8e-03 - Omega_ccc: 3.5e-05 - -Pyhia8mode2: - pp14p0: - absy1p44: - Lambda_c: 1 - B_plus: 1 - -Pyhia8monash: - pp14p0: - absy1p44: - Jpsitoee: 1 - X3872: 1 - Chi_c: 1 - absy0p33: - Chi_c: 1 -comparison_models_AA: - pt_binning: - Lambda_c: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - Xi_cc: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - Omega_cc: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - Omega_ccc: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - X3872: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - - Omega_ccc: - models: ["SHMC_2021", "SHMC_2021", "SHMC_2021", "Stat_ChoLee_1", "Stat_ChoLee_2", "Catania", "SHMC_2021", "SHMC_2021"] - collisions: ["PbPb5p52", "KrKr6p46", "ArAr6p3", "PbPb2p76", "PbPb2p76", "PbPb5p5", "PbPb5p52", "PbPb5p52"] - yrange: ["absy0p5", "absy0p5", "absy0p5", "absy0p5", "absy0p5", "absy0p5", "absy0p5", "absy0p5"] - brmode: ["central", "central", "central", "central", "central", "central", "max", "min"] - colors: [1, 2, 4, 5, 6, 7, 9, 11] - useshape: "Omega_ccc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5" - ymin: 1.e-5 - ymax: 1.e+10 - Omega_cc: - models: ["SHMC_2021", "SHMC_2021", "SHMC_2021", "SHMC_2021", "SHMC_2021", "SHMC_2021", "SHMC_2021"] - collisions: ["PbPb5p52", "KrKr6p46", "ArAr6p3", "PbPb5p52", "PbPb5p52", "KrKr6p46", "KrKr6p46"] - yrange: ["absy0p5", "absy0p5", "absy0p5", "absy0p5", "absy0p5", "absy0p5", "absy0p5"] - brmode: ["central", "central", "central", "max", "min", "max", "min"] - colors: [1, 2, 4, 5, 6, 7, 9] - useshape: "Omega_cc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5" - ymin: 1.e-2 - ymax: 1.e+10 - Xi_cc: - models: ["SHMC_2021", "Stat_ChoLee_1", "Stat_ChoLee_2", "Catania", "SHMC_2021", "SHMC_2021", "SHMC_2021"] - collisions: ["PbPb5p52", "PbPb2p76", "PbPb2p76", "PbPb5p5", "KrKr6p46", "KrKr6p46", "KrKr6p46"] - yrange: ["absy0p5", "absy0p5", "absy0p5", "absy0p5", "absy0p5", "absy0p5", "absy0p5"] - brmode: ["central", "central", "central", "central", "central", "min", "max"] - colors: [1, 2, 4, 5, 7, 9, 11] - useshape: "Xi_cc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5" - ymin: 1.e-2 - ymax: 1.e+10 - X3872: - models: ["SHMC_2021", "SHMC_2021", "SHMC_2021", "Stat_ChoLee_tetra", "Stat_ChoLee_molecule"] - collisions: ["PbPb5p52", "KrKr6p46", "ArAr6p3", "PbPb2p76", "PbPb2p76"] - yrange: ["absy0p5", "absy0p5", "absy0p5", "absy0p5", "absy0p5"] - brmode: ["central", "central", "central", "central", "central"] - colors: [1, 2, 4, 5, 7] - useshape: "X3872_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5" - ymin: 1.e-2 - ymax: 1.e+10 diff --git a/Upgrade/analysis/expected_yields.py b/Upgrade/analysis/expected_yields.py deleted file mode 100644 index bf48a8cc..00000000 --- a/Upgrade/analysis/expected_yields.py +++ /dev/null @@ -1,128 +0,0 @@ -# pylint: disable=too-many-locals,too-many-statements, missing-docstring, pointless-string-statement -from array import array - -import yaml - -# pylint: disable=import-error, no-name-in-module, unused-import -from ROOT import TH2F, TCanvas, TFile, TLegend, gPad, gStyle - -""" -Perform comparison between expected yields of the different baryons based -on dN/dy from different theoretical calculations and different assumptions -for the integrated luminosity of the various ion species. -for the moment we use the pT-shape normalized to unity from -arXiv.1907.12786 and we just multiply for dN/dy of each model. -""" - - -def analysis(hadron="Omega_ccc"): - gStyle.SetOptStat(0) - with open(r"databases/theory_yields.yaml") as fileparamyields: - paramyields = yaml.safe_load(fileparamyields) - models = paramyields["comparison_models_AA"][hadron]["models"] - collisions = paramyields["comparison_models_AA"][hadron]["collisions"] - brmodes = paramyields["comparison_models_AA"][hadron]["brmode"] - yranges = paramyields["comparison_models_AA"][hadron]["yrange"] - colors = paramyields["comparison_models_AA"][hadron]["colors"] - useshape = paramyields["comparison_models_AA"][hadron]["useshape"] - ymin = paramyields["comparison_models_AA"][hadron]["ymin"] - ymax = paramyields["comparison_models_AA"][hadron]["ymax"] - binanal = array("d", paramyields["comparison_models_AA"]["pt_binning"][hadron]) - - with open(r"databases/general.yaml") as fileparamgen: - paramgen = yaml.safe_load(fileparamgen) - - histolist = [None] * len(models) - - fin = TFile("../InputsTheory/" + useshape + ".root") - histo_norm = fin.Get("hdNdpt_norm") # this is the pT-shape normalized to unity - - for icase, _ in enumerate(models): - histolist[icase] = histo_norm.Clone( - "dNdpt%s%s%s" % (models[icase], collisions[icase], brmodes[icase]) - ) - canvas = TCanvas("canvas", "A Simple Graph Example", 881, 176, 668, 616) - gStyle.SetOptStat(0) - canvas.SetHighLightColor(2) - canvas.Range(-1.25, -4.625, 11.25, 11.625) - canvas.SetFillColor(0) - canvas.SetBorderMode(0) - canvas.SetBorderSize(2) - canvas.SetLogy() - canvas.SetFrameBorderMode(0) - canvas.SetFrameBorderMode(0) - canvas.cd() - gPad.SetLogy() - - hempty = TH2F("hempty", ";p_{T};Yields", 100, 0.0, 10.0, 100, ymin, ymax) - hempty.GetXaxis().SetTitle("p_{T}") - hempty.GetXaxis().SetLabelFont(42) - hempty.GetXaxis().SetTitleOffset(1) - hempty.GetXaxis().SetTitleFont(42) - hempty.GetYaxis().SetLabelFont(42) - hempty.GetYaxis().SetTitleOffset(1.35) - hempty.GetYaxis().SetTitleFont(42) - hempty.GetZaxis().SetLabelFont(42) - hempty.GetZaxis().SetTitleOffset(1) - hempty.GetZaxis().SetTitleFont(42) - hempty.Draw() - - leg = TLegend(0.1471471, 0.6108291, 0.3018018, 0.8747885, "", "brNDC") - leg.SetBorderSize(1) - leg.SetLineColor(0) - leg.SetLineStyle(1) - leg.SetLineWidth(1) - leg.SetFillColor(0) - leg.SetTextSize(0.022) - leg.SetFillStyle(1001) - - # each case represents a combination of expected dNdy, - # collision type and HP on the branching ratio. - for icase, _ in enumerate(models): - brmode = brmodes[icase] - collision = collisions[icase] - model = models[icase] - yrange = yranges[icase] - - sigma_aa_b = paramgen["statistics"][collision]["sigmaAA_b"] - lumiaa_monthi_invnb = paramgen["statistics"][collision]["lumiAA_monthi_invnb"] - nevt = sigma_aa_b * lumiaa_monthi_invnb * 1e9 # luminosity given in nb-1 - bratio = paramgen["branchingratio"][hadron][brmode] - yieldmid = paramyields[model][collision][yrange][hadron] - text = "%s N_{ev}(%s) = %.1f B, BR=%.5f%%" % ( - model, - collision, - nevt / 1e9, - bratio * 100, - ) - scalef = bratio * nevt * yieldmid - - # before rebinning, the dNdpT is multiplied by the binwidth, - # branching ratios, expected dN/dy and number of events - # so that the yields can be simplied summed in rebinning process. - for ibin in range(histolist[icase].GetNbinsX()): - binwdith = histolist[icase].GetBinWidth(ibin + 1) - yvalue = histolist[icase].GetBinContent(ibin + 1) - histolist[icase].SetBinContent(ibin + 1, binwdith * scalef * yvalue) - histolist[icase] = histolist[icase].Rebin( - len(binanal) - 1, "histo_pred%s%s%s" % (model, collision, brmode), binanal - ) - histolist[icase].SetLineColor(colors[icase]) - histolist[icase].SetMarkerColor(colors[icase]) - histolist[icase].SetLineWidth(2) - histolist[icase].Draw("same") - text = text + " Yield(tot)=%.2f" % (histolist[icase].Integral()) - leg.AddEntry(histolist[icase], text, "pF") - leg.Draw() - canvas.SaveAs(hadron + "_results.pdf") - canvas.SaveAs(hadron + "_results.C") - foutput = TFile("foutput" + hadron + ".root", "recreate") - for icase, _ in enumerate(models): - foutput.cd() - histolist[icase].Write() - - -analysis("Omega_ccc") -analysis("Omega_cc") -analysis("Xi_cc") -analysis("X3872") diff --git a/Upgrade/analysis/plots/placeholder.txt b/Upgrade/analysis/plots/placeholder.txt deleted file mode 100644 index 8b137891..00000000 --- a/Upgrade/analysis/plots/placeholder.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Upgrade/analysis/read_predictions_ptdep_stat_cholee_2_pbpb2p76_absy0p5.py b/Upgrade/analysis/read_predictions_ptdep_stat_cholee_2_pbpb2p76_absy0p5.py deleted file mode 100644 index 13dc1e94..00000000 --- a/Upgrade/analysis/read_predictions_ptdep_stat_cholee_2_pbpb2p76_absy0p5.py +++ /dev/null @@ -1,158 +0,0 @@ -# pylint: disable=too-many-locals,too-many-statements, missing-docstring, pointless-string-statement -from array import array - -import pandas as pd # pylint: disable=import-error -import yaml - -# pylint: disable=import-error, no-name-in-module, unused-import -from ROOT import TH1F, TH2F, TCanvas, TFile, TGraph, TLatex, gPad, gStyle - -""" -read predictions from arXiv.1907.12786. -The predictions are given for PbPb collisions at 2.76 TeV at mid-rapidity -for one unit of rapidity (therefore |y|<0.5). -""" - - -def read_predictions(hadron="Omega_ccc"): - collision = "PbPb" - - # the option below do2pipnorm switches on/off the rinormalization of the - # extracted spectrum, which are given as 2*pi*pt dN/dpT. - # For obtaining the dN/dpt one has to multiply for 2*pi*pt. - do2pipnorm = 1 - energy = 2.76 - - # miny,maxy are the yaxis min and max for plotting reasons only. - if hadron == "Lambda_c": - filename = "Lambda_c_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5" - miny = 0.0001 - maxy = 10.0 - if hadron == "Xi_cc": - filename = "Xi_cc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5" - miny = 1.0e-8 - maxy = 1.0e-2 - if hadron == "Omega_cc": - filename = "Omega_cc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5" - miny = 1.0e-8 - maxy = 1.0e-2 - if hadron == "Omega_ccc": - filename = "Omega_ccc_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5" - miny = 1.0e-9 - maxy = 1.0e-5 - if hadron == "X3872": - filename = "X3872_ptdep_Stat_ChoLee_2_PbPb2p76_absy0p5" - miny = 1.0e-8 - maxy = 1.0e-2 - - with open(r"databases/general.yaml") as fileparam: - param = yaml.safe_load(fileparam) - latexname = param["latexparticle"][hadron] - - # the binning of the ROOT histo in which the predictions will - # be saved is hardcoded. - nbins = 50 - minb = 0.0 - maxb = 50.0 - width = (maxb - minb) / float(nbins) - - legendtext = "%s %.2f TeV, arXiv.1907.12786 (Coal.2)" % (collision, energy) - dfpred = pd.read_csv("../InputsTheory/" + filename + ".csv") - ptcand = dfpred["pt"] - cross = dfpred["cross"] - - ptcand_val = array("f", ptcand) - cross_val = array("f", cross) - if do2pipnorm == 1: - cross_val_ptscaled = array( - "f", [2 * 3.14 * a * b for a, b in zip(ptcand_val, cross_val)] - ) - if do2pipnorm == 0: - cross_val_ptscaled = cross_val - - # number of data points in each predictions - npoints = 25 - - grpred = TGraph(npoints, ptcand_val, cross_val_ptscaled) - grpred.SetName("gdNdpt") - grpred.SetLineColor(1) - grpred.SetLineWidth(4) - grpred.SetMarkerColor(1) - grpred.SetMarkerStyle(21) - grpred.SetTitle("") - grpred.GetXaxis().SetTitle("p_{T} (GeV)") - grpred.GetYaxis().SetTitle("dN/dp_{T} (%s) (GeV^{-1})" % latexname) - - histo = TH1F("hdNdpt", ";p_{T}; #Delta N/#Delta p_{T}, |y|<0.5", nbins, minb, maxb) - norm = 0.0 - for i in range(nbins - 1): - # to allow for the use of a arbitrary binning, we use the Eval function - # of TGraph. We set to zero the prediction for xvalues for which data - # are not given (8 GeV/c in this case). Given that most of the - # cross-section is at low pT the bias is negligible - yvalue = grpred.Eval(i * width + width / 2.0) - if i * width + width / 2.0 > 8.0: - yvalue = 0.0 - histo.SetBinContent(i + 1, yvalue) - print(i + 1, i * width + width / 2.0, yvalue) - norm = norm + width * yvalue - fout = TFile("../InputsTheory/" + filename + ".root", "recreate") - fout.cd() - grpred.Write() - histo.Write() - histo_norm = TH1F( - "hdNdpt_norm", - ";p_{T}; #Delta N/#Delta p_{T}, |y|<0.5, norm = 1", - nbins, - minb, - maxb, - ) - for i in range(nbins - 1): - histo_norm.SetBinContent(i + 1, histo.GetBinContent(i + 1) / norm) - histo_norm.Write() - - cpred = TCanvas("cpred", "A Simple Graph Example", 881, 176, 668, 616) - gStyle.SetOptStat(0) - cpred.SetHighLightColor(2) - cpred.Range(-1.25, -4.625, 11.25, 11.625) - cpred.SetFillColor(0) - cpred.SetBorderMode(0) - cpred.SetBorderSize(2) - cpred.SetLogy() - cpred.SetFrameBorderMode(0) - cpred.SetFrameBorderMode(0) - cpred.cd() - gPad.SetLogy() - hempty = TH2F("hempty", ";p_{T};dN/d p_{T}", 100, 0.0, 10.0, 100, miny, maxy) - hempty.GetYaxis().SetTitle("dN/dp_{T} (%s) (GeV^{-1})" % latexname) - hempty.GetXaxis().SetTitle("p_{T}") - hempty.GetXaxis().SetLabelFont(42) - hempty.GetXaxis().SetTitleOffset(1) - hempty.GetXaxis().SetTitleFont(42) - hempty.GetYaxis().SetLabelFont(42) - hempty.GetYaxis().SetTitleOffset(1.35) - hempty.GetYaxis().SetTitleFont(42) - hempty.GetZaxis().SetLabelFont(42) - hempty.GetZaxis().SetTitleOffset(1) - hempty.GetZaxis().SetTitleFont(42) - hempty.Draw() - grpred.Draw("Psame") - histo.SetLineColor(1) - histo.SetLineWidth(2) - histo.Draw("same") - tex = TLatex() - tex.SetNDC() - tex.SetTextFont(40) - tex.SetTextColor(1) - tex.SetTextSize(0.03) - tex.SetTextAlign(12) - tex.DrawLatex(0.12, 0.85, legendtext + ", dNdy=%.8f" % norm) - # tex.Draw() - cpred.SaveAs("plots/" + filename + ".pdf") - - -read_predictions("Omega_ccc") -read_predictions("Omega_cc") -read_predictions("Xi_cc") -read_predictions("X3872") -read_predictions("Lambda_c") diff --git a/Upgrade/analysis/significance.py b/Upgrade/analysis/significance.py deleted file mode 100644 index 8bde2793..00000000 --- a/Upgrade/analysis/significance.py +++ /dev/null @@ -1,242 +0,0 @@ -# pylint: disable=too-many-locals,too-many-statements, missing-docstring, pointless-string-statement -from array import array -from math import sqrt - -import yaml - -# pylint: disable=import-error, no-name-in-module, unused-import, too-many-arguments -from ROOT import TH2F, TCanvas, TFile, TLatex, gPad, gStyle - -""" -Macro to perform significance estimation of a given decay channel -in a given collision system. The ingredients are: - - efficiency vs pt - - estimated background yield within 3sigma below the peak / event - bkgperevent is already multiplied by binwidth - - expected signal yield / event = dN/dpT * binwidth * BR * efficiency -""" - - -def analysis( - hadron="Lambda_c", - collision="pp14p0", - yrange="absy3p0", - brmode="central", - model="Pyhia8mode2", - use_unnorm=1, -): - gStyle.SetOptStat(0) - with open(r"databases/significance.yaml") as filesignificance: - paramsignificance = yaml.safe_load(filesignificance) - ymin = paramsignificance[hadron][collision][yrange]["ymin"] - ymax = paramsignificance[hadron][collision][yrange]["ymax"] - # bin of the final analysis, has to be the binning of efficiency, bkg histos - binanal = array("d", paramsignificance[hadron][collision][yrange]["binning"]) - nfileyieldth = paramsignificance[hadron][collision][yrange]["theoryfile"] - - nfileeff = paramsignificance[hadron][collision][yrange]["efffile"] - nhistoeff = paramsignificance[hadron][collision][yrange]["histoeff"] - nfilebkg = paramsignificance[hadron][collision][yrange]["bkgfile"] - nhistobkg = paramsignificance[hadron][collision][yrange]["histobkg"] - nhistoyieldth = paramsignificance[hadron][collision][yrange]["histoyield"] - nhistoyieldth_norm = paramsignificance[hadron][collision][yrange]["histoyield_norm"] - - with open(r"databases/general.yaml") as fileparamgen: - paramgen = yaml.safe_load(fileparamgen) - with open(r"databases/theory_yields.yaml") as fileyields: - paramyields = yaml.safe_load(fileyields) - - textcollision = paramgen["text_string"][collision] - textrapid = paramgen["text_string"][yrange] - textmodel = paramgen["text_string"][model] - - sigma_aa_b = paramgen["statistics"][collision]["sigmaAA_b"] - lumiaa_monthi_invnb = paramgen["statistics"][collision]["lumiAA_monthi_invnb"] - nevt = sigma_aa_b * lumiaa_monthi_invnb * 1e9 - # nevt = 2.*1e9 - bratio = paramgen["branchingratio"][hadron][brmode] - decaychannel = paramgen["latexparticle"][hadron] - - if hadron == "Chi_c" and yrange == "absy1p44": - bratio *= 0.8 # chi_c1 and chi_c2 are measured together: non-weighted average of their BRs - decaychannel = "#chi_{c} #rightarrow J/#psi #gamma" - - yieldmid = paramyields[model][collision][yrange][hadron] - text = "%s, N_{ev} = %f 10^{9}" % (textmodel, (float)(nevt) / 1.0e9) - text_a = "%s, %s, BR=%.2f%%" % (decaychannel, textrapid, bratio * 100) - text_b = "ALICE3 projection, with IRIS, no PID, %s" % textcollision - fileeff = TFile(nfileeff) - histoeff = fileeff.Get(nhistoeff) - filebkg = TFile(nfilebkg) - hbkgperevent = filebkg.Get(nhistobkg) - - fileyieldth = TFile(nfileyieldth) - histoyieldth = None - - if use_unnorm == 1: - histodndptth = fileyieldth.Get(nhistoyieldth) - histodndptth.Scale(1.0 / 70000.0) # TEMPORARY this is a fix to account for the - # conversion from a cross-section in mub - # to yields, sigma=70000 mub - else: - histodndptth = fileyieldth.Get(nhistoyieldth_norm) - integral = 0 - for ibin in range(histodndptth.GetNbinsX()): - binwdith = histodndptth.GetBinWidth(ibin + 1) - integral += histodndptth.GetBinContent(ibin + 1) * binwdith - histodndptth.Scale(1.0 / integral) - histodndptth.Scale(yieldmid) - print("yieldmid = %f\n", yieldmid) - integral = 0 - for ibin in range(histodndptth.GetNbinsX()): - binwdith = histodndptth.GetBinWidth(ibin + 1) - integral += histodndptth.GetBinContent(ibin + 1) * binwdith - print("yieldmid = %f\n", yieldmid) - - if hadron == "Chi_c" and collision == "pp14p0": - print("scaling signal yield by 0.1") - histodndptth.Scale(0.1) # because pythia8 is wrong by a factor ~10 - - if hadron == "Chi_c" and yrange == "absy1p44": - print("scaling bkg by 2*2, and signal by 3.4") - hbkgperevent.Scale( - 2 - ) # to take approximately into account the worsening of the sig/bkg in the full - # rapidity range (PbWO4 and W+Sci) - hbkgperevent.Scale( - 2 - ) # because in |y| < 1.44 we sum chi_c1 and chi_c2 (states are not resolved) - histodndptth.Scale( - 3.4 - ) # because in |y| < 1.44 we sum chi_c1 and chi_c2 (states are not resolved). - # Assuming chi_c2/chi_c1 (!!) from Pythia8 - - if hadron == "Chi_c" and yrange == "absy0p33": - print("scaling signal and bkg by 0.23, from |y| < 1.44 to |y| < 0.33") - hbkgperevent.Scale( - 0.23 - ) # to take into account the reduction of the statistics from |y| < 1.44 to |y| < 0.33 - # (the input file for chi_c is always |y| < 1.44) - histodndptth.Scale( - 0.23 - ) # to take into account the reduction of the statistics from |y| < 1.44 to |y| < 0.33 - # (the input file for chi_c is always |y| < 1.44) - - histoyieldth = histodndptth.Clone("histoyieldth") - - for ibin in range(histoyieldth.GetNbinsX()): - binwdith = histoyieldth.GetBinWidth(ibin + 1) - yieldperevent = histoyieldth.GetBinContent(ibin + 1) * binwdith * bratio - histoyieldth.SetBinContent(ibin + 1, yieldperevent) - histoyieldth.SetBinError(ibin + 1, 0.0) - histoyieldth = histoyieldth.Rebin(len(binanal) - 1, "histoyieldth", binanal) - histosignfperevent = histoyieldth.Clone("histosignfperevent") - histosignf = histoyieldth.Clone("histosignf") - histosigoverbkg = histoyieldth.Clone("histosigoverbkg") - - canvas = TCanvas("canvas", "A Simple Graph Example", 881, 176, 668, 616) - gStyle.SetOptStat(0) - canvas.SetHighLightColor(2) - canvas.Range(-1.25, -4.625, 11.25, 11.625) - canvas.SetFillColor(0) - canvas.SetBorderMode(0) - canvas.SetBorderSize(2) - canvas.SetLogy() - canvas.SetFrameBorderMode(0) - canvas.SetFrameBorderMode(0) - canvas.cd() - gPad.SetLogy() - - hempty = TH2F( - "hempty", - ";p_{T} (GeV/c); Significance(3#sigma)", - 100, - 0.0, - 10.0, - 100, - ymin, - ymax, - ) - hempty.GetXaxis().SetTitle("p_{T} (GeV/c)") - hempty.GetXaxis().SetLabelFont(42) - hempty.GetXaxis().SetTitleOffset(1) - hempty.GetXaxis().SetTitleFont(42) - hempty.GetYaxis().SetLabelFont(42) - hempty.GetYaxis().SetTitleOffset(1.35) - hempty.GetYaxis().SetTitleFont(42) - hempty.GetZaxis().SetLabelFont(42) - hempty.GetZaxis().SetTitleOffset(1) - hempty.GetZaxis().SetTitleFont(42) - hempty.Draw() - - histosignf = histosignfperevent.Clone("histosignf") - for ibin in range(histoyieldth.GetNbinsX()): - yieldperevent = histoyieldth.GetBinContent(ibin + 1) - bkgperevent = hbkgperevent.GetBinContent(ibin + 1) - eff = histoeff.GetBinContent(ibin + 1) - signalperevent = eff * yieldperevent - significanceperevent = 0 - if bkgperevent > 0: - significanceperevent = signalperevent / sqrt(signalperevent + bkgperevent) - signaloverbkg = 0 - if bkgperevent > 0: - signaloverbkg = signalperevent / bkgperevent - histosignfperevent.SetBinContent(ibin + 1, significanceperevent) - histosignfperevent.SetBinError(ibin + 1, 0.0) - histosignf.SetBinContent(ibin + 1, significanceperevent * sqrt(nevt)) - histosignf.SetBinError(ibin + 1, 0.0) - histosigoverbkg.SetBinContent(ibin + 1, signaloverbkg) - histosigoverbkg.SetBinError(ibin + 1, 0.0) - - histosignfperevent.SetLineColor(1) - histosignfperevent.SetMarkerColor(1) - histosignfperevent.SetLineWidth(1) - histosignf.SetLineColor(1) - histosignf.SetMarkerColor(1) - histosignf.SetLineWidth(2) - histosignf.Draw("same") - t_b = TLatex() - t_b.SetNDC() - t_b.SetTextFont(42) - t_b.SetTextColor(1) - t_b.SetTextSize(0.035) - t_b.SetTextAlign(12) - t_b.DrawLatex(0.2, 0.85, text_b) - t_c = TLatex() - t_c.SetNDC() - t_c.SetTextFont(42) - t_c.SetTextColor(1) - t_c.SetTextSize(0.03) - t_c.SetTextAlign(12) - t_c.DrawLatex(0.2, 0.80, text) - t_a = TLatex() - t_a.SetNDC() - t_a.SetTextFont(42) - t_a.SetTextColor(1) - t_a.SetTextSize(0.035) - t_a.SetTextAlign(12) - t_a.DrawLatex(0.2, 0.75, text_a) - canvas.SaveAs(hadron + "_" + collision + "_" + yrange + "_results.pdf") - canvas.SaveAs(hadron + "_" + collision + "_" + yrange + "_results.C") - - foutput = TFile( - "foutput" + hadron + "_" + collision + "_" + yrange + ".root", "recreate" - ) - foutput.cd() - histoeff.Write() - hbkgperevent.Write() - histosignfperevent.Write() - histoyieldth.Write() - histosignf.Write() - histodndptth.Write() - histosigoverbkg.Write() - - -# analysis("Lambda_c", "pp14p0", "absy1p44", "central", "Pyhia8mode2", 1) -# analysis("Jpsitoee", "pp14p0", "absy1p44", "central", "Pyhia8monash", 1) -# analysis("Chi_c", "pp14p0", "absy1p44", "central", "Pyhia8monash", 1) -# analysis("Chi_c", "pp14p0", "absy0p33", "central", "Pyhia8monash", 1) -# analysis("Chi_c", "PbPb5p52", "absy1p44", "central", "SHMC_2021", 0) -# analysis("Chi_c", "PbPb5p52", "absy0p33", "central", "SHMC_2021", 0) -# analysis("X3872", "pp14p0", "absy1p44", "central", "Pyhia8monash", 1) -analysis("B_plus", "pp14p0", "absy1p44", "central", "Pyhia8mode2", 1) diff --git a/Upgrade/g4me/README.md b/Upgrade/g4me/README.md deleted file mode 100644 index cf07028d..00000000 --- a/Upgrade/g4me/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# g4me analysis code - -## Introduction - -The purpose of this repository is to collect the macros and utilities to study the performances of the ALICE3 detector with heavy-flavoured hadrons, including charmed and beauty hadrons, HF jets and quarkonia. For these studies, the ALICE3 detector setup is simulated using the [DelphesO2](https://github.com/AliceO2Group/DelphesO2) package, while the heavy-flavour reconstruction is performed using the [O2](https://github.com/AliceO2Group/AliceO2) analysis framework. diff --git a/Upgrade/g4me/analysis/ExtractAccMaps2D.C b/Upgrade/g4me/analysis/ExtractAccMaps2D.C deleted file mode 100644 index adec9994..00000000 --- a/Upgrade/g4me/analysis/ExtractAccMaps2D.C +++ /dev/null @@ -1,68 +0,0 @@ -#include "TFile.h" -#include "TH1D.h" -#include "TH2D.h" -#include "TH3D.h" - -enum part_t { kMIDElectron, - kMIDMuon, - kMIDPion, - kMIDKaon, - kMIDProton, - kNPartTypes }; -const char* partName[kNPartTypes] = {"electron", "muon", "pion", "kaon", "proton"}; - -enum { kGoodMatch, - kFakeMatch, - kAllMatch }; -const char* tagMatch[3] = {"GoodMatch", "FakeMatch", "allMatch"}; - -TH2D *accEffMuonPID_2D[kNPartTypes] = {0}, *gen[kNPartTypes] = {0}, *recWithMuonPID[kNPartTypes][3] = {{0}}, *fakeMatchRate[kNPartTypes] = {0}; - -TH3D* hChi2VsMomVsEtaMatchedTracks[kNPartTypes][2] = {{0}}; -TH2D* hMomVsEtaITSTracks[kNPartTypes] = {0}; - -TFile* fileIn = 0; - -//==================================================================================================================================================== - -void ExtractAccMaps2D(const char* inputFileName = "histosTracking.root", double chi2Max = 1.5) -{ - - fileIn = new TFile(inputFileName); - - for (int iPart = 0; iPart < kNPartTypes; iPart++) { - - gen[iPart] = (TH2D*)fileIn->Get(Form("hMomVsEtaITSTracks_%s", partName[iPart])); - - for (int iMatch = 0; iMatch < 2; iMatch++) { - hChi2VsMomVsEtaMatchedTracks[iPart][iMatch] = (TH3D*)fileIn->Get(Form("hChi2VsMomVsEtaMatchedTracks_%s_%s", partName[iPart], tagMatch[iMatch])); - hChi2VsMomVsEtaMatchedTracks[iPart][iMatch]->GetXaxis()->SetRangeUser(0, chi2Max); - recWithMuonPID[iPart][iMatch] = (TH2D*)hChi2VsMomVsEtaMatchedTracks[iPart][iMatch]->Project3D("zy"); - recWithMuonPID[iPart][iMatch]->SetName(Form("recWithMuonPID_%s_%s", partName[iPart], tagMatch[iMatch])); - } - - recWithMuonPID[iPart][kAllMatch] = (TH2D*)recWithMuonPID[iPart][kGoodMatch]->Clone(Form("recWithMuonPID_%s_%s", partName[iPart], tagMatch[kAllMatch])); - recWithMuonPID[iPart][kAllMatch]->Add(recWithMuonPID[iPart][kFakeMatch]); - fakeMatchRate[iPart] = (TH2D*)recWithMuonPID[iPart][kFakeMatch]->Clone(Form("fakeMatchRate_%s", partName[iPart])); - fakeMatchRate[iPart]->Divide(recWithMuonPID[iPart][kAllMatch]); - fakeMatchRate[iPart]->SetTitle(Form("Fake match probability for for %ss", partName[iPart])); - - accEffMuonPID_2D[iPart] = (TH2D*)recWithMuonPID[iPart][kAllMatch]->Clone(Form("accEffMuonPID_2D_%s", partName[iPart])); - accEffMuonPID_2D[iPart]->Divide(gen[iPart]); - accEffMuonPID_2D[iPart]->SetTitle(Form("Acc #times Eff #times #muPID for %ss", partName[iPart])); - } - - TFile* fileOut = new TFile(Form("accEffMuonPID.MaxChi2_%3.1f.root", chi2Max), "recreate"); - - for (int iPart = 0; iPart < kNPartTypes; iPart++) { - - gen[iPart]->Write(); - fakeMatchRate[iPart]->Write(); - accEffMuonPID_2D[iPart]->Write(); - - for (int iMatch = 0; iMatch < 3; iMatch++) - recWithMuonPID[iPart][iMatch]->Write(); - } - - fileOut->Close(); -} diff --git a/Upgrade/g4me/analysis/GetPzOverPt.C b/Upgrade/g4me/analysis/GetPzOverPt.C deleted file mode 100644 index cc04dcca..00000000 --- a/Upgrade/g4me/analysis/GetPzOverPt.C +++ /dev/null @@ -1,20 +0,0 @@ -// converts eta into pzOverPt - -void GetPzOverPt() -{ - const Double_t etaMin = -1.60; - const Double_t etaMax = 1.60; - const Double_t step = 0.10; - Int_t nbEta = (etaMax - etaMin) / step + 1; - TLorentzVector convertor; - Double_t pzOverpt = 0, eta = 0; - - FILE* myfile = fopen("File_pzOverpt.txt", "w"); - for (int i = 0; i < nbEta; i++) { - eta = etaMin + i * step; - convertor.SetPtEtaPhiM(1, eta, 0, 1); - pzOverpt = convertor.Pz() / convertor.Px(); - fprintf(myfile, "%4.2f %4.2f\n", eta, pzOverpt); - } - fclose(myfile); -} diff --git a/Upgrade/g4me/analysis/MIDTrackletSelector.cxx b/Upgrade/g4me/analysis/MIDTrackletSelector.cxx deleted file mode 100644 index de526536..00000000 --- a/Upgrade/g4me/analysis/MIDTrackletSelector.cxx +++ /dev/null @@ -1,188 +0,0 @@ -#include "MIDTrackletSelector.h" -#include "THnSparse.h" -#include "TH3.h" -#include "TH2.h" -#include "TFile.h" -#include "TVector3.h" -#include "TMath.h" - -MIDTrackletSelector::MIDTrackletSelector() -{ - - mInputFile = NULL; - mTrackletAcc3D = NULL; - mTrackletAcc2D = NULL; - - for (int iCharge = 0; iCharge < kNChargeOptions; iCharge++) - mTrackletAcc4D[iCharge] = NULL; - - mIsSelectorSetup = kFALSE; -} - -//========================================================================================================== - -bool MIDTrackletSelector::Setup(const Char_t* nameInputFile = "muonTrackletAcceptance.root") -{ - - mInputFile = new TFile(nameInputFile); - if (!mInputFile) { - printf("File %s not found\n", nameInputFile); - return kFALSE; - } - if (!(mInputFile->IsOpen())) { - printf("File %s not open\n", nameInputFile); - return kFALSE; - } - - mTrackletAcc4D[kMuonMinus] = (THnSparse*)mInputFile->Get("trackletAcceptanceMuMinus"); - if (!mTrackletAcc4D[kMuonMinus]) { - printf("Object not found in file %s, quitting\n", mInputFile->GetName()); - return kFALSE; - } - - mTrackletAcc4D[kMuonPlus] = (THnSparse*)mInputFile->Get("trackletAcceptanceMuPlus"); - if (!mTrackletAcc4D[kMuonPlus]) { - printf("Object not found in file %s, quitting\n", mInputFile->GetName()); - return kFALSE; - } - - mTrackletAcc4D[kAllMuons] = (THnSparse*)mTrackletAcc4D[kMuonMinus]->Clone("trackletAcceptanceAllMuons"); - mTrackletAcc4D[kAllMuons]->Add(mTrackletAcc4D[kMuonPlus]); - - mTrackletAcc3D = (TH3C*)mTrackletAcc4D[kAllMuons]->Projection(0, 1, 2); - mTrackletAcc2D = (TH2C*)mTrackletAcc4D[kAllMuons]->Projection(1, 0); - - mEtaMax = mTrackletAcc4D[kAllMuons]->GetAxis(2)->GetXmax(); - mMomMax = mTrackletAcc4D[kAllMuons]->GetAxis(3)->GetBinCenter(mTrackletAcc4D[kAllMuons]->GetAxis(3)->GetNbins()); - mMomMin = mTrackletAcc4D[kAllMuons]->GetAxis(3)->GetBinCenter(1); - - mIsSelectorSetup = kTRUE; - - printf("Setup of MIDTrackletSelector successfully completed\n"); - return kTRUE; -} - -//==================================================================================================================================================== - -bool MIDTrackletSelector::IsMIDTrackletSelected(TVector3 posHitLayer1, TVector3 posHitLayer2, bool evalEta = kFALSE) -{ - - if (!mIsSelectorSetup) { - printf("ERROR: MIDTrackletSelector not initialized\n"); - return kFALSE; - } - - if (posHitLayer1.Perp() > posHitLayer2.Perp()) { - TVector3 tmp = posHitLayer1; - posHitLayer1 = posHitLayer2; - posHitLayer2 = tmp; - } - - double deltaPhi = posHitLayer2.DeltaPhi(posHitLayer1); - double deltaEta = posHitLayer2.Eta() - posHitLayer1.Eta(); - - if (evalEta) { - double eta = posHitLayer1.Eta(); - if (abs(eta) > mEtaMax) - return kFALSE; - return mTrackletAcc3D->GetBinContent(mTrackletAcc3D->FindBin(deltaEta, deltaPhi, eta)); - } - - else - return mTrackletAcc2D->GetBinContent(mTrackletAcc2D->FindBin(deltaEta, deltaPhi)); - - return kFALSE; -} - -//==================================================================================================================================================== - -bool MIDTrackletSelector::IsMIDTrackletSelectedWithSearchSpot(TVector3 posHitLayer1, TVector3 posHitLayer2, TVector3 posITStrackLayer1, bool evalEta = kFALSE) -{ - - if (!mIsSelectorSetup) { - printf("ERROR: MIDTrackletSelector not initialized\n"); - return kFALSE; - } - - if (posHitLayer1.Perp() > posHitLayer2.Perp()) { - TVector3 tmp = posHitLayer1; - posHitLayer1 = posHitLayer2; - posHitLayer2 = tmp; - } - - double deltaPhiITS = posITStrackLayer1.DeltaPhi(posHitLayer1); - double deltaEtaITS = posITStrackLayer1.Eta() - posHitLayer1.Eta(); - - if (TMath::Sqrt(deltaPhiITS * deltaPhiITS + deltaEtaITS * deltaEtaITS) > 0.2) - return kFALSE; - - return IsMIDTrackletSelected(posHitLayer1, posHitLayer2, evalEta); -} - -//==================================================================================================================================================== - -bool MIDTrackletSelector::IsMIDTrackletSelected(TVector3 posHitLayer1, TVector3 posHitLayer2, TVector3 trackITS, int charge = 0) -{ - - if (!mIsSelectorSetup) { - printf("ERROR: MIDTrackletSelector not initialized\n"); - return kFALSE; - } - - if (posHitLayer1.Perp() > posHitLayer2.Perp()) { - TVector3 tmp = posHitLayer1; - posHitLayer1 = posHitLayer2; - posHitLayer2 = tmp; - } - - double deltaPhi = posHitLayer2.DeltaPhi(posHitLayer1); - double deltaEta = posHitLayer2.Eta() - posHitLayer1.Eta(); - double eta = trackITS.Eta(); - double mom = trackITS.Mag(); - - if (abs(eta) > mEtaMax) - return kFALSE; - - if (mom > mMomMax) - mom = mMomMax; - if (mom < mMomMin) - mom = mMomMin; - - double coord[4] = {deltaEta, deltaPhi, eta, mom}; - - if (charge > 0) - return mTrackletAcc4D[kMuonPlus]->GetBinContent(mTrackletAcc4D[kMuonPlus]->GetBin(coord)); - else if (charge < 0) - return mTrackletAcc4D[kMuonMinus]->GetBinContent(mTrackletAcc4D[kMuonMinus]->GetBin(coord)); - else - return mTrackletAcc4D[kAllMuons]->GetBinContent(mTrackletAcc4D[kAllMuons]->GetBin(coord)); - - return kFALSE; -} - -//==================================================================================================================================================== - -bool MIDTrackletSelector::IsMIDTrackletSelectedWithSearchSpot(TVector3 posHitLayer1, TVector3 posHitLayer2, TVector3 trackITS, TVector3 posITStrackLayer1, int charge = 0) -{ - - if (!mIsSelectorSetup) { - printf("ERROR: MIDTrackletSelector not initialized\n"); - return kFALSE; - } - - if (posHitLayer1.Perp() > posHitLayer2.Perp()) { - TVector3 tmp = posHitLayer1; - posHitLayer1 = posHitLayer2; - posHitLayer2 = tmp; - } - - double deltaPhiITS = posITStrackLayer1.DeltaPhi(posHitLayer1); - double deltaEtaITS = posITStrackLayer1.Eta() - posHitLayer1.Eta(); - - if (TMath::Sqrt(deltaPhiITS * deltaPhiITS + deltaEtaITS * deltaEtaITS) > 0.2) - return kFALSE; - - return IsMIDTrackletSelected(posHitLayer1, posHitLayer2, trackITS, charge); -} - -//==================================================================================================================================================== diff --git a/Upgrade/g4me/analysis/MIDTrackletSelector.h b/Upgrade/g4me/analysis/MIDTrackletSelector.h deleted file mode 100644 index 2594b01a..00000000 --- a/Upgrade/g4me/analysis/MIDTrackletSelector.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef MIDTrackletSelector_h -#define MIDTrackletSelector_h - -#include "THnSparse.h" -#include "TH3.h" -#include "TH2.h" -#include "TFile.h" -#include "TVector3.h" -#include "TMath.h" - -using namespace std; - -class MIDTrackletSelector -{ - - public: - MIDTrackletSelector(); - ~MIDTrackletSelector() = default; - - enum { kMuonMinus, - kMuonPlus, - kAllMuons, - kNChargeOptions }; - - bool Setup(const Char_t* nameInputFile); - bool IsSelectorSetup() { return mIsSelectorSetup; } - bool IsMIDTrackletSelected(TVector3 posHitLayer1, TVector3 posHitLayer2, bool evalEta); - bool IsMIDTrackletSelected(TVector3 posHitLayer1, TVector3 posHitLayer2, TVector3 trackITS, int charge); - bool IsMIDTrackletSelectedWithSearchSpot(TVector3 posHitLayer1, TVector3 posHitLayer2, TVector3 posITStrackLayer1, bool evalEta); - bool IsMIDTrackletSelectedWithSearchSpot(TVector3 posHitLayer1, TVector3 posHitLayer2, TVector3 trackITS, TVector3 posITStrackLayer1, int charge); - - TH2C* GetAcc2D() { return mTrackletAcc2D; } - TH3C* GetAcc3D() { return mTrackletAcc3D; } - THnSparse* GetAcc4D(int charge) { return mTrackletAcc4D[charge]; } - - protected: - TFile* mInputFile; - TH3C* mTrackletAcc3D; - TH2C* mTrackletAcc2D; - THnSparse* mTrackletAcc4D[kNChargeOptions]; - bool mIsSelectorSetup; - double mEtaMax; - double mMomMax; - double mMomMin; -}; - -#endif diff --git a/Upgrade/g4me/analysis/PrepareTracksForMatchingAndFit.C b/Upgrade/g4me/analysis/PrepareTracksForMatchingAndFit.C deleted file mode 100644 index 0609a199..00000000 --- a/Upgrade/g4me/analysis/PrepareTracksForMatchingAndFit.C +++ /dev/null @@ -1,245 +0,0 @@ -#include "io.C" -#include "style.C" -#include -#include "TTree.h" -#include "TFile.h" -#include -#include "TVector3.h" -#include "TMatrixDSym.h" -#include "TClonesArray.h" -#include "TMath.h" -#include "TDatabasePDG.h" -#include "TParticle.h" -#include "TObjString.h" -#include "TSystem.h" -#include "TROOT.h" -#include "TRandom.h" -#include "TDatime.h" - -#include "MIDTrackletSelector.h" - -#ifdef __MAKECINT__ -#pragma link C++ class vector < TClonesArray> + ; -#endif - -// IDs of the two MIS layers, taken from the PVIDMapFile.dat produced by g4me -const int idLayerMID1 = 300; -const int idLayerMID2 = 301; - -const double rMaxITS = 110; // (in cm). Above this radius, hits are not considered as belonging to the ITS - -// This macro reads an output file from a g4me simulation and writes a TTree containing, event per event, a list of ITS tracks (i.e. TClonesArray -// of ITS hits from a same track) and MID tracklets (i.e. any combination of hits from the 1st and 2nd MID layers, passing the selections -// implemented in the macro IsMIDTrackletSelected.C) as an input for the fit routine based on GenFit - -TTree* treeOut = 0; - -IO_t io; - -Bool_t IsTrackCharged(Int_t iTrack); -Bool_t IsTrackInteresting(Int_t iTrack); - -//==================================================================================================================================================== - -void PrepareTracksForMatchingAndFit(const char* inputFileName, const char* outputFileName, const double hitMinP = 0.050) -{ - - TDatime t; - gRandom->SetSeed(t.GetDate() + t.GetYear() * t.GetHour() * t.GetMinute() * t.GetSecond()); - - MIDTrackletSelector* trackletSel = new MIDTrackletSelector(); - if (!(trackletSel->Setup("muonTrackletAcceptance.root"))) { - printf("MID tracklet selector could not be initialized. Quitting.\n"); - return; - } - - style(); - - const double resolutionITS = 5.e-4; // 5 um - const double resolutionMID = 100.e-4; // 100 um - - io.open(inputFileName); - auto nEvents = io.nevents(); - - int nPreparedTracksITS = 0, nHits_MIDLayer1 = 0, nHits_MIDLayer2 = 0, nPreparedTrackletsMID = 0; - - TFile* fileOut = new TFile(outputFileName, "recreate"); - treeOut = new TTree("TracksToBeFitted", "Tracks to be fitted"); - - TClonesArray trackCandidatesHitPosITS("TClonesArray"); // array of hit position arrays (for the ITS tracks) - TClonesArray trackCandidatesHitCovITS("TClonesArray"); // array of hit covariance arrays (for the ITS tracks) - TClonesArray trackCandidatesHitPosMID("TClonesArray"); // array of hit position arrays (for the MID tracklets) - TClonesArray trackCandidatesHitCovMID("TClonesArray"); // array of hit covariance arrays (for the MID tracklets) - TClonesArray particlesITS("TParticle"); // array of particles corresponding to the ITS tracks - std::vector idTrackITS; - std::vector idTrackMID; - - treeOut->Branch("TrackCandidatesHitPosITS", &trackCandidatesHitPosITS, 256000, -1); - treeOut->Branch("TrackCandidatesHitCovITS", &trackCandidatesHitCovITS, 256000, -1); - treeOut->Branch("TrackCandidatesHitPosMID", &trackCandidatesHitPosMID, 256000, -1); - treeOut->Branch("TrackCandidatesHitCovMID", &trackCandidatesHitCovMID, 256000, -1); - treeOut->Branch("ParticlesITS", &particlesITS, 256000, -1); - treeOut->Branch("idTrackITS", &idTrackITS); - treeOut->Branch("idTrackMID", &idTrackMID); - - TVector3 pos, mom; - TMatrixDSym covITS(3); - for (int i = 0; i < 3; i++) - covITS(i, i) = resolutionITS * resolutionITS; - TMatrixDSym covMID(3); - for (int i = 0; i < 3; i++) - covMID(i, i) = resolutionMID * resolutionMID; - - // loop over events - - for (int iEv = 0; iEv < nEvents; iEv++) { - - io.event(iEv); - - trackCandidatesHitPosITS.Clear(); - trackCandidatesHitCovITS.Clear(); - trackCandidatesHitPosMID.Clear(); - trackCandidatesHitCovMID.Clear(); - particlesITS.Clear(); - idTrackITS.clear(); - idTrackMID.clear(); - - std::vector allTracksHitPosITS(io.tracks.n, TClonesArray("TVector3")); - std::vector allTracksHitCovITS(io.tracks.n, TClonesArray("TMatrixDSym")); - - std::vector arrayHitID_MIDLayer1(io.hits.n, -1); - std::vector arrayHitID_MIDLayer2(io.hits.n, -1); - nHits_MIDLayer1 = 0; - nHits_MIDLayer2 = 0; - - for (int iHit = 0; iHit < io.hits.n; iHit++) { - - // filling arrays of hit IDs from MID layers (coming from any charged tracks) - - auto trackID = io.hits.trkid[iHit]; - - if (!(IsTrackCharged(trackID))) - continue; - - mom.SetXYZ(io.hits.px[iHit], io.hits.py[iHit], io.hits.pz[iHit]); - if (mom.Mag() < hitMinP) - continue; - - if (io.hits.lyrid[iHit] == idLayerMID1) - arrayHitID_MIDLayer1[nHits_MIDLayer1++] = iHit; - if (io.hits.lyrid[iHit] == idLayerMID2) - arrayHitID_MIDLayer2[nHits_MIDLayer2++] = iHit; - - // filling arrays of hits from ITS tracks (only for interesting tracks: charged and primary). - // Hits from ITS are by definition all the hits having radius < rMaxITS - - if (!(IsTrackInteresting(trackID))) - continue; - - pos.SetXYZ(gRandom->Gaus(io.hits.x[iHit], resolutionITS), gRandom->Gaus(io.hits.y[iHit], resolutionITS), gRandom->Gaus(io.hits.z[iHit], resolutionITS)); - if (pos.Perp() < rMaxITS) { - new ((allTracksHitPosITS.at(trackID))[(allTracksHitPosITS.at(trackID)).GetEntries()]) TVector3(pos); - new ((allTracksHitCovITS.at(trackID))[(allTracksHitCovITS.at(trackID)).GetEntries()]) TMatrixDSym(covITS); - } - } - - // filling the final arrays with the hit information from good ITS tracks - - nPreparedTracksITS = 0; - - for (int iTrack = 0; iTrack < io.tracks.n; iTrack++) { - if (IsTrackInteresting(iTrack)) { - new (trackCandidatesHitPosITS[nPreparedTracksITS]) TClonesArray(allTracksHitPosITS.at(iTrack)); - new (trackCandidatesHitCovITS[nPreparedTracksITS]) TClonesArray(allTracksHitCovITS.at(iTrack)); - idTrackITS.emplace_back(iTrack); - TParticle part; - part.SetPdgCode(io.tracks.pdg[iTrack]); - part.SetProductionVertex(io.tracks.vx[iTrack], io.tracks.vy[iTrack], io.tracks.vz[iTrack], io.tracks.vt[iTrack]); - part.SetMomentum(io.tracks.px[iTrack], io.tracks.py[iTrack], io.tracks.pz[iTrack], io.tracks.e[iTrack]); - new (particlesITS[nPreparedTracksITS]) TParticle(part); - nPreparedTracksITS++; - } - } - - // filling the final arrays with the hit information from selected MID tracklets - - nPreparedTrackletsMID = 0; - TVector3 posHitMID1, posHitMID2; - int idHitLayer1, idHitLayer2, trackIdHitLayer1, trackIdHitLayer2, trackletID; - - for (int iHitLayer1 = 0; iHitLayer1 < nHits_MIDLayer1; iHitLayer1++) { - - idHitLayer1 = arrayHitID_MIDLayer1[iHitLayer1]; - posHitMID1.SetXYZ(gRandom->Gaus(io.hits.x[idHitLayer1], resolutionMID), gRandom->Gaus(io.hits.y[idHitLayer1], resolutionMID), gRandom->Gaus(io.hits.z[idHitLayer1], resolutionMID)); - trackIdHitLayer1 = io.hits.trkid[idHitLayer1]; - - for (int iHitLayer2 = 0; iHitLayer2 < nHits_MIDLayer2; iHitLayer2++) { - - idHitLayer2 = arrayHitID_MIDLayer2[iHitLayer2]; - posHitMID2.SetXYZ(gRandom->Gaus(io.hits.x[idHitLayer2], resolutionMID), gRandom->Gaus(io.hits.y[idHitLayer2], resolutionMID), gRandom->Gaus(io.hits.z[idHitLayer2], resolutionMID)); - trackIdHitLayer2 = io.hits.trkid[idHitLayer2]; - - if (trackletSel->IsMIDTrackletSelected(posHitMID1, posHitMID2, kFALSE)) { - - if (trackIdHitLayer1 == trackIdHitLayer2) - trackletID = trackIdHitLayer1; - else - trackletID = -1; - - TClonesArray trackletMIDpos("TVector3"); - TClonesArray trackletMIDcov("TMatrixDSym"); - - new (trackletMIDpos[trackletMIDpos.GetEntries()]) TVector3(posHitMID1); - new (trackletMIDpos[trackletMIDpos.GetEntries()]) TVector3(posHitMID2); - new (trackletMIDcov[trackletMIDcov.GetEntries()]) TMatrixDSym(covMID); - new (trackletMIDcov[trackletMIDcov.GetEntries()]) TMatrixDSym(covMID); - - new (trackCandidatesHitPosMID[nPreparedTrackletsMID]) TClonesArray(trackletMIDpos); - new (trackCandidatesHitCovMID[nPreparedTrackletsMID]) TClonesArray(trackletMIDcov); - - idTrackMID.emplace_back(trackletID); - - nPreparedTrackletsMID++; - } - } - } - - printf("Ev %4d : %4d ITS tracks and %4d MID tracklets prepared for fitting\n", iEv, nPreparedTracksITS, nPreparedTrackletsMID); - - treeOut->Fill(); - } - - treeOut->Write(); -} - -//==================================================================================================================================================== - -Bool_t IsTrackInteresting(Int_t iTrack) -{ - - if (!(IsTrackCharged(iTrack))) - return kFALSE; - if (!(io.tracks.parent[iTrack] == -1)) - return kFALSE; - - return kTRUE; -} - -//==================================================================================================================================================== - -Bool_t IsTrackCharged(Int_t iTrack) -{ - - if (iTrack < 0 || iTrack >= io.tracks.n) { - printf("ERROR: track index %d out of range (io.tracks.n = %d)\n", iTrack, io.tracks.n); - return kFALSE; - } - if (!(TDatabasePDG::Instance()->GetParticle(io.tracks.pdg[iTrack]))) - return kFALSE; - if (TMath::Abs(TDatabasePDG::Instance()->GetParticle(io.tracks.pdg[iTrack])->Charge()) < 0.1) - return kFALSE; - - return kTRUE; -} - -//==================================================================================================================================================== diff --git a/Upgrade/g4me/analysis/PrepareTracksForMatchingAndFit_embedding.C b/Upgrade/g4me/analysis/PrepareTracksForMatchingAndFit_embedding.C deleted file mode 100644 index 864e1346..00000000 --- a/Upgrade/g4me/analysis/PrepareTracksForMatchingAndFit_embedding.C +++ /dev/null @@ -1,328 +0,0 @@ -#include "io.C" -#include "style.C" -#include -#include "TTree.h" -#include "TFile.h" -#include -#include "TVector3.h" -#include "TMatrixDSym.h" -#include "TClonesArray.h" -#include "TMath.h" -#include "TDatabasePDG.h" -#include "TParticle.h" -#include "TObjString.h" -#include "TSystem.h" -#include "TROOT.h" -#include "TRandom.h" -#include "TDatime.h" - -#include "MIDTrackletSelector.h" - -#ifdef __MAKECINT__ -#pragma link C++ class vector < TClonesArray> + ; -#endif - -// IDs of the two MIS layers, taken from the PVIDMapFile.dat produced by g4me -const int idLayerMID1 = 300; -const int idLayerMID2 = 301; - -const double rMaxITS = 110; // (in cm). Above this radius, hits are not considered as belonging to the ITS - -// This macro reads an output file from a g4me simulation and writes a TTree containing, event per event, a list of ITS tracks (i.e. TClonesArray -// of ITS hits from a same track) and MID tracklets (i.e. any combination of hits from the 1st and 2nd MID layers, passing the selections -// implemented in the macro IsMIDTrackletSelected.C) as an input for the fit routine based on GenFit - -TTree* treeOut = 0; - -IO_t io_underlying; -IO_t io_signal; - -Bool_t IsTrackCharged(struct IO_t*, Int_t iTrack); -Bool_t IsTrackInteresting(struct IO_t*, Int_t iTrack); - -//==================================================================================================================================================== - -void PrepareTracksForMatchingAndFit_embedding(const char* inputFileName_underlying, - const char* inputFileName_signal, - const char* outputFileName, - const bool prepareUnderlyingITS = kFALSE, - const double hitMinP = 0.050) -{ - - TDatime t; - gRandom->SetSeed(t.GetDate() + t.GetYear() * t.GetHour() * t.GetMinute() * t.GetSecond()); - - MIDTrackletSelector* trackletSel = new MIDTrackletSelector(); - if (!(trackletSel->Setup("muonTrackletAcceptance.root"))) { - printf("MID tracklet selector could not be initialized. Quitting.\n"); - return; - } - - style(); - - const double resolutionITS = 5.e-4; // 5 um - const double resolutionMID = 100.e-4; // 100 um - - io_underlying.open(inputFileName_underlying); - io_signal.open(inputFileName_signal); - - auto nEvents = min(io_underlying.nevents(), io_signal.nevents()); - - int nPreparedTracksITS = 0, nHits_MIDLayer1 = 0, nHits_MIDLayer2 = 0, nPreparedTrackletsMID = 0; - - TFile* fileOut = new TFile(outputFileName, "recreate"); - treeOut = new TTree("TracksToBeFitted", "Tracks to be fitted"); - - TClonesArray trackCandidatesHitPosITS("TClonesArray"); // array of hit position arrays (for the ITS tracks) - TClonesArray trackCandidatesHitCovITS("TClonesArray"); // array of hit covariance arrays (for the ITS tracks) - TClonesArray trackCandidatesHitPosMID("TClonesArray"); // array of hit position arrays (for the MID tracklets) - TClonesArray trackCandidatesHitCovMID("TClonesArray"); // array of hit covariance arrays (for the MID tracklets) - TClonesArray particlesITS("TParticle"); // array of particles corresponding to the ITS tracks - std::vector idTrackITS; - std::vector idTrackMID; - - treeOut->Branch("TrackCandidatesHitPosITS", &trackCandidatesHitPosITS, 256000, -1); - treeOut->Branch("TrackCandidatesHitCovITS", &trackCandidatesHitCovITS, 256000, -1); - treeOut->Branch("TrackCandidatesHitPosMID", &trackCandidatesHitPosMID, 256000, -1); - treeOut->Branch("TrackCandidatesHitCovMID", &trackCandidatesHitCovMID, 256000, -1); - treeOut->Branch("ParticlesITS", &particlesITS, 256000, -1); - treeOut->Branch("idTrackITS", &idTrackITS); - treeOut->Branch("idTrackMID", &idTrackMID); - - TVector3 pos, mom; - TMatrixDSym covITS(3); - for (int i = 0; i < 3; i++) - covITS(i, i) = resolutionITS * resolutionITS; - TMatrixDSym covMID(3); - for (int i = 0; i < 3; i++) - covMID(i, i) = resolutionMID * resolutionMID; - - // loop over events - - for (int iEv = 0; iEv < nEvents; iEv++) { - - io_underlying.event(iEv); - io_signal.event(iEv); - - trackCandidatesHitPosITS.Clear(); - trackCandidatesHitCovITS.Clear(); - trackCandidatesHitPosMID.Clear(); - trackCandidatesHitCovMID.Clear(); - particlesITS.Clear(); - idTrackITS.clear(); - idTrackMID.clear(); - - Int_t nTracks_underlying = io_underlying.tracks.n; - Int_t nTracks = io_underlying.tracks.n + io_signal.tracks.n; - Int_t nHits = io_underlying.hits.n + io_signal.hits.n; - - std::vector allTracksHitPosITS(nTracks, TClonesArray("TVector3")); - std::vector allTracksHitCovITS(nTracks, TClonesArray("TMatrixDSym")); - - std::vector arrayHit_MIDLayer1; - std::vector arrayHit_MIDLayer2; - std::vector arrayHitTrackID_MIDLayer1(nHits, -1); - std::vector arrayHitTrackID_MIDLayer2(nHits, -1); - nHits_MIDLayer1 = 0; - nHits_MIDLayer2 = 0; - - //-------------------------------------------------------------------------- - // Loop over underlying event hits - - for (int iHit = 0; iHit < io_underlying.hits.n; iHit++) { - - // filling arrays of hit IDs from MID layers (coming from any charged tracks) - - auto trackID = io_underlying.hits.trkid[iHit]; - - if (!(IsTrackCharged(&io_underlying, trackID))) - continue; - - mom.SetXYZ(io_underlying.hits.px[iHit], io_underlying.hits.py[iHit], io_underlying.hits.pz[iHit]); - if (mom.Mag() < hitMinP) - continue; - - if (io_underlying.hits.lyrid[iHit] == idLayerMID1) { - TVector3 vectHit(io_underlying.hits.x[iHit], io_underlying.hits.y[iHit], io_underlying.hits.z[iHit]); - arrayHit_MIDLayer1.emplace_back(vectHit); - arrayHitTrackID_MIDLayer1[nHits_MIDLayer1++] = trackID; - } - if (io_underlying.hits.lyrid[iHit] == idLayerMID2) { - TVector3 vectHit(io_underlying.hits.x[iHit], io_underlying.hits.y[iHit], io_underlying.hits.z[iHit]); - arrayHit_MIDLayer2.emplace_back(vectHit); - arrayHitTrackID_MIDLayer2[nHits_MIDLayer2++] = trackID; - } - - if (prepareUnderlyingITS) { - - // filling arrays of hits from ITS tracks (only for interesting tracks: charged and primary). - // Hits from ITS are by definition all the hits having radius < rMaxITS - if (!(IsTrackInteresting(&io_underlying, trackID))) - continue; - - pos.SetXYZ(gRandom->Gaus(io_underlying.hits.x[iHit], resolutionITS), gRandom->Gaus(io_underlying.hits.y[iHit], resolutionITS), gRandom->Gaus(io_underlying.hits.z[iHit], resolutionITS)); - if (pos.Perp() < rMaxITS) { - new ((allTracksHitPosITS.at(trackID))[(allTracksHitPosITS.at(trackID)).GetEntries()]) TVector3(pos); - new ((allTracksHitCovITS.at(trackID))[(allTracksHitCovITS.at(trackID)).GetEntries()]) TMatrixDSym(covITS); - } - } - } - - // filling the final arrays with the hit information from good ITS tracks - - nPreparedTracksITS = 0; - - if (prepareUnderlyingITS) { - for (int iTrack = 0; iTrack < io_underlying.tracks.n; iTrack++) { - if (IsTrackInteresting(&io_underlying, iTrack)) { - new (trackCandidatesHitPosITS[nPreparedTracksITS]) TClonesArray(allTracksHitPosITS.at(iTrack)); - new (trackCandidatesHitCovITS[nPreparedTracksITS]) TClonesArray(allTracksHitCovITS.at(iTrack)); - idTrackITS.emplace_back(iTrack); - TParticle part; - part.SetPdgCode(io_underlying.tracks.pdg[iTrack]); - part.SetProductionVertex(io_underlying.tracks.vx[iTrack], io_underlying.tracks.vy[iTrack], io_underlying.tracks.vz[iTrack], io_underlying.tracks.vt[iTrack]); - part.SetMomentum(io_underlying.tracks.px[iTrack], io_underlying.tracks.py[iTrack], io_underlying.tracks.pz[iTrack], io_underlying.tracks.e[iTrack]); - new (particlesITS[nPreparedTracksITS]) TParticle(part); - nPreparedTracksITS++; - } - } - } - - // filling the final arrays with the hit information from selected MID tracklets - - // end of loop over pythia tree - - //-------------------------------------------------------------------------- - // Loop over signal event hits - - for (int iHit = 0; iHit < io_signal.hits.n; iHit++) { - - // filling arrays of hit IDs from MID layers (coming from any charged tracks) - - auto trackID = io_signal.hits.trkid[iHit]; - - if (!(IsTrackCharged(&io_signal, trackID))) - continue; - - mom.SetXYZ(io_signal.hits.px[iHit], io_signal.hits.py[iHit], io_signal.hits.pz[iHit]); - if (mom.Mag() < hitMinP) - continue; - - if (io_signal.hits.lyrid[iHit] == idLayerMID1) { - TVector3 vectHit(io_signal.hits.x[iHit], io_signal.hits.y[iHit], io_signal.hits.z[iHit]); - arrayHit_MIDLayer1.emplace_back(vectHit); - arrayHitTrackID_MIDLayer1[nHits_MIDLayer1++] = trackID + nTracks_underlying; - } - if (io_signal.hits.lyrid[iHit] == idLayerMID2) { - TVector3 vectHit(io_signal.hits.x[iHit], io_signal.hits.y[iHit], io_signal.hits.z[iHit]); - arrayHit_MIDLayer2.emplace_back(vectHit); - arrayHitTrackID_MIDLayer2[nHits_MIDLayer2++] = trackID + nTracks_underlying; - } - - // filling arrays of hits from ITS tracks (only for interesting tracks: charged and primary). - // Hits from ITS are by definition all the hits having radius < rMaxITS - if (!(IsTrackInteresting(&io_signal, trackID))) - continue; - - pos.SetXYZ(gRandom->Gaus(io_signal.hits.x[iHit], resolutionITS), gRandom->Gaus(io_signal.hits.y[iHit], resolutionITS), gRandom->Gaus(io_signal.hits.z[iHit], resolutionITS)); - if (pos.Perp() < rMaxITS) { - new ((allTracksHitPosITS.at(trackID + nTracks_underlying))[(allTracksHitPosITS.at(trackID + nTracks_underlying)).GetEntries()]) TVector3(pos); - new ((allTracksHitCovITS.at(trackID + nTracks_underlying))[(allTracksHitCovITS.at(trackID + nTracks_underlying)).GetEntries()]) TMatrixDSym(covITS); - } - } - - // filling the final arrays with the hit information from good ITS tracks - - for (int iTrack = 0; iTrack < io_signal.tracks.n; iTrack++) { - if (IsTrackInteresting(&io_signal, iTrack)) { - new (trackCandidatesHitPosITS[nPreparedTracksITS]) TClonesArray(allTracksHitPosITS.at(iTrack + nTracks_underlying)); - new (trackCandidatesHitCovITS[nPreparedTracksITS]) TClonesArray(allTracksHitCovITS.at(iTrack + nTracks_underlying)); - idTrackITS.emplace_back(iTrack + nTracks_underlying); - TParticle part; - part.SetPdgCode(io_signal.tracks.pdg[iTrack]); - part.SetProductionVertex(io_signal.tracks.vx[iTrack], io_signal.tracks.vy[iTrack], io_signal.tracks.vz[iTrack], io_signal.tracks.vt[iTrack]); - part.SetMomentum(io_signal.tracks.px[iTrack], io_signal.tracks.py[iTrack], io_signal.tracks.pz[iTrack], io_signal.tracks.e[iTrack]); - new (particlesITS[nPreparedTracksITS]) TParticle(part); - nPreparedTracksITS++; - } - } - - // filling the final arrays with the hit information from selected MID tracklets - nPreparedTrackletsMID = 0; - TVector3 posHitMID1, posHitMID2; - int trackIdHitLayer1, trackIdHitLayer2, trackletID; - - for (int iHitLayer1 = 0; iHitLayer1 < nHits_MIDLayer1; iHitLayer1++) { - - posHitMID1.SetXYZ(gRandom->Gaus(arrayHit_MIDLayer1[iHitLayer1].X(), resolutionMID), gRandom->Gaus(arrayHit_MIDLayer1[iHitLayer1].Y(), resolutionMID), gRandom->Gaus(arrayHit_MIDLayer1[iHitLayer1].Z(), resolutionMID)); - trackIdHitLayer1 = arrayHitTrackID_MIDLayer1[iHitLayer1]; - - for (int iHitLayer2 = 0; iHitLayer2 < nHits_MIDLayer2; iHitLayer2++) { - - posHitMID2.SetXYZ(gRandom->Gaus(arrayHit_MIDLayer2[iHitLayer2].X(), resolutionMID), gRandom->Gaus(arrayHit_MIDLayer2[iHitLayer2].Y(), resolutionMID), gRandom->Gaus(arrayHit_MIDLayer2[iHitLayer2].Z(), resolutionMID)); - trackIdHitLayer2 = arrayHitTrackID_MIDLayer2[iHitLayer2]; - - if (trackletSel->IsMIDTrackletSelected(posHitMID1, posHitMID2, kFALSE)) { - - if (trackIdHitLayer1 == trackIdHitLayer2) - trackletID = trackIdHitLayer1; - else - trackletID = -1; - - TClonesArray trackletMIDpos("TVector3"); - TClonesArray trackletMIDcov("TMatrixDSym"); - - new (trackletMIDpos[trackletMIDpos.GetEntries()]) TVector3(posHitMID1); - new (trackletMIDpos[trackletMIDpos.GetEntries()]) TVector3(posHitMID2); - new (trackletMIDcov[trackletMIDcov.GetEntries()]) TMatrixDSym(covMID); - new (trackletMIDcov[trackletMIDcov.GetEntries()]) TMatrixDSym(covMID); - - new (trackCandidatesHitPosMID[nPreparedTrackletsMID]) TClonesArray(trackletMIDpos); - new (trackCandidatesHitCovMID[nPreparedTrackletsMID]) TClonesArray(trackletMIDcov); - - idTrackMID.emplace_back(trackletID); - - nPreparedTrackletsMID++; - } - } - } - //-------------------------------------------------------------------------- - printf("Ev %4d : %4d ITS tracks and %4d MID tracklets prepared for fitting\n", iEv, nPreparedTracksITS, nPreparedTrackletsMID); - - treeOut->Fill(); - } - - treeOut->Write(); -} - -//==================================================================================================================================================== - -Bool_t IsTrackInteresting(struct IO_t* io, Int_t iTrack) -{ - - if (!(IsTrackCharged(io, iTrack))) - return kFALSE; - if (!(io->tracks.parent[iTrack] == -1)) - return kFALSE; - - return kTRUE; -} - -//==================================================================================================================================================== - -Bool_t IsTrackCharged(struct IO_t* io, Int_t iTrack) -{ - - if (iTrack < 0 || iTrack >= io->tracks.n) { - printf("ERROR: track index %d out of range (io->tracks.n = %d)\n", iTrack, io->tracks.n); - return kFALSE; - } - if (!(TDatabasePDG::Instance()->GetParticle(io->tracks.pdg[iTrack]))) - return kFALSE; - if (TMath::Abs(TDatabasePDG::Instance()->GetParticle(io->tracks.pdg[iTrack])->Charge()) < 0.1) - return kFALSE; - - return kTRUE; -} - -//==================================================================================================================================================== diff --git a/Upgrade/g4me/analysis/SmoothAccMaps2D.C b/Upgrade/g4me/analysis/SmoothAccMaps2D.C deleted file mode 100644 index 71ca3e36..00000000 --- a/Upgrade/g4me/analysis/SmoothAccMaps2D.C +++ /dev/null @@ -1,91 +0,0 @@ -#include "TFile.h" -#include "TH1D.h" -#include "TH2D.h" -#include "TF1.h" -#include "TCanvas.h" -#include "TPad.h" -#include "TStyle.h" - -enum part_t { kMIDElectron, - kMIDMuon, - kMIDPion, - kMIDKaon, - kMIDProton, - kNPartTypes }; -const char* partName[kNPartTypes] = {"electron", "muon", "pion", "kaon", "proton"}; - -TFile* fileIn = 0; - -TH2D *accEffMuonPID_2D[kNPartTypes] = {0}, *accEffMuonPID_2D_Param[kNPartTypes] = {0}; -TH1D* hTmp = 0; -TF1* fitFunction = 0; - -TCanvas* cnv[kNPartTypes] = {0}; - -double GausPlusConstant(double* var, double* par); - -//==================================================================================================================================================== - -void SmoothAccMaps2D(const char* nameInputFile) -{ - - gStyle->SetOptStat(0); - - fileIn = new TFile(nameInputFile); - - fitFunction = new TF1("fitFunction", GausPlusConstant, -2, 2, 4); - - double offset, eta; - - for (int iPart = 0; iPart < kNPartTypes; iPart++) { - - accEffMuonPID_2D[iPart] = (TH2D*)fileIn->Get(Form("accEffMuonPID_2D_%s", partName[iPart])); - accEffMuonPID_2D_Param[iPart] = (TH2D*)accEffMuonPID_2D[iPart]->Clone(Form("accEffMuonPID_2D_Param_%s", partName[iPart])); - accEffMuonPID_2D_Param[iPart]->Smooth(1); - - for (int iBinMom = 1; iBinMom <= accEffMuonPID_2D_Param[iPart]->GetNbinsY(); iBinMom++) { - - hTmp = accEffMuonPID_2D_Param[iPart]->ProjectionX("hTmp", iBinMom, iBinMom); - - offset = 0.5 * (hTmp->GetBinContent(1) + hTmp->GetBinContent(hTmp->GetNbinsX())); - - fitFunction->SetParameter(0, offset); - fitFunction->SetParameter(1, hTmp->GetBinContent(hTmp->GetBinContent(hTmp->GetNbinsX() / 2)) - offset); - fitFunction->FixParameter(2, 0); - fitFunction->SetParameter(3, 0.4); - - hTmp->Fit(fitFunction, "Q", "", -1.6, 1.6); - - for (int iBinEta = 1; iBinEta <= accEffMuonPID_2D_Param[iPart]->GetNbinsX(); iBinEta++) { - - eta = accEffMuonPID_2D_Param[iPart]->GetXaxis()->GetBinCenter(iBinEta); - accEffMuonPID_2D_Param[iPart]->SetBinContent(iBinEta, iBinMom, fitFunction->Eval(eta)); - } - } - } - - for (int iPart = 0; iPart < kNPartTypes; iPart++) { - - cnv[iPart] = new TCanvas(Form("cnv_%ss", partName[iPart]), Form("cnv_%ss", partName[iPart]), 1200, 600); - cnv[iPart]->Divide(2, 1); - - cnv[iPart]->cd(1); - gPad->SetLogy(); - accEffMuonPID_2D[iPart]->GetZaxis()->SetRangeUser(0, 0.05); - accEffMuonPID_2D[iPart]->Draw("colz"); - cnv[iPart]->cd(2); - gPad->SetLogy(); - accEffMuonPID_2D_Param[iPart]->GetZaxis()->SetRangeUser(0, 0.05); - accEffMuonPID_2D_Param[iPart]->Draw("colz"); - } -} - -//==================================================================================================================================================== - -double GausPlusConstant(double* var, double* par) -{ - - return par[0] + par[1] * TMath::Gaus(var[0], par[2], par[3]); -} - -//==================================================================================================================================================== diff --git a/Upgrade/g4me/analysis/StudyMuonMatchingChi2.C b/Upgrade/g4me/analysis/StudyMuonMatchingChi2.C deleted file mode 100644 index 6bf06331..00000000 --- a/Upgrade/g4me/analysis/StudyMuonMatchingChi2.C +++ /dev/null @@ -1,570 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "mySpacepointDetectorHit.h" -#include "mySpacepointMeasurement.h" - -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include -#include -#include "TVector3.h" -#include "TMatrixDSym.h" -#include - -#include "TDatabasePDG.h" -#include -#include "TFile.h" -#include "TTree.h" -#include "TParticle.h" -#include "TH1D.h" -#include "TH2D.h" -#include "TH3D.h" -#include "THnSparse.h" -#include "TObjString.h" -#include "TDatime.h" - -#include "MIDTrackletSelector.h" - -enum part_t { kMIDElectron, - kMIDMuon, - kMIDPion, - kMIDKaon, - kMIDProton, - kNPartTypes }; -const int pdgCode[kNPartTypes] = {11, 13, 211, 321, 2212}; -const char* partName[kNPartTypes] = {"electron", "muon", "pion", "kaon", "proton"}; - -const int nLayerITS = 12; -const int nMinMeasurementsITS = nLayerITS; - -const double rLayerMID1 = 238.; // in cm - -enum { kGoodMatch, - kFakeMatch }; -const char* tagMatch[2] = {"GoodMatch", "FakeMatch"}; - -THnSparse* hDistanceFromGoodHitAtLayerMID1[kNPartTypes] = {0}; -TH3D* hChi2VsMomVsEtaMatchedTracks[kNPartTypes][2] = {{0}}; -TH2D* hMomVsEtaITSTracks[kNPartTypes] = {0}; - -const int nMaxHelixSteps = 100; - -void BookHistos(); - -void CircleFit(double x1, double y1, double x2, double y2, double x3, double y3, double& radius); -void EstimateInitialMomentum(genfit::mySpacepointDetectorHit* hitMin, - genfit::mySpacepointDetectorHit* hitMid, - genfit::mySpacepointDetectorHit* hitMax, - TVector3 vtx, - double fieldStrength, - double& charge, - TVector3& mom); - -//==================================================================================================================================================== - -void StudyMuonMatchingChi2(const char* inputFileName, - const char* outputFileName, - int pdg = -13, - bool displayTracks = kTRUE, - const char* geoFileName = "g4meGeometry.muon.root", - double fieldStrength = 0.5) -{ - - TDatime t; - gRandom->SetSeed(t.GetDate() + t.GetYear() * t.GetHour() * t.GetMinute() * t.GetSecond()); - - MIDTrackletSelector* trackletSel = new MIDTrackletSelector(); - if (!(trackletSel->Setup("muonTrackletAcceptance.root"))) { - printf("MID tracklet selector could not be initialized. Quitting.\n"); - return; - } - - BookHistos(); - - // init geometry and mag. field - new TGeoManager("Geometry", "Geane geometry"); - TGeoManager::Import(geoFileName); - genfit::FieldManager::getInstance()->init(new genfit::ConstField(0., 0., fieldStrength * 10)); // in kGauss - genfit::MaterialEffects::getInstance()->init(new genfit::TGeoMaterialInterface()); - - // init event display - genfit::EventDisplay* display = 0; - if (displayTracks) - display = genfit::EventDisplay::getInstance(); - - // init fitter - genfit::AbsKalmanFitter* fitter = new genfit::KalmanFitterRefTrack(); - fitter->setMaxIterations(20); - fitter->setMinIterations(10); - - TFile* fileIn = new TFile(inputFileName); - TTree* treeIn = (TTree*)fileIn->Get("TracksToBeFitted"); - TClonesArray *trackCandidatesHitPosITS = 0, *trackCandidatesHitCovITS = 0, *hitsPosITS = 0, *hitsCovITS = 0, *particlesITS = 0; - TClonesArray *trackCandidatesHitPosMID = 0, *trackCandidatesHitCovMID = 0, *hitsPosMID = 0, *hitsCovMID = 0; - std::vector* idTrackITS = 0; - std::vector* idTrackMID = 0; - - treeIn->SetBranchAddress("TrackCandidatesHitPosITS", &trackCandidatesHitPosITS); - treeIn->SetBranchAddress("TrackCandidatesHitCovITS", &trackCandidatesHitCovITS); - treeIn->SetBranchAddress("TrackCandidatesHitPosMID", &trackCandidatesHitPosMID); - treeIn->SetBranchAddress("TrackCandidatesHitCovMID", &trackCandidatesHitCovMID); - treeIn->SetBranchAddress("ParticlesITS", &particlesITS); - treeIn->SetBranchAddress("idTrackITS", &idTrackITS); - treeIn->SetBranchAddress("idTrackMID", &idTrackMID); - - TClonesArray myDetectorHitArrayITS("genfit::mySpacepointDetectorHit"); - TClonesArray myDetectorHitArrayGlobal("genfit::mySpacepointDetectorHit"); - - TParticle* part = 0; - - const double primVtxResolution = 3e-4; // 3 um (for ~10 contributors) - const double resolutionITS = 5e-4; // 5 um - const double resolutionMID = 100e-4; // 100 um - - // init the factory - - int myDetId = 1; - - genfit::MeasurementFactory factoryITS; - genfit::MeasurementProducer myProducerITS(&myDetectorHitArrayITS); - factoryITS.addProducer(myDetId, &myProducerITS); - - genfit::MeasurementFactory factoryGlobal; - genfit::MeasurementProducer myProducerGlobal(&myDetectorHitArrayGlobal); - factoryGlobal.addProducer(myDetId, &myProducerGlobal); - - int nEvents = treeIn->GetEntries(); - - // main loop - - for (int iEvent = 0; iEvent < nEvents; iEvent++) { - - // if (!(iEvent%100)) printf("\n----------- iEv = %5d of %5d ----------------\n",iEvent,nEvents); - printf("\n----------- iEv = %5d of %5d ----------------\n", iEvent, nEvents); - - treeIn->GetEntry(iEvent); - - int nTracksITS = trackCandidatesHitPosITS->GetEntries(); - int nTrackletsMID = trackCandidatesHitPosMID->GetEntries(); - - vector>> fitTracksGlobal(kNPartTypes, vector>(2)); // for drawing purposes only - vector> fitTracksITS(kNPartTypes); // for drawing purposes only - - for (int iTrackITS = 0; iTrackITS < nTracksITS; iTrackITS++) { - - bool fitITSConverged = kFALSE; - double charge = 1.; // abs value of muon charge - TVector3 posAtLayerMID1, fittedMomAtVtx; - - myDetectorHitArrayITS.Clear(); - - hitsPosITS = (TClonesArray*)trackCandidatesHitPosITS->At(iTrackITS); - hitsCovITS = (TClonesArray*)trackCandidatesHitCovITS->At(iTrackITS); - - // TrackCand - genfit::TrackCand myCandITS; - - int nMeasurementsITS = hitsPosITS->GetEntries(); - if (nMeasurementsITS < nMinMeasurementsITS) - continue; - - // printf("ITS track %3d has %2d nMeasurements\n",iTrackITS,nMeasurementsITS); - - for (int iHitITS = 0; iHitITS < nMeasurementsITS; iHitITS++) { - TVector3* posHit = (TVector3*)hitsPosITS->At(iHitITS); - TMatrixDSym* covHit = (TMatrixDSym*)hitsCovITS->At(iHitITS); - new (myDetectorHitArrayITS[iHitITS]) genfit::mySpacepointDetectorHit(*posHit, *covHit); - myCandITS.addHit(myDetId, iHitITS); - } - - TVector3 vtx(0, 0, 0); // primary vertex - - part = (TParticle*)particlesITS->At(iTrackITS); - vtx.SetXYZ(gRandom->Gaus(part->Vx(), primVtxResolution), - gRandom->Gaus(part->Vy(), primVtxResolution), - gRandom->Gaus(part->Vz(), primVtxResolution)); - - TVector3 momIni; - - EstimateInitialMomentum((genfit::mySpacepointDetectorHit*)myDetectorHitArrayITS[0], - (genfit::mySpacepointDetectorHit*)myDetectorHitArrayITS[nMeasurementsITS / 2], - (genfit::mySpacepointDetectorHit*)myDetectorHitArrayITS[nMeasurementsITS - 1], - vtx, - fieldStrength, - charge, - momIni); - - if ((TDatabasePDG::Instance()->GetParticle(pdg)->Charge() * charge) < 0) - pdg *= -1; - - // initial guess for cov - TMatrixDSym covSeed(6); - for (int i = 0; i < 3; i++) - covSeed(i, i) = resolutionITS * resolutionITS; - for (int i = 3; i < 6; i++) - covSeed(i, i) = pow(resolutionITS / nMeasurementsITS / sqrt(3), 2); - - // set start values and pdg to cand - myCandITS.setPosMomSeedAndPdgCode(vtx, momIni, pdg); - myCandITS.setCovSeed(covSeed); - - // create track - genfit::AbsTrackRep* repITS = new genfit::RKTrackRep(pdg); - genfit::Track fitTrackITS(myCandITS, factoryITS, repITS); - - // do the fit: ITS track ------------------- - - try { - fitter->processTrack(&fitTrackITS); - } catch (genfit::Exception& e) { - std::cerr << e.what(); - std::cerr << "Exception, next track" << std::endl; - continue; - } - - fitTrackITS.checkConsistency(); - - if (fitTrackITS.getFitStatus(repITS)->isFitConverged()) - fitITSConverged = kTRUE; - - if (fitITSConverged) { - - genfit::MeasuredStateOnPlane fittedStateITS(fitTrackITS.getFittedState(0, repITS)); - - // estimating kinematics at primary vertex - fittedStateITS.extrapolateToPoint(vtx); - fittedMomAtVtx = fittedStateITS.getMom(); - - // estimating position at first MID layer - // (I use a simple helix model which doesn't take into account propagation in materials. A proper way to do it would be fittedStateITS.extrapolateToCylinder(rLayerMID1) - // but unfortunately the method crashes when a track is absorbed in the materials and doesn't manage to arrive the requested MID layer) - genfit::HelixTrackModel helix(vtx, fittedMomAtVtx, charge); - double length = 0; - double deltaR = rLayerMID1; - int nSteps = 0; - while (deltaR > 1 && nSteps < nMaxHelixSteps) { // 1 cm tolerance for the radial distance between the MID layer and the effective extrapolation radius of the helix - length += deltaR; - posAtLayerMID1 = helix.getPos(length); - deltaR = rLayerMID1 - posAtLayerMID1.Perp(); - nSteps++; - } - } - - // do the fit: Global track ------------------- - - bool isGoodMatch = kFALSE; - double bestChi2OverNDF_Global = 99999999.; - genfit::Track* bestGlobalTrack = 0; - TVector3 goodHitAtLayerMID1; - bool goodTrackletExists = kFALSE; - - int nSelTracklets = 0; - - for (int iTrackletMID = 0; iTrackletMID < nTrackletsMID; iTrackletMID++) { - - if (!fitITSConverged) - continue; - - myDetectorHitArrayGlobal.Clear(); - - hitsPosMID = (TClonesArray*)trackCandidatesHitPosMID->At(iTrackletMID); - hitsCovMID = (TClonesArray*)trackCandidatesHitCovMID->At(iTrackletMID); - - int nMeasurementsMID = hitsPosMID->GetEntries(); - if (nMeasurementsMID != 2) - continue; - - // if (!(trackletSel->IsMIDTrackletSelected(*((TVector3*)hitsPosMID->At(0)),*((TVector3*)hitsPosMID->At(1)),fittedMomAtVtx,posAtLayerMID1,charge))) continue; - if (!(trackletSel->IsMIDTrackletSelectedWithSearchSpot(*((TVector3*)hitsPosMID->At(0)), *((TVector3*)hitsPosMID->At(1)), posAtLayerMID1, kFALSE))) - continue; - - nSelTracklets++; - - // TrackCand - genfit::TrackCand myCandGlobal; - - if (idTrackITS->at(iTrackITS) == idTrackMID->at(iTrackletMID)) { - // WARNING: if more than a tracklet has the track ID of the ITS track (for instance tracks doing spirals), the last registered one is - // registered in goodHitAtLayerMID1. However, the tracklet selector should remove the "backward tracklets" thanks to the comparison - // at the first MID layer between the tracklet position and the extrapolation of the ITS track - goodHitAtLayerMID1.SetXYZ(((TVector3*)hitsPosMID->At(0))->X(), ((TVector3*)hitsPosMID->At(0))->Y(), ((TVector3*)hitsPosMID->At(0))->Z()); - goodTrackletExists = kTRUE; - } - - int nHitsGlobal = 0; - - for (int iHitITS = 0; iHitITS < nMeasurementsITS; iHitITS++) { - TVector3* posHit = (TVector3*)hitsPosITS->At(iHitITS); - TMatrixDSym* covHit = (TMatrixDSym*)hitsCovITS->At(iHitITS); - new (myDetectorHitArrayGlobal[nHitsGlobal]) genfit::mySpacepointDetectorHit(*posHit, *covHit); - myCandGlobal.addHit(myDetId, nHitsGlobal); - nHitsGlobal++; - } - for (int iHitMID = 0; iHitMID < nMeasurementsMID; iHitMID++) { - TVector3* posHit = (TVector3*)hitsPosMID->At(iHitMID); - TMatrixDSym* covHit = (TMatrixDSym*)hitsCovMID->At(iHitMID); - new (myDetectorHitArrayGlobal[nHitsGlobal]) genfit::mySpacepointDetectorHit(*posHit, *covHit); - myCandGlobal.addHit(myDetId, nHitsGlobal); - nHitsGlobal++; - } - - myCandGlobal.setPosMomSeedAndPdgCode(vtx, fittedMomAtVtx, pdg); - myCandGlobal.setCovSeed(covSeed); - - genfit::AbsTrackRep* repGlobal = new genfit::RKTrackRep(pdg); - genfit::Track fitTrackGlobal(myCandGlobal, factoryGlobal, repGlobal); - - try { - fitter->processTrack(&fitTrackGlobal); - } catch (genfit::Exception& e) { - std::cerr << e.what(); - std::cerr << "Exception, next track" << std::endl; - continue; - } - - fitTrackGlobal.checkConsistency(); - - double chi2OverNDF_Global = fitTrackGlobal.getFitStatus(repGlobal)->getChi2() / fitTrackGlobal.getFitStatus(repGlobal)->getNdf(); - - // the best matching tracklet is defined as the one minimizing the global track chi2 - if (chi2OverNDF_Global < bestChi2OverNDF_Global) { - bestChi2OverNDF_Global = chi2OverNDF_Global; - isGoodMatch = (idTrackITS->at(iTrackITS) == idTrackMID->at(iTrackletMID)); - if (bestGlobalTrack) - delete bestGlobalTrack; - bestGlobalTrack = new genfit::Track(fitTrackGlobal); - } - } - - // printf("%3d selected tracklets out of %3d\n",nSelTracklets,nTrackletsMID); - - int pdgCodePart = TMath::Abs(part->GetPdgCode()); - double momPart = part->P(); - double etaPart = part->Eta(); - - for (int iPartType = 0; iPartType < kNPartTypes; iPartType++) { - if (pdgCodePart == pdgCode[iPartType]) { - - // filling histos with the ITS track information - - hMomVsEtaITSTracks[iPartType]->Fill(etaPart, momPart); - - fitTracksITS[iPartType].push_back(new genfit::Track(fitTrackITS)); - - if (goodTrackletExists) { - double deltaPhi = posAtLayerMID1.DeltaPhi(goodHitAtLayerMID1); - double deltaEta = posAtLayerMID1.Eta() - goodHitAtLayerMID1.Eta(); - double var[4] = {deltaEta, deltaPhi, etaPart, momPart}; - hDistanceFromGoodHitAtLayerMID1[iPartType]->Fill(var); - } - - // filling histos with the best ITS-MID match information - - if (bestGlobalTrack) { - - if (isGoodMatch) { - hChi2VsMomVsEtaMatchedTracks[iPartType][kGoodMatch]->Fill(bestChi2OverNDF_Global, etaPart, momPart); - if (iEvent < 100) - fitTracksGlobal[iPartType][kGoodMatch].push_back(new genfit::Track(*bestGlobalTrack)); - } else { - hChi2VsMomVsEtaMatchedTracks[iPartType][kFakeMatch]->Fill(bestChi2OverNDF_Global, etaPart, momPart); - if (iEvent < 100) - fitTracksGlobal[iPartType][kFakeMatch].push_back(new genfit::Track(*bestGlobalTrack)); - } - } - - break; - } - } - } - - if (iEvent < 100 && display) { - // add tracks to event display - display->addEvent(fitTracksGlobal[kMIDMuon][kGoodMatch]); - } - - } // end loop over events - - delete fitter; - - TFile* fileOut = new TFile(outputFileName, "recreate"); - for (int iPart = 0; iPart < kNPartTypes; iPart++) { - hMomVsEtaITSTracks[iPart]->Write(); - hDistanceFromGoodHitAtLayerMID1[iPart]->Write(); - for (int iMatch = 0; iMatch < 2; iMatch++) { - hChi2VsMomVsEtaMatchedTracks[iPart][iMatch]->Write(); - } - } - - fileOut->Close(); - - // open event display - if (display) - display->open(); -} - -//==================================================================================================================================================== - -void BookHistos() -{ - - // non-uniform p binning - - const int nMomBins = 40; - const double momBinCenter[nMomBins] = { - 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, - 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, - 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, - 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 10., 12., 15., 20.}; - - double momBinLimits[nMomBins + 1] = {0}; - momBinLimits[0] = momBinCenter[0] - 0.5 * (momBinCenter[1] - momBinCenter[0]); - for (int iMomBin = 0; iMomBin < nMomBins - 1; iMomBin++) - momBinLimits[iMomBin + 1] = 0.5 * (momBinCenter[iMomBin] + momBinCenter[iMomBin + 1]); - momBinLimits[nMomBins] = momBinCenter[nMomBins - 1] + 0.5 * (momBinCenter[nMomBins - 1] - momBinCenter[nMomBins - 2]); - - // uniform eta binning - - const int nEtaBins = 33; - const double etaMin = -1.65; - const double etaMax = 1.65; - - for (int iPart = 0; iPart < kNPartTypes; iPart++) { - - hMomVsEtaITSTracks[iPart] = new TH2D(Form("hMomVsEtaITSTracks_%s", partName[iPart]), Form("hMomVsEtaITSTracks_%s", partName[iPart]), - nEtaBins, etaMin, etaMax, nMomBins, momBinLimits[0], momBinLimits[nMomBins]); - hMomVsEtaITSTracks[iPart]->GetYaxis()->Set(nMomBins, momBinLimits); - - hMomVsEtaITSTracks[iPart]->Sumw2(); - hMomVsEtaITSTracks[iPart]->SetXTitle("#eta"); - hMomVsEtaITSTracks[iPart]->SetYTitle("p (GeV/c)"); - - for (int iMatch = 0; iMatch < 2; iMatch++) { - hChi2VsMomVsEtaMatchedTracks[iPart][iMatch] = new TH3D(Form("hChi2VsMomVsEtaMatchedTracks_%s_%s", partName[iPart], tagMatch[iMatch]), - Form("hChi2VsMomVsEtaMatchedTracks_%s_%s", partName[iPart], tagMatch[iMatch]), - 200, 0, 20, nEtaBins, etaMin, etaMax, nMomBins, momBinLimits[0], momBinLimits[nMomBins]); - hChi2VsMomVsEtaMatchedTracks[iPart][iMatch]->GetZaxis()->Set(nMomBins, momBinLimits); - - hChi2VsMomVsEtaMatchedTracks[iPart][iMatch]->Sumw2(); - hChi2VsMomVsEtaMatchedTracks[iPart][iMatch]->SetXTitle(Form("#chi^{2}/ndf (%s, %s)", partName[iPart], tagMatch[iMatch])); - hChi2VsMomVsEtaMatchedTracks[iPart][iMatch]->SetYTitle("#eta"); - hChi2VsMomVsEtaMatchedTracks[iPart][iMatch]->SetZTitle("p (GeV/c)"); - } - - int nBins[4] = {300, 300, nEtaBins, nMomBins}; - double xMin[4] = {-0.3, -0.3, etaMin, momBinLimits[0]}; - double xMax[4] = {0.3, 0.3, etaMax, momBinLimits[nMomBins]}; - - hDistanceFromGoodHitAtLayerMID1[iPart] = new THnSparseD(Form("hDistanceFromGoodHitAtLayerMID1_%s", partName[iPart]), - Form("hDistanceFromGoodHitAtLayerMID1_%s", partName[iPart]), - 4, nBins, xMin, xMax); - hDistanceFromGoodHitAtLayerMID1[iPart]->GetAxis(3)->Set(nMomBins, momBinLimits); - - hDistanceFromGoodHitAtLayerMID1[iPart]->GetAxis(0)->SetTitle("#Delta#eta"); - hDistanceFromGoodHitAtLayerMID1[iPart]->GetAxis(1)->SetTitle("#Delta#phi"); - hDistanceFromGoodHitAtLayerMID1[iPart]->GetAxis(2)->SetTitle("#eta"); - hDistanceFromGoodHitAtLayerMID1[iPart]->GetAxis(3)->SetTitle("#p (GeV/c)"); - } -} - -//==================================================================================================================================================== - -void CircleFit(double x1, double y1, double x2, double y2, double x3, double y3, double& radius) -{ - - auto d1x = y2 - y1; - auto d1y = x1 - x2; - auto d2x = y3 - y1; - auto d2y = x1 - x3; - - auto k = d1y * d2x - d1x * d2y; - - if (TMath::Abs(k) < 0.000001) { - radius = 999999999; - return; - } - - auto s1x = (x1 + x2) / 2; - auto s1y = (y1 + y2) / 2; - auto s2x = (x1 + x3) / 2; - auto s2y = (y1 + y3) / 2; - auto l = d1x * (s2y - s1y) - d1y * (s2x - s1x); - auto m = l / k; - - auto centerX = s2x + m * d2x; - auto centerY = s2y + m * d2y; - - auto dx = centerX - x1; - auto dy = centerY - y1; - radius = TMath::Sqrt(dx * dx + dy * dy); -} - -//==================================================================================================================================================== - -void EstimateInitialMomentum(genfit::mySpacepointDetectorHit* hitMin, - genfit::mySpacepointDetectorHit* hitMid, - genfit::mySpacepointDetectorHit* hitMax, - TVector3 vtx, - double fieldStrength, - double& charge, - TVector3& mom) -{ - - double radius = 0; - CircleFit(hitMin->getPos().X(), hitMin->getPos().Y(), - hitMid->getPos().X(), hitMid->getPos().Y(), - hitMax->getPos().X(), hitMax->getPos().Y(), - radius); - - double pt = TMath::Abs(radius * 0.01 * fieldStrength * charge / 3.3); // momentum component transverse to the mag. field - - TVector3 v1(hitMax->getPos().X() - hitMin->getPos().X(), - hitMax->getPos().Y() - hitMin->getPos().Y(), - hitMax->getPos().Z() - hitMin->getPos().Z()); - - TVector3 v2(hitMin->getPos().X() - vtx.X(), - hitMin->getPos().Y() - vtx.Y(), - hitMin->getPos().Z() - vtx.Z()); - - double eta = v1.Eta(); - double phi = v2.Phi(); - - mom.SetPtEtaPhi(pt, eta, phi); - - TVector3 v3(hitMax->getPos().X() - hitMid->getPos().X(), - hitMax->getPos().Y() - hitMid->getPos().Y(), - 0); - - TVector3 v4(hitMid->getPos().X() - hitMin->getPos().X(), - hitMid->getPos().Y() - hitMin->getPos().Y(), - 0); - - TVector3 v5 = v3.Cross(v4); - - if (v5.Z() < 0) - charge *= -1; -} - -//==================================================================================================================================================== diff --git a/Upgrade/g4me/analysis/empty.txt b/Upgrade/g4me/analysis/empty.txt deleted file mode 100644 index 8b137891..00000000 --- a/Upgrade/g4me/analysis/empty.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Upgrade/g4me/analysis/io.C b/Upgrade/g4me/analysis/io.C deleted file mode 100644 index 1a29adcb..00000000 --- a/Upgrade/g4me/analysis/io.C +++ /dev/null @@ -1,190 +0,0 @@ -#include -#include "TTree.h" -#include "TFile.h" -struct IO_t { - - static const int kMaxHits = 1048576; - - struct Hits_t { - int n; - int trkid[kMaxHits]; - float trklen[kMaxHits]; - float edep[kMaxHits]; - float x[kMaxHits]; - float y[kMaxHits]; - float z[kMaxHits]; - float t[kMaxHits]; - double e[kMaxHits]; - double px[kMaxHits]; - double py[kMaxHits]; - double pz[kMaxHits]; - int lyrid[kMaxHits]; - } hits; - - static const int kMaxTracks = 1048576; - - enum ETrackStatus_t { - kTransport = 1 << 0, - kElectromagnetic = 1 << 1, - kHadronic = 1 << 2, - kDecay = 1 << 3, - kConversion = 1 << 4, - kCompton = 1 << 5 - }; - - enum G4ProcessType { - fNotDefined, - fTransportation, - fElectromagnetic, - fOptical, - fHadronic, - fPhotolepton_hadron, - fDecay, - fGeneral, - fParameterisation, - fUserDefined, - fParallel, - fPhonon, - fUCN - }; - - enum G4EmProcessSubType { - fCoulombScattering = 1, - fIonisation = 2, - fBremsstrahlung = 3, - fPairProdByCharged = 4, - fAnnihilation = 5, - fAnnihilationToMuMu = 6, - fAnnihilationToHadrons = 7, - fNuclearStopping = 8, - fElectronGeneralProcess = 9, - - fMultipleScattering = 10, - - fRayleigh = 11, - fPhotoElectricEffect = 12, - fComptonScattering = 13, - fGammaConversion = 14, - fGammaConversionToMuMu = 15, - fGammaGeneralProcess = 16, - - fCerenkov = 21, - fScintillation = 22, - fSynchrotronRadiation = 23, - fTransitionRadiation = 24 - }; - - struct Tracks_t { - int n; - char proc[kMaxTracks]; - char sproc[kMaxTracks]; - int status[kMaxTracks]; - int parent[kMaxTracks]; - int particle[kMaxTracks]; - int pdg[kMaxTracks]; - double vt[kMaxTracks]; - double vx[kMaxTracks]; - double vy[kMaxTracks]; - double vz[kMaxTracks]; - double e[kMaxTracks]; - double px[kMaxTracks]; - double py[kMaxTracks]; - double pz[kMaxTracks]; - } tracks; - - struct Particles_t { - int n; - int parent[kMaxTracks]; - int pdg[kMaxTracks]; - double vt[kMaxTracks]; - double vx[kMaxTracks]; - double vy[kMaxTracks]; - double vz[kMaxTracks]; - double e[kMaxTracks]; - double px[kMaxTracks]; - double py[kMaxTracks]; - double pz[kMaxTracks]; - } particles; - - TTree *tree_hits = nullptr, *tree_tracks = nullptr, *tree_particles = nullptr; - - bool - open(std::string filename) - { - auto fin = TFile::Open(filename.c_str()); - std::cout << " io.open: reading data from " << filename << std::endl; - - tree_hits = (TTree*)fin->Get("Hits"); - tree_hits->SetBranchAddress("n", &hits.n); - tree_hits->SetBranchAddress("trkid", &hits.trkid); - tree_hits->SetBranchAddress("trklen", &hits.trklen); - tree_hits->SetBranchAddress("edep", &hits.edep); - tree_hits->SetBranchAddress("x", &hits.x); - tree_hits->SetBranchAddress("y", &hits.y); - tree_hits->SetBranchAddress("z", &hits.z); - tree_hits->SetBranchAddress("t", &hits.t); - tree_hits->SetBranchAddress("e", &hits.e); - tree_hits->SetBranchAddress("px", &hits.px); - tree_hits->SetBranchAddress("py", &hits.py); - tree_hits->SetBranchAddress("pz", &hits.pz); - tree_hits->SetBranchAddress("lyrid", &hits.lyrid); - auto tree_hits_nevents = tree_hits->GetEntries(); - - tree_tracks = (TTree*)fin->Get("Tracks"); - tree_tracks->SetBranchAddress("n", &tracks.n); - tree_tracks->SetBranchAddress("proc", &tracks.proc); - tree_tracks->SetBranchAddress("sproc", &tracks.sproc); - tree_tracks->SetBranchAddress("status", &tracks.status); - tree_tracks->SetBranchAddress("parent", &tracks.parent); - tree_tracks->SetBranchAddress("particle", &tracks.particle); - tree_tracks->SetBranchAddress("pdg", &tracks.pdg); - tree_tracks->SetBranchAddress("vt", &tracks.vt); - tree_tracks->SetBranchAddress("vx", &tracks.vx); - tree_tracks->SetBranchAddress("vy", &tracks.vy); - tree_tracks->SetBranchAddress("vz", &tracks.vz); - tree_tracks->SetBranchAddress("e", &tracks.e); - tree_tracks->SetBranchAddress("px", &tracks.px); - tree_tracks->SetBranchAddress("py", &tracks.py); - tree_tracks->SetBranchAddress("pz", &tracks.pz); - auto tree_tracks_nevents = tree_tracks->GetEntries(); - - tree_particles = (TTree*)fin->Get("Particles"); - if (tree_particles) { - tree_particles->SetBranchAddress("n", &particles.n); - tree_particles->SetBranchAddress("parent", &particles.parent); - tree_particles->SetBranchAddress("pdg", &particles.pdg); - tree_particles->SetBranchAddress("vt", &particles.vt); - tree_particles->SetBranchAddress("vx", &particles.vx); - tree_particles->SetBranchAddress("vy", &particles.vy); - tree_particles->SetBranchAddress("vz", &particles.vz); - tree_particles->SetBranchAddress("e", &particles.e); - tree_particles->SetBranchAddress("px", &particles.px); - tree_particles->SetBranchAddress("py", &particles.py); - tree_particles->SetBranchAddress("pz", &particles.pz); - } - auto tree_particles_nevents = tree_particles ? tree_particles->GetEntries() : 0; - - if (((tree_hits && tree_tracks) && (tree_hits_nevents != tree_tracks_nevents)) || - ((tree_hits && tree_particles) && (tree_hits_nevents != tree_particles_nevents))) { - std::cout << " io.open: entries mismatch in trees " << std::endl; - if (tree_hits) - std::cout << " " << tree_hits_nevents << " events in \'Hits\' tree " << std::endl; - if (tree_tracks) - std::cout << " " << tree_tracks_nevents << " events in \'Tracks\' tree " << std::endl; - if (tree_particles) - std::cout << " " << tree_particles_nevents << " events in \'Particles\' tree " << std::endl; - return true; - } - std::cout << " io.open: successfully retrieved " << tree_tracks_nevents << " events " << std::endl; - return false; - } - - int nevents() { return tree_tracks->GetEntries(); } - void event(int iev) - { - tree_tracks->GetEntry(iev); - tree_hits->GetEntry(iev); - if (tree_particles) - tree_particles->GetEntry(iev); - } -}; diff --git a/Upgrade/g4me/analysis/muonAccEffPID.root b/Upgrade/g4me/analysis/muonAccEffPID.root deleted file mode 100644 index 4d834868..00000000 Binary files a/Upgrade/g4me/analysis/muonAccEffPID.root and /dev/null differ diff --git a/Upgrade/g4me/analysis/muonTrackletAcceptance.root b/Upgrade/g4me/analysis/muonTrackletAcceptance.root deleted file mode 100644 index a0f29694..00000000 Binary files a/Upgrade/g4me/analysis/muonTrackletAcceptance.root and /dev/null differ diff --git a/Upgrade/g4me/setup/GetAbsoThicknessVsZ.C b/Upgrade/g4me/setup/GetAbsoThicknessVsZ.C deleted file mode 100644 index cebf01e7..00000000 --- a/Upgrade/g4me/setup/GetAbsoThicknessVsZ.C +++ /dev/null @@ -1,50 +0,0 @@ -#include "TMath.h" -#include -#include "TGraphErrors.h" - -const Int_t nbEta = 6; - -void GetAbsoThicknessVsZ(const Double_t Rint = 162, const Double_t ThicknessEta0 = 70, const Double_t etaMax = 1.6) -{ - const Int_t deltaZ = 20; - const Int_t NbCyl = 4; - Double_t zMax = 0; - - const Double_t eta[nbEta] = {0.0, 0.5, 1.0, 1.2, 1.4, 1.5}; - const Double_t expThick[nbEta] = {70, 65, 65, 60, 60, 50}; - Double_t zVsEta[nbEta] = {0}; - TGraphErrors* graphThicknessVsZ = new TGraphErrors(nbEta); - - graphThicknessVsZ->SetName("tgraph"); - graphThicknessVsZ->SetTitle("Ideal thickness of the absorber as a function of z"); - - FILE* myfile = fopen("AbsoThicknessVsZ.txt", "w"); - - Int_t thickness = 0; - zMax = (Rint + ThicknessEta0) * (1 - exp(-2 * etaMax)) / (2 * exp(-etaMax)) + deltaZ; - Int_t zCenter[NbCyl] = {0, 120, 260, (320 + int(zMax)) / 2}; - Int_t halfLength[NbCyl] = {40, 80, 60, (int(zMax) - 320) / 2}; - printf("%d\n", int(zMax)); - - const Int_t cylThick[NbCyl] = {70, 65, 60, 50}; - - for (int i = 0; i < nbEta; i++) { - zVsEta[i] = Rint * (exp(eta[i]) - exp(-eta[i])) / 2; - graphThicknessVsZ->SetPoint(i, zVsEta[i], expThick[i]); - graphThicknessVsZ->SetPointError(i, 0, 5); - } - - for (Int_t j = 0; j < NbCyl; j++) { - fprintf(myfile, "%6d %3d %6d\n", zCenter[j], cylThick[j], halfLength[j]); - if (j) { - fprintf(myfile, "%6d %3d %6d\n", -zCenter[j], cylThick[j], halfLength[j]); - } - } - fclose(myfile); - - /*graphThicknessVsZ->GetXaxis()->SetTitle("z (cm)"); - graphThicknessVsZ->GetYaxis()->SetTitle("Abso thickness (cm)"); - graphThicknessVsZ->SetMarkerStyle(21); - graphThicknessVsZ->Draw("apl");*/ - // s->Draw("same"); -} diff --git a/Upgrade/g4me/setup/GetEmCalThicknessVsZ.C b/Upgrade/g4me/setup/GetEmCalThicknessVsZ.C deleted file mode 100644 index 4119af8e..00000000 --- a/Upgrade/g4me/setup/GetEmCalThicknessVsZ.C +++ /dev/null @@ -1,20 +0,0 @@ -#include "TMath.h" -#include - -void GetEmCalThicknessVsZ(const Double_t Rint = 100, const Double_t ThicknessEta0 = 30, const Double_t etaMax = 1.6) -{ - const Int_t deltaZ = 10; - Double_t zMax = 0; - - FILE* myfile = fopen("EmCalThicknessVsZ.txt", "w"); - Double_t thickness = 0; - zMax = (Rint + ThicknessEta0) * (1 - exp(-2 * etaMax)) / (2 * exp(-etaMax)) + deltaZ; - for (Int_t z = 0; z < zMax; z += deltaZ) { - thickness = sin(atan(Rint / (z * 1.0))) * ThicknessEta0; - fprintf(myfile, "%6d %3d\n", z, TMath::Nint(thickness)); - if (z) { - fprintf(myfile, "%6d %3d\n", -z, TMath::Nint(thickness)); - } - } - fclose(myfile); -} diff --git a/Upgrade/g4me/setup/createSetupNewEmCalNewAbsoPartGun.sh b/Upgrade/g4me/setup/createSetupNewEmCalNewAbsoPartGun.sh deleted file mode 100644 index ccff9673..00000000 --- a/Upgrade/g4me/setup/createSetupNewEmCalNewAbsoPartGun.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/bash - -partName=$1 -en=$2 -abs=$3 -seedr=$4 -nEvents=$5 -emcalThicknessEta0=30 -pzOverpt=$6 - -emcalRmin=130 -emcalRmax=$((emcalRmin+emcalThicknessEta0)) - -absRmin=$((emcalRmax+2)) -absRmax=$((absRmin+abs)) - -detAfterAbs1Rmin=$((absRmax+5)) # inner radius of the first muonId active layer -detAfterAbs1Rmax=$((absRmax+6)) # outer radius - -detAfterAbs2Rmin=$((detAfterAbs1Rmax+15)) # inner radius of the second muonId active layer -detAfterAbs2Rmax=$((detAfterAbs1Rmax+16)) # outer radius - -# to avoid "+" and "-" symbols in the filename -partNameLabel="${partName/+/Plus}" -partNameLabel="${partNameLabel/-/Minus}" - -label=ParticleGun_${partNameLabel}_${en}GeV_abs_${abs}cm_pzOverpt_${pzOverpt}_seed_${seedr} -nameSetupFile=setup$label.mac - -### Starting creating setup file -if [ -f "$nameSetupFile" ]; then - rm "$nameSetupFile" -fi -{ - echo "/random/setSeeds $seedr $seedr" - echo "/process/optical/verbose 0" - echo "/detector/world/dimensions 6. 6. 6. m" - echo "### beam pipe" - echo "/detector/pipe/radius 1.6 cm" - echo "/detector/pipe/length 200. cm" - echo "/detector/pipe/thickness 500 um" - echo "#" - echo "/detector/enable ABSO" - echo "###SENSITIVE LAYERS" - echo "# rmin rmax runit length length_unit material add_sd" - echo "# First sensitive layer to register what comes out" - echo "/detector/ABSO/addCylinder $detAfterAbs1Rmin $detAfterAbs1Rmax cm 600. cm G4_Galactic true" - echo "# Second sensitive layer to register what comes out" - echo "/detector/ABSO/addCylinder $detAfterAbs2Rmin $detAfterAbs2Rmax cm 600. cm G4_Galactic true" - echo "#" - echo "#" - echo "### inner tracker radius length thickness" - echo "/detector/tracker/addLayer 0.5 cm 16 cm 50. um" - echo "/detector/tracker/addLayer 1.2 cm 16 cm 50. um" - echo "/detector/tracker/addLayer 2.5 cm 16 cm 50. um" - echo "/detector/tracker/addLayer 3.75 cm 16 cm 50. um" - echo "#" - echo "### outer tracker radius length thickness" - echo "/detector/tracker/addLayer 7. cm 40 cm 500. um" - echo "/detector/tracker/addLayer 12. cm 60. cm 500. um" - echo "/detector/tracker/addLayer 20. cm 80. cm 500. um" - echo "/detector/tracker/addLayer 30. cm 120. cm 500. um" - echo "/detector/tracker/addLayer 45. cm 180. cm 500. um" - echo "/detector/tracker/addLayer 60. cm 240. cm 500. um" - echo "/detector/tracker/addLayer 80. cm 320. cm 500. um" - echo "/detector/tracker/addLayer 100. cm 400. cm 500. um" - echo "#" - echo "#" - echo "### EMCAL" - echo "#" - echo "#" - echo "# rmin rmax runit length length_unit material add_sd x y z" -} >> "$nameSetupFile" - -if [ ! -f EmCalThicknessVsZ.txt ]; then - root -q -b -l GetEmCalThicknessVsZ.C\($emcalRmin,${emcalThicknessEta0}\) - echo "File EmCalThicknessVsZ.txt did not exit, I created it !" -fi - -while read -r z emcalThickness; do - emcalRmaxVsZ=$((emcalRmin + emcalThickness)) - echo "/detector/ABSO/addCylinder $emcalRmin $emcalRmaxVsZ cm 5 cm G4_PbWO4 false 0 0 $z" >> "$nameSetupFile" -done > "$nameSetupFile" - -if [ ! -f AbsoThicknessVsZ.txt ]; then - root -q -b -l GetAbsoThicknessVsZ.C\("$absRmin","$abs"\) - echo "File AbsoThicknessVsZ.txt did not exit, I created it !" -fi - -while read -r zabso absoThickness halflength; do - absoRmaxVsZ=$((absRmin + absoThickness)) - echo "/detector/ABSO/addCylinder $absRmin $absoRmaxVsZ cm $halflength cm G4_Fe false 0 0 $zabso" >> "$nameSetupFile" -done > "$nameSetupFile" diff --git a/Upgrade/g4me/setup/createSetupNewEmCalNewAbsoPythiaMB.sh b/Upgrade/g4me/setup/createSetupNewEmCalNewAbsoPythiaMB.sh deleted file mode 100644 index b6459e00..00000000 --- a/Upgrade/g4me/setup/createSetupNewEmCalNewAbsoPythiaMB.sh +++ /dev/null @@ -1,142 +0,0 @@ -#!/bin/bash - -abs=$1 -seedr=$2 -nEvents=$3 -emcalThicknessEta0=30 - -seedPythia=${seedr:1} - -emcalRmin=130 -emcalRmax=$((emcalRmin+emcalThicknessEta0)) - -absRmin=$((emcalRmax+2)) -absRmax=$((absRmin+abs)) - -detAfterAbs1Rmin=$((absRmax+5)) # inner radius of the first muonId active layer -detAfterAbs1Rmax=$((absRmax+6)) # outer radius - -detAfterAbs2Rmin=$((detAfterAbs1Rmax+15)) # inner radius of the second muonId active layer -detAfterAbs2Rmax=$((detAfterAbs1Rmax+16)) # outer radius - -nameConfigFile=pythia8_pp14_seed_${seedPythia}.cfg - -label=PythiaMB_abs_${abs}cm_seed_${seedr} -nameSetupFile=setup$label.mac - -### Starting creating setup file -if [ -f "$nameSetupFile" ]; then - rm "$nameSetupFile" -fi -{ - echo "/random/setSeeds $seedr $seedr" - echo "/process/optical/verbose 0" - echo "/detector/world/dimensions 6. 6. 6. m" - echo "### beam pipe" - echo "/detector/pipe/radius 1.6 cm" - echo "/detector/pipe/length 200. cm" - echo "/detector/pipe/thickness 500 um" - echo "#" - echo "/detector/enable ABSO" - echo "###SENSITIVE LAYERS" - echo "# rmin rmax runit length length_unit material add_sd" - echo "# First sensitive layer to register what comes out" - echo "/detector/ABSO/addCylinder $detAfterAbs1Rmin $detAfterAbs1Rmax cm 600. cm G4_Galactic true" - echo "# Second sensitive layer to register what comes out" - echo "/detector/ABSO/addCylinder $detAfterAbs2Rmin $detAfterAbs2Rmax cm 600. cm G4_Galactic true" - echo "#" - echo "#" - echo "### inner tracker radius length thickness" - echo "/detector/tracker/addLayer 0.5 cm 16 cm 50. um" - echo "/detector/tracker/addLayer 1.2 cm 16 cm 50. um" - echo "/detector/tracker/addLayer 2.5 cm 16 cm 50. um" - echo "/detector/tracker/addLayer 3.75 cm 16 cm 50. um" - echo "#" - echo "### outer tracker radius length thickness" - echo "/detector/tracker/addLayer 7. cm 40 cm 500. um" - echo "/detector/tracker/addLayer 12. cm 60. cm 500. um" - echo "/detector/tracker/addLayer 20. cm 80. cm 500. um" - echo "/detector/tracker/addLayer 30. cm 120. cm 500. um" - echo "/detector/tracker/addLayer 45. cm 180. cm 500. um" - echo "/detector/tracker/addLayer 60. cm 240. cm 500. um" - echo "/detector/tracker/addLayer 80. cm 320. cm 500. um" - echo "/detector/tracker/addLayer 100. cm 400. cm 500. um" - echo "#" - echo "#" - echo "### EMCAL" - echo "#" - echo "#" - echo "# rmin rmax runit length length_unit material add_sd x y z" -} >> "$nameSetupFile" - -if [ ! -f EmCalThicknessVsZ.txt ]; then - root -q -b -l GetEmCalThicknessVsZ.C\($emcalRmin,${emcalThicknessEta0}\) - echo "File EmCalThicknessVsZ.txt did not exit, I created it !" -fi - -while read -r z emcalThickness; do - emcalRmaxVsZ=$((emcalRmin + emcalThickness)) - echo "/detector/ABSO/addCylinder $emcalRmin $emcalRmaxVsZ cm 5 cm G4_PbWO4 false 0 0 $z" >> "$nameSetupFile" -done > "$nameSetupFile" - -if [ ! -f AbsoThicknessVsZ.txt ]; then - root -q -b -l GetAbsoThicknessVsZ.C\("$absRmin","$abs"\) - echo "File AbsoThicknessVsZ.txt did not exit, I created it !" -fi - -while read -r zabso absoThickness halflength; do - absoRmaxVsZ=$((absRmin + absoThickness)) - echo "/detector/ABSO/addCylinder $absRmin $absoRmaxVsZ cm $halflength cm G4_Fe false 0 0 $zabso" >> "$nameSetupFile" -done > "$nameSetupFile" - -### Starting creating config file -if [ -f "$nameConfigFile" ]; then - rm "$nameConfigFile" -fi -{ - echo "### service" - echo "Next:numberShowEvent = 0" - echo "### random" - echo "Random:setSeed = on" - echo "Random:seed = $seedPythia" - echo "### beams" - echo "Beams:idA 2212 # proton" - echo "Beams:idB 2212 # proton" - echo "Beams:eCM 14000. # GeV" - echo "### processes" - echo "SoftQCD:inelastic on # all inelastic processes" - echo "### decays" - echo "ParticleDecays:limitTau0 on" - echo "ParticleDecays:tau0Max = 10" -} >> "$nameConfigFile" diff --git a/Upgrade/g4me/setup/empty.txt b/Upgrade/g4me/setup/empty.txt deleted file mode 100644 index 8b137891..00000000 --- a/Upgrade/g4me/setup/empty.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Upgrade/g4me/setup/g4meGeometry.root b/Upgrade/g4me/setup/g4meGeometry.root deleted file mode 100644 index a2479cb1..00000000 Binary files a/Upgrade/g4me/setup/g4meGeometry.root and /dev/null differ diff --git a/Upgrade/pythia/README.md b/Upgrade/pythia/README.md deleted file mode 100644 index 638ca59b..00000000 --- a/Upgrade/pythia/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Pythia utilities - -## Introduction - -The purpose of this repository is to collect the macros and utilities to run Pythia predictions for charmed mesons, baryons, and exotic hadrons. - diff --git a/Upgrade/pythia/case.sh b/Upgrade/pythia/case.sh deleted file mode 100644 index 333b7773..00000000 --- a/Upgrade/pythia/case.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC2034 # Ignore unused parameters. - -# x3872_ptdep_Pyhia8monash_pp14p0_absy1p44 -# Jpsi_ptdep_Pyhia8monash_pp14p0_absy1p44 -# Lambda_c_ptdep_Pyhia8mode2_pp14p0_absy1p44 -# x3872_ptdep_Pyhia8monash_pp14p0_absy1p44 -# Bplus_ptdep_Pyhia8mode2_pp14p0_absy1p44 - -CASE=Chic1_ptdep_Pyhia8monash_pp14p0_absy1p44 -OUTPUTFOLDER=outputtest_chic1 diff --git a/Upgrade/pythia/clean.sh b/Upgrade/pythia/clean.sh deleted file mode 100644 index 4e9b9253..00000000 --- a/Upgrade/pythia/clean.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -rm ./*.exe -rm -rf outputtest diff --git a/Upgrade/pythia/compile_pythia.sh b/Upgrade/pythia/compile_pythia.sh deleted file mode 100755 index 294cb86b..00000000 --- a/Upgrade/pythia/compile_pythia.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC2086,SC2154 # Ignore unquoted options, not assigned variable. - -g++ "${1}.cc" \ - -O2 -ansi -W -Wall -std=c++11 -Wshadow -m64 -Wno-shadow \ - -o "${1}.exe" \ - -I$PY8_HEPMC3_INCLUDE -L$PY8_HEPMC3_LIB -lHepMC3 \ - -I$PY8_PYTHIA8_INCLUDE -L$PY8_PYTHIA8_LIB -lpythia8 \ - -I$PY8_ROOT_INCLUDE -L$Py8_ROOT_LIB -EG -lz \ - -I$PY8_FASTJET_INCLUDE -L$PY8_FASTJET_LIB -lfastjet -lRecursiveTools -lfastjettools -lNsubjettiness \ - -L$PY8_YAMLCPP_LIB -I$PY8_YAMLCPP_INCLUDE -lyaml-cpp \ - $PY8_FLAGS diff --git a/Upgrade/pythia/config.yaml b/Upgrade/pythia/config.yaml deleted file mode 100644 index aec4f49d..00000000 --- a/Upgrade/pythia/config.yaml +++ /dev/null @@ -1,133 +0,0 @@ ---- -x3872_ptdep_Pyhia8monash_pp14p0_absy1p44: - outputfile: x3872_ptdep_Pyhia8monash_pp14p0_absy1p44.root - myhadronname: x3872 - myhadronlatex: X(3872) - pdgparticle: 100443 # this is the psi(2s)! PDG of the particle for which we want the simulation - maxneventsperjob: 40000 # max events per file/process - tune: 14 # monash - beamidA: 2212 # incoming hadron - beamidB: 2212 # incoming hadron - eCM: 14000 - pythiamode: Charmonium:all = on - extramode: none # in case extra tuning is needed - nptbins: 100 - ptmin: 0. - ptmax: 50. - ymin: -1.44 - ymax: 1.44 - correction: 0.84585366 # in case you are using pythia from another hadron, 0.1*0.3468/0.041 - -Jpsi_ptdep_Pyhia8monash_pp14p0_absy1p44: - outputfile: Jpsi_ptdep_Pyhia8monash_pp14p0_absy1p44.root - myhadronname: Jpsi - myhadronlatex: J/psi - pdgparticle: 443 # this is the psi(2s)! PDG of the particle for which we want the simulation - maxneventsperjob: 10000 # max events per file/process - tune: 14 # monash - beamidA: 2212 # incoming hadron - beamidB: 2212 # incoming hadron - eCM: 14000 - pythiamode: Charmonium:all = on - extramode: none # in case extra tuning is needed - nptbins: 100 - ptmin: 0. - ptmax: 50. - ymin: -1.44 - ymax: 1.44 - correction: 1. - -Chic1_ptdep_Pyhia8monash_pp14p0_absy1p44: - outputfile: Chic1_ptdep_Pyhia8monash_pp14p0_absy1p44.root - myhadronname: Chic1 - myhadronlatex: chic1 - pdgparticle: 20443 - maxneventsperjob: 10000 # max events per file/process - tune: 14 # monash - beamidA: 2212 # incoming hadron - beamidB: 2212 # incoming hadron - eCM: 14000 - pythiamode: Charmonium:all = on - extramode: none # in case extra tuning is needed - nptbins: 100 - ptmin: 0. - ptmax: 50. - ymin: -1.44 - ymax: 1.44 - correction: 1. - -Lambda_c_ptdep_Pyhia8mode2_pp14p0_absy1p44: - outputfile: Lambda_c_ptdep_Pyhia8mode2_pp14p0_absy1p44.root - myhadronname: Lc - myhadronlatex: Lc - pdgparticle: 4122 - maxneventsperjob: 10000 # max events per file/process - tune: 14 # monash - beamidA: 2212 # incoming hadron - beamidB: 2212 # incoming hadron - eCM: 14000 - pythiamode: SoftQCD:all = on - extramode: mode2 # in case extra tuning is needed - nptbins: 100 - ptmin: 0. - ptmax: 50. - ymin: -1.44 - ymax: 1.44 - correction: 1. - -Xicc_ptdep_Pyhia8mode2_pp14p0_absy1p44: - outputfile: Xicc_ptdep_Pyhia8mode2_pp14p0_absy1p44.root - myhadronname: Xicc - myhadronlatex: Xicc - pdgparticle: 4424 - maxneventsperjob: 1000 # max events per file/process - tune: 14 # monash - beamidA: 2212 # incoming hadron - beamidB: 2212 # incoming hadron - eCM: 14000 - pythiamode: SoftQCD:all = on - extramode: mode2 # in case extra tuning is needed - nptbins: 100 - ptmin: 0. - ptmax: 50. - ymin: -1.44 - ymax: 1.44 - correction: 1. - -Omegaccc_ptdep_Pyhia8mode2_pp14p0_absy1p44: - outputfile: Omegaccc_ptdep_Pyhia8mode2_pp14p0_absy1p44.root - myhadronname: Omegaccc - myhadronlatex: Omegaccc - pdgparticle: 4444 - maxneventsperjob: 500000 # max events per file/process - tune: 14 # monash - beamidA: 2212 # incoming hadron - beamidB: 2212 # incoming hadron - eCM: 14000 - pythiamode: SoftQCD:all = on - extramode: mode2 # in case extra tuning is needed - nptbins: 100 - ptmin: 0. - ptmax: 50. - ymin: -1.44 - ymax: 1.44 - correction: 1. - -Bplus_ptdep_Pyhia8mode2_pp14p0_absy1p44: - outputfile: Bplus_ptdep_Pyhia8mode2_pp14p0_absy1p44.root - myhadronname: Bplus - myhadronlatex: B^{+} - pdgparticle: 521 - maxneventsperjob: 50000 # max events per file/process - tune: 14 # monash - beamidA: 2212 # incoming hadron - beamidB: 2212 # incoming hadron - eCM: 14000 - pythiamode: SoftQCD:all = on - extramode: mode2 # in case extra tuning is needed - nptbins: 100 - ptmin: 0. - ptmax: 50. - ymin: -1.44 - ymax: 1.44 - correction: 1. diff --git a/Upgrade/pythia/examplehadron.cc b/Upgrade/pythia/examplehadron.cc deleted file mode 100644 index 42c7572b..00000000 --- a/Upgrade/pythia/examplehadron.cc +++ /dev/null @@ -1,186 +0,0 @@ -// This is a simple macro to generate pythia predictions - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "Pythia8/Pythia.h" -#include "TTree.h" -#include "THnSparse.h" -#include "TProfile.h" -#include "TH1F.h" -#include "TH2F.h" -#include "TFile.h" -#include "TClonesArray.h" -#include "TFile.h" -#include "TList.h" -#include "TVector3.h" -#include "TMath.h" -#include "TNtuple.h" -#include "TString.h" -#include "TRandom3.h" -#include "TH1D.h" -#include "fastjet/PseudoJet.hh" -// #include "fastjet/ClusterSequence.hh" -// #include "fastjet/ClusterSequenceArea.hh" -#include -#include // needed for io -#include // needed for io -#include -#include /* time */ -// #include -// include -// include -#include - -using namespace Pythia8; - -int main(int argc, char* argv[]) -{ - (void)argc; - std::string mycase = argv[1]; - int cislo = -1; // unique number for each file - cislo = atoi(argv[2]); - // number of parallel jobs to be run. Be aware that each single file - // will be normalized by this number to make sure that the merged output - // file has the proper normalization! - int n_jobs = -1; - n_jobs = atoi(argv[3]); - - YAML::Node node = YAML::LoadFile("config.yaml"); - YAML::Node nodecase = node[mycase.data()]; - - const std::string myhadronname = nodecase["myhadronname"].as(); - const std::string myhadronlatex = nodecase["myhadronlatex"].as(); - int pdgparticle = nodecase["pdgparticle"].as(); - float correction = nodecase["correction"].as(); - int maxnevents = nodecase["maxneventsperjob"].as(); - int tune = nodecase["tune"].as(); - int beamidA = nodecase["beamidA"].as(); - int beamidB = nodecase["beamidB"].as(); - float eCM = nodecase["eCM"].as(); - const std::string pythiamode = nodecase["pythiamode"].as(); - const std::string outputfile = nodecase["outputfile"].as(); - double nptbins = nodecase["nptbins"].as(); - double ptmin = nodecase["ptmin"].as(); - double ptmax = nodecase["ptmax"].as(); - double ymin = nodecase["ymin"].as(); - double ymax = nodecase["ymax"].as(); - const std::string extramode = nodecase["extramode"].as(); - - // END OF CONFIGURATION - - // Generator. Process selection. LHC initialization. Histogram. - Pythia pythia; - pythia.readString(Form("%s", pythiamode.data())); - pythia.readString(Form("Main:numberOfEvents = %d", maxnevents)); - pythia.readString("Next:numberShowEvent = 0"); - pythia.readString(Form("Tune:pp = %d", tune)); - pythia.readString(Form("Beams:idA = %d", beamidA)); - pythia.readString(Form("Beams:idB = %d", beamidB)); - pythia.readString(Form("Beams:eCM = %f", eCM)); - - pythia.readString("Random:setSeed = on"); - pythia.readString(Form("Random:seed = %d", cislo)); - - if (extramode == "mode2") { - std::cout << "Running with mode2" << std::endl; - pythia.readString("ColourReconnection:mode = 1"); - pythia.readString("ColourReconnection:allowDoubleJunRem = off"); - pythia.readString("ColourReconnection:m0 = 0.3"); - pythia.readString("ColourReconnection:allowJunctions = on"); - pythia.readString("ColourReconnection:junctionCorrection = 1.20"); - pythia.readString("ColourReconnection:timeDilationMode = 2"); - pythia.readString("ColourReconnection:timeDilationPar = 0.18"); - pythia.readString("StringPT:sigma = 0.335"); - pythia.readString("StringZ:aLund = 0.36"); - pythia.readString("StringZ:bLund = 0.56"); - pythia.readString("StringFlav:probQQtoQ = 0.078"); - pythia.readString("StringFlav:ProbStoUD = 0.2"); - pythia.readString("StringFlav:probQQ1toQQ0join = 0.0275,0.0275,0.0275,0.0275"); - pythia.readString("MultiPartonInteractions:pT0Ref = 2.15"); - pythia.readString("BeamRemnants:remnantMode = 1"); - pythia.readString("BeamRemnants:saturation =5"); - } - pythia.init(); - - TFile* fout = new TFile(outputfile.data(), "recreate"); - - fout->cd(); - TH1F* hparticlept = new TH1F("hchargedparticles_pt", ";p_{T};charged particle dN/dp_{T}", nptbins, ptmin, ptmax); - TH1F* hptyields_unnorm = new TH1F(Form("h%syieldsvspt_unnorm", myhadronname.data()), ";p_{T} (GeV);unnormalized yield (particle+anti)", nptbins, ptmin, ptmax); - TH1F* hptcross = new TH1F(Form("h%scrossvspt", myhadronname.data()), Form(";p_{T} (GeV);%s d#sigma^{PYTHIA}/dp_{T} (#mu b/GeV)", myhadronlatex.data()), nptbins, ptmin, ptmax); - TH1F* hycharmcross = new TH1F("hycharmcross", ";y;%s d#sigma_{c}^{PYTHIA}/dy (#mu b)", 61, -30.5, 30.5); - TH1F* hycross = new TH1F("hycross", ";y;%s d#sigma_{HF}^{PYTHIA}/dy (#mu b)", 61, -30.5, 30.5); - TH2F* hptycharmcross = new TH2F("hptcharmcross", ";p_{T} (GeV); y", 100, 0., 100., 60, -30., 30.); - - // Begin event loop. Generate event. Skip if error. List first one. - int nmyhadron = 0; - for (int iEvent = 0; iEvent < maxnevents; ++iEvent) { - - pythia.next(); - - for (int i = 0; i < pythia.event.size(); ++i) { - if (pythia.event[i].pT() < 0 || pythia.event[i].pT() > 1.e+5) - continue; - if (pythia.event[i].idAbs() == 4) { - hycharmcross->Fill(pythia.event[i].y()); - hptycharmcross->Fill(pythia.event[i].pT(), pythia.event[i].y()); - } - if (pythia.event[i].idAbs() == pdgparticle) { - hycross->Fill(pythia.event[i].y()); - } - if (pythia.event[i].y() < ymin || pythia.event[i].y() > ymax) - continue; - - hparticlept->Fill(pythia.event[i].pT()); - if (pythia.event[i].idAbs() == pdgparticle) { - ++nmyhadron; - hptyields_unnorm->Fill(pythia.event[i].pT()); - } - // End of event loop. Statistics. Histogram. Done. - } - } - pythia.stat(); - int nbinspT = hptcross->GetNbinsX(); - double norm_fact = correction * pythia.info.sigmaGen() * 1000 / (2 * n_jobs * pythia.info.nAccepted()); - printf("norm fact %f\n", norm_fact); - double contentmyhadron[nbinspT], binwidthmyhadron[nbinspT]; - - for (int ibin = 0; ibin < nbinspT; ibin++) { - contentmyhadron[ibin] = hptyields_unnorm->GetBinContent(ibin); - binwidthmyhadron[ibin] = hptyields_unnorm->GetBinWidth(ibin); - printf("bin %d, Content %f, binwidth %f\n", ibin, contentmyhadron[ibin], binwidthmyhadron[ibin]); - hptcross->SetBinContent(ibin, contentmyhadron[ibin] * norm_fact / binwidthmyhadron[ibin]); - } - const int nbinx = hptycharmcross->GetNbinsX(); - const int nbiny = hptycharmcross->GetNbinsY(); - - double contentmyhadronxy[nbinx][nbinx]; - double binwidthmyhadronxy[nbinx][nbinx]; - for (int ibinx = 0; ibinx < nbinx; ibinx++) { - for (int ibiny = 0; ibiny < nbiny; ibiny++) { - contentmyhadronxy[ibinx][ibiny] = hptycharmcross->GetBinContent(ibinx + 1, ibiny + 1); - binwidthmyhadronxy[ibinx][ibiny] = hptycharmcross->GetXaxis()->GetBinWidth(ibinx + 1) * hptycharmcross->GetYaxis()->GetBinWidth(ibiny + 1); - hptycharmcross->SetBinContent(ibinx + 1, ibiny + 1, contentmyhadronxy[ibinx][ibiny] * norm_fact / binwidthmyhadronxy[ibinx][ibiny]); - } - } - hycharmcross->Scale(norm_fact); - hycross->Scale(norm_fact); - printf("nAccepted %ld, nTried %ld\n", pythia.info.nAccepted(), pythia.info.nTried()); - printf("pythia.info.sigmaGen() %f\n", pythia.info.sigmaGen()); - printf("N myhadron %d", nmyhadron); - hptcross->Write(); - hptyields_unnorm->Write(); - hptycharmcross->Write(); - hycharmcross->Write(); - hycross->Write(); - fout->Write(); - return 0; -} diff --git a/Upgrade/pythia/merge.sh b/Upgrade/pythia/merge.sh deleted file mode 100644 index 2b1141dd..00000000 --- a/Upgrade/pythia/merge.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC1090 # Ignore non-constant source. - -export CASEFILE=case.sh -source $CASEFILE -rm "$OUTPUTFOLDER/$CASE.root" -rm "../InputsTheory/$CASE.root" -hadd "$OUTPUTFOLDER/$CASE.root" "$OUTPUTFOLDER"/file_*/"$CASE".root -cp "$OUTPUTFOLDER/$CASE.root" "../InputsTheory/$CASE.root" diff --git a/Upgrade/pythia/runhadron.sh b/Upgrade/pythia/runhadron.sh deleted file mode 100755 index 43d12217..00000000 --- a/Upgrade/pythia/runhadron.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC1090 # Ignore non-constant source. - -###### PLEASE CONFIGURE THESE PARAMETERS ##### -SETUPFILE=/home/pyadmin/software/setup_scripts/setup-pythia8.sh #contains env. variables -COMPILER=compile_pythia.sh -export CASEFILE=case.sh -source $CASEFILE -NJOBS=50 #WARNING: BE AWARE THAT THE FILES PRODUCED BY EACH JOB WILL HAVE - #1/NJOBS AS NORMALIZATION, TO PRODUCE MERGED FILES PROPERLY NORMALIZED. -echo "----------------------------------" -echo "----------------------------------" -echo "----------------------------------" -echo "$CASE" -echo "----------------------------------" -echo "----------------------------------" -echo "----------------------------------" - -###### -rm ./*.root ./*.exe -source $SETUPFILE -./$COMPILER examplehadron - -rm -rf "$OUTPUTFOLDER" -mkdir "$OUTPUTFOLDER" -cd "$OUTPUTFOLDER" || exit -for i in $(eval "echo {1..$NJOBS}"); do - mkdir "file_$i" - cd "file_$i" || exit - cp ../../examplehadron.exe . - cp ../../config.yaml . - echo "$RANDOM" - ./examplehadron.exe "$CASE" "$RANDOM" "$NJOBS" & - cd .. -done diff --git a/Upgrade/quickcalculations/geometry.py b/Upgrade/quickcalculations/geometry.py deleted file mode 100644 index 2ac20ba4..00000000 --- a/Upgrade/quickcalculations/geometry.py +++ /dev/null @@ -1,49 +0,0 @@ -# pylint: disable=missing-docstring -import math - - -def geometrybarrel(): - radius_list = [ - 0.0050, - 0.0120, - 0.0250, - 0.0375, - 0.0700, - 0.1200, - 0.2000, - 0.3000, - 0.4500, - 0.6000, - 0.8000, - 1.0000, - ] - halflength_list = [ - 0.15, - 0.15, - 0.15, - 0.62, - 0.62, - 0.62, - 0.62, - 0.62, - 1.32, - 1.32, - 1.32, - 1.32, - ] - theta_list = [] - eta_list = [] - for i, _ in enumerate(radius_list): - angle = math.atan(radius_list[i] / halflength_list[i]) - - eta = -math.log(math.tan(angle / 2.0)) - theta_list.append(angle) - eta_list.append(eta) - - print( - "layer=%d, radius=%.2f, halflength=%.2f, angle=%.2f, etamax =%.2f" - % (i, radius_list[i], halflength_list[i], theta_list[i], eta_list[i]) - ) - - -geometrybarrel() diff --git a/codeQA/o2qaplots/.gitignore b/codeQA/o2qaplots/.gitignore deleted file mode 100644 index 409424f8..00000000 --- a/codeQA/o2qaplots/.gitignore +++ /dev/null @@ -1,198 +0,0 @@ -.local -.idea -.ipython -.vscode - -# PYTHON gitignore from github - -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints -.jupyter - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# MAC OS gitignore -.DS_Store - - -# C++ gitignore from github -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - - -# CMake gitignore from github -CMakeLists.txt.user -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake -_deps \ No newline at end of file diff --git a/codeQA/o2qaplots/Dockerfile b/codeQA/o2qaplots/Dockerfile deleted file mode 100644 index 4f0d9a29..00000000 --- a/codeQA/o2qaplots/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM centos:7 - -SHELL ["/bin/bash", "-c"] - -# Create a user -RUN groupadd -r nemo && useradd --no-log-init -r -g nemo nemo -# Set it for subsequent commands -USER nemo - -# Install ROOT -RUN yum install -y epel-release \ - && yum install -y \ - python3-3.6.8-18.el7.x86_64 \ - python36-root-6.22.06-1.el7.x86_64 \ - root-6.22.06-1.el7.x86_64 \ - && yum clean all \ - && rm -rf /var/cache/yum - -COPY requirements.txt /requirements/requirements.txt - -RUN pip3 install -r /requirements/requirements.txt --no-cache-dir - -COPY . /o2qaplots -RUN pip3 install -e /o2qaplots/. --no-cache-dir diff --git a/codeQA/o2qaplots/README.md b/codeQA/o2qaplots/README.md deleted file mode 100644 index c6d1b15e..00000000 --- a/codeQA/o2qaplots/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Plots for the O2QA - -## Install the package in your system - -One of the easiest way to work with qa plotting macros is to install them as a package. -You can install it by navigating into this folder installing it using pip (or pip3 depending on your system): - - pip install -e . - -In order to run the QA plotting, you can check the available commands by running - - o2qa --help - -You can also get more information for each option, such as - - o2qa plot --help - -## Run the scripts without installing - -You can run the script directly. This will require you to run python in the correct directory -(the same one that has the setup.py and this README file). Go to the folder containing this file -and run: - - python o2qaplots/cli.py --help. - -The same instructions as for `Install the package in your system` apply here to check the available commands. - -## Run in a (docker) container - -Having problems with python versions? Something just does not work? Addicted to docker? -Or does it sparks joy on you to see your analysis running in an isolated and reproducible setup? -You can use the `Dockerfiles` and `docker-compose` configuration to help you run the analysis. diff --git a/codeQA/o2qaplots/docker-compose.yml b/codeQA/o2qaplots/docker-compose.yml deleted file mode 100644 index fc962d7b..00000000 --- a/codeQA/o2qaplots/docker-compose.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: "3.7" - -services: - plotting: - build: - context: . - volumes: - - .:/o2qaplots/ - tty: true diff --git a/codeQA/o2qaplots/o2qaplots/__init__.py b/codeQA/o2qaplots/o2qaplots/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/codeQA/o2qaplots/o2qaplots/cli.py b/codeQA/o2qaplots/o2qaplots/cli.py deleted file mode 100644 index 82aed4f4..00000000 --- a/codeQA/o2qaplots/o2qaplots/cli.py +++ /dev/null @@ -1,46 +0,0 @@ -import argparse - -import ROOT -from o2qaplots.efficiency.efficiency import Efficiency -from o2qaplots.plot1d import Plot1D, Plot2D -from o2qaplots.tracking_resolution.ip.ip import ImpactParameter - -ROOT.PyConfig.IgnoreCommandLineOptions = True - - -def cli(): - """Main entrypoint of the program. - It redirects the input to the correct task.""" - - help_general = "Action to be performed." - - parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers(dest="command", help=help_general) - - tasks = [Efficiency, ImpactParameter, Plot1D, Plot2D] - - for t in tasks: - t.add_to_subparsers(subparsers) - - args = parser.parse_args() - args_to_pop = ["command"] - - task_arguments = vars(args).copy() - - for arg in args_to_pop: - task_arguments.pop(arg) - - task_to_run = None - - for task in tasks: - if args.command == task.parser_command: - task_to_run = task - - if task is None: - raise ValueError("Task not defined.") - - task_to_run(**task_arguments).run() - - -if __name__ == "__main__": - cli() diff --git a/codeQA/o2qaplots/o2qaplots/config.py b/codeQA/o2qaplots/o2qaplots/config.py deleted file mode 100644 index 481124a1..00000000 --- a/codeQA/o2qaplots/o2qaplots/config.py +++ /dev/null @@ -1,78 +0,0 @@ -import json -import typing -from collections import defaultdict - - -class AxisConfig: - """Configures an histogram axis representation. - - Attributes: - view_range: the axes range that will be visible in the plot - log: whether the axis should be shown in a log scale. - - Args: - view_range: the axes range that will be visible in the plot - log: whether the axis should be shown in a log scale. - """ - - def __init__(self, view_range: typing.List[float] = None, log: bool = False): - self.view_range = view_range - self.log = log - - def __repr__(self): - return ( - f"<{self.__class__.__name__} view_range={self.view_range} log={self.log}>" - ) - - -class PlotConfig: - """Configures an individual plot. - - Attributes: - x_axis: AxisConfig with the configuration for the x axis - y_axis: AxisConfig with the configuration for the y axis - - Args: - x_axis: an AxisConfig with for the axis, or a dict to be passed to the - constructor of AxisConfig - y_axis: an AxisConfig with for the axis, or a dict to be passed to the - constructor of AxisConfig - - """ - - def __init__(self, x_axis=AxisConfig(), y_axis=AxisConfig()): - if not isinstance(x_axis, AxisConfig): - x_axis = AxisConfig(**x_axis) - - if not isinstance(y_axis, AxisConfig): - y_axis = AxisConfig(**y_axis) - - self.x_axis = x_axis - self.y_axis = y_axis - - def __repr__(self): - return ( - f"<{self.__class__.__name__} " - f"x_axis={repr(self.x_axis)} y_axis={repr(self.y_axis)}>" - ) - - -class JsonConfig(defaultdict): - """ "Class used to read and store the JSON configuration files. - It reads the configuration from the JSON file and it stores it in as a dictionary. - The values of the dictionaryare automatically converted into an PlotConfig. - - In case the configuration is not set for a particular object, - this configuration will return a PlotConfig with its default value. - """ - - def __init__(self, json_file_name=None): - if json_file_name is not None: - with open(json_file_name) as json_file: - values = json.load(json_file) - super().__init__( - lambda: PlotConfig(), - {k: PlotConfig(**v) for k, v in values.items()}, - ) - else: - super(JsonConfig, self).__init__() diff --git a/codeQA/o2qaplots/o2qaplots/config/qa_plot_default.json b/codeQA/o2qaplots/o2qaplots/config/qa_plot_default.json deleted file mode 100644 index 7318c48a..00000000 --- a/codeQA/o2qaplots/o2qaplots/config/qa_plot_default.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "numberOfTracks": { - "x_axis": { - "view_range": [ - 0, - 200 - ] - } - }, - "numberOfContributors": { - "x_axis": { - "view_range": [ - 0, - 200 - ] - } - }, - "pt": { - "x_axis": { - "view_range": [ - 0.1, - 10 - ], - "log": true - }, - "y_axis": { - } - }, - "ptResolution": { - "x_axis": { - "view_range": [ - -0.2, - 0.2 - ] - } - }, - "ptResolutionVsPt": { - "x_axis": { - } - }, - "ptDiffMCRec": { - "x_axis": { - "view_range": [ - -0.1, - 0.1 - ] - } - }, - "impactParameterRPhiVsPt": { - "x_axis": { - } - }, - "impactParameterErrorRPhiVsPt": { - "x_axis": { - "view_range": [0.001, 10] - }, - "y_axis": { - "view_range": [ - 80, - 110 - ] - } - }, - "impactParameterZVsPt": { - "x_axis": { - } - }, - "impactParameterErrorZVsPt": { - "x_axis": { - } - }, - "primaryTrackEfficiency": { - "x_axis": { - "log": true, - "view_range": [ - 0.01, - 1 - ] - }, - "y_axis": { - "log": false, - "view_range": [ - 0, - 1.5 - ] - } - } -} \ No newline at end of file diff --git a/codeQA/o2qaplots/o2qaplots/efficiency/__init__.py b/codeQA/o2qaplots/o2qaplots/efficiency/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/codeQA/o2qaplots/o2qaplots/efficiency/efficiency.py b/codeQA/o2qaplots/o2qaplots/efficiency/efficiency.py deleted file mode 100644 index 90c715c3..00000000 --- a/codeQA/o2qaplots/o2qaplots/efficiency/efficiency.py +++ /dev/null @@ -1,101 +0,0 @@ -import typing - -import ROOT -from o2qaplots.plot_base import ( - Configurable, - InputConfigurable, - PlottingTask, - ROOTObj, - TaskInput, - macro, -) - - -def calculate_efficiency( - reconstructed: ROOT.TH3D, - generated: ROOT.TH3D, - eta_cut: float = None, - pt_range: typing.List[float] = None, -): - """Calculated the efficiency as function of the feature in axis. - - Args: - reconstructed: histogram with the reconstructed information. - generated: histogram with the generated information. - eta_cut: applies the selection |n| < eta_cut to the efficiency - pt_range: selects only particles with pt_range[0] < pt < pt_range[1] - - Returns: - efficiency: a TGraph with the efficiencies - """ - - epsilon = 0.0001 - - if eta_cut is not None: - generated.GetYaxis().SetRangeUser(-1.0 * eta_cut + epsilon, eta_cut - epsilon) - reconstructed.GetYaxis().SetRangeUser( - -1.0 * eta_cut + epsilon, eta_cut - epsilon - ) - - if pt_range is not None: - if len(pt_range) != 2: - raise ValueError( - "You should pass exactly two values to the transverse momentum" - "range (pt_range)." - ) - - generated.GetXaxis().SetRangeUser(pt_range[0] + epsilon, pt_range[1] - epsilon) - reconstructed.GetXaxis().SetRangeUser( - pt_range[0] + epsilon, pt_range[1] - epsilon - ) - - generated_1d = generated.Project3D("x") - reconstructed_1d = reconstructed.Project3D("x") - - # efficiency = ROOT.TEfficiency(reconstructed_1d, generated_1d) - efficiency = reconstructed_1d.Clone("Efficiency") - efficiency.Divide(generated_1d) - - return efficiency - - -class Efficiency(PlottingTask): - parser_description = "Calculates the efficiency for the physical primary particles." - parser_command = "eff" - - eta = Configurable("--eta", "-e", default=1.4, type=float, help="Selection in eta.") - - pt_range = Configurable( - "--pt_range", - "-pt", - default=(0.0, 10.0), - nargs=2, - action="append", - type=float, - help="Cut in pt_range[0] < pt <= pt_range[1].", - ) - - particle = InputConfigurable( - "-p", - "--particle", - help="particle to be processed", - type=str, - choices=["electron", "pion", "kaon", "muon", "proton"], - default="pion", - ) - - generated = TaskInput("qa-tracking-efficiency/generatedKinematics") - reconstructed = TaskInput("qa-tracking-efficiency/reconstructedKinematics") - - efficiency = ROOTObj("qa-tracking-efficiency/primaryTrackEfficiency") - - def process(self): - efficiency = calculate_efficiency( - self.reconstructed, self.generated, self.eta, self.pt_range - ) - - return {self.efficiency: efficiency} - - -if __name__ == "__main__": - macro(Efficiency) diff --git a/codeQA/o2qaplots/o2qaplots/file_utils.py b/codeQA/o2qaplots/o2qaplots/file_utils.py deleted file mode 100644 index ddd216f3..00000000 --- a/codeQA/o2qaplots/o2qaplots/file_utils.py +++ /dev/null @@ -1,52 +0,0 @@ -import pathlib - - -def check_file_exists(file): - """Checks if file exists. - - Raises: - FileNotFoundError is file does not exist. - """ - file_path = pathlib.Path(file) - if not file_path.is_file(): - raise FileNotFoundError("It was not possible find the file: " + file) - - -def discover_root_objects(file, type_check): - """Discovers the histograms saved in a file with multiple TDirectories. - - Args: - file: the file to be inspected. - type_check: a function to be called in the object to determine if they should - be selected. - - Returns - histograms: a list with HistogramInfo for each histogram. - """ - histograms = list() - - _find_objects_in_path(None, histograms, file, type_check) - - return histograms - - -def _find_objects_in_path(path, results, file, type_check): - - if path is None: - key_list = file.GetListOfKeys() - else: - try: - key_list = file.Get(path).GetListOfKeys() - except AttributeError: - return - - for key in key_list: - key_path = f"{path}/{key.GetName()}" - - if path is None: - key_path = key.GetName() - - if type_check(key.GetClassName()): - results.append(key_path) - else: - _find_objects_in_path(key_path, results, file, type_check) diff --git a/codeQA/o2qaplots/o2qaplots/plot.py b/codeQA/o2qaplots/o2qaplots/plot.py deleted file mode 100644 index 6853bb84..00000000 --- a/codeQA/o2qaplots/o2qaplots/plot.py +++ /dev/null @@ -1,226 +0,0 @@ -import os -import os.path -import pathlib - -import ROOT -from o2qaplots.config import PlotConfig - -ROOT.TH1.AddDirectory(False) - - -def _validate_size(histograms, attribute): - """Checks if histograms and attributes have the same size.""" - if attribute is not None: - if len(histograms) != len(attribute): - raise ValueError( - "The size of the lists do not match the number of histograms." - ) - - -def plot_1d( - histograms_to_plot, - normalize=False, - plot_errors=True, - labels=None, - colors=None, - draw_option="", - plot_ratio=False, - plot_config=None, - legend=None, -): - """Plot a list of histograms to a ROOT.Canvas. - - Args: - histograms_to_plot: the histograms to be plotted. - draw_option: this will be passed to the Draw method of the histogram. - normalize: whether the histograms should be normalized or not. - labels: The labels to be used in the legend. - colors: The colors for each histogram. - plot_errors: if true, the uncertainties in x and y will be plotted. - Otherwise the plot will use a only a line. - plot_ratio: is True and len(histograms_to_plot) is 2, it will plot the ratio - between the two histograms. - plot_config: PlotConfig object with the plot configuration - - Returns: - A list with ROOT.Canvas or matplotlib.Axes with the histograms drawn. - """ - - if len(histograms_to_plot) == 0: - return [] - - if plot_config is None: - plot_config = PlotConfig() - - _validate_size(histograms_to_plot, labels) - _validate_size(histograms_to_plot, colors) - - if plot_ratio and len(histograms_to_plot) != 2: - raise ValueError("Ratio plots can only be used if two histograms are passed.") - - _set_root_global_style() - _normalize(histograms_to_plot, normalize) - _set_labels(histograms_to_plot, labels) - _set_colors(histograms_to_plot, colors) - - common_draw_opt = _get_draw_option( - histograms_to_plot, draw_option, colors, plot_errors - ) - canvas = ROOT.TCanvas() - _set_log(canvas, plot_config) - _set_axis_range(histograms_to_plot, plot_config) - _plot_graph(histograms_to_plot, common_draw_opt, draw_option, canvas, plot_ratio) - - if legend is None: - _build_legend(canvas, labels) - else: - legend.Draw() - - canvas.Update() - - return canvas - - -def _normalize(histograms_to_plot, normalize): - if normalize: - for h in histograms_to_plot: - if h.Integral() > 0: - h.GetYaxis().SetTitle("Relative Frequency") - h.Scale(1.0 / h.Integral()) - - -def _set_axis_range(histograms_to_plot, plot_config): - if plot_config.y_axis.view_range is not None: - for h1 in histograms_to_plot: - h1.GetYaxis().SetRangeUser(*plot_config.y_axis.view_range) - else: - if len(histograms_to_plot) > 1: - max_value, min_value = _get_histogram_ranges(histograms_to_plot) - for h1 in histograms_to_plot: - h1.GetYaxis().SetRangeUser(min_value, 1.1 * max_value) - if plot_config.x_axis.view_range is not None: - for h1 in histograms_to_plot: - h1.GetXaxis().SetRangeUser(*plot_config.x_axis.view_range) - - -def _set_labels(histograms_to_plot, labels): - if labels is not None: - for h1, label in zip(histograms_to_plot, labels): - h1.SetTitle(label) - - -def _set_colors(histograms_to_plot, colors): - if colors is not None: - for h1, color in zip(histograms_to_plot, colors): - h1.SetLineColor(color) - h1.SetMarkerColor(color) - - -def _get_draw_option(histograms_to_plot, draw_option, colors, plot_errors): - common_draw_opt = "" - if "TH1" not in str(type(histograms_to_plot[0])): - common_draw_opt += "PE " - if colors is None: - common_draw_opt += "PLC PMC" - if not plot_errors and "TH1" in str(type(histograms_to_plot[0])): - common_draw_opt += "HIST" - return common_draw_opt - - -def _plot_graph(histograms_to_plot, common_draw_opt, draw_option, canvas, plot_ratio): - canvas.cd() - - histograms_to_plot[0].Draw(draw_option + common_draw_opt) - - for h in histograms_to_plot[1:]: - h.Draw(draw_option + " SAME " + common_draw_opt) - - -def _set_log(canvas, plot_config): - if plot_config.x_axis.log: - canvas.SetLogx() - if plot_config.y_axis.log: - canvas.SetLogy() - - -def _build_legend(canvas, labels): - if labels is not None: - legend = canvas.BuildLegend() - legend.SetLineWidth(0) - legend.SetBorderSize(0) - legend.SetFillStyle(0) - - -def plot_2d(histogram, draw_option="colz1", labels=None, plot_config=None): - """Plot a list of histograms to a canvas.""" - canvas = ROOT.TCanvas() - canvas.cd() - histogram.Draw(draw_option) - - return canvas - - -def profile_histogram(histogram, axis, option="", update_title=True): - """Make a profile (taking mean of each bin) of histogram in de designated axis.""" - _set_root_global_style() - - if axis.lower() == "x": - profile1 = histogram.ProfileX("_pfx", 1, -1, option) - if update_title: - profile1.GetYaxis().SetTitle("< " + histogram.GetYaxis().GetTitle() + " >") - else: - profile1 = histogram.ProfileY("_pfy", 1, -1, option) - if update_title: - profile1.GetXaxis().SetTitle("< " + histogram.GetXaxis().GetTitle() + " >") - profile = profile1 - - return profile - - -def plot_profile(histograms, draw_option="", axis="x", option="", **kwargs): - """Plot a profile histogram, taking the average of each bin""" - profiles = [profile_histogram(h, axis, option) for h in histograms] - - return plot_1d(profiles, draw_option=draw_option, **kwargs) - - -def save_canvas(info, canvas_or_ax, base_output_dir, suffix=""): - """Save a ROOT.TCanvas or a matplotplib Axes into an base_histogram file.""" - - output_file = f"{base_output_dir}/{info.full_path}{suffix}.pdf" - - output_dir = os.path.dirname(output_file) - os.makedirs(output_dir, exist_ok=True) - - try: - canvas_or_ax.SaveAs(output_file) - except AttributeError: - canvas_or_ax.get_figure().savefig(output_file, bbox_inches="tight") - - _check_file_exists(output_file) - - -def _check_file_exists(file): - """Checks if file exists. - - Raises: - FileNotFoundError is file does not exist. - """ - file_path = pathlib.Path(file) - if not file_path.is_file(): - raise FileNotFoundError("It was not possible to save_canvas the file: " + file) - - -def _set_root_global_style(): - """Set the global style for the plots""" - - ROOT.gStyle.SetOptStat(0) - ROOT.gROOT.SetStyle("ATLAS") - ROOT.gStyle.SetMarkerStyle(ROOT.kFullSquare) - ROOT.gROOT.ForceStyle() - - -def _get_histogram_ranges(histograms_to_plot): - max_value = max([h.GetMaximum() for h in histograms_to_plot]) - min_value = min([h.GetMinimum() for h in histograms_to_plot] + [0]) - return max_value, min_value diff --git a/codeQA/o2qaplots/o2qaplots/plot1d.py b/codeQA/o2qaplots/o2qaplots/plot1d.py deleted file mode 100644 index 0ac6ae89..00000000 --- a/codeQA/o2qaplots/o2qaplots/plot1d.py +++ /dev/null @@ -1,34 +0,0 @@ -import o2qaplots.plot as plot -import ROOT -from o2qaplots.file_utils import discover_root_objects -from o2qaplots.plot_base import PlottingTask, ROOTObj, macro - - -class Plot(PlottingTask): - plot_type = "define_your_type" - save_output = False - - def process(self): - histograms = discover_root_objects( - ROOT.TFile(self.file), lambda x: self.plot_type in x - ) - print(histograms) - - return {ROOTObj(x): ROOTObj(x).get(self.file) for x in histograms} - - -class Plot1D(Plot): - parser_description = "Plots all the 1d histograms." - parser_command = "plot1d" - plot_type = "TH1" - - -class Plot2D(Plot): - parser_description = "Plots all the 2d histograms." - parser_command = "plot2d" - plotting_function = plot.plot_2d - plot_type = "TH2" - - -if __name__ == "__main__": - macro(Plot) diff --git a/codeQA/o2qaplots/o2qaplots/plot_base.py b/codeQA/o2qaplots/o2qaplots/plot_base.py deleted file mode 100644 index d28eb935..00000000 --- a/codeQA/o2qaplots/o2qaplots/plot_base.py +++ /dev/null @@ -1,385 +0,0 @@ -""" -To create your own plotting macro, do the following: - -- Derive your plotting class from PlottingTask. - -- Define configurables that this task will depend upon in the - PlottingTask.configurables class attribute. - They should be declared using the type Configurable. The task configurables - will follow the same logic of the argparse.ArgumentParser.add_argument method, - except that they require an additional "name" parameter at the start. - - When creating an instance of the class, the value read from the command line - argument will be available for this parameter at self.. - -- Define your input files that will be read from each ROOT file. Add a class - attribute with type TaskInputObj and it will automatically read it for each - file. So at run time, this will always point to the declared ROOT object - for the current file. - -- Create your own PlottingTask.process function. This will be applied to each - file and should return a dict with the output that to be saved/plotted. - -""" -import argparse -import inspect -import os -import typing - -import o2qaplots.config as cfg -import o2qaplots.plot as plot -import ROOT -from o2qaplots.file_utils import check_file_exists - -default_json = ( - f"{os.path.dirname(os.path.abspath(__file__))}/config/qa_plot_default.json" -) - - -class Configurable: - """An argument to be added to a parser from argparse. - This argument will become a data member of your plotting task and you will - be able to access it.""" - - def __init__(self, *args, **kwargs): - """Constructor that mimics argparse.ArgumentParser.add_argument. - Args: - *args: configurables to be passed to - argparse.ArgumentParser.add_argument - **kwargs: kwargs to be passed to - argparse.ArgumentParser.add_argument - """ - self.args = args - self.kwargs = kwargs - - def add_argument(self, parser): - """Adds the content of this argument to a argparse.ArgumentParser""" - parser.add_argument(*self.args, **self.kwargs) - - def __repr__(self): - return f"<{self.__class__.__name__}(args={self.args}, kwargs={self.kwargs})>" - - -class InputConfigurable(Configurable): - """Special case of configurable that can modify the path of the input - objects.""" - - pass - - -class ROOTObj: - """Stores the representation of a input ROOT object that can be read - from a file. - - Attributes: - path: a list with the path in the ROOT file. This is NOT the path to - the file, but rather the TDirectories. - name: the name of the object to be read from the file. - """ - - def __init__(self, path: str): - obj_path = path.split("/") - self.path = obj_path[:-1] - self.name = obj_path[-1] - - @property - def full_path(self): - return "/".join(self.path) + "/" + self.name - - def get(self, input_file): - file = ROOT.TFile(input_file) - return file.Get(self.full_path) - - def with_input(self, input_argument=None): - """In case your task has input configurables that can change the name of - your structure of the ROOT folders, this function will generate a new - object taking into account the input argument. The values will be - passed to the first directory of the object. - - Args: - input_argument: a string or list with the input configurables. - - Returns: - an instance of this class taking into account the input_arguments. - """ - if input_argument is None: - return self - - if not isinstance(input_argument, str): - input_argument = "-".join(input_argument) - - path = self.path[:] - - if path: - path[0] += "-" + input_argument - else: - path.append(input_argument) - - return self.__class__("/".join(path + [self.name])) - - def add_to_path(self, additional_path): - """Retuns a new object with the addition of additional_path at the - beggining of the path""" - - return self.__class__(f"{additional_path}/{self.full_path}") - - def __hash__(self): - return hash(self.full_path) - - def __eq__(self, other): - return self.full_path == other.full_path - - def __repr__(self): - return f"<{self.__class__.__name__}({self.full_path})>" - - -class TaskInput(ROOTObj): - """Stores the representation of an input object. - You should define your inputs using this class.""" - - pass - - -def find_class_instances(class_, class_to_find) -> typing.List[str]: - """Finds all the data members of class_ that are from class_to_find. - - Args: - class_: the class which will be inspected. - class_to_find: the class that the data members should match. - - Returns: - A list with the data members with type class_to_find. - """ - return [ - name - for name, _ in inspect.getmembers( - class_, lambda x: isinstance(x, class_to_find) - ) - ] - - -class PlottingTask: - """Base class to perform the plotting. It does contains basic functions to - read the files and utilities. - You should derive your class from it and override the methods. - - Attributes: - parser_description: string with the description which will be - shown when this plotting macro is run from the command line. - arguments: list with the configurables for the process. - """ - - parser_description: str = "Put here the parser description" - parser_command = "here_goes_the_parser_command" - - files = Configurable("files", type=str, nargs="+", help="Analysis files.") - - labels = Configurable("--labels", "-l", type=str, nargs="+", help="Legend labels") - - output = Configurable("--output", "-o", help="Output folder", default="qa_output") - - config = Configurable( - "--config", "-c", help="JSON configuration", default=default_json - ) - - suffix = Configurable( - "--suffix", "-s", type=str, help="Suffix to the output", default="" - ) - - save_output = True - - plotting_function = plot.plot_1d - plotting_kwargs = dict() - - output_file = "LocalTaskResults.root" - - def __init__(self, **kwargs): - """Constructor for the process. Do not modify it when inheriting, - it will be automatically generated based on the configurables specified - in the class definition.""" - cls = self.__class__ - - # Initialize all configurables and input arguments - for arg in cls.configurables(): - try: # Read from class constructor - setattr(self, arg, kwargs[arg]) - except KeyError: - try: # Set from default value defined in class - default_value = getattr(self, arg).kwargs["default"] - setattr(self, arg, default_value) - except KeyError: # if nothing is provided, fallbakcs to None - setattr(self, arg, None) - - self.input_arguments = None - if cls.input_configurables(): - self.input_arguments = [ - getattr(self, arg) for arg in cls.input_configurables() - ] - - self.json_config = cfg.JsonConfig(self.config) - self.output_objects = [] - self.file = None - - @classmethod - def input(cls): - """Returns a list with the name of the inputs.""" - return find_class_instances(cls, TaskInput) - - @classmethod - def input_configurables(cls): - """Returns a list of the class members that are input arguments.""" - return find_class_instances(cls, InputConfigurable) - - @classmethod - def configurables(cls): - """Returns a list of the class members that are configurables.""" - return find_class_instances(cls, Configurable) - - def get_input_from_file(self, file): - """Gets the input from a file. - - Args: - file: the file that will be used to read the input objects. - - Returns: - input_objs: dictionary with ROOTObj: for the inputs of this task. - - """ - cls = self.__class__ - - input_objs = { - attr: getattr(cls, attr).with_input(self.input_arguments).get(file) - for attr in cls.input() - } - - return input_objs - - def _check_consistency(self): - """Check if the input of the user is valid. The following checks are performed: - - - Files declared exists. - - If labels were passed, if they have the same length as the number of files. - - Raises: - ValueError: if the number of labels is different from the number of files. - FileNotFoundError: if any of the files in self.files do not exist. - - """ - for f in self.files: # pylint: disable=not-an-iterable - check_file_exists(f) - - if self.labels is not None: - if len(self.labels) != len(self.files): - raise ValueError( - f"The length of labels ({len(self.labels)}) is " - f"different from the length of files ({len(self.files)}" - ) - - def _set_input_for_current_file(self): - """Reads the input objects from file and returns them.""" - for attr, obj in self.get_input_from_file(self.file).items(): - setattr(self, attr, obj) - - def _get_output_objects_info(self): - """Return a list-like with the histograms that have to be saved.""" - if len(self.output_objects) == 0: - return [] - - return self.output_objects[0].keys() - - def _get_results_from_all_files(self, output_ojt): - """Returns a list will a particular output object""" - return [output[output_ojt] for output in self.output_objects] - - def process(self): - """Process the objects of input_objects. This should be the input for a - single file. - It should return the output as a dict in the form {HistogramInfo: histogram}. - """ - pass - - def run(self): - """Process the task.""" - self._check_consistency() - - self.process_files() - - self.save_figures() - - if self.save_output: - self.save_root_output() - - def process_files(self): - for f in self.files: # pylint: disable=not-an-iterable - self.file = f - self._set_input_for_current_file() - self.output_objects.append(self.process()) - - def save_figures(self): - """Save the output figures to PDF files.""" - cls = self.__class__ - plotted_canvas = [] - - for result in self._get_output_objects_info(): - result_objects_list = self._get_results_from_all_files(result) - - canvas = cls.plotting_function( - result_objects_list, - labels=self.labels, - plot_config=self.json_config.get(result.name), - **self.plotting_kwargs, - ) - - plotted_canvas.append(canvas) - - plot.save_canvas( - result.with_input(self.input_arguments), - canvas, - self.output, - self.suffix, - ) - return plotted_canvas - - def save_root_output(self): - root_output_file = ROOT.TFile(f"{self.output}/{self.output_file}", "RECREATE") - root_output_file.cd() - - labels = self.labels - - if labels is None: - if len(set(self.files)) == len(self.files): - labels = self.files - else: - labels = [str(i) for i in range(len(self.files))] - - for output, label in zip(self.output_objects, labels): - for root_info, opt_obj in output.items(): - opt_obj.Write(root_info.add_to_path(label).full_path) - - root_output_file.Close() - - @classmethod - def add_parser_options(cls, parser): - """Add the configurables from this task to parser.""" - for arg in cls.configurables(): - getattr(cls, arg).add_argument(parser) - - @classmethod - def add_to_subparsers(cls, subparsers): - sub = subparsers.add_parser( - cls.parser_command, description=cls.parser_description - ) - cls.add_parser_options(sub) - - -def macro(task_class): - """Instance to run as the main entrypoint of a program or/and scripting. - Call this function with to make a script macro. - - Args: - task_class: the class, derived from PlottingTask, which will be used to - run this script. - """ - parser_main = argparse.ArgumentParser(description=task_class.parser_description) - task_class.add_parser_options(parser_main) - task_class(**vars(parser_main.parse_args())).run() diff --git a/codeQA/o2qaplots/o2qaplots/tracking_resolution/__init__.py b/codeQA/o2qaplots/o2qaplots/tracking_resolution/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/codeQA/o2qaplots/o2qaplots/tracking_resolution/ip/__init__.py b/codeQA/o2qaplots/o2qaplots/tracking_resolution/ip/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/codeQA/o2qaplots/o2qaplots/tracking_resolution/ip/ip.py b/codeQA/o2qaplots/o2qaplots/tracking_resolution/ip/ip.py deleted file mode 100644 index c0294972..00000000 --- a/codeQA/o2qaplots/o2qaplots/tracking_resolution/ip/ip.py +++ /dev/null @@ -1,104 +0,0 @@ -import o2qaplots.plot as pl -import ROOT -from o2qaplots.plot_base import Configurable, PlottingTask, ROOTObj, TaskInput, macro - - -def plot_1d_legend(x, *args, **kwargs): - return pl.plot_1d([x[0][0]], *args, legend=x[0][1], **kwargs) - - -class ImpactParameter(PlottingTask): - parser_description = ( - "Plots the Impact Parameter resolution in the rphi and z direction. " - "Currently it can only handle ONE file at at time. This will change soon." - ) - parser_command = "ip" - - ip_rphi_pt = TaskInput( - "qa-tracking-resolution/impactParameter/impactParameterRPhiVsPt" - ) - ip_rphi_eta = TaskInput( - "qa-tracking-resolution/impactParameter/impactParameterRPhiVsEta" - ) - ip_rphi_phi = TaskInput( - "qa-tracking-resolution/impactParameter/impactParameterRPhiVsPhi" - ) - ip_z_pt = TaskInput("qa-tracking-resolution/impactParameter/impactParameterZVsPt") - ip_z_eta = TaskInput("qa-tracking-resolution/impactParameter/impactParameterZVsEta") - ip_z_phi = TaskInput("qa-tracking-resolution/impactParameter/impactParameterZVsPhi") - - ip_histograms = [ - ip_rphi_pt, - ip_rphi_eta, - ip_rphi_phi, - ip_rphi_eta, - ip_z_eta, - ip_z_phi, - ] - - show_fits = Configurable( - "--show-fits", "-sf", action="store_true", default=False, help="" - ) - - plotting_function = plot_1d_legend - - def process(self): - fit_slices, legends = calculate_ip_resolution(self.ip_rphi_pt) - return { - ROOTObj(f"qa-tracking-resolution/fit_slice_{i}"): (fit_slice, legend) - for fit_slice, legend, i in zip(fit_slices, legends, range(len(fit_slices))) - } - - -def calculate_ip_resolution(ip_vs_var): - """Calculates the impact parameter (ip) resolution vs a particular variable. - - Args: - ip_vs_var: a ROOT TH2 histogram with the ip in the y axis and the - dependent variable in the x axis. - """ - - ROOT.TH1.AddDirectory(False) - projections = [ - ip_vs_var.ProjectionY(ip_vs_var.GetName() + f"_{i}", i, i) - for i in range(1, ip_vs_var.GetNbinsX() + 1) - ] - - function = ROOT.TF1("gaus", "gaus", -1000, 1000) - legends = [] - - for hist_slice, i in zip(projections, range(1, len(projections) + 1)): - hist_slice.GetYaxis().SetTitle( - f"Counts ({ip_vs_var.GetXaxis().GetBinLowEdge(i)}, " - f"{ip_vs_var.GetXaxis().GetBinUpEdge(i)})" - ) - - hist_slice.GetXaxis().SetRangeUser(-400, 400) - fit_results = hist_slice.Fit(function, "QRS") - - chi2 = 0 - - if int(fit_results) == 0: - - if fit_results.Ndf() > 0: - chi2 = fit_results.Chi2() / fit_results.Ndf() - - mean, mean_error = fit_results.Parameter(1), fit_results.ParError(1) - sigma, sigma_error = fit_results.Parameter(2), fit_results.ParError(2) - else: - chi2 = -999 - sigma, sigma_error = hist_slice.GetStdDev(), hist_slice.GetStdDevError() - mean, mean_error = hist_slice.GetMean(), hist_slice.GetMeanError() - - legend = ROOT.TLegend() - legend.SetHeader(f"Gaussian fit results (#chi^{{2}}/NDF = {chi2:.2f})") - legend.AddEntry(ROOT.nullptr, f"Mean = {mean:.2f} #pm {mean_error:.2f}") - legend.AddEntry(ROOT.nullptr, f"Sigma = {sigma:.2f} #pm {sigma_error:.2f}") - - legends.append(legend) - - return projections, legends - - -if __name__ == "__main__": - macro(ImpactParameter) diff --git a/codeQA/o2qaplots/requirements.txt b/codeQA/o2qaplots/requirements.txt deleted file mode 100644 index 32c54949..00000000 --- a/codeQA/o2qaplots/requirements.txt +++ /dev/null @@ -1,13 +0,0 @@ -matplotlib==3.3.2 -pandas==1.1.4 -pytest==6.1.2 -seaborn==0.11.0 -setuptools>=50.3.2 -uproot==3.13.0 -tqdm==4.66.3 -autopep8==1.5.4 -black==24.3.0 -flake8==3.8.4 -isort==5.7.0 -pylint==2.6.0 -rope==0.18.0 \ No newline at end of file diff --git a/codeQA/o2qaplots/setup.py b/codeQA/o2qaplots/setup.py deleted file mode 100644 index 8c699c06..00000000 --- a/codeQA/o2qaplots/setup.py +++ /dev/null @@ -1,14 +0,0 @@ -from setuptools import find_packages, setup - -setup( - name="o2qaplots", - version="1.0.0", - packages=find_packages(), - url="https://github.com/hzanoli/O2QA", - license="MIT License", - author="Henrique J. C. Zanoli", - author_email="hzanoli@gmail.com", - description="Plotting tools for the ALICE O2 quality assurance", - entry_points={"console_scripts": ["o2qa=o2qaplots.cli:cli"]}, - install_requirepes=["tqdm"], -) diff --git a/codeQA/o2qaplots/tests/__init__.py b/codeQA/o2qaplots/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/codeQA/o2qaplots/tests/test_efficiency.py b/codeQA/o2qaplots/tests/test_efficiency.py deleted file mode 100644 index e45ef3c7..00000000 --- a/codeQA/o2qaplots/tests/test_efficiency.py +++ /dev/null @@ -1,42 +0,0 @@ -import o2qaplots.efficiency.efficiency as eff -import ROOT - -ROOT.TH1.AddDirectory(False) - - -def set_all_bin_contents(hist: ROOT.TH3D, value: float): - for x in range(0, hist.GetNbinsX() + 2): - for y in range(0, hist.GetNbinsY() + 2): - for z in range(0, hist.GetNbinsZ() + 2): - hist.SetBinContent(x, y, z, value) - - -def print_all_bin_content(hist): - for x in range(1, hist.GetNbinsX()): - for y in range(1, hist.GetNbinsY()): - for z in range(1, hist.GetNbinsZ()): - print(hist.GetBinContent(x, y, z)) - - -def make_3d_with_fixed_value(hist=None, n_fill=1.0): - if hist is None: - hist = ROOT.TH3D( - "base_hist", "", 10, 0, 10, 6, -3, 3, 10, 0, 2 * ROOT.TMath.Pi() - ) - - set_all_bin_contents(hist, n_fill) - - return hist - - -def test_calculate_efficiency( - generated=make_3d_with_fixed_value(n_fill=600 * 1000.0), - reconstructed=make_3d_with_fixed_value(n_fill=0.7 * 600 * 1000.0), -): - """Creates a generated and reconstructed histogram with 0.7 efficiency - and calculates it.""" - - efficiency = eff.calculate_efficiency(reconstructed, generated) - - for i in range(1, efficiency.GetXaxis().GetNbins() + 1): - assert efficiency.GetBinContent(i) == 0.7 diff --git a/codeQA/o2qaplots/tests/test_plot1d.py b/codeQA/o2qaplots/tests/test_plot1d.py deleted file mode 100644 index 75e8be2e..00000000 --- a/codeQA/o2qaplots/tests/test_plot1d.py +++ /dev/null @@ -1,28 +0,0 @@ -import os - -import o2qaplots.plot1d as plot1d -import ROOT - - -def test_discover_root_objects(): - file_test = ROOT.TFile("test_file.root", "RECREATE") - - ROOT.TH1D().Write("um") - ROOT.TH1D().Write("dois/tres") - ROOT.TH1D().Write("quatro/cinco/seis") - ROOT.TH1D().Write("quatro/cinco/sete/oito") - - file_test.Close() - - plots = plot1d.discover_root_objects( - ROOT.TFile("test_file.root"), lambda x: "TH1D" in x - ) - - assert set(plots) == { - "um", - "dois/tres", - "quatro/cinco/seis", - "quatro/cinco/sete/oito", - } - - os.remove("test_file.root") diff --git a/codeQA/o2qaplots/tests/test_plot_base.py b/codeQA/o2qaplots/tests/test_plot_base.py deleted file mode 100644 index e9f96036..00000000 --- a/codeQA/o2qaplots/tests/test_plot_base.py +++ /dev/null @@ -1,78 +0,0 @@ -import o2qaplots.plot_base as plot_base - - -def test_argument_reading(): - class PtSpectra(plot_base.PlottingTask): - pt_range = plot_base.Configurable( - "--pt_range", - "-pt", - default=[0.0, 10.0], - nargs=2, - action="append", - type=float, - help="Cut in pt_range[0] < pt <= pt_range[1].", - ) - - particle = plot_base.InputConfigurable( - "-p", - "--particle", - help="particle to be processed", - type=str, - choices=["electron", "pion", "kaon", "muon", "proton"], - default="pion", - ) - - pt_task_defaults = PtSpectra(files=["pt.root"]) - print(pt_task_defaults.pt_range) - assert pt_task_defaults.pt_range == [0.0, 10.0] - assert pt_task_defaults.particle == "pion" - - pt_task_arguments = PtSpectra(files=["pt.root"], pt_range=[5, 20], particle="d0") - - assert pt_task_arguments.pt_range == [5.0, 20.0] - assert pt_task_arguments.particle == "d0" - - -def test_root_obj_include_task_argument(): - """Tests if plot_base.ROOTObj.with_input does the correct routing when - including the input arguments.""" - - no_folder = plot_base.ROOTObj("some-object") - assert no_folder.with_input() is no_folder - - no_folder_str_arg = no_folder.with_input("pions") - assert no_folder_str_arg == plot_base.ROOTObj("pions/some-object") - - no_folder_list_arg = no_folder.with_input(["pions", "low_pt"]) - assert no_folder_list_arg == plot_base.ROOTObj("pions-low_pt/some-object") - - one_folder = plot_base.ROOTObj("folder/object") - - one_folder_str_arg = one_folder.with_input("pions") - assert one_folder_str_arg == plot_base.ROOTObj("folder-pions/object") - - one_folder_list_arg = one_folder.with_input(["pions", "low_pt"]) - assert one_folder_list_arg == plot_base.ROOTObj("folder-pions-low_pt/object") - - -def test_find_class_instances(): - """Construct simple cases to test find_class_instances.""" - - class Input: - pass - - class Output: - pass - - class Task: - pt = Input() - eta = Input() - - pt_histogram = Output() - eta_histogram = Output() - - assert set(plot_base.find_class_instances(Task, Input)) == set(["pt", "eta"]) - assert set(plot_base.find_class_instances(Task, Output)) == set( - ["pt_histogram", "eta_histogram"] - ) - # Add more tests? diff --git a/codeQA/o2qaplots/tests/test_plot_config.py b/codeQA/o2qaplots/tests/test_plot_config.py deleted file mode 100644 index 8aba05b2..00000000 --- a/codeQA/o2qaplots/tests/test_plot_config.py +++ /dev/null @@ -1,53 +0,0 @@ -import json - -import pytest -from o2qaplots.config import AxisConfig, PlotConfig - - -@pytest.fixture -def json_file(): - return """{ - "numberOfTracks": { - "x_axis": { - "view_range": [0, 200], - "log": false - }, - "y_axis": { - "view_range": [0.0, 1.0], - "log": true - } - }, - "pt": { - "y_axis": { - "log": true - } - }, - "ptResolutionVsPt": { - "x_axis": { - "log": true - } - } - } - """ - - -@pytest.fixture -def dict_example(json_file): - return json.loads(json_file) - - -def test_axis_config(dict_example): - x_axis = AxisConfig(**dict_example["numberOfTracks"]["x_axis"]) - - assert x_axis.log is False - assert x_axis.view_range == [0, 200] - - -def test_plot_config(dict_example): - n_tracks = PlotConfig(**dict_example["numberOfTracks"]) - - assert n_tracks.x_axis.log is False - assert n_tracks.x_axis.view_range == [0, 200] - - assert n_tracks.y_axis.log is True - assert n_tracks.y_axis.view_range == [0.0, 1.0] diff --git a/codeQA/plot_rphi_reso.py b/codeQA/plot_rphi_reso.py deleted file mode 100755 index e5190199..00000000 --- a/codeQA/plot_rphi_reso.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python3 - -import argparse - -from ROOT import TH1, TCanvas, TColor, TFile, TGraph, TLegend, TObjArray - -canvases = [] - - -def make_reso(file_name, out_tag, show, thr=0.08): - f = TFile(file_name, "READ") - h = f.Get("qa-tracking-resolution/impactParameter/impactParameterRPhiVsPt") - h.SetDirectory(0) - f.Close() - h.SetBit(TH1.kNoStats) - if show: - c = "2d" + out_tag - c = TCanvas(c, c) - canvases.append(c) - c.SetLogz() - h.Draw("COLZ") - o = TObjArray() - h.GetYaxis().SetRangeUser(-200, 200) - h.FitSlicesY(0, 0, -1, 0, "QNR", o) - h.GetYaxis().SetRange() - hmean = o.At(1) - hsigma = o.At(2) - if show: - hmean = hmean.DrawCopy("SAME") - hsigma = hsigma.DrawCopy("SAME") - hsigma.SetLineColor(2) - c.Update() - g = TGraph() - g.SetName(out_tag) - g.SetTitle(out_tag) - g.GetXaxis().SetTitle(h.GetXaxis().GetTitle()) - g.GetYaxis().SetTitle(h.GetYaxis().GetTitle()) - - for i in range(1, h.GetNbinsX() + 1): - x = h.GetXaxis().GetBinCenter(i) - if x < thr: - continue - hh = h.ProjectionY(f"{h.GetName()}_{i}", i, i) - y = hh.GetRMS() - y = hsigma.GetBinContent(hsigma.GetXaxis().FindBin(x)) - g.SetPoint(g.GetN(), x, y) - if show: - can2 = "1d" + out_tag - can2 = TCanvas(can2, can2) - canvases.append(can2) - can2.SetLogy() - can2.SetLogx() - g.SetMarkerStyle(8) - g.Draw() - can2.Update() - print(g.Eval(0.1)) - # input("press enter to continue") - g.SaveAs(f"{out_tag}.root") - return g - - -def main(input_files, tags, show=True): - g = [] - for i, j in enumerate(input_files): - t = tags[i] - # print(i, j, t) - g.append(make_reso(j, t, show)) - can = TCanvas("all", "all") - can.DrawFrame( - 0, - 0, - 1, - 200, - f";{g[0].GetXaxis().GetTitle()};Resolution {g[0].GetYaxis().GetTitle()};", - ) - cols = ["#e41a1c", "#377eb8", "#4daf4a", "#984ea3"] - leg = TLegend(0.9, 0.1, 1, 0.9) - for j, i in enumerate(g): - print("Drawing", i) - c = TColor.GetColor(cols[j]) - i.SetLineColor(c) - i.SetLineWidth(2) - leg.AddEntry(i, "", "l") - i.Draw("sameL") - leg.Draw() - can.Update() - input("press enter to continue") - - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Runner for O2 analyses") - parser.add_argument("files", type=str, nargs="+", help="Running files") - parser.add_argument( - "--tags", "-t", type=str, default=[], nargs="+", help="Tag for output files" - ) - parser.add_argument("-s", action="store_true", help="Verbose mode") - args = parser.parse_args() - main(args.files, args.tags, args.s) diff --git a/simulations/README.md b/simulations/README.md deleted file mode 100644 index 1181bfee..00000000 --- a/simulations/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Example of Run3 simulation workflow + HF O2 (WIP) -(thanks to Nazar Burmasov ) - -## Example -1) Load the O2 environment as usual -2) bash sim_challenge.sh -3) bash testAOD.sh - diff --git a/simulations/clean.sh b/simulations/clean.sh deleted file mode 100644 index edca04b9..00000000 --- a/simulations/clean.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -rm ./*.root ./*.log ./*.ini ./*log* ./*.dat ./*done ./*time ./*json ./*list diff --git a/simulations/sim_challenge.sh b/simulations/sim_challenge.sh deleted file mode 100644 index 74890cfe..00000000 --- a/simulations/sim_challenge.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# shellcheck disable=SC1091 # Ignore not following. - -. "${O2_ROOT}"/share/scripts/jobutils.sh - -# chain of algorithms from MC and reco - -# options to pass to every workflow -gloOpt=" -b --run --shm-segment-size 10000000000" - -taskwrapper sim.log o2-sim -n 10 --configKeyValue "Diamond.width[2]=6." -g pythia8 -e TGeant3 -j 6 -m PIPE ITS FT0 TPC TOF MFT - -taskwrapper digi.log o2-sim-digitizer-workflow "$gloOpt" --interactionRate 400000 --tpc-lanes 1 - -taskwrapper tpcreco.log o2-tpc-reco-workflow "$gloOpt" --tpc-digit-reader \"--infile tpcdigits.root\" --input-type digits --output-type clusters,tracks --tpc-track-writer \"--treename events --track-branch-name Tracks --trackmc-branch-name TracksMCTruth\" - -taskwrapper itsreco.log o2-its-reco-workflow --trackerCA --async-phase "$gloOpt" - -taskwrapper mftreco.log o2-mft-reco-workflow "$gloOpt" -echo "Return status of mftreco: $?" - -echo "Running FT0 reco flow" -#needs FT0 digitized data -taskwrapper ft0reco.log o2-ft0-reco-workflow "$gloOpt" -echo "Return status of ft0reco: $?" - -echo "Running ITS-TPC macthing flow" -#needs results of o2-tpc-reco-workflow, o2-its-reco-workflow and o2-fit-reco-workflow -taskwrapper itstpcMatch.log o2-tpcits-match-workflow "$gloOpt" --tpc-track-reader \"tpctracks.root\" --tpc-native-cluster-reader \"--infile tpc-native-clusters.root\" -echo "Return status of itstpcMatch: $?" - -echo "Running ITSTPC-TOF macthing flow" -#needs results of TOF digitized data and results of o2-tpcits-match-workflow -taskwrapper tofMatch.log o2-tof-reco-workflow "$gloOpt" -echo "Return status of its-tpc-tof match: $?" - -echo "Running primary vertex finding flow" -#needs results of TPC-ITS matching and FIT workflows -taskwrapper pvfinder.log o2-primary-vertexing-workflow "$gloOpt" -echo "Return status of primary vertexing: $?" - -echo "Producing AOD" -taskwrapper aod.log o2-aod-producer-workflow --aod-writer-keep dangling -echo "Return status of AOD production: $?" diff --git a/simulations/testAOD.sh b/simulations/testAOD.sh deleted file mode 100644 index 1565fdda..00000000 --- a/simulations/testAOD.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -o2-analysis-hf-track-index-skim-creator --aod-file ../simulations/AnalysisResults_trees.root -b