23 : caloAlg(p.
get<
fhicl::ParameterSet>(
"CalorimetryAlg"))
31 std::vector<recob::Track>
const& trackVector,
32 std::vector<recob::Hit>
const& hitVector,
33 std::vector<std::vector<size_t>>
const& hit_indices_per_track,
34 std::vector<anab::Calorimetry>& caloVector,
35 std::vector<size_t>& assnTrackCaloVector,
39 for (
size_t i_track = 0; i_track < trackVector.size(); i_track++) {
45 std::vector<std::vector<size_t>> hit_indices_per_plane(wireReadoutGeom.
Nplanes());
46 for (
auto const& i_hit : hit_indices_per_track[i_track])
47 hit_indices_per_plane[hitVector[i_hit].WireID().Plane].push_back(i_hit);
50 for (
unsigned int i_plane = 0; i_plane < wireReadoutGeom.
Nplanes(); ++i_plane) {
54 std::vector<std::pair<geo::WireID, float>> traj_points_in_plane(
59 traj_points_in_plane[i_trjpt] = std::make_pair(
65 for (
auto const& i_hit : hit_indices_per_plane[i_plane])
71 path_length_fraction_vec,
72 HitPropertiesMultiset,
76 HitPropertiesMultiset, track, i_track, caloVector, assnTrackCaloVector, planeID);
87 :
hit(h), wireReadoutGeom(wireReadoutGeom)
89 bool operator()(std::pair<geo::WireID, float>
const& i, std::pair<geo::WireID, float>
const& j)
91 float dw_i = ((int)(i.first.Wire) - (int)(
hit.WireID().Wire)) *
92 wireReadoutGeom.Plane(i.first.asPlaneID()).WirePitch();
93 float dw_j = ((int)(j.first.Wire) - (int)(
hit.WireID().Wire)) *
94 wireReadoutGeom.Plane(j.first.asPlaneID()).WirePitch();
95 float dt_i = i.second -
hit.PeakTime();
96 float dt_j = j.second -
hit.PeakTime();
97 return std::hypot(dw_i, dt_i) < std::hypot(dw_j, dt_j);
110 float cumulative_path_length = 0;
111 const float total_path_length = track.
Length();
114 trk_path_length_frac_vec[i_trj] = cumulative_path_length / total_path_length;
117 return trk_path_length_frac_vec;
125 std::vector<std::pair<geo::WireID, float>>
const& traj_points_in_plane,
126 std::vector<float>
const& path_length_fraction_vec,
130 size_t traj_iter = std::distance(traj_points_in_plane.begin(),
131 std::min_element(traj_points_in_plane.begin(),
132 traj_points_in_plane.end(),
137 HitPropertiesMultiset.emplace(hit.
Integral(),
142 path_length_fraction_vec[traj_iter]);
150 float charge_start = 0, charge_end = 0;
153 charge_start += (*it_hpm).charge;
159 for (HitPropertiesMultiset_t::reverse_iterator it_hpm = hpm.rbegin(); it_hpm != hpm.rend();
161 charge_end += (*it_hpm).charge;
166 return charge_start > charge_end;
171 size_t const& i_track,
172 std::vector<anab::Calorimetry>& caloVector,
173 std::vector<size_t>& assnTrackCaloVector,
176 size_t n_hits = hpm.size();
177 std::vector<float> dEdxVector, dQdxVector, resRangeVector, deadWireVector, pitchVector;
178 std::vector<TVector3> XYZVector;
180 dEdxVector.reserve(n_hits);
181 dQdxVector.reserve(n_hits);
182 resRangeVector.reserve(n_hits);
183 deadWireVector.reserve(n_hits);
184 pitchVector.reserve(n_hits);
185 XYZVector.reserve(n_hits);
187 float kinetic_energy = 0, track_length = track.
Length();
189 for (
auto it_hpm = hpm.begin(); it_hpm != hpm.end(); ++it_hpm) {
190 dEdxVector.push_back(it_hpm->dEdx);
191 dQdxVector.push_back(it_hpm->dQdx);
192 resRangeVector.push_back(it_hpm->path_fraction * track_length);
193 pitchVector.push_back(it_hpm->pitch);
194 XYZVector.push_back(it_hpm->xyz);
195 kinetic_energy += dEdxVector.back() * pitchVector.back();
199 for (
auto it_hpm = hpm.rbegin(); it_hpm != hpm.rend(); ++it_hpm) {
200 dEdxVector.push_back(it_hpm->dEdx);
201 dQdxVector.push_back(it_hpm->dQdx);
202 resRangeVector.push_back((1 - it_hpm->path_fraction) * track_length);
203 pitchVector.push_back(it_hpm->pitch);
204 XYZVector.push_back(it_hpm->xyz);
205 kinetic_energy += dEdxVector.back() * pitchVector.back();
209 caloVector.emplace_back(kinetic_energy,
218 assnTrackCaloVector.emplace_back(i_track);
224 for (
auto const&
hit : hpm)
geo::WireReadoutGeom const & wireReadoutGeom
void AnalyzeHit(detinfo::DetectorClocksData const &, detinfo::DetectorPropertiesData const &, recob::Hit const &, recob::Track const &, std::vector< std::pair< geo::WireID, float >> const &, std::vector< float > const &, HitPropertiesMultiset_t &, geo::WireReadoutGeom const &)
WireID NearestWireID(Point_t const &pos) const
Returns the ID of wire closest to the specified position.
bool IsInvertedTrack(HitPropertiesMultiset_t const &)
Declaration of signal hit object.
Point_t const & LocationAtPoint(size_t i) const
Access to track position at different points.
void MakeCalorimetryObject(HitPropertiesMultiset_t const &hpm, recob::Track const &track, size_t const &i_track, std::vector< anab::Calorimetry > &caloVector, std::vector< size_t > &assnTrackCaloVector, geo::PlaneID const &planeID)
The data type to uniquely identify a Plane.
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
bool operator()(std::pair< geo::WireID, float > const &i, std::pair< geo::WireID, float > const &j)
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
geo::WireID const & WireID() const
Initial tdc tick for hit.
std::multiset< HitProperties, HitPropertySorter > HitPropertiesMultiset_t
dist_projected(recob::Hit const &h, geo::WireReadoutGeom const &wireReadoutGeom)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< float > CreatePathLengthFractionVector(recob::Track const &track)
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
double Length(size_t p=0) const
Access to various track properties.
Interface for a class providing readout channel mapping to geometry.
void PrintHitPropertiesMultiset(HitPropertiesMultiset_t const &hpm)
T get(std::string const &key) const
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
double ConvertXToTicks(double X, int p, int t, int c) const
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
Definition of data types for geometry description.
Detector simulation of raw signals on wires.
unsigned int Nplanes(TPCID const &tpcid=details::tpc_zero) const
Returns the total number of planes in the specified TPC.
void ExtractCalorimetry(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, std::vector< recob::Track > const &, std::vector< recob::Hit > const &, std::vector< std::vector< size_t >> const &, std::vector< anab::Calorimetry > &, std::vector< size_t > &, geo::WireReadoutGeom const &)
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
TrackCalorimetryAlg(fhicl::ParameterSet const &p)
Contains all timing reference information for the detector.
Provides recob::Track data product.
unsigned int fNHitsToDetermineStart
double TrackPitchInView(recob::Track const &track, geo::View_t view, size_t trajectory_point=0U)
Returns the projected length of track on a wire pitch step [cm].
double dEdx_AREA(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, recob::Hit const &hit, double pitch, double T0=0) const
2D representation of charge deposited in the TDC/wire plane
PlaneGeo const & Plane(TPCID const &tpcid, View_t view) const
Returns the specified wire.
Utility functions to extract information from recob::Track
Interface to geometry for wire readouts .
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
constexpr PlaneID const & asPlaneID() const
Conversion to WireID (for convenience of notation).