Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooAICRegistry.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooAICRegistry.cxx
19\class RooAICRegistry
20\ingroup Roofitcore
21
22Utility class for operator p.d.f
23classes that keeps track of analytical integration codes and
24associated normalization and integration sets.
25**/
26
27#include <RooAICRegistry.h>
28#include <RooArgSet.h>
29
30namespace {
31
32template<class RooArgSetPointer_t>
33std::unique_ptr<RooArgSet> makeSnapshot(RooArgSetPointer_t const &set)
34{
35 if (!set)
36 return nullptr;
37 auto out = std::make_unique<RooArgSet>();
38 set->snapshot(*out, false);
39 return out;
40}
41
42} // namespace
43
45{
46 _clArr.reserve(size);
47 for (auto &a : _asArr) {
48 a.reserve(size);
49 }
50}
51
53{
54 // Copy code-list array if other PDF has one
55 for (std::size_t iArr = 0; iArr < _asArr.size(); ++iArr) {
56 _asArr[iArr].resize(_clArr.size());
57 for (std::size_t i = 0; i < _clArr.size(); ++i) {
58 _asArr[iArr][i] = makeSnapshot(other._asArr[iArr][i]);
59 }
60 }
61}
62
63////////////////////////////////////////////////////////////////////////////////
64/// Copy assignment.
65
67{
69 *this = std::move(tmp);
70 return *this;
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Store given arrays of integer codes, and up to four RooArgSets in
75/// the registry (each setX pointer may be null). The registry
76/// clones all RooArgSets internally so the RooArgSets passed as
77/// arguments do not need to live beyond the store() call. The return
78/// value is a unique master code for the given configuration of
79/// integers and RooArgSets. If an identical combination is
80/// previously stored in the registry no objects are stored and the
81/// unique code of the existing entry is returned.
82
85{
86 // Taking the ownership of the input sets
87 std::array<RooArgSet *, 4> sets{set1, set2, set3, set4};
88
89 // Loop over code-list array
90 for (std::size_t i = 0; i < _clArr.size(); ++i) {
91 // Existing slot, compare with current list, if matched return index.
92 // First., check that array contents is identical.
93 bool match = _clArr[i] == codeList;
94
95 // Check that supplied configuration of lists is identical
96 for (std::size_t iArr = 0; iArr < 4; ++iArr) {
97 if ((_asArr[iArr][i] && !sets[iArr]) || (!_asArr[iArr][i] && sets[iArr]))
98 match = false;
99 }
100
101 // Check that contents of arrays is identical
102 for (std::size_t iArr = 0; iArr < 4; ++iArr) {
103 if (_asArr[iArr][i] && sets[iArr] && !sets[iArr]->equals(*_asArr[iArr][i]))
104 match = false;
105 }
106
107 if (match) {
108 return i;
109 }
110 }
111
112 // Store code list and return index
113 _clArr.push_back(codeList);
114 for (std::size_t iArr = 0; iArr < 4; ++iArr) {
115 _asArr[iArr].emplace_back(makeSnapshot(sets[iArr]));
116 }
117
118 return _clArr.size() - 1;
119}
#define a(i)
Definition RSha256.hxx:99
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Registry for analytical integration codes.
int store(const std::vector< int > &codeList, RooArgSet *set1=nullptr, RooArgSet *set2=nullptr, RooArgSet *set3=nullptr, RooArgSet *set4=nullptr)
Store given arrays of integer codes, and up to four RooArgSets in the registry (each setX pointer may...
std::vector< std::vector< int > > _clArr
! Array of array of code lists
std::array< std::vector< std::unique_ptr< RooArgSet > >, 4 > _asArr
! Array of RooArgSet pointers
RooAICRegistry(std::size_t size=10)
RooAICRegistry & operator=(const RooAICRegistry &other)
Copy assignment.
std::size_t size() const
Number of stored code lists.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24