RooAbsCollection.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooAbsCollection.h,v 1.26 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_ABS_COLLECTION
00017 #define ROO_ABS_COLLECTION
00018 
00019 #include "TString.h"
00020 #include "RooAbsArg.h"
00021 #include "RooPrintable.h"
00022 #include "RooLinkedList.h"
00023 #include "RooCmdArg.h"
00024 #include <string>
00025 
00026 class RooAbsCollection : public TObject, public RooPrintable {
00027 public:
00028 
00029   // Constructors, assignment etc.
00030   RooAbsCollection();
00031   RooAbsCollection(const char *name);
00032   virtual TObject* clone(const char* newname) const = 0 ;
00033   virtual TObject* create(const char* newname) const = 0 ;
00034   virtual TObject* Clone(const char* newname=0) const { 
00035     return clone(newname?newname:GetName()) ; 
00036   }
00037   virtual ~RooAbsCollection();
00038 
00039   // Create a copy of an existing list. New variables cannot be added
00040   // to a copied list. The variables in the copied list are independent
00041   // of the original variables.
00042   RooAbsCollection(const RooAbsCollection& other, const char *name="");
00043   RooAbsCollection& operator=(const RooAbsCollection& other);
00044   RooAbsCollection& assignValueOnly(const RooAbsCollection& other) ;
00045   RooAbsCollection& assignFast(const RooAbsCollection& other) ;
00046 
00047   // Copy list and contents (and optionally 'deep' servers)
00048   RooAbsCollection *snapshot(Bool_t deepCopy=kTRUE) const ;
00049   Bool_t snapshot(RooAbsCollection& output, Bool_t deepCopy=kTRUE) const ;
00050 
00051   // Hash table control
00052   void setHashTableSize(Int_t i) { 
00053     // Set size of internal hash table to i (should be a prime number)
00054     _list.setHashTableSize(i) ; 
00055   }
00056   Int_t getHashTableSize() const { 
00057     // Return size of internal hash table
00058     return _list.getHashTableSize() ; 
00059   }
00060 
00061   // List content management
00062   virtual Bool_t add(const RooAbsArg& var, Bool_t silent=kFALSE) ;
00063   virtual Bool_t addOwned(RooAbsArg& var, Bool_t silent=kFALSE);
00064   virtual RooAbsArg *addClone(const RooAbsArg& var, Bool_t silent=kFALSE) ;
00065   virtual Bool_t replace(const RooAbsArg& var1, const RooAbsArg& var2) ;
00066   virtual Bool_t remove(const RooAbsArg& var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE) ;
00067   virtual void removeAll() ;
00068 
00069   virtual Bool_t add(const RooAbsCollection& list, Bool_t silent=kFALSE) ;
00070   virtual Bool_t addOwned(const RooAbsCollection& list, Bool_t silent=kFALSE);
00071   virtual void   addClone(const RooAbsCollection& list, Bool_t silent=kFALSE);
00072   Bool_t replace(const RooAbsCollection &other);
00073   Bool_t remove(const RooAbsCollection& list, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE) ;
00074 
00075   // Group operations on AbsArgs
00076   void setAttribAll(const Text_t* name, Bool_t value=kTRUE) ;
00077 
00078   // List search methods
00079   RooAbsArg *find(const char *name) const ;
00080   Bool_t contains(const RooAbsArg& var) const { 
00081     // Returns true if object with same name as var is contained in this collection
00082     return (0 == find(var.GetName())) ? kFALSE:kTRUE; 
00083   }
00084   Bool_t containsInstance(const RooAbsArg& var) const { 
00085     // Returns true if var is contained in this collection
00086     return (0 == _list.FindObject(&var)) ? kFALSE:kTRUE; 
00087   }
00088   RooAbsCollection* selectByAttrib(const char* name, Bool_t value) const ;
00089   RooAbsCollection* selectCommon(const RooAbsCollection& refColl) const ;
00090   RooAbsCollection* selectByName(const char* nameList, Bool_t verbose=kFALSE) const ;
00091   Bool_t equals(const RooAbsCollection& otherColl) const ; 
00092   Bool_t overlaps(const RooAbsCollection& otherColl) const ;
00093 
00094   // export subset of THashList interface
00095   inline TIterator* createIterator(Bool_t dir = kIterForward) const { 
00096     // Create and return an iterator over the elements in this collection
00097     return _list.MakeIterator(dir); 
00098   }
00099   inline Int_t getSize() const { 
00100     // Return the number of elements in the collection
00101     return _list.GetSize(); 
00102   }
00103   inline RooAbsArg *first() const { 
00104     // Return the first element in this collection
00105     return (RooAbsArg*)_list.First(); 
00106   }
00107 
00108   inline virtual void Print(Option_t *options= 0) const {
00109     // Printing interface (human readable)
00110     printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
00111   }
00112   std::string contentsString() const ;
00113 
00114 
00115   virtual void printName(ostream& os) const ;
00116   virtual void printTitle(ostream& os) const ;
00117   virtual void printClassName(ostream& os) const ;
00118   virtual void printValue(ostream& os) const ;
00119   virtual void printMultiline(ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
00120 
00121   virtual Int_t defaultPrintContents(Option_t* opt) const ;
00122 
00123   // Latex printing methods
00124   void printLatex(const RooCmdArg& arg1=RooCmdArg(), const RooCmdArg& arg2=RooCmdArg(), 
00125                   const RooCmdArg& arg3=RooCmdArg(), const RooCmdArg& arg4=RooCmdArg(), 
00126                   const RooCmdArg& arg5=RooCmdArg(), const RooCmdArg& arg6=RooCmdArg(), 
00127                   const RooCmdArg& arg7=RooCmdArg(), const RooCmdArg& arg8=RooCmdArg()) const ;
00128   void printLatex(ostream& ofs, Int_t ncol, const char* option="NEYU", Int_t sigDigit=1, 
00129                   const RooLinkedList& siblingLists=RooLinkedList(), const RooCmdArg* formatCmd=0) const ;
00130 
00131   void setName(const char *name) {
00132     // Set name of collection
00133     _name= name; 
00134   }
00135   const char* GetName() const { 
00136     // Return namer of collection
00137     return _name.Data() ; 
00138   }
00139   Bool_t isOwning() const { 
00140     // Does collection own contents?
00141     return _ownCont ; 
00142   }
00143 
00144   Bool_t allInRange(const char* rangeSpec) const ;
00145 
00146   void dump() const ;
00147 
00148   void releaseOwnership() { _ownCont = kFALSE ; }
00149 
00150   void sort(Bool_t ascend=kTRUE) { _list.Sort(ascend) ; }
00151 
00152 protected:
00153 
00154   friend class RooMultiCatIter ;
00155 
00156   RooLinkedList _list ; // Actual object store
00157 
00158   Bool_t _ownCont;  // Flag to identify a list that owns its contents.
00159   TString _name;    // Our name.
00160 
00161   void safeDeleteList() ;
00162 
00163   // Support for snapshot method 
00164   Bool_t addServerClonesToList(const RooAbsArg& var) ;
00165 
00166 private:
00167 
00168   ClassDef(RooAbsCollection,1) // Collection of RooAbsArg objects
00169 };
00170 
00171 #endif

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