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"
17
19
20using namespace o2::framework;
21using namespace o2::steer;
22
24 Configurable<std::string> kineFileName{"kineFileName", "o2sim", "name of the _Kine.root file (without '_Kine.root')"};
25 Configurable<int> aggregate{"aggregate-timeframe", 300, "Number of events to put in a timeframe"};
26
27 int nEvents = 0;
28 int eventCounter = 0;
29 int tfCounter = 0;
30 std::shared_ptr<MCKinematicsReader> mcKinReader = std::make_shared<MCKinematicsReader>();
31
33 {
34 if (mcKinReader->initFromKinematics((std::string)kineFileName)) {
35 nEvents = mcKinReader->getNEvents(0);
36 } else {
37 LOGP(fatal, "Cannot open kine file {}", (std::string)kineFileName);
38 }
39 }
40
42 {
43 auto batch = std::min((int)aggregate, nEvents - eventCounter);
44 for (auto i = 0; i < batch; ++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::wrapWithTimesliceConsumption(spec.algorithm);
68 return {spec};
69}
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
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 ITS Vertex explicitly as messageable.
Definition Cartesian.h:288
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 wrapWithTimesliceConsumption(AlgorithmSpec spec)