Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef PHASIC_Channels_Multi_Channel_H
0002 #define PHASIC_Channels_Multi_Channel_H
0003 
0004 #include "ATOOLS/Org/Info_Key.H"
0005 
0006 namespace PHASIC {
0007 
0008   class Cut_Data;
0009   class Single_Channel;
0010 
0011   struct channel_type {
0012     enum code {
0013       simple     = 0,
0014       resonance  = 1,
0015       threshold  = 2,
0016       leadinglog = 3,
0017       laserback  = 4,
0018       exponential= 5,
0019       unknown    = 99
0020     };
0021   };
0022 
0023   struct Channel_Info {
0024     channel_type::code   type;
0025     std::vector <double> parameters;
0026 
0027     Channel_Info(const channel_type::code & ctype=channel_type::unknown) :
0028       type(ctype) {}
0029     Channel_Info(const channel_type::code & ctype,const double & p0) :
0030       type(ctype) { parameters.push_back(p0); }
0031     Channel_Info(const channel_type::code & ctype,const double & p0,
0032          const double & p1) : type(ctype)
0033     { parameters.push_back(p0); parameters.push_back(p1); }
0034     Channel_Info(const channel_type::code & ctype,const double & p0,
0035          const double & p1,const double & p2) : type(ctype)
0036     { parameters.push_back(p0); parameters.push_back(p1); parameters.push_back(p2); }
0037 
0038     bool operator==(const Channel_Info & ci) {
0039       if (type != ci.type)                           return 0;
0040       if (parameters.size() != ci.parameters.size()) return 0;
0041       for (unsigned int i=0;i<parameters.size();i++) {
0042     if (parameters[i] != ci.parameters[i])       return 0;
0043       }
0044       return 1;
0045     }
0046     bool operator!=(const Channel_Info & ci) { return (!(operator==(ci))); }
0047   };
0048 
0049   typedef std::vector<PHASIC::Channel_Info> channelinfos;
0050 
0051   class Multi_Channel {
0052   protected :
0053     int                           nin, nout;
0054     std::string                   name;
0055     long unsigned int             n_points,n_contrib;
0056     long unsigned int             mn_points,mn_contrib;
0057     double                        m_weight;
0058     double                        rans[2];
0059     double                        s1xmin, * s1;
0060     std::vector<Single_Channel *> channels;
0061     std::map<std::string,double>  m_erans;
0062     bool m_readin;
0063     int m_lastdice;
0064     int m_otype;
0065   public:
0066     Multi_Channel(std::string name);
0067     virtual ~Multi_Channel();
0068 
0069     virtual bool Initialize();
0070 
0071     void             Add(Single_Channel *);
0072     virtual void     DropAllChannels(const bool del=true);
0073     void             DropChannel(int);
0074     Single_Channel * Channel(int);
0075     virtual void     Reset();
0076     virtual void     Optimize(double);
0077     virtual void     MPISync();
0078 
0079     inline std::vector<Single_Channel*> &Channels() { return channels; }
0080 
0081     /*!
0082       Endoptimize replaces, after an ordinary optimization step, the set of a-priori weights
0083       with the best set so far which has been stored during the optimization procedure.
0084       Channels, whose a-priori weight drops under a critical value are discarded
0085       in the follwoing by setting their a-priori weights to 0.
0086     */
0087     std::string SelectChannel();
0088 
0089     virtual void EndOptimize(double);
0090     virtual bool OptimizationFinished();
0091 
0092     virtual void AddPoint(double);
0093     virtual void GeneratePoint(ATOOLS::Vec4D *,Cut_Data *);
0094     virtual void GenerateWeight(ATOOLS::Vec4D *,Cut_Data *);
0095 
0096     void GeneratePoint();
0097     void GenerateWeight();
0098 
0099     virtual void ISRInfo(int,int &,double &,double &);
0100     virtual void ISRInfo(std::vector<int> &ts,
0101                          std::vector<double> &ms,std::vector<double> &ws) const;
0102 
0103     inline  Single_Channel *operator[](size_t i) { return channels[i]; }
0104 
0105     virtual void    Print();
0106     virtual void    WriteOut(std::string);
0107     virtual bool    ReadIn(std::string);
0108 
0109     size_t NChannels() const;
0110 
0111     virtual size_t              Number()    { return channels.size(); }
0112     inline long unsigned int    N()         { return n_points; }
0113     inline long unsigned int    ValidN()    { return n_contrib; }
0114     inline long unsigned int    ValidMN()   { return mn_contrib; }
0115     inline int                  Nin()       { return nin; }
0116     inline int                  Nout()      { return nout; }
0117     inline double               Weight()    { return m_weight; }
0118     inline std::string          Name()      { return name; }
0119     std::string                 ChID(int);
0120     Single_Channel*             LastChannel() { if (m_lastdice>=0) return Channel(m_lastdice); return 0;}
0121     void                        NoGenerate()    { m_lastdice=-1; }
0122 
0123     inline void SetNin(int _nin)   { nin=_nin; }
0124     inline void SetNout(int _nout) { nout=_nout; }
0125 
0126     int                         OType() const  { return m_otype; }
0127 
0128     virtual int                 HandicapFactor() { return 1; }
0129     inline void AddERan(const std::string &id) { m_erans[id]=0.0; }
0130     inline double ERan(const std::string &id) const { return m_erans.find(id)->second; }
0131   };
0132 
0133 
0134   /*!
0135     This is the Multi_Channel, AMEGICs preferred integration
0136     tool. The idea is to have a vector of Single_Channels
0137     that are repeatedly called according to their a priori
0138     weights (alpha in the channels). These weights are optimized
0139     during integration such that the overall variance is minimized.
0140   */
0141   /*!
0142     Some basic ingredients for all channels :
0143     numbers of legs and their flavours (not needed for isr)
0144     and the name of the channel. This name might be given explicitly
0145     (for instance for ISR_Channels) or it may be constructed from amplitudes
0146     in the Phase_Space/Channel_Generator.
0147   */
0148   /*!
0149     Stuff for the immediate integration
0150   */
0151   /*!
0152     Managing the multichannel, adding and dropping channels as well as
0153     access to individual channels.
0154   */
0155   /*!
0156     Reset does a complete reset of the multi-channel. All a-priori weights are reset
0157     to uniform probabilities, the individual channels are reset, and the actual weights
0158     of all channels are set to 0. Furthermore, the result and the result2 within
0159     the multi-channel are set to 0, the minimal spread so far is set to some
0160     arbitrary high value. If not existing so far, spread-vectors are initialized.
0161   */
0162   /*!
0163     Here the counters within an iterations are reset to 0.
0164     I doubt whether we need this.
0165   */
0166   /*!
0167     Optimzing the a-priori weights of the multi-channel.
0168     The idea is to compare the individual variance with their average and
0169     reshuffle the a-priori weights such that all variances would equal the
0170     average. What I find strange in this method at the moment is the occurence
0171     of s2 ... . I'll have to check this ... .
0172   */
0173   /*!
0174     Endoptimize replaces, after an ordinary optimization step, the set of a-priori weights
0175     with the best set so far which has been stored during the optimization procedure.
0176     Channels, whose a-priori weight drops under a critical value are discarded
0177     in the follwoing by setting their a-priori weights to 0.
0178   */
0179   /*!
0180     A value is added to the multi-channel, and, in due proportion, to the
0181     individual channels. This amounts to incrementing the results and the results squared
0182     of the channels, for the multi-channel, the global result(2) is incremented,
0183     for the individual channels within, the res(1,2,3) are incremented that are valid
0184     only during one iteration.
0185   */
0186   /*!
0187     The variance of a statistical distribution (values accumulated in result and their
0188     squares in result2) over a number of trials. This is equivalent to one Standard deviation
0189     and thus a measure for the quality of an integral-estimate.
0190   */
0191   /*!
0192     Methods for the generation of phase space points
0193   */
0194   /*!
0195     This is used for ISR Channels to set the y and s' range.
0196   */
0197   /*!
0198     Simple access methods
0199   */
0200 }
0201 
0202 
0203 #endif