Skip to content

first attempt of PHOS workflow#2777

Merged
shahor02 merged 15 commits into
AliceO2Group:devfrom
peressounko:dev
Jan 24, 2020
Merged

first attempt of PHOS workflow#2777
shahor02 merged 15 commits into
AliceO2Group:devfrom
peressounko:dev

Conversation

@peressounko
Copy link
Copy Markdown
Collaborator

No description provided.

@peressounko peressounko requested a review from a team as a code owner January 14, 2020 00:01
Copy link
Copy Markdown
Collaborator

@shahor02 shahor02 left a comment

Choose a reason for hiding this comment

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

Thanks @peressounko
Please see some comments below, this is just a 1st part (till Clusterer.h) it will take some time to review 70 files.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

User-defined copy constructor makes class non-POD (though there are tricks to declare it as POD) but your copy constructor makes the same what
Cluster(const Cluster& clu) = default would do, please remove it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do you really need doubles? If not, prefer floats.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

since you are using default c-tor, you better initialize data members, e.g.
int mMulDigit = 0; //...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the same is here, you don't initialize data members

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

since you have at most 12k cells, you can save 4 bytes in the size of this class by defining it as

  int mLabel;       ///< Index of the corresponding entry/entries in the MC label array
  float mAmplitude; ///< Amplitude
  float mTime;      ///< Time
  short mAbsId;       ///< cell index (absolute cell ID)
  bool mIsHighGain; ///< High Gain or Low Gain channel (for calibration)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove as the default one will do the same

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

again, do you need double for energy?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Dear Ruben,
I hope I implemented all your suggestions in the current version.
Dmitri

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could you please indent properly?

Copy link
Copy Markdown
Collaborator

@shahor02 shahor02 left a comment

Choose a reason for hiding this comment

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

Hi @peressounko

Thanks, the previous corrections are ok, here are few more comments (till ClustererTask.cxx)

Cheers,
Ruben

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if you move char mMulDigit .. up by 1 line, you will save 4 bytes (due to the alignment)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

as an input arguments instead of const std::vector<xxx> one should use gsl/span<xxx>. Note that this interface allows to pass both vectors and spans.
See https://alice.its.cern.ch/jira/browse/O2-1017 for details.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

replaced input arguments except MCContainer: not sure span will work with its complicated structure

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, mc container at the moment need to be copied

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

idem here, spans instead of the vectors.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here also. Please check all similar cases.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

instead of the init loop it is much more efficient to memset(digitsUsed,0,sizeof(bool)*maxNDigits)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

... BTW, once you change input vectors to spans, you should query it as a vector rather then a pointer (i.e. simply digits[i]). Also note that vector::at(i) (as well as a span::at(i) is slower than the vector[i], span[i] since the former is doing a range check (not needed in the correct code).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

vector::erase is very expensive procedure (requires copy for all elements after the erased one. If you cannot avoid clusters elimination and it happens often, you better fill 1st a temporary vector, flag entries which should be eliminated, then copy surviving ones to the final vector.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

our coding guidelines disadvise using explicit new / delete, you better do
std::unique_ptr<int[]> maxAt = std::make_unique<int[]>(o2::phos::PHOSSimParams::Instance().mNLMMax)
Then you don't need to delete it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As I pass it to other methods, use vector instead of unique_ptr

@peressounko
Copy link
Copy Markdown
Collaborator Author

test failed due to ERROR: executable name o2-analysistutorial-vertexingHF does not follow naming convention : should only contains lowercase letters, numbers, or dashes

@shahor02
Copy link
Copy Markdown
Collaborator

This error should be ignored.

@sawenzel sawenzel mentioned this pull request Jan 16, 2020
Copy link
Copy Markdown
Collaborator

@shahor02 shahor02 left a comment

Choose a reason for hiding this comment

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

Hi @peressounko
here is the last set of comments.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As far as I understand, FullCluster vector is used only is an internal container, right? (as this class itself contains a vector, storing or messaging will be very expensive). In this case you don't need to declare a vector here, it is needed for the serialization only.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since all these vectors are modified together, it is much more efficient to define e.g. a nested

struct ListElem {
short digID;
float energy;
int timev;
std::pair<int, float> lbl;
};

and add as a data member just 1 vector<ListElem>.
This will also simplify your multi-stage iterator loops in the methods below.

Also, why do you need a pointer datamember mPHOSGeom, which anyway will point on the same instance of the Geometry::GetInstance()?
You can either provide it as an argument of the methods wich use it, or get in these methods on the fly from that static getter.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good idea - implemented.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also here erase in the loop will lead to performance penalty (especially done on separate vectors, but I hope you will reduce it to single vector, see comment above).
Since these clusters are anyway transient objects, can't you simply flag the digits you want to suppress (e.g. by assigning negative time etc.) and then simply ignore flagged entries?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I left erase in few places: these very rare cases it is more efficient to move 5 ~CelElements then check special tag (e.g. energy) for all good elements in all clusters.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

instead of dividing in the loop by mFullEnergy, it is more efficient to calculate once outside of the loop the 1./mFullEnergy and then use multiplication.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why don't you use simply std::find? Note that you Digit has no custom operator== used in the search, so the compiler will generate for you an automatic one which will compare all data members. I guess this is not what you want?
BTW, such a light-weight methods like operators in the Digit is better to define inline.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I added operator == This is copy-past of std::find slightly adopted to this case.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this can be constexpr.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed this rudiment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

...e/(2*b*b)); will be faster

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we are switching to spans instead of vectors when receiving the inputs, see https://alice.its.cern.ch/jira/browse/O2-1017 for details.

Comment on lines 41 to 44
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

using span here instead of vector causes
[7968:PHOSClusterizerSpec]: [20:51:44][ERROR] Exception caught: Inconsistent serialization method for extracting span

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could you send me full error message?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

here is full log: https://drive.google.com/file/d/1UYuvAhLxcGZIhs2j7pHNbeMGmwpw7XXv/view?usp=sharing
For some reason I can not attach it directly here...
Dmitri

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks like the TriggerRecords are not messaged via shared memory but serialized. This is strange since you've copied the class from the emcal and there it is messagable. I will need to build your branch and test myself, but will not to do this today...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

There might be problems with TR as well, but when I tried to debug a bit I found that exception is thrown while getting Digits. With vectors (as in EMCAL) it works well.
Thanks, Dmitri

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I've tried with the same outcomes as yours. The problem comes from the Publisher/RootTreeReader. Will try to debug tomorrow with Giulio. Meanwhile, I see that you have conflicting branchnames as PHS... and PHOS..., could you bring them to unique standard (preferaby PHS)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thank you, Ruben. Concerning branch naming: I always use data producer PHS while in branch names I always use PHOS. I will cross-check.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @peressounko
The RootTreeReader was now fixed, so you can use spans instead of vectors (but you need to add a few lines in the publisher and setting up the reader, see 4abc548)

Cheers,
Ruben

@peressounko
Copy link
Copy Markdown
Collaborator Author

Dear Ruben, I implemented most of your suggestions except (main) one: switching to spans. Probably I do not understand this correctly, but when I replace vector->span as you suggest, I get:
[7968:PHOSClusterizerSpec]: [20:51:44][ERROR] Exception caught: Inconsistent serialization method for extracting span, see comment below.
Could you have a look, probably something else should be modified accordingly?
Best regards, Dmitri

@shahor02
Copy link
Copy Markdown
Collaborator

Hi @peressounko

Could you please add patch to O2/macro/analyzeDigitLabels.C changing
#include "PHOSSimulation/MCLabel.h" to DataFormatsPHOS/MCLabel.h.

@peressounko
Copy link
Copy Markdown
Collaborator Author

Dear Ruben,
I think code is ready for merging.
Dmitri

@shahor02
Copy link
Copy Markdown
Collaborator

yes, there is an unrelated problem in CI we are trying to understand, then I'll merge it.

Copy link
Copy Markdown
Collaborator

@shahor02 shahor02 left a comment

Choose a reason for hiding this comment

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

There is an unrelated error

Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
1639 warnings and 1 error generated.
Error while processing /mnt/mesos/sandbox/sandbox/sw/SOURCES/O2/build_o2checkcode_o2/0/GPU/GPUTracking/TRDTracking/GPUTRDTracker.cxx.
/mnt/mesos/sandbox/sandbox/sw/SOURCES/O2/build_o2checkcode_o2/0/GPU/GPUTracking/TRDTracking/GPUTRDTracker.cxx:38:10: error: 'omp.h' file not found [clang-diagnostic-error]
#include <omp.h>        

in the o2checkcode. @davidrohr , should it be added as an explicit dependency?

Squashing and merging this PR

@shahor02 shahor02 merged commit 7fae2ea into AliceO2Group:dev Jan 24, 2020
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.

2 participants