Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add MCH errors merger, reader and writer #10716

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Detectors/MUON/MCH/Base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ o2_add_library(MCHBase

o2_target_root_dictionary(MCHBase
HEADERS include/MCHBase/DecoderError.h
include/MCHBase/Error.h
include/MCHBase/HeartBeatPacket.h
include/MCHBase/PreCluster.h
include/MCHBase/ResponseParam.h
Expand Down
4 changes: 4 additions & 0 deletions Detectors/MUON/MCH/Base/include/MCHBase/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <map>
#include <string>

#include <Rtypes.h>

namespace o2::mch
{

Expand Down Expand Up @@ -90,6 +92,8 @@ struct Error {
std::string getTypeDescription() const;
/** returns the error message corresponding to this error */
std::string asString() const;

ClassDefNV(Error, 1)
};

} // namespace o2::mch
Expand Down
3 changes: 3 additions & 0 deletions Detectors/MUON/MCH/Base/src/MCHBaseLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@
#pragma link C++ class o2::mch::PreCluster + ;
#pragma link C++ class std::vector < o2::mch::PreCluster> + ;

#pragma link C++ class o2::mch::Error + ;
#pragma link C++ class std::vector < o2::mch::Error> + ;

#endif
21 changes: 21 additions & 0 deletions Detectors/MUON/MCH/Workflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ o2_add_library(MCHWorkflow
src/ClusterReaderSpec.cxx
src/ClusterWriterSpec.cxx
src/DataDecoderSpec.cxx
src/ErrorReaderSpec.cxx
src/ErrorWriterSpec.cxx
src/PreClusterReaderSpec.cxx
src/PreClusterWriterSpec.cxx
src/TrackReaderSpec.cxx
Expand Down Expand Up @@ -183,6 +185,24 @@ o2_add_executable(
COMPONENT_NAME mch
PUBLIC_LINK_LIBRARIES O2::Framework O2::DataFormatsMCH O2::MCHBase)

o2_add_executable(
errors-merger-workflow
SOURCES src/ErrorMergerSpec.cxx src/errors-merger-workflow.cxx
COMPONENT_NAME mch
PUBLIC_LINK_LIBRARIES O2::Framework O2::MCHBase)

o2_add_executable(
errors-writer-workflow
SOURCES src/errors-writer-workflow.cxx
COMPONENT_NAME mch
PUBLIC_LINK_LIBRARIES O2::MCHWorkflow)

o2_add_executable(
errors-reader-workflow
SOURCES src/errors-reader-workflow.cxx
COMPONENT_NAME mch
PUBLIC_LINK_LIBRARIES O2::MCHWorkflow)

o2_add_executable(
entropy-encoder-workflow
SOURCES src/entropy-encoder-workflow.cxx
Expand All @@ -193,6 +213,7 @@ o2_add_executable(
reco-workflow
SOURCES
src/DigitReaderSpec.cxx
src/ErrorMergerSpec.cxx
src/EventFinderSpec.cxx
src/TrackMCLabelFinderSpec.cxx
src/reco-workflow.cxx
Expand Down
35 changes: 35 additions & 0 deletions Detectors/MUON/MCH/Workflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
* [Tracking](#tracking)
* [Track extrapolation to vertex](#track-extrapolation-to-vertex)
* [Track fitter](#track-fitter)
* [Error merger](#error-merger)
* [Samplers](#samplers)
* [Digit sampler](#digit-sampler)
* [Precluster reader](#precluster-reader)
* [Cluster sampler](#cluster-sampler)
* [Cluster reader](#cluster-reader)
* [Track sampler](#track-sampler)
* [Track reader](#track-reader)
* [Error reader](#error-reader)
* [Vertex sampler](#vertex-sampler)
* [Sinks](#sinks)
* [Precluster sink](#precluster-sink)
Expand All @@ -33,6 +35,7 @@
* [Cluster writer](#cluster-writer)
* [Track sink](#track-sink)
* [Track writer](#track-writer)
* [Error writer](#error-writer)

<!-- vim-markdown-toc -->

Expand Down Expand Up @@ -207,6 +210,20 @@ Options `--l3Current xxx` and `--dipoleCurrent yyy` allow to specify the current

Refit the tracks to their associated clusters. [more...](/Detectors/MUON/MCH/Tracking/README.md)

## Error merger

```shell
o2-mch-errors-merger-workflow
```

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".

Options `--disable-preclustering-errors` allows to skip the preclustering errors.

Options `--disable-clustering-errors` allows to skip the clustering errors.

Options `--disable-tracking-errors` allows to skip the tracking errors.

## Samplers

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

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

## Error reader

```shell
o2-mch-errors-reader-workflow --infile mcherrors.root
```

Send the list of all MCH processing errors ([Error](../Base/include/MCHBase/Error.h)) in the current time frame, with the data description "ERRORS".

Option `--input-dir` allows to set the name of the directory containing the input file (default = current directory).

### Vertex sampler

```shell
Expand Down Expand Up @@ -411,3 +438,11 @@ Does the same kind of work as the [track sink](#track-sink) but the output is in
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".

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

## Error writer

```shell
o2-mch-errors-writer-workflow
```

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".
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#ifndef O2_MCH_WORKFLOW_ERROR_READER_SPEC_H
#define O2_MCH_WORKFLOW_ERROR_READER_SPEC_H

#include "Framework/DataProcessorSpec.h"

namespace o2::mch
{
framework::DataProcessorSpec getErrorReaderSpec(const char* specName = "mch-error-reader");
}

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#ifndef O2_MCH_WORKFLOW_ERROR_WRITER_SPEC_H
#define O2_MCH_WORKFLOW_ERROR_WRITER_SPEC_H

#include "Framework/DataProcessorSpec.h"

namespace o2::mch
{
framework::DataProcessorSpec getErrorWriterSpec(const char* specName = "mch-error-writer");
}

#endif
106 changes: 106 additions & 0 deletions Detectors/MUON/MCH/Workflow/src/ErrorMergerSpec.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file ErrorMergerSpec.cxx
/// \brief Implementation of a data processor to merge the processing errors in one single output
///
/// \author Philippe Pillot, Subatech

#include "ErrorMergerSpec.h"

#include <vector>

#include <gsl/span>

#include "Framework/ConfigParamSpec.h"
#include "Framework/InitContext.h"
#include "Framework/InputSpec.h"
#include "Framework/Lifetime.h"
#include "Framework/OutputRef.h"
#include "Framework/OutputSpec.h"
#include "Framework/ProcessingContext.h"
#include "Framework/Task.h"

#include "MCHBase/Error.h"

namespace o2
{
namespace mch
{

using namespace o2::framework;

class ErrorMergerTask
{
public:
//_________________________________________________________________________________________________
/// constructor
ErrorMergerTask(bool preclustering, bool clustering, bool tracking)
: mPreclustering{preclustering},
mClustering{clustering},
mTracking{tracking} {}

//_________________________________________________________________________________________________
/// prepare the error merger
void init(InitContext& ic) {}

//_________________________________________________________________________________________________
/// run the error merger
void run(ProcessingContext& pc)
{
auto& errors = pc.outputs().make<std::vector<Error>>(OutputRef{"errors"});

if (mPreclustering) {
auto preclusteringErrors = pc.inputs().get<gsl::span<Error>>("preclustererrors");
errors.insert(errors.end(), preclusteringErrors.begin(), preclusteringErrors.end());
}

if (mClustering) {
auto clusteringErrors = pc.inputs().get<gsl::span<Error>>("clustererrors");
errors.insert(errors.end(), clusteringErrors.begin(), clusteringErrors.end());
}

if (mTracking) {
auto trackingErrors = pc.inputs().get<gsl::span<Error>>("trackerrors");
errors.insert(errors.end(), trackingErrors.begin(), trackingErrors.end());
}
}

private:
bool mPreclustering = true; ///< add preclustering errors
bool mClustering = true; ///< add clustering errors
bool mTracking = true; ///< add tracking errors
};

//_________________________________________________________________________________________________
DataProcessorSpec getErrorMergerSpec(const char* specName, bool preclustering, bool clustering, bool tracking)
{
std::vector<InputSpec> inputSpecs{};
if (preclustering) {
inputSpecs.emplace_back(InputSpec{"preclustererrors", "MCH", "PRECLUSTERERRORS", 0, Lifetime::Timeframe});
}
if (clustering) {
inputSpecs.emplace_back(InputSpec{"clustererrors", "MCH", "CLUSTERERRORS", 0, Lifetime::Timeframe});
}
if (tracking) {
inputSpecs.emplace_back(InputSpec{"trackerrors", "MCH", "TRACKERRORS", 0, Lifetime::Timeframe});
}

return DataProcessorSpec{
specName,
inputSpecs,
Outputs{OutputSpec{{"errors"}, "MCH", "ERRORS", 0, Lifetime::Timeframe}},
adaptFromTask<ErrorMergerTask>(preclustering, clustering, tracking),
Options{}};
}

} // namespace mch
} // namespace o2
32 changes: 32 additions & 0 deletions Detectors/MUON/MCH/Workflow/src/ErrorMergerSpec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file ErrorMergerSpec.h
/// \brief Definition of a data processor to merge the processing errors in one single output
///
/// \author Philippe Pillot, Subatech

#ifndef O2_MCH_ERRORMERGERSPEC_H_
#define O2_MCH_ERRORMERGERSPEC_H_

#include "Framework/DataProcessorSpec.h"

namespace o2::mch
{

framework::DataProcessorSpec getErrorMergerSpec(const char* specName = "mch-error-merger",
bool preclustering = true,
bool clustering = true,
bool tracking = true);

} // namespace o2::mch

#endif // O2_MCH_ERRORMERGERSPEC_H_
Loading