Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Author: Enrico Guiraud, Danilo Piparo CERN  09/2018
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2018, 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_RFILTERBASE
0012 #define ROOT_RFILTERBASE
0013 
0014 #include "ROOT/RDF/RColumnRegister.hxx"
0015 #include "ROOT/RDF/RNodeBase.hxx"
0016 #include "ROOT/RDF/Utils.hxx" // ColumnNames_t
0017 #include "ROOT/RVec.hxx"
0018 #include "RtypesCore.h"
0019 
0020 #include <cassert>
0021 #include <string>
0022 #include <vector>
0023 
0024 class TTreeReader;
0025 
0026 namespace ROOT {
0027 
0028 namespace RDF {
0029 class RCutFlowReport;
0030 } // ns RDF
0031 
0032 namespace Detail {
0033 namespace RDF {
0034 namespace RDFInternal = ROOT::Internal::RDF;
0035 
0036 class RLoopManager;
0037 
0038 class RFilterBase : public RNodeBase {
0039 protected:
0040    std::vector<Long64_t> fLastCheckedEntry;
0041    std::vector<int> fLastResult = {true}; // std::vector<bool> cannot be used in a MT context safely
0042    std::vector<ULong64_t> fAccepted = {0};
0043    std::vector<ULong64_t> fRejected = {0};
0044    const std::string fName;
0045    const ROOT::RDF::ColumnNames_t fColumnNames;
0046    RDFInternal::RColumnRegister fColRegister;
0047    /// The nth flag signals whether the nth input column is a custom column or not.
0048    ROOT::RVecB fIsDefine;
0049    std::string fVariation; ///< This indicates for what variation this filter evaluates values.
0050    std::unordered_map<std::string, std::shared_ptr<RFilterBase>> fVariedFilters;
0051 
0052 public:
0053    RFilterBase(RLoopManager *df, std::string_view name, const unsigned int nSlots,
0054                const RDFInternal::RColumnRegister &colRegister, const ColumnNames_t &columns,
0055                const std::vector<std::string> &prevVariations, const std::string &variation = "nominal");
0056    RFilterBase &operator=(const RFilterBase &) = delete;
0057 
0058    ~RFilterBase() override;
0059 
0060    virtual void InitSlot(TTreeReader *r, unsigned int slot) = 0;
0061    bool HasName() const;
0062    std::string GetName() const;
0063    virtual void FillReport(ROOT::RDF::RCutFlowReport &) const;
0064    virtual void TriggerChildrenCount() = 0;
0065    virtual void ResetReportCount()
0066    {
0067       assert(!fName.empty()); // this method is to only be called on named filters
0068       // fAccepted and fRejected could be different than 0 if this is not the first event-loop run using this filter
0069       std::fill(fAccepted.begin(), fAccepted.end(), 0);
0070       std::fill(fRejected.begin(), fRejected.end(), 0);
0071    }
0072    /// Clean-up operations to be performed at the end of a task.
0073    virtual void FinalizeSlot(unsigned int slot) = 0;
0074    virtual void InitNode();
0075 };
0076 
0077 } // ns RDF
0078 } // ns Detail
0079 } // ns ROOT
0080 
0081 #endif // ROOT_RFILTERBASE