LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
FilterCryostatNus_module.cc
Go to the documentation of this file.
1 
12 
13 // Framework includes
17 #include "fhiclcpp/ParameterSet.h"
18 
19 // LArSoft Includes
24 
25 // C++ Includes
26 #include <cmath> // std::abs()
27 
28 namespace simfilter {
29 
31  public:
32  explicit FilterCryostatNus(fhicl::ParameterSet const& pset);
33 
34  private:
35  bool filter(art::Event&) override;
36  bool fKeepNusInCryostat; // true: keep cryostat nuint; false: filter them
37  };
38 
39 } // namespace simfilter
40 
41 namespace simfilter {
42 
44  : EDFilter{pset}, fKeepNusInCryostat{pset.get<bool>("KeepNusInCryostat", false)}
45  {}
46 
48  {
49  // get the list of particles from this event
50  auto const& geom = *(lar::providerFrom<geo::Geometry>());
51 
52  //std::vector<art::Handle<std::vector<simb::MCTruth>>> allmclists;
53  //evt.getManyByType(allmclists);
54  auto allmclists = evt.getMany<std::vector<simb::MCTruth>>();
55 
56  bool inCryostatNu = false;
57  for (auto const& mclistHandle : allmclists) {
58  for (simb::MCTruth const& mct : *mclistHandle) {
59 
60  // get nu, does it end in cyrostat?
61  for (int ipart = 0; ipart < mct.NParticles(); ipart++) {
62  auto const& part = mct.GetParticle(ipart);
63  auto const absPDGID = std::abs(part.PdgCode());
64  if (absPDGID == 12 || absPDGID == 14 || absPDGID == 16) {
65  const TLorentzVector& end4 = part.EndPosition();
66  if (geom.PositionToCryostatPtr({end4.X(), end4.Y(), end4.Z()}) != nullptr) {
67  inCryostatNu = true;
68  }
69  } // if neutrino
70  } // for particles
71 
72  } // end loop over mctruth col
73 
74  } // end loop over all mctruth lists
75 
76  return fKeepNusInCryostat ^ (!inCryostatNu);
77  }
78 
79 } // namespace simfilter
80 
Utilities related to art service access.
Int_t ipart
Definition: Style.C:10
constexpr auto abs(T v)
Returns the absolute value of the argument.
Access the description of detector geometry.
TString part[npart]
Definition: Style.C:32
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:65
FilterCryostatNus(fhicl::ParameterSet const &pset)
bool filter(art::Event &) override
EDFilter(fhicl::ParameterSet const &pset)
Definition: EDFilter.cc:6
TCEvent evt
Definition: DataStructs.cxx:8
Event generator information.
Definition: MCTruth.h:32
Framework includes.
art framework interface to geometry description
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const