20#include <fairlogger/Logger.h>
30 if (mOutputDir.compare(
"/dev/null")) {
33 if (mMetaFileDir.compare(
"/dev/null")) {
39 mCalibrator->setUpdateAtTheEndOfRunOnly();
47 if (mRunStartTime == 0 || crTime < mRunStartTime) {
48 mRunStartTime = crTime;
49 if (mWriteRootOutput) {
50 mHistoFileMetaData = std::make_unique<o2::dataformats::FileMetaData>();
54 auto tfcounter = o2::header::get<o2::header::DataHeader*>(pc.
inputs().
get(
"clusters").header)->tfCounter;
56 auto cluTR = pc.
inputs().
get<gsl::span<TriggerRecord>>(
"cluTR");
58 LOG(detail) <<
"Processing TF with " <<
clusters.size() <<
" clusters and " << cluTR.size() <<
" TriggerRecords";
59 mCalibrator->process(tfcounter,
clusters, cluTR);
65 if (mWriteRootOutput) {
66 std::string runNumber = mHistoFileMetaData->run;
67 std::string histoFileName = mOutputDir + fmt::format(
"PHOS_RunByRunCalib_{}.root", runNumber);
68 TFile histoFileOut(histoFileName.c_str(),
"recreate");
69 mCalibrator->writeHistos();
73 if (mMetaFileDir.compare(
"/dev/null")) {
74 mHistoFileMetaData->fillFileData(histoFileName);
75 mHistoFileMetaData->type =
"calib";
76 mHistoFileMetaData->priority =
"high";
78 std::string metaFileNameTmp = mMetaFileDir + fmt::format(
"PHOS_RunByRunCalib_{}.tmp", runNumber);
79 std::string metaFileName = mMetaFileDir + fmt::format(
"PHOS_RunByRunCalib_{}.done", runNumber);
81 std::ofstream metaFileOut(metaFileNameTmp);
82 metaFileOut << *mHistoFileMetaData.get();
84 std::filesystem::rename(metaFileNameTmp, metaFileName);
85 }
catch (std::exception
const&
e) {
86 LOG(
error) <<
"Failed to store PHOS meta data file " << metaFileName <<
", reason: " <<
e.what();
88 LOG(info) <<
"Stored metadate file " << metaFileName <<
".done";
90 LOG(info) <<
"Did not store metafile as meta-dir=" << mMetaFileDir;
93 mRunByRun = mCalibrator->getCalibration();
95 LOG(info) <<
"End of stream reached, sending output to CCDB";
98 std::map<std::string, std::string> md;
100 info.setMetaData(md);
103 LOG(info) <<
"Sending object " << info.getPath() <<
"/" << info.getFileName()
104 <<
" of size " <<
image->size()
105 <<
" bytes, valid for " << info.getStartValidityTimestamp()
106 <<
" : " << info.getEndValidityTimestamp();
111 LOG(alarm) <<
"Incorrect fit results: " << mRunByRun[0] <<
"+-" << mRunByRun[1] <<
", "
112 << mRunByRun[2] <<
"+-" << mRunByRun[3] <<
", "
113 << mRunByRun[4] <<
"+-" << mRunByRun[5] <<
", "
114 << mRunByRun[6] <<
"+-" << mRunByRun[7];
120 mCalibrator->initOutput();
125 const float massmin = 0.125;
126 const float massmax = 0.155;
127 for (
int mod = 0; mod < 4; mod++) {
128 res &= mRunByRun[2 * mod] < massmax && mRunByRun[2 * mod] > massmin;
136 std::vector<OutputSpec> outputs;
140 std::vector<InputSpec> inputs;
141 inputs.emplace_back(
"clusters",
"PHS",
"CLUSTERS");
142 inputs.emplace_back(
"cluTR",
"PHS",
"CLUSTERTRIGREC");
143 auto ccdbRequest = std::make_shared<o2::base::GRPGeomRequest>(
true,
151 "calib-phos-runbyrun",
154 AlgorithmSpec{adaptFromTask<PHOSRunbyrunCalibDevice>(ccdbRequest, outputDir, metaFileDir, writeRootOutput)},
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
char error[CURL_ERROR_SIZE]
Device to calculate PHOS time shift (L1phase)
void checkUpdates(o2::framework::ProcessingContext &pc)
static GRPGeomHelper & instance()
void setRequest(std::shared_ptr< GRPGeomRequest > req)
static std::string generateFileName(const std::string &inp)
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
static constexpr long YEAR
static constexpr long MINUTE
void snapshot(const Output &spec, T const &object)
DataAllocator & outputs()
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
void run(o2::framework::ProcessingContext &pc)
void endOfStream(o2::framework::EndOfStreamContext &ec)
void init(o2::framework::InitContext &ic)
constexpr TFType INFINITE_TF
o2::framework::DataProcessorSpec getPHOSRunbyrunCalibDeviceSpec(bool useCCDB, const std::string &outputDir, const std::string &metaFileDir, bool writeRootOutput)
static void fillTFIDInfo(o2::framework::ProcessingContext &pc, o2::dataformats::TFIDInfo &ti)
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
static std::string rectifyDirectory(const std::string_view p)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Cluster > clusters