Skip to content

Commit b3e2065

Browse files
wiechulashahor02
authored andcommitted
Extend gain calibration
1 parent d4afff4 commit b3e2065

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

Detectors/TPC/calibration/include/TPCCalibration/CalibdEdx.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class CalibdEdx
121121
}
122122
void fill(const TFIDInfo& tfid, const std::vector<TrackTPC>& tracks) { fill(tfid, gsl::span(tracks)); }
123123

124+
const TFIDInfo& getTFID() const { return mTFID; }
125+
124126
/// Add counts from another container.
125127
void merge(const CalibdEdx* other);
126128

@@ -174,10 +176,10 @@ class CalibdEdx
174176
constexpr static float recoverTgl(float scaledTgl, GEMstack rocType) { return scaledTgl * conf_dedx_corr::TglScale[rocType]; }
175177

176178
/// dump this object to a file - the boost histogram is converted to a ROOT histogram -
177-
void dumpToFile(const char* outFile, const char* outName) const;
179+
void dumpToFile(const char* outFile);
178180

179181
/// read the object from a file
180-
static CalibdEdx readFromFile(const char* inFile, const char* inName);
182+
static CalibdEdx readFromFile(const char* inFile);
181183

182184
/// set lower and upper range in units of sigma which are used for the gaussian fits
183185
/// \param lowerSigma low sigma range

Detectors/TPC/calibration/src/CalibdEdx.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -744,18 +744,18 @@ void CalibdEdx::finalizeDebugOutput() const
744744
}
745745
}
746746

747-
void CalibdEdx::dumpToFile(const char* outFile, const char* outName) const
747+
void CalibdEdx::dumpToFile(const char* outFile)
748748
{
749749
TFile f(outFile, "RECREATE");
750-
f.WriteObject(this, outName);
750+
f.WriteObject(this, "calib");
751751
const auto* thn = getRootHist();
752752
f.WriteObject(thn, "histogram_data");
753753
}
754754

755-
CalibdEdx CalibdEdx::readFromFile(const char* inFile, const char* inName)
755+
CalibdEdx CalibdEdx::readFromFile(const char* inFile)
756756
{
757757
TFile f(inFile, "READ");
758-
auto* obj = (CalibdEdx*)f.Get(inName);
758+
auto* obj = (CalibdEdx*)f.Get("calib");
759759
if (!obj) {
760760
CalibdEdx calTmp;
761761
return calTmp;

Detectors/TPC/calibration/src/CalibratordEdx.cxx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ void CalibratordEdx::finalizeSlot(Slot& slot)
4444
container->finalizeDebugOutput();
4545
mCalibs.push_back(container->getCalib());
4646

47-
TFType startTF = slot.getTFStart();
48-
TFType endTF = slot.getTFEnd();
49-
auto startTime = slot.getStartTimeMS();
50-
auto endTime = slot.getEndTimeMS();
47+
const TFType startTF = slot.getTFStart();
48+
const TFType endTF = slot.getTFEnd();
49+
const auto startTime = slot.getStartTimeMS();
50+
const auto endTime = slot.getEndTimeMS();
51+
const auto runNumber = container->getTFID().runNumber;
5152

5253
mTFIntervals.emplace_back(startTF, endTF);
5354
mTimeIntervals.emplace_back(startTime, endTime);
@@ -56,6 +57,7 @@ void CalibratordEdx::finalizeSlot(Slot& slot)
5657
LOGP(info, "Dumping time slot data to file");
5758
auto calibCopy = container->getCalib();
5859
*mDebugOutputStreamer << "CalibdEdx"
60+
<< "runNumber=" << runNumber
5961
<< "startTF=" << startTF // Initial time frame ID of time slot
6062
<< "endTF=" << endTF // Final time frame ID of time slot
6163
<< "startTime=" << startTime // Initial time frame time of time slot
@@ -65,17 +67,15 @@ void CalibratordEdx::finalizeSlot(Slot& slot)
6567
}
6668

6769
if (mDumpHistograms) {
68-
const auto fileName = fmt::format("o2tpc_CalibratordEdx_Histos_{}_{}_{}_{}.root", startTime, endTime, startTF, endTF);
6970
const auto dumpTHn = (mDumpHistograms & 0x1) == 0x1;
7071
const auto dumpTree = (mDumpHistograms & 0x2) == 0x2;
7172
if (dumpTree) {
72-
container->writeTTree(fileName);
73+
const auto fileNameTree = fmt::format("o2tpc_CalibratordEdx_Tree_{}_{}_{}_{}_{}.root", runNumber, startTime, endTime, startTF, endTF);
74+
container->writeTTree(fileNameTree);
7375
}
7476
if (dumpTHn) {
75-
auto f = std::make_unique<TFile>(fileName.data(), dumpTree ? "update" : "recreate");
76-
auto hn = container->getRootHist();
77-
hn->Write("calibHist");
78-
f->Close();
77+
const auto fileName = fmt::format("o2tpc_CalibratordEdx_Histos_{}_{}_{}_{}_{}.root", runNumber, startTime, endTime, startTF, endTF);
78+
container->dumpToFile(fileName.data());
7979
}
8080
}
8181
}

Detectors/TPC/workflow/src/CalibdEdxSpec.cxx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ class CalibdEdxDevice : public Task
8282
if (!fdEdxCustom || !fdEdxCustom->IsOpen() || fdEdxCustom->IsZombie()) {
8383
LOGP(error, "Could not open custom TimeGain file {}", mCustomdEdxFileName);
8484
} else {
85-
const auto timeGain = fdEdxCustom->Get<o2::tpc::CalibdEdxCorrection>("CalibdEdxCorrection");
85+
auto timeGain = fdEdxCustom->Get<o2::tpc::CalibdEdxCorrection>("CalibdEdxCorrection");
86+
87+
if (!timeGain) {
88+
timeGain = fdEdxCustom->Get<o2::tpc::CalibdEdxCorrection>("ccdb_object");
89+
}
90+
8691
if (!timeGain) {
8792
LOGP(error, "Could not load 'CalibdEdxCorrection' from file {}", mCustomdEdxFileName);
8893
} else {
@@ -133,7 +138,7 @@ class CalibdEdxDevice : public Task
133138
sendOutput(eos.outputs());
134139

135140
if (mDumpToFile) {
136-
mCalib->dumpToFile("calibdEdx_Obj.root", "calib");
141+
mCalib->dumpToFile("calibdEdx_Obj.root");
137142
mCalib->getCalib().writeToFile("calibdEdx.root");
138143
if (mDumpToFile > 1) {
139144
mCalib->writeTTree("calibdEdx.histo.tree.root");

0 commit comments

Comments
 (0)