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 out = new 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
66
67////////////////////////////////////////////////////////////////////////////////
68/// Copy assignment
69
71{
72 // Delete code list array, if allocated
73 for (unsigned int i = 0; i < _clArr.size(); ++i) {
74 if (_asArr1[i]) {
75 delete _asArr1[i];
76 _asArr1[i] = nullptr;
77 }
78 if (_asArr2[i]) {
79 delete _asArr2[i];
80 _asArr2[i] = nullptr;
81 }
82 if (_asArr3[i]) {
83 delete _asArr3[i];
84 _asArr3[i] = nullptr;
85 }
86 if (_asArr4[i]) {
87 delete _asArr4[i];
88 _asArr4[i] = nullptr;
89 }
90 }
92 return *this;
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// Destructor
97
99{
100 // Delete code list array, if allocated
101 for (unsigned int i = 0; i < _clArr.size(); ++i) {
102 if (_asArr1[i]) delete _asArr1[i];
103 if (_asArr2[i]) delete _asArr2[i];
104 if (_asArr3[i]) delete _asArr3[i];
105 if (_asArr4[i]) delete _asArr4[i];
106 }
107}
108
109
111{
112 _clArr = other._clArr;
113
114 // Copy code-list array if other PDF has one
115 UInt_t size = other._clArr.size();
116 if (size) {
117 _asArr1.resize(size, nullptr);
118 _asArr2.resize(size, nullptr);
119 _asArr3.resize(size, nullptr);
120 _asArr4.resize(size, nullptr);
121 for (UInt_t i = 0; i < size; ++i) {
122 _asArr1[i] = makeSnapshot(other._asArr1[i]);
123 _asArr2[i] = makeSnapshot(other._asArr2[i]);
124 _asArr3[i] = makeSnapshot(other._asArr3[i]);
125 _asArr4[i] = makeSnapshot(other._asArr4[i]);
126 }
127 }
128}
129
130
131////////////////////////////////////////////////////////////////////////////////
132/// Get size of _clArr vector
133
135{
136 return _clArr.size();
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// Store given arrays of integer codes, and up to four RooArgSets in
141/// the registry (each setX pointer may be null). The registry
142/// clones all RooArgSets internally so the RooArgSets passed as
143/// arguments do not need to live beyond the store() call. The return
144/// value is a unique master code for the given configuration of
145/// integers and RooArgSets. If an identical combination is
146/// previously stored in the registry no objects are stored and the
147/// unique code of the existing entry is returned.
148
151{
152 // Loop over code-list array
153 for (UInt_t i = 0; i < _clArr.size(); ++i) {
154 // Existing slot, compare with current list, if matched return index
155 bool match(true) ;
156
157 // Check that array contents is identical
158 match &= _clArr[i] == codeList;
159
160 // Check that supplied configuration of lists is identical
161 if (_asArr1[i] && !set1) match=false ;
162 if (!_asArr1[i] && set1) match=false ;
163 if (_asArr2[i] && !set2) match=false ;
164 if (!_asArr2[i] && set2) match=false ;
165 if (_asArr3[i] && !set3) match=false ;
166 if (!_asArr3[i] && set3) match=false ;
167 if (_asArr4[i] && !set4) match=false ;
168 if (!_asArr4[i] && set4) match=false ;
169
170 // Check that contents of arrays is identical
171 if (_asArr1[i] && set1 && !set1->equals(*_asArr1[i])) match=false ;
172 if (_asArr2[i] && set2 && !set2->equals(*_asArr2[i])) match=false ;
173 if (_asArr3[i] && set3 && !set3->equals(*_asArr3[i])) match=false ;
174 if (_asArr4[i] && set4 && !set4->equals(*_asArr4[i])) match=false ;
175
176 if (match) {
177 if (set1) delete set1 ;
178 if (set2) delete set2 ;
179 if (set3) delete set3 ;
180 if (set4) delete set4 ;
181 return i ;
182 }
183 }
184
185 // Store code list and return index
186 _clArr.push_back(codeList);
187 _asArr1.emplace_back(makeSnapshot(set1));
188 _asArr2.emplace_back(makeSnapshot(set2));
189 _asArr3.emplace_back(makeSnapshot(set3));
190 _asArr4.emplace_back(makeSnapshot(set4));
191
192 if (set1) delete set1 ;
193 if (set2) delete set2 ;
194 if (set3) delete set3 ;
195 if (set4) delete set4 ;
196 return _clArr.size() - 1;
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Retrieve the array of integer codes associated with the given master code
201
202const std::vector<Int_t>& RooAICRegistry::retrieve(Int_t masterCode) const
203{
204 return _clArr[masterCode] ;
205}
206
207////////////////////////////////////////////////////////////////////////////////
208/// Retrieve the array of integer codes associated with the given master code
209/// and set the passed set1 pointer to the first RooArgSet associated with this master code
210
211const std::vector<Int_t>& RooAICRegistry::retrieve(Int_t masterCode, pRooArgSet& set1) const
212{
214 return _clArr[masterCode] ;
215}
216
217////////////////////////////////////////////////////////////////////////////////
218/// Retrieve the array of integer codes associated with the given master code
219/// and set the passed set1,set2 pointers to the first and second RooArgSets associated with this
220/// master code respectively
221
222const std::vector<Int_t>& RooAICRegistry::retrieve
224{
227 return _clArr[masterCode] ;
228}
229
230////////////////////////////////////////////////////////////////////////////////
231/// Retrieve the array of integer codes associated with the given master code
232/// and set the passed set1-4 pointers to the four RooArgSets associated with this
233/// master code respectively
234
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)
void copyImpl(const RooAICRegistry &other)
RooAICRegistry & operator=(const RooAICRegistry &other)
Copy assignment.
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