Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
residCDC.cc
Go to the documentation of this file.
1 // residCDC: class to calculate drift distance, distance of closest
2 // approach, point of closest approach, residual and error on residual
3 // for the CDC for a given set of track parameters
4 
5 #include "residCDC.h"
6 
7 using namespace std;
8 
9 const double velDrift = 55.e-4; // cm/ns
10 const double c = 29.9792548; // speed of light, cm/ns
11 
12 // constructor, takes pointer to vector of trackhits and a pointer
13 // to a trajectory
14 residCDC::residCDC(vector<const DCDCTrackHit*> *trackHits,
15  const MyTrajectory *trajectory, int level) :
16  n_cdc(trackHits->size()), trkhitVectorPtr(trackHits), trajPtr(trajectory),
17  debug_level(level), errorCDC(0.018)
18 {}
19 
21  const DCDCTrackHit* trkhitPtr;
22  DLine line;
23  double docaThis, distThis, residThis, errorThis;
24  HepLorentzVector pocaThis;
25  HepVector posWireThis;
26  doca.clear();
27  dist.clear();
28  poca.clear();
29  posWire.clear();
30  error.clear();
31  resid.clear();
32  for (unsigned int j = 0; j < n_cdc; j++) {
33  trkhitPtr = (*trkhitVectorPtr)[j];
34  line = trackhit2line(*trkhitPtr);
35  docaThis = trajPtr->doca(line, pocaThis);
36  distThis = velDrift*(trkhitPtr->tdrift - pocaThis.getT()/c);
37  if (docaThis > distThis) {
38  residThis = (distThis - docaThis)/errorCDC;
39  } else {
40  residThis = innerResidFrac*(distThis - docaThis)/errorCDC;
41  }
42  posWireThis = line.poca(pocaThis);
43  if (debug_level > 2) cout << "residCDC: j = " << j << " dist = " << distThis << " doca = " << docaThis << " poca xyzt = " << pocaThis.getX() << ' ' << pocaThis.getY() << ' ' << pocaThis.getZ() << ' ' << pocaThis.getT()/c << " resid = " << residThis << endl;
44  errorThis = errorCDC;
45  doca.push_back(docaThis);
46  dist.push_back(distThis);
47  poca.push_back(pocaThis);
48  posWire.push_back(posWireThis);
49  resid.push_back(residThis);
50  error.push_back(errorThis);
51  }
52 };
53 
55  const DCDCWire *wire = trkhit.wire;
56  double x = wire->origin.X();
57  double y = wire->origin.Y();
58  double z = wire->origin.Z();
59  double theta = acos(wire->udir.z());
60  double phi = atan2(wire->udir.y(), wire->udir.x());
61  if (debug_level >= 4) cout << setprecision(14) << "residCDC::trackhit2line: x = " << x << " y = " << y << " z = " << z << " theta " << theta << " phi " << phi << endl;
62  DLine line(x, y, z, theta, phi, debug_level);
63  return line;
64 }
65 
66 void residCDC::setInnerResidFrac(double innerResidFracIn) {
67  innerResidFrac = innerResidFracIn;
68 }
69 
70 void residCDC::getResids(vector<double> &residsRef) {
71  residsRef = resid;
72  return;
73 }
74 
75 void residCDC::getDetails(vector<double> &docasRef, vector<double> &distsRef,
76  vector<double> &errorsRef,
77  vector<HepLorentzVector> &pocasRef,
78  vector<HepVector> &posWiresRef) {
79  docasRef = doca;
80  distsRef = dist;
81  errorsRef = error;
82  pocasRef = poca;
83  posWiresRef = posWire;
84  return;
85 }
DLine trackhit2line(const DCDCTrackHit &trackhit)
Definition: residCDC.cc:54
unsigned int n_cdc
Definition: residCDC.h:20
const DCDCWire * wire
Definition: DCDCTrackHit.h:37
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
#define c
#define y
residCDC(vector< const DCDCTrackHit * > *trackhits, const MyTrajectory *trajectory, int level=1)
Definition: residCDC.cc:14
double doca(C &spaceObject, HepLorentzVector &poca) const
Definition: MyTrajectory.h:48
vector< HepLorentzVector > poca
Definition: residCDC.h:27
HepVector poca(HepVector point)
Definition: DLine.cc:37
Definition: DLine.h:8
void calcResids()
Definition: residCDC.cc:20
double errorCDC
Definition: residCDC.h:29
vector< double > error
Definition: residCDC.h:26
const MyTrajectory * trajPtr
Definition: residCDC.h:22
int debug_level
Definition: residCDC.h:24
vector< double > resid
Definition: residCDC.h:26
double innerResidFrac
Definition: residCDC.h:25
vector< double > dist
Definition: residCDC.h:26
void setInnerResidFrac(double innerResidFracIn)
Definition: residCDC.cc:66
vector< HepVector > posWire
Definition: residCDC.h:28
void getDetails(vector< double > &docasRef, vector< double > &distsRef, vector< double > &errorsRef, vector< HepLorentzVector > &pocasRef, vector< HepVector > &posWiresRef)
Definition: residCDC.cc:75
vector< double > doca
Definition: residCDC.h:26
void getResids(vector< double > &residsRef)
Definition: residCDC.cc:70
const double velDrift