Skip to content

Commit 48c767d

Browse files
authored
add MCH errors merger, reader and writer (#10716)
1 parent d1142d3 commit 48c767d

File tree

15 files changed

+470
-0
lines changed

15 files changed

+470
-0
lines changed

Detectors/MUON/MCH/Base/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ o2_add_library(MCHBase
2424

2525
o2_target_root_dictionary(MCHBase
2626
HEADERS include/MCHBase/DecoderError.h
27+
include/MCHBase/Error.h
2728
include/MCHBase/HeartBeatPacket.h
2829
include/MCHBase/PreCluster.h
2930
include/MCHBase/ResponseParam.h

Detectors/MUON/MCH/Base/include/MCHBase/Error.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <map>
2323
#include <string>
2424

25+
#include <Rtypes.h>
26+
2527
namespace o2::mch
2628
{
2729

@@ -90,6 +92,8 @@ struct Error {
9092
std::string getTypeDescription() const;
9193
/** returns the error message corresponding to this error */
9294
std::string asString() const;
95+
96+
ClassDefNV(Error, 1)
9397
};
9498

9599
} // namespace o2::mch

Detectors/MUON/MCH/Base/src/MCHBaseLinkDef.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@
2727
#pragma link C++ class o2::mch::PreCluster + ;
2828
#pragma link C++ class std::vector < o2::mch::PreCluster> + ;
2929

30+
#pragma link C++ class o2::mch::Error + ;
31+
#pragma link C++ class std::vector < o2::mch::Error> + ;
32+
3033
#endif

Detectors/MUON/MCH/Workflow/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ o2_add_library(MCHWorkflow
1818
src/ClusterReaderSpec.cxx
1919
src/ClusterWriterSpec.cxx
2020
src/DataDecoderSpec.cxx
21+
src/ErrorReaderSpec.cxx
22+
src/ErrorWriterSpec.cxx
2123
src/PreClusterReaderSpec.cxx
2224
src/PreClusterWriterSpec.cxx
2325
src/TrackReaderSpec.cxx
@@ -183,6 +185,24 @@ o2_add_executable(
183185
COMPONENT_NAME mch
184186
PUBLIC_LINK_LIBRARIES O2::Framework O2::DataFormatsMCH O2::MCHBase)
185187

188+
o2_add_executable(
189+
errors-merger-workflow
190+
SOURCES src/ErrorMergerSpec.cxx src/errors-merger-workflow.cxx
191+
COMPONENT_NAME mch
192+
PUBLIC_LINK_LIBRARIES O2::Framework O2::MCHBase)
193+
194+
o2_add_executable(
195+
errors-writer-workflow
196+
SOURCES src/errors-writer-workflow.cxx
197+
COMPONENT_NAME mch
198+
PUBLIC_LINK_LIBRARIES O2::MCHWorkflow)
199+
200+
o2_add_executable(
201+
errors-reader-workflow
202+
SOURCES src/errors-reader-workflow.cxx
203+
COMPONENT_NAME mch
204+
PUBLIC_LINK_LIBRARIES O2::MCHWorkflow)
205+
186206
o2_add_executable(
187207
entropy-encoder-workflow
188208
SOURCES src/entropy-encoder-workflow.cxx
@@ -193,6 +213,7 @@ o2_add_executable(
193213
reco-workflow
194214
SOURCES
195215
src/DigitReaderSpec.cxx
216+
src/ErrorMergerSpec.cxx
196217
src/EventFinderSpec.cxx
197218
src/TrackMCLabelFinderSpec.cxx
198219
src/reco-workflow.cxx

Detectors/MUON/MCH/Workflow/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
* [Tracking](#tracking)
1919
* [Track extrapolation to vertex](#track-extrapolation-to-vertex)
2020
* [Track fitter](#track-fitter)
21+
* [Error merger](#error-merger)
2122
* [Samplers](#samplers)
2223
* [Digit sampler](#digit-sampler)
2324
* [Precluster reader](#precluster-reader)
2425
* [Cluster sampler](#cluster-sampler)
2526
* [Cluster reader](#cluster-reader)
2627
* [Track sampler](#track-sampler)
2728
* [Track reader](#track-reader)
29+
* [Error reader](#error-reader)
2830
* [Vertex sampler](#vertex-sampler)
2931
* [Sinks](#sinks)
3032
* [Precluster sink](#precluster-sink)
@@ -33,6 +35,7 @@
3335
* [Cluster writer](#cluster-writer)
3436
* [Track sink](#track-sink)
3537
* [Track writer](#track-writer)
38+
* [Error writer](#error-writer)
3639

3740
<!-- vim-markdown-toc -->
3841

@@ -207,6 +210,20 @@ Options `--l3Current xxx` and `--dipoleCurrent yyy` allow to specify the current
207210
208211
Refit the tracks to their associated clusters. [more...](/Detectors/MUON/MCH/Tracking/README.md)
209212
213+
## Error merger
214+
215+
```shell
216+
o2-mch-errors-merger-workflow
217+
```
218+
219+
Take as input the list of all MCH preclustering, clustering and tracking errors ([Error](../Base/include/MCHBase/Error.h)) in the current time frame, with the data description "PRECLUSTERERRORS", "CLUSTERERRORS" and "TRACKERRORS", respectively. Send the merged list of all MCH processing errors ([Error](../Base/include/MCHBase/Error.h)) in the time frame, with the data description "ERRORS".
220+
221+
Options `--disable-preclustering-errors` allows to skip the preclustering errors.
222+
223+
Options `--disable-clustering-errors` allows to skip the clustering errors.
224+
225+
Options `--disable-tracking-errors` allows to skip the tracking errors.
226+
210227
## Samplers
211228

212229
### Digit sampler
@@ -305,6 +322,16 @@ Option `--digits` allows to also read the associated digits ([Digit](/DataFormat
305322

306323
Option `--enable-mc` allows to also read the track MC labels and send them with the data description "TRACKLABELS".
307324

325+
## Error reader
326+
327+
```shell
328+
o2-mch-errors-reader-workflow --infile mcherrors.root
329+
```
330+
331+
Send the list of all MCH processing errors ([Error](../Base/include/MCHBase/Error.h)) in the current time frame, with the data description "ERRORS".
332+
333+
Option `--input-dir` allows to set the name of the directory containing the input file (default = current directory).
334+
308335
### Vertex sampler
309336

310337
```shell
@@ -411,3 +438,11 @@ Does the same kind of work as the [track sink](#track-sink) but the output is in
411438
Option `--digits` allows to also write the associated digits ([Digit](/DataFormats/Detectors/MUON/MCH/include/DataFormatsMCH/Digit.h)) from the input message with the data description "TRACKDIGITS".
412439

413440
Option `--enable-mc` allows to also write the track MC labels from the input message with the data description "TRACKLABELS".
441+
442+
## Error writer
443+
444+
```shell
445+
o2-mch-errors-writer-workflow
446+
```
447+
448+
Take as input the list of all MCH processing errors ([Error](../Base/include/MCHBase/Error.h)) in the current time frame, with the data description "ERRORS", and write it in the root file "mcherrors.root".
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_ERROR_READER_SPEC_H
13+
#define O2_MCH_WORKFLOW_ERROR_READER_SPEC_H
14+
15+
#include "Framework/DataProcessorSpec.h"
16+
17+
namespace o2::mch
18+
{
19+
framework::DataProcessorSpec getErrorReaderSpec(const char* specName = "mch-error-reader");
20+
}
21+
22+
#endif
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_ERROR_WRITER_SPEC_H
13+
#define O2_MCH_WORKFLOW_ERROR_WRITER_SPEC_H
14+
15+
#include "Framework/DataProcessorSpec.h"
16+
17+
namespace o2::mch
18+
{
19+
framework::DataProcessorSpec getErrorWriterSpec(const char* specName = "mch-error-writer");
20+
}
21+
22+
#endif
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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 ErrorMergerSpec.cxx
13+
/// \brief Implementation of a data processor to merge the processing errors in one single output
14+
///
15+
/// \author Philippe Pillot, Subatech
16+
17+
#include "ErrorMergerSpec.h"
18+
19+
#include <vector>
20+
21+
#include <gsl/span>
22+
23+
#include "Framework/ConfigParamSpec.h"
24+
#include "Framework/InitContext.h"
25+
#include "Framework/InputSpec.h"
26+
#include "Framework/Lifetime.h"
27+
#include "Framework/OutputRef.h"
28+
#include "Framework/OutputSpec.h"
29+
#include "Framework/ProcessingContext.h"
30+
#include "Framework/Task.h"
31+
32+
#include "MCHBase/Error.h"
33+
34+
namespace o2
35+
{
36+
namespace mch
37+
{
38+
39+
using namespace o2::framework;
40+
41+
class ErrorMergerTask
42+
{
43+
public:
44+
//_________________________________________________________________________________________________
45+
/// constructor
46+
ErrorMergerTask(bool preclustering, bool clustering, bool tracking)
47+
: mPreclustering{preclustering},
48+
mClustering{clustering},
49+
mTracking{tracking} {}
50+
51+
//_________________________________________________________________________________________________
52+
/// prepare the error merger
53+
void init(InitContext& ic) {}
54+
55+
//_________________________________________________________________________________________________
56+
/// run the error merger
57+
void run(ProcessingContext& pc)
58+
{
59+
auto& errors = pc.outputs().make<std::vector<Error>>(OutputRef{"errors"});
60+
61+
if (mPreclustering) {
62+
auto preclusteringErrors = pc.inputs().get<gsl::span<Error>>("preclustererrors");
63+
errors.insert(errors.end(), preclusteringErrors.begin(), preclusteringErrors.end());
64+
}
65+
66+
if (mClustering) {
67+
auto clusteringErrors = pc.inputs().get<gsl::span<Error>>("clustererrors");
68+
errors.insert(errors.end(), clusteringErrors.begin(), clusteringErrors.end());
69+
}
70+
71+
if (mTracking) {
72+
auto trackingErrors = pc.inputs().get<gsl::span<Error>>("trackerrors");
73+
errors.insert(errors.end(), trackingErrors.begin(), trackingErrors.end());
74+
}
75+
}
76+
77+
private:
78+
bool mPreclustering = true; ///< add preclustering errors
79+
bool mClustering = true; ///< add clustering errors
80+
bool mTracking = true; ///< add tracking errors
81+
};
82+
83+
//_________________________________________________________________________________________________
84+
DataProcessorSpec getErrorMergerSpec(const char* specName, bool preclustering, bool clustering, bool tracking)
85+
{
86+
std::vector<InputSpec> inputSpecs{};
87+
if (preclustering) {
88+
inputSpecs.emplace_back(InputSpec{"preclustererrors", "MCH", "PRECLUSTERERRORS", 0, Lifetime::Timeframe});
89+
}
90+
if (clustering) {
91+
inputSpecs.emplace_back(InputSpec{"clustererrors", "MCH", "CLUSTERERRORS", 0, Lifetime::Timeframe});
92+
}
93+
if (tracking) {
94+
inputSpecs.emplace_back(InputSpec{"trackerrors", "MCH", "TRACKERRORS", 0, Lifetime::Timeframe});
95+
}
96+
97+
return DataProcessorSpec{
98+
specName,
99+
inputSpecs,
100+
Outputs{OutputSpec{{"errors"}, "MCH", "ERRORS", 0, Lifetime::Timeframe}},
101+
adaptFromTask<ErrorMergerTask>(preclustering, clustering, tracking),
102+
Options{}};
103+
}
104+
105+
} // namespace mch
106+
} // namespace o2
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 ErrorMergerSpec.h
13+
/// \brief Definition of a data processor to merge the processing errors in one single output
14+
///
15+
/// \author Philippe Pillot, Subatech
16+
17+
#ifndef O2_MCH_ERRORMERGERSPEC_H_
18+
#define O2_MCH_ERRORMERGERSPEC_H_
19+
20+
#include "Framework/DataProcessorSpec.h"
21+
22+
namespace o2::mch
23+
{
24+
25+
framework::DataProcessorSpec getErrorMergerSpec(const char* specName = "mch-error-merger",
26+
bool preclustering = true,
27+
bool clustering = true,
28+
bool tracking = true);
29+
30+
} // namespace o2::mch
31+
32+
#endif // O2_MCH_ERRORMERGERSPEC_H_

0 commit comments

Comments
 (0)