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
3538template <typename T>
3639using BranchDefinition = MakeRootTreeWriterSpec::BranchDefinition<T>;
37- using ClustersType = std::vector<o2::trkft3::TRKCluster>;
3840using PatternsType = std::vector<unsigned char >;
3941using ROFrameType = std::vector<o2::trkft3::ROFRecord>;
4042using 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
0 commit comments