9#include <tracking/modules/genfitUtilities/SetupGenfitExtrapolationModule.h>
10#include <tracking/modules/genfitUtilities/Geant4MaterialInterface.h>
12#include <geometry/GeometryManager.h>
14#include <tracking/gfbfield/GFGeant4Field.h>
15#include <genfit/FieldManager.h>
16#include <genfit/MaterialEffects.h>
17#include <genfit/TGeoMaterialInterface.h>
20#include <boost/iostreams/stream_buffer.hpp>
21#include <boost/iostreams/concepts.hpp>
23#include <TGeoManager.h>
33 template<
size_t T_level>
34 class genfitSink :
public boost::iostreams::sink {
37 std::streamsize write(
const char* s, std::streamsize n)
45 genfitSink<200> debugSink;
47 boost::iostreams::stream_buffer<genfitSink<200> > debugStreamBuf(debugSink);
49 genfitSink<100> errorSink;
51 boost::iostreams::stream_buffer<genfitSink<100> > errorStreamBuf(errorSink);
53 genfitSink<150> printSink;
55 boost::iostreams::stream_buffer<genfitSink<150> > printStreamBuf(printSink);
58 void setupGenfitStreams()
60 genfit::debugOut.rdbuf(&debugStreamBuf);
61 genfit::errorOut.rdbuf(&errorStreamBuf);
62 genfit::printOut.rdbuf(&printStreamBuf);
70 setDescription(
"Sets up material handling for genfit extrapolation. Also setups up I/O streams for"
71 " genfit in order to integrate it into basf2 logging system.");
75 "If true this module will silently ignore if the geometry is already "
76 "present and do nothing in that case. If false a B2FATAL will be "
81 "Which geometry should be used, either 'TGeo' or 'Geant4'",
m_geometry);
93 "activate the material effect: NoiseBrems",
m_noiseBrems);
95 "switch off all material effects in Genfit. This overwrites all "
96 "individual material effects switches",
m_noEffects);
105 if (genfit::FieldManager::getInstance()->isInitialized() or genfit::MaterialEffects::getInstance()->isInitialized()) {
107 B2DEBUG(29,
"Magnetic field or material handling already initialized. Not touching settings.");
110 B2FATAL(
"Magnetic field or material handling already initialized. Not touching settings.");
114 setupGenfitStreams();
116 genfit::FieldManager::getInstance()->init(
new GFGeant4Field());
123 B2FATAL(
"No geometry set up so far. Load the geometry module.");
128 B2INFO(
"Building TGeo representation.");
132 genfit::MaterialEffects::getInstance()->init(
new genfit::TGeoMaterialInterface());
136 B2FATAL(
"Invalid choice of geometry interface. Please use 'TGeo' or 'Geant4'.");
141 genfit::MaterialEffects::getInstance()->setNoEffects(
true);
145 genfit::MaterialEffects::getInstance()->setNoiseCoulomb(
m_noiseCoulomb);
147 genfit::MaterialEffects::getInstance()->setNoiseBrems(
m_noiseBrems);
148 genfit::MaterialEffects::getInstance()->setMscModel(
m_mscModel);
AbsMaterialInterface implementation for use with Geant4's navigator.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Class to manage the creation and conversion of the geometry.
static GeometryManager & getInstance()
Return a reference to the instance.
void createTGeoRepresentation()
Create a TGeo representation of the native geometry description.
Interface of the Belle II B-field with GenFit.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.