Project
Loading...
Searching...
No Matches
PublisherSpec.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_EMCAL_PUBLISHER_SPEC
13#define O2_EMCAL_PUBLISHER_SPEC
14
18#include "Framework/Output.h"
22#include <string>
23#include <vector>
24
25namespace o2
26{
27
28namespace emcal
29{
30
32
50
51template <typename T = void>
52framework::DataProcessorSpec getPublisherSpec(PublisherConf const& config, uint32_t subspec = 0, bool propagateMC = true)
53{
54 using Reader = o2::framework::RootTreeReader;
56 using TriggerInputType = std::vector<o2::emcal::TriggerRecord>;
60
61 // a creator callback for the actual reader instance
62 auto creator = [dto, tro, mco, subspec, propagateMC](const char* treename, const char* filename, int nofEvents, Reader::PublishingMode publishingMode, const char* branchname, const char* triggerbranchname, const char* mcbranchname) {
63 if (propagateMC) {
64 return std::make_shared<Reader>(treename,
66 nofEvents,
67 publishingMode,
68 Output{mco.origin, mco.description, subspec},
69 mcbranchname,
70 Reader::BranchDefinition<T>{Output{dto.origin, dto.description, subspec}, branchname},
71 Reader::BranchDefinition<TriggerInputType>{Output{tro.origin, tro.description, subspec}, triggerbranchname});
72 } else {
73 return std::make_shared<Reader>(treename,
75 nofEvents,
76 publishingMode,
77 Reader::BranchDefinition<T>{Output{dto.origin, dto.description, subspec}, branchname},
78 Reader::BranchDefinition<TriggerInputType>{Output{tro.origin, tro.description, subspec}, triggerbranchname});
79 }
80 };
81
82 return createPublisherSpec(config, subspec, propagateMC, creator);
83}
84
86{
87 using cellInputType = std::vector<o2::emcal::Cell>;
88 return getPublisherSpec<cellInputType>(PublisherConf{"emcal-cell-reader",
89 "o2sim",
90 "emccells.root",
91 {"cellbranch", "EMCALCell", "Cell branch"},
92 {"celltriggerbranch", "EMCALCellTRGR", "Trigger record branch"},
93 {"mcbranch", "EMCALCellMCTruth", "MC label branch"},
94 o2::framework::OutputSpec{"EMC", "CELLS"},
95 o2::framework::OutputSpec{"EMC", "CELLSTRGR"},
96 o2::framework::OutputSpec{"EMC", "CELLSMCTR"}},
97 0,
98 propagateMC);
99}
100
101namespace workflow_reader
102{
104using Creator = std::function<std::shared_ptr<Reader>(const char*, const char*, int, Reader::PublishingMode, const char*, const char*, const char*)>;
105} // namespace workflow_reader
106
107framework::DataProcessorSpec createPublisherSpec(PublisherConf const& config, uint32_t subspec, bool propagateMC, workflow_reader::Creator creator);
108
109} // namespace emcal
110} // end namespace o2
111
112#endif // O2_EMCAL_PUBLISHER_SPEC
A generic reader for ROOT TTrees.
PublishingMode
Publishing mode determines what to do when the number of entries in the tree is reached.
std::function< std::shared_ptr< Reader >(const char *, const char *, int, Reader::PublishingMode, const char *, const char *, const char *)> Creator
framework::DataProcessorSpec createPublisherSpec(PublisherConf const &config, uint32_t subspec, bool propagateMC, workflow_reader::Creator creator)
framework::DataProcessorSpec getPublisherSpec(PublisherConf const &config, uint32_t subspec=0, bool propagateMC=true)
framework::DataProcessorSpec getCellReaderSpec(bool propagateMC)
GenericRootTreeReader< rtr::DefaultKey > RootTreeReader
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()
BranchOptionConfig triggerrecordbranch
BranchOptionConfig databranch
BranchOptionConfig mcbranch
static ConcreteDataTypeMatcher asConcreteDataTypeMatcher(OutputSpec const &spec)
header::DataOrigin origin
Definition Output.h:28