Skip to content

Conversation

@yashpatley
Copy link
Contributor

Updated histogram types and added CCDB object structure to consume less memory

Updated histogram types and added CCDB object structure to consume less memory
@github-actions
Copy link

O2 linter results: ❌ 0 errors, ⚠️ 0 warnings, 🔕 0 disabled

Comment on lines +136 to +141
struct CcdbObjects {
TList* ccdbList;
TObject* obj;
TProfile* hp;
THnSparseF* hn;
} ccdbObjects;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a full global structure needed to store entities that are used locally and temporarily?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it wasn't necessary, it was for the bookkeeping. But I will change it.

Comment on lines +322 to +324
ccdbObjects.hp = reinterpret_cast<TProfile*>(ccdbObjects.obj->Clone());
vAvgOutput[cntrx] += ccdbObjects.hp->GetBinContent(ccdbObjects.hp->GetXaxis()->FindBin(vCollParam[cntry]));
delete ccdbObjects.hp;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not recommend allocating and deallocating objects on a per collision level
Is it really needed to clone the CCDB objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of any other way other then fetching histograms from CCDB on per collision level, let me know if there is another way of getting them. I am not sure about the cloning at the moment, but I'll try without that, I think its possible.

Comment on lines 317 to 333
for (auto const& x : vHistNames) {
int cntry = 0;
for (auto const& y : x) {
TObject* obj = reinterpret_cast<TObject*>(ccdbObject->FindObject(y.c_str()));
ccdbObjects.obj = reinterpret_cast<TObject*>(ccdbObject->FindObject(y.c_str()));
if (corrType == kFineCorr) {
TProfile* hp = reinterpret_cast<TProfile*>(obj->Clone());
vAvgOutput[cntrx] += hp->GetBinContent(hp->GetXaxis()->FindBin(vCollParam[cntry]));
ccdbObjects.hp = reinterpret_cast<TProfile*>(ccdbObjects.obj->Clone());
vAvgOutput[cntrx] += ccdbObjects.hp->GetBinContent(ccdbObjects.hp->GetXaxis()->FindBin(vCollParam[cntry]));
delete ccdbObjects.hp;
} else {
THnF* hn = reinterpret_cast<THnF*>(obj->Clone());
ccdbObjects.hn = reinterpret_cast<THnSparseF*>(ccdbObjects.obj->Clone());
for (int i = 0; i < static_cast<int>(vHistNames.size()); ++i) {
binarray[i] = hn->GetAxis(i)->FindBin(vCollParam[i]);
binarray[i] = ccdbObjects.hn->GetAxis(i)->FindBin(vCollParam[i]);
}
vAvgOutput[cntrx] += hn->GetBinContent(hn->GetBin(binarray));
vAvgOutput[cntrx] += ccdbObjects.hn->GetBinContent(ccdbObjects.hn->GetBin(binarray));
delete ccdbObjects.hn;
}
++cntry;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is cryptic
Cryptic code is really hard to maintain and to evolve
I would recommend code that is readable with meaningful variable names and no magic numbers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the moment it may seem like "cryptic", but please give me a few iteration, I will try to modify it.

Copy link
Collaborator

@victor-gonzalez victor-gonzalez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will approve it for the time being but please have a look at my comments
Programming languages provide powerful syntax to do whatever one wants to do
One must choose the constructions that are easier to maintain and to evolve. Of course, one is free for choosing the worst constructions but this will have side effects one has to be ready to confront

@victor-gonzalez victor-gonzalez merged commit aad3bfc into AliceO2Group:master Oct 25, 2025
15 checks passed
@yashpatley yashpatley deleted the chptflow branch October 28, 2025 15:27
ThePhDane pushed a commit to ThePhDane/O2Physics that referenced this pull request Nov 3, 2025
lmattei01 pushed a commit to lmattei01/O2Physics that referenced this pull request Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants