38 namespace RestFrames {
48 template <
class T,
class Derived>
63 for(
int i = 0; i < N; i++)
64 if(!Add((T&)objs[i])) ret =
false;
68 int Remove(
const T& obj);
73 for(
int i = 0; i < N; i++)
77 int GetN()
const {
return m_Objs.size(); }
81 T& Get(
const RFKey& key)
const;
83 int GetIndex(
const RFKey& key)
const;
85 int GetIndex(
const T& obj)
const;
88 bool Contains(
const U& obj)
const{
90 for(
int i = 0; i < N; i++)
91 if(*m_Objs[i] == obj)
return true;
96 bool Contains(
const RFList<U>& objs)
const {
98 for(
int i = 0; i < N; i++)
99 if(!Contains(objs[i]))
105 bool IsSame(
const RFList<U>& objs)
const {
106 return Union(objs).GetN() == Intersection(objs).GetN();
110 Derived Union(
const RFList<U>& objs)
const {
111 Derived objs_this =
static_cast<const Derived&
>(*this);
117 Derived Intersection(
const RFList<U>& objs)
const {
120 for(
int i = 0; i < N; i++)
121 if(Contains(objs[i])) inter.Add(objs[i]);
126 Derived Complement(
const RFList<U>& objs)
const {
127 Derived comp =
static_cast<Derived&
>(*this);
129 for(
int i = 0; i < N; i++)
130 if(comp.Contains(objs.Get(i)))
131 comp.Remove(objs.Get(i));
135 Derived& operator = (T& obj){
138 return static_cast<Derived&
>(*this);
142 Derived& operator = (
const RFList<U>& objs){
145 return static_cast<Derived&
>(*this);
148 T& operator [] (
int i)
const;
150 T& operator [] (
const RFKey& key)
const;
152 bool operator == (
const T& obj)
const;
155 bool operator == (
const RFList<U>& objs)
const {
159 bool operator != (
const T& obj)
const;
162 bool operator != (
const RFList<U>& objs)
const {
163 return !IsSame(objs);
166 Derived operator + (T& obj)
const;
169 Derived operator + (
const RFList<U>& objs)
const {
170 Derived list =
static_cast<const Derived&
>(*this);
175 Derived operator - (
const T& obj)
const;
178 Derived operator - (
const RFList<U>& objs)
const;
180 Derived& operator += (T& obj);
183 Derived& operator += (
const RFList<U>& objs){
185 return static_cast<Derived&
>(*this);
188 Derived& operator -= (
const T& obj);
191 Derived& operator -= (
const RFList<U>& objs){
193 return static_cast<Derived&
>(*this);
197 std::vector<T*> m_Objs;
210 RFList(
const RFList<U>& objs) : RFListBase<T,RFList<T> >() {
211 RFListBase<T,RFList<T> >::Add(objs);
214 virtual ~RFList() { }
223 :
public RFListBase<State,RFList<RestFrames::State> > {
235 TLorentzVector GetFourVector()
const;
237 void Boost(
const TVector3& B)
const;
242 :
public RFListBase<RestFrame,RFList<RestFrames::RestFrame> > {
253 double GetMass()
const;
255 TLorentzVector GetFourVector()
const;
256 TLorentzVector GetFourVector(
const RestFrame& frame)
const;
257 TLorentzVector GetVisibleFourVector()
const;
258 TLorentzVector GetVisibleFourVector(
const RestFrame& frame)
const;
259 TLorentzVector GetInvisibleFourVector()
const;
260 TLorentzVector GetInvisibleFourVector(
const RestFrame& frame)
const;
261 double GetEnergy(
const RestFrame& frame)
const;
262 double GetMomentum(
const RestFrame& frame)
const;
290 typedef std::vector<RestFrames::RFList<RestFrame> > RestFrameListList;
291 typedef std::vector<RestFrames::RFList<State> > StateListList;