All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
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

void ClearInternalVectors ()
 
void ReserveInternalVectors (size_t s)
 
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

Definition at line 91 of file TrackCalorimetryAlg.h.

Definition at line 47 of file TrackCalorimetryAlg.h.

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.

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

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 126 of file TrackCalorimetryAlg.cxx.

135 {
136 
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(),
140  dist_projected(hit, geom)));
141  float pitch = lar::util::TrackPitchInView(track, geom.View(hit.WireID().Plane), traj_iter);
142 
143  HitPropertiesMultiset.emplace(hit.Integral(),
144  hit.Integral() / pitch,
145  caloAlg.dEdx_AREA(clock_data, det_prop, hit, pitch),
146  pitch,
147  track.LocationAtPoint<TVector3>(traj_iter),
148  path_length_fraction_vec[traj_iter]);
149 }
process_name use argoneut_mc_hitfinder track
process_name hit
Definition: cheaterreco.fcl:51
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
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:79
double dEdx_AREA(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, recob::Hit const &hit, double pitch, double T0=0) const
void calo::TrackCalorimetryAlg::ClearInternalVectors ( )
inlineprivate

Definition at line 94 of file TrackCalorimetryAlg.h.

95  {}
std::vector< float > calo::TrackCalorimetryAlg::CreatePathLengthFractionVector ( recob::Track const &  track)
private

Definition at line 110 of file TrackCalorimetryAlg.cxx.

111 {
112 
113  std::vector<float> trk_path_length_frac_vec(track.NumberTrajectoryPoints());
114 
115  float cumulative_path_length = 0;
116  const float total_path_length = track.Length();
117  for (size_t i_trj = 1; i_trj < track.NumberTrajectoryPoints(); i_trj++) {
118  cumulative_path_length += (track.LocationAtPoint(i_trj) - track.LocationAtPoint(i_trj - 1)).R();
119  trk_path_length_frac_vec[i_trj] = cumulative_path_length / total_path_length;
120  }
121 
122  return trk_path_length_frac_vec;
123 }
process_name use argoneut_mc_hitfinder track
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 29 of file TrackCalorimetryAlg.cxx.

38 {
39  auto const& geom = *providers.get<geo::GeometryCore>();
40 
41  //loop over the track list
42  for (size_t i_track = 0; i_track < trackVector.size(); i_track++) {
43 
44  recob::Track const& track = trackVector[i_track];
45  std::vector<float> path_length_fraction_vec(CreatePathLengthFractionVector(track));
46 
47  //sort hits into each plane
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);
51 
52  //loop over the planes
53  for (size_t i_plane = 0; i_plane < geom.Nplanes(); i_plane++) {
54 
56  ReserveInternalVectors(hit_indices_per_plane[i_plane].size());
57 
58  //project down the track into wire/tick space for this plane
59  std::vector<std::pair<geo::WireID, float>> traj_points_in_plane(
60  track.NumberTrajectoryPoints());
61  for (size_t i_trjpt = 0; i_trjpt < track.NumberTrajectoryPoints(); i_trjpt++) {
62  double x_pos = track.LocationAtPoint(i_trjpt).X();
63  float tick = det_prop.ConvertXToTicks(x_pos, (int)i_plane, 0, 0);
64  traj_points_in_plane[i_trjpt] =
65  std::make_pair(geom.NearestWireID(track.LocationAtPoint(i_trjpt), i_plane), tick);
66  }
67 
68  HitPropertiesMultiset_t HitPropertiesMultiset;
69  //now loop through hits
70  for (auto const& i_hit : hit_indices_per_plane[i_plane])
71  AnalyzeHit(clock_data,
72  det_prop,
73  hitVector[i_hit],
74  track,
75  traj_points_in_plane,
76  path_length_fraction_vec,
77  HitPropertiesMultiset,
78  geom);
79 
80  //PrintHitPropertiesMultiset(HitPropertiesMultiset);
81  geo::PlaneID planeID(0, 0, i_plane);
83  HitPropertiesMultiset, track, i_track, caloVector, assnTrackCaloVector, planeID);
84 
85  } //end loop over planes
86 
87  } //end loop over tracks
88 
89 } //end ExtractCalorimetry
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)
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
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
Definition: FixedBins.h:561
process_name use argoneut_mc_hitfinder track
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:75
void ReserveInternalVectors(size_t s)
Description of geometry of one entire detector.
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 &)
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track:
bool calo::TrackCalorimetryAlg::IsInvertedTrack ( HitPropertiesMultiset_t const &  hpm)
private

Definition at line 152 of file TrackCalorimetryAlg.cxx.

153 {
154 
155  if (hpm.size() <= fNHitsToDetermineStart) return false;
156 
157  float charge_start = 0, charge_end = 0;
158  unsigned int counter = 0;
159  for (HitPropertiesMultiset_t::iterator it_hpm = hpm.begin(); it_hpm != hpm.end(); it_hpm++) {
160  charge_start += (*it_hpm).charge;
161  counter++;
162  if (counter == fNHitsToDetermineStart) break;
163  }
164 
165  counter = 0;
166  for (HitPropertiesMultiset_t::reverse_iterator it_hpm = hpm.rbegin(); it_hpm != hpm.rend();
167  it_hpm++) {
168  charge_end += (*it_hpm).charge;
169  counter++;
170  if (counter == fNHitsToDetermineStart) break;
171  }
172 
173  return (charge_start > charge_end);
174 }
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:285
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 177 of file TrackCalorimetryAlg.cxx.

183 {
184  size_t n_hits = hpm.size();
185  std::vector<float> dEdxVector, dQdxVector, resRangeVector, deadWireVector, pitchVector;
186  std::vector<TVector3> XYZVector;
187 
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);
194 
195  float kinetic_energy = 0, track_length = track.Length();
196  if (IsInvertedTrack(hpm)) {
197 
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();
205  }
206  }
207  else {
208 
209  for (HitPropertiesMultiset_t::reverse_iterator it_hpm = hpm.rbegin(); it_hpm != hpm.rend();
210  it_hpm++) {
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();
217  }
218  }
219 
220  caloVector.emplace_back(kinetic_energy,
221  dEdxVector,
222  dQdxVector,
223  resRangeVector,
224  deadWireVector,
225  track_length,
226  pitchVector,
228  planeID);
229  assnTrackCaloVector.emplace_back(i_track);
230 }
bool IsInvertedTrack(HitPropertiesMultiset_t const &)
process_name use argoneut_mc_hitfinder track
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
Definition: TrackingTypes.h:55
void calo::TrackCalorimetryAlg::PrintHitPropertiesMultiset ( HitPropertiesMultiset_t const &  hpm)
private

Definition at line 233 of file TrackCalorimetryAlg.cxx.

234 {
235 
236  for (auto const& hit : hpm)
237  hit.Print();
238 
239  std::cout << "Inverted? " << IsInvertedTrack(hpm) << std::endl;
240 }
bool IsInvertedTrack(HitPropertiesMultiset_t const &)
process_name hit
Definition: cheaterreco.fcl:51
BEGIN_PROLOG could also be cout
void calo::TrackCalorimetryAlg::ReserveInternalVectors ( size_t  s)
inlineprivate

Definition at line 97 of file TrackCalorimetryAlg.h.

98  {}

Member Data Documentation

CalorimetryAlg calo::TrackCalorimetryAlg::caloAlg
private

Definition at line 61 of file TrackCalorimetryAlg.h.

unsigned int calo::TrackCalorimetryAlg::fNHitsToDetermineStart
private

Definition at line 62 of file TrackCalorimetryAlg.h.


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