48 std::string detStr =
"TRK";
49 std::string detStrL = dec ?
"o2_trk" :
"trk";
51 auto digitSizes = std::make_shared<std::vector<size_t>>(mLayers, 0);
52 auto digitSizeGetter = [digitSizes](std::vector<o2::itsmft::Digit>
const& inDigits,
DataRef const&
ref) {
53 auto const* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
54 (*digitSizes)[dh->subSpecification] = inDigits.size();
56 auto rofSizes = std::make_shared<std::vector<size_t>>(mLayers, 0);
57 auto rofSizeGetter = [rofSizes](std::vector<o2::itsmft::ROFRecord>
const& inROFs,
DataRef const&
ref) {
58 auto const* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
59 (*rofSizes)[dh->subSpecification] = inROFs.size();
63 auto finishWriting = [](TFile* outputfile, TTree* outputtree) {
64 const auto* brArr = outputtree->GetListOfBranches();
66 for (
const auto* brc : *brArr) {
67 int64_t
n = ((
const TBranch*)brc)->GetEntries();
68 if (nent && (nent !=
n)) {
69 LOG(error) <<
"Branches have different number of entries";
73 outputtree->SetEntries(nent);
74 outputfile->Write(
"", TObject::kOverwrite);
79 auto fillLabels = [detStr, digitSizes, rofSizes](TBranch& branch, std::vector<char>
const& labelbuffer,
DataRef const&
ref) {
81 auto const* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
82 auto layer =
static_cast<size_t>(dh->subSpecification);
83 LOG(info) << detStr <<
": WRITING " <<
labels.getNElements() <<
" LABELS"
84 << std::format(
" FOR LAYER {}",
layer) <<
" WITH " << (*digitSizes)[
layer]
85 <<
" DIGITS IN " << (*rofSizes)[
layer] <<
" ROFS";
88 auto ptr = &outputcontainer;
90 outputcontainer.
adopt(labelbuffer);
95 auto getIndex = [](
DataRef const&
ref) ->
size_t {
96 auto const* dh = DataRefUtils::getHeader<o2::header::DataHeader*>(
ref);
97 return static_cast<size_t>(dh->subSpecification);
99 auto getName = [](std::string base,
size_t index) -> std::string {
103 std::vector<InputSpec> vecInpSpecDig, vecInpSpecROF, vecInpSpecLbl;
104 vecInpSpecDig.reserve(mLayers);
105 vecInpSpecROF.reserve(mLayers);
106 vecInpSpecLbl.reserve(mLayers);
107 for (
int iLayer = 0; iLayer < mLayers; iLayer++) {
108 vecInpSpecDig.emplace_back(
getName(detStr +
"digits", iLayer), Origin,
"DIGITS", iLayer);
109 vecInpSpecROF.emplace_back(
getName(detStr +
"digitsROF", iLayer), Origin,
"DIGITSROF", iLayer);
110 vecInpSpecLbl.emplace_back(
getName(detStr +
"_digitsMCTR", iLayer), Origin,
"DIGITSMCTR", iLayer);
114 (detStrL +
"digits.root").c_str(),
118 detStr +
"Digit",
"digit-branch",
124 detStr +
"DigitROF",
"digit-rof-branch",
130 detStr +
"DigitMCTruth",
"digit-mctruth-branch",
131 (mctruth ? mLayers : 0),
136 detStr +
"Calib",
"digit-calib-branch",