RooNormSetCache.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooNormSetCache.h,v 1.12 2007/08/09 19:55:47 wouter Exp $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 #ifndef ROO_NORMSET_CACHE
00017 #define ROO_NORMSET_CACHE
00018 
00019 #include "Riosfwd.h"
00020 #include <assert.h>
00021 #include "Rtypes.h"
00022 #include "RooNameSet.h"
00023 #include "RooSetPair.h"
00024 #include "RooHashTable.h"
00025 
00026 class RooArgSet ;
00027 class RooSetPair ;
00028 
00029 typedef RooArgSet* pRooArgSet ;
00030 
00031 class RooNormSetCache {
00032 
00033 public:
00034   RooNormSetCache(Int_t regSize=10) ;
00035   RooNormSetCache(const RooNormSetCache& other) ;
00036   virtual ~RooNormSetCache() ;
00037 
00038   void add(const RooArgSet* set1, const RooArgSet* set2=0) ;
00039 
00040   inline Int_t index(const RooArgSet* set1, const RooArgSet* set2=0, const TNamed* set2RangeName=0) {
00041 
00042     // Match range name first
00043     if (set2RangeName != _set2RangeName) return -1 ;
00044 
00045     // Match pointer of sets
00046     Int_t i ;
00047     for (i=0 ; i<_nreg ; i++) {
00048       if (_asArr[i]._set1 == set1 && 
00049           _asArr[i]._set2 == set2 
00050           ) return i ;
00051     }    
00052     
00053     return -1 ;
00054   }
00055 
00056   inline Bool_t contains(const RooArgSet* set1, const RooArgSet* set2=0, const TNamed* set2RangeName=0) {
00057     if (set2RangeName!=_set2RangeName) return kFALSE ;
00058     if (_htable) return (_htable->findSetPair(set1,set2)) ;
00059     return (index(set1,set2,set2RangeName)>=0) ;
00060   }
00061 
00062   inline Bool_t containsSet1(const RooArgSet* set1) {
00063     Int_t i ;
00064     for (i=0 ; i<_nreg ; i++) {
00065       if (_asArr[i]._set1 == set1) return kTRUE ;
00066     }
00067     return kFALSE ;
00068   }
00069 
00070   const RooArgSet* lastSet1() const { return _nreg>0?_asArr[_nreg-1]._set1:0 ; }
00071   const RooArgSet* lastSet2() const { return _nreg>0?_asArr[_nreg-1]._set2:0 ; }
00072   const RooNameSet& nameSet1() const { return _name1 ; }
00073   const RooNameSet& nameSet2() const { return _name2 ; }
00074 
00075   Bool_t autoCache(const RooAbsArg* self, const RooArgSet* set1, const RooArgSet* set2=0, const TNamed* set2RangeName=0, Bool_t autoRefill=kTRUE) ;
00076     
00077   void clear() ;
00078   Int_t entries() const { return _nreg ; }
00079 
00080   void initialize(const RooNormSetCache& other) ;
00081 
00082 protected:
00083 
00084   void expand() ;
00085 
00086   RooHashTable* _htable ; //! do not persist
00087   Int_t _regSize ;
00088   Int_t _nreg ;
00089   RooSetPair* _asArr ;  //! do not persist
00090 
00091   RooNameSet _name1 ;   //!
00092   RooNameSet _name2 ;   //!
00093   TNamed*    _set2RangeName ; //!
00094 
00095   ClassDef(RooNormSetCache,1) // Management tool for tracking sets of similar integration/normalization sets
00096 } ;
00097 
00098 #endif 

Generated on Tue Jul 5 14:26:15 2011 for ROOT_528-00b_version by  doxygen 1.5.1