MarlinMT  0.1.0
ProcessorApi.h
Go to the documentation of this file.
1 #ifndef MARLINMT_PROCESSORAPI_h
2 #define MARLINMT_PROCESSORAPI_h 1
3 
4 // -- std headers
5 #include <array>
6 #include <filesystem>
7 #include <optional>
8 #include <string>
9 
10 // -- marlinmt headers
11 #include <marlinmt/Processor.h>
12 #include <marlinmt/Application.h>
16 
17 
18 namespace marlinmt {
19 
20  class Processor ;
21 
32  class InternalClass;
33 
34  class ProcessorApi {
35  public:
36  // only static API
37  ProcessorApi() = delete ;
38  ~ProcessorApi() = delete ;
39 
43  class Book {
44  public:
45  // book histogram float
46 
57  [[nodiscard]] static H1FEntry bookHist1F (
58  Processor *proc,
59  const std::filesystem::path &path,
60  const std::string_view &name,
61  const std::string_view &title,
62  const AxisConfigD &axisconfig,
63  const BookFlag_t &flags = BookFlags::Default ) ;
64 
76  [[nodiscard]] static H2FEntry bookHist2F (
77  Processor *proc,
78  const std::filesystem::path &path,
79  const std::string_view &name,
80  const std::string_view &title,
81  const AxisConfigD &axisconfigX,
82  const AxisConfigD &axisconfigY,
83  const BookFlag_t &flags = BookFlags::Default ) ;
84 
97  [[nodiscard]] static H3FEntry bookHist3F (
98  Processor *proc,
99  const std::filesystem::path &path,
100  const std::string_view &name,
101  const std::string_view &title,
102  const AxisConfigD &axisconfigX,
103  const AxisConfigD &axisconfigY,
104  const AxisConfigD &axisconfigZ,
105  const BookFlag_t &flags = BookFlags::Default ) ;
106 
107  // book histogram double
108 
119  [[nodiscard]] static H1DEntry bookHist1D (
120  Processor *proc,
121  const std::filesystem::path &path,
122  const std::string_view &name,
123  const std::string_view &title,
124  const AxisConfigD &axisconfig,
125  const BookFlag_t &flags = BookFlags::Default ) ;
126 
138  [[nodiscard]] static H2DEntry bookHist2D (
139  Processor *proc,
140  const std::filesystem::path &path,
141  const std::string_view &name,
142  const std::string_view &title,
143  const AxisConfigD &axisconfigX,
144  const AxisConfigD &axisconfigY,
145  const BookFlag_t &flags = BookFlags::Default ) ;
146 
159  [[nodiscard]] static H3DEntry bookHist3D (
160  Processor *proc,
161  const std::filesystem::path &path,
162  const std::string_view &name,
163  const std::string_view &title,
164  const AxisConfigD &axisconfigX,
165  const AxisConfigD &axisconfigY,
166  const AxisConfigD &axisconfigZ,
167  const BookFlag_t &flags = BookFlags::Default ) ;
168 
169  // book histogram integer
170 
181  [[nodiscard]] static H1IEntry bookHist1I (
182  Processor *proc,
183  const std::filesystem::path &path,
184  const std::string_view &name,
185  const std::string_view &title,
186  const AxisConfigD &axisconfig,
187  const BookFlag_t &flags = BookFlags::Default ) ;
188 
200  [[nodiscard]] static H2IEntry bookHist2I (
201  Processor *proc,
202  const std::filesystem::path &path,
203  const std::string_view &name,
204  const std::string_view &title,
205  const AxisConfigD &axisconfigX,
206  const AxisConfigD &axisconfigY,
207  const BookFlag_t &flags = BookFlags::Default ) ;
208 
221  [[nodiscard]] static H3IEntry bookHist3I (
222  Processor *proc,
223  const std::filesystem::path &path,
224  const std::string_view &name,
225  const std::string_view &title,
226  const AxisConfigD &axisconfigX,
227  const AxisConfigD &axisconfigY,
228  const AxisConfigD &axisconfigZ,
229  const BookFlag_t &flags = BookFlags::Default ) ;
230 
231  // get histogram float
232 
240  [[nodiscard]] static H1FEntry getHist1F (
241  const Processor *proc,
242  const std::filesystem::path &path,
243  const std::string_view &name ) ;
244 
252  [[nodiscard]] static H2FEntry getHist2F (
253  const Processor *proc,
254  const std::filesystem::path &path,
255  const std::string_view &name ) ;
256 
264  [[nodiscard]] static H3FEntry getHist3F (
265  const Processor *proc,
266  const std::filesystem::path &path,
267  const std::string_view &name ) ;
268 
269  // get histogram double
270 
278  [[nodiscard]] static H1DEntry getHist1D (
279  const Processor *proc,
280  const std::filesystem::path &path,
281  const std::string_view &name ) ;
282 
290  [[nodiscard]] static H2DEntry getHist2D (
291  const Processor *proc,
292  const std::filesystem::path &path,
293  const std::string_view &name ) ;
294 
302  [[nodiscard]] static H3DEntry getHist3D (
303  const Processor *proc,
304  const std::filesystem::path &path,
305  const std::string_view &name ) ;
306 
307  // get histogram integer
308 
316  [[nodiscard]] static H1IEntry getHist1I (
317  const Processor *proc,
318  const std::filesystem::path &path,
319  const std::string_view &name ) ;
320 
328  [[nodiscard]] static H2IEntry getHist2I (
329  const Processor *proc,
330  const std::filesystem::path &path,
331  const std::string_view &name ) ;
332 
340  [[nodiscard]] static H3IEntry getHist3I (
341  const Processor *proc,
342  const std::filesystem::path &path,
343  const std::string_view &name ) ;
344 
345 
346 
354  static void write(
355  Processor * proc,
356  const std::filesystem::path &path,
357  const std::string_view &name) ;
358 
365  static void dontWrite(
366  Processor * proc,
367  const std::filesystem::path &path,
368  const std::string_view &name) ;
369 
375  static void write(
376  Processor *proc,
377  const book::EntryKey &key) ;
378 
383  static void dontWrite(
384  Processor *proc,
385  const book::EntryKey &key) ;
386  };
387 
393  static void registerForRandomSeeds( Processor *const proc ) ;
394 
402  static unsigned int getRandomSeed( const Processor *const proc, EventStore *event ) ;
403 
411  static void setReturnValue( const Processor *const proc, EventStore *event, bool value ) ;
412 
421  static void setReturnValue( const Processor *const proc, EventStore *event, const std::string &name, bool value ) ;
422 
433  static bool isFirstEvent( EventStore *event ) ;
434 
440  template <typename HANDLER>
441  static const HANDLER* geometry( const Processor *const proc ) ;
442 
449  static void skipCurrentEvent( const Processor *const proc ) ;
450 
457  static void abort( const Processor *const proc, const std::string &reason ) ;
458  };
459 
460  //--------------------------------------------------------------------------
461 
462  template <typename HANDLER>
463  inline const HANDLER* ProcessorApi::geometry( const Processor *const proc ) {
464  return proc->application().geometryManager().geometry<HANDLER>() ;
465  }
466 
467 }
468 
469 #endif
static bool isFirstEvent(EventStore *event)
Whether the event is the first event to be processed.
Data selection to identify and manage an Entry.
Definition: EntryData.h:21
static H3DEntry getHist3D(const Processor *proc, const std::filesystem::path &path, const std::string_view &name)
Get handle for booked histogram 3D, double type.
static H1IEntry getHist1I(const Processor *proc, const std::filesystem::path &path, const std::string_view &name)
Get handle for booked histogram 1D, integer type.
static const HANDLER * geometry(const Processor *const proc)
Get the geometry handle as a given type.
Definition: ProcessorApi.h:463
static H1DEntry getHist1D(const Processor *proc, const std::filesystem::path &path, const std::string_view &name)
Get handle for booked histogram 1D, double type.
static H3FEntry bookHist3F(Processor *proc, const std::filesystem::path &path, const std::string_view &name, const std::string_view &title, const AxisConfigD &axisconfigX, const AxisConfigD &axisconfigY, const AxisConfigD &axisconfigZ, const BookFlag_t &flags=BookFlags::Default)
Book a histogram 3D, float type.
Definition: ProcessorApi.cc:95
constexpr unsigned long long value(const Flag_t &flag)
Definition: Flags.h:106
static H1IEntry bookHist1I(Processor *proc, const std::filesystem::path &path, const std::string_view &name, const std::string_view &title, const AxisConfigD &axisconfig, const BookFlag_t &flags=BookFlags::Default)
Book a histogram 1D, integer type.
static H1FEntry bookHist1F(Processor *proc, const std::filesystem::path &path, const std::string_view &name, const std::string_view &title, const AxisConfigD &axisconfig, const BookFlag_t &flags=BookFlags::Default)
Book a histogram 1D, float type.
Definition: ProcessorApi.cc:38
static H2DEntry bookHist2D(Processor *proc, const std::filesystem::path &path, const std::string_view &name, const std::string_view &title, const AxisConfigD &axisconfigX, const AxisConfigD &axisconfigY, const BookFlag_t &flags=BookFlags::Default)
Book a histogram 2D, double type.
Flag type for flags in marlinmt::book.
Definition: Flags.h:15
static H2IEntry getHist2I(const Processor *proc, const std::filesystem::path &path, const std::string_view &name)
Get handle for booked histogram 2D, integer type.
static H2FEntry bookHist2F(Processor *proc, const std::filesystem::path &path, const std::string_view &name, const std::string_view &title, const AxisConfigD &axisconfigX, const AxisConfigD &axisconfigY, const BookFlag_t &flags=BookFlags::Default)
Book a histogram 2D, float type.
Definition: ProcessorApi.cc:66
static H3IEntry bookHist3I(Processor *proc, const std::filesystem::path &path, const std::string_view &name, const std::string_view &title, const AxisConfigD &axisconfigX, const AxisConfigD &axisconfigY, const AxisConfigD &axisconfigZ, const BookFlag_t &flags=BookFlags::Default)
Book a histogram 3D, integer type.
static unsigned int getRandomSeed(const Processor *const proc, EventStore *event)
Get a random seed from the event.
static void write(Processor *proc, const std::filesystem::path &path, const std::string_view &name)
register Object to write it at end of lifetime.
static void abort(const Processor *const proc, const std::string &reason)
Abort program execution properly.
collection for Axis Description
Definition: Base.h:23
const GeometryManager & geometryManager() const
Get the geometry manager.
Definition: Application.cc:237
const T * geometry() const
Get the underlying geometry handle Example:
static H1DEntry bookHist1D(Processor *proc, const std::filesystem::path &path, const std::string_view &name, const std::string_view &title, const AxisConfigD &axisconfig, const BookFlag_t &flags=BookFlags::Default)
Book a histogram 1D, double type.
const Application & application() const
Get the application in which the component is registered.
Definition: Component.cc:83
static H2IEntry bookHist2I(Processor *proc, const std::filesystem::path &path, const std::string_view &name, const std::string_view &title, const AxisConfigD &axisconfigX, const AxisConfigD &axisconfigY, const BookFlag_t &flags=BookFlags::Default)
Book a histogram 2D, integer type.
constexpr Flag_t Default(0)
use default arguments
static H3IEntry getHist3I(const Processor *proc, const std::filesystem::path &path, const std::string_view &name)
Get handle for booked histogram 3D, integer type.
vanilla Handle.
Definition: Handle.h:54
static H2FEntry getHist2F(const Processor *proc, const std::filesystem::path &path, const std::string_view &name)
Get handle for booked histogram 2D, float type.
Definition: ProcessorApi.cc:84
static H3DEntry bookHist3D(Processor *proc, const std::filesystem::path &path, const std::string_view &name, const std::string_view &title, const AxisConfigD &axisconfigX, const AxisConfigD &axisconfigY, const AxisConfigD &axisconfigZ, const BookFlag_t &flags=BookFlags::Default)
Book a histogram 3D, double type.
static void skipCurrentEvent(const Processor *const proc)
Notify the application to skip the current event processing and go directly to the next event by skip...
group function for booking
Definition: ProcessorApi.h:43
Processor class.
Definition: Processor.h:43
static H2DEntry getHist2D(const Processor *proc, const std::filesystem::path &path, const std::string_view &name)
Get handle for booked histogram 2D, double type.
static H1FEntry getHist1F(const Processor *proc, const std::filesystem::path &path, const std::string_view &name)
Get handle for booked histogram 1D, float type.
Definition: ProcessorApi.cc:55
static void dontWrite(Processor *proc, const std::filesystem::path &path, const std::string_view &name)
cancels writing of Object at end of lifetime.
static void setReturnValue(const Processor *const proc, EventStore *event, bool value)
Set the processor return value.
static H3FEntry getHist3F(const Processor *proc, const std::filesystem::path &path, const std::string_view &name)
Get handle for booked histogram 3D, float type.
static void registerForRandomSeeds(Processor *const proc)
Register the processor to get random seeds.
EventStore class.
Definition: EventStore.h:17