ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeantinoRecording.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GeantinoRecording.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 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 
10 
11 #include <FTFP_BERT.hh>
12 #include <iostream>
13 #include <stdexcept>
14 
21 
24  : FW::BareAlgorithm("GeantinoRecording", level),
25  m_cfg(cnf),
26  m_runManager(std::make_unique<G4RunManager>()) {
28  if (m_cfg.geant4Service) {
29  m_runManager->SetUserInitialization(m_cfg.geant4Service->geant4Geometry());
30  } else if (!m_cfg.gdmlFile.empty()) {
32  ACTS_INFO(
33  "received Geant4 geometry from GDML file: " << m_cfg.gdmlFile.c_str());
34  FW::Geant4::MMDetectorConstruction* detConstruction =
36  detConstruction->setGdmlInput(m_cfg.gdmlFile.c_str());
37  m_runManager->SetUserInitialization(
38  detConstruction); // constructs detector (calls Construct in
39  // Geant4DetectorConstruction)
40  } else {
41  throw std::invalid_argument("Missing geometry input for Geant4");
42  }
43 
45  m_runManager->SetUserInitialization(new FTFP_BERT);
47  "geantino", 1000., m_cfg.seed1, m_cfg.seed2));
49  m_runManager->SetUserAction(runaction);
50  m_runManager->SetUserAction(new FW::Geant4::MMEventAction());
51  m_runManager->SetUserAction(new FW::Geant4::MMSteppingAction());
52  m_runManager->Initialize();
53 }
54 
56  const FW::AlgorithmContext& context) const {
57  // Begin with the simulation
58  m_runManager->BeamOn(m_cfg.tracksPerEvent);
59  // Retrieve the track material tracks from Geant4
60  auto recordedMaterial =
62  ACTS_INFO("Received " << recordedMaterial.size()
63  << " MaterialTracks. Writing them now onto file...");
64 
65  // Write the recorded material to the event store
66  context.eventStore.add(m_cfg.geantMaterialCollection,
67  std::move(recordedMaterial));
68 
69  // // Retrieve the sim hit track steps from Geant4
70  // auto trackSteps = FW::Geant4::MMEventAction::Instance()->TrackSteps();
71  // ACTS_INFO("Received " << trackSteps.size()
72  // << " steps per track. Writing them now into
73  // file...");
74  //
75  // // Write the sim hit track steps info to the event store
76  // context.eventStore.add(m_cfg.geantTrackStepCollection,
77  // std::move(trackSteps));
79 }