18 #include "cetlib_except/exception.h" 41 :
BezierTrack(track.ID(), track.Trajectory().Trajectory()) {}
51 double Pt[3], Dir[3], PtErr[3], DirErr[3];
54 SeedCol.at(0).GetPoint( Pt, PtErr );
55 SeedCol.at(0).GetDirection( Dir, DirErr );
56 for(
int i=0; i!=3; ++i)
59 FirstPt[i]=Pt[i]-((1.+1./BigN) * Dir[i]);
60 FirstDir[i]=Dir[i]/BigN;
64 for(
size_t i=0; i!=SeedCol.size(); ++i)
70 double Pt[3], Dir[3], PtErr[3], DirErr[3];
71 double LastPt[3], LastDir[3];
72 SeedCol.at(SeedCol.size()-1).GetPoint( Pt, PtErr );
73 SeedCol.at(SeedCol.size()-1).GetDirection( Dir, DirErr );
74 for(
int i=0; i!=3; ++i)
77 LastPt[i]=Pt[i]+((1.+1./BigN) * Dir[i]);
78 LastDir[i]=Dir[i]/BigN;
92 std::vector<TVector3>
const& Dir,
113 ReturnVector.erase(ReturnVector.begin());
114 ReturnVector.pop_back();
118 return std::vector<recob::Seed>();
130 static std::map<geo::View_t, bool> DoneCalc;
131 static std::map<geo::View_t, TVector3> PitchVecs;
133 if(!(DoneCalc[view]))
141 for(p=0; p!=pTop; ++p)
144 double WireEnd1[3], WireEnd2[3];
148 double WirePitch = geom->
WirePitch(view);
151 for(
size_t i=0; i!=3; ++i)
152 WireVec[i]= WireEnd2[i] -WireEnd1[i];
153 PitchVecs[view] = (1.0 / WirePitch) * WireVec.Cross(TVector3(1,0,0)).Unit();
160 return 1. / (PitchVecs[view].Dot(TrackDir));
171 for(
size_t i=0; i!=Hitv.
size(); ++i)
189 std::vector<float> dEdx;
190 std::vector<float> dQdx;
191 std::vector<float> resRange;
192 std::vector<float> deadwire;
194 std::vector<float> TrkPitch;
205 for(
size_t i=0; i!=Hits.
size(); ++i)
207 if(Hits.
at(i)->SignalType()==sigtype)
210 double WirePitch = geom->
WirePitch(view);
213 TrkPitch.push_back(ThisPitch);
214 resRange.push_back(Range - s*Range);
215 dQdx.push_back(Hits.
at(i)->Integral()/ThisPitch);
216 dEdx.push_back( calalg.
dEdx_AMP(Hits.
at(i), ThisPitch) );
219 planeID = Hits.
at(i)->WireID().planeID();
228 double KineticEnergy = 0.;
230 for(
size_t i=0; i!=dEdx.size(); ++i)
231 KineticEnergy+=dEdx.at(i)*TrkPitch.at(i);
233 return anab::Calorimetry(KineticEnergy, dEdx, dQdx, resRange, deadwire, Range, TrkPitch,planeID);
248 std::vector<float> dEdx;
249 std::vector<float> dQdx;
250 std::vector<float> resRange;
251 std::vector<float> deadwire;
253 std::vector<float> TrkPitch;
255 double WirePitch = geom->
WirePitch(view);
257 double KineticEnergy = 0;
266 for(
size_t i=0; i!=Hits.
size(); ++i)
268 if(Hits.
at(i)->View()==view)
272 TrkPitch.push_back(ThisPitch);
273 resRange.push_back( (1.-s) * Range);
274 dQdx.push_back(Hits.
at(i)->Integral()/ThisPitch);
275 double ThisdEdx = calalg.
dEdx_AMP(Hits.
at(i), ThisPitch);
276 dEdx.push_back( ThisdEdx);
277 KineticEnergy+=ThisdEdx*ThisPitch;
280 planeID = Hits.
at(i)->WireID().planeID();
290 return anab::Calorimetry(KineticEnergy, dEdx, dQdx, resRange, deadwire, Range, TrkPitch, planeID);
305 double Pt[3], Dir[3];
306 for(
int i=0; i!=NSeg; i++)
332 fdQdx.resize(NPlanes) ;
333 double Pt[3], Dir[3], ErrPt[3], ErrDir[3];
340 it->GetPoint(Pt,ErrPt);
341 it->GetDirection(Dir, ErrDir);
345 for(
int i=0; i!=NPlanes; ++i)
346 fdQdx.at(i).push_back(0);
348 positions.push_back(Point);
349 directions.push_back(Direction);
372 <<
"CalculateSegments method of Bezier track called with no" 373 <<
" track information loaded. You must fill track with " 374 <<
"poisition and direction data before calling this method." 389 for(
int i=0; i!=Segments; ++i)
413 if((s>0.9999)&&(s<1.00001))
422 else if((s<0.0001)&&(s>-0.00001))
434 throw cet::exception(
"track point out of range")<<
" s = "<<s <<
" out of range \n";
475 for(
int p=0; p!=NPlanes; p++)
504 for(
int p=0; p!=NPlanes; p++)
531 std::vector<TVector3> HitEnd1s, HitEnd2s;
532 std::vector<double> WireLengths;
534 HitEnd1s.resize(hits.
size());
535 HitEnd2s.resize(hits.
size());
536 WireLengths.resize(hits.
size());
539 double End1[3], End2[3];
541 size_t NHits = hits.
size();
543 for(
size_t i=0; i!=NHits; i++)
545 Distances.push_back(10000);
553 HitEnd1s.at(i)[1]= End1[1];
554 HitEnd2s.at(i)[1]= End2[1];
555 HitEnd1s.at(i)[2]= End1[2];
556 HitEnd2s.at(i)[2]= End2[2];
558 WireLengths.at(i)=((HitEnd1s.at(i)-HitEnd2s.at(i)).Mag());
569 for(
size_t ihit=0; ihit!=NHits; ++ihit)
571 float d = ((trackpt-HitEnd1s.at(ihit)).Cross(trackpt-HitEnd2s.at(ihit))).Mag()/WireLengths.at(ihit);
573 if(d<Distances.at(ihit))
575 Distances.at(ihit)=
d;
610 double xyzend1[3], xyzend2[3];
617 double iS, xyz[3], MinDistanceToPoint=10000, MinS=0;
624 TVector3 end1(xyzend1[0],xyzend1[1],xyzend1[2]);
625 TVector3 end2(xyzend2[0],xyzend2[1],xyzend2[2]);
626 TVector3 trackpt(xyz[0],xyz[1],xyz[2]);
628 float d = ((trackpt-end1).Cross(trackpt-end2)).Mag()/(end2-end1).Mag();
630 if(d<MinDistanceToPoint)
632 MinDistanceToPoint=
d;
638 Distance = MinDistanceToPoint;
657 double xyzend1[3], xyzend2[3];
664 double iS, xyz[3], MinDistanceToPoint=10000, MinS=0;
671 TVector3 end1(xyzend1[0],xyzend1[1],xyzend1[2]);
672 TVector3 end2(xyzend2[0],xyzend2[1],xyzend2[2]);
673 TVector3 trackpt(xyz[0],xyz[1],xyz[2]);
675 float d = ((trackpt-end1).Cross(trackpt-end2)).Mag()/(end2-end1).Mag();
677 if(d<MinDistanceToPoint)
679 MinDistanceToPoint=
d;
685 Distance = MinDistanceToPoint;
702 double xyzend1[3], xyzend2[3];
706 xyzend1[0] = xyzend2[0] =
x;
708 double iS, xyz[3], MinDistanceToPoint=10000, MinS=0;
715 TVector3 end1(xyzend1[0],xyzend1[1],xyzend1[2]);
716 TVector3 end2(xyzend2[0],xyzend2[1],xyzend2[2]);
717 TVector3 trackpt(xyz[0],xyz[1],xyz[2]);
719 float d = ((trackpt-end1).Cross(trackpt-end2)).Mag()/(end2-end1).Mag();
721 if(d<MinDistanceToPoint)
723 MinDistanceToPoint=
d;
729 Distance = MinDistanceToPoint;
741 const double* xyz = sp->
XYZ();
742 TVector3 Vec(xyz[0],xyz[1],xyz[2]);
752 double SeedPt[3], SeedErr[3];
754 TVector3 Vec(SeedPt[0],SeedPt[1],SeedPt[2]);
769 double iS, xyz[3], MinDistanceToPoint=10000, MinS=0;
775 TVector3 trackpt(xyz[0],xyz[1],xyz[2]);
777 float d = (vec-trackpt).Mag();
779 if(d<MinDistanceToPoint)
781 MinDistanceToPoint=
d;
787 Distance = MinDistanceToPoint;
810 " of track end. You asked for s = "<<s <<
811 ", which is out of range \n";
813 double xyz1[3], xyz2[3];
817 double dx = pow(pow(xyz1[0]-xyz2[0],2)+
818 pow(xyz1[1]-xyz2[1],2)+
819 pow(xyz1[2]-xyz2[2],2),0.5);
821 for(
int i=0; i!=3; ++i)
823 xyz[i] = (xyz2[i]-xyz1[i])/dx;
839 TVector3 ReturnVec(xyz[0],xyz[1],xyz[2]);
848 TVector3 ReturnVec(xyz[0],xyz[1],xyz[2]);
864 " of track end. You asked for s = "<<s <<
865 ", which is out of range \n";
873 double dtheta = (Pos3-Pos2).Angle(Pos2-Pos1);
908 if(!((LowS>=0)&&(HighS<=1.0)&&(LowS<HighS)))
910 mf::LogError(
"BezierTrack")<<
"Error in partial track calc - S out of range";
919 if(LowSegment!=HighSegment)
922 std::vector<recob::Seed> NewSeedCollection;
923 for(
int seg=LowSegment+1; seg<=HighSegment; ++seg)
928 double PtLow[3], DirLow[3], Err[3];
929 double PtHigh[3], DirHigh[3];
930 double LengthLow, LengthHigh;
932 NewSeedCollection.at(0).GetPoint(PtLow,Err);
933 NewSeedCollection.at(0).GetDirection(DirLow,Err);
934 LengthLow = NewSeedCollection.at(0).GetLength();
936 NewSeedCollection.at(NewSeedCollection.size()-1).GetPoint(PtHigh,Err);
937 NewSeedCollection.at(NewSeedCollection.size()-1).GetDirection(DirHigh,Err);
938 LengthHigh = NewSeedCollection.at(NewSeedCollection.size()-1).
GetLength();
940 double LowScale = fabs((TVector3(PtLow[0],PtLow[1],PtLow[2]) - LowEnd).Dot(TVector3(DirLow[0],DirLow[1],DirLow[2]).Unit()));
942 double HighScale = fabs((TVector3(PtHigh[0],PtHigh[1],PtHigh[2]) - HighEnd).Dot(TVector3(DirHigh[0],DirHigh[1],DirHigh[2]).Unit()));
945 for(
size_t n=0;
n!=3; ++
n)
947 DirLow[
n] *= LowScale / LengthLow;
948 DirHigh[
n] *= HighScale / LengthHigh;
952 NewSeedCollection.at(0).SetDirection(DirLow, Err);
953 NewSeedCollection.at(NewSeedCollection.size()-1).SetDirection(DirHigh, Err);
958 double Pt[3], Dir[3], Err[3];
959 for(
size_t n=0;
n!=3; ++
n)
961 Pt[
n] = 0.5*(HighEnd[
n] + LowEnd[
n]);
962 Dir[
n] = 0.5*(HighEnd[
n] - LowEnd[
n]);
966 std::vector<recob::Seed> NewSeedCollection;
967 NewSeedCollection.push_back(OneSeed);
982 std::map<int, std::map<int, double> > hitmap;
986 for(
size_t i=0; i!=Hits.
size(); ++i)
996 for(std::map<
int,std::map<int,double> >::
const_iterator itview=hitmap.begin();
997 itview!=hitmap.end(); ++itview)
999 std::vector<double> ThisViewdQdx;
1000 ThisViewdQdx.resize(NSeg);
1002 itseg!=itview->second.end(); ++itseg)
1004 int seg = itseg->first;
1008 if((seg>-1) && (seg<NSeg))
1011 fdQdx.push_back(ThisViewdQdx);
1026 std::map<int, std::map<int, double> > hitmap;
1030 for(
size_t i=0; i!=Hits.
size(); ++i)
1033 (hitmap[Hits.
at(i)->View()])[
WhichSegment(SValues.at(i))] += Hits.
at(i)->Integral();
1038 for(std::map<
int,std::map<int,double> >::
const_iterator itview=hitmap.begin();
1039 itview!=hitmap.end(); ++itview)
1041 std::vector<double> ThisViewdQdx;
1042 ThisViewdQdx.resize(NSeg);
1044 itseg!=itview->second.end(); ++itseg)
1047 int seg = itseg->first;
1051 if((seg>-1) && (seg<NSeg))
1054 fdQdx.push_back(ThisViewdQdx);
1071 <<
"Bezier track S value of " << s <<
" is not in the range 0<S<1" 1074 if( view>(
fdQdx.size()-1))
1077 <<
"Bezier track view value of " << view <<
" is not in the range " 1078 <<
"of stored views, 0 < view < " <<
fdQdx.size()
1089 if( ( Segment < (
int)
fdQdx[view].size() ) && (Segment>1))
1090 return fdQdx[view][Segment];
1093 mf::LogVerbatim(
"BezierTrack")<<
"GetdQdx : Bad s " <<s<<
", " <<Segment<<std::endl;
1108 if( view>
fdQdx.size()-1)
1111 <<
"Bezier track view value of " << view <<
" is not in the range " 1112 <<
"of stored views, 0 < view < " <<
fdQdx.size()
1117 double TotaldQdx = 0.;
1118 for(
size_t i=0; i!=NSeg; ++i)
1170 std::vector<recob::SpacePoint> spts(N);
1171 for(
int i=0; i!=N; ++i)
1174 double ErrXYZ[3]={0.1,0.1,0.1};
1190 std::reverse(SeedCol.begin(), SeedCol.end());
1191 for(
size_t i=0; i!=SeedCol.size(); ++i)
1193 SeedCol.at(i)=SeedCol.at(i).Reverse();
1200 std::vector<TVector3>& dirVector,
1201 double const ds)
const 1204 const size_t n_traj_pts = (size_t)(
GetLength()/ds);
1207 xyzVector.resize(n_traj_pts+2);
1208 dirVector.resize(n_traj_pts+2);
1210 for(
size_t i_traj=0; i_traj<=n_traj_pts; i_traj++){
recob::Trajectory fTraj
Internal trajectory representation.
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
Encapsulate the construction of a single cyostat.
std::vector< recob::Seed > GetSeedVector()
int WhichSegment(double S) const
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
geo::WireID WireID() const
Initial tdc tick for hit.
unsigned int Nplanes() const
Number of planes in this tpc.
double GetTrackPitch(geo::View_t view, double s, double WirePitch, unsigned int c=0, unsigned int t=0)
Declaration of signal hit object.
double GetRMSCurvature() const
void GetPoint(double *Pt, double *Err) const
The data type to uniquely identify a Plane.
Point_t const & End() const
Returns the position of the last point of the trajectory [cm].
TVector3 GetTrackDirectionV(double s) const
std::vector< recob::Seed > fSeedCollection
CryostatID_t Cryostat
Index of cryostat.
WireID_t Wire
Index of the wire within its plane.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::vector< double > fSegmentLength
BezierTrack GetPartialTrack(double LowS, double HighS)
void GetProjectedPointUVWX(double s, double *uvw, double *x, int c, int t) const
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
void FillTrajectoryVectors()
void GetTrackPoint(double s, double *xyz) const
virtual double ConvertXToTicks(double X, int p, int t, int c) const =0
void CalculatedQdx(art::PtrVector< recob::Hit >const &)
Vector_t DirectionAtPoint(size_t i) const
Computes and returns the direction of the trajectory at a point.
tracking::Vector_t Vector_t
void GetClosestApproaches(art::PtrVector< recob::Hit > const &hits, std::vector< double > &s, std::vector< double > &Distances) const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
View_t View() const
Which coordinate does this plane measure.
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
std::vector< double > fCumulativeLength
void push_back(Ptr< U > const &p)
std::vector< geo::Point_t > convertCollToPoint(std::vector< Point > const &coll)
enum geo::_plane_sigtype SigType_t
Enumerate the possible plane projections.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Service for finding 3D track seeds.
double GetTotalCharge(unsigned int View) const
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
Utilities to extend the interface of geometry vectors.
Point_t const & LocationAtPoint(size_t i) const
Returns the position at the specified trajectory point.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
void GetProjectedPointUVWT(double s, double *uvw, double *ticks, int c, int t) const
const Double32_t * XYZ() const
BezierTrack(int id, const recob::Trajectory &traj)
reference at(size_type n)
tracking::Positions_t Positions_t
Type of trajectory point list.
PlaneID_t Plane
Index of the plane within its TPC.
double GetSegmentLength(recob::Seed const &s1, recob::Seed const &s2)
size_t NumberTrajectoryPoints() const
Returns the number of stored trajectory points.
Definition of data types for geometry description.
tracking::Momenta_t Momenta_t
Type of momentum list.
Detector simulation of raw signals on wires.
double GetCurvature(double s) const
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
A trajectory in space reconstructed from hits.
void GetTrackDirection(double s, double *xyz) const
float PeakTime() const
Time of the signal peak, in tick units.
anab::Calorimetry GetCalorimetryObject(std::vector< art::Ptr< recob::Hit > > const &Hits, geo::SigType_t sigtype, calo::CalorimetryAlg const &)
Encapsulate the construction of a single detector plane.
std::vector< std::vector< double > > fdQdx
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
std::vector< geo::Vector_t > convertCollToVector(std::vector< Vector > const &coll)
std::vector< recob::SpacePoint > GetSpacePointTrajectory(int N)
void FillTrackVectors(std::vector< TVector3 > &xyzVector, std::vector< TVector3 > &dirVector, double const ds=0.1) const
tracking::Point_t Point_t
void GetBezierPointXYZ(recob::Seed const &s1, recob::Seed const &s2, float t, double *xyz)
void WireEndPoints(geo::WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
TVector3 GetTrackPointV(double s) const
double GetdQdx(double s, unsigned int View) const
constexpr double kBogusD
obviously bogus double value
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
2D representation of charge deposited in the TDC/wire plane
void GetClosestApproach(recob::Hit const &hit, double &s, double &Distance) const
TPCID_t TPC
Index of the TPC within its cryostat.
Point_t const & Start() const
Returns the position of the first point of the trajectory [cm].
Namespace collecting geometry-related classes utilities.
double dEdx_AMP(art::Ptr< recob::Hit > hit, double pitch, double T0=0) const
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:
cet::coded_exception< error, detail::translate > exception
Encapsulate the construction of a single detector plane.
double GetViewdQdx(unsigned int View) const