Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
larsim
larsim
SimFilters
FilterStoppingMuon_module.cc
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
/// \file FilterStoppingMuon_module.cc
3
/// \brief Simple EDFilter to require muon to stop in the TPC
4
///
5
/// \author dcaratelli@nevis.columbia.edu
6
////////////////////////////////////////////////////////////////////////
7
8
/// Framework includes
9
#include "
art/Framework/Core/ModuleMacros.h
"
10
#include "
art/Framework/Core/SharedFilter.h
"
11
#include "
art/Framework/Principal/Event.h
"
12
#include "
art/Framework/Principal/Handle.h
"
13
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
14
#include "
fhiclcpp/ParameterSet.h
"
15
16
// LArSoft Includes
17
#include "
larcore/Geometry/Geometry.h
"
18
#include "
nusimdata/SimulationBase/MCParticle.h
"
19
20
// C++ Includes
21
#include <iostream>
22
23
namespace
{
24
25
struct
bounds
{
26
double
minBound;
27
double
maxBound;
28
};
29
30
inline
bool
31
within(
bounds
const
& bnds,
double
const
value
)
32
{
33
return
bnds.minBound < value and value < bnds.maxBound;
34
}
35
36
class
FilterStoppingMuon :
public
art::SharedFilter
{
37
public
:
38
explicit
FilterStoppingMuon(
fhicl::ParameterSet
const
& pset,
39
art::ProcessingFrame
const
&);
40
41
private
:
42
void
beginRun(
art::Run
&,
art::ProcessingFrame
const
&)
override
;
43
bool
filter
(
art::Event
&,
art::ProcessingFrame
const
&)
override
;
44
std::string
const
fLArG4ModuleLabel;
45
bounds
fXBounds{};
46
bounds
fYBounds{};
47
bounds
fZBounds{};
48
};
49
50
//-----------------------------------------------------------------------
51
// Constructor
52
FilterStoppingMuon::FilterStoppingMuon(
fhicl::ParameterSet
const
& pset,
53
art::ProcessingFrame
const
&)
54
: SharedFilter{pset}
55
, fLArG4ModuleLabel{pset.
get
<
std::string
>(
"LArG4ModuleLabel"
,
"largeant"
)}
56
{
57
async<art::InEvent>();
58
}
59
60
void
61
FilterStoppingMuon::beginRun(
art::Run
&,
art::ProcessingFrame
const
& frame)
62
{
63
// Detector geometries are allowed to change on run boundaries.
64
auto
const
geom = frame.
serviceHandle
<
geo::Geometry
const
>();
65
fXBounds = {0., 2. * geom->
DetHalfWidth
()};
66
fYBounds = {-geom->DetHalfHeight(), geom->DetHalfHeight()};
67
fZBounds = {0., geom->DetLength()};
68
}
69
70
//-----------------------------------------------------------------------
71
bool
72
FilterStoppingMuon::filter
(
art::Event
&
evt
,
art::ProcessingFrame
const
&)
73
{
74
// get the particles produced by largeant
75
auto
const
& mcps =
76
*evt.
getValidHandle
<std::vector<simb::MCParticle>>(fLArG4ModuleLabel);
77
78
for
(
auto
const
& part : mcps) {
79
// skip anything that isn't a muon
80
if
(
std::abs
(part.PdgCode()) != 13) {
81
continue
;
82
}
83
84
// make sure the end position is inside the TPC
85
if
(within(fXBounds, part.EndX()) and within(fYBounds, part.EndY()) and
86
within(fZBounds, part.EndZ())) {
87
// we found a stopping muon -> return true (keep this event)
88
// N.B. Printing this out during multi-threaded execution may
89
// result in mangled printouts. If that is a problem, then
90
// these printouts should be made only if a 'debug' mode is
91
// specified, in which case 'serialize()' would be called
92
// instead of 'async'.
93
std::cout <<
"************* IN TPC *******************"
<<
std::endl
;
94
return
true
;
95
}
96
97
}
// for all mcparticles
98
99
return
false
;
100
101
}
// end FilterStoppingMuon()function
102
103
}
104
105
DEFINE_ART_MODULE
(FilterStoppingMuon)
geo::GeometryCore::DetHalfWidth
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
Definition:
GeometryCore.cxx:752
Handle.h
string
std::string string
Definition:
nybbler.cc:12
art::SharedFilter
Definition:
SharedFilter.h:17
SharedFilter.h
MCParticle.h
Particle class.
Geometry.h
art framework interface to geometry description
art::Run
Definition:
Run.h:17
ParameterSet.h
ServiceHandle.h
abs
T abs(T value)
Definition:
sparse_vector_test.cc:30
DEFINE_ART_MODULE
#define DEFINE_ART_MODULE(klass)
Definition:
ModuleMacros.h:67
art::ProcessingFrame::serviceHandle
ServiceHandle< T > serviceHandle() const
Definition:
ProcessingFrame.h:14
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:271
art::ProcessingFrame
Definition:
ProcessingFrame.h:8
art::DataViewImpl::getValidHandle
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition:
DataViewImpl.h:441
geo::Geometry
The geometry of one entire detector, as served by art.
Definition:
Geometry.h:196
ModuleMacros.h
bounds
BoundingBox bounds(int x, int y, int w, int h)
Definition:
main.cpp:37
art::Event
Definition:
Event.h:22
filter
static unsigned filter(unsigned char *out, const unsigned char *in, unsigned w, unsigned h, const LodePNG_InfoColor *info)
Definition:
lodepng.cpp:3576
tca::evt
TCEvent evt
Definition:
DataStructs.cxx:7
Event.h
submit_mcc.value
value
Definition:
submit_mcc.py:159
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11