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