herwig is hosted by Hepforge, IPPP Durham
Herwig++  2.7.0
DecayPhaseSpaceChannel.h
00001 // -*- C++ -*-
00002 //
00003 // DecayPhaseSpaceChannel.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_DecayPhaseSpaceChannel_H
00010 #define HERWIG_DecayPhaseSpaceChannel_H
00011 //
00012 // This is the declaration of the DecayPhaseSpaceChannel class.
00013 //
00014 #include <ThePEG/Interface/Interfaced.h>
00015 #include <ThePEG/PDT/ParticleData.h>
00016 #include <ThePEG/EventRecord/Particle.h>
00017 #include "DecayPhaseSpaceChannel.fh"
00018 #include "DecayIntegrator.h"
00019 #include "Herwig++/Utilities/Kinematics.h"
00020 #include "ThePEG/Repository/UseRandom.h"
00021 #include "DecayPhaseSpaceMode.fh"
00022 
00023 namespace Herwig {
00024 using namespace ThePEG;
00025 
00052 class DecayPhaseSpaceChannel: public Interfaced {
00053 
00058   friend ostream & operator<<(ostream &, const DecayPhaseSpaceChannel &);
00059 
00064   friend class DecayPhaseSpaceMode;
00065 
00066 public:
00067     
00073   DecayPhaseSpaceChannel() {}
00074 
00079   DecayPhaseSpaceChannel(tcDecayPhaseSpaceModePtr);
00081   
00082 public:
00083   
00102   void addIntermediate(PDPtr part,int jac,double power,int dau1,int dau2) {
00103     _intpart.push_back(part);
00104     _jactype.push_back(jac);
00105     _intpower.push_back(power);
00106     _intdau1.push_back(dau1); 
00107     _intdau2.push_back(dau2);
00108   }
00109   
00119   void resetIntermediate(tcPDPtr part,Energy mass,Energy width) {
00120     if(!part) return;
00121     int idin=part->id();
00122     for(unsigned int ix=0;ix<_intpart.size();++ix) {
00123       if(_intpart[ix] && _intpart[ix]->id()==idin) {
00124         _intmass[ix] =mass;_intwidth[ix]=width;
00125         _intmass2[ix]=mass*mass;_intmwidth[ix]=mass*width;
00126       }
00127     }
00128   }
00129 
00130   /*
00131    * Reset the one of the daughters
00132    * @param oldp The id of the particle being reset
00133    * @param newp The id of the particle replacing it
00134    */
00135   void resetDaughter(int oldp, int newp) {
00136     for(unsigned int ix=0;ix<_intdau1.size();++ix) {
00137       if(_intdau1[ix]==oldp) _intdau1[ix]=newp;
00138     }
00139     for(unsigned int ix=0;ix<_intdau2.size();++ix) {
00140       if(_intdau2[ix]==oldp) _intdau2[ix]=newp;
00141     }
00142   }
00144 
00145 protected:
00146 
00157   vector<Lorentz5Momentum> generateMomenta(const Lorentz5Momentum & pin,
00158                                            const vector<Energy> & massext);
00159   
00167   double generateWeight(const vector<Lorentz5Momentum> & output);
00168 
00180   void generateIntermediates(bool cc,const Particle & in, ParticleVector & out);
00181 
00191   void twoBodyDecay(const Lorentz5Momentum & p, 
00192                     const Energy m1, const Energy m2,
00193                     Lorentz5Momentum & p1, Lorentz5Momentum & p2);
00195   
00196 public:
00197   
00204   void persistentOutput(PersistentOStream & os) const;
00205 
00211   void persistentInput(PersistentIStream & is, int version);
00213 
00217   static void Init();
00218   
00219 protected:
00220   
00227   virtual IBPtr clone() const {return new_ptr(*this);}
00228 
00233   virtual IBPtr fullclone() const {return new_ptr(*this);}
00235 
00236 protected:  
00237 
00245   virtual void doinit();
00246 
00251   virtual void doinitrun();
00253 
00254 private:
00255   
00259   static ClassDescription<DecayPhaseSpaceChannel> initDecayPhaseSpaceChannel;
00260   
00264   DecayPhaseSpaceChannel & operator=(const DecayPhaseSpaceChannel &);
00265   
00266 private:
00267   
00276   Energy generateMass(int ires,Energy lower,Energy upper);
00277   
00285   InvEnergy2 massWeight(int ires, Energy moff,Energy lower,Energy upper);
00287 
00288 private:
00289   
00293   tcDecayPhaseSpaceModePtr _mode;
00294 
00298   vector <PDPtr> _intpart;
00299 
00303   vector <int> _jactype;
00304 
00308   vector<Energy> _intmass;
00309 
00313   vector<Energy> _intwidth;
00314 
00318   vector<Energy2> _intmass2;
00319 
00323   vector<Energy2>_intmwidth;
00324 
00328   vector<double> _intpower;
00329 
00333   vector<int> _intdau1; 
00334 
00338   vector<int> _intdau2;
00339 
00343   vector< vector<int> > _intext;
00344   
00350   double atanhelper_(int ires, Energy limit);
00351 };
00352 
00353 
00357 ostream & operator<<(ostream &, const DecayPhaseSpaceChannel &);
00358 
00362 class DecayPhaseSpaceError: public Exception {};
00363 }
00364 
00365 
00366 namespace ThePEG {
00367 
00374 template <>
00375 
00376 struct BaseClassTrait<Herwig::DecayPhaseSpaceChannel,1> {
00378   typedef Interfaced NthBase;
00379 };
00380 
00385 template <>
00386 
00387 struct ClassTraits<Herwig::DecayPhaseSpaceChannel>
00388   : public ClassTraitsBase<Herwig::DecayPhaseSpaceChannel> {
00390   static string className() { return "Herwig::DecayPhaseSpaceChannel"; }
00391 };
00392 
00395 }
00396 
00397 #endif /* HERWIG_DecayPhaseSpaceChannel_H */