Skip to content

Commit e3f8dd2

Browse files
committed
Fix digitizer and digit/cluster writers
1 parent 59e23c5 commit e3f8dd2

7 files changed

Lines changed: 64 additions & 23 deletions

File tree

Detectors/Upgrades/ALICE3/TRKFT3/common/workflow/include/TRKWorkflow/ClusterWriterSpec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
namespace o2::trk
1818
{
1919

20+
framework::DataProcessorSpec getTRKClusterWriterSpec(bool useMC);
21+
framework::DataProcessorSpec getFT3ClusterWriterSpec(bool useMC);
2022
framework::DataProcessorSpec getClusterWriterSpec(bool useMC);
2123

2224
} // namespace o2::trk

Detectors/Upgrades/ALICE3/TRKFT3/common/workflow/include/TRKWorkflow/DigitWriterSpec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace trk
2020
{
2121

2222
o2::framework::DataProcessorSpec getTRKDigitWriterSpec(bool mctruth = true, bool dec = false, bool calib = false);
23+
o2::framework::DataProcessorSpec getFT3DigitWriterSpec(bool mctruth = true, bool dec = false, bool calib = false);
2324
} // namespace trk
2425
} // end namespace o2
2526

Detectors/Upgrades/ALICE3/TRKFT3/common/workflow/src/ClusterWriterSpec.cxx

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
#include "Framework/ConcreteDataMatcher.h"
2222
#include "Framework/DataRef.h"
2323
#include "TRKBase/AlmiraParam.h"
24+
#include "TRKBase/Specs.h"
2425
#include "DPLUtils/MakeRootTreeWriterSpec.h"
2526
#include "DataFormatsTRKFT3/Cluster.h"
2627
#include "DataFormatsTRKFT3/ROFRecord.h"
28+
#include "DetectorsCommonDataFormats/DetID.h"
29+
#include "Headers/DataHeader.h"
2730
#include "SimulationDataFormat/MCCompLabel.h"
2831
#include "SimulationDataFormat/MCTruthContainer.h"
2932

@@ -34,15 +37,17 @@ namespace o2::trk
3437

3538
template <typename T>
3639
using BranchDefinition = MakeRootTreeWriterSpec::BranchDefinition<T>;
37-
using ClustersType = std::vector<o2::trkft3::TRKCluster>;
3840
using PatternsType = std::vector<unsigned char>;
3941
using ROFrameType = std::vector<o2::trkft3::ROFRecord>;
4042
using LabelsType = o2::dataformats::MCTruthContainer<o2::MCCompLabel>;
4143

42-
DataProcessorSpec getClusterWriterSpec(bool useMC)
44+
template <int DetID>
45+
DataProcessorSpec getClusterWriterSpecT(bool useMC)
4346
{
44-
static constexpr o2::header::DataOrigin Origin{o2::header::gDataOriginTRK};
45-
static constexpr int nLayers = o2::trk::AlmiraParam::kNLayers;
47+
static_assert(DetID == o2::detectors::DetID::TRK || DetID == o2::detectors::DetID::FT3, "only TRK and FT3 cluster writers are supported");
48+
using ClustersType = std::vector<o2::trkft3::Cluster<DetID>>;
49+
static constexpr o2::header::DataOrigin Origin = DetID == o2::detectors::DetID::TRK ? o2::header::gDataOriginTRK : o2::header::gDataOriginFT3;
50+
const int nLayers = DetID == o2::detectors::DetID::TRK ? o2::trk::AlmiraParam::kNLayers : o2::trk::constants::MLOTDisks::nLayers;
4651
const auto detName = Origin.as<std::string>();
4752

4853
auto compClusterSizes = std::make_shared<std::vector<size_t>>(nLayers, 0);
@@ -72,37 +77,52 @@ DataProcessorSpec getClusterWriterSpec(bool useMC)
7277
vecInpSpecROF.reserve(nLayers);
7378
vecInpSpecLbl.reserve(nLayers);
7479
for (int iLayer = 0; iLayer < nLayers; iLayer++) {
75-
vecInpSpecClus.emplace_back(getName("compclus", iLayer), Origin, "COMPCLUSTERS", iLayer);
76-
vecInpSpecPatt.emplace_back(getName("patterns", iLayer), Origin, "PATTERNS", iLayer);
77-
vecInpSpecROF.emplace_back(getName("ROframes", iLayer), Origin, "CLUSTERSROF", iLayer);
78-
vecInpSpecLbl.emplace_back(getName("labels", iLayer), Origin, "CLUSTERSMCTR", iLayer);
80+
vecInpSpecClus.emplace_back(getName(detName + "compclus", iLayer), Origin, "COMPCLUSTERS", iLayer);
81+
vecInpSpecPatt.emplace_back(getName(detName + "patterns", iLayer), Origin, "PATTERNS", iLayer);
82+
vecInpSpecROF.emplace_back(getName(detName + "ROframes", iLayer), Origin, "CLUSTERSROF", iLayer);
83+
vecInpSpecLbl.emplace_back(getName(detName + "labels", iLayer), Origin, "CLUSTERSMCTR", iLayer);
7984
}
8085

8186
return MakeRootTreeWriterSpec(std::format("{}-cluster-writer", detNameLC).c_str(),
82-
"o2clus_trk.root",
83-
MakeRootTreeWriterSpec::TreeAttributes{.name = "o2sim", .title = "Tree with TRK clusters"},
87+
std::format("o2clus_{}.root", detNameLC).c_str(),
88+
MakeRootTreeWriterSpec::TreeAttributes{.name = "o2sim", .title = "Tree with " + detName + " clusters"},
8489
BranchDefinition<ClustersType>{vecInpSpecClus,
85-
"TRKClusterComp", "compact-cluster-branch",
90+
detName + "ClusterComp", "compact-cluster-branch",
8691
nLayers,
8792
compClustersSizeGetter,
8893
getIndex,
8994
getName},
9095
BranchDefinition<PatternsType>{vecInpSpecPatt,
91-
"TRKClusterPatt", "cluster-pattern-branch",
96+
detName + "ClusterPatt", "cluster-pattern-branch",
9297
nLayers,
9398
getIndex,
9499
getName},
95100
BranchDefinition<ROFrameType>{vecInpSpecROF,
96-
"TRKClustersROF", "cluster-rof-branch",
101+
detName + "ClustersROF", "cluster-rof-branch",
97102
nLayers,
98103
logger,
99104
getIndex,
100105
getName},
101106
BranchDefinition<LabelsType>{vecInpSpecLbl,
102-
"TRKClusterMCTruth", "cluster-label-branch",
107+
detName + "ClusterMCTruth", "cluster-label-branch",
103108
(useMC ? nLayers : 0),
104109
getIndex,
105110
getName})();
106111
}
107112

113+
DataProcessorSpec getTRKClusterWriterSpec(bool useMC)
114+
{
115+
return getClusterWriterSpecT<o2::detectors::DetID::TRK>(useMC);
116+
}
117+
118+
DataProcessorSpec getFT3ClusterWriterSpec(bool useMC)
119+
{
120+
return getClusterWriterSpecT<o2::detectors::DetID::FT3>(useMC);
121+
}
122+
123+
DataProcessorSpec getClusterWriterSpec(bool useMC)
124+
{
125+
return getTRKClusterWriterSpec(useMC);
126+
}
127+
108128
} // namespace o2::trk

Detectors/Upgrades/ALICE3/TRKFT3/common/workflow/src/DigitWriterSpec.cxx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Framework/ConcreteDataMatcher.h"
1616
#include "Framework/DataRef.h"
1717
#include "TRKBase/AlmiraParam.h"
18+
#include "TRKBase/Specs.h"
1819
#include "DPLUtils/MakeRootTreeWriterSpec.h"
1920
#include "DataFormatsTRKFT3/Digit.h"
2021
#include "DataFormatsITSMFT/GBTCalibData.h"
@@ -27,6 +28,7 @@
2728
#include <vector>
2829
#include <string>
2930
#include <algorithm>
31+
#include <cctype>
3032
#include <format>
3133

3234
using namespace o2::framework;
@@ -41,12 +43,18 @@ template <typename T>
4143
using BranchDefinition = MakeRootTreeWriterSpec::BranchDefinition<T>;
4244
using MCCont = o2::dataformats::ConstMCTruthContainer<o2::MCCompLabel>;
4345

44-
DataProcessorSpec getTRKDigitWriterSpec(bool mctruth, bool dec, bool calib)
46+
template <int DetID>
47+
DataProcessorSpec getDigitWriterSpec(bool mctruth, bool dec, bool calib)
4548
{
46-
static constexpr o2::header::DataOrigin Origin = o2::header::gDataOriginTRK;
47-
const int mLayers = o2::trk::AlmiraParam::kNLayers;
48-
std::string detStr = "TRK";
49-
std::string detStrL = dec ? "o2_trk" : "trk";
49+
static_assert(DetID == o2::detectors::DetID::TRK || DetID == o2::detectors::DetID::FT3, "only TRK and FT3 digit writers are supported");
50+
static constexpr o2::header::DataOrigin Origin = DetID == o2::detectors::DetID::TRK ? o2::header::gDataOriginTRK : o2::header::gDataOriginFT3;
51+
const int mLayers = DetID == o2::detectors::DetID::TRK ? o2::trk::AlmiraParam::kNLayers : o2::trk::constants::MLOTDisks::nLayers;
52+
std::string detStr = o2::detectors::DetID(DetID).getName();
53+
auto detStrL = detStr;
54+
std::transform(detStrL.begin(), detStrL.end(), detStrL.begin(), [](unsigned char c) { return std::tolower(c); });
55+
if (dec) {
56+
detStrL = "o2_" + detStrL;
57+
}
5058

5159
auto digitSizes = std::make_shared<std::vector<size_t>>(mLayers, 0);
5260
auto digitSizeGetter = [digitSizes](std::vector<o2::trkft3::Digit> const& inDigits, DataRef const& ref) {
@@ -110,7 +118,7 @@ DataProcessorSpec getTRKDigitWriterSpec(bool mctruth, bool dec, bool calib)
110118
vecInpSpecLbl.emplace_back(getName(detStr + "_digitsMCTR", iLayer), Origin, "DIGITSMCTR", iLayer);
111119
}
112120

113-
return MakeRootTreeWriterSpec(("TRKDigitWriter" + std::string(dec ? "_dec" : "")).c_str(),
121+
return MakeRootTreeWriterSpec((detStr + "DigitWriter" + std::string(dec ? "_dec" : "")).c_str(),
114122
(detStrL + "digits.root").c_str(),
115123
MakeRootTreeWriterSpec::TreeAttributes{.name = "o2sim", .title = detStr + " Digits tree"},
116124
MakeRootTreeWriterSpec::CustomClose(finishWriting),
@@ -137,5 +145,15 @@ DataProcessorSpec getTRKDigitWriterSpec(bool mctruth, bool dec, bool calib)
137145
(calib ? 1 : 0)})();
138146
}
139147

148+
DataProcessorSpec getTRKDigitWriterSpec(bool mctruth, bool dec, bool calib)
149+
{
150+
return getDigitWriterSpec<o2::detectors::DetID::TRK>(mctruth, dec, calib);
151+
}
152+
153+
DataProcessorSpec getFT3DigitWriterSpec(bool mctruth, bool dec, bool calib)
154+
{
155+
return getDigitWriterSpec<o2::detectors::DetID::FT3>(mctruth, dec, calib);
156+
}
157+
140158
} // end namespace trk
141159
} // end namespace o2

Steer/DigitizerWorkflow/src/SimpleDigitizerWorkflow.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
674674
if (isEnabled(o2::detectors::DetID::FT3)) {
675675
detList.emplace_back(o2::detectors::DetID::FT3);
676676
specs.emplace_back(o2::trkft3::getFT3DigitizerSpec(fanoutsize++, mctruth));
677+
specs.emplace_back(o2::trk::getFT3DigitWriterSpec(mctruth));
677678
}
678679

679680
// the ALICE 3 IOTOF part

Steer/DigitizerWorkflow/src/TRKDigitizerSpec.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "DataFormatsTRKFT3/ROFRecord.h"
3030
#include "TRKFT3Simulation/Digitizer.h"
3131
#include "TRKFT3Simulation/DPLDigitizerParam.h"
32-
#include "FT3Base/FT3BaseParam.h"
3332
#include "FT3Base/GeometryTGeo.h"
3433
#include "TRKBase/AlmiraParam.h"
3534
#include "TRKBase/GeometryTGeo.h"
@@ -276,7 +275,7 @@ class TRKFT3DPLDigitizerTask : BaseDPLDigitizer
276275
geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G));
277276
geom->Print();
278277
mDigitizer.setGeometry(geom);
279-
mLayers = geom->getNumberOfLayers();
278+
mLayers = getNLayers<N>();
280279
}
281280
if (mLayers > static_cast<int>(o2::trkft3::DigiParams<N>::getMaxLayers())) {
282281
LOGP(fatal, "{} geometry has {} layers, but DigiParams supports at most {}", ID.getName(), mLayers, o2::trkft3::DigiParams<N>::getMaxLayers());

run/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ target_link_libraries(allsim
4646
$<$<BOOL:${ENABLE_UPGRADES}>:O2::IOTOFSimulation>
4747
$<$<BOOL:${ENABLE_UPGRADES}>:O2::RICHSimulation>
4848
$<$<BOOL:${ENABLE_UPGRADES}>:O2::ECalSimulation>
49-
$<$<BOOL:${ENABLE_UPGRADES}>:O2::FD3Simulation>
49+
$<$<BOOL:${ENABLE_UPGRADES}>:O2::FD3Simulation>
5050
$<$<BOOL:${ENABLE_UPGRADES}>:O2::MI3Simulation>
5151
O2::Generators)
5252

0 commit comments

Comments
 (0)