ProtoDUNEEmptyEventFinder.cxx
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 
5 
9 #include "canvas/Persistency/Common/FindManyP.h"
11 
13  fSpacePointLabel(pset.get<std::string>("SpacePointLabel","reco3d")),
14  fNHitsThreshold(pset.get<unsigned int>("NHitsThreshold",10)),
15  fMinCoordsData(pset.get<std::vector<float>>("MinCoordValuesData")),
16  fMaxCoordsData(pset.get<std::vector<float>>("MaxCoordValuesData")),
17  fMinCoordsSim(pset.get<std::vector<float>>("MinCoordValuesSim")),
18  fMaxCoordsSim(pset.get<std::vector<float>>("MaxCoordValuesSim"))
19 {
20 }
21 
23 {
24  // Get the space points
25  auto spacePointHandle = evt.getValidHandle<std::vector<recob::SpacePoint>>(fSpacePointLabel);
26  std::vector<art::Ptr<recob::SpacePoint>> spacePoints;
27  if(spacePointHandle.isValid())
28  art::fill_ptr_vector(spacePoints,spacePointHandle);
29 
30  const std::vector<float> minValues{evt.isRealData() ? fMinCoordsData : fMinCoordsSim};
31  const std::vector<float> maxValues{evt.isRealData() ? fMaxCoordsData : fMaxCoordsSim};
32 
33  // Now count the number of space points
34  unsigned int nBeamRegionSpacePoints{0};
35  for (const art::Ptr<recob::SpacePoint> &sp : spacePoints)
36  {
37  const double *xyz{sp->XYZ()};
38 
39  if(xyz[0] < minValues.at(0) || xyz[0] > maxValues.at(0)) continue;
40  if(xyz[1] < minValues.at(1) || xyz[1] > maxValues.at(1)) continue;
41  if(xyz[2] < minValues.at(2) || xyz[2] > maxValues.at(2)) continue;
42 
43  ++nBeamRegionSpacePoints;
44 
45  // If we reach the threshold then there is no point continuing
46  if (nBeamRegionSpacePoints >= fNHitsThreshold) return false;
47  }
48 
49  // If we get here then we didn't meet the threshold
50  return true;
51 }
52 
std::string string
Definition: nybbler.cc:12
STL namespace.
bool IsEmptyEvent(const art::Event &evt) const
bool isRealData() const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
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
ProtoDUNEEmptyEventFinder(const fhicl::ParameterSet &pset)