|
|
|||
File indexing completed on 2026-08-06 09:38:21
0001 // -*- C++ -*- 0002 // 0003 // Event.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_Event_H 0010 #define ThePEG_Event_H 0011 // This is the decalaration of the Event class. 0012 0013 #include "Particle.h" 0014 #include "StandardSelectors.h" 0015 #include "SubProcess.h" 0016 #include "ThePEG/Utilities/Named.h" 0017 #include "ThePEG/Utilities/AnyReference.h" 0018 0019 namespace ThePEG { 0020 0021 /** 0022 * The Event class contains all Particles produced in the generation 0023 * of an event. The particles are divided into Collisions 0024 * corresponding to the actiual collisions between incoming particles 0025 * in a bunch crossing. 0026 * 0027 * Event inherits from the Named which holds the name of an event. 0028 * 0029 * @see Collision 0030 * @see Step 0031 * @see SubProcess 0032 * @see Particle 0033 * @see SelectorBase 0034 * @see Named 0035 * 0036 */ 0037 class Event : public EventRecordBase, public Named { 0038 0039 public: 0040 0041 /** 0042 * EventHandler is a friend of most Event classes. 0043 */ 0044 friend class EventHandler; 0045 /** Most of the Event classes are friends with each other. */ 0046 friend class Collision; 0047 0048 /** Map colour lines to indices. */ 0049 typedef map<tcColinePtr, int> ColourLineMap; 0050 0051 public: 0052 0053 /** 0054 * The standard constructor for an Event takes as arguments a pair 0055 * of colliding particles (corresponding to the primary collision in 0056 * case of multiple collisions in an event). Optionally a pointer to 0057 * the EventHandler which performed the generation, an event name 0058 * and event number can be given. 0059 * @param newIncoming a pair of incoming particles to the prinary Collision. 0060 * @param newHandler the handler object in charge of the generation 0061 * of this Event. 0062 * @param newName the name of this event. 0063 * @param newNumber the number of this event. 0064 * @param weight the weight of this event 0065 */ 0066 Event(const PPair & newIncoming, tcEventBasePtr newHandler = tcEventBasePtr(), 0067 string newName = "", long newNumber = -1, double weight = 1.0); 0068 0069 /** 0070 * The copy constructor. 0071 */ 0072 Event(const Event&); 0073 0074 /** 0075 * The destructor. 0076 */ 0077 ~Event(); 0078 0079 /** 0080 * Returns a full clone of this Event. All collisions, 0081 * <code>Particle</code>s etc. in this Event are cloned. 0082 */ 0083 EventPtr clone() const; 0084 0085 public: 0086 0087 /** 0088 * Return a pointer to the EventHandler which produced this 0089 * Event. May be the null pointer. 0090 */ 0091 tcEventBasePtr handler() const { return theHandler; } 0092 0093 /** @name Functions for accessing particles etc. */ 0094 //@{ 0095 /** 0096 * Extract particles from this event which satisfies the 0097 * requirements given by an object of the SelectorBase class. 0098 * @param r an output iterator specifying where the extracted 0099 * (pointers to) particles will be appended. 0100 * @param s SelectorBase object defining which particles should be 0101 * extracted. 0102 */ 0103 template <class OutputIterator> 0104 void select(OutputIterator r, const SelectorBase & s) const; 0105 0106 /** 0107 * Extract all final state particles in this Event. 0108 * @param r an output iterator specifying where the extracted 0109 * (pointers to) particles will be appended. 0110 */ 0111 template <class OutputIterator> 0112 void selectFinalState(OutputIterator r) const { 0113 select(r, SelectFinalState()); 0114 } 0115 0116 /** 0117 * Extract all final state particles in this Event. 0118 * @param c a container where the extracted (pointers to) particles 0119 * will be appended. 0120 */ 0121 template <class Container> 0122 void getFinalState(Container & c) const { 0123 selectFinalState(inserter(c)); 0124 } 0125 0126 /** 0127 * Extract all final state particles in this Event. 0128 * @return a vector of pointers to the extracted particles. 0129 */ 0130 tPVector getFinalState() const { 0131 tPVector ret; 0132 selectFinalState(back_inserter(ret)); 0133 return ret; 0134 } 0135 0136 /** 0137 * Return a pointer to the primary Collision in this Event. May 0138 * be the null pointer. 0139 */ 0140 tCollPtr primaryCollision() const { 0141 return collisions().empty() ? tCollPtr() : tCollPtr(collisions()[0]); 0142 } 0143 0144 /** 0145 * Return a possibly empty list of collisions in this Event. 0146 */ 0147 const CollisionVector & collisions() const { return theCollisions; } 0148 0149 /** 0150 * Return a pointer to the primary SubProcess in the prinmary 0151 * Collision in this Event. May be the null pointer. 0152 */ 0153 tSubProPtr primarySubProcess() const; 0154 0155 /** 0156 * Return a reference to the pair of colliding particles in the 0157 * primary Collision of this Event. 0158 */ 0159 const PPair & incoming() const { return theIncoming; } 0160 0161 //@} 0162 0163 /** 0164 * Create a new Collision in this event and return a pointer to it. 0165 */ 0166 tCollPtr newCollision(); 0167 0168 /** 0169 * Create a new Step in the current Collision, which is a copy of 0170 * the last Step (if any) and return a pointer to it. If no 0171 * collision exists, one will be added. 0172 */ 0173 tStepPtr newStep(); 0174 0175 /** 0176 * Transform all particles in this Event. 0177 */ 0178 void transform(const LorentzRotation &); 0179 0180 /** 0181 * Return the number assigned to this Event. The name is accessed 0182 * with the name() method of the Named base class. 0183 */ 0184 long number() const { return theNumber; } 0185 0186 /** 0187 * Return the index of the given colour line. 0188 */ 0189 int colourLineIndex(tcColinePtr) const; 0190 0191 /** @name Functions for removing entires from an Event. */ 0192 //@{ 0193 /** 0194 * Remove (recursively) the decay products from a given Particle and 0195 * add the particle to the list of final state particles. 0196 */ 0197 void removeDecay(tPPtr); 0198 0199 /** 0200 * Remove the given Particle from the Collision. If this was the 0201 * last daughter of the mother Particle, the latter is added to the 0202 * list of final state particles. 0203 */ 0204 void removeParticle(tPPtr); 0205 0206 /** 0207 * Remove all steps which have no new particles introduced in them. 0208 */ 0209 void cleanSteps(); 0210 0211 //@} 0212 0213 /** 0214 * Return the weight associated with this event. 0215 */ 0216 double weight() const { return theWeight; } 0217 0218 /** 0219 * Return an optional named weight associated to this event. Returns 0220 * 0, if no weight identified by this name is present. 0221 */ 0222 double optionalWeight(const string& name) const; 0223 0224 /** 0225 * Return the optional named weights associated to this event. 0226 */ 0227 const map<string,double>& optionalWeights() const { return theOptionalWeights; } 0228 0229 /** 0230 * Print this Event in Graphviz format on the standard output. 0231 */ 0232 void printGraphviz() const; 0233 0234 /** 0235 * Set the weight associated with this event. 0236 */ 0237 void weight(double w) { theWeight = w; } 0238 0239 /** 0240 * Set an optional named weight associated to this event. 0241 */ 0242 void optionalWeight(const string& name, double value); 0243 0244 /** 0245 * Access the optional named weights associated to this event. 0246 */ 0247 map<string,double>& optionalWeights() { return theOptionalWeights; } 0248 0249 /** 0250 * Set event info. 0251 */ 0252 void setInfo(tcEventBasePtr newHandler, string newName, 0253 long newNumber, double weight); 0254 0255 /** 0256 * Add a collision to this Event. 0257 */ 0258 void addCollision(tCollPtr c); 0259 0260 /** 0261 * Set the primary collision in this Event. 0262 */ 0263 void primaryCollision(tCollPtr c); 0264 0265 public: 0266 0267 /** 0268 * Check for meta information 0269 */ 0270 bool hasMeta(const string& id) const { 0271 return theMeta.find(id) != theMeta.end(); 0272 } 0273 0274 /** 0275 * Set meta information. 0276 */ 0277 template<class T> 0278 void meta(const string& id, T& ref) { 0279 theMeta[id] = AnyReference(ref); 0280 } 0281 0282 /** 0283 * Erase meta information. 0284 */ 0285 void eraseMeta(const string& id) { 0286 theMeta.erase(id); 0287 } 0288 0289 /** 0290 * Retrieve meta information. 0291 */ 0292 template<class T> 0293 T& meta(const string& id) const { 0294 return theMeta.find(id)->second.cast<T>(); 0295 } 0296 0297 protected: 0298 0299 /** 0300 * Add a range of particles to this Collision. 0301 */ 0302 template <class Iterator> 0303 void addParticles(Iterator first, Iterator last) { 0304 while ( first != last ) addParticle(*first++); 0305 } 0306 0307 /** 0308 * Add a particle to this Collision. 0309 */ 0310 void addParticle(tPPtr p); 0311 0312 /** 0313 * Add a new SubProcess to this Event. For book keeping purposes 0314 * only. The sub-processes are accessed from the different 0315 * Collisions in this Event. 0316 */ 0317 void addSubProcess(tSubProPtr p) { 0318 if ( p ) allSubProcesses.insert(p); 0319 } 0320 0321 /** 0322 * Remove a SubProcess from this Event. 0323 */ 0324 void removeSubProcess(tSubProPtr p) { allSubProcesses.erase(p); } 0325 0326 /** 0327 * Add a new Step to this Collision. For book keeping purposes 0328 * only. The steps are accessed from the different Collisions in 0329 * this Event. 0330 */ 0331 void addStep(tStepPtr s) { 0332 if ( s ) allSteps.insert(s); 0333 } 0334 0335 /** 0336 * Remove a given Particle entry. 0337 */ 0338 void removeEntry(tPPtr p); 0339 0340 /** 0341 * Rebind to cloned objects. When an Event is cloned, a shallow 0342 * copy is done first, then all <code>Particle</code>s etc, are 0343 * cloned, and finally this method is used to see to that the 0344 * pointers in the cloned Event points to the cloned 0345 * <code>Particle</code>s etc. 0346 */ 0347 void rebind(const EventTranslationMap & trans); 0348 0349 public: 0350 0351 /** 0352 * Standard function for writing to a persistent stream. 0353 */ 0354 void persistentOutput(PersistentOStream &) const; 0355 0356 /** 0357 * Standard functions for reading from a persistent stream. 0358 */ 0359 void persistentInput(PersistentIStream &, int); 0360 0361 /** 0362 * Standard Init function. @see Base::Init(). 0363 */ 0364 static void Init(); 0365 0366 private: 0367 0368 /** 0369 * The pair of colliding particles. 0370 */ 0371 PPair theIncoming; 0372 0373 /** 0374 * A vector of collisions in this Event. 0375 */ 0376 CollisionVector theCollisions; 0377 0378 /** 0379 * A set of all particles in this Event. 0380 */ 0381 StepSet allSteps; 0382 0383 /** 0384 * A set of all sub-processes in this Event. 0385 */ 0386 SubProcessSet allSubProcesses; 0387 0388 /** 0389 * A set of all particles in this Event. 0390 */ 0391 ParticleSet allParticles; 0392 0393 /** 0394 * A pointer to the EventHandler which performed the generation 0395 * of this Event. 0396 */ 0397 tcEventBasePtr theHandler; 0398 0399 /** 0400 * Map of all registered colour lines to their index numbers. 0401 */ 0402 mutable ColourLineMap theColourLines; 0403 0404 /** 0405 * The number assigned to this Event. 0406 */ 0407 long theNumber; 0408 0409 /** 0410 * The weight associated with this event. 0411 */ 0412 double theWeight; 0413 0414 /** 0415 * Optional named weights 0416 */ 0417 map<string,double> theOptionalWeights; 0418 0419 /** 0420 * Counter to keep track of particle numbering. 0421 */ 0422 long theParticleNumber; 0423 0424 /** 0425 * The meta information 0426 */ 0427 map<string,AnyReference> theMeta; 0428 0429 public: 0430 0431 /** 0432 * Print out debugging information for this object on std::cerr. To 0433 * be called from within a debugger via the debug() function. 0434 */ 0435 virtual void debugme() const; 0436 0437 private: 0438 0439 /** 0440 * Describe concrete class with persistent data. 0441 */ 0442 static ClassDescription<Event> initEvent; 0443 0444 /** 0445 * Private default constructor must only be used by the 0446 * PersistentIStream class via the ClassTraits<Event> class . 0447 */ 0448 Event() : theNumber(-1), theWeight(1.0), theParticleNumber(0) {} 0449 0450 /** 0451 * The ClassTraits<Event> class must be a friend to be able to 0452 * use the private default constructor. 0453 */ 0454 friend struct ClassTraits<Event>; 0455 0456 /** 0457 * The assignment operator is private and not implemented. 0458 */ 0459 Event & operator=(const Event&) = delete; 0460 0461 }; 0462 0463 /** Output a Event to a standard ostream. */ 0464 ostream & operator<<(ostream &, const Event &); 0465 0466 /** Print event tree in Graphviz format, ready for plotting. */ 0467 void printGraphviz(ostream &, tcEventPtr); 0468 0469 /** @cond TRAITSPECIALIZATIONS */ 0470 0471 /** This template specialization informs ThePEG about the 0472 * base class of Event. */ 0473 template <> 0474 struct BaseClassTrait<Event,1>: public ClassTraitsType { 0475 /** Typedef of the first base class of Collision. */ 0476 typedef EventRecordBase NthBase; 0477 }; 0478 0479 /** This template specialization informs ThePEG about the name of 0480 * the Event class and how to create it. */ 0481 template <> 0482 struct ClassTraits<Event>: public ClassTraitsBase<Event> { 0483 /** Return a platform-independent class name */ 0484 static string className() { return "ThePEG::Event"; } 0485 /** Create a Event object. */ 0486 static TPtr create() { return TPtr::Create(Event()); } 0487 }; 0488 0489 /** @endcond */ 0490 0491 } 0492 0493 #include "Collision.h" 0494 0495 inline ThePEG::tSubProPtr ThePEG::Event::primarySubProcess() const { 0496 return collisions().empty() ? ThePEG::tSubProPtr() : 0497 ThePEG::tSubProPtr(primaryCollision()->primarySubProcess()); 0498 } 0499 0500 namespace ThePEG { 0501 template <class OutputIterator> 0502 void Event::select(OutputIterator r, const SelectorBase & s) const { 0503 if ( s.allCollisions() ) { 0504 for ( CollisionVector::const_iterator it = theCollisions.begin(); 0505 it != theCollisions.end(); ++it ) (**it).select(r, s); 0506 } else { 0507 primaryCollision()->select(r, s); 0508 } 0509 } 0510 } 0511 0512 #endif /* ThePEG_Event_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|