File indexing completed on 2026-08-06 09:38:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef ThePEG_FuzzyTheta_H
0011 #define ThePEG_FuzzyTheta_H
0012
0013
0014
0015
0016 #include "ThePEG/Interface/Interfaced.h"
0017 #include "ThePEG/Repository/EventGenerator.h"
0018 #include <cassert>
0019
0020 namespace ThePEG {
0021
0022 namespace CutTypes {
0023
0024
0025
0026
0027 struct Energy {};
0028
0029
0030
0031
0032 struct Momentum {};
0033
0034
0035
0036
0037 struct Rapidity {};
0038
0039
0040
0041
0042 struct Azimuth {};
0043
0044
0045
0046
0047 struct Polar {};
0048
0049 }
0050
0051
0052
0053
0054
0055
0056
0057 class FuzzyTheta: public Interfaced {
0058
0059 public:
0060
0061
0062
0063
0064 FuzzyTheta();
0065
0066 public:
0067
0068
0069
0070
0071
0072
0073
0074 virtual pair<double,double> support(double x) const {
0075 return make_pair(x-0.5,x+0.5);
0076 }
0077
0078
0079
0080
0081
0082
0083
0084 virtual double overlap(double x, const pair<double,double>& box) const {
0085 if ( x - 0.5 >= box.first && x + 0.5 <= box.second )
0086 return 1.;
0087 if ( x - 0.5 > box.second || x + 0.5 < box.first )
0088 return 0.;
0089 return min(box.second,x+0.5) - max(box.first,x-0.5);
0090 }
0091
0092
0093
0094
0095
0096 double overlap(double x,
0097 pair<double,double> box,
0098 const pair<double,double>& support) const {
0099 box.first = max(box.first,support.first);
0100 box.second = min(box.second,support.second);
0101 assert(x >= support.first && x <= support.second);
0102 assert(support.second - support.first >= 1.);
0103 if ( x - 0.5 < support.first )
0104 x = support.first + 0.5;
0105 if ( x + 0.5 > support.second )
0106 x = support.second - 0.5;
0107 return overlap(x,box);
0108 }
0109
0110
0111
0112
0113 pair<double,double> bounds(const CutTypes::Energy&) const {
0114 return make_pair(0.,generator()->maximumCMEnergy()/theEnergyWidth);
0115 }
0116
0117
0118
0119
0120 Energy width(const CutTypes::Energy&) const {
0121 return theEnergyWidth;
0122 }
0123
0124
0125
0126
0127 pair<double,double> bounds(const CutTypes::Momentum&) const {
0128 return make_pair(0.,0.5*generator()->maximumCMEnergy()/theEnergyWidth);
0129 }
0130
0131
0132
0133
0134 Energy width(const CutTypes::Momentum&) const {
0135 return theEnergyWidth;
0136 }
0137
0138
0139
0140
0141 pair<double,double> bounds(const CutTypes::Rapidity&) const {
0142 return make_pair(-Constants::MaxRapidity/theRapidityWidth,
0143 Constants::MaxRapidity/theRapidityWidth);
0144 }
0145
0146
0147
0148
0149 double width(const CutTypes::Rapidity&) const {
0150 return theRapidityWidth;
0151 }
0152
0153
0154
0155
0156 pair<double,double> bounds(const CutTypes::Azimuth&) const {
0157 return make_pair(0.0,2.*Constants::pi/theAngularWidth);
0158 }
0159
0160
0161
0162
0163 double width(const CutTypes::Azimuth&) const {
0164 return theAngularWidth;
0165 }
0166
0167
0168
0169
0170 pair<double,double> bounds(const CutTypes::Polar&) const {
0171 return make_pair(0.0,Constants::pi/theAngularWidth);
0172 }
0173
0174
0175
0176
0177 double width(const CutTypes::Polar&) const {
0178 return theAngularWidth;
0179 }
0180
0181
0182
0183
0184 template<class CutType, class Value>
0185 bool isInside(const Value& v, const Value& lower, const Value& upper, double& weight) const {
0186 CutType type;
0187 Value w = width(type);
0188 weight *=
0189 overlap(v/w,pair<double,double>(lower/w,upper/w),bounds(type));
0190 if ( weight == 0.0 )
0191 return false;
0192 return true;
0193 }
0194
0195
0196
0197
0198 template<class CutType, class Value>
0199 bool isLessThan(const Value& v, const Value& upper, double& weight) const {
0200 CutType type;
0201 Value w = width(type);
0202 pair<double,double> b = bounds(type);
0203 weight *=
0204 overlap(v/w,pair<double,double>(b.first,upper/w),b);
0205 if ( weight == 0.0 )
0206 return false;
0207 return true;
0208 }
0209
0210
0211
0212
0213 template<class CutType, class Value>
0214 bool isLargerThan(const Value& v, const Value& lower, double& weight) const {
0215 CutType type;
0216 Value w = width(type);
0217 pair<double,double> b = bounds(type);
0218 weight *=
0219 overlap(v/w,pair<double,double>(lower/w,b.first),b);
0220 if ( weight == 0.0 )
0221 return false;
0222 return true;
0223 }
0224
0225 public:
0226
0227
0228
0229
0230
0231
0232
0233 void persistentOutput(PersistentOStream & os) const;
0234
0235
0236
0237
0238
0239
0240 void persistentInput(PersistentIStream & is, int version);
0241
0242
0243
0244
0245
0246
0247
0248
0249 static void Init();
0250
0251 protected:
0252
0253
0254
0255
0256
0257
0258
0259 virtual IBPtr clone() const;
0260
0261
0262
0263
0264
0265 virtual IBPtr fullclone() const;
0266
0267
0268
0269
0270
0271
0272 private:
0273
0274
0275
0276
0277 Energy theEnergyWidth;
0278
0279
0280
0281
0282 double theRapidityWidth;
0283
0284
0285
0286
0287 double theAngularWidth;
0288
0289 private:
0290
0291
0292
0293
0294
0295 static ClassDescription<FuzzyTheta> initFuzzyTheta;
0296
0297
0298
0299
0300
0301 FuzzyTheta & operator=(const FuzzyTheta &) = delete;
0302
0303 };
0304
0305 }
0306
0307 #include "ThePEG/Utilities/ClassTraits.h"
0308
0309 namespace ThePEG {
0310
0311
0312
0313
0314
0315 template <>
0316 struct BaseClassTrait<FuzzyTheta,1> {
0317
0318 typedef Interfaced NthBase;
0319 };
0320
0321
0322
0323 template <>
0324 struct ClassTraits<FuzzyTheta>
0325 : public ClassTraitsBase<FuzzyTheta> {
0326
0327 static string className() { return "ThePEG::FuzzyTheta"; }
0328 };
0329
0330
0331
0332 }
0333
0334 #endif