Project
Loading...
Searching...
No Matches
DigitWriterSpec.cxx
Go to the documentation of this file.
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
13
17#include "Framework/InputSpec.h"
22
23namespace o2
24{
25namespace mch
26{
27
28template <typename T>
29using BranchDefinition = framework::MakeRootTreeWriterSpec::BranchDefinition<T>;
30
32{
35 return MakeRootTreeWriterSpec("MCHDigitWriter",
36 "mchdigits.root",
37 "o2sim",
38 1, // default number of events
39 BranchDefinition<std::vector<o2::mch::Digit>>{InputSpec{"mchdigits", "MCH", "DIGITS"}, "MCHDigit"},
40 BranchDefinition<std::vector<o2::mch::ROFRecord>>{InputSpec{"mchrofrecords", "MCH", "DIGITROFS"}, "MCHROFRecords"},
41 BranchDefinition<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>{InputSpec{"mchdigitlabels", "MCH", "DIGITSLABELS"}, "MCHMCLabels", mctruth ? 1 : 0})();
42}
43
45 bool useMC,
46 std::string_view specName,
47 std::string_view outfile,
48 std::string_view inputDigitDataDescription,
49 std::string_view inputDigitRofDataDescription,
50 std::string_view inputDigitLabelDataDescription)
51{
52 std::string input =
53 fmt::format("digits:MCH/{};rofs:MCH/{};labels:MCH/{}",
54 inputDigitDataDescription, inputDigitRofDataDescription, inputDigitLabelDataDescription);
55
56 framework::Inputs inputs{framework::select(input.c_str())};
57 auto rofs = std::find_if(inputs.begin(), inputs.end(), [](const framework::InputSpec& is) { return is.binding == "rofs"; });
58 auto digits = std::find_if(inputs.begin(), inputs.end(), [](const framework::InputSpec& is) { return is.binding == "digits"; });
59 auto labels = std::find_if(inputs.begin(), inputs.end(), [](const framework::InputSpec& is) { return is.binding == "labels"; });
61 std::string(specName).c_str(),
62 std::string(outfile).c_str(),
63 framework::MakeRootTreeWriterSpec::TreeAttributes{"o2sim", "Tree MCH Digits"},
67}
68
69} // end namespace mch
70} // end namespace o2
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the MCH ROFrame record.
Configurable generator for RootTreeWriter processor spec.
const char * specName
Generate a processor spec for the RootTreeWriter utility.
std::vector< InputSpec > select(char const *matcher="")
std::vector< InputSpec > Inputs
o2::framework::DataProcessorSpec getMCHDigitWriterSpec(bool mctruth)
o2::framework::DataProcessorSpec getDigitWriterSpec(bool useMC, std::string_view specName="mch-digit-writer", std::string_view outfile="mchdigits.root", std::string_view inputDigitDataDescription="DIGITS", std::string_view inputDigitRofDataDescription="DIGITROFS", std::string_view inputDigitLabelDataDescription="DIGITLABELS")
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< Digit > digits