Skip to content
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

TPC: Adding streamer for FastTransform in reconstruction #10739

Merged
merged 4 commits into from
Feb 12, 2023

Conversation

matthias-kleiner
Copy link
Contributor

SpaceCharge: adding option to use analytical formula for corrections and distortions

  • adding simple default analytical distortions/corrections
  • add streamer in digitizer

DebugStreamer: Allow writing out streams in parallel

SpaceCharge: adding option to use analytical formula for corrections and distortions
 - adding simple default analytical distortions/corrections
 - add streamer in digitizer

DebugStreamer: Allow  writing out streams in parallel
@davidrohr
Copy link
Collaborator

davidrohr commented Feb 9, 2023 via email

@matthias-kleiner
Copy link
Contributor Author

What is sizeof(o2::utils::DebugStreamer)? Is it guaranteed to be the same on CPU and GPU? Otherwise it will break GPU reconstruction.

The class is only defined when DEBUG_STREAMER was set during compiling o2. If it was not specified then the class should be always empty and the same size for CPU and GPU.
If o2 was compiled with DEBUG_STREAMER and one runs on GPU, then I guess it would be of different size, but I will check what happens.

@davidrohr
Copy link
Collaborator

davidrohr commented Feb 9, 2023 via email

Copy link
Collaborator

@wiechula wiechula left a comment

Choose a reason for hiding this comment

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

@matthias-kleiner , thanks for the implementation!
Concerning the streamers, could you please also add then here:
https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/TPCFastTransformation/TPCFastTransform.h#L657
https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/TPCFastTransformation/TPCFastTransform.h#L668
These functions are also called in reconstruction. @davidrohr are there others needed?

@matthias-kleiner
Copy link
Contributor Author

Ok, thx. Then it should be fine. However, I propose we add a check at the initialization of the GPUReconstruction class when the DEBUG STREAMER define is set, and if so we throw a fatal if the backend is not CPU, to avoid confusing crashes if accidentally they are used together.

This would be good. Can you implement this?

Copy link
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.

@matthias-kleiner did you check if the streaming to trees (even different ones) works in multithreaded code? The root I/O is in general not thread safe, see e.g. https://root-forum.cern.ch/t/root-i-o-and-thread-safety/5857

@davidrohr
Copy link
Collaborator

davidrohr commented Feb 9, 2023 via email

@matthias-kleiner
Copy link
Contributor Author

@matthias-kleiner did you check if the streaming to trees (even different ones) works in multithreaded code? The root I/O is in general not thread safe, see e.g. https://root-forum.cern.ch/t/root-i-o-and-thread-safety/5857

Yes I checked this and it is working fine for me. If each thread gets its unique TFile then it is working without problems.

@matthias-kleiner
Copy link
Contributor Author

Just some information on how to use it, in case someone wants to use it

  1. Create the space-charge object which can be used in the digitizer and the fast transform which can be used in the reconstruction (default analytical formulas are used, in case of custom formulas they should be set in the createTPCSpaceChargeCorrectionAnalytical() function)
.L O2/Detectors/TPC/reconstruction/macro/createTPCSpaceChargeCorrection.C+
createTPCSpaceChargeCorrectionAnalytical("tpctransform_ana.root");

Output of debug spline object:

r fastTransformUnitTest_debug1_gridsize180-129-129.root
fastTransform -> Draw("((lx*50-254.5)/49-lx) : lx","","colz");

corrections local X
corrections local Y
corrections local Z
formula - corrections local X

  1. Running the digitizer with the analytical distortions and create debug output
o2-sim-digitizer-workflow --onlyDet TPC --distortionType 2 --readSpaceCharge "distortions_analytical.root" --configKeyValues "DebugStreamerParam.StreamLevel=32;" --tpc-lanes 4 -b
  1. Running the reconstruction
mkdir -p TPC/Calib/CorrectionMap
cp tpctransform_ana.root TPC/Calib/CorrectionMap/snapshot.root
o2-tpc-reco-workflow --output-type "tracks" --infile "tpcdigits.root" --condition-remap "file:///data/mkleiner/tmp/anasc/sim/=TPC/Calib/CorrectionMap" --configKeyValues "DebugStreamerParam.StreamLevel=8;" -b
  1. In case debug output was created merge the TTrees
hadd debug_fasttransform.root  debug_fasttransform*
root.exe
o2::utils::DebugStreamer::mergeTrees("debug_fasttransform.root", "debug_fasttransform_merged.root");
  1. Comparing output corrections with expectation:
root.exe debug_fasttransform_merged.root

corrections local X - formula:tree_0 -> Draw("dx - ((lx*50-254.5)/49-lx) : lx","","");
corrections local Y - formula: tree_0 -> Draw("(lyT -ly) - (-(2 + 0.01 * (lx + (lx * 50 - 254.5) / 49 - lx))) : lx","","*")
corrections local Z - formula: tree_0 -> Draw("(lzT - lz) - (lz * 50 / 51 - lz) : lz","","*")

@matthias-kleiner
Copy link
Contributor Author

@matthias-kleiner , thanks for the implementation! Concerning the streamers, could you please also add then here: https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/TPCFastTransformation/TPCFastTransform.h#L657 https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/TPCFastTransformation/TPCFastTransform.h#L668 These functions are also called in reconstruction. @davidrohr are there others needed?

Thanks, I just added them

@wiechula
Copy link
Collaborator

wiechula commented Feb 9, 2023

@matthias-kleiner , thanks for the implementation! Concerning the streamers, could you please also add then here: https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/TPCFastTransformation/TPCFastTransform.h#L657 https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/TPCFastTransformation/TPCFastTransform.h#L668 These functions are also called in reconstruction. @davidrohr are there others needed?

Thanks, I just added them

My idea was to add streamers directly in the functions above, as in the Transform to see the values which are called.

@matthias-kleiner
Copy link
Contributor Author

@matthias-kleiner , thanks for the implementation! Concerning the streamers, could you please also add then here: https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/TPCFastTransformation/TPCFastTransform.h#L657 https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/TPCFastTransformation/TPCFastTransform.h#L668 These functions are also called in reconstruction. @davidrohr are there others needed?

Thanks, I just added them

My idea was to add streamers directly in the functions above, as in the Transform to see the values which are called.

Now I understand, I added this

@alibuild
Copy link
Collaborator

Error while checking build/O2/fullCI for 0d625ba at 2023-02-10 12:16:

## sw/BUILD/O2-latest/log
/sw/SOURCES/O2/10739-slc8_x86-64/0/GPU/TPCFastTransformation/TPCFastTransform.h(120): error: calling a __device__ function("o2::utils::DebugStreamer::flush() const") from a __host__ function("flushStreamer") is not allowed
ninja: build stopped: subcommand failed.

Full log here.

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.

5 participants