LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
FlashHypothesisCreator.cxx
Go to the documentation of this file.
1 
10 #include "FlashHypothesisCreator.h"
11 
14  std::vector<float> const& dEdxVector,
15  Providers_t providers,
17  opdet::OpDigiProperties const& opdigip,
18  float XOffset)
19 {
20  bool interpolate_dEdx=false;
21  if(track.NumberTrajectoryPoints() == dEdxVector.size())
22  interpolate_dEdx=true;
23  else if(track.NumberTrajectoryPoints() == dEdxVector.size()+1)
24  interpolate_dEdx=false;
25  else
26  throw "ERROR in FlashHypothesisCreator: dEdx vector size not compatible with track size.";
27 
28  auto const* geom = providers.get<geo::GeometryCore>();
29  FlashHypothesisCollection fhc(geom->NOpDets());
30  for(size_t pt=1; pt<track.NumberTrajectoryPoints(); pt++){
31  if(interpolate_dEdx)
32  fhc = fhc + CreateFlashHypothesesFromSegment(track.LocationAtPoint<TVector3>(pt-1),
33  track.LocationAtPoint<TVector3>(pt),
34  0.5*(dEdxVector[pt]+dEdxVector[pt-1]),
35  providers,pvs,opdigip,XOffset);
36  else
37  fhc = fhc + CreateFlashHypothesesFromSegment(track.LocationAtPoint<TVector3>(pt-1),
38  track.LocationAtPoint<TVector3>(pt),
39  dEdxVector[pt-1],
40  providers,pvs,opdigip,XOffset);
41  }
42  return fhc;
43 }
44 
47  std::vector<float> const& dEdxVector,
48  Providers_t providers,
50  opdet::OpDigiProperties const& opdigip,
51  float XOffset)
52 {
53  bool interpolate_dEdx=false;
54  if(mctrack.size() == dEdxVector.size())
55  interpolate_dEdx=true;
56  else if(mctrack.size() == dEdxVector.size()+1)
57  interpolate_dEdx=false;
58  else
59  throw "ERROR in FlashHypothesisCreator: dEdx vector size not compatible with mctrack size.";
60 
61  auto const* geom = providers.get<geo::GeometryCore>();
62  FlashHypothesisCollection fhc(geom->NOpDets());
63  for(size_t pt=1; pt<mctrack.size(); pt++){
64  if(interpolate_dEdx)
65  fhc = fhc + CreateFlashHypothesesFromSegment(mctrack[pt-1].Position().Vect(),
66  mctrack[pt].Position().Vect(),
67  0.5*(dEdxVector[pt]+dEdxVector[pt-1]),
68  providers,pvs,opdigip,XOffset);
69  else
70  fhc = fhc + CreateFlashHypothesesFromSegment(mctrack[pt-1].Position().Vect(),
71  mctrack[pt].Position().Vect(),
72  dEdxVector[pt-1],
73  providers,pvs,opdigip,XOffset);
74  }
75  return fhc;
76 }
77 
79 opdet::FlashHypothesisCreator::GetFlashHypothesisCollection(std::vector<TVector3> const& trajVector,
80  std::vector<float> const& dEdxVector,
81  Providers_t providers,
83  opdet::OpDigiProperties const& opdigip,
84  float XOffset)
85 {
86  bool interpolate_dEdx=false;
87  if(trajVector.size() == dEdxVector.size())
88  interpolate_dEdx=true;
89  else if(trajVector.size() == dEdxVector.size()+1)
90  interpolate_dEdx=false;
91  else
92  throw "ERROR in FlashHypothesisCreator: dEdx vector size not compatible with trajVector size.";
93 
94  auto const* geom = providers.get<geo::GeometryCore>();
95  FlashHypothesisCollection fhc(geom->NOpDets());
96  for(size_t pt=1; pt<trajVector.size(); pt++){
97  if(interpolate_dEdx)
98  fhc = fhc + CreateFlashHypothesesFromSegment(trajVector[pt-1],
99  trajVector[pt],
100  0.5*(dEdxVector[pt]+dEdxVector[pt-1]),
101  providers,pvs,opdigip,XOffset);
102  else
103  fhc = fhc + CreateFlashHypothesesFromSegment(trajVector[pt-1],
104  trajVector[pt],
105  dEdxVector[pt-1],
106  providers,pvs,opdigip,XOffset);
107  }
108  return fhc;
109 }
110 
112 opdet::FlashHypothesisCreator::GetFlashHypothesisCollection(TVector3 const& pt1, TVector3 const& pt2,
113  float const& dEdx,
114  Providers_t providers,
116  opdet::OpDigiProperties const& opdigip,
117  float XOffset)
118 {
119  return CreateFlashHypothesesFromSegment(pt1,pt2,dEdx,providers,pvs,opdigip,XOffset);
120 }
121 
123 opdet::FlashHypothesisCreator::CreateFlashHypothesesFromSegment(TVector3 const& pt1, TVector3 const& pt2,
124  float const& dEdx,
125  Providers_t providers,
127  opdet::OpDigiProperties const& opdigip,
128  float XOffset)
129 {
130  auto const* geom = providers.get<geo::GeometryCore>();
131  auto const* larp = providers.get<detinfo::LArProperties>();
132  auto const nOpDets = geom->NOpDets();
133  FlashHypothesisCollection fhc(nOpDets);
134 
135  FlashHypothesis prompt_hyp = FlashHypothesis(nOpDets);
136 
137  std::vector<double> xyz_segment(_calc.SegmentMidpoint(pt1,pt2,XOffset));
138 
139  //get the visibility vector
140  const float* PointVisibility = pvs.GetAllVisibilities(&xyz_segment[0]);
141 
142  //check visibility pointer, as it may be null if given a y/z outside some range
143  if (!PointVisibility) return fhc;
144 
145  //klugey ... right now, set a qe_vector that gives constant qe across all opdets
146  std::vector<float> qe_vector(nOpDets,opdigip.QE());
147  _calc.FillFlashHypothesis(larp->ScintYield()*larp->ScintYieldRatio(),
148  dEdx,
149  pt1,pt2,
150  qe_vector,
151  PointVisibility,
152  prompt_hyp);
153 
154  fhc.SetPromptHypAndPromptFraction(prompt_hyp,larp->ScintYieldRatio());
155  return fhc;
156 }
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:129
FlashHypothesisCalculator _calc
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:105
void FillFlashHypothesis(const float &yield, const float &dEdx, const TVector3 &pt1, const TVector3 &pt2, const std::vector< float > &qe_vector, const float *vis_vector, FlashHypothesis &hyp)
Provider const * get() const
Returns the provider with the specified type.
Definition: ProviderPack.h:193
float const * GetAllVisibilities(double const *xyz, bool wantReflected=false) const
TMarker * pt
Definition: egs.C:25
Description of geometry of one entire detector.
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:114
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:34
double QE() const
Returns quantum efficiency.
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:52