|
45 | 45 | #include "TProfile2D.h" |
46 | 46 | #include "TStatistic.h" |
47 | 47 |
|
| 48 | +#include "RConfigure.h" // for R__HAS_ROOT7 |
| 49 | +#ifdef R__HAS_ROOT7 |
| 50 | +#include <ROOT/RHist.hxx> |
| 51 | +#endif |
| 52 | + |
48 | 53 | #include <algorithm> |
49 | 54 | #include <cstddef> |
50 | 55 | #include <initializer_list> |
@@ -2357,6 +2362,66 @@ public: |
2357 | 2362 | columnList, h, h, fProxiedPtr, columnList.size()); |
2358 | 2363 | } |
2359 | 2364 |
|
| 2365 | +#ifdef R__HAS_ROOT7 |
| 2366 | + //////////////////////////////////////////////////////////////////////////// |
| 2367 | + /// \brief Fill and return an RHist (*lazy action*). |
| 2368 | + /// \tparam BinContentType The bin content type of the returned RHist. |
| 2369 | + /// \param[in] axes The returned histogram will be constructed using these axes. |
| 2370 | + /// \param[in] columnList A list containing the names of the columns that will be passed when calling `Fill` |
| 2371 | + /// \return the histogram wrapped in a RResultPtr. |
| 2372 | + /// |
| 2373 | + /// This action is *lazy*: upon invocation of this method the calculation is |
| 2374 | + /// booked but not executed. Also see RResultPtr. |
| 2375 | + /// |
| 2376 | + /// ### Example usage: |
| 2377 | + /// ~~~{.cpp} |
| 2378 | + /// ROOT::Experimental::RRegularAxis axis(10, {5.0, 15.0}); |
| 2379 | + /// auto myHist = myDf.Hist({axis}, {"col0"}); |
| 2380 | + /// ~~~ |
| 2381 | + template <typename BinContentType = double, typename ColumnType = RDFDetail::RInferredType, typename... ColumnTypes> |
| 2382 | + RResultPtr<ROOT::Experimental::RHist<BinContentType>> |
| 2383 | + Hist(std::vector<ROOT::Experimental::RAxisVariant> axes, const ColumnNames_t &columnList) |
| 2384 | + { |
| 2385 | + std::shared_ptr h = std::make_shared<ROOT::Experimental::RHist<BinContentType>>(std::move(axes)); |
| 2386 | + if (h->GetNDimensions() != columnList.size()) { |
| 2387 | + throw std::runtime_error("Wrong number of columns for the specified number of histogram axes."); |
| 2388 | + } |
| 2389 | + |
| 2390 | + return Hist<ColumnType, ColumnTypes...>(h, columnList); |
| 2391 | + } |
| 2392 | + |
| 2393 | + //////////////////////////////////////////////////////////////////////////// |
| 2394 | + /// \brief Fill the provided RHist (*lazy action*). |
| 2395 | + /// \param[in] h The histogram that should be filled. |
| 2396 | + /// \param[in] columnList A list containing the names of the columns that will be passed when calling `Fill` |
| 2397 | + /// \return the histogram wrapped in a RResultPtr. |
| 2398 | + /// |
| 2399 | + /// This action is *lazy*: upon invocation of this method the calculation is |
| 2400 | + /// booked but not executed. Also see RResultPtr. |
| 2401 | + /// |
| 2402 | + /// During execution of the computation graph, the passed histogram must only be accessed with methods that are |
| 2403 | + /// allowed during concurrent filling. |
| 2404 | + /// |
| 2405 | + /// ### Example usage: |
| 2406 | + /// ~~~{.cpp} |
| 2407 | + /// auto h = std::make_shared<ROOT::Experimental::RHist<double>>(10, {5.0, 15.0}); |
| 2408 | + /// auto myHist = myDf.Hist(h, {"col0"}); |
| 2409 | + /// ~~~ |
| 2410 | + template <typename ColumnType = RDFDetail::RInferredType, typename... ColumnTypes, typename BinContentType> |
| 2411 | + RResultPtr<ROOT::Experimental::RHist<BinContentType>> |
| 2412 | + Hist(std::shared_ptr<ROOT::Experimental::RHist<BinContentType>> h, const ColumnNames_t &columnList) |
| 2413 | + { |
| 2414 | + RDFInternal::WarnHist(); |
| 2415 | + |
| 2416 | + if (h->GetNDimensions() != columnList.size()) { |
| 2417 | + throw std::runtime_error("Wrong number of columns for the passed histogram."); |
| 2418 | + } |
| 2419 | + |
| 2420 | + return CreateAction<RDFInternal::ActionTags::Hist, ColumnType, ColumnTypes...>(columnList, h, h, fProxiedPtr, |
| 2421 | + columnList.size()); |
| 2422 | + } |
| 2423 | +#endif |
| 2424 | + |
2360 | 2425 | //////////////////////////////////////////////////////////////////////////// |
2361 | 2426 | /// \brief Fill and return a TGraph object (*lazy action*). |
2362 | 2427 | /// \tparam X The type of the column used to fill the x axis. |
|
0 commit comments