FiducialCutVarExtractor.cxx
Go to the documentation of this file.
3 
4 namespace VLN {
5 
6 static const std::vector<std::string> SCALAR_VARS({ "vtxContain" });
7 static const std::vector<std::string> VECTOR_VARS({});
8 
10  const std::string &prefix,
11  const fhicl::ParameterSet &pset,
12  const std::string &labelGenerator
13 )
15  labelGenerator(labelGenerator),
16  containVolMaxX(pset.get<double>("ContainVolMaxX")),
17  containVolMaxY(pset.get<double>("ContainVolMaxY")),
18  containVolMinZ(pset.get<double>("ContainVolMinZ")),
19  containVolMaxZ(pset.get<double>("ContainVolMaxZ"))
20 { }
21 
23 {
24  std::vector<art::Ptr<simb::MCTruth>> mcTruth;
25 
26  auto mcTruth_h = evt.getHandle<std::vector<simb::MCTruth>>(labelGenerator);
27  if (!mcTruth_h) {
28  return;
29  }
30 
31  art::fill_ptr_vector(mcTruth, mcTruth_h);
32  if (mcTruth.empty()) {
33  return;
34  }
35 
36  const auto &nu = mcTruth[0]->GetNeutrino();
37 
38  auto vtxX = nu.Nu().Vx();
39  auto vtxY = nu.Nu().Vy();
40  auto vtxZ = nu.Nu().Vz();
41 
42  setScalarVar(vars, "vtxContain",
43  (
44  (std::abs(vtxX) < containVolMaxX)
45  && (std::abs(vtxY) < containVolMaxY)
46  && (vtxZ > containVolMinZ) && (vtxZ < containVolMaxZ)
47  )
48  );
49 }
50 
51 }
52 
static const std::vector< std::string > VECTOR_VARS({})
void extractVars(const art::Event &evt, VarDict &vars) override
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
Definition: VarDict.h:8
T abs(T value)
static const std::vector< std::string > SCALAR_VARS({"run","subRun","event"})
Definition: utils.cxx:6
void setScalarVar(VarDict &vars, const std::string &name, double value) const
FiducialCutVarExtractor(const std::string &prefix, const fhicl::ParameterSet &pset, const std::string &labelGenerator="generator")
TCEvent evt
Definition: DataStructs.cxx:7
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297