Skip to content

Commit 4471254

Browse files
committed
Removed unused includes, directly write the TTree object to CCDB without TMem file, small fixes
1 parent 2075879 commit 4471254

File tree

7 files changed

+25
-52
lines changed

7 files changed

+25
-52
lines changed

DataFormats/Detectors/TPC/include/DataFormatsTPC/CMV.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#ifndef ALICEO2_DATAFORMATSTPC_CMV_H
2121
#define ALICEO2_DATAFORMATSTPC_CMV_H
2222

23-
#include <bitset>
23+
#include <cstdint>
2424

2525
namespace o2::tpc::cmv
2626
{

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ struct CMVContainer {
6363

6464
/// Write the container as a TTree inside a TFile on disk
6565
/// \param filename path to the output ROOT file
66-
void writeToFile(const std::string& filename) const;
66+
/// \param tree tree of the container
67+
void writeToFile(const std::string& filename, const std::unique_ptr<TTree>& tree) const;
6768

6869
/// Restore a CMVContainer from a TTree previously written by toTTree()
6970
static CMVContainer fromTTree(TTree* tree, int entry = 0);

Detectors/TPC/calibration/src/CMVContainer.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ std::unique_ptr<TTree> CMVContainer::toTTree() const
7575
throw std::runtime_error("CMVContainer::toTTree() called on empty container");
7676
}
7777

78-
auto tree = std::make_unique<TTree>("CMVTree", "TPC common mode values");
78+
auto tree = std::make_unique<TTree>("ccdb_object", "ccdb_object");
7979
tree->SetAutoSave(0);
80+
tree->SetDirectory(nullptr);
8081

81-
// Point branches directly at the vector data — single Fill() call writes all rows
82+
// Point branches directly at the vector data
8283
float* pCmv = const_cast<float*>(cmvValues.data());
8384
uint32_t* pCru = const_cast<uint32_t*>(cru.data());
8485
uint32_t* pTimebin = const_cast<uint32_t*>(timebin.data());
@@ -93,13 +94,12 @@ std::unique_ptr<TTree> CMVContainer::toTTree() const
9394
return tree;
9495
}
9596

96-
void CMVContainer::writeToFile(const std::string& filename) const
97+
void CMVContainer::writeToFile(const std::string& filename, const std::unique_ptr<TTree>& tree) const
9798
{
9899
TFile f(filename.c_str(), "RECREATE");
99100
if (f.IsZombie()) {
100101
throw std::runtime_error(fmt::format("CMVContainer::writeToFile: cannot open '{}'", filename));
101102
}
102-
auto tree = toTTree();
103103
tree->Write();
104104
f.Close();
105105
}

Detectors/TPC/workflow/include/TPCWorkflow/CMVToVectorSpec.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#define TPC_CMVToVectorSpec_H_
1818

1919
#include "Framework/DataProcessorSpec.h"
20-
#include <string_view>
2120

2221
namespace o2::tpc
2322
{

Detectors/TPC/workflow/include/TPCWorkflow/TPCFactorizeCMVSpec.h

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include <chrono>
2121
#include <fmt/format.h>
2222

23-
#include "TMemFile.h"
24-
2523
#include "Framework/Task.h"
2624
#include "Framework/ControlService.h"
2725
#include "Framework/Logger.h"
@@ -198,7 +196,7 @@ class TPCFactorizeCMVDevice : public o2::framework::Task
198196
mTimestampStart = mUsePreciseTimestamp
199197
? (mTFInfo.first + (tinfo.firstTForbit - nOrbitsOffset) * o2::constants::lhc::LHCOrbitMUS * 0.001)
200198
: tinfo.creation;
201-
LOGP(info, "setting time stamp reset reference to: {}, at tfCounter: {}, firstTForbit: {}, NHBFPerTF: {}, relTF: {}, nOrbitsOffset: {}",
199+
LOGP(info, "Setting timestamp reset reference to: {}, at tfCounter: {}, firstTForbit: {}, NHBFPerTF: {}, relTF: {}, nOrbitsOffset: {}",
202200
mTFInfo.first, tinfo.tfCounter, tinfo.firstTForbit, mTFInfo.second, relTF, nOrbitsOffset);
203201
}
204202

@@ -219,57 +217,45 @@ class TPCFactorizeCMVDevice : public o2::framework::Task
219217
const long offsetCCDB = mOffsetCCDB ? o2::ccdb::CcdbObjectInfo::HOUR : 0;
220218
const long timeStampEnd = offsetCCDB + mTimestampStart +
221219
mNOrbitsCMV * mTimeFrames * mNTFsBuffer * o2::constants::lhc::LHCOrbitMUS * 0.001;
222-
LOGP(info, "Setting time stamp range from {} to {} for writing to CCDB with an offset of {}",
220+
LOGP(info, "Setting timestamp range from {} to {} for writing to CCDB with an offset of {}",
223221
mTimestampStart, timeStampEnd, offsetCCDB);
224222

225-
// Write local ROOT file for debugging
226-
if (mDumpCMVs) {
227-
const std::string fname = fmt::format("CMV_lane{:02}_TS{}.root", mLaneId, mTimestampStart);
228-
try {
229-
mContainer.writeToFile(fname);
230-
LOGP(info, "CMV debug file written to {}", fname);
231-
} catch (const std::exception& e) {
232-
LOGP(error, "Failed to write CMV debug file: {}", e.what());
233-
}
234-
}
235-
236223
if (mSendCCDB && timeStampEnd > mTimestampStart) {
237224
auto start = timer::now();
238225

239-
// Build a TMemFile containing the TTree, hand it to CcdbApi for serialisation
240-
TMemFile memFile("CMV.root", "RECREATE");
241-
try {
242-
auto tree = mContainer.toTTree();
243-
memFile.cd();
244-
tree->Write();
245-
} catch (const std::exception& e) {
246-
LOGP(error, "CMVContainer::toTTree() failed: {}", e.what());
247-
reset();
248-
return;
226+
auto tree = mContainer.toTTree();
227+
228+
// Write local ROOT file for debugging
229+
if (mDumpCMVs) {
230+
const std::string fname = fmt::format("CMV_lane{:02}_timestamp{}.root", mLaneId, mTimestampStart);
231+
try {
232+
mContainer.writeToFile(fname, tree);
233+
LOGP(info, "CMV debug file written to {}", fname);
234+
} catch (const std::exception& e) {
235+
LOGP(error, "Failed to write CMV debug file: {}", e.what());
236+
}
249237
}
250-
memFile.Write();
251238

252-
o2::ccdb::CcdbObjectInfo ccdbInfo(
239+
o2::ccdb::CcdbObjectInfo ccdbInfoCMV(
253240
"TPC/Calib/CMV",
254241
"TTree",
255242
"CMV.root",
256243
/*metadata=*/{},
257244
mTimestampStart,
258245
timeStampEnd);
259246

260-
auto image = o2::ccdb::CcdbApi::createObjectImage(&memFile, &ccdbInfo);
247+
auto image = o2::ccdb::CcdbApi::createObjectImage((tree.get()), &ccdbInfoCMV);
261248
LOGP(info, "Sending object {} / {} of size {} bytes, valid for {} : {}",
262-
ccdbInfo.getPath(), ccdbInfo.getFileName(), image->size(),
263-
ccdbInfo.getStartValidityTimestamp(), ccdbInfo.getEndValidityTimestamp());
249+
ccdbInfoCMV.getPath(), ccdbInfoCMV.getFileName(), image->size(),
250+
ccdbInfoCMV.getStartValidityTimestamp(), ccdbInfoCMV.getEndValidityTimestamp());
264251

265252
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, getDataDescriptionCCDBCMV(), 0}, *image);
266-
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, getDataDescriptionCCDBCMV(), 0}, ccdbInfo);
253+
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, getDataDescriptionCCDBCMV(), 0}, ccdbInfoCMV);
267254

268255
auto stop = timer::now();
269256
std::chrono::duration<float> elapsed = stop - start;
270257
LOGP(info, "CMV CCDB serialisation time: {:.3f} s", elapsed.count());
271258
}
272-
273259
reset();
274260
}
275261

Detectors/TPC/workflow/src/CMVToVectorSpec.cxx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,19 @@
1313
/// @author Tuba Gündem, tuba.gundem@cern.ch
1414
/// @brief Processor to convert CMVs to a vector in a CRU
1515

16-
#include <iterator>
1716
#include <limits>
1817
#include <memory>
1918
#include <stdexcept>
2019
#include <vector>
2120
#include <string>
2221
#include <fstream>
2322
#include <algorithm>
24-
#include <cassert>
25-
#include <cmath>
2623
#include <fmt/format.h>
2724
#include <fmt/chrono.h>
2825

2926
#include "TFile.h"
3027
#include "DetectorsRaw/RDHUtils.h"
3128
#include "Framework/Task.h"
32-
#include "Framework/ControlService.h"
3329
#include "Framework/ConfigParamRegistry.h"
3430
#include "Framework/Logger.h"
3531
#include "Framework/DataProcessorSpec.h"
@@ -40,23 +36,15 @@
4036
#include "Headers/DataHeader.h"
4137
#include "Headers/DataHeaderHelpers.h"
4238
#include "CommonUtils/TreeStreamRedirector.h"
43-
#include "CommonUtils/NameConf.h"
44-
#include "DataFormatsTPC/Constants.h"
45-
#include "CommonConstants/LHCConstants.h"
46-
#include "CCDB/BasicCCDBManager.h"
4739

48-
#include "DataFormatsTPC/Defs.h"
4940
#include "DataFormatsTPC/CMV.h"
5041
#include "DataFormatsTPC/RawDataTypes.h"
51-
#include "TPCBase/Utils.h"
5242
#include "TPCBase/RDHUtils.h"
5343
#include "TPCBase/Mapper.h"
5444
#include "TPCWorkflow/ProcessingHelpers.h"
5545

5646
using namespace o2::framework;
57-
using o2::constants::lhc::LHCMaxBunches;
5847
using o2::header::gDataOriginTPC;
59-
using o2::tpc::constants::LHCBCPERTIMEBIN;
6048
using RDHUtils = o2::raw::RDHUtils;
6149
using RawDataType = o2::tpc::raw_data_types::Type;
6250

Detectors/TPC/workflow/src/tpc-cmv-to-vector.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include "Algorithm/RangeTokenizer.h"
1717
#include "Framework/WorkflowSpec.h"
18-
#include "Framework/ControlService.h"
1918
#include "Framework/ConfigParamSpec.h"
2019
#include "Framework/CompletionPolicy.h"
2120
#include "Framework/CompletionPolicyHelpers.h"

0 commit comments

Comments
 (0)