Herwig++
2.7.0
|
00001 // -*- C++ -*- 00002 // 00003 // DecayPhaseSpaceMode.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator 00004 // Copyright (C) 2002-2011 The Herwig Collaboration 00005 // 00006 // Herwig++ is licenced under version 2 of the GPL, see COPYING for details. 00007 // Please respect the MCnet academic guidelines, see GUIDELINES for details. 00008 // 00009 #ifndef HERWIG_DecayPhaseSpaceMode_H 00010 #define HERWIG_DecayPhaseSpaceMode_H 00011 // 00012 // This is the declaration of the DecayPhaseSpaceMode class. 00013 // 00014 #include "ThePEG/Interface/Interfaced.h" 00015 #include "DecayPhaseSpaceMode.fh" 00016 #include "DecayPhaseSpaceChannel.h" 00017 #include "Herwig++/PDT/GenericWidthGenerator.h" 00018 #include "Herwig++/PDT/GenericMassGenerator.h" 00019 #include <Herwig++/Decay/DecayVertex.h> 00020 #include "DecayIntegrator.h" 00021 00022 namespace Herwig { 00023 using namespace ThePEG; 00024 00043 class DecayPhaseSpaceMode: public Interfaced { 00044 00048 friend ostream & operator<<(ostream &, const DecayPhaseSpaceMode &); 00049 00054 friend class DecayIntegrator; 00055 00060 friend class DecayPhaseSpaceChannel; 00061 00062 public: 00063 00069 DecayPhaseSpaceMode() : _maxweight(0.),_niter(10), _npoint(10000), _ntry(500), 00070 _partial(-1), _testOnShell(false), _ichannel(999) {} 00071 00080 DecayPhaseSpaceMode(tPDVector in, tcDecayIntegratorPtr intin,bool onShell=false) 00081 : _integrator(intin), _maxweight(0.), 00082 _niter(10), _npoint(10000), _ntry(500), 00083 _extpart(in), _partial(-1), _testOnShell(onShell), _ichannel(999) {} 00085 00091 tcPDPtr externalParticles(int ix) const {return _extpart[ix];} 00092 00097 unsigned int numberofParticles() const {return _extpart.size();} 00098 00103 unsigned int numberChannels() const {return _channels.size();} 00104 00109 void addChannel(DecayPhaseSpaceChannelPtr channel) { 00110 channel->init(); 00111 _channels.push_back(channel); 00112 } 00113 00122 void resetIntermediate(int ichan, tcPDPtr part, Energy mass, Energy width) { 00123 if(!part) return; 00124 _channels[ichan]->resetIntermediate(part,mass,width); 00125 } 00126 00134 void resetIntermediate(tcPDPtr part, Energy mass, Energy width) { 00135 for(unsigned int ix=0,N=_channels.size();ix<N;++ix) 00136 _channels[ix]->resetIntermediate(part,mass,width); 00137 } 00138 00143 double maxWeight() const {return _maxweight;} 00144 00149 void setMaxWeight(double wgt) const {_maxweight=wgt;} 00150 00156 double channelWeight(unsigned int ichan) const {return _channelwgts[ichan];} 00157 00162 void setWeights(const vector<double> & in) const {_channelwgts=in;} 00163 00167 unsigned int selectedChannel() const {return _ichannel;} 00168 00172 bool testOnShell() const { return _testOnShell; } 00173 00174 protected: 00175 00182 Energy initializePhaseSpace(bool init, bool onShell=false); 00183 00190 void setIntegrate(int iter,int points,int ntry) { 00191 _niter=iter; 00192 _npoint=points; 00193 _ntry=ntry; 00194 } 00195 00201 void setPartialWidth(int in) {_partial=in;} 00203 00204 00207 00216 double me2(const int ichan ,const Particle & inpart, 00217 const ParticleVector &outpart,DecayIntegrator::MEOption opt) const { 00218 return _integrator->me2(ichan,inpart,outpart,opt); 00219 } 00220 00230 ParticleVector generate(bool intermediates,bool cc,const Particle & inpart) const; 00231 00232 00238 int selectChannel(const Particle & inpart, ParticleVector & outpart) const { 00239 // if using flat phase-space don't need to do this 00240 if(_channelwgts.empty()) return 0; 00241 vector<double> mewgts(_channels.size(),0.0); 00242 double total=0.; 00243 for(unsigned int ix=0,N=_channels.size();ix<N;++ix) { 00244 mewgts[ix]=me2(ix,inpart,outpart,DecayIntegrator::Calculate); 00245 total+=mewgts[ix]; 00246 } 00247 // randomly pick a channel 00248 total*=UseRandom::rnd(); 00249 int ichan=-1; 00250 do { 00251 ++ichan; 00252 total-=mewgts[ichan]; 00253 } 00254 while(ichan<int(_channels.size())&&total>0.); 00255 return ichan; 00256 } 00257 00268 Energy weight(bool cc,int & ichan, const Particle & in, 00269 ParticleVector & particles,bool first, 00270 bool onShell=false) const { 00271 ichan=0; 00272 Energy phwgt = (_channels.size()==0) ? 00273 flatPhaseSpace(cc,in,particles,onShell) : channelPhaseSpace(cc,ichan,in,particles,onShell); 00274 // generate the matrix element 00275 return me2(-1,in,particles, 00276 first ? DecayIntegrator::Initialize : DecayIntegrator::Calculate)*phwgt; 00277 } 00278 00287 Energy flatPhaseSpace(bool cc,const Particle & inpart, ParticleVector & outpart, 00288 bool onShell=false) const; 00289 00299 Energy channelPhaseSpace(bool cc,int & ichan, const Particle & in, 00300 ParticleVector & particles, 00301 bool onShell=false) const; 00302 00308 void constructVertex(const Particle & in, const ParticleVector & out) const; 00309 00316 vector<Energy> externalMasses(Energy inmass,double & wgt, bool onShell) const; 00318 00319 public: 00320 00327 void persistentOutput(PersistentOStream & os) const; 00328 00334 void persistentInput(PersistentIStream & is, int version); 00336 00340 static void Init(); 00341 00342 protected: 00343 00350 virtual IBPtr clone() const {return new_ptr(*this);} 00351 00356 virtual IBPtr fullclone() const {return new_ptr(*this);} 00358 00359 protected: 00360 00368 virtual void doinit(); 00369 00373 virtual void doinitrun(); 00375 00376 private: 00377 00381 static ClassDescription<DecayPhaseSpaceMode> initDecayPhaseSpaceMode; 00382 00386 DecayPhaseSpaceMode & operator=(const DecayPhaseSpaceMode &); 00387 00388 private: 00389 00393 tcDecayIntegratorPtr _integrator; 00394 00398 vector<DecayPhaseSpaceChannelPtr> _channels; 00399 00403 mutable vector<double> _channelwgts; 00404 00408 mutable double _maxweight; 00409 00413 int _niter; 00414 00418 int _npoint; 00419 00423 int _ntry; 00424 00428 tPDVector _extpart; 00429 00433 int _partial; 00434 00438 cGenericWidthGeneratorPtr _widthgen; 00439 00443 vector<cGenericMassGeneratorPtr> _massgen; 00444 00449 bool _testOnShell; 00450 00454 mutable unsigned int _ichannel; 00455 00456 }; 00457 00461 ostream & operator<<(ostream &, const DecayPhaseSpaceMode &); 00462 00463 } 00464 00465 00466 #include "ThePEG/Utilities/ClassTraits.h" 00467 00468 namespace ThePEG { 00469 00472 template <> 00477 struct BaseClassTrait<Herwig::DecayPhaseSpaceMode,1> { 00479 typedef Interfaced NthBase; 00480 }; 00481 00482 template <> 00487 struct ClassTraits<Herwig::DecayPhaseSpaceMode> 00488 : public ClassTraitsBase<Herwig::DecayPhaseSpaceMode> { 00490 static string className() { return "Herwig::DecayPhaseSpaceMode"; } 00491 }; 00492 00495 } 00496 00497 #endif /* HERWIG_DecayPhaseSpaceMode_H */