RooAbsDataStore.cxx

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  * @(#)root/roofitcore:$Id: RooAbsDataStore.cxx 28963 2009-06-12 15:47:45Z wouter $
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 
00017 //////////////////////////////////////////////////////////////////////////////
00018 //
00019 // BEGIN_HTML
00020 // RooAbsDataStore is the abstract base class for data collection that
00021 // use a TTree as internal storage mechanism
00022 // END_HTML
00023 //
00024 
00025 #include "RooFit.h"
00026 #include "RooMsgService.h"
00027 #include "RooAbsDataStore.h"
00028 
00029 #include "Riostream.h"
00030 #include <iomanip>
00031 #include "TClass.h"
00032 
00033 using namespace std ;
00034 
00035 ClassImp(RooAbsDataStore)
00036 ;
00037 
00038 
00039 //_____________________________________________________________________________
00040 RooAbsDataStore::RooAbsDataStore() 
00041 {
00042   // Default constructor
00043   _iterator = _vars.createIterator() ;
00044   _cacheIter = _cachedVars.createIterator() ;
00045   _doDirtyProp = kTRUE ;
00046 }
00047 
00048 
00049 
00050 
00051 //_____________________________________________________________________________
00052 RooAbsDataStore::RooAbsDataStore(const char* name, const char* title, const RooArgSet& vars) : 
00053   TNamed(name,title)
00054 {
00055   // Default constructor
00056 
00057   // clone the fundamentals of the given data set into internal buffer
00058   _vars.add(vars) ;
00059 
00060   _iterator = _vars.createIterator() ;
00061   _cacheIter = _cachedVars.createIterator() ;
00062   _doDirtyProp = kTRUE ;
00063 }
00064 
00065 
00066 
00067 
00068 //_____________________________________________________________________________
00069 RooAbsDataStore::RooAbsDataStore(const RooAbsDataStore& other, const char* newname) : TNamed(other), RooPrintable(other)
00070 {
00071   if (newname) {
00072     SetName(newname) ;
00073   }
00074   _vars.add(other._vars) ;
00075   _iterator = _vars.createIterator() ;
00076   _cacheIter = _cachedVars.createIterator() ;
00077   _doDirtyProp = other._doDirtyProp ;
00078 }
00079 
00080 
00081 
00082 //_____________________________________________________________________________
00083 RooAbsDataStore::RooAbsDataStore(const RooAbsDataStore& other, const RooArgSet& vars, const char* newname) : TNamed(other), RooPrintable(other)
00084 {
00085   if (newname) {
00086     SetName(newname) ;
00087   }
00088   _vars.add(vars) ;
00089   _iterator = _vars.createIterator() ;
00090   _cacheIter = _cachedVars.createIterator() ;
00091   _doDirtyProp = other._doDirtyProp ;
00092 }
00093 
00094 
00095 
00096 //_____________________________________________________________________________
00097 RooAbsDataStore::~RooAbsDataStore()
00098 {
00099   // Destructor
00100   delete _iterator ;
00101   delete _cacheIter ;
00102 }
00103 
00104 
00105 
00106 //_____________________________________________________________________________
00107 Bool_t RooAbsDataStore::valid() const 
00108 {
00109   // Return true if currently loaded coordinate is considered valid within
00110   // the current range definitions of all observables
00111   return kTRUE ;
00112 }
00113 
00114 
00115 //_____________________________________________________________________________
00116 void RooAbsDataStore::printName(ostream& os) const 
00117 {
00118   // Print name of dataset
00119 
00120   os << GetName() ;
00121 }
00122 
00123 
00124 
00125 //_____________________________________________________________________________
00126 void RooAbsDataStore::printTitle(ostream& os) const 
00127 {
00128   // Print title of dataset
00129   os << GetTitle() ;
00130 }
00131 
00132 
00133 
00134 //_____________________________________________________________________________
00135 void RooAbsDataStore::printClassName(ostream& os) const 
00136 {
00137   // Print class name of dataset
00138   os << IsA()->GetName() ;
00139 }
00140 
00141 
00142 
00143 //_____________________________________________________________________________
00144 void RooAbsDataStore::printValue(ostream& os) const 
00145 {
00146   // Print value of the dataset, i.e. the sum of weights contained in the dataset
00147   os << numEntries() << " entries" ;
00148 }
00149 
00150 
00151 
00152 //_____________________________________________________________________________
00153 void RooAbsDataStore::printArgs(ostream& os) const 
00154 {
00155   // Print argument of dataset, i.e. the observable names
00156 
00157   os << "[" ;    
00158   _iterator->Reset() ;
00159   RooAbsArg* arg ;
00160   Bool_t first(kTRUE) ;
00161   while((arg=(RooAbsArg*)_iterator->Next())) {
00162     if (first) {
00163       first=kFALSE ;
00164     } else {
00165       os << "," ;
00166     }
00167     os << arg->GetName() ;
00168   }
00169   os << "]" ;
00170 }
00171 
00172 
00173 
00174 
00175 
00176 
00177 //_____________________________________________________________________________
00178 Int_t RooAbsDataStore::defaultPrintContents(Option_t* /*opt*/) const 
00179 {
00180   // Define default print options, for a given print style
00181 
00182   return kName|kClassName|kArgs|kValue ;
00183 }
00184 
00185 
00186 
00187 
00188 
00189 //_____________________________________________________________________________
00190 void RooAbsDataStore::printMultiline(ostream& os, Int_t /*content*/, Bool_t verbose, TString indent) const 
00191 {
00192   // Detailed printing interface
00193 
00194   os << indent << "DataStore " << GetName() << " (" << GetTitle() << ")" << endl ;
00195   os << indent << "  Contains " << numEntries() << " entries" << endl;
00196 
00197   if (!verbose) {
00198     os << indent << "  Observables " << _vars << endl ;
00199   } else {
00200     os << indent << "  Observables: " << endl ;
00201     _vars.printStream(os,kName|kValue|kExtras|kTitle,kVerbose,indent+"  ") ;
00202   }
00203 
00204   if(verbose) {
00205     if (_cachedVars.getSize()>0) {
00206       os << indent << "  Caches " << _cachedVars << endl ;
00207     }
00208 //     if(_truth.getSize() > 0) {
00209 //       os << indent << "  Generated with ";
00210 //       TString deeper(indent) ;
00211 //       deeper += "   " ;
00212 //       _truth.printStream(os,kName|kValue,kStandard,deeper) ;
00213 //     }
00214   }
00215 }
00216 
00217 
00218 

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