Projection.hh
Go to the documentation of this file.
00001 // -*- C++ -*- 00002 #ifndef RIVET_Projection_HH 00003 #define RIVET_Projection_HH 00004 00005 #include "Rivet/Rivet.hh" 00006 #include "Rivet/Projection.fhh" 00007 #include "Rivet/ProjectionApplier.hh" 00008 #include "Rivet/ProjectionHandler.hh" 00009 #include "Rivet/ParticleName.hh" 00010 #include "Rivet/Tools/Logging.hh" 00011 #include "Rivet/Tools/ParticleUtils.hh" 00012 00013 namespace Rivet { 00014 00015 00016 // Forward declaration 00017 class Event; 00018 00019 00020 /// @brief Base class for all Rivet projections. 00021 /// 00022 /// Projection is the base class of all Projections to be used by 00023 /// Rivet. A Projection object can be assigned to an Event object and 00024 /// will then define a processed part of the information available in 00025 /// the Event, which then can be used by other Projection objects 00026 /// and/or Analysis objects. 00027 /// 00028 /// The main virtual functions to be overridden by concrete sub-classes 00029 /// are project(const Event &) and compare(const Projection &). 00030 class Projection : public ProjectionApplier { 00031 public: 00032 00033 /// Event is a friend. 00034 friend class Event; 00035 00036 /// The Cmp specialization for Projection is a friend. 00037 friend class Cmp<Projection>; 00038 00039 public: 00040 00041 /// @name Standard constructors and destructors. 00042 //@{ 00043 /// The default constructor. 00044 Projection(); 00045 00046 /// Clone on the heap. 00047 virtual const Projection* clone() const = 0; 00048 00049 /// The destructor. 00050 virtual ~Projection(); 00051 //@} 00052 00053 00054 public: 00055 00056 /// Take the information available in the Event and make the 00057 /// calculations necessary to obtain the projection. Note that this 00058 /// function must never be called except inside the 00059 /// Event::applyProjection(Projection *) function. 00060 virtual void project(const Event& e) = 0; 00061 00062 00063 protected: 00064 00065 /// This function is used to define a unique ordering between 00066 /// different Projection objects of the same class. If this is 00067 /// considered to be equivalent to the Projector object, \a p, in the 00068 /// argument the function should return 0. If this object should be 00069 /// ordered before \a p a negative value should be returned, 00070 /// otherwise a positive value should be returned. This function must 00071 /// never be called explicitly, but should only be called from the 00072 /// operator<(const Projection &). When implementing the function in 00073 /// concrete sub-classes, it is then guaranteed that the Projection 00074 /// object \a p in the argument is of the same class as the sub-class 00075 /// and can be safely dynamically casted to that class. 00076 /// 00077 /// When implementing this function in a sub-class, the immediate 00078 /// base class version of the function should be called first. If the 00079 /// base class function returns a non-zero value, that value should 00080 /// be returned immediately. Only if zero is returned should this 00081 /// function check the member variables of the sub-class to determine 00082 /// whether this should be ordered before or after \a p, or if it is 00083 /// equivalent with \a p. 00084 virtual int compare(const Projection& p) const = 0; 00085 00086 public: 00087 00088 /// Determine whether this object should be ordered before the object 00089 /// \a p given as argument. If \a p is of a different class than 00090 /// this, the before() function of the corresponding type_info 00091 /// objects is used. Otherwise, if the objects are of the same class, 00092 /// the virtual compare(const Projection &) will be returned. 00093 bool before(const Projection& p) const; 00094 00095 /// Return the allowed beam pairs on which this projection can operate, not 00096 /// including recursion. Derived classes should ensure that all contained 00097 /// projections are registered in the @a _projections set for the beam 00098 /// constraint chaining to work. 00099 /// @todo Remove the beam constraints system from projections. 00100 virtual const std::set<PdgIdPair> beamPairs() const; 00101 00102 /// Get the name of the projection. 00103 virtual std::string name() const { 00104 return _name; 00105 } 00106 00107 00108 /// Add a colliding beam pair. 00109 Projection& addPdgIdPair(PdgId beam1, PdgId beam2) { 00110 _beamPairs.insert(PdgIdPair(beam1, beam2)); 00111 return *this; 00112 } 00113 00114 00115 /// Get a Log object based on the getName() property of the calling projection object. 00116 Log& getLog() const { 00117 string logname = "Rivet.Projection." + name(); 00118 return Log::getLog(logname); 00119 } 00120 00121 /// Used by derived classes to set their name. 00122 void setName(const std::string& name) { 00123 _name = name; 00124 } 00125 00126 protected: 00127 00128 /// Shortcut to make a named Cmp<Projection> comparison with the @c *this 00129 /// object automatically passed as one of the parent projections. 00130 Cmp<Projection> mkNamedPCmp(const Projection& otherparent, const std::string& pname) const; 00131 00132 00133 /// Shortcut to make a named Cmp<Projection> comparison with the @c *this 00134 /// object automatically passed as one of the parent projections. 00135 Cmp<Projection> mkPCmp(const Projection& otherparent, const std::string& pname) const; 00136 00137 00138 private: 00139 00140 /// Name variable is used by the base class messages to identify 00141 /// which derived class is being handled. 00142 string _name; 00143 00144 /// Beam-type constraint. 00145 set<PdgIdPair> _beamPairs; 00146 00147 }; 00148 00149 00150 } 00151 00152 00153 /// Define "less" operator for Projection* containers in terms of the Projection::before virtual method. 00154 inline bool std::less<const Rivet::Projection *>::operator()(const Rivet::Projection* x, 00155 const Rivet::Projection* y) const { 00156 return x->before(*y); 00157 } 00158 00159 00160 // Definition of the comparison objects and functions 00161 #include "Rivet/Cmp.hh" 00162 00163 00164 #endif Generated on Thu Feb 6 2014 17:38:46 for The Rivet MC analysis system by ![]() |