UParticle.cxx 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. #include <iostream>
  2. using namespace std;
  3. #include "TObject.h"
  4. #include "TParticle.h"
  5. #include "UParticle.h"
  6. //____________________________________________________________________
  7. //
  8. // UParticle
  9. //
  10. // Class for particle description.
  11. //
  12. //--------------------------------------------------------------------
  13. UParticle::UParticle()
  14. {
  15. // Default constructor
  16. fIndex = fPdg = fStatus = fParent = fParentDecay = fMate = fDecay = 0;
  17. fChild[0] = fChild[1] = 0;
  18. fPx = fPy = fPz = fE = 0.;
  19. fX = fY = fZ = fT = 0.;
  20. fWeight = 0.;
  21. }
  22. //--------------------------------------------------------------------
  23. //--------------------------------------------------------------------
  24. UParticle::UParticle(Int_t index, Int_t pdg, Int_t status,
  25. Int_t parent, Int_t parentDecay,
  26. Int_t mate, Int_t decay, Int_t child[2],
  27. Double_t px, Double_t py, Double_t pz, Double_t e,
  28. Double_t x, Double_t y, Double_t z, Double_t t,
  29. Double_t weight)
  30. {
  31. // Standard constructor
  32. fIndex = index;
  33. fPdg = pdg;
  34. fStatus = status;
  35. fParent = parent;
  36. fParentDecay = parentDecay;
  37. fMate = mate;
  38. fDecay = decay;
  39. fChild[0] = child[0];
  40. fChild[1] = child[1];
  41. fPx = px;
  42. fPy = py;
  43. fPz = pz;
  44. fE = e;
  45. fX = x;
  46. fY = y;
  47. fZ = z;
  48. fT = t;
  49. fWeight = weight;
  50. }
  51. //--------------------------------------------------------------------
  52. //--------------------------------------------------------------------
  53. UParticle::UParticle(Int_t index, Int_t pdg, Int_t status,
  54. Int_t parent, Int_t parentDecay,
  55. Int_t mate, Int_t decay, Int_t child[2],
  56. TLorentzVector mom, TLorentzVector pos,
  57. Double_t weight)
  58. {
  59. // Standard constructor
  60. fIndex = index;
  61. fPdg = pdg;
  62. fStatus = status;
  63. fParent = parent;
  64. fParentDecay = parentDecay;
  65. fMate = mate;
  66. fDecay = decay;
  67. fChild[0] = child[0];
  68. fChild[1] = child[1];
  69. fPx = mom.Px();
  70. fPy = mom.Py();
  71. fPz = mom.Pz();
  72. fE = mom.E();
  73. fX = pos.X();
  74. fY = pos.Y();
  75. fZ = pos.Z();
  76. fT = pos.T();
  77. fWeight = weight;
  78. }
  79. //--------------------------------------------------------------------
  80. //--------------------------------------------------------------------
  81. UParticle::UParticle(const UParticle& right)
  82. {
  83. // Copy constructor
  84. *this = right;
  85. }
  86. //--------------------------------------------------------------------
  87. //--------------------------------------------------------------------
  88. UParticle::UParticle(const TParticle &right)
  89. {
  90. // Copy constructor from the TParticle
  91. *this = right;
  92. }
  93. //--------------------------------------------------------------------
  94. //--------------------------------------------------------------------
  95. UParticle::~UParticle()
  96. {
  97. // Destructor
  98. }
  99. //--------------------------------------------------------------------
  100. //--------------------------------------------------------------------
  101. const UParticle& UParticle::operator = (const UParticle& right)
  102. {
  103. // Assignment operator
  104. fIndex = right.fIndex;
  105. fPdg = right.fPdg;
  106. fStatus = right.fStatus;
  107. fParent = right.fParent;
  108. fParentDecay = right.fParentDecay;
  109. fMate = right.fMate;
  110. fDecay = right.fDecay;
  111. fChild[0] = right.fChild[0];
  112. fChild[1] = right.fChild[1];
  113. fPx = right.fPx;
  114. fPy = right.fPy;
  115. fPz = right.fPz;
  116. fE = right.fE;
  117. fX = right.fX;
  118. fY = right.fY;
  119. fZ = right.fZ;
  120. fT = right.fT;
  121. fWeight = right.fWeight;
  122. return (*this);
  123. }
  124. //--------------------------------------------------------------------
  125. //--------------------------------------------------------------------
  126. const UParticle& UParticle::operator = (const TParticle &right)
  127. {
  128. // Assignment operator from the TParticle
  129. fIndex = 0;
  130. fPdg = right.GetPdgCode();
  131. fStatus = right.GetStatusCode();
  132. fParent = right.GetFirstMother();
  133. fParentDecay = 0;
  134. fMate = 0;
  135. fDecay = 0;
  136. fChild[0] = right.GetFirstDaughter();
  137. fChild[1] = right.GetLastDaughter();
  138. fPx = right.Px();
  139. fPy = right.Py();
  140. fPz = right.Pz();
  141. fE = right.Energy();
  142. fX = right.Vx();
  143. fY = right.Vy();
  144. fZ = right.Vz();
  145. fT = right.T();
  146. fWeight = right.GetWeight();
  147. return (*this);
  148. }
  149. //--------------------------------------------------------------------
  150. //--------------------------------------------------------------------
  151. const Bool_t UParticle::operator == (const UParticle& right) const
  152. {
  153. // If equal operator
  154. return (
  155. fIndex == right.fIndex &&
  156. fPdg == right.fPdg &&
  157. fStatus == right.fStatus &&
  158. fParent == right.fParent &&
  159. fParentDecay == right.fParentDecay &&
  160. fMate == right.fMate &&
  161. fDecay == right.fDecay &&
  162. fChild[0] == right.fChild[0] &&
  163. fChild[1] == right.fChild[1] &&
  164. ((TMath::Abs((fPx-right.fPx)/fPx)<0.0001) ||
  165. (TMath::Abs(fPx)<1e-16&&TMath::Abs(right.fPx)<1e-16)) &&
  166. ((TMath::Abs((fPy-right.fPy)/fPy)<0.0001) ||
  167. (TMath::Abs(fPy)<1e-16&&TMath::Abs(right.fPy)<1e-16)) &&
  168. ((TMath::Abs((fPz-right.fPz)/fPz)<0.0001) ||
  169. (TMath::Abs(fPz)<1e-16&&TMath::Abs(right.fPz)<1e-16)) &&
  170. ((TMath::Abs((fE-right.fE)/fE)<0.0001) ||
  171. (TMath::Abs(fE)<1e-16&&TMath::Abs(right.fE)<1e-16)) &&
  172. ((TMath::Abs((fX-right.fX)/fX)<0.0001) ||
  173. (TMath::Abs(fX)<1e-16&&TMath::Abs(right.fX)<1e-16)) &&
  174. ((TMath::Abs((fY-right.fY)/fY)<0.0001) ||
  175. (TMath::Abs(fY)<1e-16&&TMath::Abs(right.fY)<1e-16)) &&
  176. ((TMath::Abs((fZ-right.fZ)/fZ)<0.0001) ||
  177. (TMath::Abs(fZ)<1e-16&&TMath::Abs(right.fZ)<1e-16)) &&
  178. ((TMath::Abs((fT-right.fT)/fT)<0.0001) ||
  179. (TMath::Abs(fT)<1e-16&&TMath::Abs(right.fT)<1e-16)) &&
  180. ((TMath::Abs((fWeight-right.fWeight)/fWeight)<0.0001) ||
  181. (TMath::Abs(fWeight)<1e-16&&TMath::Abs(right.fWeight)<1e-16))
  182. );
  183. }
  184. //--------------------------------------------------------------------
  185. //--------------------------------------------------------------------
  186. void UParticle::Print(Option_t* option)
  187. {
  188. // Print the data members to the standard output
  189. cout << "------------------------------------------------" << endl
  190. << "-I- Particle -I-" << endl
  191. << "Index : " << fIndex << endl
  192. << "PDG code : " << fPdg << endl
  193. << "Status code : " << fStatus << endl
  194. << "Parent index : " << fParent << endl
  195. << "Parent decay index : " << fParentDecay << endl
  196. << "Last collision partner : " << fMate << endl
  197. << "Decay index : " << fDecay << endl
  198. << "First child index : " << fChild[0] << endl
  199. << "Last child index : " << fChild[1] << endl
  200. << "Momentum (px, py, pz) (GeV) : (" << fPx << ", " << fPy << ", " << fPz << ")" << endl
  201. << "Energy (GeV) : " << fE << endl
  202. << "Position (x, y, z) (fm) : (" << fX << ", " << fY << ", " << fZ << ")" << endl
  203. << "Creation time (fm) : " << fT << endl
  204. << "Weight : " << fWeight << endl
  205. << "------------------------------------------------" << endl;
  206. }
  207. //--------------------------------------------------------------------
  208. ClassImp(UParticle);