Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle Ancestry Map #45

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions larg4/Analysis/CheckMCParticle_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "art_root_io/TFileDirectory.h"
#include "art_root_io/TFileService.h"
#include "lardataobj/Simulation/ParticleAncestryMap.h"
#include "nusimdata/SimulationBase/MCParticle.h"

// Root includes.
Expand Down Expand Up @@ -57,14 +58,14 @@ void larg4::CheckMCParticle::analyze(const art::Event& event)
{
#if defined _verbose_

auto allDropped = event.getMany<std::map<int, std::set<int>>>();
auto allDropped = event.getMany<sim::ParticleAncestryMap>();

for (auto const& maps : allDropped) {
for (auto const& element : *maps) {
std::cout << "Parent of dropped Tracks: " << element.first << std::endl;
std::set<int> droppedset = element.second;
std::cout << " droppedid size: " << droppedset.size() << std::endl;
for (auto const& droppedid : droppedset) {
auto const& map = maps->GetMap();
for (auto const& [parent, daughters] : map) {
std::cout << "Parent of dropped Tracks: " << parent << std::endl;
std::cout << " droppedid size: " << daughters.size() << std::endl;
for (auto const& droppedid : daughters) {
std::cout << droppedid << " ";
}
std::cout << std::endl;
Expand Down
3 changes: 2 additions & 1 deletion larg4/Core/larg4Main_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// art extensions
#include "lardataalg/MCDumpers/MCDumpers.h"
#include "lardataobj/Simulation/GeneratedParticleInfo.h"
#include "lardataobj/Simulation/ParticleAncestryMap.h"
#include "nug4/ParticleNavigation/ParticleList.h"
#include "nurandom/RandomUtils/NuRandomService.h"
// Geant4 includes
Expand Down Expand Up @@ -136,7 +137,7 @@ larg4::larg4Main::larg4Main(fhicl::ParameterSet const& p)
, uiAtBeginRun_(p.get<bool>("uiAtBeginRun", false))
, afterEvent_(p.get<std::string>("afterEvent", "pass"))
{
produces<std::map<int, std::set<int>>>();
produces<sim::ParticleAncestryMap>();
produces<std::vector<simb::MCParticle>>();
produces<art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo>>();

Expand Down
6 changes: 2 additions & 4 deletions larg4/pluginActions/ParticleListAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ namespace larg4 {
}

partCol_ = std::make_unique<std::vector<simb::MCParticle>>();
droppedCol_ = std::make_unique<std::map<int, std::set<int>>>();
droppedCol_ = std::make_unique<sim::ParticleAncestryMap>();
tpassn_ =
std::make_unique<art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo>>();
// Set up the utility class for the "for_each" algorithm. (We only
Expand Down Expand Up @@ -725,9 +725,7 @@ namespace larg4 {
tpassn_->addSingle(mct, mcp_ptr, truthInfo);
}
mf::LogDebug("Offset") << "nGeneratedParticles = " << nGeneratedParticles;
for (auto const& dropped : fdroppedTracksMap) {
droppedCol_->insert(dropped);
}
droppedCol_->SetMap(fdroppedTracksMap);
++nMCTruths;
}
}
Expand Down
5 changes: 3 additions & 2 deletions larg4/pluginActions/ParticleListAction_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "art/Framework/Services/Registry/ServiceDeclarationMacros.h"

#include "lardataobj/Simulation/GeneratedParticleInfo.h"
#include "lardataobj/Simulation/ParticleAncestryMap.h"

#include "artg4tk/actionBase/EventActionBase.hh"
#include "artg4tk/actionBase/SteppingActionBase.hh"
Expand Down Expand Up @@ -99,7 +100,7 @@ namespace larg4 {
{
return std::move(partCol_);
}
std::unique_ptr<std::map<int, std::set<int>>> DroppedTracksCollection()
std::unique_ptr<sim::ParticleAncestryMap> DroppedTracksCollection()
{
return std::move(droppedCol_);
}
Expand Down Expand Up @@ -197,7 +198,7 @@ namespace larg4 {
std::map<int, std::set<int>> fdroppedTracksMap;

std::unique_ptr<std::vector<simb::MCParticle>> partCol_;
std::unique_ptr<std::map<int, std::set<int>>> droppedCol_;
std::unique_ptr<sim::ParticleAncestryMap> droppedCol_;
std::unique_ptr<art::Assns<simb::MCTruth, simb::MCParticle, sim::GeneratedParticleInfo>>
tpassn_;
art::ProductID pid_{art::ProductID::invalid()};
Expand Down