Project
Loading...
Searching...
No Matches
FV0DigitWriterSpec.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
14
15namespace o2
16{
17namespace fv0
18{
19
20template <typename T>
22
24{
27 // Spectators for logging
28 auto logger = [](std::vector<o2::fv0::Digit> const& vecDigits) {
29 LOG(debug) << "FV0DigitWriter pulled " << vecDigits.size() << " digits";
30 };
31 // the callback to be set as hook for custom action when the writer is closed
32 auto finishWriting = [](TFile* outputfile, TTree* outputtree) {
33 const auto* brArr = outputtree->GetListOfBranches();
34 int64_t nent = 0;
35 for (const auto* brc : *brArr) {
36 int64_t n = ((const TBranch*)brc)->GetEntries();
37 if (nent && (nent != n)) {
38 LOG(error) << "Branches have different number of entries";
39 }
40 nent = n;
41 }
42 outputtree->SetEntries(nent);
43 outputtree->Write();
44 outputfile->Close();
45 };
46
47 auto labelsdef = BranchDefinition<o2::dataformats::MCTruthContainer<o2::fv0::MCLabel>>{InputSpec{"labelinput", "FV0", "DIGITSMCTR"},
48 "FV0DIGITSMCTR", mctruth ? 1 : 0};
49 if (trigInp) {
50 return MakeRootTreeWriterSpec("FV0DigitWriter",
51 "fv0digits.root",
52 "o2sim",
54 BranchDefinition<std::vector<o2::fv0::Digit>>{InputSpec{"digitBCinput", "FV0", "DIGITSBC"}, "FV0DigitBC", 1,
55 logger},
56 BranchDefinition<std::vector<o2::fv0::ChannelData>>{InputSpec{"digitChinput", "FV0", "DIGITSCH"}, "FV0DigitCh"},
57 BranchDefinition<std::vector<o2::fv0::DetTrigInput>>{InputSpec{"digitTrinput", "FV0", "TRIGGERINPUT"}, "TRIGGERINPUT"},
58 std::move(labelsdef))();
59 } else {
60 return MakeRootTreeWriterSpec("FV0DigitWriterRaw",
61 "o2_fv0digits.root",
62 "o2sim",
64 BranchDefinition<std::vector<o2::fv0::Digit>>{InputSpec{"digitBCinput", "FV0", "DIGITSBC"}, "FV0DigitBC", 1,
65 logger},
66 BranchDefinition<std::vector<o2::fv0::ChannelData>>{InputSpec{"digitChinput", "FV0", "DIGITSCH"}, "FV0DigitCh"},
67 std::move(labelsdef))();
68 }
69}
70
71} // end namespace fv0
72} // end namespace o2
std::ostringstream debug
Generate a processor spec for the RootTreeWriter utility.
GLdouble n
Definition glcorearb.h:1982
framework::DataProcessorSpec getFV0DigitWriterSpec(bool mctruth=true, bool trigInp=true)
create a processor spec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"