FilterCryostatNus_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file FilterCryostatNus_module.cc
3 /// \brief EDFilter to require projected generator trajectories in volumes
4 /// within a particular time window.
5 ///
6 /// \author Matthew.Bass@physics.ox.ac.uk
7 ////////////////////////////////////////////////////////////////////////
8 
9 /// Framework includes
12 
13 // Framework includes
17 #include "fhiclcpp/ParameterSet.h"
18 
19 // LArSoft Includes
23 
24 // C++ Includes
25 #include <cmath> // std::abs()
26 
27 namespace simfilter {
28 
30  public:
31  explicit FilterCryostatNus(fhicl::ParameterSet const& pset);
32 
33  private:
34  bool filter(art::Event&) override;
35  bool fKeepNusInCryostat; // true: keep cryostat nuint; false: filter them
36  };
37 
38 } // namespace simfilter
39 
40 namespace simfilter {
41 
43  : EDFilter{pset}
44  , fKeepNusInCryostat{pset.get<bool>("KeepNusInCryostat", false)}
45  {}
46 
47  bool
49  {
50  // get the list of particles from this event
51  auto const& geom = *(lar::providerFrom<geo::Geometry>());
52 
53  //std::vector<art::Handle<std::vector<simb::MCTruth>>> allmclists;
54  //evt.getManyByType(allmclists);
55  auto allmclists = evt.getMany<std::vector<simb::MCTruth>>();
56 
57  bool inCryostatNu = false;
58  for (auto const& mclistHandle : allmclists) {
59  for (simb::MCTruth const& mct : *mclistHandle) {
60 
61  // get nu, does it end in cyrostat?
62  for (int ipart = 0; ipart < mct.NParticles(); ipart++) {
63  auto const& part = mct.GetParticle(ipart);
64  auto const absPDGID = std::abs(part.PdgCode());
65  if (absPDGID == 12 || absPDGID == 14 || absPDGID == 16) {
66  const TLorentzVector& end4 = part.EndPosition();
67  if (geom.PositionToCryostatPtr({end4.X(), end4.Y(), end4.Z()}) !=
68  nullptr) {
69  inCryostatNu = true;
70  }
71  } // if neutrino
72  } // for particles
73 
74  } // end loop over mctruth col
75 
76  } // end loop over all mctruth lists
77 
78  return fKeepNusInCryostat ^ (!inCryostatNu);
79  }
80 
81 } // namespace simfilter
82 
art framework interface to geometry description
T abs(T value)
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:67
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
Definition: DataViewImpl.h:479
FilterCryostatNus(fhicl::ParameterSet const &pset)
bool filter(art::Event &) override
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.h:21
Access the description of detector geometry.
TCEvent evt
Definition: DataStructs.cxx:7
Event generator information.
Definition: MCTruth.h:32
Framework includes.