Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Containers.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_Containers_H
0010 #define ThePEG_Containers_H
0011 
0012 /** \file
0013  * This file defines a number of containers. Some are just typedefs of
0014  * std containers, while others are wrappers around
0015  * std containers introduced in the hope of reducing the
0016  * amount of debugging and code duplication.
0017  *
0018  * Do not make changes in this file. If you need to modify any of the
0019  * standard containers used in ThePEG, edit a copy of this file and
0020  * include it in an alternative config file which can be included in
0021  * the main ThePEG.h config file
0022  * using the macro ThePEG_ALTERNATE_CONFIG.
0023  */
0024 
0025 #include "ThePEG/Utilities/UnitIO.h"
0026 
0027 namespace ThePEG {
0028 
0029 /** A set of pointers to ParticleData objects. */
0030 ThePEG_DECLARE_SET(PDPtr,ParticleDataSet);
0031 
0032 /** A vector of pointers to ParticleData objects. */
0033 typedef vector<PDPtr> PDVector;
0034 
0035 /** A vector of pointers to const ParticleData objects. */
0036 typedef vector<cPDPtr> cPDVector;
0037 
0038 /** A vector of transient pointers to ParticleData objects. */
0039 typedef vector<tPDPtr> tPDVector;
0040 
0041 /** A vector of transient pointers to const ParticleData objects. */
0042 typedef vector<tcPDPtr> tcPDVector;
0043 
0044 /** A set of pointers to MatcherBase objects. */
0045 ThePEG_DECLARE_SET(PMPtr,MatcherSet);
0046 
0047 /** A set of pointers to DecayMode objects */
0048 ThePEG_DECLARE_SET(DMPtr,DecayModeSet);
0049 
0050 /** A set of pointers to InterfacedBase objects */
0051 ThePEG_DECLARE_SET(IBPtr,ObjectSet);
0052 
0053 /** A set of pointers to InterfacedBase objects */
0054 ThePEG_DECLARE_SET(IBPtr,DependencySet);
0055 
0056 /** A map relating integers to ParticleData objects */
0057 ThePEG_DECLARE_MAP(long,PDPtr,ParticleMap);
0058 
0059 /** A map relating character strings to InterfacedBase objects */
0060 ThePEG_DECLARE_MAP(string,IBPtr,ObjectMap);
0061 
0062 /** A map relating InterfacedBase objects to corresponding
0063  * DependencySet containers */
0064 ThePEG_DECLARE_MAP(IBPtr,DependencySet,DependencyMap);
0065 
0066 /** A vector of pointers to InterfacedBase objects. */
0067 typedef vector<IBPtr> IVector;
0068 
0069 /** A vector of pointers to const InterfacedBase objects. */
0070 typedef vector<cIBPtr> CIVector;
0071 
0072 /** A vector of pointers to Particle objects. */
0073 typedef vector<PPtr> ParticleVector;
0074 
0075 /** A vector of pointers to Particle objects. */
0076 typedef vector<PPtr> PVector;
0077 
0078 /** A vector of pointers to const Particle objects. */
0079 typedef vector<cPPtr> cPVector;
0080 
0081 /** A vector of transient pointers to Particle objects. */
0082 typedef vector<tPPtr> tPVector;
0083 
0084 /** A vector of transient pointers to const Particle objects. */
0085 typedef vector<tcPPtr> tcPVector;
0086 
0087 /** A list of pointers to Particle objects. */
0088 typedef list<PPtr> ParticleList;
0089 
0090 /** A list of pointers to Particle objects. */
0091 typedef list<PPtr> PList;
0092 
0093 /** A list of pointers to const Particle objects. */
0094 typedef list<cPPtr> cPList;
0095 
0096 /** A list of transient pointers to Particle objects. */
0097 typedef list<tPPtr> tPList;
0098 
0099 /** A list of transient pointers to const Particle objects. */
0100 typedef list<tcPPtr> tcPList;
0101 
0102 /** A map relating character strings to bare pointers to InterfaceBase objects */
0103 ThePEG_DECLARE_MAP(string,const InterfaceBase *,InterfaceMap);
0104 
0105 /** A rebinder for InterfacedBase objects. */
0106 typedef Rebinder<InterfacedBase> TranslationMap;
0107 
0108 /** A map relating character strings to EventGenerator objects */
0109 ThePEG_DECLARE_MAP(string,EGPtr,GeneratorMap);
0110 
0111 /** A vector of pointers to AnalysisHandler objects. */
0112 typedef vector<AnaPtr> AnalysisVector;
0113 
0114 /** A pair of pointers to ParticleData objects. */
0115 typedef pair<PDPtr, PDPtr> PDPair;
0116 
0117 /** A pair of pointers to const ParticleData objects. */
0118 typedef pair<cPDPtr, cPDPtr> cPDPair;
0119 
0120 /** A pair of transient pointers to ParticleData objects. */
0121 typedef pair<tPDPtr, tPDPtr> tPDPair;
0122 
0123 /** A pair of transient pointers to const ParticleData objects. */
0124 typedef pair<tcPDPtr, tcPDPtr> tcPDPair;
0125 
0126 /** A pair of pointers to Particle objects. */
0127 typedef pair<PPtr, PPtr> PPair;
0128 
0129 /** A pair of pointers to const Particle objects. */
0130 typedef pair<cPPtr, cPPtr> cPPair;
0131 
0132 /** A pair of transient pointers to const Particle objects. */
0133 typedef pair<tPPtr, tPPtr> tPPair;
0134 
0135 /** A pair of transient pointers to const Particle objects. */
0136 typedef pair<tcPPtr, tcPPtr> tcPPair;
0137 
0138 /** An Interval in scale. */
0139 typedef Interval<Energy2> SInterval;
0140 
0141 /** A vector of intervals of scales. */
0142 typedef vector<SInterval> SIntervalVector;
0143 
0144 /** A vector of pairs of transient pointers to PartonBins. */
0145 typedef vector<tPDPair> tPartonPairVec;
0146 
0147 /** A pair of transient pointers to ColourLine objects. */
0148 typedef pair<tColinePtr,tColinePtr> tColinePair;
0149 
0150 /** A set of pointers to DecayMode objects. */
0151 ThePEG_DECLARE_SET(tDMPtr,DecaySet);
0152 
0153 /** A set oc character strings. */
0154 ThePEG_DECLARE_SET(string,StringSet);
0155 
0156 /** A vector of energies. */
0157 typedef vector<Energy> EnergyVector;
0158 
0159 /** A vector of pointers to EventInfoBase objects. */
0160 typedef vector<EIPtr> EIVector;
0161 
0162 /** A vector of doubles. */
0163 typedef vector<double> DVector;
0164 
0165 /** A pair of doubles. */
0166 typedef pair<double,double> DPair;
0167 
0168 /** @name Global shift operators to simplify adding and removing
0169  * objects to containers. */
0170 //@{
0171 /**
0172  * Overload the left shift operator for vector to push_back objects to
0173  * a vector.
0174  * @param tv the vector being filled by push_back.
0175  * @param u the object being pushed back.
0176  * @return a referens to the vector.
0177  */
0178 template <typename T, typename U>
0179 vector<T> & operator<<(vector<T> & tv, const U & u) {
0180   tv.push_back(u);
0181   return tv;
0182 }
0183 
0184 /**
0185  * Overload the right shift operator for vector to pop objects from
0186  * a vector.
0187  * @param tv the vector being popped by pop_back.
0188  * @param u the object at the back of the vector before popping.
0189  * @return a referens to the vector.
0190  */
0191 template <typename T, typename U>
0192 vector<T> & operator>>(vector<T> & tv, U & u) {
0193   u = tv.back();
0194   tv.pop_back();
0195   return tv;
0196 }
0197 
0198 /**
0199  * Overload the left shift operator for stack to push objects to
0200  * a vector.
0201  * @param ts the stack being filled by push.
0202  * @param u the object being pushed.
0203  * @return a referens to the stack.
0204  */
0205 template <typename T, typename U>
0206 stack<T> & operator<<(stack<T> & ts, const U & u) {
0207   ts.push(u);
0208   return ts;
0209 }
0210 
0211 /**
0212  * Overload the right shift operator for stack to pop objects from
0213  * a stack.
0214  * @param ts the stack being popped.
0215  * @param u the object at the top of the stack before popping.
0216  * @return a referens to the stack.
0217  */
0218 template <typename T, typename U>
0219 stack<T> & operator>>(stack<T> & ts, U & u) {
0220   u = ts.top();
0221   ts.pop();
0222   return ts;
0223 }
0224 
0225 /**
0226  * Overload the left shift operator for deque to push_back objects to
0227  * a deque.
0228  * @param td the deque being filled by push_back.
0229  * @param u the object being pushed back.
0230  * @return a referens to the deque.
0231  */
0232 template <typename T, typename U>
0233 deque<T> & operator<<(deque<T> & td, const U & u) {
0234   td.push_back(u);
0235   return td;
0236 }
0237 
0238 /**
0239  * Overload the right shift operator for vector to pop objects from
0240  * a deque.
0241  * @param td the deque being popped by pop_front.
0242  * @param u the object at the front of the deque before popping.
0243  * @return a referens to the deque.
0244  */
0245 template <typename T, typename U>
0246 deque<T> & operator>>(deque<T> & td, U & u) {
0247   u = td.front();
0248   td.pop_front();
0249   return td;
0250 }
0251 
0252 /**
0253  * Overload the left shift operator for std::set to insert objects in
0254  * a set.
0255  * @param ts the set being filled by insert.
0256  * @param u the object being inserted.
0257  * @return a referens to the set.
0258  */
0259 template <typename T, typename U>
0260 set<T> & operator<<(set<T> & ts, const U & u) {
0261   ts.insert(u);
0262   return ts;
0263 }
0264 //@}
0265 
0266 /** @name Functions for I/O of containers of objects with unit. */
0267 //@{
0268 /**
0269  * Ouput a vector of objects with the specified unit.
0270  * @param os the stream used for output.
0271  * @param v the vector to be output.
0272  * @param u the unit to be used.
0273  */
0274 template <typename OStream, typename T, typename Alloc, typename UT>
0275 void ounitstream(OStream & os, const vector<T,Alloc> & v, UT & u) {
0276   os << v.size();
0277   for ( typename vector<T,Alloc>::const_iterator i = v.begin();
0278     i != v.end(); ++i )
0279     os << ounit(*i, u);
0280 }
0281 
0282 /**
0283  * Input a vector of objects with the specified unit.
0284  * @param is the stream used for input.
0285  * @param v the vector to be input.
0286  * @param u the unit to be used.
0287  */
0288 template <typename IStream, typename T, typename Alloc, typename UT>
0289 void iunitstream(IStream & is, vector<T,Alloc> & v, UT & u) {
0290   typename vector<T,Alloc>::size_type l;
0291   is >> l;
0292   v.resize(l);
0293   for ( typename vector<T,Alloc>::iterator i = v.begin(); i != v.end(); ++i )
0294     is >> iunit(*i, u);
0295 }
0296 
0297 /**
0298  * Ouput a set of objects with the specified unit.
0299  * @param os the stream used for output.
0300  * @param s the set to be output.
0301  * @param u the unit to be used.
0302  */
0303 template <typename OStream, typename T, typename CMP, typename A, typename UT>
0304 void ounitstream(OStream & os, const set<T,CMP,A> & s, UT & u) {
0305   os << s.size();
0306   for ( typename set<T,CMP,A>::const_iterator i = s.begin(); i != s.end(); ++i )
0307     os << ounit(*i, u);
0308 }
0309 
0310 /**
0311  * Input a set of objects with the specified unit.
0312  * @param is the stream used for input.
0313  * @param s the set to be input.
0314  * @param u the unit to be used.
0315  */
0316 template <typename IStream, typename T, typename CMP, typename A, typename UT>
0317 void iunitstream(IStream & is, set<T,CMP,A> & s, UT & u) {
0318   s.clear();
0319   typename set<T,CMP,A>::size_type l;
0320   is >> l;
0321   T t;
0322   while ( l-- ) {
0323     is >> iunit(t, u);
0324     s.insert(t);
0325   }
0326 }
0327 
0328 /**
0329  * Ouput a map of keys and objects where the objects are output with
0330  * the specified unit.
0331  * @param os the stream used for output.
0332  * @param m the map to be output.
0333  * @param u the unit to be used for the mapped objects.
0334  */
0335 template <typename OStream, typename K, typename T,
0336           typename CMP, typename A, typename UT>
0337 void ounitstream(OStream & os, const map<K,T,CMP,A> & m, UT & u) {
0338   os << m.size();
0339   for ( typename map<K,T,CMP,A>::const_iterator i = m.begin();
0340     i != m.end(); ++i )
0341     os << i->first << ounit(i->second, u);
0342 }
0343 
0344 /**
0345  * Input a map of keys and objects where the objects are input with
0346  * the specified unit.
0347  * @param is the stream used for input.
0348  * @param m the map to be input.
0349  * @param u the unit to be used for the mapped objects.
0350  */
0351 template <typename IStream, typename K, typename T,
0352           typename CMP, typename A, typename UT>
0353 void iunitstream(IStream & is, map<K,T,CMP,A> & m, UT & u) {
0354   m.clear();
0355   typename map<K,T,CMP,A>::size_type l;
0356   is >> l;
0357   T t;
0358   K k;
0359   while ( l-- ) {
0360     is >> k >> iunit(t, u);
0361     m[k] = t;
0362   }
0363 }
0364 //@}
0365 
0366 }
0367 
0368 #endif /* ThePEG_Containers_H */