Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:19:07

0001 // TRENTO: Reduced Thickness Event-by-event Nuclear Topology
0002 // Copyright 2015 Jonah E. Bernhard, J. Scott Moreland
0003 // TRENTO3D: Three-dimensional extension of TRENTO by Weiyao Ke
0004 // MIT License
0005 
0006 #ifndef OUTPUT_H
0007 #define OUTPUT_H
0008 
0009 #include <functional>
0010 #include <utility>
0011 #include <vector>
0012 
0013 #include "fwd_decl.h"
0014 
0015 namespace trento {
0016 
0017 /// Simple interface for outputting event data.  Determines which output formats
0018 /// to create based on the configuration and writes those formats when called.
0019 class Output {
0020  public:
0021   /// Instantiate from the configuration.
0022   Output(const VarMap& var_map);
0023 
0024   /// \rst
0025   /// Call the functor to output event data.  Arguments are perfect-forwarded to
0026   /// each output function.  The required arguments are
0027   ///
0028   /// - ``int`` event number
0029   /// - ``double`` impact parameter
0030   /// - ``const Event&`` Event object
0031   ///
0032   /// \endrst
0033   template <typename... Args>
0034   void operator()(Args&&... args) const;
0035 
0036  private:
0037   /// Internal storage of output functions.
0038   std::vector<std::function<void(int, double, const Event&)>> writers_;
0039 };
0040 
0041 template <typename... Args>
0042 void Output::operator()(Args&&... args) const {
0043   for (const auto& write : writers_)
0044     write(std::forward<Args>(args)...);
0045 }
0046 
0047 }  // namespace trento
0048 
0049 #endif  // OUTPUT_H