Match the tree lines in two planes in region 3.
Match the tree lines in two like-pitched planes in region 3.
In this function the list of tree lines in the front VDC plane is combined with the list of tree lines in the back VDC plane. The resulting list of combined tree lines is returned as a linked-list. The criterion for keeping a combined tree line is that the following slopes are within their slope matching resolutions:
The reference frame for the matching is defined with the center of the first wire plane at the origin. The center of the second wire plane is then at (0, delta_para, delta_perp) assuming no lateral displacement. The difference in the u coordinate between the center of the chambers is then given by delta_u.
The line slopes are calculated in a different reference frame: the distance between the wires (in the plane) is represented by z, the perpendicular distance from the wire is represented by x.
Set up the geometry of the two wire planes: distances between them, relative orientation, etc.
70 QwError <<
"[TreeMatch::MatchR3] Tree line matching is only valid for region 3!"
79 QwError <<
"[TreeMatch::MatchR3] The front and back planes are not consistent!"
86 QwError <<
"[TreeMatch::MatchR3] The front and back planes are identical!"
117 double delta_perp = delta_z * cos_theta + delta_y * sin_theta;
121 double delta_para = - delta_z * sin_theta + delta_y * cos_theta + 0.5 * delta_x;
136 for (
QwTreeLine* frontline = frontlist; frontline;
137 frontline = frontline->
next, numflines++) {
139 if (frontline->IsVoid())
continue;
141 for (
int hit = 0; hit < frontline->GetNumberOfHits(); hit++) {
142 int element = frontline->GetHit(hit)->GetElement();
144 frontline->GetHit(hit)->SetWirePosition(wire);
146 << frontline->GetHit(hit)->GetWirePosition() <<
" "
147 << frontline->GetHit(hit)->GetDriftPosition() <<
QwLog::endl;
152 for (
QwTreeLine* backline = backlist; backline;
153 backline = backline->
next, numblines++) {
155 if (backline->IsVoid())
continue;
157 for (
int hit = 0; hit < backline->GetNumberOfHits(); hit++) {
158 int element = backline->GetHit(hit)->GetElement();
160 backline->GetHit(hit)->SetWirePosition(wire);
162 << backline->GetHit(hit)->GetWirePosition() + delta_u <<
" "
163 << backline->GetHit(hit)->GetDriftPosition() + delta_perp <<
QwLog::endl;
171 int fmatches[numflines];
172 int bmatches[numblines];
173 int reverse[numflines*numblines];
177 double bestmatches[numblines];
178 for (
int i = 0; i < numblines; i++) bestmatches[i] = 99;
182 for (
QwTreeLine* frontline = frontlist; frontline;
183 frontline = frontline->
next, ifront++) {
186 fmatches[ifront] = -1;
189 if (frontline->IsVoid())
continue;
192 QwHit* fronthit = frontline->GetBestWireHit();
195 double bestmatch = 99;
199 for (
QwTreeLine* backline = backlist; backline;
200 backline = backline->
next, iback++) {
203 if (backline->IsVoid())
continue;
207 QwHit* backhit = backline->GetBestWireHit();
210 double u[2], perp[2];
221 if(backline->GetPackage()==1)
222 slope = (-1*delta_u + u[1] - u[0]) / (delta_perp + perp[1] - perp[0]);
224 slope = (delta_u + u[1] - u[0]) / (delta_perp + perp[1] - perp[0]);
235 double fslope = wirespacing_f / frontline->GetSlope();
236 double bslope = wirespacing_b / backline->GetSlope();
239 if (fabs(fslope - slope) <= sloperes_f
240 && fabs(bslope - slope) <= sloperes_b
241 && fabs(fslope - slope) + fabs(bslope - slope) < bestmatch){
243 reverse[ifront*numblines+iback]=1;
248 reverse[ifront*numblines+iback]=-1;
251 if (fabs(fslope - slope) <= sloperes_f
252 && fabs(bslope - slope) <= sloperes_b
253 && fabs(fslope - slope) + fabs(bslope - slope) < bestmatch) {
256 if (bestmatches[iback] != 99) {
258 bestmatch = fabs(fslope - slope) + fabs(bslope - slope);
259 if (bestmatch > bestmatches[iback])
continue;
260 else fmatches[bmatches[iback]] = -1;
264 fmatches[ifront] = iback;
265 bmatches[iback] = ifront;
266 bestmatch = bestmatches[iback] = fabs(fslope - slope) + fabs(bslope - slope);
280 for (
const QwTreeLine* frontline = frontlist; frontline;
281 frontline = frontline->
next, ifront++) {
285 for (
const QwTreeLine* backline = backlist; backline;
286 backline = backline->
next, iback++) {
289 if (fmatches[ifront] == iback) {
294 treeline->
SetRegion(frontline->GetRegion());
295 treeline->
SetPackage(frontline->GetPackage());
297 treeline->
SetOctant(frontline->GetOctant());
300 int fronthits = frontline->GetNumberOfHits();
301 for (
int hit = 0; hit < fronthits; hit++) {
302 treeline->
AddHit(frontline->GetHit(hit));
307 int backhits = backline->GetNumberOfHits();
308 for (
int hit = 0; hit < backhits; hit++) {
309 treeline->
AddHit(backline->GetHit(hit));
312 if (backline->GetPackage() == 1)
320 int nhits = fronthits + backhits;
323 double slope, offset, chi, cov[3];
340 for (
int hit = 0; hit < fronthits + backhits; hit++) {
344 treeline->
next = treelinelist;
345 treelinelist = treeline;
double GetElementCoordinate(const int element) const
#define QwMessage
Predefined log drain for regular messages.
double GetDetectorPitchSin() const
const std::vector< QwHit * > & GetListOfHits() const
Get the list of hits.
void SetRegion(EQwRegionID region)
Set the region.
void SetSlope(const double slope)
Set the slope.
void SetPackage(EQwDetectorPackage package)
Set the package.
double GetDetectorPitchCos() const
const Double_t & GetWirePosition() const
EQwRegionID GetRegion() const
Get the region.
Double_t fDriftPosition
Position of the decoded hit in the drift cell.
void SetChi(const double chi)
Set the chi^2.
int GetPlane() const
Get the plane number.
double GetSlopeMatching() const
void SetValid(const bool isvoid=false)
void SetOctant(int octant)
Set the octant number.
int fNumHits
number of hits on this treeline
void SetOffset(const double offset)
Set the offset.
const Double_t & GetDriftPosition() const
void SetDirection(EQwDirectionID direction)
Set the direction.
double GetYPosition() const
One-dimensional (u, v, or x) track stubs and associated hits.
int fNumMiss
number of planes without hits
static std::ostream & endl(std::ostream &)
End of the line.
double GetElementSpacing() const
const QwDetectorInfo * GetDetectorInfo() const
Get the detector info pointer.
void AddHit(const QwHit *hit)
Add a single hit.
Combines track segments and performs line fitting.
double GetElementAngleCos() const
void r3_TreelineFit(double &slope, double &offset, double cov[3], double &chi, const std::vector< QwHit * > hits, double z1, int wire_offset)
QwHit * fHits[2 *MAX_LAYERS]
Hit structure uniquely defining each hit.
double GetZPosition() const
double GetXPosition() const
EQwDirectionID GetDirection() const
Get the direction.
double CalculateAverageResidual()
Calculate the average residuals.
#define QwError
Predefined log drain for errors.
EQwDetectorPackage GetPackage() const
Get the package.