43 mCalibrator = std::make_unique<o2::calibration::IntegratedClusterCalibrator<ITOFC>>();
44 const auto slotLength = ic.options().get<
uint32_t>(
"tf-per-slot");
45 const auto maxDelay = ic.options().get<
uint32_t>(
"max-delay");
46 const auto debug = ic.options().get<
bool>(
"debug");
47 mCalibrator->setSlotLength(slotLength);
48 mCalibrator->setMaxSlotsDelay(maxDelay);
49 mCalibrator->setDebug(
debug);
50 mCalibFileDir = ic.options().get<std::string>(
"output-dir");
51 if (mCalibFileDir !=
"/dev/null") {
54 mMetaFileDir = ic.options().get<std::string>(
"meta-output-dir");
55 if (mMetaFileDir !=
"/dev/null") {
58 mDumpCalibData = ic.options().get<
bool>(
"dump-calib-data");
67 if (mSetDataTakingCont) {
69 mSetDataTakingCont =
false;
73 tofcurr.
mITOFCNCl = pc.inputs().get<std::vector<float>>(pc.inputs().get(
"itofcn"));
74 tofcurr.
mITOFCQ = pc.inputs().get<std::vector<float>>(pc.inputs().get(
"itofcq"));
77 mCalibrator->process(mCalibrator->getCurrentTFInfo().tfCounter, tofcurr);
79 LOGP(
debug,
"Created {} objects for TF {} and time stamp {}", mCalibrator->getTFinterval().size(), mCalibrator->getCurrentTFInfo().tfCounter, mCalibrator->getCurrentTFInfo().creation);
81 if (mCalibrator->hasCalibrationData()) {
82 sendOutput(pc.outputs());
88 LOGP(info,
"Finalizing calibration. Dumping all objects");
90 for (
int i = 0;
i < mCalibrator->getNSlots(); ++
i) {
91 mCalibrator->finalizeSlot(mCalibrator->getSlot(
i));
93 sendOutput(eos.outputs());
101 std::unique_ptr<o2::calibration::IntegratedClusterCalibrator<ITOFC>> mCalibrator;
102 std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
103 std::string mMetaFileDir{};
104 std::string mCalibFileDir{};
106 bool mSetDataTakingCont{
true};
107 bool mDumpCalibData{
false};
111 auto calibrations = std::move(*mCalibrator).getCalibs();
112 const auto& intervals = mCalibrator->getTimeIntervals();
113 assert(calibrations.size() == intervals.size());
114 for (
unsigned int i = 0;
i < calibrations.size();
i++) {
115 const auto&
object = calibrations[
i];
116 o2::ccdb::CcdbObjectInfo info(
"TOF/Calib/ITOFC", std::string{}, std::string{}, std::map<std::string, std::string>{}, intervals[
i].first, intervals[
i].second);
118 LOGP(info,
"Sending object {} / {} of size {} bytes, valid for {} : {} ",
info.getPath(),
info.getFileName(),
image->size(),
info.getStartValidityTimestamp(),
info.getEndValidityTimestamp());
122 if (mDumpCalibData && mCalibFileDir !=
"/dev/null") {
123 std::string calibFName = fmt::format(
"itofc_cal_data_{}_{}.root",
info.getStartValidityTimestamp(),
info.getEndValidityTimestamp());
125 std::ofstream calFile(fmt::format(
"{}{}", mCalibFileDir, calibFName), std::ios::out | std::ios::binary);
128 }
catch (std::exception
const&
e) {
129 LOG(
error) <<
"Failed to store ITOFC calibration data file " << calibFName <<
", reason: " <<
e.what();
132 if (mMetaFileDir !=
"/dev/null") {
136 calMetaData.
type =
"calib";
138 auto metaFileNameTmp = fmt::format(
"{}{}.tmp", mMetaFileDir, calibFName);
139 auto metaFileName = fmt::format(
"{}{}.done", mMetaFileDir, calibFName);
141 std::ofstream metaFileOut(metaFileNameTmp);
142 metaFileOut << calMetaData;
144 std::filesystem::rename(metaFileNameTmp, metaFileName);
145 }
catch (std::exception
const&
e) {
146 LOG(
error) <<
"Failed to store CTF meta data file " << metaFileName <<
", reason: " <<
e.what();
151 mCalibrator->initOutput();
157 std::vector<InputSpec> inputs;
161 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(
true,
169 std::vector<OutputSpec> outputs;
174 "tof-merge-integrated-clusters",
177 AlgorithmSpec{adaptFromTask<TOFMergeIntegrateClusters>(ccdbRequest)},
179 {
"debug", VariantType::Bool,
false, {
"Write debug output files"}},
180 {
"tf-per-slot", VariantType::UInt32, 1000u, {
"number of TFs per calibration time slot"}},
181 {
"max-delay", VariantType::UInt32, 3u, {
"number of slots in past to consider"}},
182 {
"output-dir", VariantType::String,
"none", {
"calibration files output directory, must exist"}},
183 {
"meta-output-dir", VariantType::String,
"/dev/null", {
"calibration metadata output directory, must exist (if not /dev/null)"}},
184 {
"dump-calib-data", VariantType::Bool,
false, {
"Dump ITOFC calibration data to file"}}}};
Utils and constants for calibration and related workflows.
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
Helper for geometry and GRP related CCDB requests.
char error[CURL_ERROR_SIZE]
calibrator class for accumulating integrated clusters
void checkUpdates(o2::framework::ProcessingContext &pc)
bool finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
static constexpr header::DataDescription getDataDescriptionCCDB()
void finaliseCCDB(o2::framework::ConcreteDataMatcher &matcher, void *obj) final
void init(framework::InitContext &ic) final
void run(ProcessingContext &pc) final
void endOfStream(EndOfStreamContext &eos) final
This is invoked whenever we have an EndOfStream event.
TOFMergeIntegrateClusters(std::shared_ptr< o2::base::GRPGeomRequest > req)
\construcor
constexpr o2::header::DataOrigin gDataOriginTOF
Defining ITS Vertex explicitly as messageable.
o2::framework::DataProcessorSpec getTOFMergeIntegrateClusterSpec()
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static void fillTFIDInfo(o2::framework::ProcessingContext &pc, o2::dataformats::TFIDInfo &ti)
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
struct containing the integrated TOF currents
std::vector< float > mITOFCNCl
integrated 1D TOF cluster currents
std::vector< float > mITOFCQ
integrated 1D TOF qTot currents
static std::string rectifyDirectory(const std::string_view p)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"