Project
Loading...
Searching...
No Matches
TOFDigitWriterSpec.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
18#include "TOFBase/Digit.h"
19
20using namespace o2::framework;
21
22namespace o2
23{
24namespace tof
25{
26template <typename T>
28using OutputType = std::vector<o2::tof::Digit>;
29using ReadoutWinType = std::vector<o2::tof::ReadoutWindowData>;
30using PatternType = std::vector<uint8_t>;
31using ErrorType = std::vector<uint64_t>;
32using LabelsType = std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>>;
34using namespace o2::header;
35
36DataProcessorSpec getTOFDigitWriterSpec(bool useMC, bool writeErr)
37{
38 auto nCalls = std::make_shared<int>();
39 *nCalls = 0;
40 // the callback to be set as hook at stop of processing for the framework
41 auto finishWriting = [nCalls](TFile* outputfile, TTree* outputtree) {
42 printf("TOF finish writing with %d entries in the tree\n", *nCalls);
43 outputtree->SetEntries(*nCalls);
44 outputfile->Write();
45 outputfile->Close();
46 };
47 // preprocessor callback
48 // read the trigger data first and store in the trigP2Sect shared pointer
49 auto preprocessor = [nCalls](ProcessingContext&) {
50 (*nCalls)++;
51 };
52 auto loggerH = [nCalls](HeaderType const& indata) {
53 };
54 auto logger = [nCalls](OutputType const& indata) {
55 // LOG(info) << "TOF: RECEIVED DIGITS SIZE " << indata.size();
56 };
57 auto loggerROW = [nCalls](ReadoutWinType const& row) {
58 // LOG(info) << "TOF: RECEIVED READOUT WINDOWS " << row.size();
59 };
60 auto loggerPatterns = [nCalls](PatternType const& patterns) {
61 // LOG(info) << "TOF: RECEIVED PATTERNS " << patterns.size();
62 };
63 auto loggerErrors = [nCalls](ErrorType const& errors) {
64 // LOG(info) << "TOF: Error logger ";
65 };
66 return MakeRootTreeWriterSpec("TOFDigitWriter",
67 "tofdigits.root",
68 "o2sim",
69 // the preprocessor only increments the call count, we keep this functionality
70 // of the original implementation
72 BranchDefinition<HeaderType>{InputSpec{"tofdigitheader", gDataOriginTOF, "DIGITHEADER", 0},
73 "TOFHeader",
74 "tofdigitheader-branch-name",
75 1,
76 loggerH},
77 BranchDefinition<OutputType>{InputSpec{"tofdigits", gDataOriginTOF, "DIGITS", 0},
78 "TOFDigit",
79 "tofdigits-branch-name",
80 1,
81 logger},
82 BranchDefinition<ReadoutWinType>{InputSpec{"tofrowindow", gDataOriginTOF, "READOUTWINDOW", 0},
83 "TOFReadoutWindow",
84 "rowindow-branch-name",
85 1,
86 loggerROW},
87 BranchDefinition<PatternType>{InputSpec{"tofpatterns", gDataOriginTOF, "PATTERNS", 0},
88 "TOFPatterns",
89 "patterns-branch-name",
90 1,
91 loggerPatterns},
92 BranchDefinition<ErrorType>{InputSpec{"toferrors", gDataOriginTOF, "ERRORS", 0},
93 "TOFErrors",
94 "errors-branch-name",
95 (writeErr ? 1 : 0), // one branch if mc labels enabled
96 loggerErrors},
97 BranchDefinition<LabelsType>{InputSpec{"toflabels", gDataOriginTOF, "DIGITSMCTR", 0},
98 "TOFDigitMCTruth",
99 (useMC ? 1 : 0), // one branch if mc labels enabled
100 "digitlabels-branch-name"})();
101}
102} // end namespace tof
103} // end namespace o2
Definition of a container to keep Monte Carlo truth external to simulation objects.
Configurable generator for RootTreeWriter processor spec.
Generate a processor spec for the RootTreeWriter utility.
constexpr o2::header::DataOrigin gDataOriginTOF
Definition DataHeader.h:575
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
O2 data header classes and API, v0.1.
Definition DetID.h:49
std::vector< o2::tof::CalibInfoCluster > OutputType
o2::framework::DataProcessorSpec getTOFDigitWriterSpec(bool useMC=1, bool writeErr=0)
std::vector< o2::tof::ReadoutWindowData > ReadoutWinType
std::vector< uint64_t > ErrorType
std::vector< uint8_t > PatternType
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< int > row