LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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, detinfo::DetectorProperties >
 

Public Member Functions

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

typedef std::multiset< HitProperties, HitPropertySorterHitPropertiesMultiset_t
 

Private Member Functions

void ClearInternalVectors ()
 
void ReserveInternalVectors (size_t s)
 
std::vector< float > CreatePathLengthFractionVector (recob::Track const &track)
 
void AnalyzeHit (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 34 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 16 of file TrackCalorimetryAlg.cxx.

References reconfigure().

16  :
17  caloAlg(p.get<fhicl::ParameterSet>("CalorimetryAlg"))
18 {
19  this->reconfigure(p);
20 }
void reconfigure(fhicl::ParameterSet const &p)

Member Function Documentation

void calo::TrackCalorimetryAlg::AnalyzeHit ( 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 119 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(), and ReserveInternalVectors().

124  {
125 
126  size_t traj_iter = std::distance(traj_points_in_plane.begin(),
127  std::min_element(traj_points_in_plane.begin(),
128  traj_points_in_plane.end(),
129  dist_projected(hit,geom)));
130  float pitch = lar::util::TrackPitchInView(track, geom.View(hit.WireID().Plane),traj_iter);
131 
132  HitPropertiesMultiset.emplace(hit.Integral(),
133  hit.Integral()/pitch,
134  caloAlg.dEdx_AREA(hit,pitch),
135  pitch,
136  track.LocationAtPoint(traj_iter),
137  path_length_fraction_vec[traj_iter]);
138 }
double dEdx_AREA(art::Ptr< recob::Hit > hit, double pitch, double T0=0) const
Detector simulation of raw signals on wires.
double TrackPitchInView(recob::Track const &track, geo::View_t view, size_t trajectory_point=0)
Provides projected wire pitch for the view.
Definition: TrackUtils.cxx:76
Float_t track
Definition: plot.C:34
void calo::TrackCalorimetryAlg::ClearInternalVectors ( )
inlineprivate

Definition at line 83 of file TrackCalorimetryAlg.h.

Referenced by ExtractCalorimetry().

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

Definition at line 105 of file TrackCalorimetryAlg.cxx.

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

Referenced by ExtractCalorimetry(), and ReserveInternalVectors().

105  {
106 
107  std::vector<float> trk_path_length_frac_vec(track.NumberTrajectoryPoints());
108 
109  float cumulative_path_length=0;
110  const float total_path_length = track.Length();
111  for(size_t i_trj=1; i_trj<track.NumberTrajectoryPoints(); i_trj++){
112  cumulative_path_length+=(track.LocationAtPoint(i_trj)-track.LocationAtPoint(i_trj-1)).Mag();
113  trk_path_length_frac_vec[i_trj]=cumulative_path_length/total_path_length;
114  }
115 
116  return trk_path_length_frac_vec;
117 }
Float_t track
Definition: plot.C:34
void calo::TrackCalorimetryAlg::ExtractCalorimetry ( 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 27 of file TrackCalorimetryAlg.cxx.

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

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

33 {
34  auto const& geom = *(providers.get<geo::GeometryCore>());
35 // auto const& larp = *(providers.get<detinfo::LArProperties>());
36  auto const& detprop = *(providers.get<detinfo::DetectorProperties>());
37 
38  //loop over the track list
39  for(size_t i_track=0; i_track<trackVector.size(); i_track++){
40 
41  recob::Track const& track = trackVector[i_track];
42  std::vector<float> path_length_fraction_vec(CreatePathLengthFractionVector(track));
43 
44  //sort hits into each plane
45  std::vector< std::vector<size_t> > hit_indices_per_plane(geom.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);
48 
49  //loop over the planes
50  for(size_t i_plane=0; i_plane<geom.Nplanes(); i_plane++){
51 
53  ReserveInternalVectors(hit_indices_per_plane[i_plane].size());
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(track.NumberTrajectoryPoints());
57  for(size_t i_trjpt=0; i_trjpt<track.NumberTrajectoryPoints(); i_trjpt++){
58  double x_pos = track.LocationAtPoint(i_trjpt).X();
59  float tick = detprop.ConvertXToTicks(x_pos,(int)i_plane,0,0);
60  traj_points_in_plane[i_trjpt] = std::make_pair(geom.NearestWireID(track.LocationAtPoint(i_trjpt),i_plane),
61  tick);
62  }
63 
64  HitPropertiesMultiset_t HitPropertiesMultiset;
65  //now loop through hits
66  for(auto const& i_hit : hit_indices_per_plane[i_plane])
67  AnalyzeHit(hitVector[i_hit],
68  track,
69  traj_points_in_plane,
70  path_length_fraction_vec,
71  HitPropertiesMultiset,
72  geom);
73 
74 
75  //PrintHitPropertiesMultiset(HitPropertiesMultiset);
76  geo::PlaneID planeID(0,0,i_plane);
77  MakeCalorimetryObject(HitPropertiesMultiset, track, i_track, caloVector, assnTrackCaloVector, planeID);
78 
79  }//end loop over planes
80 
81  }//end loop over tracks
82 
83 }//end ExtractCalorimetry
TVector3 LocationAtPoint(unsigned int p) const
Covariance matrices are either set or not.
Definition: Track.h:241
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:250
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:109
std::vector< float > CreatePathLengthFractionVector(recob::Track const &track)
void ReserveInternalVectors(size_t s)
Description of geometry of one entire detector.
std::multiset< HitProperties, HitPropertySorter > HitPropertiesMultiset_t
Float_t track
Definition: plot.C:34
void AnalyzeHit(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 "fitted" track:
Definition: Track.h:51
bool calo::TrackCalorimetryAlg::IsInvertedTrack ( HitPropertiesMultiset_t const &  hpm)
private

Definition at line 140 of file TrackCalorimetryAlg.cxx.

References fNHitsToDetermineStart.

Referenced by MakeCalorimetryObject(), PrintHitPropertiesMultiset(), and ReserveInternalVectors().

140  {
141 
142  if(hpm.size() <= fNHitsToDetermineStart) return false;
143 
144  float charge_start=0,charge_end=0;
145  unsigned int counter=0;
146  for(HitPropertiesMultiset_t::iterator it_hpm=hpm.begin();
147  it_hpm!=hpm.end();
148  it_hpm++)
149  {
150  charge_start += (*it_hpm).charge;
151  counter++;
152  if(counter==fNHitsToDetermineStart) break;
153  }
154 
155  counter=0;
156  for(HitPropertiesMultiset_t::reverse_iterator it_hpm=hpm.rbegin();
157  it_hpm!=hpm.rend();
158  it_hpm++)
159  {
160  charge_end += (*it_hpm).charge;
161  counter++;
162  if(counter==fNHitsToDetermineStart) break;
163  }
164 
165  return (charge_start > charge_end);
166 }
intermediate_table::iterator iterator
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 168 of file TrackCalorimetryAlg.cxx.

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

Referenced by ExtractCalorimetry(), and ReserveInternalVectors().

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

Definition at line 229 of file TrackCalorimetryAlg.cxx.

References IsInvertedTrack().

Referenced by ReserveInternalVectors().

229  {
230 
231  for(auto const& hit : hpm)
232  hit.Print();
233 
234  std::cout << "Inverted? " << IsInvertedTrack(hpm) << std::endl;
235 
236 }
bool IsInvertedTrack(HitPropertiesMultiset_t const &)
Detector simulation of raw signals on wires.
void calo::TrackCalorimetryAlg::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 22 of file TrackCalorimetryAlg.cxx.

References caloAlg, fNHitsToDetermineStart, fhicl::ParameterSet::get(), and calo::CalorimetryAlg::reconfigure().

Referenced by calo::TrackCalorimetry::reconfigure(), and TrackCalorimetryAlg().

22  {
23  caloAlg.reconfigure(p.get<fhicl::ParameterSet>("CalorimetryAlg"));
24  fNHitsToDetermineStart = p.get<unsigned int>("NHitsToDetermineStart",3);
25 }
void reconfigure(const Config &config)
void calo::TrackCalorimetryAlg::ReserveInternalVectors ( size_t  s)
inlineprivate

Member Data Documentation

CalorimetryAlg calo::TrackCalorimetryAlg::caloAlg
private

Definition at line 53 of file TrackCalorimetryAlg.h.

Referenced by AnalyzeHit(), and reconfigure().

unsigned int calo::TrackCalorimetryAlg::fNHitsToDetermineStart
private

Definition at line 54 of file TrackCalorimetryAlg.h.

Referenced by IsInvertedTrack(), and reconfigure().


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