LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
calo::TrackCalorimetryAlg Class Reference

#include "TrackCalorimetryAlg.h"

Classes

struct  HitProperties
 
struct  HitPropertySorter
 

Public Types

using Providers_t = lar::ProviderPack< geo::GeometryCore, detinfo::LArProperties >
 

Public Member Functions

 TrackCalorimetryAlg (fhicl::ParameterSet const &p)
 
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)
 

Private Types

using HitPropertiesMultiset_t = std::multiset< HitProperties, HitPropertySorter >
 

Private Member Functions

std::vector< float > CreatePathLengthFractionVector (recob::Track const &track)
 
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 &)
 
bool IsInvertedTrack (HitPropertiesMultiset_t 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 PrintHitPropertiesMultiset (HitPropertiesMultiset_t const &hpm)
 

Private Attributes

CalorimetryAlg caloAlg
 
unsigned int fNHitsToDetermineStart
 

Detailed Description

Definition at line 45 of file TrackCalorimetryAlg.h.

Member Typedef Documentation

Constructor & Destructor Documentation

calo::TrackCalorimetryAlg::TrackCalorimetryAlg ( fhicl::ParameterSet const &  p)

Title: Track Calorimetry Algorithim Class Author: Wes Ketchum (wketc.nosp@m.hum@.nosp@m.lanl..nosp@m.gov), based on code in the Calorimetry_module

Description: Algorithm that produces a calorimetry object given a track Input: recob::Track, Assn<recob::Spacepoint,recob::Track>, Assn<recob::Hit,recob::Track> Output: anab::Calorimetry, (and Assn<anab::Calorimetry,recob::Track>)

Definition at line 22 of file TrackCalorimetryAlg.cxx.

References fNHitsToDetermineStart, and fhicl::ParameterSet::get().

23  : caloAlg(p.get<fhicl::ParameterSet>("CalorimetryAlg"))
24 {
25  fNHitsToDetermineStart = p.get<unsigned int>("NHitsToDetermineStart", 3);
26 }

Member Function Documentation

void calo::TrackCalorimetryAlg::AnalyzeHit ( detinfo::DetectorClocksData const &  clock_data,
detinfo::DetectorPropertiesData const &  det_prop,
recob::Hit const &  hit,
recob::Track const &  track,
std::vector< std::pair< geo::WireID, float >> const &  traj_points_in_plane,
std::vector< float > const &  path_length_fraction_vec,
HitPropertiesMultiset_t HitPropertiesMultiset,
geo::GeometryCore const &  geom 
)
private

Definition at line 122 of file TrackCalorimetryAlg.cxx.

References caloAlg, calo::CalorimetryAlg::dEdx_AREA(), recob::Hit::Integral(), recob::Track::LocationAtPoint(), geo::PlaneID::Plane, lar::util::TrackPitchInView(), geo::GeometryCore::View(), and recob::Hit::WireID().

Referenced by ExtractCalorimetry().

131 {
132 
133  size_t traj_iter = std::distance(traj_points_in_plane.begin(),
134  std::min_element(traj_points_in_plane.begin(),
135  traj_points_in_plane.end(),
136  dist_projected(hit, geom)));
137  float pitch = lar::util::TrackPitchInView(track, geom.View(hit.WireID().Plane), traj_iter);
138 
139  HitPropertiesMultiset.emplace(hit.Integral(),
140  hit.Integral() / pitch,
141  caloAlg.dEdx_AREA(clock_data, det_prop, hit, pitch),
142  pitch,
143  track.LocationAtPoint<TVector3>(traj_iter),
144  path_length_fraction_vec[traj_iter]);
145 }
Detector simulation of raw signals on wires.
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].
Definition: TrackUtils.cxx:75
double dEdx_AREA(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, recob::Hit const &hit, double pitch, double T0=0) const
Float_t track
Definition: plot.C:35
std::vector< float > calo::TrackCalorimetryAlg::CreatePathLengthFractionVector ( recob::Track const &  track)
private

Definition at line 106 of file TrackCalorimetryAlg.cxx.

References recob::Track::Length(), recob::Track::LocationAtPoint(), and recob::Track::NumberTrajectoryPoints().

Referenced by ExtractCalorimetry().

108 {
109 
110  std::vector<float> trk_path_length_frac_vec(track.NumberTrajectoryPoints());
111 
112  float cumulative_path_length = 0;
113  const float total_path_length = track.Length();
114  for (size_t i_trj = 1; i_trj < track.NumberTrajectoryPoints(); i_trj++) {
115  cumulative_path_length += (track.LocationAtPoint(i_trj) - track.LocationAtPoint(i_trj - 1)).R();
116  trk_path_length_frac_vec[i_trj] = cumulative_path_length / total_path_length;
117  }
118 
119  return trk_path_length_frac_vec;
120 }
Float_t track
Definition: plot.C:35
void calo::TrackCalorimetryAlg::ExtractCalorimetry ( detinfo::DetectorClocksData const &  clock_data,
detinfo::DetectorPropertiesData const &  det_prop,
std::vector< recob::Track > const &  trackVector,
std::vector< recob::Hit > const &  hitVector,
std::vector< std::vector< size_t >> const &  hit_indices_per_track,
std::vector< anab::Calorimetry > &  caloVector,
std::vector< size_t > &  assnTrackCaloVector,
Providers_t  providers 
)

Definition at line 28 of file TrackCalorimetryAlg.cxx.

References AnalyzeHit(), detinfo::DetectorPropertiesData::ConvertXToTicks(), CreatePathLengthFractionVector(), lar::ProviderPack< Providers >::get(), recob::Track::LocationAtPoint(), MakeCalorimetryObject(), recob::Track::NumberTrajectoryPoints(), and track.

Referenced by calo::TrackCalorimetry::produce().

37 {
38  auto const& geom = *providers.get<geo::GeometryCore>();
39 
40  //loop over the track list
41  for (size_t i_track = 0; i_track < trackVector.size(); i_track++) {
42 
43  recob::Track const& track = trackVector[i_track];
44  std::vector<float> path_length_fraction_vec(CreatePathLengthFractionVector(track));
45 
46  //sort hits into each plane
47  std::vector<std::vector<size_t>> hit_indices_per_plane(geom.Nplanes());
48  for (auto const& i_hit : hit_indices_per_track[i_track])
49  hit_indices_per_plane[hitVector[i_hit].WireID().Plane].push_back(i_hit);
50 
51  //loop over the planes
52  for (unsigned int i_plane = 0; i_plane < geom.Nplanes(); ++i_plane) {
53  geo::PlaneID const planeID{0, 0, i_plane};
54 
55  //project down the track into wire/tick space for this plane
56  std::vector<std::pair<geo::WireID, float>> traj_points_in_plane(
57  track.NumberTrajectoryPoints());
58  for (size_t i_trjpt = 0; i_trjpt < track.NumberTrajectoryPoints(); i_trjpt++) {
59  double x_pos = track.LocationAtPoint(i_trjpt).X();
60  float tick = det_prop.ConvertXToTicks(x_pos, (int)i_plane, 0, 0);
61  traj_points_in_plane[i_trjpt] =
62  std::make_pair(geom.NearestWireID(track.LocationAtPoint(i_trjpt), planeID), tick);
63  }
64 
65  HitPropertiesMultiset_t HitPropertiesMultiset;
66  //now loop through hits
67  for (auto const& i_hit : hit_indices_per_plane[i_plane])
68  AnalyzeHit(clock_data,
69  det_prop,
70  hitVector[i_hit],
71  track,
72  traj_points_in_plane,
73  path_length_fraction_vec,
74  HitPropertiesMultiset,
75  geom);
76 
77  //PrintHitPropertiesMultiset(HitPropertiesMultiset);
79  HitPropertiesMultiset, track, i_track, caloVector, assnTrackCaloVector, planeID);
80 
81  } //end loop over planes
82 
83  } //end loop over tracks
84 
85 } //end ExtractCalorimetry
Point_t const & LocationAtPoint(size_t i) const
Access to track position at different points.
Definition: Track.h:160
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.
Definition: geo_types.h:463
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:136
std::multiset< HitProperties, HitPropertySorter > HitPropertiesMultiset_t
std::vector< float > CreatePathLengthFractionVector(recob::Track const &track)
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Definition: electronics.h:73
Description of geometry of one entire detector.
Definition: GeometryCore.h:119
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 &)
Float_t track
Definition: plot.C:35
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
bool calo::TrackCalorimetryAlg::IsInvertedTrack ( HitPropertiesMultiset_t const &  hpm)
private

Definition at line 147 of file TrackCalorimetryAlg.cxx.

References util::counter(), and fNHitsToDetermineStart.

Referenced by MakeCalorimetryObject(), and PrintHitPropertiesMultiset().

148 {
149 
150  if (hpm.size() <= fNHitsToDetermineStart) return false;
151 
152  float charge_start = 0, charge_end = 0;
153  unsigned int counter = 0;
154  for (HitPropertiesMultiset_t::iterator it_hpm = hpm.begin(); it_hpm != hpm.end(); it_hpm++) {
155  charge_start += (*it_hpm).charge;
156  counter++;
157  if (counter == fNHitsToDetermineStart) break;
158  }
159 
160  counter = 0;
161  for (HitPropertiesMultiset_t::reverse_iterator it_hpm = hpm.rbegin(); it_hpm != hpm.rend();
162  it_hpm++) {
163  charge_end += (*it_hpm).charge;
164  counter++;
165  if (counter == fNHitsToDetermineStart) break;
166  }
167 
168  return (charge_start > charge_end);
169 }
intermediate_table::iterator iterator
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:295
void calo::TrackCalorimetryAlg::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 
)
private

Definition at line 171 of file TrackCalorimetryAlg.cxx.

References recob::tracking::convertCollToPoint(), IsInvertedTrack(), and recob::Track::Length().

Referenced by ExtractCalorimetry().

177 {
178  size_t n_hits = hpm.size();
179  std::vector<float> dEdxVector, dQdxVector, resRangeVector, deadWireVector, pitchVector;
180  std::vector<TVector3> XYZVector;
181 
182  dEdxVector.reserve(n_hits);
183  dQdxVector.reserve(n_hits);
184  resRangeVector.reserve(n_hits);
185  deadWireVector.reserve(n_hits);
186  pitchVector.reserve(n_hits);
187  XYZVector.reserve(n_hits);
188 
189  float kinetic_energy = 0, track_length = track.Length();
190  if (IsInvertedTrack(hpm)) {
191 
192  for (HitPropertiesMultiset_t::iterator it_hpm = hpm.begin(); it_hpm != hpm.end(); it_hpm++) {
193  dEdxVector.push_back((*it_hpm).dEdx);
194  dQdxVector.push_back((*it_hpm).dQdx);
195  resRangeVector.push_back((*it_hpm).path_fraction * track_length);
196  pitchVector.push_back((*it_hpm).pitch);
197  XYZVector.push_back((*it_hpm).xyz);
198  kinetic_energy += dEdxVector.back() * pitchVector.back();
199  }
200  }
201  else {
202 
203  for (HitPropertiesMultiset_t::reverse_iterator it_hpm = hpm.rbegin(); it_hpm != hpm.rend();
204  it_hpm++) {
205  dEdxVector.push_back((*it_hpm).dEdx);
206  dQdxVector.push_back((*it_hpm).dQdx);
207  resRangeVector.push_back((1 - (*it_hpm).path_fraction) * track_length);
208  pitchVector.push_back((*it_hpm).pitch);
209  XYZVector.push_back((*it_hpm).xyz);
210  kinetic_energy += dEdxVector.back() * pitchVector.back();
211  }
212  }
213 
214  caloVector.emplace_back(kinetic_energy,
215  dEdxVector,
216  dQdxVector,
217  resRangeVector,
218  deadWireVector,
219  track_length,
220  pitchVector,
222  planeID);
223  assnTrackCaloVector.emplace_back(i_track);
224 }
intermediate_table::iterator iterator
bool IsInvertedTrack(HitPropertiesMultiset_t const &)
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
Definition: TrackingTypes.h:68
Float_t track
Definition: plot.C:35
void calo::TrackCalorimetryAlg::PrintHitPropertiesMultiset ( HitPropertiesMultiset_t const &  hpm)
private

Definition at line 226 of file TrackCalorimetryAlg.cxx.

References IsInvertedTrack().

227 {
228 
229  for (auto const& hit : hpm)
230  hit.Print();
231 
232  std::cout << "Inverted? " << IsInvertedTrack(hpm) << std::endl;
233 }
bool IsInvertedTrack(HitPropertiesMultiset_t const &)
Detector simulation of raw signals on wires.

Member Data Documentation

CalorimetryAlg calo::TrackCalorimetryAlg::caloAlg
private

Definition at line 61 of file TrackCalorimetryAlg.h.

Referenced by AnalyzeHit().

unsigned int calo::TrackCalorimetryAlg::fNHitsToDetermineStart
private

Definition at line 62 of file TrackCalorimetryAlg.h.

Referenced by IsInvertedTrack(), and TrackCalorimetryAlg().


The documentation for this class was generated from the following files: