Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DTrackingResolution.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DTrackingResolution.cc
4 // Created: Mon Feb 25 15:06:17 EST 2008
5 // Creator: davidl (on Darwin fwing-dhcp13.jlab.org 8.11.1 i386)
6 //
7 
8 #include <cmath>
9 #include <iostream>
10 using namespace std;
11 
12 #include "DTrackingResolution.h"
13 
14 
15 //---------------------------------
16 // DTrackingResolution (Constructor)
17 //---------------------------------
19 {
20 
21 }
22 
23 //---------------------------------
24 // ~DTrackingResolution (Destructor)
25 //---------------------------------
27 {
28 
29 }
30 
31 //----------------
32 // Smear
33 //----------------
34 bool DTrackingResolution::Smear(int geanttype, TVector3 &mom)
35 {
36  /// Smear the momentum vector of a charged particle
37  /// based on reolutions obtained from the GetResolution
38  /// method.
39  ///
40  /// The value of geanttype should specify the particle
41  /// type using the GEANT particle ids.
42  ///
43  /// The units of mom should be GeV/c
44 
45  // Efficiency should be based on input values. Calculate that
46  // now before they are smeared.
47  bool is_reconstructed = Efficiency(geanttype, mom);
48 
49  // Get resolutions
50  double pt_res, theta_res, phi_res;
51  GetResolution(geanttype, mom, pt_res, theta_res, phi_res);
52 
53  // Calculate new values. For each, we make a check that it is
54  // still in a valid range (e.g. theta is not less than 0).
55  // In reality, the probablity functions near these hard limits
56  // would not be gaussian in shape and so should be handled
57  // quite differently.
58  double pt_new=-1.0, theta_new=-1.0, phi_new=-1.0;
59 
60  while(pt_new<=0.0) pt_new = mom.Perp()*(1.0 + rnd.Gaus(0.0, pt_res));
61  while(theta_new<=0.0 || theta_new>M_PI)theta_new = mom.Theta() + rnd.Gaus(0.0, theta_res)/1000.0;
62  phi_new = mom.Phi() + rnd.Gaus(0.0, phi_res)/1000.0;
63  while(phi_new<-M_PI)phi_new+=M_PI;
64  while(phi_new>=M_PI)phi_new-=M_PI;
65 
66  // Overwrite input vector with new values
67  mom.SetMagThetaPhi(pt_new/sin(theta_new), theta_new, phi_new);
68 
69  return is_reconstructed;
70 }
71 
72 //----------------
73 // Efficiency
74 //----------------
75 bool DTrackingResolution::Efficiency(int geanttype, const TVector3 &mom)
76 {
77  /// Return a boolean saying whether this event would be reconstructed
78  /// or not. The value returned will vary in that if mom points to
79  /// an area of the detector with 80% efficienct, then this will return
80  /// "true" 80% of the time and "false" 20% of the time.
81  ///
82  /// Geometric acceptance is also included so values of mom pointing
83  /// away from the detector will always returen "false".
84  ///
85  /// This works by calling the GetEfficiency method and then picking a
86  /// random number between 0 and 1. If the random number is less than or
87  /// equal to the efficiency value, then true is returned . Otherwise,
88  /// false is returned.
89 
90  double eff = GetEfficiency(geanttype, mom);
91 
92  double s = rnd.Rndm();
93 
94  return s<=eff;
95 }
96 
97 
98 
bool Efficiency(int geanttype, const TVector3 &mom)
bool Smear(int geanttype, TVector3 &mom)
double sin(double)