StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vecTest3.cc
1 /***************************************************************************
2  *
3  * $Id: vecTest3.cc,v 1.2 2003/09/02 17:59:38 perev Exp $
4  *
5  * Author: Thomas Ullrich, Oct 1998
6  ***************************************************************************
7  *
8  * Description: Tests various features of StLorentzVector
9  *
10  ***************************************************************************
11  *
12  * $Log: vecTest3.cc,v $
13  * Revision 1.2 2003/09/02 17:59:38 perev
14  * gcc 3.2 updates + WarnOff
15  *
16  * Revision 1.1 1999/02/17 12:44:05 ullrich
17  * New Revision
18  *
19  * Revision 1.1 1999/01/23 00:26:56 ullrich
20  * Initial Revision
21  *
22  **************************************************************************/
23 #include <Stiostream.h>
24 #include <math.h>
25 #include "StGlobals.hh"
26 #include "StLorentzVector.hh"
27 #include "SystemOfUnits.h"
28 #include "PhysicalConstants.h"
29 #include "Randomize.h"
30 
31 int main()
32 {
33  HepJamesRandom engine;
34  RandFlat rflat(engine);
35 
36  //
37  // Generate 2-body decay: phi->e+e-
38  //
39  cout << "This programs generates a phi meson with random momentum px, py, pz" << endl;
40  cout << "and lets it decay into electrons. Their momenta are then calculated" << endl;
41  cout << "in the lab frame. Tests essentially StLorentzVector<>::boost()" << endl;
42 
43  //
44  // Create parent particle, here a phi(1020)
45  // with momentum random momenta 0-1 GeV/c
46  //
47  StThreeVector<double> p(rflat.shoot()*GeV, rflat.shoot()*GeV, rflat.shoot()*GeV);
48  StLorentzVector<double> parent(p, p.massHypothesis(1020*MeV));
49 
50  cout << "parent particle: " << endl;
51  cout << "\t4-momentum: " << parent << endl;
52  cout << "\tinvariant mass: " << abs(parent) << endl;
53 
54  //
55  // Let the phi decay into two electrons.
56  // The easiest way to do this is in the CM of the parent.
57  //
58  double mass1 = electron_mass_c2;
59  double mass2 = electron_mass_c2;
60  double massParent = abs(parent);
61  double E1 = (massParent*massParent + mass1*mass1 - mass2*mass2)/(2.*massParent);
62  double E2 = massParent - E1;
63  double p1 = ::sqrt((E1 + mass1)*(E1 - mass1));
64  double p2 = ::sqrt((massParent*massParent-(mass1+mass2)*(mass1+mass2))*
65  (massParent*massParent-(mass1-mass2)*(mass1-mass2)))/(2.*massParent);
66 
67  //
68  // Orientation in decaying particle rest frame
69  //
70  double costheta = 2*rflat.shoot() - 1;
71  double sintheta = ::sqrt((1 + costheta)*(1 - costheta));
72  double phi = 2*pi*rflat.shoot();
73 
74  //
75  // Create daughters
76  //
77  StThreeVector<double> momentum(p1*sintheta*cos(phi),
78  p1*sintheta*sin(phi),
79  p1*costheta);
80  StLorentzVector<double> daughter1(E1, momentum);
81  StLorentzVector<double> daughter2(E2, -momentum);
82 
83  cout << "decay particles in CM frame of parent: " << endl;
84  cout << "daughter1: " << endl;
85  cout << "\t4-momentum: " << daughter1 << endl;
86  cout << "\tinvariant mass: " << abs(daughter1) << endl;
87  cout << "daughter2: " << endl;
88  cout << "\t4-momentum: " << daughter2 << endl;
89  cout << "\tinvariant mass: " << abs(daughter2) << endl;
90 
91  //
92  // Boost secondary particles into the lab
93  //
94  daughter1 = daughter1.boost(parent);
95  daughter2 = daughter2.boost(parent);
96 
97  cout << "decay particles in lab frame: " << endl;
98  cout << "daughter1: " << endl;
99  cout << "\t4-momentum: " << daughter1 << endl;
100  cout << "\tinvariant mass: " << abs(daughter1) << endl;
101  cout << "daughter2: " << endl;
102  cout << "\t4-momentum: " << daughter2 << endl;
103  cout << "\tinvariant mass: " << abs(daughter2) << endl;
104 
105  //
106  // Cross-check: reconstruct parent from daughters
107  //
108  StLorentzVector<double> check = daughter1+daughter2;
109  cout << "cross-check: reconstructed parent" << endl;
110  cout << "\t4-momentum: " << check << endl;
111  cout << "\tinvariant mass: " << abs(check) << endl;
112 
113  return 0;
114 }