19 : fG4TrackIDOffsets(offsets)
29 std::make_pair(std::numeric_limits<int>::max(), std::numeric_limits<int>::min()));
35 std::vector<simb::MCParticle>& merged_vector,
36 const std::vector<simb::MCParticle>& input_vector,
41 std::runtime_error(
"ERROR in MergeSimSourcesUtility: Source index out of range!");
44 merged_vector.reserve(merged_vector.size() + input_vector.size());
46 std::pair<int, int> range_trackID(std::numeric_limits<int>::max(),
47 std::numeric_limits<int>::min());
49 for (
size_t i_p = 0; i_p < input_vector.size(); i_p++) {
54 if (
std::abs(merged_vector.back().TrackId()) < range_trackID.first)
55 range_trackID.first =
std::abs(merged_vector.back().TrackId());
56 if (
std::abs(merged_vector.back().TrackId()) > range_trackID.second)
57 range_trackID.second =
std::abs(merged_vector.back().TrackId());
64 const std::vector<sim::SimChannel>& input_vector,
68 std::runtime_error(
"ERROR in MergeSimSourcesUtility: Source index out of range!");
70 merged_vector.reserve(merged_vector.size() + input_vector.size());
72 std::pair<int, int> range_trackID(std::numeric_limits<int>::max(),
73 std::numeric_limits<int>::min());
75 for (
auto const& simchannel : input_vector) {
77 std::find(merged_vector.begin(), merged_vector.end(), simchannel);
79 if (it == merged_vector.end()) {
80 merged_vector.emplace_back(simchannel.Channel());
81 it = merged_vector.end() - 1;
84 std::pair<int, int> thisrange =
87 range_trackID.first =
std::abs(thisrange.first);
89 range_trackID.second =
std::abs(thisrange.second);
96 std::vector<sim::AuxDetSimChannel>& merged_vector,
97 const std::vector<sim::AuxDetSimChannel>& input_vector,
101 std::runtime_error(
"ERROR in MergeSimSourcesUtility: Source index out of range!");
103 merged_vector.reserve(merged_vector.size() + input_vector.size());
105 std::pair<int, int> range_trackID(std::numeric_limits<int>::max(),
106 std::numeric_limits<int>::min());
108 for (
auto const& simchannel : input_vector) {
110 std::find(merged_vector.begin(), merged_vector.end(), simchannel);
112 if (it == merged_vector.end()) {
113 merged_vector.emplace_back(simchannel.AuxDetID(), simchannel.AuxDetSensitiveID());
114 it = merged_vector.end() - 1;
119 std::vector<sim::AuxDetIDE> all_ides = it->AuxDetIDEs();
121 all_ides.emplace_back(ide, offset);
123 auto tid =
std::abs(ide.trackID) + offset;
125 if (tid < range_trackID.first) range_trackID.first = tid;
126 if (tid > range_trackID.second) range_trackID.second = tid;
130 simchannel.AuxDetID(), std::move(all_ides), simchannel.AuxDetSensitiveID());
137 const std::vector<sim::SimPhotons>& input_vector)
140 merged_vector.reserve(merged_vector.size() + input_vector.size());
142 for (
auto const& simphotons : input_vector) {
144 std::find(merged_vector.begin(), merged_vector.end(), simphotons);
146 if (it == merged_vector.end()) {
147 merged_vector.emplace_back(simphotons.OpChannel());
148 it = merged_vector.end() - 1;
156 std::vector<sim::SimPhotonsLite>& merged_vector,
157 const std::vector<sim::SimPhotonsLite>& input_vector)
160 merged_vector.reserve(merged_vector.size() + input_vector.size());
162 for (
auto const& simphotons : input_vector) {
164 std::find(merged_vector.begin(), merged_vector.end(), simphotons);
166 if (it == merged_vector.end()) {
167 merged_vector.emplace_back(simphotons.OpChannel);
168 it = merged_vector.end() - 1;
176 std::vector<sim::SimEnergyDeposit>& dest,
177 const std::vector<sim::SimEnergyDeposit>& src,
178 std::size_t source_index)
const 186 dest.reserve(dest.size() + src.size());
187 std::transform(
begin(src),
end(src), back_inserter(dest), offsetEDepID);
191 const std::vector<sim::AuxDetHit>& src,
192 std::size_t source_index)
const 196 auto const offsetAuxDetHitID = [offset](
sim::AuxDetHit const& adh) {
200 dest.reserve(dest.size() + src.size());
201 std::transform(
begin(src),
end(src), back_inserter(dest), offsetAuxDetHitID);
205 std::vector<sim::ParticleAncestryMap>& dest,
207 std::size_t source_index)
const 211 dest.reserve(dest.size() + 1);
219 std::runtime_error(
"ERROR in MergeSimSourcesUtility: Source index out of range!");
226 if (i == source_index)
continue;
232 std::stringstream ss;
233 ss <<
"ERROR in MergeSimSourcesUtility: Source trackIDs overlap!" 236 <<
"n\t" << newrange.first <<
" " << newrange.second;
237 throw std::runtime_error(ss.str());
299 std::map<int, std::set<int>> newMap;
301 for (
auto const& [ancestor, descendants] : pam.
GetMap()) {
302 const int newAnc = (ancestor >= 0) ? ancestor + offset : ancestor - offset;
304 for (
auto const& descendant : descendants) {
305 const int newDesc = (descendant >= 0) ? descendant + offset : descendant - offset;
306 newMap[newAnc].insert(newDesc);
unsigned int GetTrackID() const
void MergeSimPhotonsLite(std::vector< sim::SimPhotonsLite > &, const std::vector< sim::SimPhotonsLite > &)
std::vector< std::pair< int, int > > fG4TrackIDRanges
void MergeSimChannels(std::vector< sim::SimChannel > &, const std::vector< sim::SimChannel > &, size_t)
void UpdateG4TrackIDRange(std::pair< int, int >, size_t)
static sim::ParticleAncestryMap offsetParticleAncestryMapTrackID(sim::ParticleAncestryMap const &, int)
MergeSimSourcesUtility(std::vector< int > const &)
void MergeSimPhotons(std::vector< sim::SimPhotons > &, const std::vector< sim::SimPhotons > &)
constexpr auto abs(T v)
Returns the absolute value of the argument.
static sim::SimEnergyDeposit offsetSimEnergyDepositTrackID(sim::SimEnergyDeposit const &, int)
void MergeAuxDetSimChannels(std::vector< sim::AuxDetSimChannel > &, const std::vector< sim::AuxDetSimChannel > &, size_t)
float GetExitMomentumY() const
void MergeAuxDetHits(std::vector< sim::AuxDetHit > &, const std::vector< sim::AuxDetHit > &, size_t) const
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Collection of particles crossing one auxiliary detector cell.
geo::Point_t Start() const
std::vector< int > fG4TrackIDOffsets
float GetEnergyDeposited() const
void MergeParticleAncestryMaps(std::vector< sim::ParticleAncestryMap > &, const sim::ParticleAncestryMap &, size_t) const
unsigned int GetID() const
void MergeMCParticles(std::vector< simb::MCParticle > &, const std::vector< simb::MCParticle > &, size_t)
float GetExitMomentumX() const
MC truth information to make RawDigits and do back tracking.
static sim::AuxDetHit offsetAuxDetHitTrackID(sim::AuxDetHit const &, int)
Energy deposition in the active material.
void MergeSimEnergyDeposits(std::vector< sim::SimEnergyDeposit > &, const std::vector< sim::SimEnergyDeposit > &, size_t) const
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
float GetExitMomentumZ() const
double ScintYieldRatio() const
std::map< int, std::set< int > > const & GetMap() const
std::vector< std::vector< size_t > > fMCParticleListMap