EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HelloWorld.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HelloWorld.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
11 
15 
16 #include <cstdlib>
17 #include <memory>
18 
19 #include "HelloLoggerAlgorithm.hpp"
20 #include "HelloRandomAlgorithm.hpp"
21 #include "HelloService.hpp"
23 
24 int main(int argc, char* argv[]) {
25  // setup options
26  // every component should have an associated option setup function
27  // that should be called here.
31  // parse options from command line flags
32  auto vm = ActsExamples::Options::parse(opt, argc, argv);
33  // an empty varaibles map indicates an error
34  if (vm.empty()) {
35  return EXIT_FAILURE;
36  }
37 
38  // extract some common options
39  auto logLevel = ActsExamples::Options::readLogLevel(vm);
40 
41  // setup basic tools shared among algorithms
42  auto rnd = std::make_shared<ActsExamples::RandomNumbers>(
44 
45  // setup the sequencer first w/ config derived from options
46  ActsExamples::Sequencer sequencer(
48 
49  // add HelloWorld algorithm that does nothing
50  sequencer.addAlgorithm(
51  std::make_shared<ActsExamples::HelloLoggerAlgorithm>(logLevel));
52 
53  // add HelloRandom algorithm that uses RandomNumbers to generate some
54  // random numbers from various distributions.
56  rndCfg.randomNumbers = rnd;
57  rndCfg.gaussParameters = {{0., 2.5}};
58  rndCfg.uniformParameters = {{-1.23, 4.25}};
59  rndCfg.gammaParameters = {{1., 1.}};
60  rndCfg.drawsPerEvent = 5000;
61  rndCfg.output = "random_data";
62  sequencer.addAlgorithm(
63  std::make_shared<ActsExamples::HelloRandomAlgorithm>(rndCfg, logLevel));
64 
65  // add HelloWhiteBoardAlgorithm the reads/writes data from/to the event store
67  // use data from previous algorithm as input
68  wbCfg.input = rndCfg.output;
69  wbCfg.output = "copied_data";
70  sequencer.addAlgorithm(
71  std::make_shared<ActsExamples::HelloWhiteBoardAlgorithm>(wbCfg,
72  logLevel));
73 
74  // add HelloService that generates an event block index.
76  svcCfg.eventsPerBlock = 3;
77  sequencer.addService(
78  std::make_shared<ActsExamples::HelloService>(svcCfg, logLevel));
79 
80  // Run all configured algorithms and return the appropriate status.
81  return sequencer.run();
82 }