|
| 1 | +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 2 | +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +// All rights not expressly granted are reserved. |
| 4 | +// |
| 5 | +// This software is distributed under the terms of the GNU General Public |
| 6 | +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +// |
| 8 | +// In applying this license CERN does not waive the privileges and immunities |
| 9 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +// or submit itself to any jurisdiction. |
| 11 | + |
| 12 | +/// \file CalibdEdxContainer.h |
| 13 | +/// \brief Definition of container class for dE/dx corrections |
| 14 | +/// \author Matthias Kleiner <mkleiner@ikf.uni-frankfurt.de> |
| 15 | + |
| 16 | +#ifndef ALICEO2_TPC_CALIBDEDXCONTAINER_H_ |
| 17 | +#define ALICEO2_TPC_CALIBDEDXCONTAINER_H_ |
| 18 | + |
| 19 | +#include "GPUCommonDef.h" |
| 20 | +#include "DataFormatsTPC/CalibdEdxCorrection.h" |
| 21 | +#include "DataFormatsTPC/CalibdEdxTrackTopologyPol.h" |
| 22 | +#include "DataFormatsTPC/CalibdEdxTrackTopologySpline.h" |
| 23 | +#include "FlatObject.h" |
| 24 | + |
| 25 | +#ifndef GPUCA_ALIGPUCODE |
| 26 | +#include <string_view> |
| 27 | +#endif |
| 28 | + |
| 29 | +namespace o2::tpc |
| 30 | +{ |
| 31 | + |
| 32 | +/// |
| 33 | +/// This container class contains all necessary corrections for the dE/dx |
| 34 | +/// Currently it holds the residual dE/dx correction and the track topology correction, which can be either provided by 2D-splines or by 5D-polynomials. |
| 35 | +/// To be able to correctly use the flat buffer functionality only one of the topology corrections should be set: 2D-splines or by 5D-polynomials! |
| 36 | +/// The track topology corrections are set as a nullptr for default as a member. |
| 37 | +/// By loading only one of them memory overhead for the classes are avoided and appropriate flat buffer sizes are used. |
| 38 | +/// |
| 39 | +class CalibdEdxContainer : public o2::gpu::FlatObject |
| 40 | +{ |
| 41 | + public: |
| 42 | + /// Default constructor: creates an empty uninitialized object |
| 43 | + CalibdEdxContainer() CON_DEFAULT; |
| 44 | + |
| 45 | + /// Copy constructor: disabled to avoid ambiguity. Use cloneFromObject() instead |
| 46 | + CalibdEdxContainer(const CalibdEdxContainer&) CON_DELETE; |
| 47 | + |
| 48 | + /// Assignment operator: disabled to avoid ambiguity. Use cloneFromObject() instead |
| 49 | + CalibdEdxContainer& operator=(const CalibdEdxContainer&) CON_DELETE; |
| 50 | + |
| 51 | + /// Destructor |
| 52 | + ~CalibdEdxContainer() CON_DEFAULT; |
| 53 | + |
| 54 | + /// \return returns the topology correction for the cluster charge |
| 55 | + /// \param region region of the TPC |
| 56 | + /// \param charge type of the charge (qMax or qTot) |
| 57 | + /// \param tanTheta local inclination angle tanTheta |
| 58 | + /// \param sinPhi snp track parameter |
| 59 | + /// \param z z position |
| 60 | + /// \param relPad relative pad position of the cluster |
| 61 | + /// \param relTime relative time position of the cluster |
| 62 | + GPUd() float getTopologyCorrection(const int region, const ChargeType charge, const float tanTheta, const float sinPhi, const float z, const float relPad, const float relTime) const |
| 63 | + { |
| 64 | + return mCalibTrackTopologyPol ? mCalibTrackTopologyPol->getCorrection(region, charge, tanTheta, sinPhi, z, relPad, relTime) : (mCalibTrackTopologySpline ? mCalibTrackTopologySpline->getCorrection(region, charge, tanTheta, sinPhi, z) : 1); |
| 65 | + } |
| 66 | + |
| 67 | + /// \return returns maximum tanTheta for which the topology correction is valid |
| 68 | + GPUd() float getMaxTanThetaTopologyCorrection() const { return mCalibTrackTopologyPol ? mCalibTrackTopologyPol->getMaxTanTheta() : (mCalibTrackTopologySpline ? mCalibTrackTopologySpline->getMaxTanTheta() : 1); } |
| 69 | + |
| 70 | + /// \return returns maximum sinPhi for which the topology correction is valid |
| 71 | + GPUd() float getMaxSinPhiTopologyCorrection() const { return mCalibTrackTopologyPol ? mCalibTrackTopologyPol->getMaxSinPhi() : (mCalibTrackTopologySpline ? mCalibTrackTopologySpline->getMaxSinPhi() : 1); } |
| 72 | + |
| 73 | + /// \return returns the residual dE/dx correction for the cluster charge |
| 74 | + /// \param stack ID of the GEM stack |
| 75 | + /// \param charge type of the charge (qMax or qTot) |
| 76 | + /// \param z z position |
| 77 | + /// \param tgl tracking parameter tgl |
| 78 | + GPUd() float getResidualCorrection(const StackID& stack, const ChargeType charge, const float z = 0, const float tgl = 0) const { return mCalibResidualdEdx.getCorrection(stack, charge, z, tgl); } |
| 79 | + |
| 80 | + /// ========== FlatObject functionality, see FlatObject class for description ================= |
| 81 | +#if !defined(GPUCA_GPUCODE) |
| 82 | + /// cloning a container object (use newFlatBufferPtr=nullptr for simple copy) |
| 83 | + void cloneFromObject(const CalibdEdxContainer& obj, char* newFlatBufferPtr); |
| 84 | + |
| 85 | + /// move flat buffer to new location |
| 86 | + /// \param newBufferPtr new buffer location |
| 87 | + void moveBufferTo(char* newBufferPtr); |
| 88 | +#endif |
| 89 | + /// destroy the object (release internal flat buffer) |
| 90 | + void destroy(); |
| 91 | + |
| 92 | + /// set location of external flat buffer |
| 93 | + void setActualBufferAddress(char* actualFlatBufferPtr); |
| 94 | + |
| 95 | + /// set future location of the flat buffer |
| 96 | + void setFutureBufferAddress(char* futureFlatBufferPtr); |
| 97 | + /// ================================================================================================ |
| 98 | + |
| 99 | +#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE) |
| 100 | + // loading the polynomial track topology correction from a file |
| 101 | + /// \param fileName input file containg the correction |
| 102 | + void loadPolTopologyCorrectionFromFile(std::string_view fileName); |
| 103 | + |
| 104 | + // loading the spline track topology correction from a file |
| 105 | + /// \param fileName input file containg the correction |
| 106 | + void loadSplineTopologyCorrectionFromFile(std::string_view fileName); |
| 107 | + |
| 108 | + // loading the residual dE/dx correction from a file |
| 109 | + /// \param fileName input file containg the correction |
| 110 | + void loadResidualCorrectionFromFile(std::string_view fileName) { mCalibResidualdEdx.loadFromFile(fileName); } |
| 111 | + |
| 112 | +#endif // !GPUCA_GPUCODE |
| 113 | + |
| 114 | + private: |
| 115 | + CalibdEdxTrackTopologySpline* mCalibTrackTopologySpline{nullptr}; ///< calibration for the track topology correction (splines) |
| 116 | + CalibdEdxTrackTopologyPol* mCalibTrackTopologyPol{nullptr}; ///< calibration for the track topology correction (polynomial) |
| 117 | + CalibdEdxCorrection mCalibResidualdEdx; ///< calibration for the residual dE/dx correction |
| 118 | + |
| 119 | +#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE) |
| 120 | + /// \return returns size of the CalibdEdxTrackTopologyPol class |
| 121 | + std::size_t sizeOfCalibdEdxTrackTopologyPol() const { return alignSize(sizeof(CalibdEdxTrackTopologyPol), FlatObject::getClassAlignmentBytes()); } |
| 122 | + |
| 123 | + /// \return returns size of the CalibdEdxTrackTopologySpline class (without taking the size of the flat buffer into acocunt) |
| 124 | + std::size_t sizeOfCalibdEdxTrackTopologySpline() const { return alignSize(sizeof(CalibdEdxTrackTopologyPol), FlatObject::getClassAlignmentBytes()); } |
| 125 | +#endif // !GPUCA_GPUCODE |
| 126 | + |
| 127 | +#ifndef GPUCA_ALIROOT_LIB |
| 128 | + ClassDefNV(CalibdEdxContainer, 1); |
| 129 | +#endif |
| 130 | +}; |
| 131 | + |
| 132 | +} // namespace o2::tpc |
| 133 | + |
| 134 | +#endif |
0 commit comments