LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
FlashHypothesisCreator.cxx
Go to the documentation of this file.
1 
10 #include "FlashHypothesisCreator.h"
11 #include "OpDigiProperties.h"
12 
18 
20  recob::Track const& track,
21  std::vector<float> const& dEdxVector,
22  Providers_t providers,
24  opdet::OpDigiProperties const& opdigip,
25  float XOffset)
26 {
27  bool interpolate_dEdx = false;
28  if (track.NumberTrajectoryPoints() == dEdxVector.size())
29  interpolate_dEdx = true;
30  else if (track.NumberTrajectoryPoints() == dEdxVector.size() + 1)
31  interpolate_dEdx = false;
32  else
33  throw "ERROR in FlashHypothesisCreator: dEdx vector size not compatible with track size.";
34 
35  auto const* geom = providers.get<geo::GeometryCore>();
36  FlashHypothesisCollection fhc(geom->NOpDets());
37  for (size_t pt = 1; pt < track.NumberTrajectoryPoints(); pt++) {
38  if (interpolate_dEdx)
39  fhc = fhc + CreateFlashHypothesesFromSegment(track.LocationAtPoint<TVector3>(pt - 1),
40  track.LocationAtPoint<TVector3>(pt),
41  0.5 * (dEdxVector[pt] + dEdxVector[pt - 1]),
42  providers,
43  pvs,
44  opdigip,
45  XOffset);
46  else
47  fhc = fhc + CreateFlashHypothesesFromSegment(track.LocationAtPoint<TVector3>(pt - 1),
48  track.LocationAtPoint<TVector3>(pt),
49  dEdxVector[pt - 1],
50  providers,
51  pvs,
52  opdigip,
53  XOffset);
54  }
55  return fhc;
56 }
57 
59  sim::MCTrack const& mctrack,
60  std::vector<float> const& dEdxVector,
61  Providers_t providers,
63  opdet::OpDigiProperties const& opdigip,
64  float XOffset)
65 {
66  bool interpolate_dEdx = false;
67  if (mctrack.size() == dEdxVector.size())
68  interpolate_dEdx = true;
69  else if (mctrack.size() == dEdxVector.size() + 1)
70  interpolate_dEdx = false;
71  else
72  throw "ERROR in FlashHypothesisCreator: dEdx vector size not compatible with mctrack size.";
73 
74  auto const* geom = providers.get<geo::GeometryCore>();
75  FlashHypothesisCollection fhc(geom->NOpDets());
76  for (size_t pt = 1; pt < mctrack.size(); pt++) {
77  if (interpolate_dEdx)
78  fhc = fhc + CreateFlashHypothesesFromSegment(mctrack[pt - 1].Position().Vect(),
79  mctrack[pt].Position().Vect(),
80  0.5 * (dEdxVector[pt] + dEdxVector[pt - 1]),
81  providers,
82  pvs,
83  opdigip,
84  XOffset);
85  else
86  fhc = fhc + CreateFlashHypothesesFromSegment(mctrack[pt - 1].Position().Vect(),
87  mctrack[pt].Position().Vect(),
88  dEdxVector[pt - 1],
89  providers,
90  pvs,
91  opdigip,
92  XOffset);
93  }
94  return fhc;
95 }
96 
98  std::vector<TVector3> const& trajVector,
99  std::vector<float> const& dEdxVector,
100  Providers_t providers,
102  opdet::OpDigiProperties const& opdigip,
103  float XOffset)
104 {
105  bool interpolate_dEdx = false;
106  if (trajVector.size() == dEdxVector.size())
107  interpolate_dEdx = true;
108  else if (trajVector.size() == dEdxVector.size() + 1)
109  interpolate_dEdx = false;
110  else
111  throw "ERROR in FlashHypothesisCreator: dEdx vector size not compatible with trajVector size.";
112 
113  auto const* geom = providers.get<geo::GeometryCore>();
114  FlashHypothesisCollection fhc(geom->NOpDets());
115  for (size_t pt = 1; pt < trajVector.size(); pt++) {
116  if (interpolate_dEdx)
117  fhc = fhc + CreateFlashHypothesesFromSegment(trajVector[pt - 1],
118  trajVector[pt],
119  0.5 * (dEdxVector[pt] + dEdxVector[pt - 1]),
120  providers,
121  pvs,
122  opdigip,
123  XOffset);
124  else
125  fhc =
126  fhc +
128  trajVector[pt - 1], trajVector[pt], dEdxVector[pt - 1], providers, pvs, opdigip, XOffset);
129  }
130  return fhc;
131 }
132 
134  TVector3 const& pt1,
135  TVector3 const& pt2,
136  float const& dEdx,
137  Providers_t providers,
139  opdet::OpDigiProperties const& opdigip,
140  float XOffset)
141 {
142  return CreateFlashHypothesesFromSegment(pt1, pt2, dEdx, providers, pvs, opdigip, XOffset);
143 }
144 
146  TVector3 const& pt1,
147  TVector3 const& pt2,
148  float const& dEdx,
149  Providers_t providers,
151  opdet::OpDigiProperties const& opdigip,
152  float XOffset)
153 {
154  auto const* geom = providers.get<geo::GeometryCore>();
155  auto const* larp = providers.get<detinfo::LArProperties>();
156  auto const nOpDets = geom->NOpDets();
157  FlashHypothesisCollection fhc(nOpDets);
158 
159  FlashHypothesis prompt_hyp = FlashHypothesis(nOpDets);
160 
161  std::vector<double> xyz_segment(_calc.SegmentMidpoint(pt1, pt2, XOffset));
162 
163  //get the visibility vector
164  auto const& PointVisibility = pvs.GetAllVisibilities(&xyz_segment[0]);
165 
166  //check visibility pointer, as it may be null if given a y/z outside some range
167  if (!PointVisibility) return fhc;
168 
169  //klugey ... right now, set a qe_vector that gives constant qe across all opdets
170  std::vector<float> qe_vector(nOpDets, opdigip.QE());
171  _calc.FillFlashHypothesis(larp->ScintYield() * larp->ScintYieldRatio(),
172  dEdx,
173  pt1,
174  pt2,
175  qe_vector,
176  PointVisibility,
177  prompt_hyp);
178 
179  fhc.SetPromptHypAndPromptFraction(prompt_hyp, larp->ScintYieldRatio());
180  return fhc;
181 }
void FillFlashHypothesis(const float &yield, const float &dEdx, const TVector3 &pt1, const TVector3 &pt2, const std::vector< float > &qe_vector, phot::MappedCounts_t const &vis_vector, FlashHypothesis &hyp)
FlashHypothesisCollection GetFlashHypothesisCollection(recob::Track const &track, std::vector< float > const &dEdxVector, Providers_t providers, phot::PhotonVisibilityService const &pvs, opdet::OpDigiProperties const &opdigip, float XOffset=0)
Point_t const & LocationAtPoint(size_t i) const
Access to track position at different points.
Definition: Track.h:160
FlashHypothesisCalculator _calc
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:136
Provider const * get() const
Returns the provider with the specified type.
Definition: ProviderPack.h:182
double QE() const noexcept
Returns quantum efficiency.
TText * pt2
Definition: plot.C:64
TMarker * pt
Definition: egs.C:25
Provides recob::Track data product.
Description of geometry of one entire detector.
Definition: GeometryCore.h:119
Class def header for mctrack data container.
MappedCounts_t GetAllVisibilities(Point const &p, bool wantReflected=false) const
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Definition: PFPUtils.cxx:2675
void SetPromptHypAndPromptFraction(const FlashHypothesis &prompt, float frac)
std::vector< double > SegmentMidpoint(const TVector3 &pt1, const TVector3 &pt2, float XOffset=0)
Container for a list of pointers to providers.
Definition: ProviderPack.h:111
TText * pt1
Definition: plot.C:61
FlashHypothesisCollection CreateFlashHypothesesFromSegment(TVector3 const &pt1, TVector3 const &pt2, float const &dEdx, Providers_t providers, phot::PhotonVisibilityService const &pvs, opdet::OpDigiProperties const &opdigip, float XOffset)
Float_t track
Definition: plot.C:35
art framework interface to geometry description
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