This file is indexed.

/usr/include/root/RooVectorDataStore.h is in libroot-roofit-dev 5.34.00-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooVectorDataStore.h 44077 2012-05-02 17:10:21Z moneta $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/
#ifndef ROO_VECTOR_DATA_STORE
#define ROO_VECTOR_DATA_STORE

#include <list>
#include <vector>
#include <string>
#include "RooAbsDataStore.h" 
#include "TString.h"
#include "RooCatType.h"
#include "RooAbsCategory.h"
#include "RooAbsReal.h"
#include "RooChangeTracker.h"

class RooAbsArg ;
class RooArgList ;
class TTree ;
class RooFormulaVar ;
class RooArgSet ;

class RooVectorDataStore : public RooAbsDataStore {
public:

  RooVectorDataStore() ; 

  // Empty ctor
  RooVectorDataStore(const char* name, const char* title, const RooArgSet& vars, const char* wgtVarName=0) ;
  virtual RooAbsDataStore* clone(const char* newname=0) const { return new RooVectorDataStore(*this,newname) ; }
  virtual RooAbsDataStore* clone(const RooArgSet& vars, const char* newname=0) const { return new RooVectorDataStore(*this,vars,newname) ; }

  RooVectorDataStore(const RooVectorDataStore& other, const char* newname=0) ;
  RooVectorDataStore(const RooTreeDataStore& other, const RooArgSet& vars, const char* newname=0) ;
  RooVectorDataStore(const RooVectorDataStore& other, const RooArgSet& vars, const char* newname=0) ;


  RooVectorDataStore(const char *name, const char *title, RooAbsDataStore& tds, 
		     const RooArgSet& vars, const RooFormulaVar* cutVar, const char* cutRange,
		     Int_t nStart, Int_t nStop, Bool_t /*copyCache*/, const char* wgtVarName=0) ;

  virtual ~RooVectorDataStore() ;

  RooArgSet varsNoWeight(const RooArgSet& allVars, const char* wgtName) ;
  RooRealVar* weightVar(const RooArgSet& allVars, const char* wgtName) ;

  // Write current row
  virtual Int_t fill() ;

  // Retrieve a row
  using RooAbsDataStore::get ;
  virtual const RooArgSet* get(Int_t index) const ;
  virtual const RooArgSet* getNative(Int_t index) const ;
  virtual Double_t weight() const ;
  virtual Double_t weightError(RooAbsData::ErrorType etype=RooAbsData::Poisson) const ;
  virtual void weightError(Double_t& lo, Double_t& hi, RooAbsData::ErrorType etype=RooAbsData::Poisson) const ; 
  virtual Double_t weight(Int_t index) const ;
  virtual Bool_t isWeighted() const { return (_wgtVar!=0||_extWgtArray!=0) ; }

  // Change observable name
  virtual Bool_t changeObservableName(const char* from, const char* to) ;
  
  // Add one or more columns
  virtual RooAbsArg* addColumn(RooAbsArg& var, Bool_t adjustRange=kTRUE) ;
  virtual RooArgSet* addColumns(const RooArgList& varList) ;

  // Merge column-wise
  RooAbsDataStore* merge(const RooArgSet& allvars, std::list<RooAbsDataStore*> dstoreList) ;

  // Add rows 
  virtual void append(RooAbsDataStore& other) ;

  // General & bookkeeping methods
  virtual Bool_t valid() const ;
  virtual Int_t numEntries() const ;
  virtual Double_t sumEntries() const { return _sumWeight ; }
  virtual void reset() ;

  // Buffer redirection routines used in inside RooAbsOptTestStatistics
  virtual void attachBuffers(const RooArgSet& extObs) ; 
  virtual void resetBuffers() ;
  
  
  // Constant term  optimizer interface
  virtual const RooAbsArg* cacheOwner() { return _cacheOwner ; }
  virtual void cacheArgs(const RooAbsArg* owner, RooArgSet& varSet, const RooArgSet* nset=0) ;
  virtual void attachCache(const RooAbsArg* newOwner, const RooArgSet& cachedVars) ;
  virtual void resetCache() ;
  virtual void recalculateCache(const RooArgSet* /*proj*/, Int_t firstEvent, Int_t lastEvent, Int_t stepSize) ;

  virtual void setArgStatus(const RooArgSet& set, Bool_t active) ;

  const RooVectorDataStore* cache() const { return _cache ; }

  void loadValues(const RooAbsDataStore *tds, const RooFormulaVar* select=0, const char* rangeName=0, Int_t nStart=0, Int_t nStop=2000000000) ;
  
  void dump() ;

  void setExternalWeightArray(Double_t* arrayWgt, Double_t* arrayWgtErrLo, Double_t* arrayWgtErrHi, Double_t* arraySumW2) { 
    _extWgtArray = arrayWgt ; 
    _extWgtErrLoArray = arrayWgtErrLo ;
    _extWgtErrHiArray = arrayWgtErrHi ;
    _extSumW2Array = arraySumW2 ;
  }

  virtual void setDirtyProp(Bool_t flag) { 
    _doDirtyProp = flag ; 
    if (_cache) {
      _cache->setDirtyProp(flag) ;
    }
  }

  //virtual void checkInit() const;

  const RooArgSet& row() { return _varsww ; }

  class RealVector {
  public:
    RealVector(UInt_t initialCapacity=100) : 
      _nativeReal(0), _real(0), _buf(0), _nativeBuf(0), _vec0(0), _tracker(0) { 
      _vec.reserve(initialCapacity) ; 
    }

    RealVector(RooAbsReal* arg, UInt_t initialCapacity=100) : 
      _nativeReal(arg), _real(0), _buf(0), _nativeBuf(0), _vec0(0), _tracker(0) { 
      _vec.reserve(initialCapacity) ; 
    }

    virtual ~RealVector() {
      if (_tracker) delete _tracker ;
    }

    RealVector(const RealVector& other, RooAbsReal* real=0) : 
      _vec(other._vec), _nativeReal(real?real:other._nativeReal), _real(real?real:other._real), _buf(other._buf), _nativeBuf(other._nativeBuf)   {
      _vec0 = _vec.size()>0 ? &_vec.front() : 0 ;
      if (other._tracker) {
	_tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",other._tracker->parameters()) ;
      } else {
	_tracker = 0 ;
      }
    }

    RealVector& operator=(const RealVector& other) {
      if (&other==this) return *this ;
      _nativeReal = other._nativeReal ;
      _real = other._real ;
      _buf = other._buf ;
      _nativeBuf = other._nativeBuf ;
      _vec = other._vec ;
      _vec0 = _vec.size()>0 ? &_vec.front() : 0 ;
      return *this ;
    }

    void setBufArg(RooAbsReal* arg) { _nativeReal = arg ; }
    const RooAbsReal* bufArg() const { return _nativeReal ; }

    void setBuffer(RooAbsReal* real, Double_t* newBuf) { 
      _real = real ;
      _buf = newBuf ; 
      if (_nativeBuf==0) {
	_nativeBuf=newBuf ;
      }
    }

    void setNativeBuffer(Double_t* newBuf=0) {       
      _nativeBuf = newBuf ? newBuf : _buf ; 
    }

    void setDependents(const RooArgSet& deps) {
      if (_tracker) {
	delete _tracker ;
      }
      _tracker = new RooChangeTracker(Form("track_%s",_nativeReal->GetName()),"tracker",deps) ;
    }
    
    Bool_t needRecalc() {
      if (!_tracker) return kFALSE ;
      return _tracker->hasChanged(kTRUE) ;
    }

    void fill() { 
      _vec.push_back(*_buf) ; 
      _vec0 = &_vec.front() ;
    } ;

    void write(Int_t i) {
/*       cout << "write(" << this << ") [" << i << "] nativeReal = " << _nativeReal << " = " << _nativeReal->GetName() << " real = " << _real << " buf = " << _buf << " value = " << *_buf << " native getVal() = " << _nativeReal->getVal() << " getVal() = " << _real->getVal() << endl ; */
      _vec[i] = *_buf ;
    }
    
    void reset() { 
      _vec.clear() ; 
      _vec0 = &_vec.front() ;
    }

    inline void get(Int_t idx) const { 
      *_buf = *(_vec0+idx) ; 
    }

    inline void getNative(Int_t idx) const { 
      *_nativeBuf = *(_vec0+idx) ; 
    }

    Int_t size() const { return _vec.size() ; }

    void resize(Int_t siz) {
      _vec.resize(siz) ;
      _vec0 = &_vec.front() ;
    }

  protected:
    std::vector<Double_t> _vec ;

  private:
    friend class RooVectorDataStore ;
    RooAbsReal* _nativeReal ;
    RooAbsReal* _real ;
    Double_t* _buf ; //!
    Double_t* _nativeBuf ; //!
    Double_t* _vec0 ; //!
    RooChangeTracker* _tracker ; //
    ClassDef(RealVector,1) // STL-vector-based Data Storage class
  } ;
  

  class RealFullVector : public RealVector {
  public:
    RealFullVector(UInt_t initialCapacity=100) : RealVector(initialCapacity),
      _bufE(0), _bufEL(0), _bufEH(0), 
      _nativeBufE(0), _nativeBufEL(0), _nativeBufEH(0), 
      _vecE(0), _vecEL(0), _vecEH(0) { 
    }

    RealFullVector(RooAbsReal* arg, UInt_t initialCapacity=100) : 
      RealVector(arg,initialCapacity), 
      _bufE(0), _bufEL(0), _bufEH(0), 
      _nativeBufE(0), _nativeBufEL(0), _nativeBufEH(0), 
      _vecE(0), _vecEL(0), _vecEH(0) { 
    }

    virtual ~RealFullVector() {
      if (_vecE) delete _vecE ;
      if (_vecEL) delete _vecEL ;
      if (_vecEH) delete _vecEH ;
    }
    
    RealFullVector(const RealFullVector& other, RooAbsReal* real=0) : RealVector(other,real),
      _bufE(other._bufE), _bufEL(other._bufEL), _bufEH(other._bufEH),
      _nativeBufE(other._nativeBufE), _nativeBufEL(other._nativeBufEL), _nativeBufEH(other._nativeBufEH) {
      _vecE = (other._vecE) ? new std::vector<Double_t>(*other._vecE) : 0 ;
      _vecEL = (other._vecEL) ? new std::vector<Double_t>(*other._vecEL) : 0 ;
      _vecEH = (other._vecEH) ? new std::vector<Double_t>(*other._vecEH) : 0 ;
    }

    RealFullVector(const RealVector& other, RooAbsReal* real=0) : RealVector(other,real), 
      _bufE(0), _bufEL(0), _bufEH(0),
      _nativeBufE(0), _nativeBufEL(0), _nativeBufEH(0) {
      _vecE = 0 ;
      _vecEL = 0 ; 
      _vecEH = 0 ; 
    }

    RealFullVector& operator=(const RealFullVector& other) {
      if (&other==this) return *this ;
      RealVector::operator=(other) ;
      _bufE = other._bufE ;
      _bufEL = other._bufEL ;
      _bufEH = other._bufEH ;
      _nativeBufE = other._nativeBufE ;
      _nativeBufEL = other._nativeBufEL ;
      _nativeBufEH = other._nativeBufEH ;
      _vecE = other._vecE ? new std::vector<Double_t>(*other._vecE) : 0 ;
      _vecEL = other._vecEL ? new std::vector<Double_t>(*other._vecEL) : 0 ;
      _vecEH = other._vecEH ? new std::vector<Double_t>(*other._vecEH) : 0 ;
      return *this ;
    }
    
    void setErrorBuffer(Double_t* newBuf) { 
/*       cout << "setErrorBuffer(" << _nativeReal->GetName() << ") newBuf = " << newBuf << endl ; */
      _bufE = newBuf ; 
      if (!_vecE) _vecE = new std::vector<Double_t> ;
      _vecE->reserve(_vec.capacity()) ;
      if (!_nativeBufE) _nativeBufE = _bufE ;
    }
    void setAsymErrorBuffer(Double_t* newBufL, Double_t* newBufH) { 
      _bufEL = newBufL ; _bufEH = newBufH ; 
      if (!_vecEL) {
        _vecEL = new std::vector<Double_t> ;
	_vecEH = new std::vector<Double_t> ;
	_vecEL->reserve(_vec.capacity()) ;
	_vecEH->reserve(_vec.capacity()) ;
      }
      if (!_nativeBufEL) {
	_nativeBufEL = _bufEL ;
	_nativeBufEH = _bufEH ;
      }
    }

    inline void getNative(Int_t idx) const { 
      RealVector::getNative(idx) ;
      if (_vecE) {
	*_nativeBufE = (*_vecE)[idx] ; 
      }
      if (_vecEL) {
	*_nativeBufEL = (*_vecEL)[idx] ; 
	*_nativeBufEH = (*_vecEH)[idx] ; 
      }
    }
        
    void fill() { 
      RealVector::fill() ;
      if (_vecE) _vecE->push_back(*_bufE) ;
      if (_vecEL) _vecEL->push_back(*_bufEL) ;
      if (_vecEH) _vecEH->push_back(*_bufEH) ;
    } ;

    void write(Int_t i) {
      RealVector::write(i) ;
      if (_vecE) (*_vecE)[i] = *_bufE ;
      if (_vecEL) (*_vecEL)[i] = *_bufEL ;
      if (_vecEH) (*_vecEH)[i] = *_bufEH ;
    }
    
    void reset() { 
      RealVector::reset() ;
      if (_vecE) _vecE->clear() ;
      if (_vecEL) _vecEL->clear() ;
      if (_vecEH) _vecEH->clear() ;
    }

    inline void get(Int_t idx) const { 
      RealVector::get(idx) ;
      if (_vecE) *_bufE = (*_vecE)[idx];
      if (_vecEL) *_bufEL = (*_vecEL)[idx] ;
      if (_vecEH) *_bufEH = (*_vecEH)[idx] ;
    }

    void resize(Int_t siz) {
      RealVector::resize(siz) ;
      if (_vecE) _vecE->resize(siz) ;
      if (_vecEL) _vecEL->resize(siz) ;
      if (_vecEH) _vecEH->resize(siz) ;
    }

  private:
    friend class RooVectorDataStore ;
    Double_t *_bufE ; //!
    Double_t *_bufEL ; //!
    Double_t *_bufEH ; //!
    Double_t *_nativeBufE ; //!
    Double_t *_nativeBufEL ; //! 
    Double_t *_nativeBufEH ; //!
    std::vector<Double_t> *_vecE, *_vecEL, *_vecEH ;
    ClassDef(RealFullVector,1) // STL-vector-based Data Storage class
  } ;
  

  class CatVector {
  public:
    CatVector(UInt_t initialCapacity=100) : 
      _cat(0), _buf(0), _nativeBuf(0), _vec0(0)
    {
      _vec.reserve(initialCapacity) ;
    }

    CatVector(RooAbsCategory* cat, UInt_t initialCapacity=100) : 
      _cat(cat), _buf(0), _nativeBuf(0), _vec0(0)
    {
      _vec.reserve(initialCapacity) ;
    }

    virtual ~CatVector() {
    }

    CatVector(const CatVector& other, RooAbsCategory* cat=0) : 
      _cat(cat?cat:other._cat), _buf(other._buf), _nativeBuf(other._nativeBuf), _vec(other._vec) 
      {
	_vec0 = _vec.size()>0 ? &_vec.front() : 0 ;
      }

    CatVector& operator=(const CatVector& other) {
      if (&other==this) return *this ;
      _cat = other._cat ;
      _buf = other._buf ;
      _nativeBuf = other._nativeBuf ;
      _vec = other._vec ;
      _vec0 = _vec.size()>0 ? &_vec.front() : 0 ;
      return *this ;
    }

    void setBuffer(RooCatType* newBuf) { 
      _buf = newBuf ; 
      if (_nativeBuf==0) _nativeBuf=newBuf ;
    }

    void setNativeBuffer(RooCatType* newBuf=0) {       
      _nativeBuf = newBuf ? newBuf : _buf ; 
    }
    
    void fill() { 
      _vec.push_back(*_buf) ; 
      _vec0 = &_vec.front() ;
    } ;
    void write(Int_t i) { 
      _vec[i]=*_buf ; 
    } ;
    void reset() { 
      _vec.clear() ; 
      _vec0 = &_vec.front() ;
    }
    inline void get(Int_t idx) const { 
      _buf->assignFast(*(_vec0+idx)) ;
    }
    inline void getNative(Int_t idx) const { 
      _nativeBuf->assignFast(*(_vec0+idx)) ;
    }
    Int_t size() const { return _vec.size() ; }

    void resize(Int_t siz) {
      _vec.resize(siz) ;
      _vec0 = &_vec.front() ;
    }

    void setBufArg(RooAbsCategory* arg) { _cat = arg ; }
    const RooAbsCategory* bufArg() const { return _cat ; }


  private:
    friend class RooVectorDataStore ;
    RooAbsCategory* _cat ;
    RooCatType* _buf ;  //!
    RooCatType* _nativeBuf ;  //!
    std::vector<RooCatType> _vec ;
    RooCatType* _vec0 ; //!
    ClassDef(CatVector,1) // STL-vector-based Data Storage class
  } ;
  

 protected:

  friend class RooAbsReal ;
  friend class RooAbsCategory ;
  friend class RooRealVar ;
  std::vector<RealVector*>& realStoreList() { return _realStoreList ; }
  std::vector<RealFullVector*>& realfStoreList() { return _realfStoreList ; }
  std::vector<CatVector*>& catStoreList() { return _catStoreList ; }

  CatVector* addCategory(RooAbsCategory* cat) {

    CatVector* cv(0) ;

    // First try a match by name
    std::vector<CatVector*>::iterator iter = _catStoreList.begin() ;
    for (; iter!=_catStoreList.end() ; ++iter) {
      if (std::string((*iter)->bufArg()->GetName())==cat->GetName()) {
	cv = (*iter)  ;
	return cv ;
      }
    }

    // If nothing found this will make an entry
    _catStoreList.push_back(new CatVector(cat)) ;
    _nCat++ ;

    // Update cached ptr to first element as push_back may have reallocated
    _firstCat = &_catStoreList.front() ;

    return _catStoreList.back() ;
  }

  RealVector* addReal(RooAbsReal* real) {

    RealVector* rv(0) ;
    
    // First try a match by name
    std::vector<RealVector*>::iterator iter = _realStoreList.begin() ;
    for (; iter!=_realStoreList.end() ; ++iter) {
      if (std::string((*iter)->bufArg()->GetName())==real->GetName()) {
	rv = (*iter) ;
	return rv ;
      }
    }    

    // Then check if an entry already exists for a full real    
    std::vector<RealFullVector*>::iterator iter2 = _realfStoreList.begin() ;
    for (; iter2!=_realfStoreList.end() ; ++iter2) {
      if (std::string((*iter2)->bufArg()->GetName())==real->GetName()) {
	// Return full vector as RealVector base class here
	return (*iter2) ;
      }
    }    


    // If nothing found this will make an entry
    _realStoreList.push_back(new RealVector(real)) ;
    _nReal++ ;

    // Update cached ptr to first element as push_back may have reallocated
    _firstReal = &_realStoreList.front() ;


    return _realStoreList.back() ;
  }

  Bool_t isFullReal(RooAbsReal* real) {
    
    // First try a match by name
    std::vector<RealFullVector*>::iterator iter = _realfStoreList.begin() ;
    for (; iter!=_realfStoreList.end() ; ++iter) {
      if (std::string((*iter)->bufArg()->GetName())==real->GetName()) {
	return kTRUE ;
      }
    }        
    return kFALSE ;
  }

  Bool_t hasError(RooAbsReal* real) {
    
    // First try a match by name
    std::vector<RealFullVector*>::iterator iter = _realfStoreList.begin() ;
    for (; iter!=_realfStoreList.end() ; ++iter) {
      if (std::string((*iter)->bufArg()->GetName())==real->GetName()) {
	return (*iter)->_vecE ? kTRUE : kFALSE ;
      }
    }        
    return kFALSE ;
  }

  Bool_t hasAsymError(RooAbsReal* real) {
    
    // First try a match by name
    std::vector<RealFullVector*>::iterator iter = _realfStoreList.begin() ;
    for (; iter!=_realfStoreList.end() ; ++iter) {
      if (std::string((*iter)->bufArg()->GetName())==real->GetName()) {
	return (*iter)->_vecEL ? kTRUE : kFALSE ;
      }
    }        
    return kFALSE ;
  }

  RealFullVector* addRealFull(RooAbsReal* real) {
    
    RealFullVector* rv(0) ;
    
    // First try a match by name
    std::vector<RealFullVector*>::iterator iter = _realfStoreList.begin() ;
    for (; iter!=_realfStoreList.end() ; ++iter) {
      if (std::string((*iter)->bufArg()->GetName())==real->GetName()) {
	rv = (*iter) ;
	return rv ;
      }
    }    

    // Then check if an entry already exists for a bare real    
    std::vector<RealVector*>::iterator iter2 = _realStoreList.begin() ;
    for (; iter2!=_realStoreList.end() ; ++iter2) {
      if (std::string((*iter2)->bufArg()->GetName())==real->GetName()) {

	// Convert element to full and add to full list
	_realfStoreList.push_back(new RealFullVector(*(*iter2),real)) ;
	_nRealF++ ;
	_firstRealF = &_realfStoreList.front() ;
	
	// Delete bare element
	RealVector* tmp = *iter2 ;
	_realStoreList.erase(iter2) ;
	delete tmp ;
	_firstReal = &_realStoreList.front() ;
	_nReal-- ;

	return _realfStoreList.back() ;
      }
    }    

    // If nothing found this will make an entry
    _realfStoreList.push_back(new RealFullVector(real)) ;
    _nRealF++ ;

    // Update cached ptr to first element as push_back may have reallocated
    _firstRealF = &_realfStoreList.front() ;


    return _realfStoreList.back() ;
  }

 private:
  RooArgSet _varsww ;
  RooRealVar* _wgtVar ;     // Pointer to weight variable (if set)

  std::vector<RealVector*> _realStoreList ;
  std::vector<RealFullVector*> _realfStoreList ;
  std::vector<CatVector*> _catStoreList ;

  void setAllBuffersNative() ;

  Int_t _nReal ;
  Int_t _nRealF ;
  Int_t _nCat ;
  Int_t _nEntries ;
  RealVector** _firstReal ; //! do not persist
  RealFullVector** _firstRealF ; //! do not persist
  CatVector** _firstCat ; //! do not persist
  Double_t _sumWeight ; 

  Double_t* _extWgtArray ;         //! External weight array
  Double_t* _extWgtErrLoArray ;    //! External weight array - low error
  Double_t* _extWgtErrHiArray ;    //! External weight array - high error
  Double_t* _extSumW2Array ;       //! External sum of weights array

  mutable Double_t  _curWgt ;      // Weight of current event
  mutable Double_t  _curWgtErrLo ; // Weight of current event
  mutable Double_t  _curWgtErrHi ; // Weight of current event
  mutable Double_t  _curWgtErr ;   // Weight of current event

  RooVectorDataStore* _cache ; //! Optimization cache
  RooAbsArg* _cacheOwner ; //! Cache owner

  ClassDef(RooVectorDataStore,1) // STL-vector-based Data Storage class
};


#endif