Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RFilterBase.cxx
Go to the documentation of this file.
1 // Author: Enrico Guiraud, Danilo Piparo CERN 09/2018
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
12 #include "ROOT/RDF/RFilterBase.hxx"
13 #include <numeric> // std::accumulate
14 
15 using namespace ROOT::Detail::RDF;
16 
17 RFilterBase::RFilterBase(RLoopManager *implPtr, std::string_view name, const unsigned int nSlots,
18  const RDFInternal::RBookedCustomColumns &customColumns)
19  : RNodeBase(implPtr), fLastResult(nSlots), fAccepted(nSlots), fRejected(nSlots), fName(name), fNSlots(nSlots),
20  fCustomColumns(customColumns) {}
21 
22 // outlined to pin virtual table
23 RFilterBase::~RFilterBase() {}
24 
25 bool RFilterBase::HasName() const
26 {
27  return !fName.empty();
28 }
29 
30 std::string RFilterBase::GetName() const
31 {
32  return fName;
33 }
34 
35 void RFilterBase::FillReport(ROOT::RDF::RCutFlowReport &rep) const
36 {
37  if (fName.empty()) // FillReport is no-op for unnamed filters
38  return;
39  const auto accepted = std::accumulate(fAccepted.begin(), fAccepted.end(), 0ULL);
40  const auto all = accepted + std::accumulate(fRejected.begin(), fRejected.end(), 0ULL);
41  rep.AddCut({fName, accepted, all});
42 }
43 
44 void RFilterBase::InitNode()
45 {
46  fLastCheckedEntry = std::vector<Long64_t>(fNSlots, -1);
47  if (!fName.empty()) // if this is a named filter we care about its report count
48  ResetReportCount();
49 }