Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ class NameConf : public o2::conf::ConfigurableParamHelper<NameConf>
// 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)
{
Expand Down Expand Up @@ -119,6 +125,8 @@ class NameConf : public o2::conf::ConfigurableParamHelper<NameConf>
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";
Expand All @@ -134,6 +142,8 @@ class NameConf : public o2::conf::ConfigurableParamHelper<NameConf>

// 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
Expand Down
12 changes: 12 additions & 0 deletions DataFormats/Detectors/Common/src/NameConf.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
8 changes: 6 additions & 2 deletions DataFormats/Parameters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
125 changes: 125 additions & 0 deletions DataFormats/Parameters/include/DataFormatsParameters/GRPECSObject.h
Original file line number Diff line number Diff line change
@@ -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 <Rtypes.h>
#include <cstdint>
#include <ctime>
#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
121 changes: 121 additions & 0 deletions DataFormats/Parameters/include/DataFormatsParameters/GRPLHCIFData.h
Original file line number Diff line number Diff line change
@@ -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 <Rtypes.h>
#include <string>
#include <unordered_map>
#include <cstdint>
#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<unsigned int, unsigned int> mZtoA;

std::pair<long, int32_t> getBeamEnergyPerZWithTime() const { return mBeamEnergyPerZ; }
int32_t getBeamEnergyPerZ() const { return mBeamEnergyPerZ.second; }
long getBeamEnergyPerZTime() const { return mBeamEnergyPerZ.first; }
void setBeamEnergyPerZWithTime(std::pair<long, int32_t> p) { mBeamEnergyPerZ = p; }
void setBeamEnergyPerZWithTime(long t, int32_t v) { mBeamEnergyPerZ = std::make_pair(t, v); }

std::pair<long, int32_t> getFillNumberWithTime() const { return mFillNumber; }
int32_t getFillNumber() const { return mFillNumber.second; }
long getFillNumberTime() const { return mFillNumber.first; }
void setFillNumberWithTime(std::pair<long, int32_t> p) { mFillNumber = p; }
void setFillNumberWithTime(long t, int32_t v) { mFillNumber = std::make_pair(t, v); }

std::pair<long, std::string> getInjectionSchemeWithTime() const { return mInjectionScheme; }
std::string getInjectionScheme() const { return mInjectionScheme.second; }
long getInjectionSchemeTime() const { return mInjectionScheme.first; }
void setInjectionSchemeWithTime(std::pair<long, std::string> p) { mInjectionScheme = p; }
void setInjectionSchemeWithTime(long t, std::string v) { mInjectionScheme = std::make_pair(t, v); }

std::pair<long, int32_t> getAtomicNumberB1WithTime() const { return mAtomicNumberB1; }
int32_t getAtomicNumberB1() const { return mAtomicNumberB1.second; }
long getAtomicNumberB1Time() const { return mAtomicNumberB1.first; }
void setAtomicNumberB1WithTime(std::pair<long, int32_t> p) { mAtomicNumberB1 = p; }
void setAtomicNumberB1WithTime(long t, int32_t v) { mAtomicNumberB1 = std::make_pair(t, v); }

std::pair<long, int32_t> getAtomicNumberB2WithTime() const { return mAtomicNumberB2; }
int32_t getAtomicNumberB2() const { return mAtomicNumberB2.second; }
long getAtomicNumberB2Time() const { return mAtomicNumberB2.first; }
void setAtomicNumberB2WithTime(std::pair<long, int32_t> p) { mAtomicNumberB2 = p; }
void setAtomicNumberB2WithTime(long t, int32_t v) { mAtomicNumberB2 = std::make_pair(t, v); }

std::pair<long, o2::units::AngleRad_t> getCrossingAngleWithTime() const { return mCrossingAngle; }
o2::units::AngleRad_t getCrossingAngle() const { return mCrossingAngle.second; }
long getCrossingAngleTime() const { return mCrossingAngle.first; }
void setCrossingAngleWithTime(std::pair<long, o2::units::AngleRad_t> p) { mCrossingAngle = p; }
void setCrossingAngleWithTime(long t, o2::units::AngleRad_t v) { mCrossingAngle = std::make_pair(t, v); }

std::pair<long, o2::BunchFilling> getBunchFillingWithTime() const { return mBunchFilling; }
o2::BunchFilling getBunchFilling() const { return mBunchFilling.second; }
long getBunchFillingTime() const { return mBunchFilling.first; }
void setBunchFillingWithTime(std::pair<long, o2::BunchFilling> 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<int>(beam)] & 0xffff; }
int getBeamA(beamDirection beam) const { return mBeamAZ[static_cast<int>(beam)] >> 16; }
float getBeamZoverA(beamDirection beam) const;
void setBeamAZ(int a, int z, beamDirection beam) { mBeamAZ[static_cast<int>(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<int32_t>& bcNb, std::vector<int32_t>& buckets, int beam);

private:
std::pair<long, int32_t> mBeamEnergyPerZ; // beam energy per charge
std::pair<long, int32_t> mFillNumber;
std::pair<long, std::string> mInjectionScheme;
std::pair<long, int32_t> mAtomicNumberB1; // clockwise
std::pair<long, int32_t> mAtomicNumberB2; // anticlockwise
std::pair<long, o2::units::AngleRad_t> mCrossingAngle;
int mBeamAZ[beamDirection::NBeamDirections] = {0, 0}; ///< A<<16+Z for each beam
std::pair<long, o2::BunchFilling> 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<float>(a) : 0.f;
}

} // namespace parameters
} // namespace o2
#endif
Original file line number Diff line number Diff line change
@@ -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 <Rtypes.h>
#include <cstdint>
#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
Loading