27 m_selectionFunction = [](
const std::vector<const xAOD::AFPSiHitsCluster*>&) {
return true; };
32 std::vector<int> plane{0, 0, 0, 0};
34 for (
auto&& cluster : t) {
35 const int p = cluster->pixelLayerID();
39 auto HasAnyClusters = [](
int n) {
return n > 0; };
47 std::vector<int> plane{0, 0, 0, 0};
49 for (
auto&& cluster : t) {
50 const int p = cluster->pixelLayerID();
54 auto HasMultipleClusters = [](
int n) {
return n > 1; };
56 if (std::any_of(plane.begin(), plane.end(), HasMultipleClusters)) {
return false; }
67 return StatusCode::FAILURE;
72 return StatusCode::SUCCESS;
96 std::vector<const xAOD::AFPSiHitsCluster*> track;
97 track.push_back(init);
99 std::vector<const xAOD::AFPSiHitsCluster*> newNeighbours;
103 newNeighbours.clear();
104 for (
auto&& b : toJoin) {
106 for (
auto&&
a : track) {
111 newNeighbours.push_back(b);
117 for (
auto& t : newNeighbours) {
121 }
while (!newNeighbours.empty());
131 double meanx = 0, meany = 0;
132 for (
const auto& [
y,
x] : YX) {
139 double numerator = 0, denominator = 0;
140 for (
const auto& [
y,
x] : YX) {
141 const double dy =
y - meany;
142 const double dx =
x - meanx;
144 numerator += dx * dy;
145 denominator += dx * dx;
148 const double slope = numerator / denominator;
149 const double position = meany - slope * meanx;
151 return {position, slope};
158 if(!clusters.isValid())
161 return StatusCode::SUCCESS;
165 std::list<const xAOD::AFPSiHitsCluster*> clustersInStation;
166 std::copy_if(clusters->begin(), clusters->end(), std::back_inserter(clustersInStation),
167 [
this](
auto cluster) { return cluster->stationID() == m_stationID; });
173 while (!clustersInStation.empty())
176 const auto *
const initialCluster = clustersInStation.front();
177 clustersInStation.pop_front();
184 ATH_MSG_DEBUG(
"track candidate of size " << clusterOfClusters.size() <<
" did not pass selection.");
188 auto *track = outputContainer->push_back(std::make_unique<xAOD::AFPTrack>());
194 for (
const auto *
const cluster : clusterOfClusters) {
197 track->addCluster(clusterLink);
200 const int nClusters = track->clusters().size();
204 track->setNClusters(nClusters);
209 outputContainer->pop_back();
220 if (nClusters == 1) {
221 x = (*(track->clusters().at(0)))->xLocal();
222 y = (*(track->clusters().at(0)))->yLocal();
226 std::vector<std::pair<double, double>> XZ;
227 std::vector<std::pair<double, double>> YZ;
229 for (
int i = 0; i < nClusters; i++) {
239 std::tie(
x, xSlope) = linregx;
240 std::tie(
y, ySlope) = linregy;
242 for (
int i = 0; i < nClusters; i++) {
245 const double z = cluster->
zLocal();
249 const double dx = cluster->
xLocal() - (
x + xSlope *
z);
250 const double dy = cluster->
yLocal() - (
y + ySlope *
z);
252 chi2 += dx * dx / (ex * ex);
253 chi2 += dy * dy / (ey * ey);
258 track->setChi2(
chi2);
260 track->setXSlope(xSlope);
262 track->setYSlope(ySlope);
263 track->setZLocal(0.);
267 std::vector<int> clustersPlane{0, 0, 0, 0};
268 for (
const auto& cl : track->clusters()) {
269 ++clustersPlane[(*cl)->pixelLayerID()];
271 auto HasNoClusters = [](
int n) {
return n == 0; };
272 track->setNHoles(std::count_if(clustersPlane.begin(), clustersPlane.end(), HasNoClusters));
275 ATH_MSG_DEBUG(
"new track with " << track->clusters().size() <<
" clusters, x: " << track->xLocal()
276 <<
", y: " << track->yLocal() <<
", sx: " << track->xSlope()
277 <<
", sy: " << track->ySlope() <<
", chi2: " << track->chi2());
278 for (
auto&& cluster : track->clusters())
280 ATH_MSG_DEBUG(
'\t' << (*cluster)->xLocal() <<
" " << (*cluster)->yLocal() <<
" " << (*cluster)->zLocal());
284 return StatusCode::SUCCESS;
bool toContainedElement(BaseConstReference data, ElementType element, IProxyDict *sg=0)
Set from element pointer and a reference to the container (storable)