Skip to content

Commit

Permalink
Merge pull request #1389 from edcallaghan/straw_digi_merging_pass_by_…
Browse files Browse the repository at this point in the history
…reference

More performant straw digi collision resolution
  • Loading branch information
brownd1978 authored Dec 13, 2024
2 parents e5a4f9b + e61a9e2 commit 86ef8c7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Blinding/src/MergeDigis_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ namespace mu2e{
bundles.Append(*digi_handle, *adcs_handle);
}
const auto& electronics = _tracker_conditions_handle.get(event.id());
StrawDigiBundleCollection resolved = bundles.ResolveCollisions(electronics);
StrawDigiBundleCollection resolved;
bundles.ResolveCollisions(electronics, resolved);
auto digis = resolved.GetStrawDigiPtrs();
auto adcs = resolved.GetStrawDigiADCWaveformPtrs();
event.put(std::move(digis));
Expand Down
4 changes: 2 additions & 2 deletions TrackerMC/inc/StrawDigiBundleCollection.hh
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ namespace mu2e{

// identify sets of digis with overlapping digitization windows, and
// reduce each such set to a single digi, representing their "sum"
StrawDigiBundleCollection ResolveCollisions(const StrawElectronics& conditions);
void ResolveCollisions(const StrawElectronics& conditions, StrawDigiBundleCollection& rv);
protected:
std::vector<StrawDigiBundle> _bundles;
StrawDigiBundleCollection ResolveCollision(StrawDigiBundleCollection& collided);
void ResolveCollision(StrawDigiBundleCollection& collided, StrawDigiBundleCollection& rv);
private:
/**/
};
Expand Down
12 changes: 3 additions & 9 deletions TrackerMC/src/StrawDigiBundleCollection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ namespace mu2e{
return rv;
}

StrawDigiBundleCollection StrawDigiBundleCollection::ResolveCollisions(const StrawElectronics& conditions){
void StrawDigiBundleCollection::ResolveCollisions(const StrawElectronics& conditions, StrawDigiBundleCollection& rv){
// identify time-overlapped chains: this is a 3 step process
// first, partition bundles according to StrawId
std::map<StrawId, StrawDigiBundleCollection> unsorted_map;
Expand Down Expand Up @@ -200,29 +200,23 @@ namespace mu2e{

// finally, recast each bucket as a regular container
// and resolve the set of degenerate digis into one
StrawDigiBundleCollection rv;
for (const auto& pair: buckets_map){
const auto& buckets = pair.second;
for (const auto& bucket: buckets){
StrawDigiBundleCollection bundles;
for (const auto& bundle: bucket){
bundles.Append(bundle);
}
auto resolved = this->ResolveCollision(bundles);
rv += resolved;
this->ResolveCollision(bundles, rv);
}
}

return rv;
}

StrawDigiBundleCollection StrawDigiBundleCollection::ResolveCollision(StrawDigiBundleCollection& collided){
StrawDigiBundleCollection rv;
void StrawDigiBundleCollection::ResolveCollision(StrawDigiBundleCollection& collided, StrawDigiBundleCollection& rv){
auto first = collided[0];
// update StrawDigiMC component to reflect that the MC information may be tainted or incomplete
auto mc = StrawDigiMC(first.GetStrawDigiMC(), first.GetStrawDigiMC().provenance());
auto updated = StrawDigiBundle(first.GetStrawDigi(), first.GetStrawDigiADCWaveform(), mc);
rv.Append(updated);
return rv;
}
}
3 changes: 2 additions & 1 deletion TrackerMC/src/StrawDigisFromStrawGasSteps_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ namespace mu2e {
bundles.Append(*digis, *digiadcs, *mcdigis);

// resolve collisions between any preexisting and new digis
StrawDigiBundleCollection resolved = bundles.ResolveCollisions(strawele);
StrawDigiBundleCollection resolved;
bundles.ResolveCollisions(strawele, resolved);
digis = resolved.GetStrawDigiPtrs();
digiadcs = resolved.GetStrawDigiADCWaveformPtrs();
mcdigis = resolved.GetStrawDigiMCPtrs();
Expand Down

0 comments on commit 86ef8c7

Please sign in to comment.