Project
Loading...
Searching...
No Matches
GRPECSObject.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 <TFile.h>
17#include <ctime>
18#include <sstream>
19#include <iomanip>
20#include <cmath>
22#include "Framework/Logger.h"
24
25using namespace o2::parameters;
27
28//_______________________________________________
30{
31 // print itself
32 auto timeStr = [](long t) -> std::string {
33 if (t) {
34 std::time_t temp = t / 1000;
35 std::tm* tt = std::gmtime(&temp);
36 std::stringstream ss;
37 ss << std::put_time(tt, "%d/%m/%y %H:%M:%S") << " UTC";
38 return ss.str();
39 }
40 return {" N / A "};
41 };
42 std::string rtypName = int(mRunType) < GRPECS::RunType::NRUNTYPES ? GRPECS::RunTypeNames[int(mRunType)].data() : "INVALID";
43 printf("Run %d of type %s, period %s, isMC: %d\n", mRun, rtypName.c_str(), mDataPeriod.c_str(), isMC());
44 printf("ECS/CTP Start: %s/%s | End: %s/%s\n", timeStr(mTimeStart).c_str(), timeStr(mTimeStartCTP).c_str(),
45 timeStr(mTimeEnd).c_str(), timeStr(mTimeEndCTP).c_str());
46 printf("Number of HBF per timframe: %d\n", mNHBFPerTF);
47 printf("Detectors: Cont.RO Triggers\n");
48 for (auto i = DetID::First; i <= DetID::Last; i++) {
49 if (!isDetReadOut(DetID(i))) {
50 continue;
51 }
52 printf("%9s: ", DetID(i).getName());
53 printf("%7s ", isDetContinuousReadOut(DetID(i)) ? " + " : " - ");
54 printf("%7s ", isDetTriggers(DetID(i)) ? " + " : " - ");
55 printf("\n");
56 }
57 printf("List of FLPs used\n");
58 for (auto flp : mFLPs) {
59 printf("%3hu ", flp);
60 }
61 printf("\n");
62}
63
64//_______________________________________________
66{
68 if (!(status & PRESENT)) {
69 remDetReadOut(id);
70 return;
71 }
72 addDetReadOut(id);
73 if ((status & CONTINUOUS) == CONTINUOUS) {
75 } else {
77 }
78 if ((status & TRIGGERING) == TRIGGERING) {
79 addDetTrigger(id);
80 } else {
81 remDetTrigger(id);
82 }
83}
84
85//_______________________________________________
87{
89 if (isDetReadOut(id)) {
90 status = PRESENT;
91 } else {
92 if (isDetContinuousReadOut(id)) {
93 status = GRPECSObject::ROMode(status | CONTINUOUS);
94 }
95 if (isDetTriggers(id)) {
96 status = GRPECSObject::ROMode(status | TRIGGERING);
97 }
98 }
99 return status;
100}
101
102//_______________________________________________
103GRPECSObject* GRPECSObject::loadFrom(const std::string& grpecsFileName)
104{
105 // load object from file
106 auto fname = o2::base::NameConf::getGRPECSFileName(grpecsFileName);
107 TFile flGRP(fname.c_str());
108 if (flGRP.IsZombie()) {
109 LOG(error) << "Failed to open " << fname;
110 throw std::runtime_error("Failed to open GRPECS file");
111 }
112 auto grp = reinterpret_cast<o2::parameters::GRPECSObject*>(flGRP.GetObjectChecked(o2::base::NameConf::CCDBOBJECT.data(), Class()));
113 if (!grp) {
114 throw std::runtime_error(fmt::format("Failed to load GRPECS object from {}", fname));
115 }
116 return grp;
117}
std::string getName(const TDataMember *dm, int index, int size)
int32_t i
Header of the AggregatedRunInfo struct.
Definition of the Names Generator class.
static std::string getGRPECSFileName(const std::string_view prefix=STANDARDSIMPREFIX)
Definition NameConf.cxx:64
static constexpr std::string_view CCDBOBJECT
Definition NameConf.h:66
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
bool isDetTriggers(DetID id) const
test if detector is triggering
bool isDetContinuousReadOut(DetID id) const
test if detector is read out
void addDetTrigger(DetID id)
add specific detector to the list of triggering detectors
ROMode getDetROMode(DetID id) const
void remDetTrigger(DetID id)
remove specific detector from the list of triggering detectors
bool isDetReadOut(DetID id) const
test if detector is read out
void setDetROMode(DetID id, ROMode status)
set detector readout mode status
void addDetReadOut(DetID id)
add specific detector to the list of readout detectors
void addDetContinuousReadOut(DetID id)
add specific detector to the list of continuously readout detectors
void print() const
print itself
void remDetReadOut(DetID id)
remove specific detector from the list of readout detectors
static GRPECSObject * loadFrom(const std::string &grpecsFileName="")
void remDetContinuousReadOut(DetID id)
remove specific detector from the list of continuouslt readout detectors
GLboolean * data
Definition glcorearb.h:298
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"