-
Notifications
You must be signed in to change notification settings - Fork 484
AOD: Prepare Thinner for TPC-only V0s #12510
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
Conversation
|
Ok last part, I found a better way to compare the resulting AO2Ds in #12039, posting here for due to slight modification and bookkeeping but all credit goes to the author of the mentioned PR. void GetMinMax(TH1 *h, Double_t &ymin, Double_t &ymax) {
ymax = -1e30;
ymin = 1e30;
for (Int_t i = 1; i <= h->GetNbinsX(); i++) {
Double_t y = h->GetBinContent(i);
ymax = TMath::Max(ymax, y);
if (y > 0)
ymin = TMath::Min(ymin, y);
}
}
Bool_t LogScale(TH1 *h) {
Double_t ymin, ymax;
GetMinMax(h, ymin, ymax);
if (ymin > ymax)
return false;
return (ymax > ymin * 1000);
}
void CompareTrees(TTree *mine, TTree *dev, TDirectory *ret, TCanvas *canvas,
TString df) {
TDirectory *sub = ret->mkdir(Form("%s_%s", df.Data(), mine->GetName()));
auto mineL = mine->GetListOfBranches();
Int_t ncol = mineL->GetEntriesFast() > 10 ? 3 : 2;
Int_t nrow = (mineL->GetEntriesFast() + ncol - 1) / ncol;
canvas->Clear();
canvas->Divide(ncol, nrow);
canvas->Draw();
TVirtualPad *pad = 0;
Int_t ipad = 1;
Int_t mineN = mine->GetEntries();
Int_t devN = dev->GetEntries();
if (mineN != devN) {
Fatal(mine->GetName(), "Inconsistent selected %d (mine) vs %d (dev)", mineN,
devN);
}
sub->cd();
for (auto ob : *mineL) {
TBranch *mineB = static_cast<TBranch *>(ob);
TObject *db = dev->GetListOfBranches()->FindObject(mineB->GetName());
if (not db) {
Fatal(mineB->GetName(), "Branch not in dev %s", dev->GetName());
continue;
}
TBranch *devB = static_cast<TBranch *>(db);
Info("", " %s/%s", mine->GetName(), mineB->GetName());
mine->Draw(Form("%s>>hmine", mineB->GetName()), "", "goff");
dev->Draw(Form("%s>>hdev", devB->GetName()), "", "goff");
mineN = mine->GetSelectedRows();
devN = dev->GetSelectedRows();
Double_t *mineX = mine->GetV1();
Double_t *devX = dev->GetV1();
Int_t nDiff = 0;
Int_t diff1 = -1;
for (size_t i = 0; i < TMath::Min(mineN, devN); i++) {
if (TMath::Abs((mineX[i] - devX[i]) / devX[i]) > 0.0001) {
nDiff++;
// Info(mineB->GetName(), " %8d: %g vs %g",
// i, mineX[i], devX[i]);
if (diff1 >= 0)
continue;
diff1 = i;
}
}
if (nDiff > 0)
Fatal(mineB->GetName(), "%d values differ, starting at %d", nDiff, diff1);
TH1 *mineH = static_cast<TH1 *>(sub->Get("hmine"));
TH1 *devH = static_cast<TH1 *>(sub->Get("hdev"));
if ((mineH and not devH) or (not mineH and devH)) {
Fatal(mineB->GetName(), "One histogram is missing %p %p", mineH, devH);
continue;
}
if (not mineH and not devH) {
// Warning(mineB->GetName(),"No histograms");
continue;
}
mineH->SetName(mineB->GetName());
mineH->SetTitle("PR");
mineH->SetLineColor(kRed + 1);
mineH->SetFillColor(kRed + 1);
mineH->SetMarkerColor(kRed + 1);
mineH->SetMarkerStyle(20);
devH->SetName(devB->GetName());
devH->SetTitle("Dev");
devH->SetLineColor(kBlue + 1);
devH->SetFillColor(kBlue + 1);
devH->SetMarkerColor(kBlue + 1);
devH->SetMarkerStyle(25);
devH->SetMarkerSize(1.2);
THStack *stack = new THStack(mineB->GetName(), mineB->GetName());
stack->Add(mineH);
stack->Add(devH);
stack->Write();
pad = canvas->cd(ipad);
stack->Draw("no stack ep");
TH1 *h = stack->GetHistogram();
if (LogScale(mineH) or LogScale(devH))
pad->SetLogy();
pad->BuildLegend();
ipad++;
}
}
void CompareAO2D() {
TFile *origFile = TFile::Open("AO2D.root", "READ");
TFile *mineFile = TFile::Open("AO2D_thin_test.root", "READ");
TFile *devFile = TFile::Open("AO2D_thin_dev.root", "READ");
TFile *output = TFile::Open("compare.root", "RECREATE");
TCanvas *canvas = new TCanvas("compare", "Compare AODs", 600, 800);
canvas->Print(Form("%s.pdf[", canvas->GetName()));
int nDF{0};
for (auto keyDF : *origFile->GetListOfKeys()) {
TString df = static_cast<TKey *>(keyDF)->ReadObj()->GetName();
if (!df.BeginsWith("DF_")) {
continue;
}
TDirectory *mineDF = mineFile->GetDirectory(df);
TDirectory *devDF = devFile->GetDirectory(df);
if (!mineDF || !devDF) {
Fatal("", "%s not in one File!", df.Data());
}
Printf("Analyzing %s", mineDF->GetName());
for (auto key : *mineDF->GetListOfKeys()) {
TObject *keyTree = static_cast<TKey *>(key)->ReadObj();
if (!keyTree->InheritsFrom(TTree::Class())) {
continue;
}
Info("", "%s", key->GetName());
TObject *mineO = static_cast<TKey *>(key)->ReadObj();
if (not mineO) {
Fatal(key->GetName(), "Tree null");
}
TObject *devO = devDF->Get(mineO->GetName());
if (not devO) {
Fatal(mineO->GetName(), "Object not found in dev output");
}
if (TString name = key->GetName(); name == "O2trackqa"){
continue; // trackqa is sampled, e.g., not reproducible
}
TTree *mineT = static_cast<TTree *>(mineO);
TTree *devT = static_cast<TTree *>(devO);
CompareTrees(mineT, devT, output, canvas, df);
canvas->Print(Form("%s.pdf", canvas->GetName()),
Form("Title: %s in %s", mineT->GetName(), df.Data()));
}
if (nDF++ > 10) {
break;
}
}
canvas->Print(Form("%s.pdf]", canvas->GetName()));
output->Write();
}The resulting report: For scenario four I did a test on a MC production with mostly photons (most V0 prongs are TPConly). I ran the analysis on the original-unthinned AO2D and then based on this PR thinned version including TPConly prongs. The results are identical, thus showing that the correct V0 tracks are kept in the AO2D + all original kept tracks. |
jgrosseo
left a comment
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.
Thanks for this extensive work and the major testing effort.
Please find my mostly minor comments here.
28e388e to
8ff247a
Compare
|
Also another question I had; Is it save to make keeping TPC v0 prongs optional, okay in 2022 there are non anyways but if this is ever applied in to future datasets. Then the AO2Ds are not valid in the sense that there will be V0 with TPConly prongs which would be thrown away unless one explicitly specifies '-K'. IMHO, I would drop the flag. |
Yes, I agree. If we want to keep the flag one would need to remove those V0s which is additional further work. Better to drop the flag for now. |
This patch carefully checks which tracks are associated with a V0 and flags to not be discarded. This is written such that the thinner is unaware of the track-type. Additionally, this patch further generalizes the thinner by making it check manually for the table_name with regex. E.g., previously the v0-name was specifically ‘O2v0_001’, now this has been changed to ’O2v0_00?’. That way, we no longer care about the actual version contained in the table. Hence, new AO2Ds can also be thinned. Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
|
Error while checking build/O2/fullCI for 8ff247a at 2024-01-22 15:28: Full log here. |
This patch carefully checks which tracks are associated with a V0 and flags to not be discarded. This is written such that the thinner is unaware of the track-type. Additionally, this patch further generalizes the thinner by making it check manually for the table_name with regex. E.g., previously the v0-name was specifically ‘O2v0_001’, now this has been changed to ’O2v0_00?’. That way, we no longer care about the actual version contained in the table. Hence, new AO2Ds can also be thinned. Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
This patch carefully checks which tracks are associated with a V0 and flags to not be discarded. This is written such that the thinner is unaware of the track-type. Additionally, this patch further generalizes the thinner by making it check manually for the table_name with regex. E.g., previously the v0-name was specifically ‘O2v0_001’, now this has been changed to ’O2v0_00?’. That way, we no longer care about the actual version contained in the table. Hence, new AO2Ds can also be thinned. Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
This patch carefully checks which tracks are associated with a V0 and flags to not be discarded. This is written such that the thinner is unaware of the track-type. Additionally, this patch further generalizes the thinner by making it check manually for the table_name with regex. E.g., previously the v0-name was specifically ‘O2v0_001’, now this has been changed to ’O2v0_00?’. That way, we no longer care about the actual version contained in the table. Hence, new AO2Ds can also be thinned. Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>


This patch carefully checks which tracks are associated with a V0 and flags to not be discarded. This is written such that the thinner is unaware of the track-type. Additionally, this patch further generalizes the thinner by making it check manually for the table_name with regex. E.g., previously the v0-name was specifically ‘O2v0_001’, now this has been changed to ’O2v0_00?’. That way, we no longer care about the actual version contained in the table. Hence, new AO2Ds can also be thinned.
Additionally, I added short_options and a flag to protect against overwriting existing output files (mostly for my own sanity). Also I added some printing to compare the file sizes before and after thinning.
I manually sporadically scanned the tree entries of O2v0 and O2trackextra and compared if the prong indices correspond to the same tracks. The thinning w/o TPC tracks was space Saving ~69.1% and w TPC tracks it was ~68%. The timing increased by ~6s so ~10%. I checked one AO2D from the PbPb apass1.
@jgrosseo open to suggestions and to trim this PR down if needed.