Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:10:09

0001 #ifndef PHASIC_Channels_Vegas_H
0002 #define PHASIC_Channels_Vegas_H
0003 
0004 #include "ATOOLS/Org/Message.H"
0005 #include <list>
0006 #include <vector>
0007 
0008 namespace PHASIC {
0009 
0010   class Vegas {
0011   public:
0012     class Mapping {
0013     public:
0014       virtual double operator()(double &x) const = 0;
0015     };// end of class Mapping
0016     class Power: public Mapping {
0017     public:
0018       double m_exp;
0019       inline Power(const double &exp): m_exp(exp) {}
0020       double operator()(double &x) const;
0021     };// end of class Power
0022   private:
0023     std::string m_name;
0024     int m_nd;
0025     unsigned long m_nevt,m_nopt,m_snevt,m_cevt;
0026     unsigned long m_mnevt, m_mcevt, m_const;
0027     double m_alpha;
0028     double m_nc;
0029     double **p_xi;
0030     double *p_x,*p_xin,*p_r,*p_cx,*p_bm;
0031     double **p_d,**p_di,*p_dt;
0032     double **p_md,**p_mdi;
0033     double *p_chi,*p_bestchi,**p_bestxi;
0034     int *p_ia,*p_opt,*p_cb;
0035     int **p_hit, m_sint, m_scnt;
0036     int **p_mhit;
0037     int m_dim,m_mode,m_on,m_autooptimize,m_omode,m_cmode;
0038     static int s_on, s_onext;
0039     void Rebin(double rc, double * xi);
0040     void AddPoint(double);
0041   public:
0042     Vegas(int dim,int ndx,const std::string &);
0043     ~Vegas();
0044     double* GeneratePoint(const double * _ran);
0045     double GenerateWeight(const double *) const;
0046     double GenerateBinWeight(int *) const;
0047     void AddPoint(double,double *);
0048     void AddBinPoint(double,int *);
0049 
0050     void MPISync();
0051     void Reset();
0052     void Optimize();
0053     void EndOptimize();
0054     void ConstChannel(int i) { p_opt[i]=0; m_const|=(1<<i); }
0055 
0056     void InitBinInfo();
0057     void Refine();
0058     void Preset(const Mapping *,const int);
0059 
0060     void SetOptimizeChannel(int i,const bool opt) { p_opt[i]=opt;    }
0061     bool OptimizeChannel(int i) const             { return p_opt[i]; }
0062 
0063     void SetCheck(int mode) { m_mode=mode; }
0064 
0065     void WriteOut(const std::string &);
0066     void ReadIn(const std::string &);
0067     void WriteHistos(const std::string &);
0068 
0069     void SetAutoOptimize(int ao)    { m_autooptimize=ao*m_nd; }
0070 
0071     void SetAutoRefine() { m_sint=1; }
0072 
0073     static inline void SetOnExternal(const bool on) { s_onext=on;     }
0074     static inline bool OnExternal()                 { return s_onext; }
0075 
0076     bool Finished();
0077 
0078     std::vector<double> GetMaxPos() const;
0079     std::vector<double> GetMeanPos() const;
0080 
0081     double *GetBinsMean(int *) const;
0082 
0083     inline std::string Name() const { return m_name; }
0084 
0085     inline int GetNBins() const { return m_nd; }
0086     inline int GetNDims() const { return m_dim; }
0087 
0088     inline int    *GetPointBins() const     { return p_cb; }
0089     inline double *GetPointBinsMean() const { return p_cx; }
0090 
0091     inline void SetOutputMode(const int mode) { m_omode=mode; }
0092     inline void SetCheckMode(const int mode)  { m_cmode=mode; }
0093 
0094   };
0095 
0096 }
0097 
0098 #endif