Skip to content

Commit 7278425

Browse files
pillotalcaliva
authored andcommitted
add StatusMap IO and a converter to RejectList
1 parent 5b61046 commit 7278425

File tree

10 files changed

+488
-0
lines changed

10 files changed

+488
-0
lines changed

Detectors/MUON/MCH/IO/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,19 @@ o2_add_executable(tracks-writer-workflow
9797
COMPONENT_NAME mch
9898
PUBLIC_LINK_LIBRARIES O2::MCHIO)
9999

100+
o2_add_executable(statusmaps-reader-workflow
101+
SOURCES src/StatusMapReaderSpec.cxx src/statusmaps-reader-workflow.cxx
102+
COMPONENT_NAME mch
103+
PUBLIC_LINK_LIBRARIES
104+
O2::DPLUtils
105+
O2::DetectorsRaw
106+
O2::MCHStatus
107+
)
108+
109+
o2_add_executable(statusmaps-writer-workflow
110+
SOURCES src/StatusMapWriterSpec.cxx src/statusmaps-writer-workflow.cxx
111+
COMPONENT_NAME mch
112+
PUBLIC_LINK_LIBRARIES
113+
O2::DPLUtils
114+
O2::MCHStatus
115+
)

Detectors/MUON/MCH/IO/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* [Cluster writer](#cluster-writer)
1515
* [Track reader](#track-reader)
1616
* [Track writer](#track-writer)
17+
* [StatusMap reader](#statusmap-reader)
18+
* [StatusMap writer](#statusmap-writer)
1719

1820
<!-- vim-markdown-toc -->
1921

@@ -126,3 +128,21 @@ Option `--digits` allows to also write the associated digits ([Digit](/DataForma
126128

127129
Option `--enable-mc` allows to also write the track MC labels from the input message with the data description "TRACKLABELS".
128130

131+
## StatusMap reader
132+
133+
```shell
134+
o2-mch-statusmaps-reader-workflow --infile mchstatusmaps.root
135+
```
136+
137+
Send the status map ([StatusMap](../Status/include/MCHStatus/StatusMap.h)) of the current time frame, with the data description "STATUSMAP".
138+
139+
Option `--input-dir` allows to set the name of the directory containing the input file (default = current directory).
140+
141+
## StatusMap writer
142+
143+
```shell
144+
o2-mch-statusmaps-writer-workflow
145+
```
146+
147+
Take as input the status map ([StatusMap](../Status/include/MCHStatus/StatusMap.h)) of the current time frame, with the data description "STATUSMAP", and write it in the root file "mchstatusmaps.root".
148+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 "StatusMapReaderSpec.h"
13+
14+
#include <memory>
15+
#include <string>
16+
17+
#include "Framework/ConfigParamRegistry.h"
18+
#include "Framework/ConfigParamSpec.h"
19+
#include "Framework/ControlService.h"
20+
#include "Framework/InitContext.h"
21+
#include "Framework/Lifetime.h"
22+
#include "Framework/OutputSpec.h"
23+
#include "Framework/ProcessingContext.h"
24+
#include "Framework/Task.h"
25+
26+
#include "DPLUtils/RootTreeReader.h"
27+
#include "CommonUtils/StringUtils.h"
28+
#include "MCHStatus/StatusMap.h"
29+
30+
using namespace o2::framework;
31+
32+
namespace o2::mch
33+
{
34+
35+
struct StatusMapReader {
36+
std::unique_ptr<RootTreeReader> mTreeReader;
37+
38+
void init(InitContext& ic)
39+
{
40+
auto fileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get<std::string>("input-dir")), ic.options().get<std::string>("infile"));
41+
mTreeReader = std::make_unique<RootTreeReader>(
42+
"o2sim",
43+
fileName.c_str(),
44+
-1,
45+
RootTreeReader::PublishingMode::Single,
46+
RootTreeReader::BranchDefinition<StatusMap>{Output{"MCH", "STATUSMAP", 0}, "statusmaps"});
47+
}
48+
49+
void run(ProcessingContext& pc)
50+
{
51+
if (mTreeReader->next()) {
52+
(*mTreeReader)(pc);
53+
} else {
54+
pc.services().get<ControlService>().endOfStream();
55+
}
56+
}
57+
};
58+
59+
DataProcessorSpec getStatusMapReaderSpec(const char* specName)
60+
{
61+
return DataProcessorSpec{
62+
specName,
63+
Inputs{},
64+
Outputs{OutputSpec{{"statusmaps"}, "MCH", "STATUSMAP", 0, Lifetime::Timeframe}},
65+
adaptFromTask<StatusMapReader>(),
66+
Options{{"infile", VariantType::String, "mchstatusmaps.root", {"name of the input status map file"}},
67+
{"input-dir", VariantType::String, "none", {"Input directory"}}}};
68+
}
69+
70+
} // namespace o2::mch
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+
#ifndef O2_MCH_WORKFLOW_STATUSMAP_READER_SPEC_H
13+
#define O2_MCH_WORKFLOW_STATUSMAP_READER_SPEC_H
14+
15+
#include "Framework/DataProcessorSpec.h"
16+
17+
namespace o2::mch
18+
{
19+
framework::DataProcessorSpec getStatusMapReaderSpec(const char* specName = "mch-statusmap-reader");
20+
}
21+
22+
#endif
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 "StatusMapWriterSpec.h"
13+
14+
#include "DPLUtils/MakeRootTreeWriterSpec.h"
15+
#include "MCHStatus/StatusMap.h"
16+
17+
using namespace o2::framework;
18+
19+
namespace o2::mch
20+
{
21+
22+
template <typename T>
23+
using BranchDefinition = MakeRootTreeWriterSpec::BranchDefinition<T>;
24+
25+
DataProcessorSpec getStatusMapWriterSpec(const char* specName)
26+
{
27+
return MakeRootTreeWriterSpec(specName,
28+
"mchstatusmaps.root",
29+
MakeRootTreeWriterSpec::TreeAttributes{"o2sim", "Tree MCH StatusMaps"},
30+
BranchDefinition<StatusMap>{InputSpec{"statusmaps", "MCH", "STATUSMAP"}, "statusmaps"})();
31+
}
32+
33+
} // namespace o2::mch
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+
#ifndef O2_MCH_WORKFLOW_STATUSMAP_WRITER_SPEC_H
13+
#define O2_MCH_WORKFLOW_STATUSMAP_WRITER_SPEC_H
14+
15+
#include "Framework/DataProcessorSpec.h"
16+
17+
namespace o2::mch
18+
{
19+
framework::DataProcessorSpec getStatusMapWriterSpec(const char* specName = "mch-statusmap-writer");
20+
}
21+
22+
#endif
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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 <vector>
13+
#include "DetectorsRaw/HBFUtilsInitializer.h"
14+
#include "Framework/CallbacksPolicy.h"
15+
#include "Framework/ConfigParamSpec.h"
16+
#include "StatusMapReaderSpec.h"
17+
18+
using namespace o2::framework;
19+
20+
void customize(std::vector<CallbacksPolicy>& policies)
21+
{
22+
o2::raw::HBFUtilsInitializer::addNewTimeSliceCallback(policies);
23+
}
24+
25+
// we need to add workflow options before including Framework/runDataProcessing
26+
void customize(std::vector<ConfigParamSpec>& workflowOptions)
27+
{
28+
o2::raw::HBFUtilsInitializer::addConfigOption(workflowOptions);
29+
}
30+
31+
#include "Framework/runDataProcessing.h"
32+
33+
WorkflowSpec defineDataProcessing(const ConfigContext& config)
34+
{
35+
WorkflowSpec wf{o2::mch::getStatusMapReaderSpec("mch-statusmap-reader")};
36+
o2::raw::HBFUtilsInitializer hbfIni(config, wf);
37+
return wf;
38+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 <vector>
13+
#include "Framework/CompletionPolicyHelpers.h"
14+
#include "StatusMapWriterSpec.h"
15+
16+
using namespace o2::framework;
17+
18+
void customize(std::vector<o2::framework::CompletionPolicy>& policies)
19+
{
20+
// ordered policies for the writers
21+
policies.push_back(CompletionPolicyHelpers::consumeWhenAllOrdered(".*(?:MCH|mch).*[W,w]riter.*"));
22+
}
23+
24+
#include "Framework/runDataProcessing.h"
25+
26+
WorkflowSpec defineDataProcessing(const ConfigContext&)
27+
{
28+
return WorkflowSpec{o2::mch::getStatusMapWriterSpec("mch-statusmap-writer")};
29+
}

Detectors/MUON/MCH/Status/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ o2_add_executable(
3535
O2::MCHStatus
3636
)
3737

38+
o2_add_executable(
39+
statusmap-to-rejectlist
40+
COMPONENT_NAME mch
41+
SOURCES src/statusmap-to-rejectlist.cxx
42+
PUBLIC_LINK_LIBRARIES
43+
ROOT::TreePlayer
44+
O2::CCDB
45+
O2::DataFormatsMCH
46+
O2::Framework
47+
O2::MCHGlobalMapping
48+
O2::MCHStatus
49+
)
50+
3851
if(BUILD_TESTING)
3952

4053
o2_add_test(

0 commit comments

Comments
 (0)