LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
FilterPrimaryPDG_module.cc
Go to the documentation of this file.
1
9
#include "
art/Framework/Core/EDFilter.h
"
10
#include "
art/Framework/Core/ModuleMacros.h
"
11
12
// Framework includes
13
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
14
#include "
fhiclcpp/ParameterSet.h
"
15
#include "
messagefacility/MessageLogger/MessageLogger.h
"
16
17
// LArSoft Includes
18
#include "
larcore/Geometry/Geometry.h
"
19
#include "
lardataobj/Simulation/sim.h
"
20
#include "
larsim/MCCheater/ParticleInventoryService.h
"
21
#include "
nug4/ParticleNavigation/ParticleList.h
"
22
24
namespace
simfilter
{
25
26
class
FilterPrimaryPDG
:
public
art::EDFilter
{
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
43
FilterPrimaryPDG::FilterPrimaryPDG
(
fhicl::ParameterSet
const
& pset)
44
:
EDFilter
{pset},
fPrimaryVec
{pset.get<std::vector<int>>(
"PrimaryParticles"
)}
45
{}
46
47
//-----------------------------------------------------------------------
48
bool
FilterPrimaryPDG::filter
(
art::Event
&
evt
)
49
{
50
51
//get the list of particles from this event
52
art::ServiceHandle<cheat::ParticleInventoryService const>
pi_serv;
53
art::ServiceHandle<geo::Geometry const>
geom;
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
88
DEFINE_ART_MODULE
(
FilterPrimaryPDG
)
89
90
}
// namespace simfilter
simfilter::FilterPrimaryPDG::filter
bool filter(art::Event &) override
Definition:
FilterPrimaryPDG_module.cc:48
art::ServiceHandle< cheat::ParticleInventoryService const >
art::EDFilter
Definition:
EDFilter.h:16
mf::LogInfo
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Definition:
MessageLogger.h:209
ParticleInventoryService.h
MessageLogger.h
ParameterSet.h
ServiceHandle.h
simfilter::FilterPrimaryPDG::FilterPrimaryPDG
FilterPrimaryPDG(fhicl::ParameterSet const &pset)
Definition:
FilterPrimaryPDG_module.cc:43
DEFINE_ART_MODULE
#define DEFINE_ART_MODULE(klass)
Definition:
ModuleMacros.h:65
EDFilter.h
simfilter::FilterPrimaryPDG::fPrimaryVec
std::vector< int > fPrimaryVec
Definition:
FilterPrimaryPDG_module.cc:34
ModuleMacros.h
simfilter::FilterPrimaryPDG
Definition:
FilterPrimaryPDG_module.cc:26
cheat::ParticleInventoryService::ParticleList
const sim::ParticleList & ParticleList() const
Definition:
ParticleInventoryService.cc:138
art::Event
Definition:
Event.h:26
simfilter::FilterPrimaryPDG::fG4ModuleLabel
std::string fG4ModuleLabel
Definition:
FilterPrimaryPDG_module.cc:33
art::EDFilter::EDFilter
EDFilter(fhicl::ParameterSet const &pset)
Definition:
EDFilter.cc:6
tca::evt
TCEvent evt
Definition:
DataStructs.cxx:8
simfilter
Framework includes.
Definition:
FilterCryostatNus_module.cc:28
ParticleList.h
Particle list in DetSim contains Monte Carlo particle information.
sim::ParticleList::size
size_type size() const
Definition:
ParticleList.h:313
sim.h
Tools and modules for checking out the basics of the Monte Carlo.
Geometry.h
art framework interface to geometry description
Particles
Definition:
Particles.hh:42
fhicl::ParameterSet
Definition:
ParameterSet.h:36
sim::ParticleList
Definition:
ParticleList.h:122
larsim
v09_43_00
source
larsim
SimFilters
FilterPrimaryPDG_module.cc
Generated on Thu May 2 2024 20:59:52 for LArSoft by
1.8.11