Project
Loading...
Searching...
No Matches
Trackable.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include "MCHBase/Trackable.h"
13
15#include "MCHBase/PreCluster.h"
16
17namespace o2::mch
18{
19
20bool isTrackable(std::array<int, 10> itemsPerChamber,
21 std::array<bool, 5> requestStation,
22 bool moreCandidates)
23{
24 // first check that the required stations are actually hit
25 for (auto i = 0; i < 5; i++) {
26 int inStation = itemsPerChamber[i * 2] + itemsPerChamber[i * 2 + 1];
27 if (requestStation[i] && inStation == 0) {
28 return false;
29 }
30 }
31 // then check that we have the right number of hit chambers in St45
32 int nChHitInSt4 = (itemsPerChamber[6] > 0 ? 1 : 0) + (itemsPerChamber[7] > 0 ? 1 : 0);
33 int nChHitInSt5 = (itemsPerChamber[8] > 0 ? 1 : 0) + (itemsPerChamber[9] > 0 ? 1 : 0);
34
35 if (moreCandidates) {
36 return nChHitInSt4 + nChHitInSt5 >= 2;
37 } else {
38 return nChHitInSt4 == 2 || nChHitInSt5 == 2;
39 }
40 return true;
41}
42
46template <>
47std::array<int, 10> perChamber(gsl::span<const int> deids)
48{
49 std::array<int, 10> nitems{};
50 for (const auto& d : deids) {
51 nitems[d / 100 - 1]++;
52 }
53 return nitems;
54}
55
57template <>
58std::array<int, 10> perChamber(gsl::span<const Digit> digits)
59{
60 std::array<int, 10> nofDigits{};
61 for (const auto& digit : digits) {
62 nofDigits[digit.getDetID() / 100 - 1]++;
63 }
64 // do not count isolated digits (at least 2 are required for a cluster)
65 for (auto i = 0; i < 10; ++i) {
66 if (nofDigits[i] == 1) {
67 nofDigits[i] = 0;
68 }
69 }
70 return nofDigits;
71}
72
74template <>
75std::array<int, 10> perChamber(gsl::span<const PreCluster> preclusters, gsl::span<const Digit> digits)
76{
77 std::array<int, 10> nofPreclusters{};
78 for (const auto& precluster : preclusters) {
79 // only consider preclusters made of at least 2 digits
80 if (precluster.nDigits > 1) {
81 nofPreclusters[digits[precluster.firstDigit].getDetID() / 100 - 1]++;
82 }
83 }
84 return nofPreclusters;
85}
86
87} // namespace o2::mch
int32_t i
Definition of the MCH precluster minimal structure.
bool isTrackable(std::array< int, 10 > itemsPerChamber, std::array< bool, 5 > requestStation={true, true, true, true, true}, bool moreCandidates=false)
Definition Trackable.cxx:20
std::array< int, 10 > perChamber(gsl::span< const T > items)
std::vector< Digit > digits