Skip to content

Commit 7bb9128

Browse files
authored
ALICE3: add FT3 clusters, reader and writer (#15972)
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent e02a56e commit 7bb9128

14 files changed

Lines changed: 428 additions & 72 deletions

File tree

‎Detectors/Upgrades/ALICE3/TRKFT3/common/reconstruction/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ o2_add_library(TRKReconstruction
2323
O2::DataFormatsTRKFT3
2424
O2::SimulationDataFormat
2525
O2::TRKBase
26+
O2::FT3Base
2627
nlohmann_json::nlohmann_json
2728
${actsTarget})
2829

‎Detectors/Upgrades/ALICE3/TRKFT3/common/reconstruction/include/TRKReconstruction/Clusterer.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@
3434
#include <array>
3535
#include <memory>
3636
#include <cstring>
37+
#include <type_traits>
3738
#include <utility>
3839

40+
namespace o2::ft3
41+
{
42+
class GeometryTGeo;
43+
}
44+
3945
namespace o2::trk
4046
{
4147

@@ -56,6 +62,8 @@ class Clusterer
5662
using ClusterTruth = o2::dataformats::MCTruthContainer<o2::MCCompLabel>;
5763
using ConstDigitTruth = o2::dataformats::ConstMCTruthContainerView<o2::MCCompLabel>;
5864
using Label = o2::MCCompLabel;
65+
/// The geometry that gives a chip's sub-detector and layer.
66+
using GeometryTGeo = std::conditional_t<DetID == o2::detectors::DetID::TRK, o2::trk::GeometryTGeo, o2::ft3::GeometryTGeo>;
5967

6068
//----------------------------------------------
6169
struct BBox {

‎Detectors/Upgrades/ALICE3/TRKFT3/common/reconstruction/src/Clusterer.cxx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
/// \brief Implementation of the TRK cluster finder
1414

1515
#include "TRKReconstruction/Clusterer.h"
16+
#include "FT3Base/GeometryTGeo.h"
1617
#include "TRKBase/GeometryTGeo.h"
1718
#include "TRKBase/SegmentationChip.h"
1819

@@ -82,7 +83,7 @@ void Clusterer<DetID>::process(gsl::span<const Digit> digits,
8283
mThread = std::make_unique<ClustererThread>(this);
8384
}
8485

85-
auto* geom = o2::trk::GeometryTGeo::Instance();
86+
auto* geom = GeometryTGeo::Instance();
8687

8788
for (size_t iROF = 0; iROF < digitROFs.size(); ++iROF) {
8889
const auto& inROF = digitROFs[iROF];

‎Detectors/Upgrades/ALICE3/TRKFT3/common/workflow/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ o2_add_library(TRKWorkflow
1515
src/DigitWriterSpec.cxx
1616
src/ClustererSpec.cxx
1717
src/ClusterWriterSpec.cxx
18+
src/ClusterReaderSpec.cxx
1819
src/RecoWorkflow.cxx
1920
PUBLIC_LINK_LIBRARIES O2::Framework
2021
O2::GPUWorkflow
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// @file ClusterReaderSpec.h
13+
/// @brief Reads the TRK or FT3 clusters the cluster writer stored, one stream per layer
14+
15+
#ifndef O2_TRK_CLUSTERREADER
16+
#define O2_TRK_CLUSTERREADER
17+
18+
#include <memory>
19+
#include <string>
20+
#include <vector>
21+
22+
#include "TFile.h"
23+
#include "TTree.h"
24+
#include "DataFormatsTRKFT3/Cluster.h"
25+
#include "DataFormatsTRKFT3/ROFRecord.h"
26+
#include "SimulationDataFormat/MCCompLabel.h"
27+
#include "SimulationDataFormat/MCTruthContainer.h"
28+
#include "Framework/DataProcessorSpec.h"
29+
#include "Framework/Task.h"
30+
#include "TRKBase/AlmiraParam.h"
31+
32+
namespace o2::trk
33+
{
34+
35+
template <int DetID>
36+
class ClusterReader : public framework::Task
37+
{
38+
public:
39+
explicit ClusterReader(bool useMC);
40+
void init(framework::InitContext& ic) final;
41+
void run(framework::ProcessingContext& pc) final;
42+
43+
static constexpr int NLayers = DetID == o2::detectors::DetID::TRK ? static_cast<int>(o2::trk::AlmiraParam::kNLayers) : o2::trk::constants::MLOTDisks::nLayers;
44+
45+
private:
46+
void connectTree(const std::string& filename);
47+
template <typename Ptr>
48+
void setBranchAddress(const std::string& base, int layer, Ptr& address);
49+
50+
std::vector<std::vector<o2::trkft3::Cluster<DetID>>*> mClusters;
51+
std::vector<std::vector<unsigned char>*> mPatterns;
52+
std::vector<std::vector<o2::trkft3::ROFRecord>*> mROFs;
53+
std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>*> mLabels;
54+
55+
std::unique_ptr<TFile> mFile;
56+
std::unique_ptr<TTree> mTree;
57+
bool mUseMC = true;
58+
};
59+
60+
using TRKClusterReader = ClusterReader<o2::detectors::DetID::TRK>;
61+
using FT3ClusterReader = ClusterReader<o2::detectors::DetID::FT3>;
62+
63+
/// The reader of \a defname, by default the cluster writer's file.
64+
framework::DataProcessorSpec getTRKClusterReaderSpec(bool useMC = true, std::string defname = "o2clus_trk.root");
65+
framework::DataProcessorSpec getFT3ClusterReaderSpec(bool useMC = true, std::string defname = "o2clus_ft3.root");
66+
67+
} // namespace o2::trk
68+
69+
#endif

‎Detectors/Upgrades/ALICE3/TRKFT3/common/workflow/include/TRKWorkflow/ClustererSpec.h‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#ifndef O2_TRK_CLUSTERERDPL
1313
#define O2_TRK_CLUSTERERDPL
1414

15+
#include "DetectorsCommonDataFormats/DetID.h"
1516
#include "Framework/DataProcessorSpec.h"
1617
#include "Framework/Task.h"
17-
#include "TRKBase/AlmiraParam.h"
1818
#include "TRKReconstruction/Clusterer.h"
1919
#ifdef O2_WITH_ACTS
2020
#include "TRKReconstruction/ClustererACTS.h"
@@ -23,6 +23,8 @@
2323
namespace o2::trk
2424
{
2525

26+
/// Clusterises the digits of TRK or FT3, layer by layer.
27+
template <int DetID>
2628
class ClustererDPL : public o2::framework::Task
2729
{
2830
public:
@@ -31,17 +33,19 @@ class ClustererDPL : public o2::framework::Task
3133
void run(o2::framework::ProcessingContext& pc) final;
3234

3335
private:
34-
static constexpr int mLayers = o2::trk::AlmiraParam::kNLayers;
3536
bool mUseMC = true;
3637
int mNThreads = 1;
37-
o2::trk::TRKClusterer mClusterer;
38+
Clusterer<DetID> mClusterer;
3839
#ifdef O2_WITH_ACTS
39-
bool mUseACTS = false;
40+
bool mUseACTS = false; // TRK only
4041
o2::trk::ClustererACTS mClustererACTS;
4142
#endif
4243
};
4344

45+
/// The clusterer of TRK's digits.
4446
o2::framework::DataProcessorSpec getClustererSpec(bool useMC);
47+
/// The clusterer of FT3's digits.
48+
o2::framework::DataProcessorSpec getFT3ClustererSpec(bool useMC);
4549

4650
} // namespace o2::trk
4751

‎Detectors/Upgrades/ALICE3/TRKFT3/common/workflow/include/TRKWorkflow/DigitReaderSpec.h‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "Framework/Task.h"
2525
#include "Headers/DataHeader.h"
2626
#include "DetectorsCommonDataFormats/DetID.h"
27-
#include "TRKBase/AlmiraParam.h"
2827

2928
using namespace o2::framework;
3029

@@ -48,7 +47,7 @@ class DigitReader : public Task
4847
void setBranchAddress(const std::string& base, Ptr& addr, int layer = -1);
4948
std::string getBranchName(const std::string& base, int index) const;
5049

51-
static constexpr int mLayers = o2::trk::AlmiraParam::kNLayers;
50+
int mLayers = 0; ///< TRK's AlmiraParam entries or FT3's discs
5251

5352
std::vector<std::vector<o2::trkft3::Digit>*> mDigits{nullptr};
5453
std::vector<o2::itsmft::GBTCalibData> mCalib, *mCalibPtr = &mCalib;
@@ -84,9 +83,20 @@ class TRKDigitReader : public DigitReader
8483
}
8584
};
8685

86+
class FT3DigitReader : public DigitReader
87+
{
88+
public:
89+
FT3DigitReader(bool useMC = true, bool useCalib = false)
90+
: DigitReader(o2::detectors::DetID::FT3, useMC, useCalib)
91+
{
92+
mOrigin = o2::header::gDataOriginFT3;
93+
}
94+
};
95+
8796
/// create a processor spec
88-
/// read ITS/MFT Digit data from a root file
97+
/// read TRK/FT3 Digit data from a root file
8998
framework::DataProcessorSpec getTRKDigitReaderSpec(bool useMC = true, bool useCalib = false, std::string defname = "trkdigits.root");
99+
framework::DataProcessorSpec getFT3DigitReaderSpec(bool useMC = true, bool useCalib = false, std::string defname = "ft3digits.root");
90100

91101
} // namespace trk
92102
} // namespace o2

‎Detectors/Upgrades/ALICE3/TRKFT3/common/workflow/include/TRKWorkflow/RecoWorkflow.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@
1212
#ifndef O2_TRK_RECOWORKFLOW_H
1313
#define O2_TRK_RECOWORKFLOW_H
1414

15+
#include "DetectorsCommonDataFormats/DetID.h"
1516
#include "Framework/WorkflowSpec.h"
1617

1718
namespace o2::trk
1819
{
1920
namespace reco_workflow
2021
{
2122

23+
/// The digit readers, clusterers and cluster writers of \a detectors, TRK and/or FT3.
2224
o2::framework::WorkflowSpec getWorkflow(bool useMC,
2325
bool upstreamDigits = false,
2426
bool upstreamClusters = false,
25-
bool disableRootOutput = false);
27+
bool disableRootOutput = false,
28+
o2::detectors::DetID::mask_t detectors = o2::detectors::DetID::getMask(o2::detectors::DetID::TRK));
2629
}
2730

2831
} // namespace o2::trk

0 commit comments

Comments
 (0)