Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/tmva $Id$
0002 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Eckhard v. Toerne
0003 
0004 /**********************************************************************************
0005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0006  * Package: TMVA                                                                  *
0007  * Class  : VariableGaussTransform                                                *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *      Decorrelation of input variables                                          *
0012  *                                                                                *
0013  * Authors (alphabetical):                                                        *
0014  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
0015  *      Joerg Stelzer   <Joerg.Stelzer@cern.ch>  - CERN, Switzerland              *
0016  *      Eckhard v. Toerne     <evt@uni-bonn.de>  - Uni Bonn, Germany              *
0017  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
0018  *                                                                                *
0019  * Copyright (c) 2005:                                                            *
0020  *      CERN, Switzerland                                                         *
0021  *      U. of Victoria, Canada                                                    *
0022  *      MPI-K Heidelberg, Germany                                                 *
0023  *                                                                                *
0024  * Redistribution and use in source and binary forms, with or without             *
0025  * modification, are permitted according to the terms listed in LICENSE           *
0026  * (see tmva/doc/LICENSE)                                          *
0027  **********************************************************************************/
0028 
0029 #ifndef ROOT_TMVA_VariableGaussTransform
0030 #define ROOT_TMVA_VariableGaussTransform
0031 
0032 #include "TMVA/PDF.h"
0033 
0034 //////////////////////////////////////////////////////////////////////////
0035 //                                                                      //
0036 // VariableGaussTransform                                               //
0037 //                                                                      //
0038 // Gaussian transformation of input variables.                          //
0039 //                                                                      //
0040 //////////////////////////////////////////////////////////////////////////
0041 
0042 #include <vector>
0043 
0044 #include "TH1.h"
0045 #include "TGraph.h"
0046 #include "TSpline.h"
0047 #include "TDirectory.h"
0048 #include "Event.h"
0049 
0050 #include "TMVA/VariableTransformBase.h"
0051 
0052 namespace TMVA {
0053 
0054    class TMVAGaussPair {
0055 
0056    public:
0057 
0058    TMVAGaussPair( Float_t f, Float_t w ): fF(f), fW(w) {}
0059       Bool_t  operator >  ( const TMVAGaussPair &p ) const { return fF >  p.fF; }
0060       Bool_t  operator <  ( const TMVAGaussPair &p ) const { return fF <  p.fF; }
0061       Bool_t  operator == ( const TMVAGaussPair &p ) const { return fF == p.fF; }
0062       Float_t GetValue() const { return fF; }
0063       Float_t GetWeight() const { return fW; }
0064 
0065    private:
0066 
0067       Float_t fF; // the float
0068       Float_t fW; // the event weight
0069    };
0070 
0071 
0072    class VariableGaussTransform : public VariableTransformBase {
0073 
0074    public:
0075 
0076       VariableGaussTransform( DataSetInfo& dsi, TString strcor=""  );
0077       virtual ~VariableGaussTransform( void );
0078 
0079       void   Initialize();
0080       Bool_t PrepareTransformation (const std::vector<Event*>&);
0081 
0082       virtual const Event* Transform(const Event* const, Int_t cls ) const;
0083       virtual const Event* InverseTransform(const Event* const, Int_t cls ) const;
0084 
0085       void WriteTransformationToStream ( std::ostream& ) const;
0086       void ReadTransformationFromStream( std::istream&, const TString& );
0087 
0088       virtual void AttachXMLTo(void* parent);
0089       virtual void ReadFromXML( void* trfnode );
0090 
0091       virtual void PrintTransformation( std::ostream & o );
0092 
0093       // writer of function code
0094       virtual void MakeFunction( std::ostream& fout, const TString& fncName, Int_t part, UInt_t trCounter, Int_t cls );
0095 
0096    private:
0097 
0098       Bool_t           fFlatNotGauss;
0099       Int_t            fPdfMinSmooth;
0100       Int_t            fPdfMaxSmooth;
0101       //      mutable Event*   fTransformedEvent;
0102 
0103       std::vector< std::vector< TH1F* > >      fCumulativeDist;     ///<! The Cumulative distributions
0104       //std::vector< std::vector< TGraph* > >    fCumulativeGraph;  ///<! The Cumulative distributions
0105       //std::vector< std::vector< TSpline3* > >  fCumulativeSpline; ///<! The Cumulative distributions
0106       std::vector< std::vector< PDF*> >         fCumulativePDF;     ///<  The cumulative PDF
0107 
0108       void GetCumulativeDist( const std::vector<Event*>& );
0109       void CleanUpCumulativeArrays(TString opt = "ALL");
0110 
0111       // needed for backward compatibility
0112       UInt_t fElementsperbin;  // av number of events stored per bin in cum dist
0113       Double_t OldCumulant(Float_t x, TH1* h ) const;
0114 
0115       ClassDef(VariableGaussTransform,0); // Variable transformation: Gauss transformation
0116    };
0117 
0118 } // namespace TMVA
0119 
0120 #endif