Project
Loading...
Searching...
No Matches
GRPObject.h
Go to the documentation of this file.
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
15
16#ifndef ALICEO2_DATA_GRPOBJECT_H_
17#define ALICEO2_DATA_GRPOBJECT_H_
18
19#include <Rtypes.h>
20#include <cstdint>
21#include <ctime>
23#include "CommonTypes/Units.h"
25
26namespace o2
27{
28namespace parameters
29{
30/*
31 * Collects parameters describing the run, like the beam, magnet settings
32 * masks for participating and triggered detectors etc.
33 */
34
36{
39
40 public:
41 using timePoint = uint64_t; // std::time_t;
42
43 enum ROMode : int { ABSENT = 0,
44 PRESENT = 0x1,
45 CONTINUOUS = PRESENT + (0x1 << 1),
46 TRIGGERING = PRESENT + (0x1 << 2) };
47
48 GRPObject() = default;
49 ~GRPObject() = default;
50
52 timePoint getTimeStart() const { return mTimeStart; }
53 timePoint getTimeEnd() const { return mTimeEnd; }
54 void setTimeStart(timePoint t) { mTimeStart = t; }
55 void setTimeEnd(timePoint t) { mTimeEnd = t; }
56
57 void setNHBFPerTF(uint32_t n) { mNHBFPerTF = n; }
58 uint32_t getNHBFPerTF() const { return mNHBFPerTF; }
59
60 void setFirstOrbit(uint32_t o) { mFirstOrbit = o; }
61 uint32_t getFirstOrbit() const { return mFirstOrbit; }
62
64 o2::units::AngleRad_t getCrossingAngle() const { return mCrossingAngle; }
65 void setCrossingAngle(o2::units::AngleRad_t v) { mCrossingAngle = v; }
67 int getBeamZ(beamDirection beam) const { return mBeamAZ[static_cast<int>(beam)] & 0xffff; }
68 int getBeamA(beamDirection beam) const { return mBeamAZ[static_cast<int>(beam)] >> 16; }
69 float getBeamZ2A(beamDirection beam) const;
70 void setBeamAZ(int a, int z, beamDirection beam) { mBeamAZ[static_cast<int>(beam)] = (a << 16) + z; }
72 void setBeamEnergyPerZ(float v) { mBeamEnergyPerZ = v; }
73 float getBeamEnergyPerZ() const { return mBeamEnergyPerZ; }
74 float getBeamEnergyPerNucleon(beamDirection beam) const { return mBeamEnergyPerZ * getBeamZ2A(beam); }
76 float getSqrtS() const;
77
79 o2::units::Current_t getL3Current() const { return mL3Current; }
80 o2::units::Current_t getDipoleCurrent() const { return mDipoleCurrent; }
81 bool getFieldUniformity() const { return mUniformField; }
82 void setL3Current(o2::units::Current_t v) { mL3Current = v; }
83 void setDipoleCurrent(o2::units::Current_t v) { mDipoleCurrent = v; }
84 void setFieldUniformity(bool v) { mUniformField = v; }
85 int8_t getNominalL3Field();
87 const std::string& getDataPeriod() const { return mDataPeriod; }
88 void setDataPeriod(const std::string v) { mDataPeriod = v; }
90 const std::string& getLHCState() const { return mLHCState; }
91 void setLHCState(const std::string v) { mLHCState = v; }
92 // getter/setter for run identifier
93 void setRun(int r) { mRun = r; }
94 int getRun() const { return mRun; }
96 void setFill(int f) { mFill = f; }
97 int getFill() const { return mFill; }
99 DetID::mask_t getDetsReadOut() const { return mDetsReadout; }
100 void setDetsReadOut(DetID::mask_t mask) { mDetsReadout = mask; }
102 DetID::mask_t getDetsContinuousReadOut() const { return mDetsContinuousRO; }
103 void setDetsContinuousReadOut(DetID::mask_t mask) { mDetsContinuousRO = mask; }
105 DetID::mask_t getDetsTrigger() const { return mDetsTrigger; }
106 void setDetsTrigger(DetID::mask_t mask) { mDetsTrigger = mask; }
108 void addDetReadOut(DetID id) { mDetsReadout |= id.getMask(); }
111 {
112 mDetsReadout &= ~id.getMask();
114 remDetTrigger(id);
115 }
117 void addDetContinuousReadOut(DetID id) { mDetsContinuousRO |= id.getMask(); }
119 void remDetContinuousReadOut(DetID id) { mDetsContinuousRO &= ~id.getMask(); }
121 void addDetTrigger(DetID id) { mDetsTrigger |= id.getMask(); }
123 void remDetTrigger(DetID id) { mDetsTrigger &= ~id.getMask(); }
125 bool isDetReadOut(DetID id) const { return (mDetsReadout & id.getMask()) != 0; }
127 bool isDetContinuousReadOut(DetID id) const { return (mDetsContinuousRO & id.getMask()) != 0; }
129 bool isDetTriggers(DetID id) const { return (mDetsTrigger & id.getMask()) != 0; }
131 void setDetROMode(DetID id, ROMode status);
132 ROMode getDetROMode(DetID id) const;
133
136 DetID::mask_t getDetsReadOut(DetID::mask_t only, DetID::mask_t skip = 0) const { return only.any() ? (mDetsReadout & only) : (mDetsReadout ^ skip); }
138 DetID::mask_t getDetsReadOut(const std::string& only, const std::string& skip = "") const { return getDetsReadOut(DetID::getMask(only), DetID::getMask(skip)); }
139
140 bool isMC() const { return mIsMC; }
141 void setIsMC(bool v = true) { mIsMC = v; }
142
144 void print() const;
145
146 static GRPObject* loadFrom(const std::string& grpFileName = "");
147
148 private:
149 timePoint mTimeStart = 0;
150 timePoint mTimeEnd = LONG_MAX;
151
152 uint32_t mFirstOrbit = 0;
153 uint32_t mNHBFPerTF = 256;
154
155 DetID::mask_t mDetsReadout;
156 DetID::mask_t mDetsContinuousRO;
157 DetID::mask_t mDetsTrigger;
158
159 o2::units::AngleRad_t mCrossingAngle = 0.f;
160 o2::units::Current_t mL3Current = 0.f;
161 o2::units::Current_t mDipoleCurrent = 0.f;
162 bool mUniformField = false;
163 float mBeamEnergyPerZ = 0.f;
164
165 int8_t mNominalL3Field = 0;
166 bool mNominalL3FieldValid = false;
167 bool mIsMC = false; // flag GRP for MC
168 int mBeamAZ[beamDirection::NBeamDirections] = {0, 0};
169
170 int mRun = 0;
171 int mFill = 0;
172 std::string mDataPeriod = "";
173 std::string mLHCState = "";
174
175 ClassDefNV(GRPObject, 8);
176};
177
178//______________________________________________
180{
181 // Z/A of beam 0 or 1
182 int a = getBeamA(b);
183 return a ? getBeamZ(b) / static_cast<float>(a) : 0.f;
184}
185
186//______________________________________________
188{
189 // compute nominal L3 field in kG
190
191 if (mNominalL3FieldValid == false) {
192 mNominalL3Field = std::lround(5.f * mL3Current / 30000.f);
193 mNominalL3FieldValid = true;
194 }
195 return mNominalL3Field;
196}
197
198} // namespace parameters
199} // namespace o2
200
201#endif
bool o
Header to collect LHC related constants.
Header to collect definitions for different units.
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
static mask_t getMask(const std::string_view detList)
detector masks from any non-alpha-num delimiter-separated list (empty if NONE is supplied)
Definition DetID.cxx:42
const std::string & getDataPeriod() const
getter/setter for data taking period name
Definition GRPObject.h:87
int getBeamZ(beamDirection beam) const
getters/setters for given beam A and Z info, encoded as A<<16+Z
Definition GRPObject.h:67
DetID::mask_t getDetsReadOut() const
getter/setter for masks of detectors in the readout
Definition GRPObject.h:99
void setLHCState(const std::string v)
Definition GRPObject.h:91
void addDetContinuousReadOut(DetID id)
add specific detector to the list of continuously readout detectors
Definition GRPObject.h:117
DetID::mask_t getDetsContinuousReadOut() const
getter/setter for masks of detectors with continuos readout
Definition GRPObject.h:102
const std::string & getLHCState() const
getter/setter for LHC state in the beggining of run
Definition GRPObject.h:90
void setTimeStart(timePoint t)
Definition GRPObject.h:54
o2::units::AngleRad_t getCrossingAngle() const
getters/setters for beams crossing angle (deviation from 0)
Definition GRPObject.h:64
void print() const
print itself
Definition GRPObject.cxx:46
timePoint getTimeStart() const
getters/setters for Start and Stop times according to logbook
Definition GRPObject.h:52
void setBeamAZ(int a, int z, beamDirection beam)
Definition GRPObject.h:70
int getBeamA(beamDirection beam) const
Definition GRPObject.h:68
float getBeamZ2A(beamDirection beam) const
Definition GRPObject.h:179
uint32_t getFirstOrbit() const
Definition GRPObject.h:61
o2::units::Current_t getDipoleCurrent() const
Definition GRPObject.h:80
void setNHBFPerTF(uint32_t n)
Definition GRPObject.h:57
void setBeamEnergyPerZ(float v)
getters/setters for beam energy per charge and per nucleon
Definition GRPObject.h:72
void setDetsReadOut(DetID::mask_t mask)
Definition GRPObject.h:100
bool isDetReadOut(DetID id) const
test if detector is read out
Definition GRPObject.h:125
void setFirstOrbit(uint32_t o)
Definition GRPObject.h:60
bool isDetTriggers(DetID id) const
test if detector is triggering
Definition GRPObject.h:129
void setTimeEnd(timePoint t)
Definition GRPObject.h:55
float getBeamEnergyPerNucleon(beamDirection beam) const
Definition GRPObject.h:74
void addDetTrigger(DetID id)
add specific detector to the list of triggering detectors
Definition GRPObject.h:121
float getBeamEnergyPerZ() const
Definition GRPObject.h:73
void setDataPeriod(const std::string v)
Definition GRPObject.h:88
void setDetsContinuousReadOut(DetID::mask_t mask)
Definition GRPObject.h:103
DetID::mask_t getDetsTrigger() const
getter/setter for masks of detectors providing the trigger
Definition GRPObject.h:105
bool isDetContinuousReadOut(DetID id) const
test if detector is read out
Definition GRPObject.h:127
void addDetReadOut(DetID id)
add specific detector to the list of readout detectors
Definition GRPObject.h:108
void setDetROMode(DetID id, ROMode status)
set detector readout mode status
Definition GRPObject.cxx:76
void remDetReadOut(DetID id)
remove specific detector from the list of readout detectors
Definition GRPObject.h:110
DetID::mask_t getDetsReadOut(const std::string &only, const std::string &skip="") const
same with comma-separate list of detector names
Definition GRPObject.h:138
void setCrossingAngle(o2::units::AngleRad_t v)
Definition GRPObject.h:65
void setDipoleCurrent(o2::units::Current_t v)
Definition GRPObject.h:83
timePoint getTimeEnd() const
Definition GRPObject.h:53
void setIsMC(bool v=true)
Definition GRPObject.h:141
bool getFieldUniformity() const
Definition GRPObject.h:81
void remDetTrigger(DetID id)
remove specific detector from the list of triggering detectors
Definition GRPObject.h:123
void setL3Current(o2::units::Current_t v)
Definition GRPObject.h:82
static GRPObject * loadFrom(const std::string &grpFileName="")
void setFieldUniformity(bool v)
Definition GRPObject.h:84
DetID::mask_t getDetsReadOut(DetID::mask_t only, DetID::mask_t skip=0) const
Definition GRPObject.h:136
void remDetContinuousReadOut(DetID id)
remove specific detector from the list of continuouslt readout detectors
Definition GRPObject.h:119
uint32_t getNHBFPerTF() const
Definition GRPObject.h:58
ROMode getDetROMode(DetID id) const
Definition GRPObject.cxx:97
float getSqrtS() const
calculate center of mass energy per nucleon collision
Definition GRPObject.cxx:29
o2::units::Current_t getL3Current() const
getters/setters for magnets currents
Definition GRPObject.h:79
void setDetsTrigger(DetID::mask_t mask)
Definition GRPObject.h:106
void setFill(int f)
getter/setter for fill identifier
Definition GRPObject.h:96
GLdouble n
Definition glcorearb.h:1982
const GLdouble * v
Definition glcorearb.h:832
GLdouble f
Definition glcorearb.h:310
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLboolean r
Definition glcorearb.h:1233
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLint GLuint mask
Definition glcorearb.h:291
GLuint id
Definition glcorearb.h:650
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...