R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandPrimaryClusterFinder.cxx
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
15#include "R3BNeulandCluster.h"
16#include "R3BNeulandHit.h"
17#include <FairTask.h>
18#include <RtypesCore.h>
19#include <string_view>
20#include <vector>
21
22namespace
23{
24 auto IsPrimaryCluster(const R3BNeulandCluster& cluster, const std::vector<R3BNeulandHit>& primaryHits) -> bool
25 {
26 for (const auto& primary_hit : primaryHits)
27 {
28 for (const auto& hit : cluster.GetHits())
29 {
30 if (hit == primary_hit)
31 {
32 return true;
33 }
34 }
35 }
36 return false;
37 }
38
39} // namespace
40
41// NOLINTNEXTLINE: bugprone-easily-swappable-parameters
43 std::string_view clusters,
44 std::string_view primaryClusters,
45 std::string_view secondaryClusters)
46 : fPrimaryHits{ primaryHits }
47 , fClusters{ clusters }
48 , fPrimaryClusters{ primaryClusters }
49 , fSecondaryClusters{ secondaryClusters }
50{
51}
52
54{
55 fPrimaryHits.init();
56 fClusters.init();
57 fPrimaryClusters.init();
58 fSecondaryClusters.init();
59
60 return kSUCCESS;
61}
62
63void R3BNeulandPrimaryClusterFinder::Exec(Option_t* /*option*/)
64{
65 const auto& primaryHits = fPrimaryHits.get();
66 const auto& clusters = fClusters.get();
67 fPrimaryClusters.clear();
68 fSecondaryClusters.clear();
69
70 for (const auto& cluster : clusters)
71 {
72 if (IsPrimaryCluster(cluster, primaryHits))
73 {
74 fPrimaryClusters.get().push_back(cluster);
75 }
76 else
77 {
78 fSecondaryClusters.get().push_back(cluster);
79 }
80 }
81}
R3B::InputVectorConnector< R3BNeulandHit > fPrimaryHits
R3B::OutputVectorConnector< R3BNeulandCluster > fSecondaryClusters
R3B::InputVectorConnector< R3BNeulandCluster > fClusters
R3B::OutputVectorConnector< R3BNeulandCluster > fPrimaryClusters
R3BNeulandPrimaryClusterFinder(std::string_view primaryHits="NeulandPrimaryHits", std::string_view clusters="NeulandClusters", std::string_view primaryClusters="NeulandPrimaryClusters", std::string_view secondaryClusters="NeulandSecondaryClusters")