Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:59

0001 // @(#)root/tmva $Id$
0002 // Author: Peter Speckmayer
0003 
0004 /**********************************************************************************
0005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0006  * Package: TMVA                                                                  *
0007  * Class  : GeneticRange                                                          *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *    Range definition for genetic algorithm                                      *
0012  *                                                                                *
0013  * Authors (alphabetical):                                                        *
0014  *      Peter Speckmayer <speckmay@mail.cern.ch>  - CERN, Switzerland             *
0015  *                                                                                *
0016  * Copyright (c) 2005:                                                            *
0017  *      CERN, Switzerland                                                         *
0018  *      MPI-K Heidelberg, Germany                                                 *
0019  *                                                                                *
0020  * Redistribution and use in source and binary forms, with or without             *
0021  * modification, are permitted according to the terms listed in LICENSE           *
0022  * (see tmva/doc/LICENSE)                                          *
0023  **********************************************************************************/
0024 
0025 #ifndef ROOT_TMVA_GeneticRange
0026 #define ROOT_TMVA_GeneticRange
0027 
0028 //////////////////////////////////////////////////////////////////////////
0029 //                                                                      //
0030 // GeneticRange                                                         //
0031 //                                                                      //
0032 // Range definition for genetic algorithm                               //
0033 //                                                                      //
0034 //////////////////////////////////////////////////////////////////////////
0035 
0036 #include "TMVA/Interval.h"
0037 
0038 class TRandom3;
0039 
0040 namespace TMVA {
0041 
0042    class GeneticRange {
0043 
0044    public:
0045 
0046       GeneticRange( TRandom3* rnd, Interval *interval );
0047       virtual ~GeneticRange();
0048 
0049       Double_t Random( Bool_t near = kFALSE, Double_t value=0, Double_t spread=0.1, Bool_t mirror=kFALSE );
0050       Double_t RandomDiscrete();
0051 
0052       Double_t GetFrom()        { return fFrom; }
0053       Double_t GetTo()          { return fTo; }
0054       Double_t GetTotalLength() { return fTotalLength; }
0055 
0056    private:
0057 
0058       Double_t fFrom, fTo;    ///< the constraints of the coefficient
0059       Int_t fNbins;
0060 
0061       Interval *fInterval;     ///< holds the complete information of the interval
0062       Double_t fTotalLength;  ///< the distance between the lower and upper constraints
0063 
0064       // maps the values thrown outside of the ]from,to] interval back to the interval
0065       // the values which leave the range on the from-side, are mapped in to the to-side
0066       Double_t ReMap( Double_t val );
0067 
0068       // same as before, but the values leaving the allowed range, are mirrored into the range.
0069       Double_t ReMapMirror( Double_t val );
0070 
0071       TRandom3* fRandomGenerator;  ///< the randomGenerator for calculating the new values
0072 
0073       ClassDef(GeneticRange,0); // Range definition for genetic algorithm
0074    };
0075 
0076 } // namespace TMVA
0077 
0078 #endif