Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef PHASIC_Main_Color_Integrator_H
0002 #define PHASIC_Main_Color_Integrator_H
0003 
0004 #include <vector>
0005 #include <iostream>
0006 #include <map>
0007 
0008 namespace ATOOLS { class Cluster_Amplitude; }
0009 
0010 namespace PHASIC {
0011 
0012   struct cls {
0013 
0014     enum scheme {
0015       unknown   = 0,
0016       sum       = 1,
0017       sample    = 2
0018     };
0019 
0020     static std::map<std::string,std::string> ColorSchemeTags();
0021 
0022   };// end of struct cls
0023 
0024   std::ostream &operator<<(std::ostream &str,const cls::scheme &s);
0025 
0026   typedef std::vector<int>    Int_Vector;
0027   typedef std::vector<double> Double_Vector;
0028 
0029   class Representation {
0030   protected:
0031 
0032     size_t m_id, m_i, m_j;
0033     int    m_type, m_act;
0034 
0035     Int_Vector m_ids;
0036 
0037   public:
0038 
0039     // constructor
0040     Representation(const size_t &id,const int &type,const int &act);
0041 
0042     // inline functions
0043     inline void SetI(const size_t &i) { m_i=i; }
0044     inline void SetJ(const size_t &j) { m_j=j; }
0045 
0046     inline size_t I() const { return m_i; }
0047     inline size_t J() const { return m_j; }
0048 
0049     inline size_t Id() const { return m_id; }
0050 
0051     inline int Type() const { return m_type; }
0052     inline int Act() const  { return m_act;  }
0053 
0054     inline const Int_Vector &Ids() const { return m_ids; }
0055 
0056   };// end of class Representation
0057 
0058   std::ostream &operator<<(std::ostream &ostr,const Representation &v);
0059   
0060   typedef short unsigned int      Idx_Type;
0061   typedef std::vector<Idx_Type>   Idx_Vector;
0062   typedef std::vector<Idx_Vector> Idx_Matrix;
0063 
0064   class Color_Integrator {
0065   private:
0066 
0067     std::vector<Representation*> m_ids, m_decids;
0068     std::vector<std::vector<double> > m_mc, m_sum, m_msum;
0069     std::vector<size_t> m_specs;
0070 
0071     Idx_Matrix m_orders;
0072     Idx_Vector m_lastids, m_lastperm, m_nexti;
0073 
0074     Double_Vector m_weights, m_cweights, m_alpha;
0075 
0076     size_t m_pairs, m_lastconf, m_alphamode, m_csmode, m_omode;
0077     bool   m_check, m_on, m_otfcc, m_fincc, m_valid, m_nogen, m_won;
0078 
0079     double m_weight, m_n, m_nv, m_max, m_over, m_cmax, m_mean, m_cweight;
0080     double m_sn, m_msn;
0081 
0082     double Factorial(const double &n) const;
0083 
0084     std::pair<int,double> GenerateIndex
0085     (const std::vector<int> &idx,const int i);
0086 
0087     bool GenerateColours();
0088     int  Generate();
0089     bool LookUp();
0090     
0091     int  ConstructConfigurations(Idx_Vector ids,Idx_Vector perm,
0092                  bool sing,double weight,
0093                  Idx_Vector &nexti,bool one,size_t depth);
0094     void InitConstruction(Idx_Vector &ids,Idx_Vector &perm,
0095               Idx_Vector &nexti);
0096     int  ConstructConfigurations();
0097 
0098     bool TrivialCheck();
0099     bool CheckDecays();
0100     bool CheckPermutation(const Idx_Vector &perm);
0101 
0102     bool AddConfiguration(const size_t &i);
0103     bool RInitialize();
0104 
0105   public:
0106 
0107     // constructor
0108     Color_Integrator();
0109 
0110     // destructor
0111     ~Color_Integrator();
0112 
0113     // member functions
0114     bool ConstructRepresentations(const Idx_Vector &ids,
0115                   const Int_Vector &types,
0116                   const Int_Vector &acts);
0117 
0118     bool NextOrder();
0119     bool GenerateOrders();
0120     bool GeneratePoint();
0121     bool GenerateType(const size_t &type,const bool orders=false);
0122     bool Initialize();
0123 
0124     size_t IdentifyType(const Idx_Vector &perm) const;
0125 
0126     void SetI(const Int_Vector &i);
0127     void SetJ(const Int_Vector &j);
0128 
0129     Int_Vector I() const;
0130     Int_Vector J() const;
0131 
0132     void MPISync(const int mode=0);
0133     void AddPoint(const double &weight);
0134     void Optimize();
0135 
0136     void ReadIn(const std::string &path);
0137     void WriteOut(const std::string &path);
0138 
0139     bool SetConfiguration(const size_t &id);
0140 
0141     void SetAlpha(const Double_Vector &alpha);
0142 
0143     void SetPoint(const ATOOLS::Cluster_Amplitude *const ampl);
0144     void SetPoint(const Int_Vector &ci,const Int_Vector &cj);
0145 
0146     void SetDecayIds(const std::vector<size_t> &ids,
0147              const Int_Vector &types,const Int_Vector &acts);
0148 
0149     // inline functions
0150     inline void SetOMode(const bool omode)     { m_omode=omode;     }
0151     inline void SetNoGen(const bool nogen)     { m_nogen=nogen;     }
0152     inline void SetCheck(const bool check)     { m_check=check;     }
0153     inline void SetOTFCC(const bool otf)       { m_otfcc=otf;       }
0154 
0155     inline void SetOn(const bool on)           { m_on=on;           }
0156     inline void SetAlphaMode(const size_t am)  { m_alphamode=am;    }
0157 
0158     inline bool OMode() const   { return m_omode;   }
0159     inline bool NoGen() const   { return m_nogen;   }
0160     inline bool Check() const   { return m_check;   }
0161     inline bool OTFCC() const   { return m_otfcc;   }
0162 
0163     inline bool On() const { return m_on; }
0164 
0165     inline bool ValidPoint() const   { return m_valid; }
0166 
0167     inline void RestartOrders() { m_fincc=true; }
0168 
0169     inline double GlobalWeight() const { return m_won?m_cweight:1.0; }
0170 
0171     inline const Idx_Matrix    &Orders() const  { return m_orders; }
0172     inline const Double_Vector &Weights() const { return m_weights; }
0173 
0174     inline void SetWOn(const bool won) { m_won=won; }
0175 
0176   };// end of class Color_Integrator
0177 
0178 }// end of namespace PHASIC
0179 
0180 #endif