forked from DeepLearnPhysics/Supera
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MCParticleFilter_module.cc
80 lines (65 loc) · 2.38 KB
/
MCParticleFilter_module.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
////////////////////////////////////////////////////////////////////////
// Class: MCParticleFilter
// Module Type: filter
// File: MCParticleFilter_module.cc
//
// Generated at Tue Sep 24 10:45:04 2019 by Ka Vang Tsang using artmod
// from cetpkgsupport v1_14_01.
////////////////////////////////////////////////////////////////////////
#include "art/Framework/Core/EDFilter.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/Handle.h"
#include "art/Framework/Principal/Run.h"
#include "art/Framework/Principal/SubRun.h"
//#include "art/Utilities/InputTag.h"
#include "fhiclcpp/ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include <memory>
#include <string>
#include <vector>
#include <set>
#include "nusimdata/SimulationBase/MCParticle.h"
namespace supera {
class MCParticleFilter;
}
class supera::MCParticleFilter : public art::EDFilter {
public:
explicit MCParticleFilter(fhicl::ParameterSet const & p);
// The destructor generated by the compiler is fine for classes
// without bare pointers or other resource use.
// Plugins should not be copied or assigned.
MCParticleFilter(MCParticleFilter const &) = delete;
MCParticleFilter(MCParticleFilter &&) = delete;
MCParticleFilter & operator = (MCParticleFilter const &) = delete;
MCParticleFilter & operator = (MCParticleFilter &&) = delete;
// Required functions.
bool filter(art::Event & e) override;
private:
// Declare member data here.
std::string _g4_label;
std::set<int> _pdg_set;
};
supera::MCParticleFilter::MCParticleFilter(fhicl::ParameterSet const & pset)
: art::EDFilter(pset)
{
_g4_label = pset.get<std::string>("LArG4ModuleLabel", "largeant");
// TODO: Assgin std::set from pset.get?
std::vector<int> v_pdg = pset.get<decltype(v_pdg)>("PDGCodes");
_pdg_set = decltype(_pdg_set)(v_pdg.begin(), v_pdg.end());
// Call appropriate produces<>() functions here.
}
bool supera::MCParticleFilter::filter(art::Event & e)
{
// Implementation of required member function here.
typedef std::vector<simb::MCParticle> MCParticles;
auto const& mc_parts = *e.getValidHandle<MCParticles>(_g4_label);
for (auto const& p : mc_parts) {
auto const& itr = _pdg_set.find(p.PdgCode());
if (itr != _pdg_set.end()) {
return true;
}
}
return false;
}
DEFINE_ART_MODULE(supera::MCParticleFilter)