33 {
35
37 std::unique_ptr<StraightPatRec> sfitter = std::make_unique<StraightPatRec>();
40 Combination combination;
41 std::vector<unsigned int> hit_index;
42 unsigned int try_nb_hits;
43 bool segment_found(false);
45
46 CurvedLine aux_line;
49 std::vector<Amg::Vector3D> points;
51
53
56
58
60
62 throw std::runtime_error(
63 Form("File: %s, Line: %d\nCurvedPatRec::fit - Size of selection vector does not match the number of hits on track!", __FILE__,
64 __LINE__));
65 }
66
68
70
71
76 if (sfitter->fit(r_segment, r_selection, track)) { est_dir =
track.directionVector(); }
77
78
81 if (r_selection[k] == 0 && hit->sigmaDriftRadius() < 100) { loc_track_hits.push_back(hit); };
83 }
84
85
86 if (loc_track_hits.size() < 4) { return false; }
88
90
91
92 try_nb_hits = loc_track_hits.size();
93
96
97 while (!segment_found && try_nb_hits > 3) {
98
101
103 diff = difftime(end, start);
106 log << MSG::WARNING <<
"Class CurvedPatRec, method fit: time-out for track finding after " <<
m_time_out <<
" seconds!"
108 return false;
109 }
110
111
112 if (cb == 0) {
114 } else {
116 }
118 for (
unsigned int k = 0;
k < try_nb_hits; ++
k) { track_hits.push_back(loc_track_hits[hit_index[k] - 1]); }
119
120
121 CurvedCandidateFinder
finder(track_hits);
124
125 segment_found = true;
126
127 for (const auto & candidate : candidates) {
128 std::vector<Amg::Vector3D>
errors(track_hits.size());
129 for (
unsigned int k = 0;
k <
errors.size();
k++) {
130 if (track_hits[k]->sigmaDriftRadius() > 0.0) {
132 } else {
134 }
135 }
136
137
139
140
141 aux_line = CurvedLine(points, errors);
142
143
144 double tmp_chi2(0.0);
145 for (auto & track_hit : track_hits) {
146 MTStraightLine tang(curved_track.
getTangent((track_hit->localPosition()).z()));
147 MTStraightLine wire(
Amg::Vector3D(0.0, track_hit->localPosition().y(), track_hit->localPosition().z()), xhat,
148 null, null);
149 double d(std::abs(tang.signDistFrom(wire)));
150 if (track_hit->sigma2DriftRadius() != 0) {
151 tmp_chi2 = tmp_chi2 + std::pow(d - track_hit->driftRadius(), 2) / track_hit->sigma2DriftRadius();
152 } else {
153 tmp_chi2 = tmp_chi2 + std::pow(d - track_hit->driftRadius(), 2) / 0.01;
154 }
155 }
156
157
160 curved_track = aux_line;
161
162 stored_track_hits = track_hits;
163 }
164 }
165 }
166
167 try_nb_hits = try_nb_hits - 1;
168 }
169
170 if (!segment_found) { return false; }
171
173
175
176
178 std::vector<Amg::Vector3D>
errors(stored_track_hits.size());
179 for (
unsigned int k = 0;
k <
errors.size();
k++) {
180 if (stored_track_hits[k]->sigmaDriftRadius() > 0.0) {
182 } else {
184 }
185 }
186
187
188 curved_track = CurvedLine(points, errors);
189
191
193
195 for (auto & stored_track_hit : stored_track_hits) {
196 MTStraightLine tang(curved_track.
getTangent((stored_track_hit->localPosition()).z()));
197 MTStraightLine wire(
Amg::Vector3D(0.0, stored_track_hit->localPosition().y(), stored_track_hit->localPosition().z()), xhat,
198 null, null);
199 double d(std::abs(tang.signDistFrom(wire)));
200 if (stored_track_hit->sigma2DriftRadius() != 0) {
201 chi2 += std::pow(d - stored_track_hit->driftRadius(), 2) / stored_track_hit->sigma2DriftRadius();
202 } else {
203 chi2 += std::pow(d - stored_track_hit->driftRadius(), 2) / 0.01;
204 }
205 }
206
208
210
213 MTStraightLine aux_line(pos, xhat, null, null);
214
216
217 double dist(tang.signDistFrom(aux_line));
218 double dist_err(1.0);
219 hit->setDistanceToTrack(dist, dist_err);
220 }
221
222 if (std::isnan(
chi2)) {
chi2 = 1.0e6; }
223
225
227
229 r_segment.
set(
chi2 / (stored_track_hits.size() - 3), tangent.positionVector(), tangent.directionVector());
233 return true;
234}
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
void currentCombination(std::vector< unsigned int > &index_array) const
get the current combination; the result is stored in the vector index_array
unsigned int numberOfCombinations() const
get the number of combinations
void setNewParameters(const unsigned int &nb_elements, const unsigned int &wh_class)
set the number of elements = nb_elements; set the class of which the combination is = wh_class
void nextCombination(std::vector< unsigned int > &index_array)
get the next combination; the results is stored in the array index_array
void setChi2(double chi2)
Cache the chi2.
MTStraightLine getTangent(const double loc_z) const
get the tangent to the line a the local z coordinate "loc_z"
void setUsedHits(const MdtHitVec &hits)
void setNumberOfTrackHits(unsigned int n_hits)
cache the number of track hits
MuonCalibSegment::MdtHitPtr MdtHitPtr
std::vector< Amg::Vector3D > getHitPoints(const MdtHitVec &track_hits, const MTStraightLine &straight_track) const
MuonCalibSegment::MdtHitVec MdtHitVec
std::shared_ptr< MdtCalibHitBase > MdtHitPtr
typedef for a collection of MdtCalibHitBase s
const MdtHitVec & mdtHOT() const
retrieve the full set of MdtCalibHitBase s assigned to this segment
void set(double chi2, const Amg::Vector3D &pos, const Amg::Vector3D &dir)
const Amg::Vector3D & position() const
retrieve local position of segment (on station level)
double chi2(TH1 *h0, TH1 *h1)
Eigen::Matrix< double, 3, 1 > Vector3D
IMessageSvc * getMessageSvc(bool quiet=false)
time(flags, cells_name, *args, **kw)