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
0083
0084
0085
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
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200 }
0201
0202
0203 #endif