Skip to content

Commit a701815

Browse files
committed
MFT: add scaffolding for the new CA tracker
1 parent aafbebf commit a701815

4 files changed

Lines changed: 291 additions & 0 deletions

File tree

Detectors/ITSMFT/MFT/workflow/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
o2_add_library(MFTWorkflow
1313
TARGETVARNAME targetName
1414
SOURCES src/RecoWorkflow.cxx
15+
src/CATrackerSpec.cxx
1516
src/TrackerSpec.cxx
1617
src/TrackReaderSpec.cxx
1718
src/TrackWriterSpec.cxx
@@ -25,6 +26,7 @@ o2_add_library(MFTWorkflow
2526
O2::MFTAssessment
2627
O2::DataFormatsMFT
2728
O2::ITSMFTWorkflow
29+
O2::ITStracking
2830
O2::MFTAlignment
2931
O2::GlobalTrackingWorkflowReaders)
3032
o2_add_executable(reco-workflow
@@ -51,3 +53,8 @@ o2_add_executable(tracks2records-workflow
5153
SOURCES src/mft-tracks2records-workflow.cxx
5254
COMPONENT_NAME mft
5355
PUBLIC_LINK_LIBRARIES O2::MFTWorkflow)
56+
57+
o2_add_executable(ca-tracker-workflow
58+
SOURCES src/mft-ca-tracker-workflow.cxx
59+
COMPONENT_NAME mft
60+
PUBLIC_LINK_LIBRARIES O2::MFTWorkflow)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 CATrackerSpec.h
13+
14+
#ifndef O2_MFT_CATRACKERSPEC_H_
15+
#define O2_MFT_CATRACKERSPEC_H_
16+
17+
#include <memory>
18+
#include <utility>
19+
20+
#include <gsl/span>
21+
22+
#include "DataFormatsITSMFT/ROFRecord.h"
23+
#include "DataFormatsITSMFT/TopologyDictionary.h"
24+
#include "DataFormatsParameters/GRPObject.h"
25+
#include "DetectorsBase/GRPGeomHelper.h"
26+
#include "Framework/DataProcessorSpec.h"
27+
#include "Framework/Task.h"
28+
#include "ITStracking/ROFLookupTables.h"
29+
30+
namespace o2::mft
31+
{
32+
33+
class CATrackerDPL : public o2::framework::Task
34+
{
35+
public:
36+
static constexpr int NCALayers = 5;
37+
using ROFOverlapTable = o2::its::ROFOverlapTable<NCALayers>;
38+
39+
CATrackerDPL(std::shared_ptr<o2::base::GRPGeomRequest> gr, bool useMC) : mGGCCDBRequest(std::move(gr)), mUseMC(useMC) {}
40+
~CATrackerDPL() override = default;
41+
42+
void init(framework::InitContext& ic) final;
43+
void run(framework::ProcessingContext& pc) final;
44+
void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final;
45+
46+
private:
47+
void updateTimeDependentParams(framework::ProcessingContext& pc);
48+
void initialiseROFTable(gsl::span<const o2::itsmft::ROFRecord> rofs);
49+
50+
bool mUseMC = false;
51+
std::shared_ptr<o2::base::GRPGeomRequest> mGGCCDBRequest;
52+
const o2::itsmft::TopologyDictionary* mDict = nullptr;
53+
ROFOverlapTable mROFTable;
54+
ROFOverlapTable::View mROFTableView;
55+
};
56+
57+
/// create a processor spec that reads all MFT tracker inputs and provides the
58+
/// future insertion point for wiring them into a generalized ITS TimeFrame.
59+
o2::framework::DataProcessorSpec getCATrackerSpec(bool useMC, bool useGeom, bool useIRFrames);
60+
61+
} // namespace o2::mft
62+
63+
#endif // O2_MFT_CATRACKERSPEC_H_
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
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 CATrackerSpec.cxx
13+
14+
#include "MFTWorkflow/CATrackerSpec.h"
15+
16+
#include <vector>
17+
18+
#include <gsl/span>
19+
20+
#include "CommonConstants/LHCConstants.h"
21+
#include "CommonDataFormat/IRFrame.h"
22+
#include "DataFormatsITSMFT/CompCluster.h"
23+
#include "DataFormatsITSMFT/DPLAlpideParam.h"
24+
#include "DataFormatsITSMFT/ROFRecord.h"
25+
#include "DataFormatsITSMFT/TopologyDictionary.h"
26+
#include "DataFormatsParameters/GRPObject.h"
27+
#include "DetectorsBase/GeometryManager.h"
28+
#include "DetectorsCommonDataFormats/DetectorNameConf.h"
29+
#include "Framework/CCDBParamSpec.h"
30+
#include "Framework/ConfigParamRegistry.h"
31+
#include "Framework/ControlService.h"
32+
#include "Framework/DataProcessorSpec.h"
33+
#include "Framework/DeviceSpec.h"
34+
#include "Framework/Logger.h"
35+
#include "MFTBase/GeometryTGeo.h"
36+
#include "SimulationDataFormat/MCCompLabel.h"
37+
#include "SimulationDataFormat/MCTruthContainer.h"
38+
39+
using namespace o2::framework;
40+
41+
namespace o2::mft
42+
{
43+
44+
void CATrackerDPL::init(InitContext&)
45+
{
46+
o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest);
47+
}
48+
49+
void CATrackerDPL::run(ProcessingContext& pc)
50+
{
51+
updateTimeDependentParams(pc);
52+
53+
auto compClusters = pc.inputs().get<const std::vector<o2::itsmft::CompClusterExt>>("compClusters");
54+
gsl::span<const unsigned char> patterns = pc.inputs().get<gsl::span<unsigned char>>("patterns");
55+
auto rofs = pc.inputs().get<const std::vector<o2::itsmft::ROFRecord>>("ROframes");
56+
initialiseROFTable(gsl::span<const o2::itsmft::ROFRecord>(rofs.data(), rofs.size()));
57+
58+
const dataformats::MCTruthContainer<MCCompLabel>* labels = nullptr;
59+
if (mUseMC) {
60+
labels = pc.inputs().get<const dataformats::MCTruthContainer<MCCompLabel>*>("labels").release();
61+
}
62+
63+
LOGP(info, "MFT CA input pulled {} compressed clusters, {} pattern bytes, {} RO frames, dictionary={}, MC labels={}",
64+
compClusters.size(), patterns.size(), rofs.size(), mDict != nullptr, labels != nullptr);
65+
66+
size_t nClusterRefs = 0;
67+
for (const auto& rof : rofs) {
68+
nClusterRefs += rof.getNEntries();
69+
}
70+
LOGP(info, "MFT CA input ROF cluster references: {}", nClusterRefs);
71+
72+
if (pc.inputs().getPos("IRFramesITS") >= 0) {
73+
auto irFrames = pc.inputs().get<gsl::span<o2::dataformats::IRFrame>>("IRFramesITS");
74+
LOGP(info, "MFT CA input pulled {} ITS IR frames", irFrames.size());
75+
}
76+
77+
// Next step: replace this inspection point with a loader into a generalized
78+
// ITS TimeFrame interface that accepts MFT layer geometry and cluster data.
79+
}
80+
81+
void CATrackerDPL::updateTimeDependentParams(ProcessingContext& pc)
82+
{
83+
o2::base::GRPGeomHelper::instance().checkUpdates(pc);
84+
static bool initOnceDone = false;
85+
if (!initOnceDone) {
86+
initOnceDone = true;
87+
if (pc.inputs().getPos("mftTGeo") >= 0) {
88+
pc.inputs().get<o2::mft::GeometryTGeo*>("mftTGeo");
89+
}
90+
pc.inputs().get<o2::itsmft::TopologyDictionary*>("cldict");
91+
o2::mft::GeometryTGeo::Instance()->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L,
92+
o2::math_utils::TransformType::T2GRot,
93+
o2::math_utils::TransformType::T2G));
94+
}
95+
}
96+
97+
void CATrackerDPL::initialiseROFTable(gsl::span<const o2::itsmft::ROFRecord> rofs)
98+
{
99+
if (!o2::base::GRPGeomHelper::instance().getGRPECS()->isDetContinuousReadOut(o2::detectors::DetID::MFT)) {
100+
LOGP(fatal, "MFT CA tracker currently supports only continuous readout");
101+
}
102+
103+
const auto& par = o2::itsmft::DPLAlpideParam<o2::detectors::DetID::MFT>::Instance();
104+
const int nOrbitsPerTF = o2::base::GRPGeomHelper::getNHBFPerTF();
105+
const int timingSourceLayer = 0; // MFT CA disks share timing for now; keep per-CA-layer definition for future staggering.
106+
const unsigned int nROFsPerOrbit = o2::constants::lhc::LHCMaxBunches / par.getROFLengthInBC(timingSourceLayer);
107+
const auto nROFsTF = nROFsPerOrbit * nOrbitsPerTF;
108+
109+
ROFOverlapTable rofTable;
110+
for (int caLayer = 0; caLayer < NCALayers; ++caLayer) {
111+
const o2::its::LayerTiming timing{
112+
.mNROFsTF = nROFsTF,
113+
.mROFLength = static_cast<uint32_t>(par.getROFLengthInBC(timingSourceLayer)),
114+
.mROFDelay = static_cast<uint32_t>(par.getROFDelayInBC(timingSourceLayer)),
115+
.mROFBias = static_cast<uint32_t>(par.getROFBiasInBC(timingSourceLayer)),
116+
.mROFAddTimeErr = 0};
117+
rofTable.defineLayer(caLayer, timing);
118+
}
119+
rofTable.init();
120+
mROFTable = std::move(rofTable);
121+
mROFTableView = mROFTable.getView();
122+
123+
if (rofs.size() != nROFsTF) {
124+
LOGP(warn, "MFT CA ROF count differs from continuous timing expectation: received {} expected {}", rofs.size(), nROFsTF);
125+
}
126+
LOGP(info, "MFT CA ROF lookup table initialised for {} CA layers, {} ROFs/TF, ROF length {} BC, bias {} BC",
127+
NCALayers, nROFsTF, par.getROFLengthInBC(timingSourceLayer), par.getROFBiasInBC(timingSourceLayer));
128+
}
129+
130+
void CATrackerDPL::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
131+
{
132+
if (o2::base::GRPGeomHelper::instance().finaliseCCDB(matcher, obj)) {
133+
return;
134+
}
135+
if (matcher == ConcreteDataMatcher("MFT", "CLUSDICT", 0)) {
136+
LOG(info) << "MFT CA input cluster dictionary updated";
137+
mDict = static_cast<const o2::itsmft::TopologyDictionary*>(obj);
138+
return;
139+
}
140+
if (matcher == ConcreteDataMatcher("MFT", "GEOMTGEO", 0)) {
141+
LOG(info) << "MFT CA input GeometryTGeo loaded from CCDB";
142+
o2::mft::GeometryTGeo::adopt(static_cast<o2::mft::GeometryTGeo*>(obj));
143+
return;
144+
}
145+
}
146+
147+
DataProcessorSpec getCATrackerSpec(bool useMC, bool useGeom, bool useIRFrames)
148+
{
149+
std::vector<InputSpec> inputs;
150+
inputs.emplace_back("compClusters", "MFT", "COMPCLUSTERS", 0, Lifetime::Timeframe);
151+
inputs.emplace_back("patterns", "MFT", "PATTERNS", 0, Lifetime::Timeframe);
152+
inputs.emplace_back("ROframes", "MFT", "CLUSTERSROF", 0, Lifetime::Timeframe);
153+
inputs.emplace_back("cldict", "MFT", "CLUSDICT", 0, Lifetime::Condition, ccdbParamSpec("MFT/Calib/ClusterDictionary"));
154+
155+
if (useMC) {
156+
inputs.emplace_back("labels", "MFT", "CLUSTERSMCTR", 0, Lifetime::Timeframe);
157+
}
158+
if (useIRFrames) {
159+
inputs.emplace_back("IRFramesITS", "ITS", "IRFRAMES", 0, Lifetime::Timeframe);
160+
}
161+
162+
auto ggRequest = std::make_shared<o2::base::GRPGeomRequest>(false, // orbitResetTime
163+
true, // GRPECS=true
164+
false, // GRPLHCIF
165+
true, // GRPMagField
166+
false, // askMatLUT
167+
useGeom ? o2::base::GRPGeomRequest::Aligned : o2::base::GRPGeomRequest::None, // geometry
168+
inputs,
169+
true);
170+
if (!useGeom) {
171+
ggRequest->addInput({"mftTGeo", "MFT", "GEOMTGEO", 0, Lifetime::Condition, framework::ccdbParamSpec("MFT/Config/Geometry")}, inputs);
172+
}
173+
174+
return DataProcessorSpec{
175+
"mft-ca-tracker",
176+
inputs,
177+
{},
178+
AlgorithmSpec{adaptFromTask<CATrackerDPL>(ggRequest, useMC)},
179+
Options{}};
180+
}
181+
182+
} // namespace o2::mft
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 mft-ca-tracker-workflow.cxx
13+
14+
#include <vector>
15+
16+
#include "Framework/ConfigParamSpec.h"
17+
#include "MFTWorkflow/CATrackerSpec.h"
18+
19+
using namespace o2::framework;
20+
21+
void customize(std::vector<ConfigParamSpec>& workflowOptions)
22+
{
23+
workflowOptions.push_back(ConfigParamSpec{"disable-mc", VariantType::Bool, false, {"disable MC labels"}});
24+
workflowOptions.push_back(ConfigParamSpec{"use-geom", VariantType::Bool, false, {"use geometry from the global geometry manager"}});
25+
workflowOptions.push_back(ConfigParamSpec{"use-irframes", VariantType::Bool, false, {"consume ITS IR frames"}});
26+
}
27+
28+
#include "Framework/runDataProcessing.h"
29+
30+
WorkflowSpec defineDataProcessing(ConfigContext const& config)
31+
{
32+
const bool useMC = !config.options().get<bool>("disable-mc");
33+
const bool useGeom = config.options().get<bool>("use-geom");
34+
const bool useIRFrames = config.options().get<bool>("use-irframes");
35+
36+
WorkflowSpec specs;
37+
specs.emplace_back(o2::mft::getCATrackerSpec(useMC, useGeom, useIRFrames));
38+
return specs;
39+
}

0 commit comments

Comments
 (0)