Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
residFDC.cc
Go to the documentation of this file.
1 #include <CLHEP/Matrix/Matrix.h>
2 #include <CLHEP/Matrix/Vector.h>
3 
4 using namespace std;
5 
7 #include "MyTrajectory.h"
9 #include "residFDC.h"
10 
11 const double velDrift = 55.e-4; // cm/ns
12 const double c = 29.9792548; // speed of light, cm/ns
13 
14 // constructor, takes pointer to vector of pseudopoints and a pointer
15 // to a trajectory
16 residFDC::residFDC(vector<const DFDCPseudo*> *pseudopoints,
17  const MyTrajectory *trajectory,
18  const DLorentzDeflections *lorentz_def_in, int level) :
19  n_fdc(pseudopoints->size()), ppPtr(pseudopoints),
20  trajPtr(trajectory), debug_level(level), lorentz_def(lorentz_def_in), errorFDC(0.046) {}
21 
23  double docaThis, errorThis, residThis;
24  HepVector pointThis(3);
25  HepLorentzVector pocaThis;
26  const DFDCPseudo* ppointPtr;
27  doca.clear();
28  poca.clear();
29  error.clear();
30  resid.clear();
31  for (unsigned int i = 0; i < n_fdc; i++) {
32  ppointPtr = (*ppPtr)[i];
33  pointThis = pseudo2HepVector(*ppointPtr);
34  point.push_back(pointThis);
35  docaThis = trajPtr->doca(pointThis, pocaThis);
36  errorThis = errorFDC;
37  residThis = docaThis/errorThis;
38  doca.push_back(docaThis);
39  poca.push_back(pocaThis);
40  resid.push_back(residThis);
41  error.push_back(errorThis);
42  if (debug_level > 2) cout << "residFDC: i = " << i << " doca = " << docaThis << " poca xyzt = " << pocaThis.getX() << ' ' << pocaThis.getY() << ' ' << pocaThis.getZ() << ' ' << pocaThis.getT()/c << " resid = " << residThis << endl;
43 
44  }
45 }
46 
47 HepVector residFDC::pseudo2HepVector(const DFDCPseudo &ppoint) {
48  double x;
49  double y;
50  double ct;
51  double z = ppoint.wire->origin(2);
52  trajPtr->getXYT(z, x, y, ct); // on trajectory
53  double delta_x = 0.0, delta_y = 0.0;
54  getCorrectionValue(ppoint, x, y, z, ct, delta_x, delta_y);
55  bool ispos = getCorrectionSign(ppoint, x, y, delta_x, delta_y);
56  HepVector point(3);
57  if (ispos) {
58  point(1) = ppoint.xy.X() + delta_x;
59  point(2) = ppoint.xy.Y() + delta_y;
60  } else {
61  point(1) = ppoint.xy.X() - delta_x;
62  point(2) = ppoint.xy.Y() - delta_y;
63  }
64  point(3) = z;
65  if (debug_level >= 4) {
66  cout << "residFDC::pseudo2HepVector, x = " << x << " y = " << y << " z = " << z << " ct = " << ct << " delta_x = " << delta_x << " delta_y = " << delta_y << " ispos = " << ispos << " point = " << point << endl;
67  }
68  return point;
69 }
70 
71 bool residFDC::getCorrectionSign(const DFDCPseudo &ppoint, double x, double y, double delta_x, double delta_y) {
72  double xWire = ppoint.wire->udir(0);
73  double yWire = ppoint.wire->udir(1);
74  double wireCrossTraj = xWire*(y - ppoint.xy.Y()) - yWire*(x - ppoint.xy.X());
75  double wireCrossDelta = xWire*delta_y - yWire*delta_x;
76  bool isposTraj = wireCrossTraj > 0?true:false;
77  bool isposDelta = wireCrossDelta > 0?true:false;
78  bool ispos = !(isposTraj ^ isposDelta);
79  if (debug_level > 3) cout << setprecision(14)
80  << "residFDC::getCorrectionSign,"
81  << " x = " << x
82  << " y = " << y
83  << " ppx = " << ppoint.xy.X()
84  << " ppy = " << ppoint.xy.Y()
85  << " dx = " << x - ppoint.xy.X()
86  << " dy = " << y - ppoint.xy.Y()
87  << " delta_x = " << delta_x
88  << " delta_y = " << delta_y
89  << " xWire = " << xWire
90  << " yWire = " << yWire
91  << " wireCrossTraj = " << wireCrossTraj
92  << " wireCrossDelta = " << wireCrossDelta
93  << " isposTraj = " << isposTraj
94  << " isposDelta = " << isposDelta
95  << " ispos = " << ispos
96  << endl;
97  return ispos;
98 }
99 
100 void residFDC::getCorrectionValue(const DFDCPseudo &ppoint, double x, double y, double z, double ct, double &delta_x, double &delta_y) {
101  double driftDist = (ppoint.time - ct/c)*DRIFT_VELOCITY;
102  //double driftDist = ppoint.time*DRIFT_VELOCITY;
103  double cosangle = ppoint.wire->udir(1);
104  double sinangle= ppoint.wire->udir(0);
105  double alpha = 0.0; // for now
106  if (debug_level > 3) cout << "x, y, z, ct = " << x << ' ' << y << ' ' << z << ' ' << ct << " time, ct/c = " << ppoint.time << " " << ct/c << " driftdist = " << driftDist << endl;
107  double lorentzShift = lorentz_def->GetLorentzCorrection(x, y, z, alpha, driftDist);
108  double ds = -lorentzShift;
109  double dw = driftDist;
110  if (debug_level > 3) cout << "ds, dw" << ds << " " << dw << endl;
111  delta_x = dw*cosangle + ds*sinangle;
112  delta_y = -dw*sinangle + ds*cosangle;
113  return;
114 }
115 
116 void residFDC::getResids(vector<double> &residRef) {
117  residRef = resid;
118  return;
119 }
120 
121 void residFDC::getDetails(vector<HepVector> &pointsRef, vector<double> &docasRef, vector<double> &errorsRef,
122  vector<HepLorentzVector> &pocasRef) {
123  pointsRef = point;
124  docasRef = doca;
125  errorsRef = error;
126  pocasRef = poca;
127  return;
128 }
129 
130 // end of C++ source
int getXYT(double z, double &x, double &y, double &ct) const
DVector2 xy
rough x,y coordinates in lab coordinate system
Definition: DFDCPseudo.h:100
vector< HepVector > point
Definition: residFDC.h:32
bool getCorrectionSign(const DFDCPseudo &pseudopoint, double x, double y, double deltaX, double deltaY)
Definition: residFDC.cc:71
vector< HepLorentzVector > poca
Definition: residFDC.h:34
unsigned int n_fdc
Definition: residFDC.h:22
HepVector pseudo2HepVector(const DFDCPseudo &pseudopoint)
Definition: residFDC.cc:47
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
#define c
#define y
const DFDCWire * wire
DFDCWire for this wire.
Definition: DFDCPseudo.h:92
void getDetails(vector< HepVector > &points, vector< double > &docasRef, vector< double > &errorsRef, vector< HepLorentzVector > &pocasRef)
Definition: residFDC.cc:121
vector< double > error
Definition: residFDC.h:33
double doca(C &spaceObject, HepLorentzVector &poca) const
Definition: MyTrajectory.h:48
class DFDCPseudo: definition for a reconstructed point in the FDC
Definition: DFDCPseudo.h:74
double errorFDC
Definition: residFDC.h:35
void getResids(vector< double > &residsRef)
Definition: residFDC.cc:116
const double alpha
int debug_level
Definition: residFDC.h:26
const MyTrajectory * trajPtr
Definition: residFDC.h:24
residFDC(vector< const DFDCPseudo * > *pseudopoints, const MyTrajectory *trajectory, const DLorentzDeflections *lorentz_def, int level=1)
Definition: residFDC.cc:16
void calcResids()
Definition: residFDC.cc:22
double time
time corresponding to this pseudopoint.
Definition: DFDCPseudo.h:93
double GetLorentzCorrection(double x, double y, double z, double alpha, double dx) const
vector< double > doca
Definition: residFDC.h:33
vector< double > resid
Definition: residFDC.h:33
const DLorentzDeflections * lorentz_def
Definition: residFDC.h:31
#define DRIFT_VELOCITY
const double velDrift
void getCorrectionValue(const DFDCPseudo &pseudopoint, double x, double y, double z, double t, double &delta_x, double &delta_y)
Definition: residFDC.cc:100