LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
FilterPrimaryPDG_module.cc
Go to the documentation of this file.
1 
11 
12 // Framework includes
14 #include "fhiclcpp/ParameterSet.h"
16 
17 // LArSoft Includes
22 
24 namespace simfilter {
25 
27  public:
28  explicit FilterPrimaryPDG(fhicl::ParameterSet const& pset);
29 
30  private:
31  bool filter(art::Event&) override;
32 
33  std::string fG4ModuleLabel;
34  std::vector<int> fPrimaryVec;
35  };
36 
37 } // namespace simfilter
38 
39 namespace simfilter {
40 
41  //-----------------------------------------------------------------------
42  // Constructor
44  : EDFilter{pset}, fPrimaryVec{pset.get<std::vector<int>>("PrimaryParticles")}
45  {}
46 
47  //-----------------------------------------------------------------------
49  {
50 
51  //get the list of particles from this event
54 
55  // get the particles from the back tracker
56  const sim::ParticleList& Particles = pi_serv->ParticleList();
57  std::vector<const simb::MCParticle*> pvec;
58  pvec.reserve(Particles.size());
59  for (const auto& PartPair : Particles) {
60  pvec.push_back(PartPair.second);
61  // fPDGCodes->Fill(PartPair.second->PdgCode());
62  }
63 
64  bool pdgDesired(false);
65  for (unsigned int i = 0; i < pvec.size(); ++i) {
66  for (int pdg : fPrimaryVec) {
67  const std::string sprim("primary");
68  if (pvec[i]->PdgCode() == pdg) {
69  Char_t tProcess[50];
70  for (unsigned int s = 0; s < pvec[i]->Process().length(); ++s)
71  *(tProcess + s) = pvec[i]->Process()[s];
72  std::string sProcess(tProcess);
73  if (!sProcess.compare(sprim)) {
74  mf::LogInfo("FilterPrimaryPDG") << " Found a primary " << pdg << " in event.";
75  pdgDesired = true;
76  }
77  }
78  }
79  }
80 
81  return pdgDesired;
82  }
83 
84 } // namespace simfilter
85 
86 namespace simfilter {
87 
89 
90 } // namespace simfilter
bool filter(art::Event &) override
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
FilterPrimaryPDG(fhicl::ParameterSet const &pset)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
const sim::ParticleList & ParticleList() const
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.cc:6
TCEvent evt
Definition: DataStructs.cxx:8
Framework includes.
Particle list in DetSim contains Monte Carlo particle information.
size_type size() const
Definition: ParticleList.h:313
Tools and modules for checking out the basics of the Monte Carlo.
art framework interface to geometry description