Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 }
41 set->snapshot(*out, false);
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/// Store given arrays of integer codes, and up to four RooArgSets in
98/// the registry (each setX pointer may be null). The registry
99/// clones all RooArgSets internally so the RooArgSets passed as
100/// arguments do not need to live beyond the store() call. The return
101/// value is a unique master code for the given configuration of
102/// integers and RooArgSets. If an identical combination is
103/// previously stored in the registry no objects are stored and the
104/// unique code of the existing entry is returned.
105
108{
109 // Loop over code-list array
110 for (UInt_t i = 0; i < _clArr.size(); ++i) {
111 // Existing slot, compare with current list, if matched return index
112 bool match(true) ;
113
114 // Check that array contents is identical
115 match &= _clArr[i] == codeList;
116
117 // Check that supplied configuration of lists is identical
118 if (_asArr1[i] && !set1) match=false ;
119 if (!_asArr1[i] && set1) match=false ;
120 if (_asArr2[i] && !set2) match=false ;
121 if (!_asArr2[i] && set2) match=false ;
122 if (_asArr3[i] && !set3) match=false ;
123 if (!_asArr3[i] && set3) match=false ;
124 if (_asArr4[i] && !set4) match=false ;
125 if (!_asArr4[i] && set4) match=false ;
126
127 // Check that contents of arrays is identical
128 if (_asArr1[i] && set1 && !set1->equals(*_asArr1[i])) match=false ;
129 if (_asArr2[i] && set2 && !set2->equals(*_asArr2[i])) match=false ;
130 if (_asArr3[i] && set3 && !set3->equals(*_asArr3[i])) match=false ;
131 if (_asArr4[i] && set4 && !set4->equals(*_asArr4[i])) match=false ;
132
133 if (match) {
134 if (set1) delete set1 ;
135 if (set2) delete set2 ;
136 if (set3) delete set3 ;
137 if (set4) delete set4 ;
138 return i ;
139 }
140 }
141
142 // Store code list and return index
143 _clArr.push_back(codeList);
144 _asArr1.emplace_back(makeSnapshot(set1));
145 _asArr2.emplace_back(makeSnapshot(set2));
146 _asArr3.emplace_back(makeSnapshot(set3));
147 _asArr4.emplace_back(makeSnapshot(set4));
148
149 if (set1) delete set1 ;
150 if (set2) delete set2 ;
151 if (set3) delete set3 ;
152 if (set4) delete set4 ;
153 return _clArr.size() - 1;
154}
155
156////////////////////////////////////////////////////////////////////////////////
157/// Retrieve the array of integer codes associated with the given master code
158
159const std::vector<Int_t>& RooAICRegistry::retrieve(Int_t masterCode) const
160{
161 return _clArr[masterCode] ;
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Retrieve the array of integer codes associated with the given master code
166/// and set the passed set1 pointer to the first RooArgSet associated with this master code
167
168const std::vector<Int_t>& RooAICRegistry::retrieve(Int_t masterCode, pRooArgSet& set1) const
169{
171 return _clArr[masterCode] ;
172}
173
174////////////////////////////////////////////////////////////////////////////////
175/// Retrieve the array of integer codes associated with the given master code
176/// and set the passed set1,set2 pointers to the first and second RooArgSets associated with this
177/// master code respectively
178
179const std::vector<Int_t>& RooAICRegistry::retrieve
181{
184 return _clArr[masterCode] ;
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Retrieve the array of integer codes associated with the given master code
189/// and set the passed set1-4 pointers to the four RooArgSets associated with this
190/// master code respectively
191
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.
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