Skip to content

Commit 3603ce3

Browse files
committed
Make IRFrame reader/writer global devices + workflows
1 parent 12c834b commit 3603ce3

File tree

12 files changed

+158
-41
lines changed

12 files changed

+158
-41
lines changed

Detectors/GlobalTrackingWorkflow/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,5 @@ add_subdirectory(tofworkflow)
105105
add_subdirectory(tpcinterpolationworkflow)
106106
add_subdirectory(helpers)
107107
add_subdirectory(readers)
108+
add_subdirectory(writers)
108109
add_subdirectory(qc)

Detectors/GlobalTrackingWorkflow/helpers/src/InputHelper.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "Framework/ConfigParamRegistry.h"
1616
#include "ITSMFTWorkflow/ClusterReaderSpec.h"
1717
#include "ITSWorkflow/TrackReaderSpec.h"
18-
#include "ITSWorkflow/IRFrameReaderSpec.h"
1918
#include "MFTWorkflow/TrackReaderSpec.h"
2019
#include "TPCReaderWorkflow/TrackReaderSpec.h"
2120
#include "TPCReaderWorkflow/ClusterReaderSpec.h"
@@ -27,6 +26,7 @@
2726
#include "GlobalTrackingWorkflowReaders/PrimaryVertexReaderSpec.h"
2827
#include "GlobalTrackingWorkflowReaders/SecondaryVertexReaderSpec.h"
2928
#include "GlobalTrackingWorkflowReaders/TrackCosmicsReaderSpec.h"
29+
#include "GlobalTrackingWorkflowReaders/IRFrameReaderSpec.h"
3030
#include "TOFWorkflowIO/ClusterReaderSpec.h"
3131
#include "TOFWorkflowIO/TOFMatchedReaderSpec.h"
3232
#include "FT0Workflow/RecPointReaderSpec.h"
@@ -194,6 +194,6 @@ int InputHelper::addInputSpecsIRFramesITS(const o2::framework::ConfigContext& co
194194
if (configcontext.options().get<bool>("disable-root-input")) {
195195
return 0;
196196
}
197-
specs.emplace_back(o2::its::getIRFrameReaderSpec());
197+
specs.emplace_back(o2::globaltracking::getIRFrameReaderSpec("ITS", 0, "its-irframe-reader", "o2_its_irframe.root"));
198198
return 0;
199199
}

Detectors/GlobalTrackingWorkflow/readers/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ o2_add_library(GlobalTrackingWorkflowReaders
1717
src/GlobalFwdTrackReaderSpec.cxx
1818
src/MatchedMFTMCHReaderSpec.cxx
1919
src/MatchedMCHMIDReaderSpec.cxx
20+
src/IRFrameReaderSpec.cxx
2021
PUBLIC_LINK_LIBRARIES O2::ReconstructionDataFormats
2122
O2::DataFormatsITSMFT
2223
O2::SimulationDataFormat)
24+
25+
o2_add_executable(reader-workflow
26+
COMPONENT_NAME irframe
27+
SOURCES src/irframe-reader-workflow.cxx
28+
PUBLIC_LINK_LIBRARIES O2::GlobalTrackingWorkflowReaders
29+
O2::DetectorsRaw)

Detectors/ITSMFT/ITS/workflow/include/ITSWorkflow/IRFrameReaderSpec.h renamed to Detectors/GlobalTrackingWorkflow/readers/include/GlobalTrackingWorkflowReaders/IRFrameReaderSpec.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@
1111

1212
/// @file IRFramesReaderSpec.h
1313

14-
#ifndef O2_ITS_IRFRAMES_READER
15-
#define O2_ITS_IRFRAMES_READER
14+
#ifndef O2_IRFRAMES_READER
15+
#define O2_IRFRAMES_READER
1616

1717
#include "Framework/DataProcessorSpec.h"
1818

1919
namespace o2
2020
{
21-
namespace its
21+
namespace globaltracking
2222
{
2323

2424
/// create a processor spec
25-
/// read ITS IRFrames data from a root file
26-
framework::DataProcessorSpec getIRFrameReaderSpec();
25+
/// read IRFrames data from a root file
26+
framework::DataProcessorSpec getIRFrameReaderSpec(o2::header::DataOrigin origin, uint32_t subSpec, const std::string& devName, const std::string& defFileName);
2727

28-
} // namespace its
28+
} // namespace globaltracking
2929
} // namespace o2
3030

3131
#endif

Detectors/ITSMFT/ITS/workflow/src/IRFrameReaderSpec.cxx renamed to Detectors/GlobalTrackingWorkflow/readers/src/IRFrameReaderSpec.cxx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,31 @@
1717
#include "Framework/ConfigParamRegistry.h"
1818
#include "Framework/Task.h"
1919
#include "Framework/Logger.h"
20-
#include "ITSWorkflow/IRFrameReaderSpec.h"
20+
#include "GlobalTrackingWorkflowReaders/IRFrameReaderSpec.h"
2121
#include "CommonDataFormat/IRFrame.h"
2222
#include "CommonUtils/StringUtils.h"
2323
#include "TFile.h"
2424
#include "TTree.h"
2525

2626
using namespace o2::framework;
27-
using namespace o2::its;
2827

2928
namespace o2
3029
{
31-
namespace its
30+
namespace globaltracking
3231
{
3332

3433
class IRFrameReaderSpec : public o2::framework::Task
3534
{
3635
public:
37-
IRFrameReaderSpec() = default;
36+
IRFrameReaderSpec(o2::header::DataOrigin origin, uint32_t subSpec) : mDataOrigin(origin), mSubSpec(subSpec) {}
3837
~IRFrameReaderSpec() override = default;
3938
void init(o2::framework::InitContext& ic) final;
4039
void run(o2::framework::ProcessingContext& pc) final;
4140

4241
protected:
4342
void connectTree(const std::string& filename);
44-
43+
o2::header::DataOrigin mDataOrigin = o2::header::gDataOriginInvalid;
44+
uint32_t mSubSpec = 0;
4545
std::vector<o2::dataformats::IRFrame> mIRF, *mIRFInp = &mIRF;
4646
std::unique_ptr<TFile> mFile;
4747
std::unique_ptr<TTree> mTree;
@@ -53,7 +53,7 @@ class IRFrameReaderSpec : public o2::framework::Task
5353
void IRFrameReaderSpec::init(InitContext& ic)
5454
{
5555
mInputFileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get<std::string>("input-dir")),
56-
ic.options().get<std::string>("its-irframe-infile"));
56+
ic.options().get<std::string>("irframe-infile"));
5757
connectTree(mInputFileName);
5858
}
5959

@@ -62,8 +62,8 @@ void IRFrameReaderSpec::run(ProcessingContext& pc)
6262
auto ent = mTree->GetReadEntry() + 1;
6363
assert(ent < mTree->GetEntries()); // this should not happen
6464
mTree->GetEntry(ent);
65-
LOG(info) << "Pushing " << mIRF.size() << " IR-frames in at entry " << ent;
66-
pc.outputs().snapshot(Output{"ITS", "IRFRAMES", 0, Lifetime::Timeframe}, mIRF);
65+
LOG(debug) << "Pushing " << mIRF.size() << " IR-frames in at entry " << ent;
66+
pc.outputs().snapshot(Output{mDataOrigin, "IRFRAMES", mSubSpec, Lifetime::Timeframe}, mIRF);
6767

6868
if (mTree->GetReadEntry() + 1 >= mTree->GetEntries()) {
6969
pc.services().get<ControlService>().endOfStream();
@@ -84,19 +84,19 @@ void IRFrameReaderSpec::connectTree(const std::string& filename)
8484
LOG(info) << "Loaded tree from " << filename << " with " << mTree->GetEntries() << " entries";
8585
}
8686

87-
DataProcessorSpec getIRFrameReaderSpec()
87+
DataProcessorSpec getIRFrameReaderSpec(o2::header::DataOrigin origin, uint32_t subSpec, const std::string& devName, const std::string& defFileName)
8888
{
8989
std::vector<OutputSpec> outputSpec;
9090

9191
return DataProcessorSpec{
92-
"its-irframe-reader",
92+
devName,
9393
Inputs{},
94-
Outputs{{"ITS", "IRFRAMES", 0, Lifetime::Timeframe}},
95-
AlgorithmSpec{adaptFromTask<IRFrameReaderSpec>()},
94+
Outputs{{origin, "IRFRAMES", subSpec, Lifetime::Timeframe}},
95+
AlgorithmSpec{adaptFromTask<IRFrameReaderSpec>(origin, subSpec)},
9696
Options{
97-
{"its-irframe-infile", VariantType::String, "o2_its_irframe.root", {"Name of the input IRFrames file"}},
97+
{"irframe-infile", VariantType::String, defFileName, {"Name of the input IRFrames file"}},
9898
{"input-dir", VariantType::String, "none", {"Input directory"}}}};
9999
}
100100

101-
} // namespace its
101+
} // namespace globaltracking
102102
} // namespace o2
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
#include "Framework/ConfigParamSpec.h"
13+
#include "DetectorsRaw/HBFUtilsInitializer.h"
14+
#include "Framework/CallbacksPolicy.h"
15+
16+
using namespace o2::framework;
17+
18+
void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
19+
{
20+
o2::raw::HBFUtilsInitializer::addNewTimeSliceCallback(policies);
21+
}
22+
23+
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
24+
{
25+
workflowOptions.push_back(ConfigParamSpec{"data-origin", o2::framework::VariantType::String, "NIL", {"ouput data origin"}});
26+
workflowOptions.push_back(ConfigParamSpec{"subspec", o2::framework::VariantType::Int, 0, {"ouput subspec"}});
27+
workflowOptions.push_back(ConfigParamSpec{"device-name", o2::framework::VariantType::String, "irframe-reader", {"device name"}});
28+
workflowOptions.push_back(ConfigParamSpec{"file-name", o2::framework::VariantType::String, "o2_irframe.root", {"default input file name"}});
29+
o2::raw::HBFUtilsInitializer::addConfigOption(workflowOptions);
30+
}
31+
32+
#include "Framework/runDataProcessing.h"
33+
#include "GlobalTrackingWorkflowReaders/IRFrameReaderSpec.h"
34+
35+
WorkflowSpec defineDataProcessing(ConfigContext const& cc)
36+
{
37+
WorkflowSpec specs;
38+
o2::header::DataOrigin origin;
39+
origin.runtimeInit(cc.options().get<std::string>("data-origin").c_str());
40+
41+
specs.emplace_back(o2::globaltracking::getIRFrameReaderSpec(origin, (uint32_t)cc.options().get<int>("subspec"),
42+
cc.options().get<std::string>("device-name"), cc.options().get<std::string>("file-name")));
43+
44+
// configure dpl timer to inject correct firstTFOrbit: start from the 1st orbit of TF containing 1st sampled orbit
45+
o2::raw::HBFUtilsInitializer hbfIni(cc, specs);
46+
47+
return specs;
48+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
o2_add_library(GlobalTrackingWorkflowWriters
13+
SOURCES src/IRFrameWriterSpec.cxx
14+
PUBLIC_LINK_LIBRARIES O2::Framework
15+
O2::DPLUtils
16+
O2::ReconstructionDataFormats
17+
O2::SimulationDataFormat)
18+
19+
o2_add_executable(writer-workflow
20+
COMPONENT_NAME irframe
21+
SOURCES src/irframe-writer-workflow.cxx
22+
PUBLIC_LINK_LIBRARIES O2::GlobalTrackingWorkflowWriters)

Detectors/ITSMFT/ITS/workflow/include/ITSWorkflow/IRFrameWriterSpec.h renamed to Detectors/GlobalTrackingWorkflow/writers/include/GlobalTrackingWorkflowWriters/IRFrameWriterSpec.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@
1111

1212
/// @file IRFrameWriterSpec.h
1313

14-
#ifndef O2_ITS_IRFRAMEWRITER
15-
#define O2_ITS_IRFRAMEWRITER
14+
#ifndef O2_IRFRAMEWRITER
15+
#define O2_IRFRAMEWRITER
1616

1717
#include "Framework/DataProcessorSpec.h"
1818

1919
namespace o2
2020
{
21-
namespace its
21+
namespace globaltracking
2222
{
2323

2424
/// create a processor spec
25-
/// write IRFrames for which ITS was reconstructed and tracks found
26-
o2::framework::DataProcessorSpec getIRFrameWriterSpec();
25+
/// write IRFrames for which data was selected
26+
o2::framework::DataProcessorSpec getIRFrameWriterSpec(const std::string& spec, const std::string& defFileName = "o2_irframe.root", const std::string& devName = "irframe-writer");
2727

28-
} // namespace its
28+
} // namespace globaltracking
2929
} // namespace o2
3030

3131
#endif

Detectors/ITSMFT/ITS/workflow/src/IRFrameWriterSpec.cxx renamed to Detectors/GlobalTrackingWorkflow/writers/src/IRFrameWriterSpec.cxx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,32 @@
1313

1414
#include <vector>
1515

16-
#include "ITSWorkflow/IRFrameWriterSpec.h"
16+
#include "GlobalTrackingWorkflowWriters/IRFrameWriterSpec.h"
1717
#include "DPLUtils/MakeRootTreeWriterSpec.h"
1818
#include "CommonDataFormat/IRFrame.h"
19+
#include "Framework/DataDescriptorQueryBuilder.h"
1920

2021
using namespace o2::framework;
2122

2223
namespace o2
2324
{
24-
namespace its
25+
namespace globaltracking
2526
{
2627

2728
template <typename T>
2829
using BranchDefinition = MakeRootTreeWriterSpec::BranchDefinition<T>;
2930

30-
DataProcessorSpec getIRFrameWriterSpec()
31+
DataProcessorSpec getIRFrameWriterSpec(const std::string& spec, const std::string& defFileName, const std::string& devName)
3132
{
32-
return MakeRootTreeWriterSpec("its-irframe-writer",
33-
"o2_its_irframe.root",
34-
MakeRootTreeWriterSpec::TreeAttributes{"o2sim", "Tree with reconstructed ITS IR Frames"},
35-
BranchDefinition<std::vector<o2::dataformats::IRFrame>>{InputSpec{"irfr", "ITS", "IRFRAMES", 0}, "IRFrames"})();
33+
auto inputs = DataDescriptorQueryBuilder::parse(spec.c_str());
34+
if (inputs.size() != 1) {
35+
LOGP(fatal, "irframe-writer expects exactly 1 input spec, {} is received: {}", inputs.size(), spec);
36+
}
37+
return MakeRootTreeWriterSpec(devName.c_str(),
38+
defFileName.c_str(),
39+
MakeRootTreeWriterSpec::TreeAttributes{"o2sim", "Tree with selected IR Frames"},
40+
BranchDefinition<std::vector<o2::dataformats::IRFrame>>{inputs.front(), "IRFrames"})();
3641
}
3742

38-
} // namespace its
43+
} // namespace globaltracking
3944
} // namespace o2
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
#include "Framework/ConfigParamSpec.h"
13+
14+
using namespace o2::framework;
15+
16+
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
17+
{
18+
workflowOptions.push_back(ConfigParamSpec{"input-spec", o2::framework::VariantType::String, "X:NIL/IRFRAMES/0", {"input spec"}});
19+
workflowOptions.push_back(ConfigParamSpec{"device-name", o2::framework::VariantType::String, "irframe-writer", {"device name"}});
20+
}
21+
22+
#include "Framework/runDataProcessing.h"
23+
#include "GlobalTrackingWorkflowWriters/IRFrameWriterSpec.h"
24+
25+
WorkflowSpec defineDataProcessing(ConfigContext const& cc)
26+
{
27+
WorkflowSpec specs;
28+
if (cc.helpOnCommandLine()) {
29+
return specs;
30+
}
31+
specs.emplace_back(o2::globaltracking::getIRFrameWriterSpec(cc.options().get<std::string>("input-spec"), "o2_irframe.root",
32+
cc.options().get<std::string>("device-name")));
33+
return specs;
34+
}

0 commit comments

Comments
 (0)