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 "RooMsgService.h"
29#include "RooArgSet.h"
30
31#include "Riostream.h"
32
33
34namespace {
35
36RooArgSet * makeSnapshot(RooArgSet const* set) {
37 if(!set) {
38 return nullptr;
39 }
40 auto RooArgSet;
41 set->snapshot(*out, false);
42 return out;
43}
44
45}
46
47////////////////////////////////////////////////////////////////////////////////
48
50 : _clArr(0), _asArr1(0), _asArr2(0), _asArr3(0), _asArr4(0)
51{
52 _clArr.reserve(size);
53 _asArr1.reserve(size);
54 _asArr2.reserve(size);
55 _asArr3.reserve(size);
56 _asArr4.reserve(size);
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// Copy constructor
61
63 : _clArr(other._clArr), _asArr1(other._clArr.size(), nullptr), _asArr2(other._clArr.size(), nullptr),
64 _asArr3(other._clArr.size(), nullptr), _asArr4(other._clArr.size(), nullptr)
65{
66 // Copy code-list array if other PDF has one
67 UInt_t size = other._clArr.size();
68 if (size) {
69 _asArr1.resize(size, nullptr);
70 _asArr2.resize(size, nullptr);
71 _asArr3.resize(size, nullptr);
72 _asArr4.resize(size, nullptr);
73 for(UInt_t i = 0; i < size; ++i) {
74 _asArr1[i] = makeSnapshot(other._asArr1[i]);
75 _asArr2[i] = makeSnapshot(other._asArr2[i]);
76 _asArr3[i] = makeSnapshot(other._asArr3[i]);
77 _asArr4[i] = makeSnapshot(other._asArr4[i]);
78 }
79 }
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// Destructor
84
86{
87 // Delete code list array, if allocated
88 for (unsigned int i = 0; i < _clArr.size(); ++i) {
89 if (_asArr1[i]) delete _asArr1[i];
90 if (_asArr2[i]) delete _asArr2[i];
91 if (_asArr3[i]) delete _asArr3[i];
92 if (_asArr4[i]) delete _asArr4[i];
93 }
94}
95
96////////////////////////////////////////////////////////////////////////////////
97/// Get size of _clArr vector
98
100{
101 return _clArr.size();
102}
103
104////////////////////////////////////////////////////////////////////////////////
105/// Store given arrays of integer codes, and up to four RooArgSets in
106/// the registry (each setX pointer may be null). The registry
107/// clones all RooArgSets internally so the RooArgSets passed as
108/// arguments do not need to live beyond the store() call. The return
109/// value is a unique master code for the given configuration of
110/// integers and RooArgSets. If an identical combination is
111/// previously stored in the registry no objects are stored and the
112/// unique code of the existing entry is returned.
113
116{
117 // Loop over code-list array
118 for (UInt_t i = 0; i < _clArr.size(); ++i) {
119 // Existing slot, compare with current list, if matched return index
120 bool match(true) ;
121
122 // Check that array contents is identical
123 match &= _clArr[i] == codeList;
124
125 // Check that supplied configuration of lists is identical
126 if (_asArr1[i] && !set1) match=false ;
127 if (!_asArr1[i] && set1) match=false ;
128 if (_asArr2[i] && !set2) match=false ;
129 if (!_asArr2[i] && set2) match=false ;
130 if (_asArr3[i] && !set3) match=false ;
131 if (!_asArr3[i] && set3) match=false ;
132 if (_asArr4[i] && !set4) match=false ;
133 if (!_asArr4[i] && set4) match=false ;
134
135 // Check that contents of arrays is identical
136 if (_asArr1[i] && set1 && !set1->equals(*_asArr1[i])) match=false ;
137 if (_asArr2[i] && set2 && !set2->equals(*_asArr2[i])) match=false ;
138 if (_asArr3[i] && set3 && !set3->equals(*_asArr3[i])) match=false ;
139 if (_asArr4[i] && set4 && !set4->equals(*_asArr4[i])) match=false ;
140
141 if (match) {
142 if (set1) delete set1 ;
143 if (set2) delete set2 ;
144 if (set3) delete set3 ;
145 if (set4) delete set4 ;
146 return i ;
147 }
148 }
149
150 // Store code list and return index
151 _clArr.push_back(codeList);
152 _asArr1.emplace_back(makeSnapshot(set1));
153 _asArr2.emplace_back(makeSnapshot(set2));
154 _asArr3.emplace_back(makeSnapshot(set3));
155 _asArr4.emplace_back(makeSnapshot(set4));
156
157 if (set1) delete set1 ;
158 if (set2) delete set2 ;
159 if (set3) delete set3 ;
160 if (set4) delete set4 ;
161 return _clArr.size() - 1;
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Retrieve the array of integer codes associated with the given master code
166
167const std::vector<Int_t>& RooAICRegistry::retrieve(Int_t masterCode) const
168{
169 return _clArr[masterCode] ;
170}
171
172////////////////////////////////////////////////////////////////////////////////
173/// Retrieve the array of integer codes associated with the given master code
174/// and set the passed set1 pointer to the first RooArgSet associated with this master code
175
176const std::vector<Int_t>& RooAICRegistry::retrieve(Int_t masterCode, pRooArgSet& set1) const
177{
179 return _clArr[masterCode] ;
180}
181
182////////////////////////////////////////////////////////////////////////////////
183/// Retrieve the array of integer codes associated with the given master code
184/// and set the passed set1,set2 pointers to the first and second RooArgSets associated with this
185/// master code respectively
186
187const std::vector<Int_t>& RooAICRegistry::retrieve
189{
192 return _clArr[masterCode] ;
193}
194
195////////////////////////////////////////////////////////////////////////////////
196/// Retrieve the array of integer codes associated with the given master code
197/// and set the passed set1-4 pointers to the four RooArgSets associated with this
198/// master code respectively
199
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.
Utility class for operator p.d.f classes that keeps track of analytical integration codes and associa...
virtual ~RooAICRegistry()
Destructor.
const std::vector< Int_t > & retrieve(Int_t masterCode) const
Retrieve the array of integer codes associated with the given master code.
size_t size() const
Get size of _clArr vector.
RooAICRegistry(UInt_t size=10)
std::vector< pRooArgSet > _asArr2
! Array of 2nd RooArgSet pointers
Int_t store(const std::vector< Int_t > &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< pRooArgSet > _asArr1
! Array of 1st RooArgSet pointers
std::vector< pRooArgSet > _asArr4
! Array of 4th RooArgSet pointers
std::vector< std::vector< Int_t > > _clArr
! Array of array of code lists
std::vector< pRooArgSet > _asArr3
! Array of 3rd RooArgSet pointers
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition RooArgSet.h:159