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