File indexing completed on 2025-01-18 09:55:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef DDDIGI_DIGIKERNEL_H
0014 #define DDDIGI_DIGIKERNEL_H
0015
0016
0017 #include <DDDigi/DigiActionSequence.h>
0018 #include <DDDigi/DigiParallelWorker.h>
0019
0020
0021 #include <mutex>
0022 #include <memory>
0023
0024
0025 class TH1;
0026
0027
0028 namespace dd4hep {
0029
0030
0031 namespace digi {
0032
0033
0034 class DigiAction;
0035 class DigiActionSequence;
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 class DigiKernel : public DigiAction {
0046 public:
0047 typedef std::map<std::string,int> ClientOutputLevels;
0048 typedef std::pair<void*, const std::type_info*> UserFramework;
0049
0050 private:
0051 class Internals;
0052 class Processor;
0053 template <typename ACTION, typename ARGUMENT> class Wrapper;
0054
0055
0056 Internals* internals { nullptr };
0057
0058 protected:
0059
0060 Detector* m_detDesc { nullptr };
0061
0062 mutable UserFramework m_userFramework;
0063
0064
0065 virtual void executeEvent(std::unique_ptr<DigiContext>&& context);
0066
0067 void notify(std::unique_ptr<DigiContext>&& context);
0068
0069 void notify(std::unique_ptr<DigiContext>&&, const std::exception& e);
0070
0071 protected:
0072
0073 DDDIGI_DEFINE_ACTION_CONSTRUCTORS(DigiKernel);
0074
0075 public:
0076
0077 DigiKernel(Detector& description);
0078
0079 public:
0080
0081 virtual ~DigiKernel();
0082
0083 #ifndef __CINT__
0084
0085 static DigiKernel& instance(Detector& description);
0086 #endif
0087
0088 Detector& detectorDescription() const { return *m_detDesc; }
0089
0090 UserFramework& userFramework() const { return m_userFramework; }
0091
0092 template <typename T> void setUserFramework(T* object) {
0093 m_userFramework = UserFramework(object,&typeid(T));
0094 }
0095
0096
0097 std::mutex& initializer_lock() const;
0098
0099
0100 std::mutex& global_io_lock() const;
0101
0102
0103 std::mutex& global_output_lock() const;
0104
0105
0106
0107 virtual void printProperties() const override;
0108
0109
0110
0111 void setOutputLevel(const std::string object, PrintLevel new_level);
0112
0113 PrintLevel getOutputLevel(const std::string object) const;
0114
0115
0116 std::size_t events_todo() const;
0117
0118 std::size_t events_done() const;
0119
0120 std::size_t events_processing() const;
0121
0122
0123 void register_configure(const std::function<void()>& callback) const;
0124
0125 void register_initialize(const std::function<void()>& callback) const;
0126
0127 void register_terminate(const std::function<void()>& callback) const;
0128
0129 void register_start_event(const std::function<void(DigiContext&)>& callback) const;
0130
0131 void register_end_event(const std::function<void(DigiContext&)>& callback) const;
0132
0133
0134 void register_monitor(DigiAction* action, TNamed* histo) const;
0135
0136
0137 virtual void loadGeometry(const std::string& compact_file);
0138
0139 virtual void loadXML(const char* fname);
0140
0141
0142 virtual int configure();
0143
0144 virtual int initialize();
0145
0146 virtual int run();
0147
0148 virtual int terminate();
0149
0150
0151 DigiActionSequence& inputAction() const;
0152
0153 DigiActionSequence& eventAction() const;
0154
0155 DigiActionSequence& outputAction() const;
0156
0157
0158 virtual void submit (DigiContext& context, ParallelCall*const algorithms[], std::size_t count, void* data, bool parallel=true) const;
0159
0160
0161 virtual void submit (DigiContext& context, const std::vector<ParallelCall*>& algorithms, void* data, bool parallel=true) const;
0162
0163
0164 virtual void wait(DigiContext& context) const;
0165
0166 };
0167 }
0168 }
0169 #endif