ROOTPWA
amplitude/particle.h
Go to the documentation of this file.
1 
2 //
3 // Copyright 2010
4 //
5 // This file is part of rootpwa
6 //
7 // rootpwa is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // rootpwa is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
19 //
21 //-------------------------------------------------------------------------
22 // File and Version Information:
23 // $Rev:: $: revision of last commit
24 // $Author:: $: author of last commit
25 // $Date:: $: date of last commit
26 //
27 // Description:
28 // container class for all particle related external information
29 //
30 //
31 // Author List:
32 // Boris Grube TUM (original author)
33 //
34 //
35 //-------------------------------------------------------------------------
36 
37 
38 #ifndef PARTICLE_H
39 #define PARTICLE_H
40 
41 
42 #include <string>
43 
44 #include <boost/shared_ptr.hpp>
45 
46 #include "TVector3.h"
47 #include "TLorentzVector.h"
48 #include "TLorentzRotation.h"
49 
50 #include "conversionUtils.hpp"
51 #include "particleProperties.h"
52 
53 
54 namespace rpwa {
55 
56  class particle;
57  typedef boost::shared_ptr<particle> particlePtr;
58 
59 
60  class particle : public particleProperties {
61 
62  public:
63 
64  particle();
65  particle(const particle& part);
66  particle(const particleProperties& partProp,
67  const int index = -1,
68  const int spinProj = 0,
69  const int refl = 0,
70  const TVector3& momentum = TVector3());
71  particle(const std::string& partName,
72  const bool requirePartInTable = true,
73  const int index = -1,
74  const int spinProj = 0,
75  const int refl = 0,
76  const TVector3& momentum = TVector3());
77  particle(const std::string& partName,
78  const int isospin,
79  const int G,
80  const int J,
81  const int P,
82  const int C,
83  const int spinProj,
84  const int refl = 0,
85  const int index = -1);
86  virtual ~particle();
87 
88  particle& operator =(const particle& part);
89  particlePtr clone() const { return particlePtr(doClone()); }
90 
91  int spinProj () const { return _spinProj; }
92  TVector3 momentum () const { return _lzVec.Vect(); }
93  const TLorentzVector& lzVec () const { return _lzVec; }
94  int index () const { return _index; }
95  int reflectivity() const { return _refl; }
96 
97  void setSpinProj (const int spinProj) { _spinProj = spinProj; }
98  void setMomentum (const TVector3& momentum) { _lzVec = TLorentzVector(momentum, sqrt(momentum.Mag2() + mass() * mass())); }
99  void setLzVec (const TLorentzVector& lzVec ) { _lzVec = lzVec; }
100  void setIndex (const int index ) { _index = index; }
101  void setReflectivity(const int refl ) { _refl = signum(refl); }
102 
103  void setProperties(const particleProperties& prop);
104 
105  const TLorentzVector& transform(const TLorentzRotation& L) { return _lzVec.Transform(L); }
106  const TLorentzVector& transform(const TVector3& boost)
107  {
108  _lzVec.Boost(boost);
109  return _lzVec;
110  }
111 
112  virtual std::string qnSummary() const;
113 
114  virtual std::ostream& print(std::ostream& out) const;
115 
116  virtual std::string label() const;
117 
118  static bool debug() { return _debug; }
119  static void setDebug(const bool debug = true) { _debug = debug; }
120 
121 
122  protected:
123 
124  virtual particle* doClone() const;
125 
126  virtual bool isEqualTo(const particleProperties& partProp) const;
127 
128  private:
129 
130  int _spinProj;
131  TLorentzVector _lzVec;
132  int _index;
133  int _refl;
134 
135  static bool _debug;
136 
137  };
138 
139 
140  inline
143  {
144  particlePtr partCopy(new particle(part));
145  return partCopy;
146  }
147 
148 
149  inline
152  const int index = -1,
153  const int spinProj = 0,
154  const int refl = 0,
155  const TVector3& momentum = TVector3())
156  {
157  particlePtr part(new particle(partProp, index, spinProj, refl, momentum));
158  return part;
159  }
160 
161 
162  inline
164  createParticle(const std::string& partName,
165  const bool requirePartInTable = true,
166  const int index = -1,
167  const int spinProj = 0,
168  const int refl = 0,
169  const TVector3& momentum = TVector3())
170  {
171  particlePtr part(new particle(partName, requirePartInTable, index, spinProj, refl, momentum));
172  return part;
173  }
174 
175 
176  inline
178  createParticle(const std::string& partName,
179  const int isospin,
180  const int G,
181  const int J,
182  const int P,
183  const int C,
184  const int spinProj,
185  const int refl = 0,
186  const int index = -1)
187  {
188  particlePtr part(new particle(partName, isospin, G, J, P, C, spinProj, refl, index));
189  return part;
190  }
191 
192 
193  // predicate for ascending sort
194  inline
195  bool
197  const particlePtr& b)
198  {
199  if (not a or not b) {
200  printWarn << "null pointer to particle. result undefined." << std::endl;
201  return false;
202  }
203  return a->index() < b->index();
204  }
205 
206 
207  // predicate for descending sort
208  inline
209  bool
211  const particlePtr& b)
212  {
213  if (not a or not b) {
214  printWarn << "null pointer to particle. result undefined." << std::endl;
215  return false;
216  }
217  return a->index() > b->index();
218  }
219 
220 
221  inline
222  std::ostream&
223  operator <<(std::ostream& out,
224  const particle& part)
225  {
226  return part.print(out);
227  }
228 
229 
230 } // namespace rpwa
231 
232 
233 #endif // PARTICLE_H