Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:53:09

0001 // Author: Enrico Guiraud CERN 11/2021
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOT_RDF_RVARIATIONREADER
0012 #define ROOT_RDF_RVARIATIONREADER
0013 
0014 #include "RColumnReaderBase.hxx"
0015 #include "RVariationBase.hxx"
0016 #include <Rtypes.h> // Long64_t, R__CLING_PTRCHECK
0017 
0018 #include <limits>
0019 #include <type_traits>
0020 
0021 namespace ROOT {
0022 namespace Internal {
0023 namespace RDF {
0024 
0025 /// Column reader that reads the value for a specific column, variation and slot.
0026 class R__CLING_PTRCHECK(off) RVariationReader final : public ROOT::Detail::RDF::RColumnReaderBase {
0027    RVariationBase *fVariation;
0028 
0029    /// Non-owning ptr to the value of the variation.
0030    void *fValuePtr = nullptr;
0031 
0032    /// The slot this value belongs to.
0033    unsigned int fSlot = std::numeric_limits<unsigned int>::max();
0034 
0035    void *GetImpl(Long64_t entry) final
0036    {
0037       fVariation->Update(fSlot, entry);
0038       return fValuePtr;
0039    }
0040 
0041 public:
0042    RVariationReader(unsigned int slot, const std::string &colName, const std::string &variationName,
0043                     RVariationBase &variation)
0044       : fVariation(&variation), fValuePtr(variation.GetValuePtr(slot, colName, variationName)), fSlot(slot)
0045    {
0046    }
0047 };
0048 
0049 class RVariationsWithReaders {
0050    // this is a shared_ptr only because we have to track its lifetime with a weak_ptr that we pass to jitted code
0051    // (see BookVariationJit). it is never null.
0052    std::shared_ptr<RVariationBase> fVariation;
0053    // Column readers for this RVariation for a given variation (map key) and a given slot (vector element).
0054    std::vector<std::unordered_map<std::string, std::unique_ptr<RVariationReader>>> fReadersPerVariation;
0055 
0056 public:
0057    RVariationsWithReaders(std::shared_ptr<RVariationBase> variation, unsigned int nSlots);
0058    RVariationBase &GetVariation() const { return *fVariation; }
0059    RVariationReader &GetReader(unsigned int slot, const std::string &colName, const std::string &variationName);
0060 };
0061 
0062 } // namespace RDF
0063 } // namespace Internal
0064 } // namespace ROOT
0065 
0066 #endif