Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- // mock TDataFrameGuessedType (maybe better than the original?)
- using ToGuess = void;
- // mock TH1F
- class TH1F {
- public:
- TH1F(unsigned int nbins, double xmin, double xmax){};
- };
- // mock TH2F
- class TH2F {
- public:
- TH2F(unsigned int nbins, double xmin, double xmax, double ymin, double ymax){};
- };
- // mock TH3F
- class TH3F {
- public:
- TH3F(unsigned int nbins, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax){};
- };
- // mock TDataFrameInterface
- class TDataFrameInterface {
- public:
- // Histo1D w/o weights
- template<typename V = ToGuess>
- TH1F Histo1D(TH1F&& h = TH1F{128u,0.,0.}, const std::string& v = "");
- template<typename V = ToGuess>
- TH1F Histo1D(const std::string& v);
- // Histo1D w/ weights
- template<typename V = ToGuess, typename W = ToGuess>
- TH1F Histo1D(TH1F&& h, const std::string& v, const std::string& w);
- template<typename V = ToGuess, typename W = ToGuess>
- TH1F Histo1D(const std::string& v, const std::string& w);
- template<typename V, typename W>
- TH1F Histo1D(TH1F&& h = TH1F{128u,0.,0.});
- // Histo2D w/o weights
- template<typename V1 = ToGuess, typename V2 = ToGuess>
- TH2F Histo2D(TH2F&& h, const std::string& v1 = "", const std::string& v2 = "");
- // Histo2D w/ weights
- template<typename V1 = ToGuess, typename V2 = ToGuess, typename W = ToGuess>
- TH2F Histo2D(TH2F&& h, const std::string& v1, const std::string& v2, const std::string& w);
- template<typename V1, typename V2, typename W>
- TH2F Histo2D(TH2F&& h);
- // Histo3D w/o weights
- template<typename V1 = ToGuess, typename V2 = ToGuess, typename V3 = ToGuess>
- TH3F Histo3D(TH3F&& h, const std::string& v1 = "", const std::string& v2 = "", const std::string& v3 = "");
- // Histo3D w/ weights
- template<typename V1 = ToGuess, typename V2 = ToGuess, typename V3 = ToGuess, typename W = ToGuess>
- TH3F Histo3D(TH3F&& h, const std::string& v1, const std::string& v2, const std::string& v3, const std::string& w);
- template<typename V1, typename V2, typename V3, typename W>
- TH3F Histo3D(TH3F&& h);
- };
- int main() {
- TDataFrameInterface d;
- // histogram w/o weights -- these calls are all equivalent
- d.Histo1D();
- d.Histo1D<int>();
- d.Histo1D("v");
- d.Histo1D<int>("v");
- // histogram w/ weights -- these calls are all equivalent
- d.Histo1D("v", "w");
- d.Histo1D<int>("v", "w");
- d.Histo1D<int, double>("v", "w");
- d.Histo1D<int, double>();
- // histo2D w/o weights
- d.Histo2D(TH2F{128u,0.,1.,0.,1.});
- d.Histo2D(TH2F{128u,0.,1.,0.,1.}, "v1");
- d.Histo2D(TH2F{128u,0.,1.,0.,1.}, "v1", "v2");
- d.Histo2D<int>(TH2F{128u,0.,1.,0.,1.});
- d.Histo2D<int>(TH2F{128u,0.,1.,0.,1.}, "v1");
- d.Histo2D<int>(TH2F{128u,0.,1.,0.,1.}, "v1", "v2");
- d.Histo2D<int,int>(TH2F{128u,0.,1.,0.,1.});
- d.Histo2D<int,int>(TH2F{128u,0.,1.,0.,1.}, "v1");
- d.Histo2D<int,int>(TH2F{128u,0.,1.,0.,1.}, "v1", "v2");
- // histo2D w/ weights
- d.Histo2D(TH2F{128u,0.,1.,0.,1.}, "v1", "v2", "w");
- d.Histo2D<int>(TH2F{128u,0.,1.,0.,1.}, "v1", "v2", "w");
- d.Histo2D<int,int>(TH2F{128u,0.,1.,0.,1.}, "v1", "v2", "w");
- d.Histo2D<int,int,double>(TH2F{128u,0.,1.,0.,1.}, "v1", "v2", "w");
- d.Histo2D<int,int,double>(TH2F{128u,0.,1.,0.,1.});
- // Histo3D w/o weights
- d.Histo3D(TH3F{128u,0.,1.,0.,1.,0.,1.});
- d.Histo3D(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1");
- d.Histo3D(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2");
- d.Histo3D(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2", "v3");
- d.Histo3D<int>(TH3F{128u,0.,1.,0.,1.,0.,1.});
- d.Histo3D<int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1");
- d.Histo3D<int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2");
- d.Histo3D<int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2", "v3");
- d.Histo3D<int,int>(TH3F{128u,0.,1.,0.,1.,0.,1.});
- d.Histo3D<int,int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1");
- d.Histo3D<int,int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2");
- d.Histo3D<int,int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2", "v3");
- d.Histo3D<int,int,int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1");
- d.Histo3D<int,int,int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2");
- d.Histo3D<int,int,int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2", "v3");
- // Histo3D w/ weights
- d.Histo3D(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2", "v3", "w");
- d.Histo3D<int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2", "v3", "w");
- d.Histo3D<int,int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2", "v3", "w");
- d.Histo3D<int,int,int>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2", "v3", "w");
- d.Histo3D<int,int,int,double>(TH3F{128u,0.,1.,0.,1.,0.,1.}, "v1", "v2", "v3", "w");
- d.Histo3D<int,int,int,double>(TH3F{128u,0.,1.,0.,1.,0.,1.});
- return 0;
- }
- // mock method implementations, for demonstration purposes only :)
- template <typename V>
- TH1F TDataFrameInterface::Histo1D(TH1F&& h, const std::string& v)
- {
- std::cout << "1D value" << std::endl;
- return h;
- }
- template<typename V>
- TH1F TDataFrameInterface::Histo1D(const std::string& v) {
- return Histo1D<V>(TH1F{128u,0.,0.}, v);
- }
- template <typename V, typename W>
- TH1F TDataFrameInterface::Histo1D(TH1F &&h, const std::string &v, const std::string &w)
- {
- std::cout << "1D value+weight" << std::endl;
- return h;
- }
- template <typename V, typename W>
- TH1F TDataFrameInterface::Histo1D(const std::string &v, const std::string &w)
- {
- return Histo1D<V,W>(TH1F{128u,0.,0.}, v, w);
- }
- template <typename V, typename W>
- TH1F TDataFrameInterface::Histo1D(TH1F &&h)
- {
- return Histo1D<V,W>(std::move(h),"","");
- }
- template<typename V1, typename V2>
- TH2F TDataFrameInterface::Histo2D(TH2F&& h, const std::string& v1, const std::string& v2) {
- std::cout << "2D value" << std::endl;
- return h;
- }
- template<typename V1, typename V2, typename W>
- TH2F TDataFrameInterface::Histo2D(TH2F&& h, const std::string& v1, const std::string& v2, const std::string& w) {
- std::cout << "2D value+weight" << std::endl;
- return h;
- }
- template<typename V1, typename V2, typename W>
- TH2F TDataFrameInterface::Histo2D(TH2F&& h) {
- return Histo2D<V1,V2,W>(std::move(h),"","","");
- }
- template<typename V1, typename V2, typename V3>
- TH3F TDataFrameInterface::Histo3D(TH3F&& h, const std::string& v1, const std::string& v2, const std::string& v3) {
- std::cout << "3D value" << std::endl;
- return h;
- }
- template<typename V1, typename V2, typename V3, typename W>
- TH3F TDataFrameInterface::Histo3D(TH3F&& h, const std::string& v1, const std::string& v2, const std::string& v3, const std::string& w) {
- std::cout << "3D value+weight" << std::endl;
- return h;
- }
- template<typename V1, typename V2, typename V3, typename W>
- TH3F TDataFrameInterface::Histo3D(TH3F&& h) {
- return Histo3D<V1, V2, V3, W>(std::move(h), "", "", "", "");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement