Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-13 10:29:21

0001 #ifndef SHRIMPS_Main_Ladder_H
0002 #define SHRIMPS_Main_Ladder_H
0003 
0004 #include "ATOOLS/Phys/Blob.H"
0005 #include "ATOOLS/Phys/Particle.H"
0006 #include "ATOOLS/Math/Poincare.H"
0007 #include "ATOOLS/Math/Vector.H"
0008 #include "ATOOLS/Org/Message.H"
0009 #include <map>
0010 #include <list>
0011 
0012 namespace SHRIMPS {
0013   struct colour_type {
0014     enum code {
0015       none,
0016       singlet,
0017       triplet,
0018       octet
0019     };
0020   };
0021 
0022   std::ostream & operator<<(std::ostream & s, const colour_type::code & colour);
0023 
0024   struct Ladder_Particle {
0025     ATOOLS::Particle * p_part;
0026     ATOOLS::Flavour    m_flav;
0027     ATOOLS::Vec4D      m_mom, m_pos;
0028     ATOOLS::Flow       m_flow;
0029     bool               m_marked,m_beam,m_IS;
0030 
0031     Ladder_Particle() :
0032       p_part(NULL), m_flav(ATOOLS::Flavour(kf_none)), 
0033       m_mom(ATOOLS::Vec4D(0.,0.,0.,0.)), m_pos(ATOOLS::Vec4D(0.,0.,0.,0.)),
0034       m_marked(false),m_beam(false),m_IS(false)
0035     {}
0036 
0037     Ladder_Particle(const Ladder_Particle & part) :
0038       p_part(NULL), m_flav(part.m_flav), m_mom(part.m_mom), m_pos(part.m_pos),
0039       m_marked(part.m_marked),m_beam(part.m_beam),m_IS(part.m_IS)
0040     {}
0041 
0042     Ladder_Particle(const ATOOLS::Particle * part);
0043 
0044     Ladder_Particle(const ATOOLS::Flavour & flav,
0045             const ATOOLS::Vec4D & mom=ATOOLS::Vec4D(0.,0.,0.,0.),
0046             const ATOOLS::Vec4D & pos=ATOOLS::Vec4D(0.,0.,0.,0.)) :
0047       p_part(NULL), m_flav(flav), m_mom(mom), m_pos(pos),
0048       m_marked(false),m_beam(false),m_IS(false)
0049     {}
0050 
0051     ~Ladder_Particle() { }
0052 
0053     inline void SetFlow(const unsigned int & pos,const int & code=-1) {
0054       if(code==-1) m_flow.SetCode(pos);
0055       else m_flow.SetCode(pos,code);
0056       if (p_part) p_part->SetFlow(pos,code);
0057     }
0058     inline int GetFlow(const unsigned int & pos,const bool & test=true) const {
0059       unsigned int code(m_flow.Code(pos));
0060       if (test && p_part && p_part->GetFlow(pos)!=code) {
0061     msg_Error()<<"Error in "<<METHOD<<": "<<std::endl
0062            <<"   colours do not coincide "
0063            <<"("<<code<<" vs. "<<p_part->GetFlow(pos)<<") "
0064            <<"for pos = "<<pos<<"."<<std::endl;
0065     exit(1);
0066       }
0067       return code;
0068     }
0069 
0070     inline void BoostBack(const ATOOLS::Poincare & booster) {
0071       booster.BoostBack(m_mom);
0072     }
0073 
0074     inline void Boost(const ATOOLS::Poincare & booster) {
0075       booster.Boost(m_mom);
0076     }
0077 
0078     ATOOLS::Particle * GetParticle();
0079   };
0080   typedef std::map<double,Ladder_Particle,std::less_equal<double> > LadderMap;
0081   std::ostream & operator<<(std::ostream & s, const Ladder_Particle & part);
0082   std::ostream & operator<<(std::ostream & s, const LadderMap & lmap);
0083 
0084 
0085   struct T_Prop {
0086     T_Prop(const colour_type::code & col,
0087        const ATOOLS::Vec4D & q,const double & q02=0.) : 
0088       m_col(col), m_q(q), m_q2(ATOOLS::dabs(m_q.Abs2())), 
0089       m_qt2(m_q.PPerp2()), m_q02(q02) {}
0090     T_Prop(const colour_type::code & col) : 
0091       m_col(col), m_q(ATOOLS::Vec4D(0.,0.,0.,0.)), m_q2(0.), 
0092       m_qt2(0.), m_q02(0.) {}
0093     T_Prop(const ATOOLS::Vec4D & q,const double & q02=0.) : 
0094       m_col(colour_type::octet), m_q(q), m_q2(ATOOLS::dabs(m_q.Abs2())), 
0095       m_qt2(m_q.PPerp2()), m_q02(q02) {}
0096     colour_type::code m_col;
0097     ATOOLS::Vec4D     m_q;
0098     double            m_q2, m_qt2, m_q02;
0099   };
0100   typedef std::list<T_Prop> TPropList;
0101   std::ostream & operator<<(std::ostream & s, const T_Prop & tprop);
0102   std::ostream & operator<<(std::ostream & s, const TPropList & props);
0103 
0104   class Ladder {
0105   private:
0106     ATOOLS::Vec4D       m_position;
0107     double              m_weight, m_Y, m_Ymin, m_Ymax, m_deltaY;
0108     LadderMap           m_emissions;
0109     TPropList           m_tprops;
0110     bool                m_diffractive, m_rescatter, m_harddiffractive;
0111     double              m_maxkt2, m_minkt2, m_ktcut2;
0112     double              m_shat, m_that, m_uhat, m_mu2, m_Yhat, m_DeltaYhat;
0113     colour_type::code   m_propcol;
0114     Ladder_Particle   * p_inpart1, * p_inpart2, * p_part1, * p_part2;
0115     T_Prop            * p_hardestprop;    
0116     bool                m_enforceup;
0117 
0118     bool FixFirstColours(LadderMap::iterator & liter,
0119              int & col1,int & col2,const size_t & fix,
0120              TPropList::iterator & citer);
0121     bool FixIntermediateColours(LadderMap::iterator & liter,
0122                 int & col1,int & col2,size_t & fix,
0123                 TPropList::iterator & citer);
0124     bool FixLastColours(LadderMap::iterator & liter,
0125             const int & col1,const int & col2,const size_t & fix,
0126             TPropList::iterator & citer);
0127     bool MoreSinglets(const TPropList::iterator & citer);
0128     void UpdatePropagators();
0129   public:
0130     Ladder(const ATOOLS::Vec4D & position);
0131     ~Ladder();
0132     // Colour on the ladder
0133     bool GenerateColourIndices(size_t & fix);
0134     bool CanReplaceColour(const size_t & oldc,const size_t & newc,
0135               const size_t & pos,const bool & inclIS=true);
0136 
0137     // ME reweighting
0138     inline const double            & Shat()       const { return m_shat; }
0139     inline const double            & That()       const { return m_that; }
0140     inline const double            & Uhat()       const { return m_uhat; }
0141     inline const double            & Yhat()       const { return m_Yhat; }
0142     inline const double            & DeltaYhat()  const { return m_DeltaYhat; }
0143     inline const colour_type::code & Propcolour() const { return m_propcol; }
0144     const bool & IsHardDiffractive() const { return m_harddiffractive; } 
0145     bool ExtractHardest(); 
0146     bool ReconstructMEFlavours(ATOOLS::Flavour & i1,ATOOLS::Flavour & i2,
0147                    ATOOLS::Flavour & o1,ATOOLS::Flavour & o2);
0148     inline Ladder_Particle * GetMEFSParticle(const int & i) const {
0149       if (i==1) return p_part1;
0150       return p_part2;
0151     }
0152     inline void SetMEFSParticles(Ladder_Particle * part1,
0153                  Ladder_Particle * part2) {
0154       p_part1 = part1; p_part2 = part2;
0155     }
0156 
0157     // Simple service functions
0158     bool CheckFourMomentum();
0159     inline void ProdProps(double & kt2prod,int & Nprobs) {
0160       for (TPropList::iterator tit=m_tprops.begin();tit!=m_tprops.end();
0161        tit++) {
0162     kt2prod *= ATOOLS::Max(tit->m_qt2, tit->m_q02);
0163     Nprobs++;
0164       }
0165     }
0166 
0167     inline void Reset(const bool & all=true) { 
0168       m_emissions.clear(); 
0169       m_tprops.clear();
0170       m_diffractive = m_rescatter = m_harddiffractive = false;
0171       m_weight  = 1.;
0172       if (p_inpart1) { delete p_inpart1; p_inpart1 = NULL; }
0173       if (p_inpart2) { delete p_inpart2; p_inpart2 = NULL; }
0174     }
0175     inline void ResetFS() {
0176       m_emissions.clear(); 
0177       m_tprops.clear();
0178       m_maxkt2 = m_mu2 = 0.;
0179       m_diffractive = m_harddiffractive = false;
0180       m_weight = 1.;
0181 
0182     }
0183     // Global properties of ladders
0184     const double & Weight()        const { return m_weight; }
0185     const double & MaxKT2()        const { return m_maxkt2; }
0186     const double & MinKT2()        const { return m_minkt2; }
0187     const double & KtCut2()        const { return m_ktcut2; }
0188     const double & Mu2()           const { return m_mu2; }
0189     const double & Y()             const { return m_Y; }
0190     const bool   & IsDiffractive() const { return m_diffractive; } 
0191     const bool   & IsRescatter()   const { return m_rescatter; } 
0192     double MRKweight() const;
0193     inline Ladder_Particle * GetIn(const int & pos) {
0194       if (pos==0) return p_inpart1;
0195       return p_inpart2;
0196     }
0197     inline Ladder_Particle * GetIn1() const { return p_inpart1; }
0198     inline Ladder_Particle * GetIn2() const { return p_inpart2; }
0199     inline void GetInFlavours(ATOOLS::Flavour & flav1,
0200                   ATOOLS::Flavour & flav2) const {
0201       flav1 = p_inpart1->m_flav; flav2 = p_inpart2->m_flav;
0202     }
0203     inline void GetInFlows(ATOOLS::Flow & flow1,
0204                   ATOOLS::Flow & flow2) const {
0205       flow1 = p_inpart1->m_flow; flow2 = p_inpart2->m_flow;
0206     }
0207     inline const ATOOLS::Vec4D & Position() const { return m_position; }
0208     inline void SetWeight(const double & weight)  { m_weight = weight; }
0209     inline void SetMaxKT2(const double & maxkt2)  { 
0210       if (maxkt2>m_maxkt2) m_maxkt2 = maxkt2; 
0211     }
0212     inline void SetMinKT2(const double & minkt2)  { m_minkt2 = minkt2; }
0213     inline void SetKtCut2(const double & ktcut2)  { m_ktcut2 = ktcut2; }
0214     inline void SetMu2(const double & mu2)        { m_mu2    = mu2; }
0215     inline void SetDiffractive(const bool & diff) { m_diffractive = diff; }
0216     inline void SetRescatter(const bool & resc)   { m_rescatter = resc; }
0217 
0218     inline void SetInParticles(Ladder_Particle * part1,
0219                    Ladder_Particle * part2) {
0220       if (part1 && part2) {
0221     part1->m_IS= part2->m_IS = true;
0222     if (part1->m_mom.Y()<part2->m_mom.Y()) {
0223       p_inpart1 = part1; 
0224       p_inpart2 = part2;
0225     }
0226     else {
0227       p_inpart1 = part2; 
0228       p_inpart2 = part1;
0229     }
0230     p_inpart1->m_pos = m_position; 
0231     p_inpart2->m_pos = m_position;
0232       }
0233       else { 
0234     p_inpart1 = NULL; 
0235     p_inpart2 = NULL; 
0236       }
0237     }
0238 
0239     inline T_Prop * GetHardestProp()  { return p_hardestprop; }
0240     // Organizing the emissions and propagators
0241     bool SwapColourIndices();
0242     inline size_t Size()  const { return m_emissions.size(); }
0243     inline LadderMap * GetEmissions() { return &m_emissions; }
0244     inline TPropList * GetProps()     { return &m_tprops; }
0245     inline void MakeDiffractive() {
0246       if (IsDiffractive()) return;
0247       TPropList::iterator tit(m_tprops.begin()), softest(m_tprops.begin());
0248       while (tit!=m_tprops.end()) {
0249     if (ATOOLS::dabs(tit->m_q2)<ATOOLS::dabs(softest->m_q2)) softest=tit;
0250     tit++;
0251       }
0252       softest->m_col = colour_type::singlet;
0253       m_diffractive  = true;
0254     }
0255     inline void AddRapidity(const double & y) {
0256       Ladder_Particle part;
0257       m_emissions[y] = part;
0258       part.m_pos = m_position;
0259     }
0260     inline void DeleteRapidity(const double & y) {
0261       if (m_emissions.find(y)!=m_emissions.end()) m_emissions.erase(y);
0262     }
0263     inline void DeleteRapidity(LadderMap::iterator yiter) {
0264       if (yiter!=m_emissions.end()) m_emissions.erase(yiter);
0265     }
0266 
0267     inline void AddParticle(const double & y,Ladder_Particle part) {
0268       part.m_pos = m_position;
0269       m_emissions[y] = part;
0270     }
0271     inline void SetParticle(LadderMap::iterator yiter,
0272                 const Ladder_Particle part) {
0273       yiter->second = part;
0274     }
0275     LadderMap::iterator GetEmissionsBegin() { 
0276       return m_emissions.begin(); 
0277     }
0278     LadderMap::iterator GetEmissionsEnd() { 
0279       return m_emissions.end(); 
0280     }
0281     LadderMap::reverse_iterator GetEmissionsRBegin() { 
0282       return m_emissions.rbegin(); 
0283     }
0284     LadderMap::reverse_iterator GetEmissionsREnd() { 
0285       return m_emissions.rend(); 
0286     }
0287     TPropList::iterator GetPropsBegin() { 
0288       return m_tprops.begin(); 
0289     }
0290     TPropList::iterator GetPropsEnd() { 
0291       return m_tprops.end(); 
0292     }
0293     TPropList::reverse_iterator GetPropsRBegin() { 
0294       return m_tprops.rbegin(); 
0295     }
0296     TPropList::reverse_iterator GetPropsREnd() { 
0297       return m_tprops.rend(); 
0298     }
0299 
0300     friend std::ostream & operator<<(std::ostream & s, const Ladder &);
0301   };
0302 
0303   std::ostream & operator<<(std::ostream & s, const Ladder &);
0304 }
0305 #endif