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>
22#include <climits>
24#include "CommonTypes/Units.h"
26
27namespace o2
28{
29namespace parameters
30{
31/*
32 * Collects parameters describing the run, like the beam, magnet settings
33 * masks for participating and triggered detectors etc.
34 */
35
37{
40
41 public:
42 using timePoint = uint64_t; // std::time_t;
43
44 enum ROMode : int { ABSENT = 0,
45 PRESENT = 0x1,
46 CONTINUOUS = PRESENT + (0x1 << 1),
47 TRIGGERING = PRESENT + (0x1 << 2) };
48
49 GRPObject() = default;
50 ~GRPObject() = default;
51
53 timePoint getTimeStart() const { return mTimeStart; }
54 timePoint getTimeEnd() const { return mTimeEnd; }
55 void setTimeStart(timePoint t) { mTimeStart = t; }
56 void setTimeEnd(timePoint t) { mTimeEnd = t; }
57
58 void setNHBFPerTF(uint32_t n) { mNHBFPerTF = n; }
59 uint32_t getNHBFPerTF() const { return mNHBFPerTF; }
60
61 void setFirstOrbit(uint32_t o) { mFirstOrbit = o; }
62 uint32_t getFirstOrbit() const { return mFirstOrbit; }
63
65 o2::units::AngleRad_t getCrossingAngle() const { return mCrossingAngle; }
66 void setCrossingAngle(o2::units::AngleRad_t v) { mCrossingAngle = v; }
68 int getBeamZ(beamDirection beam) const { return mBeamAZ[static_cast<int>(beam)] & 0xffff; }
69 int getBeamA(beamDirection beam) const { return mBeamAZ[static_cast<int>(beam)] >> 16; }
70 float getBeamZ2A(beamDirection beam) const;
71 void setBeamAZ(int a, int z, beamDirection beam) { mBeamAZ[static_cast<int>(beam)] = (a << 16) + z; }
73 void setBeamEnergyPerZ(float v) { mBeamEnergyPerZ = v; }
74 float getBeamEnergyPerZ() const { return mBeamEnergyPerZ; }
75 float getBeamEnergyPerNucleon(beamDirection beam) const { return mBeamEnergyPerZ * getBeamZ2A(beam); }
77 float getSqrtS() const;
78
80 o2::units::Current_t getL3Current() const { return mL3Current; }
81 o2::units::Current_t getDipoleCurrent() const { return mDipoleCurrent; }
82 bool getFieldUniformity() const { return mUniformField; }
83 void setL3Current(o2::units::Current_t v) { mL3Current = v; }
84 void setDipoleCurrent(o2::units::Current_t v) { mDipoleCurrent = v; }
85 void setFieldUniformity(bool v) { mUniformField = v; }
88 const std::string& getDataPeriod() const { return mDataPeriod; }
89 void setDataPeriod(const std::string v) { mDataPeriod = v; }
91 const std::string& getLHCState() const { return mLHCState; }
92 void setLHCState(const std::string v) { mLHCState = v; }
93 // getter/setter for run identifier
94 void setRun(int r) { mRun = r; }
95 int getRun() const { return mRun; }
97 void setFill(int f) { mFill = f; }
98 int getFill() const { return mFill; }
100 DetID::mask_t getDetsReadOut() const { return mDetsReadout; }
101 void setDetsReadOut(DetID::mask_t mask) { mDetsReadout = mask; }
103 DetID::mask_t getDetsContinuousReadOut() const { return mDetsContinuousRO; }
104 void setDetsContinuousReadOut(DetID::mask_t mask) { mDetsContinuousRO = mask; }
106 DetID::mask_t getDetsTrigger() const { return mDetsTrigger; }
107 void setDetsTrigger(DetID::mask_t mask) { mDetsTrigger = mask; }
109 void addDetReadOut(DetID id) { mDetsReadout |= id.getMask(); }
112 {
113 mDetsReadout &= ~id.getMask();
115 remDetTrigger(id);
116 }
118 void addDetContinuousReadOut(DetID id) { mDetsContinuousRO |= id.getMask(); }
120 void remDetContinuousReadOut(DetID id) { mDetsContinuousRO &= ~id.getMask(); }
122 void addDetTrigger(DetID id) { mDetsTrigger |= id.getMask(); }
124 void remDetTrigger(DetID id) { mDetsTrigger &= ~id.getMask(); }
126 bool isDetReadOut(DetID id) const { return (mDetsReadout & id.getMask()) != 0; }
128 bool isDetContinuousReadOut(DetID id) const { return (mDetsContinuousRO & id.getMask()) != 0; }
130 bool isDetTriggers(DetID id) const { return (mDetsTrigger & id.getMask()) != 0; }
132 void setDetROMode(DetID id, ROMode status);
133 ROMode getDetROMode(DetID id) const;
134
137 DetID::mask_t getDetsReadOut(DetID::mask_t only, DetID::mask_t skip = 0) const { return only.any() ? (mDetsReadout & only) : (mDetsReadout ^ skip); }
139 DetID::mask_t getDetsReadOut(const std::string& only, const std::string& skip = "") const { return getDetsReadOut(DetID::getMask(only), DetID::getMask(skip)); }
140
141 bool isMC() const { return mIsMC; }
142 void setIsMC(bool v = true) { mIsMC = v; }
143
145 void print() const;
146
147 static GRPObject* loadFrom(const std::string& grpFileName = "");
148
149 private:
150 timePoint mTimeStart = 0;
151 timePoint mTimeEnd = LONG_MAX;
152
153 uint32_t mFirstOrbit = 0;
154 uint32_t mNHBFPerTF = 256;
155
156 DetID::mask_t mDetsReadout;
157 DetID::mask_t mDetsContinuousRO;
158 DetID::mask_t mDetsTrigger;
159
160 o2::units::AngleRad_t mCrossingAngle = 0.f;
161 o2::units::Current_t mL3Current = 0.f;
162 o2::units::Current_t mDipoleCurrent = 0.f;
163 bool mUniformField = false;
164 float mBeamEnergyPerZ = 0.f;
165
166 int8_t mNominalL3Field = 0;
167 bool mNominalL3FieldValid = false;
168 bool mIsMC = false; // flag GRP for MC
169 int mBeamAZ[beamDirection::NBeamDirections] = {0, 0};
170
171 int mRun = 0;
172 int mFill = 0;
173 std::string mDataPeriod = "";
174 std::string mLHCState = "";
175
176 ClassDefNV(GRPObject, 8);
177};
178
179//______________________________________________
181{
182 // Z/A of beam 0 or 1
183 int a = getBeamA(b);
184 return a ? getBeamZ(b) / static_cast<float>(a) : 0.f;
185}
186
187//______________________________________________
189{
190 // compute nominal L3 field in kG
191
192 if (mNominalL3FieldValid == false) {
193 mNominalL3Field = std::lround(5.f * mL3Current / 30000.f);
194 mNominalL3FieldValid = true;
195 }
196 return mNominalL3Field;
197}
198
199} // namespace parameters
200} // namespace o2
201
202#endif
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
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:60
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:88
int getBeamZ(beamDirection beam) const
getters/setters for given beam A and Z info, encoded as A<<16+Z
Definition GRPObject.h:68
DetID::mask_t getDetsReadOut() const
getter/setter for masks of detectors in the readout
Definition GRPObject.h:100
void setLHCState(const std::string v)
Definition GRPObject.h:92
void addDetContinuousReadOut(DetID id)
add specific detector to the list of continuously readout detectors
Definition GRPObject.h:118
DetID::mask_t getDetsContinuousReadOut() const
getter/setter for masks of detectors with continuos readout
Definition GRPObject.h:103
const std::string & getLHCState() const
getter/setter for LHC state in the beggining of run
Definition GRPObject.h:91
void setTimeStart(timePoint t)
Definition GRPObject.h:55
o2::units::AngleRad_t getCrossingAngle() const
getters/setters for beams crossing angle (deviation from 0)
Definition GRPObject.h:65
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:53
void setBeamAZ(int a, int z, beamDirection beam)
Definition GRPObject.h:71
int getBeamA(beamDirection beam) const
Definition GRPObject.h:69
float getBeamZ2A(beamDirection beam) const
Definition GRPObject.h:180
uint32_t getFirstOrbit() const
Definition GRPObject.h:62
o2::units::Current_t getDipoleCurrent() const
Definition GRPObject.h:81
void setNHBFPerTF(uint32_t n)
Definition GRPObject.h:58
void setBeamEnergyPerZ(float v)
getters/setters for beam energy per charge and per nucleon
Definition GRPObject.h:73
void setDetsReadOut(DetID::mask_t mask)
Definition GRPObject.h:101
bool isDetReadOut(DetID id) const
test if detector is read out
Definition GRPObject.h:126
void setFirstOrbit(uint32_t o)
Definition GRPObject.h:61
bool isDetTriggers(DetID id) const
test if detector is triggering
Definition GRPObject.h:130
void setTimeEnd(timePoint t)
Definition GRPObject.h:56
float getBeamEnergyPerNucleon(beamDirection beam) const
Definition GRPObject.h:75
void addDetTrigger(DetID id)
add specific detector to the list of triggering detectors
Definition GRPObject.h:122
float getBeamEnergyPerZ() const
Definition GRPObject.h:74
void setDataPeriod(const std::string v)
Definition GRPObject.h:89
void setDetsContinuousReadOut(DetID::mask_t mask)
Definition GRPObject.h:104
DetID::mask_t getDetsTrigger() const
getter/setter for masks of detectors providing the trigger
Definition GRPObject.h:106
bool isDetContinuousReadOut(DetID id) const
test if detector is read out
Definition GRPObject.h:128
void addDetReadOut(DetID id)
add specific detector to the list of readout detectors
Definition GRPObject.h:109
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:111
DetID::mask_t getDetsReadOut(const std::string &only, const std::string &skip="") const
same with comma-separate list of detector names
Definition GRPObject.h:139
void setCrossingAngle(o2::units::AngleRad_t v)
Definition GRPObject.h:66
void setDipoleCurrent(o2::units::Current_t v)
Definition GRPObject.h:84
timePoint getTimeEnd() const
Definition GRPObject.h:54
void setIsMC(bool v=true)
Definition GRPObject.h:142
bool getFieldUniformity() const
Definition GRPObject.h:82
void remDetTrigger(DetID id)
remove specific detector from the list of triggering detectors
Definition GRPObject.h:124
void setL3Current(o2::units::Current_t v)
Definition GRPObject.h:83
static GRPObject * loadFrom(const std::string &grpFileName="")
void setFieldUniformity(bool v)
Definition GRPObject.h:85
DetID::mask_t getDetsReadOut(DetID::mask_t only, DetID::mask_t skip=0) const
Definition GRPObject.h:137
void remDetContinuousReadOut(DetID id)
remove specific detector from the list of continuouslt readout detectors
Definition GRPObject.h:120
uint32_t getNHBFPerTF() const
Definition GRPObject.h:59
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:80
void setDetsTrigger(DetID::mask_t mask)
Definition GRPObject.h:107
void setFill(int f)
getter/setter for fill identifier
Definition GRPObject.h:97
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
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...