11 #include "fhiclcpp/ParameterSet.h"
23 : caloAlg(p.
get<fhicl::ParameterSet>(
"CalorimetryAlg"))
32 std::vector<recob::Track>
const& trackVector,
33 std::vector<recob::Hit>
const& hitVector,
34 std::vector<std::vector<size_t>>
const& hit_indices_per_track,
35 std::vector<anab::Calorimetry>& caloVector,
36 std::vector<size_t>& assnTrackCaloVector,
42 for (
size_t i_track = 0; i_track < trackVector.size(); i_track++) {
45 std::vector<float> path_length_fraction_vec(CreatePathLengthFractionVector(track));
48 std::vector<std::vector<size_t>> hit_indices_per_plane(geom.Nplanes());
49 for (
auto const& i_hit : hit_indices_per_track[i_track])
50 hit_indices_per_plane[hitVector[i_hit].WireID().Plane].push_back(i_hit);
53 for (
size_t i_plane = 0; i_plane < geom.Nplanes(); i_plane++) {
55 ClearInternalVectors();
56 ReserveInternalVectors(hit_indices_per_plane[i_plane].
size());
59 std::vector<std::pair<geo::WireID, float>> traj_points_in_plane(
64 traj_points_in_plane[i_trjpt] =
65 std::make_pair(geom.NearestWireID(track.
LocationAtPoint(i_trjpt), i_plane), tick);
70 for (
auto const& i_hit : hit_indices_per_plane[i_plane])
71 AnalyzeHit(clock_data,
76 path_length_fraction_vec,
77 HitPropertiesMultiset,
82 MakeCalorimetryObject(
83 HitPropertiesMultiset, track, i_track, caloVector, assnTrackCaloVector, planeID);
95 operator()(std::pair<geo::WireID, float> i, std::pair<geo::WireID, float> j)
97 float dw_i = ((int)(i.first.Wire) - (int)(
hit.WireID().Wire)) * geom.WirePitch(i.first.Plane);
98 float dw_j = ((int)(j.first.Wire) - (int)(
hit.WireID().Wire)) * geom.WirePitch(j.first.Plane);
99 float dt_i = i.second -
hit.PeakTime();
100 float dt_j = j.second -
hit.PeakTime();
101 return std::hypot(dw_i, dt_i) < std::hypot(dw_j, dt_j);
115 float cumulative_path_length = 0;
116 const float total_path_length = track.
Length();
119 trk_path_length_frac_vec[i_trj] = cumulative_path_length / total_path_length;
122 return trk_path_length_frac_vec;
131 std::vector<std::pair<geo::WireID, float>>
const& traj_points_in_plane,
132 std::vector<float>
const& path_length_fraction_vec,
137 size_t traj_iter =
std::distance(traj_points_in_plane.begin(),
138 std::min_element(traj_points_in_plane.begin(),
139 traj_points_in_plane.end(),
143 HitPropertiesMultiset.emplace(hit.
Integral(),
145 caloAlg.dEdx_AREA(clock_data, det_prop, hit, pitch),
148 path_length_fraction_vec[traj_iter]);
155 if (hpm.size() <= fNHitsToDetermineStart)
return false;
157 float charge_start = 0, charge_end = 0;
159 for (HitPropertiesMultiset_t::iterator it_hpm = hpm.begin(); it_hpm != hpm.end(); it_hpm++) {
160 charge_start += (*it_hpm).charge;
162 if (counter == fNHitsToDetermineStart)
break;
166 for (HitPropertiesMultiset_t::reverse_iterator it_hpm = hpm.rbegin(); it_hpm != hpm.rend();
168 charge_end += (*it_hpm).charge;
170 if (counter == fNHitsToDetermineStart)
break;
173 return (charge_start > charge_end);
179 size_t const& i_track,
180 std::vector<anab::Calorimetry>& caloVector,
181 std::vector<size_t>& assnTrackCaloVector,
184 size_t n_hits = hpm.size();
185 std::vector<float> dEdxVector, dQdxVector, resRangeVector, deadWireVector, pitchVector;
186 std::vector<TVector3> XYZVector;
188 dEdxVector.reserve(n_hits);
189 dQdxVector.reserve(n_hits);
190 resRangeVector.reserve(n_hits);
191 deadWireVector.reserve(n_hits);
192 pitchVector.reserve(n_hits);
193 XYZVector.reserve(n_hits);
195 float kinetic_energy = 0, track_length = track.
Length();
196 if (IsInvertedTrack(hpm)) {
198 for (HitPropertiesMultiset_t::iterator it_hpm = hpm.begin(); it_hpm != hpm.end(); it_hpm++) {
199 dEdxVector.push_back((*it_hpm).dEdx);
200 dQdxVector.push_back((*it_hpm).dQdx);
201 resRangeVector.push_back((*it_hpm).path_fraction * track_length);
202 pitchVector.push_back((*it_hpm).pitch);
203 XYZVector.push_back((*it_hpm).xyz);
204 kinetic_energy += dEdxVector.back() * pitchVector.back();
209 for (HitPropertiesMultiset_t::reverse_iterator it_hpm = hpm.rbegin(); it_hpm != hpm.rend();
211 dEdxVector.push_back((*it_hpm).dEdx);
212 dQdxVector.push_back((*it_hpm).dQdx);
213 resRangeVector.push_back((1 - (*it_hpm).path_fraction) * track_length);
214 pitchVector.push_back((*it_hpm).pitch);
215 XYZVector.push_back((*it_hpm).xyz);
216 kinetic_energy += dEdxVector.back() * pitchVector.back();
220 caloVector.emplace_back(kinetic_energy,
229 assnTrackCaloVector.emplace_back(i_track);
236 for (
auto const&
hit : hpm)
239 std::cout <<
"Inverted? " << IsInvertedTrack(hpm) << std::endl;
geo::GeometryCore const & geom
geo::WireID WireID() const
bool IsInvertedTrack(HitPropertiesMultiset_t const &)
Declaration of signal hit object.
Point_t const & LocationAtPoint(size_t i) const
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)
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 > &, Providers_t providers)
The data type to uniquely identify a Plane.
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
std::size_t size(FixedBins< T, C > const &) noexcept
Provider const * get() const
Returns the provider with the specified type.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
process_name use argoneut_mc_hitfinder track
std::multiset< HitProperties, HitPropertySorter > HitPropertiesMultiset_t
dist_projected(recob::Hit const &h, geo::GeometryCore const &g)
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.
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
bool operator()(std::pair< geo::WireID, float > i, std::pair< geo::WireID, float > j)
void PrintHitPropertiesMultiset(HitPropertiesMultiset_t const &hpm)
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)
PlaneID_t Plane
Index of the plane within its TPC.
Description of geometry of one entire detector.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Definition of data types for geometry description.
Provides recob::Track data product.
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::GeometryCore const &)
TrackCalorimetryAlg(fhicl::ParameterSet const &p)
Contains all timing reference information for the detector.
Container for a list of pointers to providers.
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].
2D representation of charge deposited in the TDC/wire plane
Utility functions to extract information from recob::Track
BEGIN_PROLOG could also be cout
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track: