Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:28

0001 // -*- C++ -*-
0002 //
0003 // PartonBinInstance.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 //
0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef THEPEG_PartonBinInstance_H
0010 #define THEPEG_PartonBinInstance_H
0011 // This is the declaration of the PartonBinInstance class.
0012 
0013 #include "ThePEG/Config/ThePEG.h"
0014 #include "ThePEG/PDF/PartonBin.h"
0015 
0016 namespace ThePEG {
0017 
0018 ThePEG_DECLARE_CLASS_POINTERS(PartonBinInstance,PBIPtr);
0019 /** A pair of pointers to PartonBinInstance objects. */
0020 typedef pair<PBIPtr,PBIPtr> PBIPair;
0021 
0022 ThePEG_DECLARE_CLASS_POINTERS(RemInfoBase,RemIPtr);
0023 
0024 /**
0025  * PartonBinInstance is used to store information about the generation
0026  * of a given parton extraction for a corresponding PartonBin object.
0027  */
0028 class PartonBinInstance: public PersistentBase {
0029 
0030 public:
0031 
0032   /** @name Standard constructors and destructors. */
0033   //@{
0034   /**
0035    * Default constructor.
0036    */
0037   PartonBinInstance();
0038 
0039   /**
0040    * Copy-constructor.
0041    */
0042   PartonBinInstance(const PartonBinInstance &);
0043 
0044   /**
0045    * Destructor.
0046    */
0047   virtual ~PartonBinInstance();
0048 
0049   /**
0050    * Constructor taking a PartonBin as argument. The second argument
0051    * should be used if the incoming bin is already known and exists.
0052    */
0053   PartonBinInstance(tcPBPtr, tPBIPtr = tPBIPtr());
0054 
0055   /**
0056    * Constructor using an already prepared extracted parton. This will
0057    * also initialize the x, and scale values. To calculate the
0058    * momentum fractions, a Direction<0> object must have been properly
0059    * initialized.
0060    *
0061    * @param parton the extracted parton which must have its first
0062    * parent set to define the particle extracted from.
0063    *
0064    * @param pb the PartonBin object corresponding to the extracted \a
0065    * parton. If the particle extracted from in turn has been
0066    * extracted, the incoming() member of the PartonBin must point to
0067    * the corresponding PartonBin.
0068    *
0069    * @param scale the resolution scale at which the \a parton was
0070    * extracted.
0071    */
0072   PartonBinInstance(tPPtr parton, tcPBPtr pb, Energy2 scale = ZERO);
0073 
0074   /**
0075    * Constructor using a parton which is to be extracted from the
0076    * given particle, but no mother-child relations exist, yet. This
0077    * will also initialize the x, and scale values. To calculate the
0078    * momentum fractions, a Direction<0> object must have been properly
0079    * initialized.
0080    */
0081   PartonBinInstance(tPPtr particle, tPPtr parton, tcPBPtr pb, 
0082             Energy2 scale = ZERO);
0083 
0084   //@}
0085 
0086 public:
0087 
0088   /** @name Access information about the corresponding PartonBin object. */
0089   //@{
0090   /**
0091    * Return a pointer to the PartonBin this instance refer to.
0092    */
0093   tcPBPtr bin() const { return theBin; }
0094 
0095   /**
0096    * Return pointers to the bins this instance refer to in case more
0097    * than one parton has been extracted.
0098    */
0099   const PartonVector & bins() const { return theBins; }
0100 
0101   /**
0102    * Return a pointer to the data object of the incoming particle.
0103    */
0104   tcPDPtr particleData() const { return bin()->particle(); }
0105 
0106   /**
0107    * Return a pointer to the data object of the extracted parton.
0108    */
0109   tcPDPtr partonData() const { return bin()->parton(); }
0110 
0111   /**
0112    * In the case the incoming particle in turn is extracted from
0113    * another particle, return the PartonBinInstance for that
0114    * extraction.
0115    */
0116   tPBIPtr incoming() const { return theIncoming; }
0117 
0118   /**
0119    * Return the parton bin instance corresponding to the first
0120    * incoming particle for this bin.
0121    */
0122   tPBIPtr getFirst();
0123 
0124   /**
0125    * The PDFBase object describing the momentum distribution of the
0126    * parton within the particle in this PartonBin.
0127    */
0128   tcPDFPtr pdf() const { return bin()->pdf(); }
0129 
0130   /**
0131    * The remnant handler associated with the pdf().
0132    */
0133   tcRemHPtr remnantHandler() const { return bin()->remnantHandler(); }
0134 
0135   /**
0136    * Return true if the corresponding PDFs has a pole at $x=1$ for the
0137    * current particle/parton combination.
0138    */
0139   bool hasPoleIn1() const;
0140   //@}
0141 
0142   /** @name Functions used for the generation. */
0143   //@{
0144   /**
0145    * Reset the current PartonBin, making room for a new event.
0146    */
0147   void reset(double lx = 0, Energy2 Q2 = ZERO);
0148 
0149   /**
0150    * Reset last generated l and Q2 values of this and parent bins.
0151    */
0152   void prepare();
0153 
0154   /**
0155    * Generate l and Q2 of this and parent bins.
0156    */
0157   void generate(const double * r);
0158 
0159   /**
0160    * Get the jacobian associated with the phase space point generated.
0161    */
0162   double jacobian() const { return theJacobian; }
0163 
0164   /**
0165    * Set the jacobian associated with the phase space point generated.
0166    */
0167   void jacobian(double j) { theJacobian = j; }
0168   //@}
0169 
0170   /** @name Access information about the generated extraction. */
0171   //@{
0172   /**
0173    * Get the current particle instance.
0174    */
0175   tPPtr particle() const { return theParticle; }
0176 
0177   /**
0178    * Set the current particle instance.
0179    */
0180   void particle(tPPtr p) { theParticle = p; }
0181 
0182   /**
0183    * Get the current parton instance.
0184    */
0185   tPPtr parton() const { return theParton; }
0186 
0187   /**
0188    * Set the current parton instance.
0189    */
0190   void parton(tPPtr p) { theParton = p; }
0191 
0192   /**
0193    * The currently extracted partons (in case of multiple
0194    * interactions.
0195    */
0196   const PVector & partons() const { return thePartons; }
0197 
0198   /**
0199    * Get the momentum fraction of this parton w.r.t. the incoming
0200    * particle in this bin.
0201    */
0202   double xi() const {
0203     if ( theXi < 0.0 ) theXi = exp(-li());
0204     return theXi;
0205   }
0206 
0207 
0208   /**
0209    * Get one minus the momentum fraction of this parton w.r.t. the
0210    * incoming particle in this bin.
0211    */
0212   double eps() const {
0213     if ( theEps < 0.0 ) theEps =  Math::exp1m(-li());
0214     return theEps;
0215   }
0216 
0217   /**
0218    * Get the logarithmic momentum fraction of this parton w.r.t. the
0219    * incoming particle in this bin.
0220    */
0221   double li() const { return theLi; }
0222 
0223   /**
0224    * Set the logarithmic momentum fraction of this parton w.r.t. the
0225    * incoming particle in this bin.
0226    */
0227   void li(double lx) {
0228     theLi = lx;
0229     theXi = theEps = -1.0;
0230   }
0231 
0232 
0233   /**
0234    * Get the momentum fraction of this parton w.r.t. the collidig
0235    * particles.
0236    */
0237   double x() const {
0238     if ( theX < 0.0 ) theX = exp(-l());
0239     return theX;
0240   }
0241 
0242 
0243   /**
0244    * Get the logarithmic momentum fraction of this parton w.r.t. the
0245    * collidig particles.
0246    */
0247   double l() const { return theL; }
0248 
0249   /**
0250    * Set the logarithmic momentum fraction of this parton w.r.t. the
0251    * collidig particles.
0252    */
0253   void l(double lx) {
0254     theL = lx;
0255     theX = -1.0;
0256   }
0257 
0258 
0259   /**
0260    * Get the scale at which the current parton was extracted.
0261    */
0262   Energy2 scale() const { return theScale; }
0263   
0264 
0265   /**
0266    * Set the scale at which the current parton was extracted.
0267    */
0268   void scale(Energy2 s) { theScale = s; }
0269 
0270   /**
0271    * Return the transverse momentum of the extracted parton.
0272    */
0273   const TransverseMomentum & kT() const { return theKT; }
0274 
0275   /**
0276    * Get the weight associated with the remnant generation.
0277    */
0278   double remnantWeight() const { return theRemnantWeight; }
0279 
0280   /**
0281    * Set the weight associated with the remnant generation.
0282    */
0283   void remnantWeight(double w) { theRemnantWeight = w; }
0284 
0285   /**
0286    * Get the current remnants.
0287    */
0288   const PVector & remnants() const { return theRemnants; }
0289 
0290   /**
0291    * Set the current remnants.
0292    */
0293   void remnants(const PVector & rems) { theRemnants = rems; }
0294 
0295   /**
0296    * Get information saved by the remnant handler from the generation,
0297    * to be used in the construction of the remnants. (In addition the
0298    * remnantWeight and remnants() may be used for this purpose.)
0299    */
0300   tRemIPtr remnantInfo() const { return theRemInfo; }
0301 
0302   /**
0303    * Set information saved by the remnant handler from the generation,
0304    * to be used in the construction of the remnants. (In addition the
0305    * remnantWeight and remnants() may be used for this purpose.)
0306    */
0307   void remnantInfo(tRemIPtr ri) { theRemInfo = ri; }
0308   //@}
0309 
0310 public:
0311 
0312   /** @name Functions used by the persistent I/O system. */
0313   //@{
0314   /**
0315    * Function used to write out object persistently.
0316    * @param os the persistent output stream written to.
0317    */
0318   void persistentOutput(PersistentOStream & os) const;
0319 
0320   /**
0321    * Function used to read in object persistently.
0322    * @param is the persistent input stream read from.
0323    * @param version the version number of the object when written.
0324    */
0325   void persistentInput(PersistentIStream & is, int version);
0326   //@}
0327 
0328   /**
0329    * Standard Init function used to initialize the interfaces.
0330    */
0331   static void Init();
0332 
0333 private:
0334 
0335   /**
0336    * Pointer to the main bin this instance refer to.
0337    */
0338   cPBPtr theBin;
0339 
0340   /**
0341    * Pointer to the main bin (and secondary in case several partons
0342    * have been extracted this instance refer to.
0343    */
0344   PartonVector theBins;
0345 
0346   /**
0347    * In the case the incoming particle in turn is extracted from
0348    * another particle, this is the PartonBinInstance for that
0349    * extraction.
0350    */
0351   PBIPtr theIncoming;
0352 
0353   /**
0354    * The jacobian associated with the phase space point generated.
0355    */
0356   double theJacobian;
0357 
0358   /**
0359    * The current particle instance.
0360    */
0361   PPtr theParticle;
0362 
0363   /**
0364    * The current parton instance.
0365    */
0366   PPtr theParton;
0367 
0368   /**
0369    * The currently extracted partons (in case of multiple
0370    * interactions.
0371    */
0372   PVector thePartons;
0373 
0374   /**
0375    * The momentum fraction (xi, li=log(xi), eps=1-xi), of this
0376    * parton w.r.t. the incoming particle in this
0377    * bin.
0378    */
0379   mutable double theXi;
0380   /**
0381    * The momentum fraction (xi, li=log(xi), eps=1-xi), of this
0382    * parton w.r.t. the incoming particle in this
0383    * bin.
0384    */
0385   mutable double theEps;
0386   /**
0387    * The momentum fraction (xi, li=log(xi), eps=1-xi), of this
0388    * parton w.r.t. the incoming particle in this
0389    * bin.
0390    */
0391   double theLi;
0392 
0393   /**
0394    * The momentum fraction (x, l=log(x)) of this parton
0395    * w.r.t. the collidig particles.
0396    */
0397   mutable double theX;
0398   /**
0399    * The momentum fraction (x, l=log(x)) of this parton
0400    * w.r.t. the collidig particles.
0401    */
0402   double theL;
0403 
0404   /**
0405    * The scale at which the current parton was extracted.
0406    */
0407   Energy2 theScale;
0408 
0409   /**
0410    * The transverse momentum of the extracted parton.
0411    */
0412   TransverseMomentum theKT;
0413 
0414   /**
0415    * The weight associated with the remnant generation.
0416    */
0417   double theRemnantWeight;
0418 
0419   /**
0420    * The current remnants.
0421    */
0422   PVector theRemnants;
0423 
0424   /**
0425    * The information saved by the remnant handler from the generation,
0426    * to be used in the construction of the remnants. (In addition the
0427    * remnantWeight and lastRemnants() may be used for this purpose.)
0428    */
0429   RemIPtr theRemInfo;
0430 
0431 private:
0432 
0433   /**
0434    * Describe a concrete class with persistent data.
0435    */
0436   static ClassDescription<PartonBinInstance> initPartonBinInstance;
0437 
0438   /**
0439    * Private and non-existent assignment operator.
0440    */
0441   PartonBinInstance & operator=(const PartonBinInstance &) = delete;
0442 
0443 };
0444 
0445 /** Empty base class. A RemnantHandler may use sub-classes to store
0446     information about the generation of remnants. */
0447 class RemInfoBase: public Base {
0448 public:
0449   /** The descructor. */
0450   virtual ~RemInfoBase() {}
0451 };
0452 
0453 }
0454 
0455 
0456 namespace ThePEG {
0457 
0458 /** @cond TRAITSPECIALIZATIONS */
0459 
0460 /** This template specialization informs ThePEG about the base classes
0461  *  of PartonBinInstance. */
0462 template <>
0463 struct BaseClassTrait<PartonBinInstance,1>: public ClassTraitsType {
0464   /** Typedef of the first base class of PartonBinInstance. */
0465   typedef Base NthBase;
0466 };
0467 
0468 /** This template specialization informs ThePEG about the name of the
0469  *  PartonBinInstance class. */
0470 template <>
0471 struct ClassTraits<PartonBinInstance>:
0472     public ClassTraitsBase<PartonBinInstance> {
0473   /** Return a platform-independent class name */
0474   static string className() { return "ThePEG::PartonBinInstance"; }
0475 };
0476 
0477 /** @endcond */
0478 
0479 }
0480 
0481 #endif /* THEPEG_PartonBinInstance_H */