Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class CalibdEdx
}
void fill(const TFIDInfo& tfid, const std::vector<TrackTPC>& tracks) { fill(tfid, gsl::span(tracks)); }

const TFIDInfo& getTFID() const { return mTFID; }

/// Add counts from another container.
void merge(const CalibdEdx* other);

Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Detectors/TPC/calibration/src/CalibdEdx.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions Detectors/TPC/calibration/src/CalibratordEdx.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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<TFile>(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());
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions Detectors/TPC/workflow/src/CalibdEdxSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<o2::tpc::CalibdEdxCorrection>("CalibdEdxCorrection");
auto timeGain = fdEdxCustom->Get<o2::tpc::CalibdEdxCorrection>("CalibdEdxCorrection");

if (!timeGain) {
timeGain = fdEdxCustom->Get<o2::tpc::CalibdEdxCorrection>("ccdb_object");
}

if (!timeGain) {
LOGP(error, "Could not load 'CalibdEdxCorrection' from file {}", mCustomdEdxFileName);
} else {
Expand Down Expand Up @@ -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");
Expand Down