Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:18

0001 
0002 // Copyright 2020, Jefferson Science Associates, LLC.
0003 // Subject to the terms in the LICENSE file found in the top-level directory.
0004 
0005 #ifndef JANA2_DSTEXAMPLE_DATAOBJECTS_H
0006 #define JANA2_DSTEXAMPLE_DATAOBJECTS_H
0007 
0008 #include <JANA/JObject.h>
0009 
0010 /// Renderable is another base class. We strongly encourage users to
0011 /// stick to _implementation_inheritance_, aka no member variables and all
0012 /// member functions are pure virtual.
0013 struct Renderable {
0014     virtual void Render() = 0;
0015     virtual ~Renderable() = default;
0016 };
0017 
0018 struct MyJObject : public JObject {
0019     int x;
0020     int y;
0021     double E;
0022 
0023     MyJObject(int x, int y, double E) : x(x), y(y), E(E) {};
0024 
0025     void Summarize(JObjectSummary& summary) const override {
0026         summary.add(x, NAME_OF(x), "%d", "Pixel coordinates centered around 0,0");
0027         summary.add(y, NAME_OF(y), "%d", "Pixel coordinates centered around 0,0");
0028         summary.add(E, NAME_OF(E), "%f", "Energy loss in GeV");
0029     }
0030 
0031     const std::string className() const override {
0032         return NAME_OF_THIS;
0033     }
0034 };
0035 
0036 struct MyRenderable : public Renderable {
0037     int x;
0038     int y;
0039     double E;
0040 
0041     MyRenderable(int x, int y, double E) : x(x), y(y), E(E) {
0042     };
0043 
0044     void Render() override {
0045         LOG << "MyRenderable::Render " << x << "," << y << "," << E << LOG_END;
0046     }
0047 };
0048 
0049 struct MyRenderableJObject : public JObject, Renderable {
0050     int x;
0051     int y;
0052     double E;
0053 
0054     /// Constructor
0055 
0056     MyRenderableJObject(int x, int y, double E) : x(x), y(y), E(E) {};
0057 
0058     /// Renderable vfunctions
0059 
0060     void Render() override {
0061         LOG << "MyRenderableJObject::Render " << x << "," << y << "," << E << LOG_END;
0062     }
0063 
0064     /// JObject vfunctions
0065 
0066     void Summarize(JObjectSummary& summary) const override {
0067         summary.add(x, NAME_OF(x), "%d", "Pixel coordinates centered around 0,0");
0068         summary.add(y, NAME_OF(y), "%d", "Pixel coordinates centered around 0,0");
0069         summary.add(E, NAME_OF(E), "%f", "Energy loss in GeV");
0070     }
0071 
0072     const std::string className() const override {
0073         return NAME_OF_THIS;
0074     }
0075 };
0076 
0077 #endif //JANA2_DATAOBJECTS_H