| RootFinder.h | | RootFinder.h | |
|
| // @(#)root/mathmore:$Id: RootFinder.h 33942 2010-06-16 13:12:17Z moneta $ | | // @(#)root/tmva $Id: RootFinder.h 39395 2011-05-26 10:05:54Z moneta $ | |
| // Authors: L. Moneta, A. Zsenei 08/2005 | | // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss | |
| | | | |
|
| /********************************************************************** | | /************************************************************************** | |
| * * | | ******** | |
| * Copyright (c) 2004 ROOT Foundation, CERN/PH-SFT * | | * Project: TMVA - a Root-integrated toolkit for multivariate data analysis | |
| * * | | * | |
| * This library is free software; you can redistribute it and/or * | | * Package: TMVA | |
| * modify it under the terms of the GNU General Public License * | | * | |
| * as published by the Free Software Foundation; either version 2 * | | * Class : RootFinder | |
| * of the License, or (at your option) any later version. * | | * | |
| * * | | * Web : http://tmva.sourceforge.net | |
| * This library is distributed in the hope that it will be useful, * | | * | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of * | | * | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * | | * | |
| * General Public License for more details. * | | * Description: | |
| * * | | * | |
| * You should have received a copy of the GNU General Public License * | | * Root finding using Brents algorithm | |
| * along with this library (see file COPYING); if not, write * | | * | |
| * to the Free Software Foundation, Inc., 59 Temple Place, Suite * | | * (translated from CERNLIB function RZERO) | |
| * 330, Boston, MA 02111-1307 USA, or contact the author. * | | * | |
| * * | | * | |
| **********************************************************************/ | | * | |
| | | * Authors (alphabetical): | |
| // Header file for class RootFinder | | * | |
| // | | * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland | |
| // Created by: moneta at Sun Nov 14 16:59:55 2004 | | * | |
| // | | * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, German | |
| // Last update: Sun Nov 14 16:59:55 2004 | | y * | |
| // | | * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada | |
| #ifndef ROOT_Math_RootFinder | | * | |
| #define ROOT_Math_RootFinder | | * | |
| | | * | |
| | | * Copyright (c) 2005: | |
| | | * | |
| | | * CERN, Switzerland | |
| | | * | |
| | | * U. of Victoria, Canada | |
| | | * | |
| | | * MPI-K Heidelberg, Germany | |
| | | * | |
| | | * | |
| | | * | |
| | | * Redistribution and use in source and binary forms, with or without | |
| | | * | |
| | | * modification, are permitted according to the terms listed in LICENSE | |
| | | * | |
| | | * (http://tmva.sourceforge.net/LICENSE) | |
| | | * | |
| | | ************************************************************************** | |
| | | ********/ | |
| | | | |
| | | #ifndef ROOT_TMVA_RootFinder | |
| | | #define ROOT_TMVA_RootFinder | |
| | | | |
| | | ////////////////////////////////////////////////////////////////////////// | |
| | | // // | |
| | | // RootFinder // | |
| | | // // | |
| | | // Root finding using Brents algorithm // | |
| | | // (translated from CERNLIB function RZERO) // | |
| | | // // | |
| | | ////////////////////////////////////////////////////////////////////////// | |
| | | | |
|
| #ifndef ROOT_Math_IFunctionfwd | | #ifndef ROOT_TObject | |
| #include "Math/IFunctionfwd.h" | | #include "TObject.h" | |
| #endif | | #endif | |
| | | | |
|
| #ifndef ROOT_Math_IRootFinderMethod | | namespace TMVA { | |
| #include "Math/IRootFinderMethod.h" | | | |
| #endif | | | |
| | | | |
|
| /** | | class MsgLogger; | |
| @defgroup RootFinders One-dimensional Root-Finding algorithms | | | |
| Various implementation esists in MathCore and MathMore | | | |
| The user interacts with a proxy class ROOT::Math::RootFinder which creat | | | |
| es behing | | | |
| the choosen algorithms which are implemented using the ROOT::Math::IRoot | | | |
| FinderMethod interface | | | |
| | | | |
| @ingroup NumAlgo | | | |
| */ | | | |
| | | | |
| namespace ROOT { | | | |
| namespace Math { | | | |
| | | | |
| //_________________________________________________________________________ | | | |
| ____________ | | | |
| /** | | | |
| User Class to find the Root of one dimensional functions. | | | |
| The GSL Methods are implemented in MathMore and they are loaded au | | | |
| tomatically | | | |
| via the plug-in manager | | | |
| | | | |
| The possible types of Root-finding algorithms are: | | | |
| <ul> | | | |
| <li>Root Bracketing Algorithms which do not require function deriv | | | |
| atives | | | |
| <ol> | | | |
| <li>RootFinder::kBRENT (default method implemented in MathCore) | | | |
| <li>RootFinder::kGSL_BISECTION | | | |
| <li>RootFinder::kGSL_FALSE_POS | | | |
| <li>RootFinder::kGSL_BRENT | | | |
| </ol> | | | |
| <li>Root Finding Algorithms using Derivatives | | | |
| <ol> | | | |
| <li>RootFinder::kGSL_NEWTON | | | |
| <li>RootFinder::kGSL_SECANT | | | |
| <li>RootFinder::kGSL_STEFFENSON | | | |
| </ol> | | | |
| </ul> | | | |
| | | | |
| This class does not cupport copying | | | |
| | | | |
| @ingroup RootFinders | | | |
| | | | |
| */ | | | |
| | | | |
| class RootFinder { | | | |
| | | | |
| public: | | | |
| | | | |
| enum EType { kBRENT, // Methods | | | |
| from MathCore | | | |
| kGSL_BISECTION, kGSL_FALSE_POS, kGSL_BRENT, // GSL Nor | | | |
| mal | | | |
| kGSL_NEWTON, kGSL_SECANT, kGSL_STEFFENSON // GSL Der | | | |
| ivatives | | | |
| }; | | | |
| | | | |
| /** | | | |
| Construct a Root-Finder algorithm | | | |
| */ | | | |
| RootFinder(RootFinder::EType type = RootFinder::kBRENT); | | | |
| virtual ~RootFinder(); | | | |
| | | | |
| private: | | | |
| // usually copying is non trivial, so we make this unaccessible | | | |
| RootFinder(const RootFinder & ) {} | | | |
| RootFinder & operator = (const RootFinder & rhs) | | | |
| { | | | |
| if (this == &rhs) return *this; // time saving self-test | | | |
| return *this; | | | |
| } | | | |
| | | | |
| public: | | | |
| | | | |
| bool SetMethod(RootFinder::EType type = RootFinder::kBRENT); | | | |
| | | | |
| /** | | | |
| Provide to the solver the function and the initial search inter | | | |
| val [xlow, xup] | | | |
| for algorithms not using derivatives (bracketing algorithms) | | | |
| The templated function f must be of a type implementing the \a | | | |
| operator() method, | | | |
| <em> double operator() ( double x ) </em> | | | |
| Returns non zero if interval is not valid (i.e. does not contai | | | |
| ns a root) | | | |
| */ | | | |
| | | | |
| bool SetFunction( const IGenFunction & f, double xlow, double xup) | | | |
| { | | | |
| return fSolver->SetFunction( f, xlow, xup); | | | |
| } | | | |
| | | | |
| /** | | | |
| Provide to the solver the function and an initial estimate of t | | | |
| he root, | | | |
| for algorithms using derivatives. | | | |
| The templated function f must be of a type implementing the \a | | | |
| operator() | | | |
| and the \a Gradient() methods. | | | |
| <em> double operator() ( double x ) </em> | | | |
| Returns non zero if starting point is not valid | | | |
| */ | | | |
| | | | |
| bool SetFunction( const IGradFunction & f, double xstart) { | | | |
| return fSolver->SetFunction( f, xstart); | | | |
| } | | | |
| | | | |
| template<class Function, class Derivative> | | | |
| bool Solve(Function &f, Derivative &d, double start, | | | |
| int maxIter = 100, double absTol = 1E-8, double relTol = | | | |
| 1E-10); | | | |
| | | | |
| template<class Function> | | | |
| bool Solve(Function &f, double min, double max, | | | |
| int maxIter = 100, double absTol = 1E-8, double relTol = | | | |
| 1E-10); | | | |
| | | | |
| /** | | | |
| Compute the roots iterating until the estimate of the Root is | | | |
| within the required tolerance returning | | | |
| the iteration Status | | | |
| */ | | | |
| bool Solve( int maxIter = 100, double absTol = 1E-8, double relTol | | | |
| = 1E-10) { | | | |
| return fSolver->Solve( maxIter, absTol, relTol ); | | | |
| } | | | |
| | | | |
| /** | | | |
| Return the number of iteration performed to find the Root. | | | |
| */ | | | |
| int Iterations() const { | | | |
| return fSolver->Iterations(); | | | |
| } | | | |
| | | | |
| /** | | | |
| Perform a single iteration and return the Status | | | |
| */ | | | |
| int Iterate() { | | | |
| return fSolver->Iterate(); | | | |
| } | | | |
| | | | |
| /** | | | |
| Return the current and latest estimate of the Root | | | |
| */ | | | |
| double Root() const { | | | |
| return fSolver->Root(); | | | |
| } | | | |
| | | | |
| /** | | | |
| Return the status of the last estimate of the Root | | | |
| = 0 OK, not zero failure | | | |
| */ | | | |
| int Status() const { | | | |
| return fSolver->Status(); | | | |
| } | | | |
| | | | |
| /** | | | |
| Return the current and latest estimate of the lower value of th | | | |
| e Root-finding interval (for bracketing algorithms) | | | |
| */ | | | |
| /* double XLower() const { */ | | | |
| /* return fSolver->XLower(); */ | | | |
| /* } */ | | | |
| | | | |
| /** | | | |
| Return the current and latest estimate of the upper value of th | | | |
| e Root-finding interval (for bracketing algorithms) | | | |
| */ | | | |
| /* double XUpper() const { */ | | | |
| /* return fSolver->XUpper(); */ | | | |
| /* } */ | | | |
| | | | |
| /** | | | |
| Get Name of the Root-finding solver algorithm | | | |
| */ | | | |
| const char * Name() const { | | | |
| return fSolver->Name(); | | | |
| } | | | |
| | | | |
| protected: | | | |
| | | | |
| private: | | | |
| | | | |
| IRootFinderMethod* fSolver; // type of algorithm to be used | | | |
| | | | |
|
| }; | | class RootFinder : public TObject { | |
| | | | |
|
| } // namespace Math | | public: | |
| } // namespace ROOT | | | |
| | | | |
|
| #ifndef ROOT_Math_WrappedFunction | | RootFinder( Double_t (*rootVal)( Double_t ), | |
| #include "Math/WrappedFunction.h" | | Double_t rootMin, Double_t rootMax, | |
| #endif | | Int_t maxIterations = 100, | |
| | | Double_t absTolerance = 0.0 ); | |
| | | virtual ~RootFinder( void ); | |
| | | | |
|
| #ifndef ROOT_Math_Functor | | // returns the root of the function | |
| #include "Math/Functor.h" | | Double_t Root( Double_t refValue ); | |
| #endif | | | |
| | | private: | |
| | | | |
| | | Double_t fRootMin; // minimum root value | |
| | | Double_t fRootMax; // maximum root value | |
| | | Int_t fMaxIter; // maximum number of iterations | |
| | | Double_t fAbsTol; // absolute tolerance deviation | |
| | | | |
|
| template<class Function, class Derivative> | | // function pointer | |
| bool ROOT::Math::RootFinder::Solve(Function &f, Derivative &d, double start | | Double_t (*fGetRootVal)( Double_t ); | |
| , | | | |
| int maxIter, double absTol, double relTol | | | |
| ) | | | |
| { | | | |
| if (!fSolver) return false; | | | |
| ROOT::Math::GradFunctor1D wf(f, d); | | | |
| bool ret = fSolver->SetFunction(wf, start); | | | |
| if (!ret) return false; | | | |
| return Solve(maxIter, absTol, relTol); | | | |
| } | | | |
| | | | |
| template<class Function> | | | |
| bool ROOT::Math::RootFinder::Solve(Function &f, double min, double max, | | | |
| int maxIter, double absTol, double relTol | | | |
| ) | | | |
| { | | | |
| if (!fSolver) return false; | | | |
| ROOT::Math::WrappedFunction<Function &> wf(f); | | | |
| bool ret = fSolver->SetFunction(wf, min, max); | | | |
| if (!ret) return false; | | | |
| return Solve(maxIter, absTol, relTol); | | | |
| } | | | |
| | | | |
|
| #endif /* ROOT_Math_RootFinder */ | | mutable MsgLogger* fLogger; //! message logger | |
| | | MsgLogger& Log() const { return *fLogger; } | |
| | | | |
| | | ClassDef(RootFinder,0) // Root finding using Brents algorithm | |
| | | }; | |
| | | | |
| | | } // namespace TMVA | |
| | | | |
| | | #endif | |
| | | | |
End of changes. 11 change blocks. |
| 254 lines changed or deleted | | 84 lines changed or added | |
|
| TFile.h | | TFile.h | |
|
| // @(#)root/io:$Id: TFile.h 39697 2011-06-13 21:43:43Z pcanal $ | | // @(#)root/io:$Id: TFile.h 41699 2011-11-01 21:38:19Z pcanal $ | |
| // Author: Rene Brun 28/11/94 | | // Author: Rene Brun 28/11/94 | |
| | | | |
| /************************************************************************* | | /************************************************************************* | |
| * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * | | * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * | |
| * All rights reserved. * | | * All rights reserved. * | |
| * * | | * * | |
| * For the licensing terms see $ROOTSYS/LICENSE. * | | * For the licensing terms see $ROOTSYS/LICENSE. * | |
| * For the list of contributors see $ROOTSYS/README/CREDITS. * | | * For the list of contributors see $ROOTSYS/README/CREDITS. * | |
| *************************************************************************/ | | *************************************************************************/ | |
| | | | |
| | | | |
| skipping to change at line 165 | | skipping to change at line 165 | |
| virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)")
; } | | virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)")
; } | |
| virtual TKey* CreateKey(TDirectory* mother, const TObject* obj, co
nst char* name, Int_t bufsize); | | virtual TKey* CreateKey(TDirectory* mother, const TObject* obj, co
nst char* name, Int_t bufsize); | |
| virtual TKey* CreateKey(TDirectory* mother, const void* obj, const
TClass* cl, | | virtual TKey* CreateKey(TDirectory* mother, const void* obj, const
TClass* cl, | |
| const char* name, Int_t bufsize); | | const char* name, Int_t bufsize); | |
| virtual void Delete(const char *namecycle=""); | | virtual void Delete(const char *namecycle=""); | |
| virtual void Draw(Option_t *option=""); | | virtual void Draw(Option_t *option=""); | |
| virtual void DrawMap(const char *keys="*",Option_t *option=""); /
/ *MENU* | | virtual void DrawMap(const char *keys="*",Option_t *option=""); /
/ *MENU* | |
| virtual void FillBuffer(char *&buffer); | | virtual void FillBuffer(char *&buffer); | |
| virtual void Flush(); | | virtual void Flush(); | |
| TArchiveFile *GetArchive() const { return fArchive; } | | TArchiveFile *GetArchive() const { return fArchive; } | |
|
| | | Long64_t GetArchiveOffset() const { return fArchiveOffset; } | |
| Int_t GetBestBuffer() const; | | Int_t GetBestBuffer() const; | |
| virtual Int_t GetBytesToPrefetch() const; | | virtual Int_t GetBytesToPrefetch() const; | |
| TFileCacheRead *GetCacheRead() const; | | TFileCacheRead *GetCacheRead() const; | |
| TFileCacheWrite *GetCacheWrite() const; | | TFileCacheWrite *GetCacheWrite() const; | |
| TArrayC *GetClassIndex() const { return fClassIndex; } | | TArrayC *GetClassIndex() const { return fClassIndex; } | |
| Int_t GetCompressionAlgorithm() const; | | Int_t GetCompressionAlgorithm() const; | |
| Int_t GetCompressionLevel() const; | | Int_t GetCompressionLevel() const; | |
| Int_t GetCompressionSettings() const; | | Int_t GetCompressionSettings() const; | |
| Float_t GetCompressionFactor(); | | Float_t GetCompressionFactor(); | |
| virtual Long64_t GetEND() const { return fEND; } | | virtual Long64_t GetEND() const { return fEND; } | |
| | | | |
End of changes. 2 change blocks. |
| 1 lines changed or deleted | | 2 lines changed or added | |
|
| TFilePrefetch.h | | TFilePrefetch.h | |
|
| // @(#)root/io:$Id: TFilePrefetch.h 39675 2011-06-10 16:19:12Z pcanal $ | | // @(#)root/io:$Id: TFilePrefetch.h 41699 2011-11-01 21:38:19Z pcanal $ | |
| // Author: Elvin Sindrilaru 19/05/2011 | | // Author: Elvin Sindrilaru 19/05/2011 | |
| | | | |
| /************************************************************************* | | /************************************************************************* | |
| * Copyright (C) 1995-2011, Rene Brun and Fons Rademakers. * | | * Copyright (C) 1995-2011, Rene Brun and Fons Rademakers. * | |
| * All rights reserved. * | | * All rights reserved. * | |
| * * | | * * | |
| * For the licensing terms see $ROOTSYS/LICENSE. * | | * For the licensing terms see $ROOTSYS/LICENSE. * | |
| * For the list of contributors see $ROOTSYS/README/CREDITS. * | | * For the list of contributors see $ROOTSYS/README/CREDITS. * | |
| *************************************************************************/ | | *************************************************************************/ | |
| | | | |
| | | | |
| skipping to change at line 77 | | skipping to change at line 77 | |
| | | | |
| class TFilePrefetch : public TObject { | | class TFilePrefetch : public TObject { | |
| | | | |
| private: | | private: | |
| TFile *fFile; // reference to the file | | TFile *fFile; // reference to the file | |
| TList *fPendingBlocks; // list of pending block to be read | | TList *fPendingBlocks; // list of pending block to be read | |
| TList *fReadBlocks; // list of block read | | TList *fReadBlocks; // list of block read | |
| TThread *fConsumer; // consumer thread | | TThread *fConsumer; // consumer thread | |
| TMutex *fMutexPendingList; // mutex for the pending list | | TMutex *fMutexPendingList; // mutex for the pending list | |
| TMutex *fMutexReadList; // mutex for the list of read blocks | | TMutex *fMutexReadList; // mutex for the list of read blocks | |
|
| | | TMutex *fMutexSynch; // mutex for synchronisation between wor
king and main thread | |
| TCondition *fNewBlockAdded; // condition used to signal the addition
of a new pending block | | TCondition *fNewBlockAdded; // condition used to signal the addition
of a new pending block | |
| TCondition *fReadBlockAdded; // condition usd to signal the addition
of a new red block | | TCondition *fReadBlockAdded; // condition usd to signal the addition
of a new red block | |
| TSemaphore *fSem; // semaphore used to kill the consumer t
hread | | TSemaphore *fSem; // semaphore used to kill the consumer t
hread | |
| TString fPathCache; // path to the cache directory | | TString fPathCache; // path to the cache directory | |
| TStopwatch fWaitTime; // time wating to prefetch a buffer (in
usec) | | TStopwatch fWaitTime; // time wating to prefetch a buffer (in
usec) | |
| | | | |
| static TThread::VoidRtnFunc_t ThreadProc(void*); //create a joinable wo
rker thread | | static TThread::VoidRtnFunc_t ThreadProc(void*); //create a joinable wo
rker thread | |
| | | | |
| public: | | public: | |
| TFilePrefetch(TFile*); | | TFilePrefetch(TFile*); | |
| | | | |
| skipping to change at line 113 | | skipping to change at line 114 | |
| Bool_t SetCache(const char*); | | Bool_t SetCache(const char*); | |
| Bool_t CheckCachePath(const char*); | | Bool_t CheckCachePath(const char*); | |
| Bool_t CheckBlockInCache(char*&, TFPBlock*); | | Bool_t CheckBlockInCache(char*&, TFPBlock*); | |
| char *GetBlockFromCache(const char*, Int_t); | | char *GetBlockFromCache(const char*, Int_t); | |
| void SaveBlockInCache(TFPBlock*); | | void SaveBlockInCache(TFPBlock*); | |
| | | | |
| Int_t SumHex(const char*); | | Int_t SumHex(const char*); | |
| Bool_t BinarySearchReadList(TFPBlock*, Long64_t, Int_t, Int_t*); | | Bool_t BinarySearchReadList(TFPBlock*, Long64_t, Int_t, Int_t*); | |
| Long64_t GetWaitTime(); | | Long64_t GetWaitTime(); | |
| | | | |
|
| | | void SetFile(TFile*); | |
| | | TMutex* GetMutexSynch() const { return fMutexSynch; }; | |
| | | | |
| ClassDef(TFilePrefetch, 0); // File block prefetcher | | ClassDef(TFilePrefetch, 0); // File block prefetcher | |
| }; | | }; | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 3 change blocks. |
| 1 lines changed or deleted | | 5 lines changed or added | |
|