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