Skip to content

TRD: Move Digit class to DataFormatsTRD#6014

Merged
davidrohr merged 3 commits into
AliceO2Group:devfrom
jolopezl:TRD-move-digit-class
Apr 29, 2021
Merged

TRD: Move Digit class to DataFormatsTRD#6014
davidrohr merged 3 commits into
AliceO2Group:devfrom
jolopezl:TRD-move-digit-class

Conversation

@jolopezl
Copy link
Copy Markdown
Contributor

For moving the Digit clas to DataFormatsTRD, HelperMethods is added in DataFormatsTRD. Otherwise, a cyclic dependency appears between TRDBase and DataFormatTRD.

Copy link
Copy Markdown
Contributor

@martenole martenole left a comment

Choose a reason for hiding this comment

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

Thanks Jorge that looks good. Would just consider the minor changes in the helper class methods

static int getMCMfromPad(int irow, int icol)
{
if (irow < 0 || icol < 0 || irow > constants::NROWC1 || icol > constants::NCOLUMN) {
return -1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know this is written simply analog to what was there in AliRoot, but now that I see it again and think about it shouldn't we put an error message here in case of a wrong input? Because where these functions are used the return values are not checked for plausibility.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These methods can be called a lot. Since the return value is a flag for errors, I don't think one should add messages here, even if it's just a DEBUG message. So, I would leave this as it is or add an assertion for the whole test condition.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Especially if the function is called a lot, we should probably not force the user to check for errors. I think this should be a fatal error: if we do not get irow and icol correct, then there is a major issue somewhere else in the code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My point here is that this should never happen. These methods are primarily internal, and if there is an error, it should pop up in a test (less likely, be caught eventually as a bug when you start seeing -1 around). Therefore it will require a change in the codebase. So, we expect that this actually never happens or rarely happens. That's why we should use assert, instead of logging, IMO.

We had a similar discussion with @sawenzel a long time ago (See: this code review), and the choice was using assert.

Since this condition should never happen or at least is very unlikely, one could use some optimizations, like: https://en.cppreference.com/w/cpp/language/attributes/likely, but I am not sure how this applies to O2. Of course, this is not relevant if one drops the conditional here.

Comment thread DataFormats/Detectors/TRD/include/DataFormatsTRD/HelperMethods.h
Comment thread DataFormats/Detectors/TRD/include/DataFormatsTRD/HelperMethods.h
Comment thread DataFormats/Detectors/TRD/include/DataFormatsTRD/HelperMethods.h
@martenole
Copy link
Copy Markdown
Contributor

Ah o2::trd::Digit is already used in QC.. I think then for a smooth transition it would be ideal to first keep the Digit class in TRDBase in order not to break the QC build. So we would have two Digit classes simultaneously, but the one from TRDBase is only used by QC.
And after this PR is merged we can change QC to take the Digit class from DataformatsTRD and only then we can remove the old Digit class from TRDBase.


} // namespace trd
} // namespace o2
#include "DataFormatsTRD/Digit.h"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this a temporary hack, or is this meant to stay? I think we should avoid having files that are essentially unused.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This would be temporary in order to not break the QC build which looks for the Digit header in TRDBase. After this is merged and QC is updated the file can be deleted

@davidrohr davidrohr merged commit e8cbd2f into AliceO2Group:dev Apr 29, 2021
@jolopezl jolopezl deleted the TRD-move-digit-class branch April 29, 2021 16:16
cortesep pushed a commit to cortesep/AliceO2 that referenced this pull request Jun 11, 2021
* Move Digit to DataFormats

* Use correct header in macro

* TRD: back compatibility for QC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants