All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Namespaces | Functions
VertexChargeVacuum_module.cc File Reference
#include "art/Framework/Core/EDProducer.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/Handle.h"
#include "art/Framework/Principal/Run.h"
#include "art/Framework/Principal/SubRun.h"
#include "canvas/Utilities/InputTag.h"
#include "fhiclcpp/ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include "lardata/Utilities/AssociationUtil.h"
#include <memory>
#include "lardataobj/RecoBase/Wire.h"
#include "lardataobj/RecoBase/Vertex.h"
#include "lardataobj/RecoBase/Hit.h"
#include "lardataobj/RecoBase/SpacePoint.h"
#include "lardataobj/RecoBase/Cluster.h"
#include "larcore/Geometry/Geometry.h"
#include "larcore/CoreUtils/ServiceUtil.h"
#include "larcorealg/Geometry/GeometryCore.h"
#include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h"
#include "lardata/DetectorInfoServices/DetectorPropertiesService.h"
#include "lardataobj/RecoBase/Slice.h"
#include "lardataobj/RecoBase/Track.h"
#include "lardataobj/RecoBase/PFParticle.h"
#include "larreco/Calorimetry/CalorimetryAlg.h"
#include "larreco/Calorimetry/INormalizeCharge.h"
#include "larevt/SpaceCharge/SpaceCharge.h"
#include "larevt/SpaceChargeServices/SpaceChargeService.h"
#include "art/Utilities/make_tool.h"
#include "sbnobj/Common/Reco/VertexHit.h"
#include "sbncode/TPCReco/VertexStub/StubMergeAlgorithms.h"

Go to the source code of this file.

Classes

class  sbn::VertexChargeVacuum
 

Namespaces

 sbn
 This module creates Common Analysis Files.
 

Functions

 produces< art::Assns< recob::Slice, sbn::VertexHit > > ()
 
 produces< art::Assns< recob::Hit, sbn::VertexHit > > ()
 
 produces< art::Assns< recob::Vertex, sbn::VertexHit > > ()
 
std::array< float, 2 > HitVector (const recob::Hit &hit, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
 
std::array< float, 2 > VertexVector (const recob::Vertex &vert, const geo::PlaneID &plane, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
 
float Vert2HitDistance (const recob::Hit &hit, const recob::Vertex &vert, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
 
std::array< float, 2 > HitDirection (const std::vector< art::Ptr< recob::Hit >> &hits, const recob::Vertex &vert, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
 
float TrackDirectionParallel (const recob::Track &trk, const geo::PlaneID &plane, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
 
geo::Point_t PlaceHitAlongTrack (const recob::Track &trk, const recob::Vertex &vert, const recob::Hit &hit, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
 

Function Documentation

std::array<float, 2> HitDirection ( const std::vector< art::Ptr< recob::Hit >> &  hits,
const recob::Vertex vert,
const geo::GeometryCore geo,
const detinfo::DetectorPropertiesData dprop 
)

Definition at line 139 of file VertexChargeVacuum_module.cc.

140  {
141  if (!hits.size()) return {0., 0.};
142 
143  geo::Vector_t avg(0., 0., 0.);
144 
145  std::array<float, 2> vert_v = VertexVector(vert, hits[0]->WireID(), geo, dprop);
146  geo::Point_t vert_p(vert_v[0], vert_v[1], 0.);
147 
148  for (const art::Ptr<recob::Hit> &h: hits) {
149  std::array<float, 2> hit_v = HitVector(*h, geo, dprop);
150  geo::Point_t hit_p(hit_v[0], hit_v[1], 0.);
151  avg += (hit_p - vert_p).Unit();
152  }
153 
154  avg = avg.Unit();
155 
156  return {(float)avg.X(), (float)avg.Y()};
157 }
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
std::array< float, 2 > HitVector(const recob::Hit &hit, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
while getopts h
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:184
std::array< float, 2 > VertexVector(const recob::Vertex &vert, const geo::PlaneID &plane, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
std::array<float, 2> HitVector ( const recob::Hit hit,
const geo::GeometryCore geo,
const detinfo::DetectorPropertiesData dprop 
)

Definition at line 115 of file VertexChargeVacuum_module.cc.

115  {
116  float wire_distance = hit.WireID().Wire;
117  // convert to cm
118  float wire_distance_cm = wire_distance * geo->WirePitch();
119  // and the time difference
120  float time_distance = hit.PeakTime();
121  // convert to cm
122  float time_distance_cm = dprop.ConvertTicksToX(time_distance, hit.WireID());
123 
124  return {wire_distance_cm, time_distance_cm};
125 }
geo::WireID WireID() const
Definition: Hit.h:233
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
double ConvertTicksToX(double ticks, int p, int t, int c) const
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:218
geo::Point_t PlaceHitAlongTrack ( const recob::Track trk,
const recob::Vertex vert,
const recob::Hit hit,
const geo::GeometryCore geo,
const detinfo::DetectorPropertiesData dprop 
)

Definition at line 170 of file VertexChargeVacuum_module.cc.

171  {
172  // project the vertex onto the hit Plane
173  std::array<float, 2> v_plane = VertexVector(vert, hit.WireID(), geo, dprop);
174 
175  // also get the 2d hit location
176  std::array<float, 2> h_plane = HitVector(hit, geo, dprop);
177 
178  float t_dir_parallel_plane = TrackDirectionParallel(trk, hit.WireID(), geo, dprop);
179 
180  // Get the distance from the vertex to the hit on the plane.
181  //
182  // The track "should" be along the same direction as the vertex to the hit in the plane,
183  // so this distance is the same as the distance along the track
184  float plane_dist = (h_plane[0] - v_plane[0]) + (h_plane[1] - v_plane[1]);
185 
186  // Use this distance to place the hit along the track trajectory in 3D
187  float dist_3d = plane_dist / t_dir_parallel_plane;
188 
189  // std::cout << "Placing Hit\n";
190  // std::cout << "Hit wire: " << hit.WireID() << std::endl;
191  // std::cout << "Hit plane coord: " << h_plane[0] << " " << h_plane[1] << std::endl;
192  // std::cout << "Vtx plane coord: " << v_plane[0] << " " << v_plane[1] << std::endl;
193  // std::cout << "Trk dir: " << trk.StartDirection().x() << " " << trk.StartDirection().y() << " " << trk.StartDirection().z() << std::endl;
194  // std::cout << "Vtx pos: " << vert.position().x() << " " << vert.position().y() << " " << vert.position().z() << std::endl;
195 
196  // std::cout << "Trk parallel dir: " << t_dir_parallel_plane << std::endl;
197  // std::cout << "Hit plane dist: " << plane_dist << std::endl;
198  // std::cout << "Hit 3d dist: " << dist_3d << std::endl;
199 
200  geo::Vector_t trk_dir(trk.StartDirection().x(), trk.StartDirection().y(), trk.StartDirection().z());
201 
202  return vert.position() + trk_dir * dist_3d;
203 }
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
geo::WireID WireID() const
Definition: Hit.h:233
std::array< float, 2 > HitVector(const recob::Hit &hit, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
Vector_t StartDirection() const
Access to track direction at different points.
float TrackDirectionParallel(const recob::Track &trk, const geo::PlaneID &plane, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
std::array< float, 2 > VertexVector(const recob::Vertex &vert, const geo::PlaneID &plane, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
const Point_t & position() const
Return vertex 3D position.
Definition: Vertex.h:60
produces< art::Assns< recob::Hit, sbn::VertexHit > > ( )
produces< art::Assns< recob::Slice, sbn::VertexHit > > ( )
produces< art::Assns< recob::Vertex, sbn::VertexHit > > ( )
float TrackDirectionParallel ( const recob::Track trk,
const geo::PlaneID plane,
const geo::GeometryCore geo,
const detinfo::DetectorPropertiesData dprop 
)

Definition at line 159 of file VertexChargeVacuum_module.cc.

160  {
161  double angleToVert = geo->WireAngleToVertical(geo->View(plane), plane) - 0.5*::util::pi<>();
162  double cosgamma = std::abs(std::sin(angleToVert)*trk.StartDirection().y() + std::cos(angleToVert)*trk.StartDirection().z());
163 
164  float ret = sqrt(cosgamma * cosgamma + trk.StartDirection().x() * trk.StartDirection().x());
165 
166  return ret;
167 
168 }
T abs(T value)
Vector_t StartDirection() const
Access to track direction at different points.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
double WireAngleToVertical(geo::View_t view, geo::TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.
float Vert2HitDistance ( const recob::Hit hit,
const recob::Vertex vert,
const geo::GeometryCore geo,
const detinfo::DetectorPropertiesData dprop 
)

Definition at line 131 of file VertexChargeVacuum_module.cc.

131  {
132  std::array<float, 2> vert_v = VertexVector(vert, hit.WireID(), geo, dprop);
133  std::array<float, 2> hit_v = HitVector(hit, geo, dprop);
134 
135  return sqrt((vert_v[0] - hit_v[0]) * (vert_v[0] - hit_v[0]) + (vert_v[1] - hit_v[1]) * (vert_v[1] - hit_v[1]));
136 }
geo::WireID WireID() const
Definition: Hit.h:233
std::array< float, 2 > HitVector(const recob::Hit &hit, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
std::array< float, 2 > VertexVector(const recob::Vertex &vert, const geo::PlaneID &plane, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
std::array<float, 2> VertexVector ( const recob::Vertex vert,
const geo::PlaneID plane,
const geo::GeometryCore geo,
const detinfo::DetectorPropertiesData dprop 
)

Definition at line 127 of file VertexChargeVacuum_module.cc.

127  {
128  return {(float)(geo->WireCoordinate(vert.position(), plane) * geo->WirePitch()), (float)vert.position().X()};
129 }
geo::Length_t WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
const Point_t & position() const
Return vertex 3D position.
Definition: Vertex.h:60