-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update repo: committing code updates for Lc->pKpi analysis #255
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
c067000
Update GetRawYieldsDplusDs: split in LctopKpi and LctopK0s
strogolo 4cca6e0
Add projection for each resonant channel (LctopKpi)
strogolo 48cd6c9
Add projection (TTree) for each resonant channel (LctopKpi)
strogolo 1538368
Add macro/script to compute LctopKpi efficiency BR-weighted
strogolo 8343546
Update RunFullAnalysis.sh for LctopKpi analysis
strogolo d2b7a7c
Re-write ComputeEffAccWeightedAvg.py with loops
strogolo 36e3312
Fix kLctopKpi and kLctopK0s
strogolo 1878f88
Introduce loop to check LcResonance BIT
strogolo 7025378
Implement for loop on Lc ResoChannel
strogolo d21be60
Remove debug print output
strogolo aa451fd
Update: re-arrange weighted average loop
strogolo 6df53c6
Add TMath in ComputeEffAccWeightedAvg
strogolo a1ac0d3
Remove the file with all efficiencies
strogolo 6906329
Change loop length
strogolo 796c35e
Change TFile size
strogolo 8d939e8
Change array size
strogolo cc8b5c2
Change loop length
strogolo 8ef6855
Update uncertainty calculation for weighted average
strogolo 3b45f2a
Remove loading of global efficiency
strogolo c770718
Remove opening of global efficiency
strogolo 2ad5e07
Indentation of SetObjectStyle
strogolo e85d97d
Indentation of SetObjectStyle
strogolo ade6921
Remove total BR Lc->pKpi
strogolo c2fb726
Remove case of unweighted average
strogolo d871a5b
Remove effC and wC
strogolo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
//___________________________________________________________________________________// | ||
// Macro for computing the weighted average of Lc resonant channels // | ||
// Main Function: ComputeEffAccWeightedAvg // | ||
//___________________________________________________________________________________// | ||
|
||
#if !defined (__CINT__) || defined (__CLING__) | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "yaml-cpp/yaml.h" | ||
|
||
#include "TROOT.h" | ||
#include "Riostream.h" | ||
#include "TH1.h" | ||
#include "TF1.h" | ||
#include "TCanvas.h" | ||
#include "TStyle.h" | ||
#include "TFile.h" | ||
#include "TGaxis.h" | ||
#include "TDatabasePDG.h" | ||
#include "TMath.h" | ||
#include "AliHFInvMassFitter.h" | ||
#include "AliVertexingHFUtils.h" | ||
|
||
#endif | ||
|
||
using namespace std; | ||
|
||
int ComputeEffAccWeightedAvg(TString effdir, TString particle, TString cutset, TString outFileName){ | ||
|
||
if(particle=="LctopKpi"){ | ||
TString f[5] = { | ||
Form("%s/Eff_times_Acc_%s_NonRes%s.root", effdir.Data(), particle.Data(), cutset.Data()), //NonResonant | ||
Form("%s/Eff_times_Acc_%s_KStar%s.root", effdir.Data(), particle.Data(), cutset.Data()), //KStar | ||
Form("%s/Eff_times_Acc_%s_Delta%s.root", effdir.Data(), particle.Data(), cutset.Data()), //Delta | ||
Form("%s/Eff_times_Acc_%s_Lambda1520%s.root", effdir.Data(), particle.Data(), cutset.Data()), //Lambda1520 | ||
}; | ||
|
||
TFile *file[4]; | ||
for (int i = 0; i < 4; i++){ | ||
file[i] = TFile::Open(f[i].Data()); | ||
} | ||
|
||
Double_t BR[4] = { | ||
//6.28 * 1e-02, //all | ||
3.5 * 1e-02, //non res | ||
1.96 * 0.667 * 1e-02, //Kstar | ||
1.08 * 1e-02, //Delta | ||
2.2 * 0.225 * 1e-02 //L1520 | ||
}; | ||
|
||
TH1D *effC[4]; | ||
TH1D *effB[4]; | ||
for(int i = 0; i < 4; i++){ | ||
effC[i] = (TH1D *)file[i]->Get("hAccEffPrompt"); | ||
effB[i] = (TH1D *)file[i]->Get("hAccEffFD"); | ||
cout << " n bins " << effC[i]->GetNbinsX() << endl; | ||
} | ||
TH1D *effCw = (TH1D *)effC[0]->Clone("hAccEffPrompt"); | ||
TH1D *effBw = (TH1D *)effB[0]->Clone("hAccEffFD"); | ||
effCw->Reset("icse"); | ||
effBw->Reset("icse"); | ||
|
||
|
||
for(int iPt=0; iPt<effC[0]->GetNbinsX(); iPt++) { | ||
double weightEffC = 0., weightUncEffC = 0., weightEffB = 0., weightUncEffB = 0., sumOfBR = 0.; | ||
for(int iCh=0; iCh<4; iCh++) { | ||
weightEffC += effC[iCh]->GetBinContent(iPt + 1) * BR[iCh]; | ||
weightUncEffC += effC[iCh]->GetBinError(iPt + 1) * effC[iCh]->GetBinError(iPt + 1) * BR[iCh] * BR[iCh]; | ||
weightEffB += effB[iCh]->GetBinContent(iPt + 1) * BR[iCh]; | ||
weightUncEffB += effB[iCh]->GetBinError(iPt + 1) * effB[iCh]->GetBinError(iPt + 1) * BR[iCh] * BR[iCh]; | ||
sumOfBR += BR[iCh]; | ||
} | ||
weightEffC /= sumOfBR; | ||
weightUncEffC = TMath::Sqrt(weightUncEffC) / sumOfBR; | ||
weightEffB /= sumOfBR; | ||
weightUncEffB = TMath::Sqrt(weightUncEffB) / sumOfBR; | ||
effC[iCh]->SetBinContent(iPt + 1, weightEffC); | ||
effC[iCh]->SetBinError(iPt + 1, weightUncEffC); | ||
effB[iCh]->SetBinContent(iPt + 1, weightEffB); | ||
effB[iCh]->SetBinError(iPt + 1, weightUncEffB); | ||
} | ||
|
||
TFile outFile(Form("%s/%s", effdir.Data(),outFileName.Data()),"recreate"); | ||
effCw->Write("hAccEffPrompt"); | ||
effBw->Write("hAccEffFD"); | ||
} | ||
|
||
return 0; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
''' | ||
Script for the combination of efficiency and acceptance factors | ||
run: python ComputeEffAccWeightedAvg.py effFileAll.root effFileNonRes.root effFileKStar.root effFileDelta.root effFileLambda1520.root outFileName.root | ||
''' | ||
|
||
import sys | ||
import argparse | ||
import ctypes | ||
import numpy as np | ||
from ROOT import gROOT, TFile, TCanvas, TLegend # pylint: disable=import-error,no-name-in-module | ||
from ROOT import kBlack, kRed, kAzure # pylint: disable=import-error,no-name-in-module | ||
from ROOT import kFullDiamond, kOpenDiamond, kFullTriangleUp, kOpenTriangleUp, kFullStar, kOpenStar, kFullCircle, kOpenCircle, kFullSquare, kOpenSquare, kFullCross, kOpenCross # pylint: disable=import-error,no-name-in-module | ||
from utils.StyleFormatter import SetGlobalStyle, SetObjectStyle | ||
|
||
parser = argparse.ArgumentParser(description='Arguments') | ||
parser.add_argument('effFileNonRes', metavar='text', default='') | ||
parser.add_argument('effFileKStar', metavar='text', default='') | ||
parser.add_argument('effFileDelta', metavar='text', default='') | ||
parser.add_argument('effFileLambda1520', metavar='text', default='') | ||
parser.add_argument('outFileName', metavar='text', default='') | ||
parser.add_argument("--batch", help="suppress video output", action="store_true") | ||
args = parser.parse_args() | ||
|
||
gROOT.SetBatch(args.batch) | ||
SetGlobalStyle(padleftmargin=0.14, padbottommargin=0.12, titlesize=0.045, labelsize=0.04) | ||
|
||
inputFile = [args.effFileNonRes, args.effFileKStar, args.effFileDelta, args.effFileLambda1520] | ||
colorMarkerPrompt = [kBlack, kRed, kRed, kRed, kRed] | ||
colorMarkerFD = [kBlack, kAzure, kAzure, kAzure, kAzure] | ||
styleMarkerPrompt = [kFullDiamond, kFullSquare, kFullStar, kFullTriangleUp, kFullCross] | ||
styleMarkerFD = [kOpenDiamond, kOpenSquare, kOpenStar, kOpenTriangleUp, kOpenCross] | ||
hEffPrompt, hEffFD = [], [] | ||
|
||
for iReso, fileName, in enumerate(inputFile): | ||
infile = TFile.Open(fileName) | ||
hEffPrompt.append(infile.Get('hAccEffPrompt')) | ||
hEffFD.append(infile.Get('hAccEffFD')) | ||
hEffPrompt[iReso].SetDirectory(0) | ||
hEffFD[iReso].SetDirectory(0) | ||
SetObjectStyle( | ||
hEffPrompt[iReso], | ||
color=colorMarkerPrompt[iReso], | ||
markerstyle=styleMarkerPrompt[iReso] | ||
) | ||
SetObjectStyle( | ||
hEffFD[iReso], | ||
color=colorMarkerFD[iReso], | ||
markerstyle=styleMarkerFD[iReso], | ||
markersize=1.5, linewidh=2, linestyle=7 | ||
) | ||
|
||
ptMin = hEffPrompt[0].GetBinLowEdge(1) | ||
ptMax = hEffPrompt[0].GetBinLowEdge(hEffPrompt[0].GetNbinsX()) + hEffPrompt[0].GetBinWidth(hEffPrompt[0].GetNbinsX()) | ||
|
||
cEffPrompt = TCanvas('cEffPrompt', '', 800, 800) | ||
cEffPrompt.DrawFrame(ptMin, 1.e-5, ptMax, 1., | ||
';#it{p}_{T} (GeV/#it{c});(Acc #times #epsilon);') | ||
cEffPrompt.SetLogy() | ||
for histo in hEffPrompt: | ||
histo.Draw('same') | ||
|
||
cEffFD = TCanvas('cEffFD', '', 800, 800) | ||
cEffFD.DrawFrame(ptMin, 1.e-5, ptMax, 1., | ||
';#it{p}_{T} (GeV/#it{c});(Acc #times #epsilon);') | ||
cEffFD.SetLogy() | ||
for histo in hEffFD: | ||
histo.Draw('same') | ||
|
||
outFileNamePDF = args.outFileName.replace('.root', '') | ||
cEffPrompt.SaveAs('%s_prompt.pdf' % (outFileNamePDF)) | ||
cEffFD.SaveAs('%s_FD.pdf' % (outFileNamePDF)) | ||
|
||
hEffCw = hEffPrompt[0].Clone("hAccEffPrompt") | ||
hEffBw = hEffFD[0].Clone("hAccEffFD") | ||
|
||
BR = [3.5 * 1e-02, 1.96 * 0.667 * 1e-02, 1.08 * 1e-02, 2.2 * 0.225 * 1e-02] | ||
nPtBins = hEffPrompt[0].GetNbinsX() | ||
for iPt in range(nPtBins): | ||
effC, effB, uncEffC, uncEffB, sumOfW = (0. for _ in range(5)) | ||
for histo, br, in zip(hEffPrompt, BR): | ||
effC += histo.GetBinContent(iPt+1) * br | ||
effB += histo.GetBinContent(iPt+1) * br | ||
uncEffC += histo.GetBinError(iPt+1)**2 * br**2 | ||
uncEffB += histo.GetBinError(iPt+1)**2 * br**2 | ||
sumOfW += br | ||
hEffCw.SetBinContent(iPt+1, (effC/sumOfW)) | ||
hEffCw.SetBinError(iPt+1, np.sqrt(uncEffC)/sumOfW) | ||
hEffBw.SetBinContent(iPt+1, (effB/sumOfW)) | ||
hEffBw.SetBinError(iPt+1, np.sqrt(uncEffB)/sumOfW) | ||
|
||
outFile = TFile(args.outFileName, 'recreate') | ||
hEffCw.Write() | ||
hEffBw.Write() | ||
outFile.Close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? You are not drawing anything in the macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the previous version of the script I was not drawing the histograms, while now I'm doing it in the latest update