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"
14
15namespace o2::mch
16{
17
18bool isTrackable(std::array<int, 10> itemsPerChamber,
19 std::array<bool, 5> requestStation,
20 bool moreCandidates)
21{
22 // first check that the required stations are actually hit
23 for (auto i = 0; i < 5; i++) {
24 int inStation = itemsPerChamber[i * 2] + itemsPerChamber[i * 2 + 1];
25 if (requestStation[i] && inStation == 0) {
26 return false;
27 }
28 }
29 // then check that we have the right number of hit chambers in St45
30 int nChHitInSt4 = (itemsPerChamber[6] > 0 ? 1 : 0) + (itemsPerChamber[7] > 0 ? 1 : 0);
31 int nChHitInSt5 = (itemsPerChamber[8] > 0 ? 1 : 0) + (itemsPerChamber[9] > 0 ? 1 : 0);
32
33 if (moreCandidates) {
34 return nChHitInSt4 + nChHitInSt5 >= 2;
35 } else {
36 return nChHitInSt4 == 2 || nChHitInSt5 == 2;
37 }
38 return true;
39}
40
44template <>
45std::array<int, 10> perChamber(gsl::span<const int> deids)
46{
47 std::array<int, 10> nitems{};
48 for (const auto& d : deids) {
49 nitems[d / 100 - 1]++;
50 }
51 return nitems;
52}
53
55template <>
56std::array<int, 10> perChamber(gsl::span<const Digit> digits)
57{
58 std::array<int, 10> nofDigits{};
59 for (const auto& digit : digits) {
60 nofDigits[digit.getDetID() / 100 - 1]++;
61 }
62 return nofDigits;
63}
64
65} // namespace o2::mch
int32_t i
bool isTrackable(std::array< int, 10 > itemsPerChamber, std::array< bool, 5 > requestStation={true, true, true, true, true}, bool moreCandidates=false)
Definition Trackable.cxx:18
std::array< int, 10 > perChamber(gsl::span< const T > items)
std::vector< Digit > digits