Project
Loading...
Searching...
No Matches
o2sim_kine_publisher.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
12#include "../Framework/Core/src/ArrowSupport.h"
14#include "Monitoring/Monitoring.h"
18
20
21using namespace o2::framework;
22using namespace o2::steer;
23
25 Configurable<std::string> kineFileName{"kineFileName", "o2sim", "name of the _Kine.root file (without '_Kine.root')"};
26 Configurable<int> aggregate{"aggregate-timeframe", 300, "Number of events to put in a timeframe"};
27
28 int nEvents = 0;
29 int eventCounter = 0;
30 int tfCounter = 0;
31 std::shared_ptr<MCKinematicsReader> mcKinReader = std::make_shared<MCKinematicsReader>();
32
34 {
35 if (mcKinReader->initFromKinematics((std::string)kineFileName)) {
36 nEvents = mcKinReader->getNEvents(0);
37 } else {
38 LOGP(fatal, "Cannot open kine file {}", (std::string)kineFileName);
39 }
40 }
41
43 {
44 for (auto i = 0; i < std::min((int)aggregate, nEvents - eventCounter); ++i) {
45 auto mcevent = mcKinReader->getMCEventHeader(0, eventCounter);
46 auto mctracks = mcKinReader->getTracks(0, eventCounter);
47 pc.outputs().snapshot(Output{"MC", "MCHEADER", 0}, mcevent);
48 pc.outputs().snapshot(Output{"MC", "MCTRACKS", 0}, mctracks);
50 }
51 // report number of TFs injected for the rate limiter to work
52 ++tfCounter;
53 pc.services().get<o2::monitoring::Monitoring>().send(o2::monitoring::Metric{(uint64_t)tfCounter, "df-sent"}.addTag(o2::monitoring::tags::Key::Subsystem, o2::monitoring::tags::Value::DPL));
54 if (eventCounter >= nEvents) {
55 pc.services().get<ControlService>().endOfStream();
56 pc.services().get<ControlService>().readyToQuit(QuitRequest::Me);
57 }
58 }
59};
60
62{
63 auto spec = adaptAnalysisTask<O2simKinePublisher>(cfgc);
64 spec.outputs.emplace_back("MC", "MCHEADER", 0, Lifetime::Timeframe);
65 spec.outputs.emplace_back("MC", "MCTRACKS", 0, Lifetime::Timeframe);
66 spec.requiredServices.push_back(o2::framework::ArrowSupport::arrowBackendSpec());
67 spec.algorithm = CommonDataProcessors::wrapWithRateLimiting(spec.algorithm);
68 return {spec};
69}
int32_t i
Definition of the MCTrack class.
void snapshot(const Output &spec, T const &object)
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
ServiceRegistryRef services()
The services registry associated with this processing context.
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
WorkflowSpec defineDataProcessing(ConfigContext const &cfgc)
This function hooks up the the workflow specifications into the DPL driver.
void init(o2::framework::InitContext &)
Configurable< int > aggregate
Configurable< std::string > kineFileName
void run(o2::framework::ProcessingContext &pc)
std::shared_ptr< MCKinematicsReader > mcKinReader
static ServiceSpec arrowBackendSpec()
static AlgorithmSpec wrapWithRateLimiting(AlgorithmSpec spec)