397 if (hits.empty())
return false;
399 std::vector<std::vector<Pt2D>> pts;
400 std::vector<TVector3> dirs;
406 double minz[3] = {+1e9, +1e9, +1e9};
407 double maxz[3] = {-1e9, -1e9, -1e9};
408 for (
int view = 0; view < 3; ++view) {
409 for (
const Pt2D&
p : pts[view]) {
410 minx = std::min(minx,
p.x);
411 maxx = std::max(maxx,
p.x);
412 minz[view] = std::min(minz[view],
p.z);
413 maxz[view] = std::max(maxz[view],
p.z);
418 for (
int view = 0; view < 3; ++view) {
427 std::vector<float> zs;
428 zs.reserve(pts[0].
size());
429 for (
const Pt2D&
p : pts[0])
431 auto mid = zs.begin() + zs.size() / 4;
432 if (mid != zs.end()) {
433 std::nth_element(zs.begin(), mid, zs.end());
437 std::vector<HeatMap> hms;
439 for (
int view = 0; view < 3; ++view) {
440 if (pts[view].
empty())
return false;
442 std::vector<Line2D> lines;
445 if (lines.empty())
return false;
448 hms.emplace_back(maxz[view] - minz[view], minz[view], maxz[view], maxx - minx, minx, maxx);
454 std::vector<HeatMap> hms_zoom;
456 for (
int view = 0; view < 3; ++view) {
457 const double x0 = vtx.X();
458 const double z0 = vtx.Dot(dirs[view]);
460 std::vector<Line2D> lines;
463 if (lines.empty())
return false;
466 hms_zoom.emplace_back(50, z0 - 2.5, z0 + 2.5, 50, x0 - 2.5, x0 + 2.5);
474 art::TFileDirectory evt_dir =
475 art::ServiceHandle<art::TFileService>()->
mkdir(TString::Format(
"evt%d",
evt).Data());
477 for (
int view = 0; view < 3; ++view) {
478 art::TFileDirectory view_dir = evt_dir.mkdir(TString::Format(
"view%d", view).
Data());
480 TGraph* gpts = view_dir.makeAndRegister<TGraph>(
"hits",
"");
481 for (
const Pt2D&
p : pts[view])
482 gpts->SetPoint(gpts->GetN(),
p.z,
p.x);
484 view_dir.makeAndRegister<TH2F>(
"hmap",
"", *hms[view].AsTH2());
486 view_dir.makeAndRegister<TH2F>(
"hmap_zoom",
"", *hms_zoom[view].AsTH2());
488 const double x = vtx.X();
489 const double z = vtx.Dot(dirs[view]);
490 view_dir.makeAndRegister<TGraph>(
"vtx3d",
"", 1, &
z, &
x);
process_name opflash particleana ie ie ie z
void GetPts2D(const detinfo::DetectorPropertiesData &detProp, const std::vector< recob::Hit > &hits, std::vector< std::vector< Pt2D >> &pts, std::vector< TVector3 > &dirs, const geo::GeometryCore *geom)
TVector3 FindPeak3D(const std::vector< HeatMap > &hs, const std::vector< TVector3 > &dirs) noexcept
process_name opflash particleana ie x
std::size_t size(FixedBins< T, C > const &) noexcept
void MapFromLines(const std::vector< Line2D > &lines, HeatMap &hm)
void LinesFromPoints(const std::vector< Pt2D > &pts, std::vector< Line2D > &lines, float z0=0, float x0=0, float R=-1)
const geo::GeometryCore * geom
bool empty(FixedBins< T, C > const &) noexcept