diff --git a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/NameConf.h b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/NameConf.h index ad998115ea3a5..ff693897021de 100644 --- a/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/NameConf.h +++ b/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/NameConf.h @@ -49,6 +49,12 @@ class NameConf : public o2::conf::ConfigurableParamHelper // Filename of general run parameters (GRP) static std::string getGRPFileName(const std::string_view prefix = STANDARDSIMPREFIX); + // Filename of general run parameters from ECS (GRPECS) + static std::string getGRPECSFileName(const std::string_view prefix = STANDARDSIMPREFIX); + + // Filename of general run parameters fof B field (GRPMagField) + static std::string getGRPMagFieldFileName(const std::string_view prefix = STANDARDSIMPREFIX); + // Filename to store kinematics + TrackRefs static std::string getMCKinematicsFileName(const std::string_view prefix = STANDARDSIMPREFIX) { @@ -119,6 +125,8 @@ class NameConf : public o2::conf::ConfigurableParamHelper static constexpr std::string_view HITS_STRING = "Hits"; // hardcoded static constexpr std::string_view DIGITS_STRING = "Digits"; // hardcoded static constexpr std::string_view GRP_STRING = "grp"; // hardcoded + static constexpr std::string_view GRPECS_STRING = "grpecs"; // hardcoded + static constexpr std::string_view GRPMAGFIELD_STRING = "grpMagField"; // hardcoded static constexpr std::string_view KINE_STRING = "Kine"; // hardcoded static constexpr std::string_view MCHEADER_STRING = "MCHeader"; // hardcoded static constexpr std::string_view GEOM_FILE_STRING = "geometry"; @@ -134,6 +142,8 @@ class NameConf : public o2::conf::ConfigurableParamHelper // these are configurable paths for some commonly used files std::string mDirGRP = "none"; // directory for GRP file ("none" == "") + std::string mDirGRPECS = "none"; // directory for GRPECS file ("none" == "") + std::string mDirGRPMagField = "none"; // directory for GRPMagField file ("none" == "") std::string mDirGeom = "none"; // directory for geometry file std::string mDirMatLUT = "none"; // directory for material LUT std::string mDirCollContext = "none"; // directory for collision context diff --git a/DataFormats/Detectors/Common/src/NameConf.cxx b/DataFormats/Detectors/Common/src/NameConf.cxx index 6fc949b742cce..e2eeea64d007f 100644 --- a/DataFormats/Detectors/Common/src/NameConf.cxx +++ b/DataFormats/Detectors/Common/src/NameConf.cxx @@ -55,6 +55,18 @@ std::string NameConf::getGRPFileName(const std::string_view prefix) return buildFileName(prefix, "_", STANDARDSIMPREFIX, GRP_STRING, ROOT_EXT_STRING, Instance().mDirGRP); } +// Filename to store general run parameters from ECS (GRPECS) +std::string NameConf::getGRPECSFileName(const std::string_view prefix) +{ + return buildFileName(prefix, "_", STANDARDSIMPREFIX, GRPECS_STRING, ROOT_EXT_STRING, Instance().mDirGRPECS); +} + +// Filename to store general run parameters from ECS (GRPECS) +std::string NameConf::getGRPMagFieldFileName(const std::string_view prefix) +{ + return buildFileName(prefix, "_", STANDARDSIMPREFIX, GRPMAGFIELD_STRING, ROOT_EXT_STRING, Instance().mDirGRPMagField); +} + // Filename to store simulation cuts/process summary std::string NameConf::getCutProcFileName(std::string_view prefix) { diff --git a/DataFormats/Parameters/CMakeLists.txt b/DataFormats/Parameters/CMakeLists.txt index 49bf5f6099fdc..562d2209c3441 100644 --- a/DataFormats/Parameters/CMakeLists.txt +++ b/DataFormats/Parameters/CMakeLists.txt @@ -11,14 +11,18 @@ o2_add_library(DataFormatsParameters SOURCES src/GRPObject.cxx - src/LHCIFData.cxx + src/GRPLHCIFData.cxx + src/GRPECSObject.cxx + src/GRPMagField.cxx PUBLIC_LINK_LIBRARIES FairRoot::Base O2::CommonConstants O2::CommonTypes O2::DetectorsCommonDataFormats) o2_target_root_dictionary(DataFormatsParameters HEADERS include/DataFormatsParameters/GRPObject.h - include/DataFormatsParameters/LHCIFData.h + include/DataFormatsParameters/GRPLHCIFData.h + include/DataFormatsParameters/GRPECSObject.h + include/DataFormatsParameters/GRPMagField.h LINKDEF src/ParametersDataLinkDef.h) diff --git a/DataFormats/Parameters/include/DataFormatsParameters/GRPECSObject.h b/DataFormats/Parameters/include/DataFormatsParameters/GRPECSObject.h new file mode 100644 index 0000000000000..77bb1c52cd897 --- /dev/null +++ b/DataFormats/Parameters/include/DataFormatsParameters/GRPECSObject.h @@ -0,0 +1,125 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file GRPECSObject.h +/// \brief Header of the General Run Parameters object +/// \author ruben.shahoyan@cern.ch + +#ifndef ALICEO2_DATA_GRPECSOBJECT_H_ +#define ALICEO2_DATA_GRPECSOBJECT_H_ + +#include +#include +#include +#include "DetectorsCommonDataFormats/DetID.h" + +namespace o2 +{ +namespace parameters +{ +/* + * Collects parameters describing the run that come from ECS only. + */ + +class GRPECSObject +{ + using DetID = o2::detectors::DetID; + + public: + using timePoint = std::time_t; + + enum ROMode : int { ABSENT = 0, + PRESENT = 0x1, + CONTINUOUS = PRESENT + (0x1 << 1), + TRIGGERING = PRESENT + (0x1 << 2) }; + + GRPECSObject() = default; + ~GRPECSObject() = default; + + /// getters/setters for Start and Stop times according to logbook + timePoint getTimeStart() const { return mTimeStart; } + void setTimeStart(timePoint t) { mTimeStart = t; } + + void setNHBFPerTF(uint32_t n) { mNHBFPerTF = n; } + uint32_t getNHBFPerTF() const { return mNHBFPerTF; } + + /// getter/setter for data taking period name + const std::string& getDataPeriod() const { return mDataPeriod; } + void setDataPeriod(const std::string v) { mDataPeriod = v; } + // getter/setter for run identifier + void setRun(int r) { mRun = r; } + int getRun() const { return mRun; } + /// getter/setter for masks of detectors in the readout + DetID::mask_t getDetsReadOut() const { return mDetsReadout; } + void setDetsReadOut(DetID::mask_t mask) { mDetsReadout = mask; } + /// getter/setter for masks of detectors with continuos readout + DetID::mask_t getDetsContinuousReadOut() const { return mDetsContinuousRO; } + void setDetsContinuousReadOut(DetID::mask_t mask) { mDetsContinuousRO = mask; } + /// getter/setter for masks of detectors providing the trigger + DetID::mask_t getDetsTrigger() const { return mDetsTrigger; } + void setDetsTrigger(DetID::mask_t mask) { mDetsTrigger = mask; } + /// add specific detector to the list of readout detectors + void addDetReadOut(DetID id) { mDetsReadout |= id.getMask(); } + /// remove specific detector from the list of readout detectors + void remDetReadOut(DetID id) + { + mDetsReadout &= ~id.getMask(); + remDetContinuousReadOut(id); + remDetTrigger(id); + } + /// add specific detector to the list of continuously readout detectors + void addDetContinuousReadOut(DetID id) { mDetsContinuousRO |= id.getMask(); } + /// remove specific detector from the list of continuouslt readout detectors + void remDetContinuousReadOut(DetID id) { mDetsContinuousRO &= ~id.getMask(); } + /// add specific detector to the list of triggering detectors + void addDetTrigger(DetID id) { mDetsTrigger |= id.getMask(); } + /// remove specific detector from the list of triggering detectors + void remDetTrigger(DetID id) { mDetsTrigger &= ~id.getMask(); } + /// test if detector is read out + bool isDetReadOut(DetID id) const { return (mDetsReadout & id.getMask()) != 0; } + /// test if detector is read out + bool isDetContinuousReadOut(DetID id) const { return (mDetsContinuousRO & id.getMask()) != 0; } + /// test if detector is triggering + bool isDetTriggers(DetID id) const { return (mDetsTrigger & id.getMask()) != 0; } + /// set detector readout mode status + void setDetROMode(DetID id, ROMode status); + ROMode getDetROMode(DetID id) const; + + /// extra selections + /// mask of readout detectors with addition selections. "only" overrides "skip" + DetID::mask_t getDetsReadOut(DetID::mask_t only, DetID::mask_t skip = 0) const { return only.any() ? (mDetsReadout & only) : (mDetsReadout ^ skip); } + /// same with comma-separate list of detector names + DetID::mask_t getDetsReadOut(const std::string& only, const std::string& skip = "") const { return getDetsReadOut(DetID::getMask(only), DetID::getMask(skip)); } + + /// print itself + void print() const; + + static GRPECSObject* loadFrom(const std::string& grpecsFileName = "", const std::string& grpecsName = "GRPECS"); + + private: + timePoint mTimeStart = 0; ///< DAQ_time_start entry from DAQ logbook + + uint32_t mNHBFPerTF = 128; /// Number of HBFrames per TF + + DetID::mask_t mDetsReadout; ///< mask of detectors which are read out + DetID::mask_t mDetsContinuousRO; ///< mask of detectors read out in continuos mode + DetID::mask_t mDetsTrigger; ///< mask of detectors which provide trigger + + int mRun = 0; ///< run identifier + std::string mDataPeriod = ""; ///< name of the period + + ClassDefNV(GRPECSObject, 1); +}; + +} // namespace parameters +} // namespace o2 + +#endif diff --git a/DataFormats/Parameters/include/DataFormatsParameters/GRPLHCIFData.h b/DataFormats/Parameters/include/DataFormatsParameters/GRPLHCIFData.h new file mode 100644 index 0000000000000..10a8d440b5b77 --- /dev/null +++ b/DataFormats/Parameters/include/DataFormatsParameters/GRPLHCIFData.h @@ -0,0 +1,121 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file GRPLHCIFData.h +/// \brief container for the LHC InterFace data + +#ifndef O2_GRP_LHCIFDATA_H +#define O2_GRP_LHCIFDATA_H + +#include +#include +#include +#include +#include "CommonTypes/Units.h" +#include "CommonConstants/LHCConstants.h" +#include "CommonDataFormat/BunchFilling.h" + +namespace o2 +{ +namespace parameters +{ + +class GRPLHCIFData +{ + + using beamDirection = o2::constants::lhc::BeamDirection; + + public: + GRPLHCIFData() = default; + ~GRPLHCIFData() = default; + + static const std::unordered_map mZtoA; + + std::pair getBeamEnergyPerZWithTime() const { return mBeamEnergyPerZ; } + int32_t getBeamEnergyPerZ() const { return mBeamEnergyPerZ.second; } + long getBeamEnergyPerZTime() const { return mBeamEnergyPerZ.first; } + void setBeamEnergyPerZWithTime(std::pair p) { mBeamEnergyPerZ = p; } + void setBeamEnergyPerZWithTime(long t, int32_t v) { mBeamEnergyPerZ = std::make_pair(t, v); } + + std::pair getFillNumberWithTime() const { return mFillNumber; } + int32_t getFillNumber() const { return mFillNumber.second; } + long getFillNumberTime() const { return mFillNumber.first; } + void setFillNumberWithTime(std::pair p) { mFillNumber = p; } + void setFillNumberWithTime(long t, int32_t v) { mFillNumber = std::make_pair(t, v); } + + std::pair getInjectionSchemeWithTime() const { return mInjectionScheme; } + std::string getInjectionScheme() const { return mInjectionScheme.second; } + long getInjectionSchemeTime() const { return mInjectionScheme.first; } + void setInjectionSchemeWithTime(std::pair p) { mInjectionScheme = p; } + void setInjectionSchemeWithTime(long t, std::string v) { mInjectionScheme = std::make_pair(t, v); } + + std::pair getAtomicNumberB1WithTime() const { return mAtomicNumberB1; } + int32_t getAtomicNumberB1() const { return mAtomicNumberB1.second; } + long getAtomicNumberB1Time() const { return mAtomicNumberB1.first; } + void setAtomicNumberB1WithTime(std::pair p) { mAtomicNumberB1 = p; } + void setAtomicNumberB1WithTime(long t, int32_t v) { mAtomicNumberB1 = std::make_pair(t, v); } + + std::pair getAtomicNumberB2WithTime() const { return mAtomicNumberB2; } + int32_t getAtomicNumberB2() const { return mAtomicNumberB2.second; } + long getAtomicNumberB2Time() const { return mAtomicNumberB2.first; } + void setAtomicNumberB2WithTime(std::pair p) { mAtomicNumberB2 = p; } + void setAtomicNumberB2WithTime(long t, int32_t v) { mAtomicNumberB2 = std::make_pair(t, v); } + + std::pair getCrossingAngleWithTime() const { return mCrossingAngle; } + o2::units::AngleRad_t getCrossingAngle() const { return mCrossingAngle.second; } + long getCrossingAngleTime() const { return mCrossingAngle.first; } + void setCrossingAngleWithTime(std::pair p) { mCrossingAngle = p; } + void setCrossingAngleWithTime(long t, o2::units::AngleRad_t v) { mCrossingAngle = std::make_pair(t, v); } + + std::pair getBunchFillingWithTime() const { return mBunchFilling; } + o2::BunchFilling getBunchFilling() const { return mBunchFilling.second; } + long getBunchFillingTime() const { return mBunchFilling.first; } + void setBunchFillingWithTime(std::pair p) { mBunchFilling = p; } + void setBunchFillingWithTime(long t, o2::BunchFilling v) { mBunchFilling = std::make_pair(t, v); } + + /// getters/setters for given beam A and Z info, encoded as A<<16+Z + int getBeamZ(beamDirection beam) const { return mBeamAZ[static_cast(beam)] & 0xffff; } + int getBeamA(beamDirection beam) const { return mBeamAZ[static_cast(beam)] >> 16; } + float getBeamZoverA(beamDirection beam) const; + void setBeamAZ(int a, int z, beamDirection beam) { mBeamAZ[static_cast(beam)] = (a << 16) + z; } + void setBeamAZ(beamDirection beam); + void setBeamAZ(); + /// getters/setters for beam energy per charge and per nucleon + float getBeamEnergyPerNucleon(beamDirection beam) const { return mBeamEnergyPerZ.second * getBeamZoverA(beam); } + /// calculate center of mass energy per nucleon collision + float getSqrtS() const; + /// helper function for BunchFilling + void translateBucketsToBCNumbers(std::vector& bcNb, std::vector& buckets, int beam); + + private: + std::pair mBeamEnergyPerZ; // beam energy per charge + std::pair mFillNumber; + std::pair mInjectionScheme; + std::pair mAtomicNumberB1; // clockwise + std::pair mAtomicNumberB2; // anticlockwise + std::pair mCrossingAngle; + int mBeamAZ[beamDirection::NBeamDirections] = {0, 0}; ///< A<<16+Z for each beam + std::pair mBunchFilling; ///To hold bunch filling information + + ClassDefNV(GRPLHCIFData, 1); +}; + +//______________________________________________ +inline float GRPLHCIFData::getBeamZoverA(beamDirection b) const +{ + // Z/A of beam 0 or 1 + int a = getBeamA(b); + return a ? getBeamZ(b) / static_cast(a) : 0.f; +} + +} // namespace parameters +} // namespace o2 +#endif diff --git a/DataFormats/Parameters/include/DataFormatsParameters/GRPMagField.h b/DataFormats/Parameters/include/DataFormatsParameters/GRPMagField.h new file mode 100644 index 0000000000000..8f4f1185c9b5d --- /dev/null +++ b/DataFormats/Parameters/include/DataFormatsParameters/GRPMagField.h @@ -0,0 +1,61 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file GRPMagField.h +/// \brief Header of the General Run Parameters object for B field values +/// \author ruben.shahoyan@cern.ch + +#ifndef ALICEO2_DATA_GRPMAGFIELDOBJECT_H_ +#define ALICEO2_DATA_GRPMAGFIELDOBJECT_H_ + +#include +#include +#include "CommonTypes/Units.h" + +namespace o2 +{ +namespace parameters +{ +/* + * Collects parameters describing the run that are related to the B field only. +*/ + +class GRPMagField +{ + public: + GRPMagField() = default; + ~GRPMagField() = default; + + /// getters/setters for magnets currents + o2::units::Current_t getL3Current() const { return mL3Current; } + o2::units::Current_t getDipoleCurrent() const { return mDipoleCurrent; } + bool getFieldUniformity() const { return mUniformField; } + void setL3Current(o2::units::Current_t v) { mL3Current = v; } + void setDipoleCurrent(o2::units::Current_t v) { mDipoleCurrent = v; } + void setFieldUniformity(bool v) { mUniformField = v; } + + /// print itself + void print() const { printf("magnet currents (A) L3 = %.3f, Dipole = %.f; uniformity = %s\n", getL3Current(), getDipoleCurrent(), mUniformField ? "true" : "false"); } + + static GRPMagField* loadFrom(const std::string& grpMagFieldFileName = "", const std::string& grpMagFieldName = "GRPMAGFIELD"); + + private: + o2::units::Current_t mL3Current = 0.f; ///< signed current in L3 + o2::units::Current_t mDipoleCurrent = 0.f; ///< signed current in Dipole + bool mUniformField = false; ///< uniformity of magnetic field + + ClassDefNV(GRPMagField, 1); +}; + +} // namespace parameters +} // namespace o2 + +#endif diff --git a/DataFormats/Parameters/include/DataFormatsParameters/LHCIFData.h b/DataFormats/Parameters/include/DataFormatsParameters/LHCIFData.h deleted file mode 100644 index 0db3953454425..0000000000000 --- a/DataFormats/Parameters/include/DataFormatsParameters/LHCIFData.h +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -/// \file LHCIFData.h -/// \brief container for the LHC InterFace data - -#ifndef O2_GRP_LHCIFDATA_H -#define O2_GRP_LHCIFDATA_H - -#include -#include -#include - -namespace o2 -{ -namespace parameters -{ - -class LHCIFData -{ - public: - LHCIFData() = default; - ~LHCIFData() = default; - - std::pair getBeamEnergy() const { return mBeamEnergy; } - std::pair getFillNumber() const { return mFillNumber; } - std::pair getInjectionScheme() const { return mInjectionScheme; } - std::pair getAtomicNumberB1() const { return mAtomicNumberB1; } - std::pair getAtomicNumberB2() const { return mAtomicNumberB2; } - - int32_t getBeamEnergyVal() const { return mBeamEnergy.second; } - int32_t getFillNumberVal() const { return mFillNumber.second; } - std::string getInjectionSchemeVal() const { return mInjectionScheme.second; } - int32_t getAtomicNumberB1Val() const { return mAtomicNumberB1.second; } - int32_t getAtomicNumberB2Val() const { return mAtomicNumberB2.second; } - - long getBeamEnergyTime() const { return mBeamEnergy.first; } - long getFillNumberTime() const { return mFillNumber.first; } - long getInjectionSchemeTime() const { return mInjectionScheme.first; } - long getAtomicNumberB1Time() const { return mAtomicNumberB1.first; } - long getAtomicNumberB2Time() const { return mAtomicNumberB2.first; } - - void setBeamEnergy(std::pair p) { mBeamEnergy = p; } - void setFillNumber(std::pair p) { mFillNumber = p; } - void setInjectionScheme(std::pair p) { mInjectionScheme = p; } - void setAtomicNumberB1(std::pair p) { mAtomicNumberB1 = p; } - void setAtomicNumberB2(std::pair p) { mAtomicNumberB2 = p; } - - void setBeamEnergy(long t, int32_t v) { mBeamEnergy = std::make_pair(t, v); } - void setFillNumber(long t, int32_t v) { mFillNumber = std::make_pair(t, v); } - void setInjectionScheme(long t, std::string v) { mInjectionScheme = std::make_pair(t, v); } - void setAtomicNumberB1(long t, int32_t v) { mAtomicNumberB1 = std::make_pair(t, v); } - void setAtomicNumberB2(long t, int32_t v) { mAtomicNumberB2 = std::make_pair(t, v); } - - private: - std::pair mBeamEnergy; - std::pair mFillNumber; - std::pair mInjectionScheme; - std::pair mAtomicNumberB1; - std::pair mAtomicNumberB2; - - ClassDefNV(LHCIFData, 1); -}; -} // namespace parameters -} // namespace o2 -#endif diff --git a/DataFormats/Parameters/src/GRPECSObject.cxx b/DataFormats/Parameters/src/GRPECSObject.cxx new file mode 100644 index 0000000000000..0121d94b5fe94 --- /dev/null +++ b/DataFormats/Parameters/src/GRPECSObject.cxx @@ -0,0 +1,98 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file GRPECSObject.cxx +/// \brief Implementation of General Run Parameters object from ECS +/// \author ruben.shahoyan@cern.ch + +#include +#include +#include "DataFormatsParameters/GRPECSObject.h" +#include +#include "DetectorsCommonDataFormats/NameConf.h" + +using namespace o2::parameters; +using o2::detectors::DetID; + +//_______________________________________________ +void GRPECSObject::print() const +{ + // print itself + std::time_t t = mTimeStart; // system_clock::to_time_t(mTimeStart); + printf("Start: %s", std::ctime(&t)); + printf("Detectors: Cont.RO Triggers\n"); + for (auto i = DetID::First; i <= DetID::Last; i++) { + if (!isDetReadOut(DetID(i))) { + continue; + } + printf("%9s: ", DetID(i).getName()); + printf("%7s ", isDetContinuousReadOut(DetID(i)) ? " + " : " - "); + printf("%7s ", isDetTriggers(DetID(i)) ? " + " : " - "); + printf("\n"); + } +} + +//_______________________________________________ +void GRPECSObject::setDetROMode(o2::detectors::DetID id, ROMode status) +{ + /// set detector readout mode status + if (!(status & PRESENT)) { + remDetReadOut(id); + return; + } + addDetReadOut(id); + if ((status & CONTINUOUS) == CONTINUOUS) { + addDetContinuousReadOut(id); + } else { + remDetContinuousReadOut(id); + } + if ((status & TRIGGERING) == TRIGGERING) { + addDetTrigger(id); + } else { + remDetTrigger(id); + } +} + +//_______________________________________________ +GRPECSObject::ROMode GRPECSObject::getDetROMode(o2::detectors::DetID id) const +{ + GRPECSObject::ROMode status = ABSENT; + if (isDetReadOut(id)) { + status = PRESENT; + } else { + if (isDetContinuousReadOut(id)) { + status = GRPECSObject::ROMode(status | CONTINUOUS); + } + if (isDetTriggers(id)) { + status = GRPECSObject::ROMode(status | TRIGGERING); + } + } + return status; +} + +//_______________________________________________ +GRPECSObject* GRPECSObject::loadFrom(const std::string& grpecsFileName, const std::string& grpecsName) +{ + // load object from file + auto fname = o2::base::NameConf::getGRPECSFileName(grpecsFileName); + TFile flGRPECS(fname.c_str()); + if (flGRPECS.IsZombie()) { + LOG(ERROR) << "Failed to open " << fname; + throw std::runtime_error("Failed to open GRP ECS file"); + } + auto grpecs = reinterpret_cast( + flGRPECS.GetObjectChecked(grpecsName.data(), o2::parameters::GRPECSObject::Class())); + if (!grpecs) { + LOG(ERROR) << "Did not find GRP ECS object named " << grpecsName; + throw std::runtime_error("Failed to load GRP ECS object"); + } + return grpecs; +} diff --git a/DataFormats/Parameters/src/GRPLHCIFData.cxx b/DataFormats/Parameters/src/GRPLHCIFData.cxx new file mode 100644 index 0000000000000..235f33884798e --- /dev/null +++ b/DataFormats/Parameters/src/GRPLHCIFData.cxx @@ -0,0 +1,84 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file GRPLHCIFData.cxx +/// \brief Implementation of the LHC InterFace data + +#include "DataFormatsParameters/GRPLHCIFData.h" +#include "CommonConstants/PhysicsConstants.h" +#include +#include + +using namespace o2::parameters; +using namespace o2::constants::physics; +using namespace o2::constants::lhc; + +const std::unordered_map GRPLHCIFData::mZtoA = + { + {1, 1}, + {82, 208}}; + +//_______________________________________________ +void GRPLHCIFData::setBeamAZ(beamDirection beam) +{ + // set both A and Z of the beam in direction 'beam' + if (beam == beamDirection::BeamClockWise) { + auto atomicNum = mZtoA.find(getAtomicNumberB1()); + if (atomicNum == mZtoA.end()) { + LOG(FATAL) << "We don't know the Mass Number for Z = " << getAtomicNumberB1(); + } else { + mBeamAZ[static_cast(beam)] = (atomicNum->second << 16) + getAtomicNumberB1(); + } + } else { + auto atomicNum = mZtoA.find(getAtomicNumberB2()); + if (atomicNum == mZtoA.end()) { + LOG(FATAL) << "We don't know the Mass Number for Z = " << getAtomicNumberB2(); + } else { + mBeamAZ[static_cast(beam)] = (atomicNum->second << 16) + getAtomicNumberB2(); + } + } +} + +//_______________________________________________ +void GRPLHCIFData::setBeamAZ() +{ + + // setting A and Z for both beams + setBeamAZ(BeamClockWise); + setBeamAZ(BeamAntiClockWise); +} + +//_______________________________________________ +float GRPLHCIFData::getSqrtS() const +{ + // get center of mass energy + double e0 = getBeamEnergyPerNucleon(BeamClockWise); + double e1 = getBeamEnergyPerNucleon(BeamAntiClockWise); + if (e0 <= MassProton || e1 <= MassProton) { + return 0.f; + } + double beta0 = 1. - MassProton * MassProton / (e0 * e0); + double beta1 = 1. - MassProton * MassProton / (e1 * e1); + beta0 = beta0 > 0 ? sqrt(beta0) : 0.; + beta1 = beta1 > 0 ? sqrt(beta1) : 0.; + double ss = 2. * (MassProton * MassProton + e0 * e1 * (1. + beta0 * beta1 * cos(getCrossingAngle()))); + return ss > 0. ? sqrt(ss) : 0.; +} + +//_________________________________________________________________ + +void GRPLHCIFData::translateBucketsToBCNumbers(std::vector& bcNb, std::vector& buckets, int beam) +{ + // to translate the vector of bucket numbers to BC numbers + for (auto i : buckets) { + bcNb.push_back(i = 0 ? 0 : (i / 10 + o2::constants::lhc::BunchOffsetsP2[beam]) % o2::constants::lhc::LHCMaxBunches); + } +} diff --git a/DataFormats/Parameters/src/GRPMagField.cxx b/DataFormats/Parameters/src/GRPMagField.cxx new file mode 100644 index 0000000000000..1413e4c91c6dd --- /dev/null +++ b/DataFormats/Parameters/src/GRPMagField.cxx @@ -0,0 +1,39 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file GRPMagField.cxx +/// \brief Implementation of General Run Parameters object for MagField +/// \author ruben.shahoyan@cern.ch + +#include +#include "DataFormatsParameters/GRPMagField.h" +#include "DetectorsCommonDataFormats/NameConf.h" + +using namespace o2::parameters; + +//_______________________________________________ +GRPMagField* GRPMagField::loadFrom(const std::string& grpMagFieldFileName, const std::string& grpMagFieldName) +{ + // load object from file + auto fname = o2::base::NameConf::getGRPMagFieldFileName(grpMagFieldFileName); + TFile flGRPMagField(fname.c_str()); + if (flGRPMagField.IsZombie()) { + LOG(ERROR) << "Failed to open " << fname; + throw std::runtime_error("Failed to open GRP Mag Field file"); + } + auto grpMagField = reinterpret_cast( + flGRPMagField.GetObjectChecked(grpMagFieldName.data(), o2::parameters::GRPMagField::Class())); + if (!grpMagField) { + LOG(ERROR) << "Did not find GRP Mag Field object named " << grpMagFieldName; + throw std::runtime_error("Failed to load GRP Mag Field object"); + } + return grpMagField; +} diff --git a/DataFormats/Parameters/src/LHCIFData.cxx b/DataFormats/Parameters/src/LHCIFData.cxx deleted file mode 100644 index 4ae9d0f9d98a8..0000000000000 --- a/DataFormats/Parameters/src/LHCIFData.cxx +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// In applying this license CERN does not waive the privileges and immunities -// granted to it by virtue of its status as an Intergovernmental Organization -// or submit itself to any jurisdiction. - -/// \file LHCIFData.cxx -/// \brief Implementation of the LHC InterFace data - -#include "DataFormatsParameters/LHCIFData.h" diff --git a/DataFormats/Parameters/src/ParametersDataLinkDef.h b/DataFormats/Parameters/src/ParametersDataLinkDef.h index da7124658164a..741cd6cd47787 100644 --- a/DataFormats/Parameters/src/ParametersDataLinkDef.h +++ b/DataFormats/Parameters/src/ParametersDataLinkDef.h @@ -24,7 +24,10 @@ #pragma link off all functions; #pragma link C++ class o2::parameters::GRPObject + ; -#pragma link C++ class o2::parameters::LHCIFData + ; +#pragma link C++ class o2::parameters::GRPLHCIFData + ; #pragma link C++ class std::pair < long, std::string> + ; +#pragma link C++ class o2::parameters::GRPECSObject + ; +#pragma link C++ class o2::parameters::GRPMagField + ; +#pragma link C++ class std::unordered_map < unsigned int, unsigned int> + ; #endif diff --git a/Detectors/Calibration/src/MeanVertexCalibrator.cxx b/Detectors/Calibration/src/MeanVertexCalibrator.cxx index 4b169a6c761a9..0d9ddbbf76cce 100644 --- a/Detectors/Calibration/src/MeanVertexCalibrator.cxx +++ b/Detectors/Calibration/src/MeanVertexCalibrator.cxx @@ -146,7 +146,7 @@ void MeanVertexCalibrator::finalizeSlot(Slot& slot) std::map md; auto clName = o2::utils::MemFileHelper::getClassName(mSMAMVobj); auto flName = o2::ccdb::CcdbApi::generateFileName(clName); - mInfoVector.emplace_back("GRP/MeanVertex", clName, flName, md, startValidity, 99999999999999); + mInfoVector.emplace_back("GLO/Calib/MeanVertex", clName, flName, md, startValidity, 99999999999999); mMeanVertexVector.emplace_back(mSMAMVobj); slot.print(); diff --git a/Detectors/GRP/calibration/include/GRPCalibration/LHCIFfileReader.h b/Detectors/GRP/calibration/include/GRPCalibration/LHCIFfileReader.h index 35bb16ea9db07..3951ecbd11d07 100644 --- a/Detectors/GRP/calibration/include/GRPCalibration/LHCIFfileReader.h +++ b/Detectors/GRP/calibration/include/GRPCalibration/LHCIFfileReader.h @@ -16,6 +16,7 @@ #include #include "Framework/Logger.h" #include "CommonUtils/StringUtils.h" +#include "CommonConstants/LHCConstants.h" /// @brief Class to read the LHC InterFace file coming from the DCS filepush service @@ -83,7 +84,7 @@ void LHCIFfileReader::readValue(const std::string& alias, std::string& type, int if constexpr (std::is_same::value) { if (type == "i" || type == "b") { for (int iele = 0; iele < nele; ++iele) { - LOG(INFO) << alias << ": value int/bool = " << tokensStr[shift + iele]; + LOG(DEBUG) << alias << ": value int/bool = " << tokensStr[shift + iele]; vect.emplace_back(std::stoi(tokensStr[shift + iele])); } } else { @@ -92,7 +93,7 @@ void LHCIFfileReader::readValue(const std::string& alias, std::string& type, int } else if constexpr (std::is_same::value) { if (type == "f") { for (int iele = 0; iele < nele; ++iele) { - LOG(INFO) << alias << ": value float = " << tokensStr[shift + iele]; + LOG(DEBUG) << alias << ": value float = " << tokensStr[shift + iele]; vect.emplace_back(std::stof(tokensStr[shift + iele])); } } else { @@ -103,7 +104,7 @@ void LHCIFfileReader::readValue(const std::string& alias, std::string& type, int else if constexpr (std::is_same::value) { if (type == "s") { for (int iele = 0; iele < nele; ++iele) { - LOG(INFO) << alias << ": value string = " << tokensStr[shift + iele]; + LOG(DEBUG) << alias << ": value string = " << tokensStr[shift + iele]; vect.emplace_back(tokensStr[shift + iele]); } } else { diff --git a/Detectors/GRP/workflows/include/GRPWorkflows/GRPLHCIFfileSpec.h b/Detectors/GRP/workflows/include/GRPWorkflows/GRPLHCIFfileSpec.h index 77a1fd5a2d3d8..8eff98c0a579d 100644 --- a/Detectors/GRP/workflows/include/GRPWorkflows/GRPLHCIFfileSpec.h +++ b/Detectors/GRP/workflows/include/GRPWorkflows/GRPLHCIFfileSpec.h @@ -17,7 +17,7 @@ #include "GRPCalibration/LHCIFfileReader.h" #include "Framework/DataProcessorSpec.h" #include "Framework/Task.h" -#include "DataFormatsParameters/LHCIFData.h" +#include "DataFormatsParameters/GRPLHCIFData.h" using namespace o2::framework; @@ -33,7 +33,7 @@ class GRPLHCIFfileProcessor : public Task void endOfStream(o2::framework::EndOfStreamContext& ec) final; private: - void sendOutput(DataAllocator& output, long tf, const o2::parameters::LHCIFData& lhcifdata); + void sendOutput(DataAllocator& output, long tf, const o2::parameters::GRPLHCIFData& lhcifdata); LHCIFfileReader mReader; bool mVerbose = false; // to enable verbose mode diff --git a/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx b/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx index 3719cdcd464ee..5a87f96bf0012 100644 --- a/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx +++ b/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx @@ -19,6 +19,7 @@ #include "CCDB/CcdbObjectInfo.h" #include "CommonUtils/MemFileHelper.h" #include "DetectorsCalibration/Utils.h" +#include "CommonTypes/Units.h" #include #include @@ -27,7 +28,7 @@ using namespace o2::framework; using TFType = uint64_t; using HighResClock = std::chrono::high_resolution_clock; using Duration = std::chrono::duration>; -using LHCIFData = o2::parameters::LHCIFData; +using GRPLHCIFData = o2::parameters::GRPLHCIFData; namespace o2 { @@ -54,58 +55,116 @@ void GRPLHCIFfileProcessor::run(o2::framework::ProcessingContext& pc) std::vector>> fillNb; std::vector>> atomicNbB1; std::vector>> atomicNbB2; + std::vector>> crossAngle; + std::vector>> bunchConfigB1; + std::vector>> bunchConfigB2; - int nEleBeamEn, nEleInjSch, nEleFillNb, nEleAtNbB1, nEleAtNbB2 = 0; - int nMeasBeamEn, nMeasInjSch, nMeasFillNb, nMeasAtNbB1, nMeasAtNbB2 = 0; + int nEle = 0; + int nMeas = 0; std::string type{""}; - LHCIFData lhcifdata; + GRPLHCIFData lhcifdata; - mReader.readValue("BEAM_ENERGY", type, nEleBeamEn, nMeasBeamEn, beamEnergy); - if (nMeasBeamEn == 0) { + // Beam Energy + mReader.readValue("BEAM_ENERGY", type, nEle, nMeas, beamEnergy); + if (nMeas == 0) { LOG(FATAL) << "Beam energy not present"; } - if (nEleBeamEn != 1 || nMeasBeamEn != 1) { + if (nEle != 1 || nMeas != 1) { LOG(ERROR) << "More than one value/measurement found for Beam Energy, keeping the last one"; } LOG(INFO) << "beam energy size = " << beamEnergy.size(); - lhcifdata.setBeamEnergy(beamEnergy.back().first, beamEnergy.back().second.back()); + lhcifdata.setBeamEnergyPerZWithTime(beamEnergy.back().first, beamEnergy.back().second.back()); - mReader.readValue("INJECTION_SCHEME", type, nEleInjSch, nMeasInjSch, injScheme); - if (nMeasInjSch == 0) { + // Injection scheme + mReader.readValue("INJECTION_SCHEME", type, nEle, nMeas, injScheme); + if (nMeas == 0) { LOG(FATAL) << "Injection scheme not present"; } - if (nEleInjSch != 1 || nMeasInjSch != 1) { + if (nEle != 1 || nMeas != 1) { LOG(ERROR) << "More than one value/measurement found for Injection Scheme, keeping the last one"; } - lhcifdata.setInjectionScheme(injScheme.back().first, injScheme.back().second.back()); + lhcifdata.setInjectionSchemeWithTime(injScheme.back().first, injScheme.back().second.back()); - mReader.readValue("FILL_NUMBER", type, nEleFillNb, nMeasFillNb, fillNb); - if (nMeasFillNb == 0) { + // fill number + mReader.readValue("FILL_NUMBER", type, nEle, nMeas, fillNb); + if (nMeas == 0) { LOG(FATAL) << "Fill Number not present"; } - if (nEleFillNb != 1 || nMeasFillNb != 1) { + if (nEle != 1 || nMeas != 1) { LOG(ERROR) << "More than one value/measurement found for Fill Number, keeping the last one"; } - lhcifdata.setFillNumber(fillNb.back().first, atoi(fillNb.back().second.back().c_str())); + lhcifdata.setFillNumberWithTime(fillNb.back().first, atoi(fillNb.back().second.back().c_str())); - mReader.readValue("ATOMIC_NUMBER_B1", type, nEleAtNbB1, nMeasAtNbB1, atomicNbB1); - if (nMeasAtNbB1 == 0) { - LOG(FATAL) << "Atomic Number Beam 1 not present"; + // Atomic Number (Z) for B1 + mReader.readValue("ATOMIC_NUMBER_B1", type, nEle, nMeas, atomicNbB1); + if (nMeas == 0) { + LOG(FATAL) << "Atomic Number Beam 1 (clockwise) not present"; } - if (nEleAtNbB1 != 1 || nMeasAtNbB1 != 1) { - LOG(ERROR) << "More than one value/measurement found for Atomic Number Beam 1, keeping the last one"; + if (nEle != 1 || nMeas != 1) { + LOG(ERROR) << "More than one value/measurement found for Atomic Number Beam 1 (clockwise), keeping the last one"; } - lhcifdata.setAtomicNumberB1(atomicNbB1.back().first, atomicNbB1.back().second.back()); + lhcifdata.setAtomicNumberB1WithTime(atomicNbB1.back().first, atomicNbB1.back().second.back()); - mReader.readValue("ATOMIC_NUMBER_B2", type, nEleAtNbB2, nMeasAtNbB2, atomicNbB2); - if (nMeasAtNbB2 == 0) { - LOG(FATAL) << "Atomic Number Beam 2 not present"; + // Atomic Number (Z) for B2 + mReader.readValue("ATOMIC_NUMBER_B2", type, nEle, nMeas, atomicNbB2); + if (nMeas == 0) { + LOG(FATAL) << "Atomic Number Beam 2 (anticlockwise) not present"; } - if (nEleAtNbB2 != 1 || nMeasAtNbB2 != 1) { - LOG(ERROR) << "More than one value/measurement found for Atomic Number Beam 2, keeping the last one"; + if (nEle != 1 || nMeas != 1) { + LOG(ERROR) << "More than one value/measurement found for Atomic Number Beam 2 (anticlockwise), keeping the last one"; } - lhcifdata.setAtomicNumberB2(atomicNbB2.back().first, atomicNbB2.back().second.back()); + lhcifdata.setAtomicNumberB2WithTime(atomicNbB2.back().first, atomicNbB2.back().second.back()); + + // Crossing Angle + mReader.readValue("IP2_XING_V_MURAD", type, nEle, nMeas, crossAngle); + if (nMeas == 0) { + LOG(FATAL) << "Crossing Angle not present"; + } + if (nEle != 1 || nMeas != 1) { + LOG(ERROR) << "More than one value/measurement found for Crossing Angle, keeping the last one"; + } + lhcifdata.setCrossingAngleWithTime(crossAngle.back().first, crossAngle.back().second.back()); + + // Bunch Config for B1 + mReader.readValue("CIRCULATING_BUNCH_CONFIG_BEAM1", type, nEle, nMeas, bunchConfigB1); + if (nMeas == 0) { + LOG(FATAL) << "Bunch Config Beam 1 not present"; + } + if (nEle != 1 || nMeas != 1) { + LOG(ERROR) << "More than one value/measurement found for Bunch Config Beam 1, keeping the last one"; + } + + // Bunch Config for B2 + mReader.readValue("CIRCULATING_BUNCH_CONFIG_BEAM2", type, nEle, nMeas, bunchConfigB2); + if (nMeas == 0) { + LOG(FATAL) << "Bunch Config Beam 2 not present"; + } + if (nEle != 1 || nMeas != 1) { + LOG(ERROR) << "More than one value/measurement found for Bunch Config Beam 2, keeping the last one"; + } + if (nMeas != o2::constants::lhc::LHCMaxBunches) { + LOG(ERROR) << "We don't have the right number of bunches information for Beam 2"; + } + + // Building Bunch Filling + std::vector bcNumbersB1, bcNumbersB2; + lhcifdata.translateBucketsToBCNumbers(bcNumbersB1, bunchConfigB1.back().second, 1); + lhcifdata.translateBucketsToBCNumbers(bcNumbersB2, bunchConfigB2.back().second, 2); + o2::BunchFilling bunchFilling; + for (int i = 0; i < bcNumbersB1.size(); ++i) { + int bc = bcNumbersB1[i]; + int val = (bc == 0 ? 0 : 1); + bunchFilling.setBC(bc, val, 0); + } + for (int i = 0; i < bcNumbersB2.size(); ++i) { + int bc = bcNumbersB2[i]; + int val = (bc == 0 ? 0 : 1); + bunchFilling.setBC(bc, val, 1); + } + bunchFilling.setInteractingBCsFromBeams(); + + lhcifdata.setBunchFillingWithTime((bunchConfigB1.back().first + bunchConfigB2.back().first) / 2, bunchFilling); if (mVerbose) { LOG(INFO) << " **** Beam Energy ****"; @@ -126,18 +185,24 @@ void GRPLHCIFfileProcessor::run(o2::framework::ProcessingContext& pc) std::cout << el.first << " --> " << elVect << std::endl; } } - LOG(INFO) << " **** Atomic Number Beam 1 ****"; + LOG(INFO) << " **** Atomic Number Beam 1 (clockwise) ****"; for (auto& el : atomicNbB1) { for (auto elVect : el.second) { std::cout << el.first << " --> " << elVect << std::endl; } } - LOG(INFO) << " **** Atomic Number B2 ****"; + LOG(INFO) << " **** Atomic Number B2 (anticlockwise) ****"; for (auto& el : atomicNbB2) { for (auto elVect : el.second) { std::cout << el.first << " --> " << elVect << std::endl; } } + LOG(INFO) << " **** Crossing Angle ****"; + for (auto& el : crossAngle) { + for (auto elVect : el.second) { + std::cout << el.first << " --> " << elVect << std::endl; + } + } } sendOutput(pc.outputs(), timer, lhcifdata); @@ -151,7 +216,7 @@ void GRPLHCIFfileProcessor::endOfStream(o2::framework::EndOfStreamContext& ec) //__________________________________________________________________ -void GRPLHCIFfileProcessor::sendOutput(DataAllocator& output, long tf, const LHCIFData& lhcifdata) +void GRPLHCIFfileProcessor::sendOutput(DataAllocator& output, long tf, const GRPLHCIFData& lhcifdata) { // sending output to CCDB @@ -162,7 +227,7 @@ void GRPLHCIFfileProcessor::sendOutput(DataAllocator& output, long tf, const LHC auto flName = o2::ccdb::CcdbApi::generateFileName(clName); std::map md; md.emplace("created by", "dpl"); - o2::ccdb::CcdbObjectInfo info("GRP/Data/LHCIFData", clName, flName, md, tf, INFINITE_TF); + o2::ccdb::CcdbObjectInfo info("GLO/Config/GRPLHCIFData", clName, flName, md, tf, INFINITE_TF); auto image = o2::ccdb::CcdbApi::createObjectImage(&lhcifdata, &info); LOG(INFO) << "Sending object " << info.getPath() << "/" << info.getFileName() << " of size " << image->size() << " bytes, valid for " << info.getStartValidityTimestamp() << " : " << info.getEndValidityTimestamp(); diff --git a/macro/CMakeLists.txt b/macro/CMakeLists.txt index 0d79d90444623..e1ca8e5e0e8f7 100644 --- a/macro/CMakeLists.txt +++ b/macro/CMakeLists.txt @@ -53,8 +53,10 @@ install(FILES CheckDigits_mft.C run_trac_its.C CreateBCPattern.C UploadDummyAlignment.C - UploadMatBudLUT.C - CreateCTPOrbitResetObject.C + UploadMatBudLUT.C + CreateCTPOrbitResetObject.C + CreateGRPECSObject.C + CreateGRPMagFieldObject.C DESTINATION share/macro/) # FIXME: a lot of macros that are here should really be elsewhere. Those which @@ -346,12 +348,23 @@ o2_add_test_root_macro(run_trac_its.C O2::SimulationDataFormat LABELS its) +o2_add_test_root_macro(CreateGRPECSObject.C + PUBLIC_LINK_LIBRARIES O2::DataFormatsParameters + O2::DetectorsCommonDataFormats + O2::CCDB) + +o2_add_test_root_macro(CreateGRPMagFieldObject.C + PUBLIC_LINK_LIBRARIES O2::DataFormatsParameters + O2::CommonTypes + O2::CCDB) + o2_add_test_root_macro(UploadMatBudLUT.C PUBLIC_LINK_LIBRARIES O2::DetectorsCommonDataFormats O2::CCDB O2::DataFormatsParameters O2::DetectorsBase O2::CommonUtils) + # # NOTE: commented out until unit testing reenabled FIXME : re-enable or delete ? # diff --git a/macro/CreateGRPECSObject.C b/macro/CreateGRPECSObject.C new file mode 100644 index 0000000000000..4bce6d682e071 --- /dev/null +++ b/macro/CreateGRPECSObject.C @@ -0,0 +1,65 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#if !defined(__CLING__) || defined(__ROOTCLING__) + +#include +#include +#include "DataFormatsParameters/GRPECSObject.h" +#include "DetectorsCommonDataFormats/DetID.h" +#include "CCDB/CcdbApi.h" + +#endif + +using timePoint = std::time_t; +using DetID = o2::detectors::DetID; +using CcdbApi = o2::ccdb::CcdbApi; +using GRPECSObject = o2::parameters::GRPECSObject; + +// Simple macro to exemplify how to fill a GRPECS object (GRP object containing the information that come from ECS) + +// The list of detectors in the readout, read-out continuously, or in the trigger are passed as DetID::mask_it; this is a std::bitset<32>, with the following meaning per bit: +// {"ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FT0", "FV0", "FDD", "ACO", "CTP"} + +// e.g. +/* + .L CreateGRPECSObject.C+ + std::time_t tStart = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() + std::time_t tEnd = (tStart + 60 * 60 * 24 * 365) * 1000; // 1 year validity, just an example + o2::detectors::DetID::mask_t detsRO = o2::detectors::DetID::getMask("ITS, TPC, TRD, TOF, CPV, PHS, EMC, MID, MFT, MCH, FT0, FV0, FDD, CTP"); + o2::detectors::DetID::mask_t detsContRO = o2::detectors::DetID::getMask("TOF, TPC, ITS") + o2::detectors::DetID::mask_t detsTrig = o2::detectors::DetID::getMask("FV0") + CreateGRPECSObject(tStart, 128, detsRO, detsContRO, detsTrig, 123456, "LHC21m", tEnd) +*/ + +void CreateGRPECSObject(timePoint start, uint32_t nHBPerTF, DetID::mask_t detsReadout, DetID::mask_t detsContinuousRO, DetID::mask_t detsTrigger, int run, std::string dataPeriod, timePoint end = -1, std::string ccdbPath = "http://ccdb-test.cern.ch:8080") +{ + + GRPECSObject grpecs; + grpecs.setTimeStart(start); + grpecs.setNHBFPerTF(nHBPerTF); + grpecs.setDetsReadOut(detsReadout); + grpecs.setDetsContinuousReadOut(detsContinuousRO); + grpecs.setDetsTrigger(detsTrigger); + grpecs.setRun(run); + grpecs.setDataPeriod(dataPeriod); + + CcdbApi api; + api.init(ccdbPath); + std::map metadata; + metadata["responsible"] = "ECS"; + metadata["run_number"] = std::to_string(run); + //long ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + if (end < 0) { + end = (start + 60 * 60 * 10) * 1000; // start + 10h, in ms + } + api.storeAsTFileAny(&grpecs, "GLO/Config/GRPECS", metadata, start * 1000, end); // making it 1-year valid to be sure we have something +} diff --git a/macro/CreateGRPMagFieldObject.C b/macro/CreateGRPMagFieldObject.C new file mode 100644 index 0000000000000..e868365135cde --- /dev/null +++ b/macro/CreateGRPMagFieldObject.C @@ -0,0 +1,59 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#if !defined(__CLING__) || defined(__ROOTCLING__) + +#include +#include +#include "DataFormatsParameters/GRPMagField.h" +#include "CCDB/CcdbApi.h" +#include "CommonTypes/Units.h" + +#endif + +using timePoint = std::time_t; +using CcdbApi = o2::ccdb::CcdbApi; +using GRPMagField = o2::parameters::GRPMagField; +using current = o2::units::Current_t; + +// Simple macro to exemplify how to fill a GRPMagField object (GRP object containing the information on the magnetic field) + +// e.g. +/* + .L CreateGRPMagFieldObject.C+ + float l3 = 30000 // Ampere + float dipole = 6000 // Ampere + std::time_t tStart = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count() + std::time_t tEnd = (tStart + 60 * 60 * 24 * 365) * 1000; // 1 year validity, just an example + bool isUniform = true + int runNb = 123456 + CreateGRPMagFieldObject(l3, dipole, tStart, runNb, tEnd, isUniform) +*/ + +void CreateGRPMagFieldObject(current l3, current dipole, timePoint start, int run, timePoint end = -1, bool isUniform = true, std::string ccdbPath = "http://ccdb-test.cern.ch:8080") +{ + + GRPMagField grp; + grp.setL3Current(l3); + grp.setDipoleCurrent(dipole); + grp.setFieldUniformity(isUniform); + + CcdbApi api; + api.init(ccdbPath); + std::map metadata; + metadata["responsible"] = "DCS"; + metadata["run_number"] = std::to_string(run); + //long ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + if (end < 0) { + end = (start + 60 * 60 * 10) * 1000; // start + 10h, in ms + } + api.storeAsTFileAny(&grp, "GLO/Config/GRPMagField", metadata, start * 1000, end); // making it 1-year valid to be sure we have something +}