|
| 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 GRPLHCIFData.h |
| 13 | +/// \brief container for the LHC InterFace data |
| 14 | + |
| 15 | +#ifndef O2_GRP_LHCIFDATA_H |
| 16 | +#define O2_GRP_LHCIFDATA_H |
| 17 | + |
| 18 | +#include <Rtypes.h> |
| 19 | +#include <string> |
| 20 | +#include <unordered_map> |
| 21 | +#include <cstdint> |
| 22 | +#include "CommonTypes/Units.h" |
| 23 | +#include "CommonConstants/LHCConstants.h" |
| 24 | +#include "CommonDataFormat/BunchFilling.h" |
| 25 | + |
| 26 | +namespace o2 |
| 27 | +{ |
| 28 | +namespace parameters |
| 29 | +{ |
| 30 | + |
| 31 | +class GRPLHCIFData |
| 32 | +{ |
| 33 | + |
| 34 | + using beamDirection = o2::constants::lhc::BeamDirection; |
| 35 | + |
| 36 | + public: |
| 37 | + GRPLHCIFData() = default; |
| 38 | + ~GRPLHCIFData() = default; |
| 39 | + |
| 40 | + static const std::unordered_map<unsigned int, unsigned int> mZtoA; |
| 41 | + |
| 42 | + std::pair<long, int32_t> getBeamEnergyPerZWithTime() const { return mBeamEnergyPerZ; } |
| 43 | + int32_t getBeamEnergyPerZ() const { return mBeamEnergyPerZ.second; } |
| 44 | + long getBeamEnergyPerZTime() const { return mBeamEnergyPerZ.first; } |
| 45 | + void setBeamEnergyPerZWithTime(std::pair<long, int32_t> p) { mBeamEnergyPerZ = p; } |
| 46 | + void setBeamEnergyPerZWithTime(long t, int32_t v) { mBeamEnergyPerZ = std::make_pair(t, v); } |
| 47 | + |
| 48 | + std::pair<long, int32_t> getFillNumberWithTime() const { return mFillNumber; } |
| 49 | + int32_t getFillNumber() const { return mFillNumber.second; } |
| 50 | + long getFillNumberTime() const { return mFillNumber.first; } |
| 51 | + void setFillNumberWithTime(std::pair<long, int32_t> p) { mFillNumber = p; } |
| 52 | + void setFillNumberWithTime(long t, int32_t v) { mFillNumber = std::make_pair(t, v); } |
| 53 | + |
| 54 | + std::pair<long, std::string> getInjectionSchemeWithTime() const { return mInjectionScheme; } |
| 55 | + std::string getInjectionScheme() const { return mInjectionScheme.second; } |
| 56 | + long getInjectionSchemeTime() const { return mInjectionScheme.first; } |
| 57 | + void setInjectionSchemeWithTime(std::pair<long, std::string> p) { mInjectionScheme = p; } |
| 58 | + void setInjectionSchemeWithTime(long t, std::string v) { mInjectionScheme = std::make_pair(t, v); } |
| 59 | + |
| 60 | + std::pair<long, int32_t> getAtomicNumberB1WithTime() const { return mAtomicNumberB1; } |
| 61 | + int32_t getAtomicNumberB1() const { return mAtomicNumberB1.second; } |
| 62 | + long getAtomicNumberB1Time() const { return mAtomicNumberB1.first; } |
| 63 | + void setAtomicNumberB1WithTime(std::pair<long, int32_t> p) { mAtomicNumberB1 = p; } |
| 64 | + void setAtomicNumberB1WithTime(long t, int32_t v) { mAtomicNumberB1 = std::make_pair(t, v); } |
| 65 | + |
| 66 | + std::pair<long, int32_t> getAtomicNumberB2WithTime() const { return mAtomicNumberB2; } |
| 67 | + int32_t getAtomicNumberB2() const { return mAtomicNumberB2.second; } |
| 68 | + long getAtomicNumberB2Time() const { return mAtomicNumberB2.first; } |
| 69 | + void setAtomicNumberB2WithTime(std::pair<long, int32_t> p) { mAtomicNumberB2 = p; } |
| 70 | + void setAtomicNumberB2WithTime(long t, int32_t v) { mAtomicNumberB2 = std::make_pair(t, v); } |
| 71 | + |
| 72 | + std::pair<long, o2::units::AngleRad_t> getCrossingAngleWithTime() const { return mCrossingAngle; } |
| 73 | + o2::units::AngleRad_t getCrossingAngle() const { return mCrossingAngle.second; } |
| 74 | + long getCrossingAngleTime() const { return mCrossingAngle.first; } |
| 75 | + void setCrossingAngleWithTime(std::pair<long, o2::units::AngleRad_t> p) { mCrossingAngle = p; } |
| 76 | + void setCrossingAngleWithTime(long t, o2::units::AngleRad_t v) { mCrossingAngle = std::make_pair(t, v); } |
| 77 | + |
| 78 | + std::pair<long, o2::BunchFilling> getBunchFillingWithTime() const { return mBunchFilling; } |
| 79 | + o2::BunchFilling getBunchFilling() const { return mBunchFilling.second; } |
| 80 | + long getBunchFillingTime() const { return mBunchFilling.first; } |
| 81 | + void setBunchFillingWithTime(std::pair<long, o2::BunchFilling> p) { mBunchFilling = p; } |
| 82 | + void setBunchFillingWithTime(long t, o2::BunchFilling v) { mBunchFilling = std::make_pair(t, v); } |
| 83 | + |
| 84 | + /// getters/setters for given beam A and Z info, encoded as A<<16+Z |
| 85 | + int getBeamZ(beamDirection beam) const { return mBeamAZ[static_cast<int>(beam)] & 0xffff; } |
| 86 | + int getBeamA(beamDirection beam) const { return mBeamAZ[static_cast<int>(beam)] >> 16; } |
| 87 | + float getBeamZoverA(beamDirection beam) const; |
| 88 | + void setBeamAZ(int a, int z, beamDirection beam) { mBeamAZ[static_cast<int>(beam)] = (a << 16) + z; } |
| 89 | + void setBeamAZ(beamDirection beam); |
| 90 | + void setBeamAZ(); |
| 91 | + /// getters/setters for beam energy per charge and per nucleon |
| 92 | + float getBeamEnergyPerNucleon(beamDirection beam) const { return mBeamEnergyPerZ.second * getBeamZoverA(beam); } |
| 93 | + /// calculate center of mass energy per nucleon collision |
| 94 | + float getSqrtS() const; |
| 95 | + /// helper function for BunchFilling |
| 96 | + void translateBucketsToBCNumbers(std::vector<int32_t>& bcNb, std::vector<int32_t>& buckets, int beam); |
| 97 | + |
| 98 | + private: |
| 99 | + std::pair<long, int32_t> mBeamEnergyPerZ; // beam energy per charge |
| 100 | + std::pair<long, int32_t> mFillNumber; |
| 101 | + std::pair<long, std::string> mInjectionScheme; |
| 102 | + std::pair<long, int32_t> mAtomicNumberB1; // clockwise |
| 103 | + std::pair<long, int32_t> mAtomicNumberB2; // anticlockwise |
| 104 | + std::pair<long, o2::units::AngleRad_t> mCrossingAngle; |
| 105 | + int mBeamAZ[beamDirection::NBeamDirections] = {0, 0}; ///< A<<16+Z for each beam |
| 106 | + std::pair<long, o2::BunchFilling> mBunchFilling; ///To hold bunch filling information |
| 107 | + |
| 108 | + ClassDefNV(GRPLHCIFData, 1); |
| 109 | +}; |
| 110 | + |
| 111 | +//______________________________________________ |
| 112 | +inline float GRPLHCIFData::getBeamZoverA(beamDirection b) const |
| 113 | +{ |
| 114 | + // Z/A of beam 0 or 1 |
| 115 | + int a = getBeamA(b); |
| 116 | + return a ? getBeamZ(b) / static_cast<float>(a) : 0.f; |
| 117 | +} |
| 118 | + |
| 119 | +} // namespace parameters |
| 120 | +} // namespace o2 |
| 121 | +#endif |
0 commit comments