Project
Loading...
Searching...
No Matches
DataSamplingConditionCustom.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
16
19#include "Headers/DataHeader.h"
20
21#include <fairlogger/Logger.h>
22
23#include <TClass.h>
24#include <TROOT.h>
25#include <TSystem.h>
26#include <boost/property_tree/ptree.hpp>
27
28using namespace o2::framework;
29
30namespace o2::utilities
31{
32
35{
36
37 public:
41 ~DataSamplingConditionCustom() override = default;
42
47 void configure(const boost::property_tree::ptree& config) override
48 {
49 std::string libraryName = "lib" + config.get<std::string>("moduleName");
50 std::string className = config.get<std::string>("className");
51
52 int libLoaded = gSystem->Load(libraryName.c_str(), "", true);
53 if (libLoaded < 0) {
54 throw std::runtime_error("Failed to load the library: " + libraryName);
55 }
56
57 // it does not seem to be documented anywhere, but this pointer to
58 // a dictionary should not be deleted - it results in segfaults.
59 TClass* dictionary = TClass::GetClass(className.c_str());
60 if (!dictionary) {
61 throw std::runtime_error("Failed to load the dictionary of the class: " + className + " from the library: " + libraryName);
62 }
63
64 mCondition.reset(static_cast<DataSamplingCondition*>(dictionary->New()));
65 if (mCondition == nullptr) {
66 throw std::runtime_error("Failed to instantiate the class: " + className + " from the library: " + libraryName);
67 }
68
69 mCondition->configure(config);
70 }
71
73 bool decide(const o2::framework::DataRef& dataRef) override
74 {
75 return mCondition->decide(dataRef);
76 }
77
78 private:
79 std::unique_ptr<DataSamplingCondition> mCondition;
80};
81
83{
84 return std::make_unique<DataSamplingConditionCustom>();
85}
86
87} // namespace o2::utilities
A definition of DataSamplingConditionFactory.
A standarised data sampling condition, to decide if given data sample should be passed forward.
A DataSamplingCondition which makes decisions based on payload size.
~DataSamplingConditionCustom() override=default
Default destructor.
bool decide(const o2::framework::DataRef &dataRef) override
Invokes decide() of a custom condition.
void configure(const boost::property_tree::ptree &config) override
Instantiates and configures a custom condition based on configuration.
static std::unique_ptr< DataSamplingCondition > createDataSamplingConditionCustom()
Getter for DataSamplingConditionCustom.
A standardised data sampling condition, to decide if given data sample should be passed forward.
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
A header which contains some meta-data generated by Data Sampling.