Project
Loading...
Searching...
No Matches
GRPObject.cxx
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#include <fairlogger/Logger.h>
17#include <TFile.h>
19#include <cmath>
22
23using namespace o2::parameters;
24using namespace o2::constants::physics;
25using namespace o2::constants::lhc;
27
28//_______________________________________________
30{
31 // get center of mass energy
32 double e0 = getBeamEnergyPerNucleon(BeamC);
33 double e1 = getBeamEnergyPerNucleon(BeamA);
34 if (e0 <= MassProton || e1 <= MassProton) {
35 return 0.f;
36 }
37 double beta0 = 1. - MassProton * MassProton / (e0 * e0);
38 double beta1 = 1. - MassProton * MassProton / (e1 * e1);
39 beta0 = beta0 > 0 ? sqrt(beta0) : 0.;
40 beta1 = beta1 > 0 ? sqrt(beta1) : 0.;
41 double ss = 2. * (MassProton * MassProton + e0 * e1 * (1. + beta0 * beta1 * cos(mCrossingAngle)));
42 return ss > 0. ? sqrt(ss) : 0.;
43}
44
45//_______________________________________________
46void GRPObject::print() const
47{
48 // print itself
49 printf("Run: %8d\nFill: %6d\nPeriod: %s, isMC:%d\n", getRun(), getFill(), getDataPeriod().data(), isMC());
50 printf("LHC State: %s\n", getLHCState().data());
51 std::time_t t = mTimeStart; // system_clock::to_time_t(mTimeStart);
52 printf("Start: %s", std::ctime(&t));
53 t = mTimeEnd; // system_clock::to_time_t(mTimeEnd);
54 printf("End : %s", std::ctime(&t));
55 printf("1st orbit: %u, %u orbits per TF\n", mFirstOrbit, mNHBFPerTF);
56 printf("Beam0: Z:A = %3d:%3d, Energy = %.3f\n", getBeamZ(BeamC), getBeamA(BeamC),
58 printf("Beam1: Z:A = %3d:%3d, Energy = %.3f\n", getBeamZ(BeamA), getBeamA(BeamA),
60 printf("sqrt[s] = %.3f\n", getSqrtS());
61 printf("crossing angle (radian) = %e\n", getCrossingAngle());
62 printf("magnet currents (A) L3 = %.3f, Dipole = %.f\n", getL3Current(), getDipoleCurrent());
63 printf("Detectors: Cont.RO Triggers\n");
64 for (auto i = DetID::First; i <= DetID::Last; i++) {
65 if (!isDetReadOut(DetID(i))) {
66 continue;
67 }
68 printf("%9s: ", DetID(i).getName());
69 printf("%7s ", isDetContinuousReadOut(DetID(i)) ? " + " : " - ");
70 printf("%7s ", isDetTriggers(DetID(i)) ? " + " : " - ");
71 printf("\n");
72 }
73}
74
75//_______________________________________________
77{
79 if (!(status & PRESENT)) {
80 remDetReadOut(id);
81 return;
82 }
83 addDetReadOut(id);
84 if ((status & CONTINUOUS) == CONTINUOUS) {
86 } else {
88 }
89 if ((status & TRIGGERING) == TRIGGERING) {
90 addDetTrigger(id);
91 } else {
92 remDetTrigger(id);
93 }
94}
95
96//_______________________________________________
98{
100 if (isDetReadOut(id)) {
101 status = PRESENT;
102 } else {
103 if (isDetContinuousReadOut(id)) {
104 status = GRPObject::ROMode(status | CONTINUOUS);
105 }
106 if (isDetTriggers(id)) {
107 status = GRPObject::ROMode(status | TRIGGERING);
108 }
109 }
110 return status;
111}
112
113//_______________________________________________
114GRPObject* GRPObject::loadFrom(const std::string& grpFileName)
115{
116 // load object from file
117 auto fname = o2::base::NameConf::getGRPFileName(grpFileName);
118 TFile flGRP(fname.c_str());
119 if (flGRP.IsZombie()) {
120 LOG(error) << "Failed to open " << fname;
121 throw std::runtime_error("Failed to open GRP file");
122 }
123 auto grp = reinterpret_cast<o2::parameters::GRPObject*>(flGRP.GetObjectChecked(o2::base::NameConf::CCDBOBJECT.data(), Class()));
124 if (!grp && !(grp = reinterpret_cast<o2::parameters::GRPObject*>(flGRP.GetObjectChecked("GRP", Class())))) { // for BWD compatibility
125 throw std::runtime_error(fmt::format("Failed to load GRP object from {}", fname));
126 }
127 return grp;
128}
std::string getName(const TDataMember *dm, int index, int size)
int32_t i
Header of the General Run Parameters object.
Definition of the Names Generator class.
Header to collect physics constants.
static constexpr std::string_view CCDBOBJECT
Definition NameConf.h:66
static std::string getGRPFileName(const std::string_view prefix=STANDARDSIMPREFIX)
Definition NameConf.cxx:58
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
static constexpr ID First
Definition DetID.h:94
static constexpr ID Last
if extra detectors added, update this !!!
Definition DetID.h:92
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
void addDetContinuousReadOut(DetID id)
add specific detector to the list of continuously readout detectors
Definition GRPObject.h:117
const std::string & getLHCState() const
getter/setter for LHC state in the beggining of run
Definition GRPObject.h:90
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
int getBeamA(beamDirection beam) const
Definition GRPObject.h:68
o2::units::Current_t getDipoleCurrent() const
Definition GRPObject.h:80
bool isDetReadOut(DetID id) const
test if detector is read out
Definition GRPObject.h:125
bool isDetTriggers(DetID id) const
test if detector is triggering
Definition GRPObject.h:129
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
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
void remDetTrigger(DetID id)
remove specific detector from the list of triggering detectors
Definition GRPObject.h:123
static GRPObject * loadFrom(const std::string &grpFileName="")
void remDetContinuousReadOut(DetID id)
remove specific detector from the list of continuouslt readout detectors
Definition GRPObject.h:119
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
GLboolean * data
Definition glcorearb.h:298
constexpr double MassProton
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"