Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaVDCPointPair.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen 13-Mar-02
2
4//
5// THaVDCPointPair
6//
7// A pair of THaVDCPoints, candidate for a reconstructed track.
8//
10
11#include "THaVDCPointPair.h"
12#include "THaVDCChamber.h"
13#include "TClass.h" // for IsA()
14#include "TString.h"
15
16#include <iostream>
17#include <cassert>
18#include <algorithm>
19
20using namespace std;
21using namespace VDC;
22
23//_____________________________________________________________________________
25{
26 // Compute goodness of match parameter between upper and lower point.
27 // Essentially, this is a measure of how closely the two local tracks
28 // point at each other.
29
30 //FIXME: preliminary, just the old functionality
32}
33
34//_____________________________________________________________________________
36{
37 // Mark upper and lower points as well as their clusters
38 // as belonging to the given track
39
40 THaVDCPoint* point[2] = { fLowerPoint, fUpperPoint };
41
42 for( auto& p : point ) {
43 p->SetTrack(track);
44 p->GetUCluster()->SetTrack(track);
45 p->GetVCluster()->SetTrack(track);
46 }
47}
48
49//_____________________________________________________________________________
51{
52 // Calculate chi2 and number of data points for the associated track
53 // and clusters
54
55 THaVDCCluster* clust[4] =
58
59 chi2_t res(0,0);
60 for( auto& cl : clust ) {
61 res = res + cl->CalcDist();
62 }
63 return res;
64}
65
66//_____________________________________________________________________________
68{
69 // Compare this object to another THaVDCPointPair.
70 // Used for sorting tracks.
71
72 if( !obj || IsA() != obj->IsA() )
73 return -1;
74
75 const auto *rhs = static_cast<const THaVDCPointPair*>( obj );
76 if( fError < rhs->fError )
77 return -1;
78 if( fError > rhs->fError )
79 return 1;
80
81 return 0;
82}
83
84//_____________________________________________________________________________
86 THaVDCPoint* there,
87 Double_t spacing )
88{
89 // Calculate projected positions of points in opposite planes, measure
90 // how far they differ from partner point intercept, and return the sum
91 // of the squares of the distances
92
93 Double_t error =
94 GetProjectedDistance( here, there, spacing );
95 error +=
96 GetProjectedDistance( there, here, -spacing );
97
98 return error;
99}
100
101//_____________________________________________________________________________
103 THaVDCPoint* there,
104 Double_t spacing )
105{
106 // Project 'here' to plane of 'there' and return square of distance between
107 // projected position and intercept of 'there'
108
109 Double_t px = here->GetX() + spacing * here->GetTheta(); // Projected x
110 Double_t py = here->GetY() + spacing * here->GetPhi(); // Projected y
111
112 Double_t x = there->GetX();
113 Double_t y = there->GetY();
114
115 return (px-x)*(px-x) + (py-y)*(py-y);
116}
117
118//_____________________________________________________________________________
120{
121 // Return track associated with this pair
122
123 assert( fLowerPoint->GetTrack() == fUpperPoint->GetTrack() );
124 return fLowerPoint->GetTrack();
125}
126
127//_____________________________________________________________________________
129{
130 // Return true if any cluster underlying this point pair is also part of
131 // another point pair that has already been chosen for making a track.
132 // This ensures each cluster is only ever used in at most one final track.
133
134 const THaVDCCluster* clust[4] =
137
138 return any_of(clust, clust + 4, []( const THaVDCCluster* cl ) {
139 return (cl->GetPointPair() != nullptr);
140 });
141}
142
143//_____________________________________________________________________________
145{
146 // Print details about this point pair (for debugging)
147
148 TString sopt(opt);
149 if( sopt.Contains("TRACKP") ) {
150 cout << "Global track parameters: mu/mv/th/ph = "
151 << GetLower()->GetUCluster()->GetSlope() << " "
152 << GetLower()->GetVCluster()->GetSlope() << " "
153 << GetLower()->GetTheta() << " "
154 << GetLower()->GetPhi()
155 << endl;
156 return;
157 }
158
159 if( !sopt.Contains("NOHEAD") ) {
160 cout << "Pair: ";
161 }
162 cout << "pivots = "
163 << GetLower()->GetUCluster()->GetPivotWireNum() << " "
164 << GetLower()->GetVCluster()->GetPivotWireNum() << " "
165 << GetUpper()->GetUCluster()->GetPivotWireNum() << " "
167 << ", dUpper/dLower = "
169 << " "
171 << ", error = "
172 << GetError()
173 << endl;
174}
175
176//_____________________________________________________________________________
178{
179 // Mark this point pair as used (i.e. chosen for making a track)
180 // This does the following:
181 //
182 // (a) upper and lower points are marked as each other's partners
183 // (b) the underlying four clusters are marked as associated with this pair
184 // (c) the global slope resulting from the coordinate pair is calculated
185 // and stored in the clusters associated with the points
186 // (d) This pair is marked as used
187
188 // Compute global track values and get TRANSPORT coordinates for tracks. Re-
189 // place local cluster slopes with global ones, which have higher precision.
190 Double_t mu =
191 (fUpperPoint->GetU() - fLowerPoint->GetU()) /
193 Double_t mv =
194 (fUpperPoint->GetV() - fLowerPoint->GetV()) /
196
197 // Set point an cluster data
198 THaVDCPoint* point[2] = { fLowerPoint, fUpperPoint };
199 for( int i = 0; i<2; ++i ) {
200 point[i]->SetPartner( point[!i] );
201 point[i]->SetSlopes( mu, mv );
202 point[i]->GetUCluster()->SetPointPair( this );
203 point[i]->GetVCluster()->SetPointPair( this );
204 }
205
206 SetStatus(1);
207}
208
209//_____________________________________________________________________________
210//void THaVDCPointPair::Release()
211//{
212// // Mark this track pair as unused
213//
214// //TODO
215//}
216
int Int_t
bool Bool_t
double Double_t
const char Option_t
winID h TVirtualViewer3D TVirtualGLPainter p
static const char *const here
Definition THaVar.cxx:64
void SetPointPair(VDC::VDCpp_t *pp)
VDC::VDCpp_t * GetPointPair() const
Double_t GetSlope() const
Int_t GetPivotWireNum() const
Double_t GetError() const
THaVDCPoint * fUpperPoint
virtual Int_t Compare(const TObject *) const
virtual void Print(Option_t *opt="") const
THaVDCPoint * GetUpper() const
THaVDCPoint * GetLower() const
static Double_t CalcError(THaVDCPoint *lowerPoint, THaVDCPoint *upperPoint, Double_t spacing)
static Double_t GetProjectedDistance(THaVDCPoint *here, THaVDCPoint *there, Double_t spacing)
Bool_t HasUsedCluster() const
void Associate(THaTrack *track)
VDC::chi2_t CalcChi2() const
THaTrack * GetTrack() const
THaVDCPoint * fLowerPoint
void SetStatus(Int_t i)
Double_t GetZV() const
THaVDCCluster * GetVCluster() const
Definition THaVDCPoint.h:29
Double_t GetTheta() const
Definition THaVDCPoint.h:37
THaVDCCluster * GetUCluster() const
Definition THaVDCPoint.h:28
Double_t GetV() const
Definition THaVDCPoint.h:88
void SetPartner(THaVDCPoint *partner)
Definition THaVDCPoint.h:48
Double_t GetPhi() const
Definition THaVDCPoint.h:38
Double_t GetY() const
Definition THaVDCPoint.h:36
Double_t GetU() const
Definition THaVDCPoint.h:79
Double_t GetZU() const
THaTrack * GetTrack() const
Definition THaVDCPoint.h:32
void SetSlopes(Double_t mu, Double_t mv)
Double_t GetX() const
Definition THaVDCPoint.h:35
virtual TClass * IsA() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Double_t y[n]
Double_t x[n]
std::pair< Double_t, Int_t > chi2_t
STL namespace.
ClassImp(TPyArg)