41 #include "RestFrames/RFPDF.hh"
43 namespace RestFrames {
47 template <
class T,
class Derived>
48 void RFListBase<T,Derived>::Clear(){
52 template <
class T,
class Derived>
53 T& RFListBase<T,Derived>::Get(
const RFKey& key)
const{
55 for(
int i = 0; i < N; i++)
56 if(m_Objs[i]->IsSame(key))
return *m_Objs[i];
61 template <
class T,
class Derived>
62 T& RFListBase<T,Derived>::Get(
int i)
const {
63 if(i < 0 || i >= GetN())
return T::Empty();
67 template <
class T,
class Derived>
68 bool RFListBase<T,Derived>::Add(T& obj){
69 if(!obj)
return false;
71 for(
int i = 0; i < N; i++)
72 if(m_Objs[i]->IsSame(obj))
return false;
73 m_Objs.push_back(&obj);
77 template <
class T,
class Derived>
78 int RFListBase<T,Derived>::Remove(
const T& obj){
80 for(
int i = 0; i < N; i++){
81 if(m_Objs[i]->IsSame(obj)){
82 m_Objs.erase(m_Objs.begin()+i);
89 template <
class T,
class Derived>
90 int RFListBase<T,Derived>::GetIndex(
const RFKey& key)
const {
92 for(
int i = 0; i < N; i++){
93 if(m_Objs[i]->IsSame(key))
return i;
98 template <
class T,
class Derived>
99 int RFListBase<T,Derived>::GetIndex(
const T& obj)
const {
101 for(
int i = 0; i < N; i++){
102 if(m_Objs[i]->IsSame(obj))
return i;
107 template <
class T,
class Derived>
108 T& RFListBase<T,Derived>::operator[](
int i)
const {
112 template <
class T,
class Derived>
113 bool RFListBase<T,Derived>::operator==(
const T& obj)
const {
114 if(GetN() != 1)
return false;
115 return obj == *m_Objs[0];
118 template <
class T,
class Derived>
119 bool RFListBase<T,Derived>::operator!=(
const T& obj)
const {
120 if(GetN() != 1)
return true;
121 return !(obj == *m_Objs[0]);
124 template <
class T,
class Derived>
125 Derived RFListBase<T,Derived>::operator+(T& obj)
const {
127 list.Add((Derived&)*
this);
132 template <
class T,
class Derived>
133 Derived RFListBase<T,Derived>::operator-(
const T& obj)
const {
135 list.Add((Derived&)*
this);
148 template <
class T,
class Derived>
149 Derived& RFListBase<T,Derived>::operator+=(T& obj){
151 return (Derived&)*
this;
160 template <
class T,
class Derived>
161 Derived& RFListBase<T,Derived>::operator-=(
const T& obj){
163 return (Derived&)*
this;
167 double RFList<RestFrame>::GetMass()
const {
168 int N = m_Objs.size();
169 TLorentzVector V(0.,0.,0.,0.);
170 for(
int i = 0; i < N; i++)
171 V += m_Objs[i]->GetFourVector();
175 TLorentzVector RFList<RestFrame>::GetFourVector()
const {
176 return GetFourVector(RestFrame::Empty());
179 TLorentzVector RFList<RestFrame>::GetFourVector(
const RestFrame& frame)
const {
180 int N = m_Objs.size();
181 TLorentzVector V(0.,0.,0.,0.);
182 for(
int i = 0; i < N; i++)
183 V += m_Objs[i]->GetFourVector(frame);
187 TLorentzVector RFList<RestFrame>::GetVisibleFourVector()
const {
188 return GetVisibleFourVector(RestFrame::Empty());
191 TLorentzVector RFList<RestFrame>::GetVisibleFourVector(
const RestFrame& frame)
const {
192 int N = m_Objs.size();
193 TLorentzVector V(0.,0.,0.,0.);
194 for(
int i = 0; i < N; i++)
195 V += m_Objs[i]->GetVisibleFourVector(frame);
199 TLorentzVector RFList<RestFrame>::GetInvisibleFourVector()
const {
200 return GetInvisibleFourVector(RestFrame::Empty());
203 TLorentzVector RFList<RestFrame>::GetInvisibleFourVector(
const RestFrame& frame)
const {
204 int N = m_Objs.size();
205 TLorentzVector V(0.,0.,0.,0.);
206 for(
int i = 0; i < N; i++)
207 V += m_Objs[i]->GetInvisibleFourVector(frame);
211 double RFList<RestFrame>::GetEnergy(
const RestFrame& frame)
const {
212 int N = m_Objs.size();
213 TLorentzVector V(0.,0.,0.,0.);
214 for(
int i = 0; i < N; i++)
215 V += m_Objs[i]->GetFourVector(frame);
219 double RFList<RestFrame>::GetMomentum(
const RestFrame& frame)
const {
220 int N = m_Objs.size();
221 TLorentzVector V(0.,0.,0.,0.);
222 for(
int i = 0; i < N; i++)
223 V += m_Objs[i]->GetFourVector(frame);
227 RFCharge RFList<RestFrame>::GetCharge()
const {
230 for(
int i = 0; i < N; i++)
231 charge += m_Objs[i]->GetCharge();
237 State& RFList<State>::GetFrame(
const RestFrame& frame)
const {
239 for(
int i = 0; i < N; i++)
240 if(m_Objs[i]->IsFrame(frame))
return *m_Objs[i];
242 return State::Empty();
245 TLorentzVector RFList<State>::GetFourVector()
const {
246 TLorentzVector V(0.,0.,0.,0.);
248 for(
int i = 0; i < N; i++)
249 V += m_Objs[i]->GetFourVector();
254 RFCharge RFList<State>::GetCharge()
const {
257 for(
int i = 0; i < N; i++)
258 charge += m_Objs[i]->GetCharge();
263 void RFList<State>::Boost(
const TVector3& B)
const {
268 for(
int i = 0; i < N; i++){
273 template class RFList<RFBase>;
275 template class RFList<const RestFrame>;
276 template class RFList<ReconstructionFrame>;
277 template class RFList<GeneratorFrame>;
278 template class RFList<VisibleRecoFrame>;
279 template class RFList<DecayRecoFrame>;
280 template class RFList<ResonanceGenFrame>;
281 template class RFList<Jigsaw>;
282 template class RFList<const Jigsaw>;
283 template class RFList<Group>;
284 template class RFList<const Group>;
286 template class RFList<VisibleState>;
287 template class RFList<InvisibleState>;
288 template class RFList<CombinatoricState>;
289 template class RFList<HistPlotVar>;
290 template class RFList<HistPlotCategory>;
291 template class RFList<const HistPlotCategory>;
292 template class RFList<RFDataVar>;
293 template class RFList<const RFDataVar>;
294 template class RFList<RFPDF>;
296 template class RFListBase<RFBase,RFList<RFBase> >;
297 template class RFListBase<RestFrame,RFList<RestFrame> >;
298 template class RFListBase<const RestFrame,RFList<const RestFrame> >;
299 template class RFListBase<ReconstructionFrame,RFList<ReconstructionFrame> >;
300 template class RFListBase<GeneratorFrame,RFList<GeneratorFrame> >;
301 template class RFListBase<VisibleRecoFrame,RFList<VisibleRecoFrame> >;
302 template class RFListBase<DecayRecoFrame,RFList<DecayRecoFrame> >;
303 template class RFListBase<ResonanceGenFrame,RFList<ResonanceGenFrame> >;
304 template class RFListBase<Jigsaw,RFList<Jigsaw> >;
305 template class RFListBase<const Jigsaw,RFList<const Jigsaw> >;
306 template class RFListBase<Group,RFList<Group> >;
307 template class RFListBase<const Group,RFList<const Group> >;
308 template class RFListBase<State,RFList<State> >;
309 template class RFListBase<VisibleState,RFList<VisibleState> >;
310 template class RFListBase<InvisibleState,RFList<InvisibleState> >;
311 template class RFListBase<CombinatoricState,RFList<CombinatoricState> >;
312 template class RFListBase<HistPlotVar,RFList<HistPlotVar> >;
313 template class RFListBase<HistPlotCategory,RFList<HistPlotCategory> >;
314 template class RFListBase<const HistPlotCategory,RFList<const HistPlotCategory> >;
315 template class RFListBase<RFDataVar,RFList<RFDataVar> >;
316 template class RFListBase<const RFDataVar,RFList<const RFDataVar> >;
317 template class RFListBase<RFPDF,RFList<RFPDF> >;