Project
Loading...
Searching...
No Matches
DigitWriterSpec.h
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
12#ifndef O2_FDD_DIGITWRITERSPEC_H
13#define O2_FDD_DIGITWRITERSPEC_H
14
17#include "Framework/InputSpec.h"
23
24namespace o2
25{
26namespace fdd
27{
28
29template <typename T>
31
32o2::framework::DataProcessorSpec getFDDDigitWriterSpec(bool mctruth = true, bool trigInp = true)
33{
36
37 // the callback to be set as hook for custom action when the writer is closed
38 auto finishWriting = [](TFile* outputfile, TTree* outputtree) {
39 const auto* brArr = outputtree->GetListOfBranches();
40 int64_t nent = 0;
41 for (const auto* brc : *brArr) {
42 int64_t n = ((const TBranch*)brc)->GetEntries();
43 if (nent && (nent != n)) {
44 LOG(error) << "Branches have different number of entries";
45 }
46 nent = n;
47 }
48 outputtree->SetEntries(nent);
49 outputfile->Write();
50 outputfile->Close();
51 };
52
53 // custom handler for labels:
54 // essentially transform the input container (as registered in the original branch definition) to the special output format for labels
55 auto customlabelhandler = [](TBranch& branch, std::vector<char> const& labeldata, framework::DataRef const& ref) {
57 // make the actual output object by adopting/casting the buffer
58 // into a split format
59 o2::dataformats::IOMCTruthContainerView outputcontainer(labeldata);
60 auto ptr = &outputcontainer;
62 br->Fill();
63 br->ResetAddress();
64 };
65
66 auto labelsdef = BranchDefinition<std::vector<char>>{InputSpec{"FDDlabelinput", "FDD", "DIGITLBL"},
67 "FDDDigitLabels", "labels-branch-name",
68 // this branch definition is disabled if MC labels are not processed
69 (mctruth ? 1 : 0),
70 customlabelhandler};
71 if (trigInp) {
72 return MakeRootTreeWriterSpec("FDDDigitWriter",
73 "fdddigits.root",
74 "o2sim",
76 BranchDefinition<std::vector<o2::fdd::Digit>>{InputSpec{"FDDdigitBCinput", "FDD", "DIGITSBC"}, "FDDDigit"},
77 BranchDefinition<std::vector<o2::fdd::ChannelData>>{InputSpec{"FDDdigitChinput", "FDD", "DIGITSCH"}, "FDDDigitCh"},
78 BranchDefinition<std::vector<o2::fdd::DetTrigInput>>{InputSpec{"FDDdigitTrinput", "FDD", "TRIGGERINPUT"}, "TRIGGERINPUT"},
79 std::move(labelsdef))();
80 } else {
81 return MakeRootTreeWriterSpec("FDDDigitWriterRaw",
82 "o2_fdddigits.root",
83 "o2sim",
85 BranchDefinition<std::vector<o2::fdd::Digit>>{InputSpec{"FDDdigitBCinput", "FDD", "DIGITSBC"}, "FDDDigit"},
86 BranchDefinition<std::vector<o2::fdd::ChannelData>>{InputSpec{"FDDdigitChinput", "FDD", "DIGITSCH"}, "FDDDigitCh"},
87 std::move(labelsdef))();
88 }
89}
90
91} // end namespace fdd
92} // end namespace o2
93
94#endif /* STEER_DIGITIZERWORKFLOW_SRC_FDDDIGITWRITERSPEC_H_ */
A const (ready only) version of MCTruthContainer.
A special IO container - splitting a given vector to enable ROOT IO.
Configurable generator for RootTreeWriter processor spec.
TBranch * ptr
Generate a processor spec for the RootTreeWriter utility.
static TBranch * remapBranch(TBranch &branchRef, T **newdata)
GLdouble n
Definition glcorearb.h:1982
GLint ref
Definition glcorearb.h:291
o2::framework::DataProcessorSpec getFDDDigitWriterSpec(bool mctruth=true, bool trigInp=true)
struct o2::upgrades_utils::@459 fdd
Collision labels.
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"