diff --git a/Detectors/TPC/calibration/include/TPCCalibration/CalibdEdx.h b/Detectors/TPC/calibration/include/TPCCalibration/CalibdEdx.h index b40daa7b6e61f..20e470702a89a 100644 --- a/Detectors/TPC/calibration/include/TPCCalibration/CalibdEdx.h +++ b/Detectors/TPC/calibration/include/TPCCalibration/CalibdEdx.h @@ -121,6 +121,8 @@ class CalibdEdx } void fill(const TFIDInfo& tfid, const std::vector& tracks) { fill(tfid, gsl::span(tracks)); } + const TFIDInfo& getTFID() const { return mTFID; } + /// Add counts from another container. void merge(const CalibdEdx* other); @@ -174,10 +176,10 @@ class CalibdEdx constexpr static float recoverTgl(float scaledTgl, GEMstack rocType) { return scaledTgl * conf_dedx_corr::TglScale[rocType]; } /// dump this object to a file - the boost histogram is converted to a ROOT histogram - - void dumpToFile(const char* outFile, const char* outName) const; + void dumpToFile(const char* outFile); /// read the object from a file - static CalibdEdx readFromFile(const char* inFile, const char* inName); + static CalibdEdx readFromFile(const char* inFile); /// set lower and upper range in units of sigma which are used for the gaussian fits /// \param lowerSigma low sigma range diff --git a/Detectors/TPC/calibration/src/CalibdEdx.cxx b/Detectors/TPC/calibration/src/CalibdEdx.cxx index 2e20eacb94324..e1081335c04cb 100644 --- a/Detectors/TPC/calibration/src/CalibdEdx.cxx +++ b/Detectors/TPC/calibration/src/CalibdEdx.cxx @@ -744,18 +744,18 @@ void CalibdEdx::finalizeDebugOutput() const } } -void CalibdEdx::dumpToFile(const char* outFile, const char* outName) const +void CalibdEdx::dumpToFile(const char* outFile) { TFile f(outFile, "RECREATE"); - f.WriteObject(this, outName); + f.WriteObject(this, "calib"); const auto* thn = getRootHist(); f.WriteObject(thn, "histogram_data"); } -CalibdEdx CalibdEdx::readFromFile(const char* inFile, const char* inName) +CalibdEdx CalibdEdx::readFromFile(const char* inFile) { TFile f(inFile, "READ"); - auto* obj = (CalibdEdx*)f.Get(inName); + auto* obj = (CalibdEdx*)f.Get("calib"); if (!obj) { CalibdEdx calTmp; return calTmp; diff --git a/Detectors/TPC/calibration/src/CalibratordEdx.cxx b/Detectors/TPC/calibration/src/CalibratordEdx.cxx index 7599e2f5d4472..bd61ca2ec6b1d 100644 --- a/Detectors/TPC/calibration/src/CalibratordEdx.cxx +++ b/Detectors/TPC/calibration/src/CalibratordEdx.cxx @@ -44,10 +44,11 @@ void CalibratordEdx::finalizeSlot(Slot& slot) container->finalizeDebugOutput(); mCalibs.push_back(container->getCalib()); - TFType startTF = slot.getTFStart(); - TFType endTF = slot.getTFEnd(); - auto startTime = slot.getStartTimeMS(); - auto endTime = slot.getEndTimeMS(); + const TFType startTF = slot.getTFStart(); + const TFType endTF = slot.getTFEnd(); + const auto startTime = slot.getStartTimeMS(); + const auto endTime = slot.getEndTimeMS(); + const auto runNumber = container->getTFID().runNumber; mTFIntervals.emplace_back(startTF, endTF); mTimeIntervals.emplace_back(startTime, endTime); @@ -56,6 +57,7 @@ void CalibratordEdx::finalizeSlot(Slot& slot) LOGP(info, "Dumping time slot data to file"); auto calibCopy = container->getCalib(); *mDebugOutputStreamer << "CalibdEdx" + << "runNumber=" << runNumber << "startTF=" << startTF // Initial time frame ID of time slot << "endTF=" << endTF // Final time frame ID of time slot << "startTime=" << startTime // Initial time frame time of time slot @@ -65,17 +67,15 @@ void CalibratordEdx::finalizeSlot(Slot& slot) } if (mDumpHistograms) { - const auto fileName = fmt::format("o2tpc_CalibratordEdx_Histos_{}_{}_{}_{}.root", startTime, endTime, startTF, endTF); const auto dumpTHn = (mDumpHistograms & 0x1) == 0x1; const auto dumpTree = (mDumpHistograms & 0x2) == 0x2; if (dumpTree) { - container->writeTTree(fileName); + const auto fileNameTree = fmt::format("o2tpc_CalibratordEdx_Tree_{}_{}_{}_{}_{}.root", runNumber, startTime, endTime, startTF, endTF); + container->writeTTree(fileNameTree); } if (dumpTHn) { - auto f = std::make_unique(fileName.data(), dumpTree ? "update" : "recreate"); - auto hn = container->getRootHist(); - hn->Write("calibHist"); - f->Close(); + const auto fileName = fmt::format("o2tpc_CalibratordEdx_Histos_{}_{}_{}_{}_{}.root", runNumber, startTime, endTime, startTF, endTF); + container->dumpToFile(fileName.data()); } } } diff --git a/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx b/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx index 2eaf6125e6c29..5cf412f227d78 100644 --- a/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx +++ b/Detectors/TPC/workflow/src/CalibdEdxSpec.cxx @@ -82,7 +82,12 @@ class CalibdEdxDevice : public Task if (!fdEdxCustom || !fdEdxCustom->IsOpen() || fdEdxCustom->IsZombie()) { LOGP(error, "Could not open custom TimeGain file {}", mCustomdEdxFileName); } else { - const auto timeGain = fdEdxCustom->Get("CalibdEdxCorrection"); + auto timeGain = fdEdxCustom->Get("CalibdEdxCorrection"); + + if (!timeGain) { + timeGain = fdEdxCustom->Get("ccdb_object"); + } + if (!timeGain) { LOGP(error, "Could not load 'CalibdEdxCorrection' from file {}", mCustomdEdxFileName); } else { @@ -133,7 +138,7 @@ class CalibdEdxDevice : public Task sendOutput(eos.outputs()); if (mDumpToFile) { - mCalib->dumpToFile("calibdEdx_Obj.root", "calib"); + mCalib->dumpToFile("calibdEdx_Obj.root"); mCalib->getCalib().writeToFile("calibdEdx.root"); if (mDumpToFile > 1) { mCalib->writeTTree("calibdEdx.histo.tree.root");