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