24#include <fairlogger/Logger.h>
31#include <boost/interprocess/sync/named_semaphore.hpp>
33#include <unordered_map>
44static std::vector<o2::detectors::DetID> sDetList;
64 boost::interprocess::named_semaphore* sem =
nullptr;
65 std::string semhashedstring;
67 const auto semname = std::filesystem::current_path().string() + grpECSFileName;
68 std::hash<std::string> hasher;
69 semhashedstring =
"alice_grp_" +
std::to_string(hasher(semname)).substr(0, 16);
70 sem =
new boost::interprocess::named_semaphore(boost::interprocess::open_or_create_t{}, semhashedstring.c_str(), 1);
71 }
catch (std::exception
e) {
72 LOG(warn) <<
"Could not setup GRP semaphore; Continuing without";
80 auto postSem = [sem, &semhashedstring] {
83 if (sem->try_wait()) {
86 boost::interprocess::named_semaphore::remove(semhashedstring.c_str());
91 updateECSData<o2::parameters::GRPECSObject>(grpECSFileName, pc);
92 updateECSData<o2::parameters::GRPObject>(grpFileName, pc);
95 }
catch (boost::interprocess::interprocess_exception
e) {
96 LOG(
error) <<
"Caught semaphore exception " <<
e.what();
102 template <
typename GRP>
106 TFile flGRP(grpFileName.c_str(),
"update");
107 if (flGRP.IsZombie()) {
108 LOG(
error) <<
"Failed to open in update mode " << grpFileName;
111 std::unique_ptr<GRP> grp(
static_cast<GRP*
>(flGRP.GetObjectChecked(grpName.c_str(), GRP::Class())));
112 for (
auto det : sDetList) {
113 auto roMode = pc.
inputs().
get<
typename GRP::ROMode>(det.getName());
114 if (!(roMode & GRP::PRESENT)) {
115 LOG(
error) <<
"Detector " << det.getName() <<
" is read out while processor set ABSENT";
118 grp->setDetROMode(det, roMode);
122 LOG(info) <<
"Updated " << grpFileName <<
" with detectors RO modes";
124 flGRP.WriteObjectAny(grp.get(), grp->Class(), grpName.c_str());
133 if (!std::filesystem::exists(grpFileName)) {
134 LOGP(info,
"GRPLHCIF file {} is absent, abandon setting bunch-filling", grpFileName);
137 TFile flGRP(grpFileName.c_str(),
"update");
138 if (flGRP.IsZombie()) {
139 LOG(fatal) <<
"Failed to open in update mode " << grpFileName;
141 std::unique_ptr<GRPLHCIF> grp(
static_cast<GRPLHCIF*
>(flGRP.GetObjectChecked(grpName.c_str(), GRPLHCIF::Class())));
143 flGRP.WriteObjectAny(grp.get(), grp->Class(), grpName.c_str());
145 LOG(info) <<
"Updated " << grpFileName <<
" with bunch filling";
148 std::string mPrefix =
"o2sim";
157 std::vector<InputSpec> inputs;
158 for (
const auto det : detList) {
159 inputs.emplace_back(
InputSpec{det.getName(), det.getDataOrigin(),
"ROMode", 0, Lifetime::Timeframe});
161 inputs.emplace_back(
InputSpec{
"bunchfilling",
"SIM",
"BUNCHFILLING", 0, Lifetime::Timeframe});
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 e
Header of the AggregatedRunInfo struct.
container for the LHC InterFace data
Header of the General Run Parameters object.
char error[CURL_ERROR_SIZE]
Definition of the Names Generator class.
static std::string getGRPECSFileName(const std::string_view prefix=STANDARDSIMPREFIX)
static std::string getGRPLHCIFFileName(const std::string_view prefix=STANDARDSIMPREFIX)
static constexpr std::string_view CCDBOBJECT
static std::string getGRPFileName(const std::string_view prefix=STANDARDSIMPREFIX)
static const HBFUtils & Instance()
o2::header::DataHeader::SubSpecificationType SubSpecificationType
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
void run(framework::ProcessingContext &pc)
GRPDPLUpdatedTask(const std::string &prefix)
void init(framework::InitContext &ic)
Defining ITS Vertex explicitly as messageable.
o2::framework::DataProcessorSpec getGRPUpdaterSpec(const std::string &prefix, const std::vector< o2::detectors::DetID > &detList)
create the processor spec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string to_string(gsl::span< T, Size > span)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"