16 std::vector<TVector3>::const_iterator i1;
17 std::vector<Double_t>::const_iterator i2;
19 for(i1=path_.
pos.begin();i1!=path_.
pos.end();++i1){
23 for(i1=path_.
vel.begin();i1!=path_.
vel.end();++i1){
27 for(i2=path_.
t.begin();i2!=path_.
t.end();++i2){
50 if (
pos.size()==0 ||
pos.size()<=i){
51 std::cerr<<
"Path::GetRecordX : NO ANY VALUES, RETURN NULL VECTOR"<<std::endl;
58 if (
vel.size()==0 ||
vel.size()<=i){
59 std::cerr<<
"Path::GetRecordV : NO ANY VALUES, RETURN NULL VECTOR"<<std::endl;
66 if (
t.size()==0 ||
t.size()<=i){
67 std::cerr<<
"Path::GetRecordT : NO ANY VALUES, RETURN NULL VALUE"<<std::endl;
74 TVector3 & x_, TVector3 & v_,
84 std::cerr<<
"Path::GetInitX : RETURN NULL VECTOR"<<std::endl;
92 std::cerr<<
"Path::GetInitV : NO ANY VALUES, RETURN NULL VECTOR"<<std::endl;
100 std::cerr<<
"Path::GetInitT : NO ANY VALUES, RETURN ZERO VALUE"<<std::endl;
116 std::cerr<<
"Path::GetLastX : NO ANY VALUES, RETURN NULL VECTOR"<<std::endl;
124 std::cerr<<
"Path::GetLastV : NO ANY VALUES, RETURN NULL VECTOR"<<std::endl;
132 std::cerr<<
"Path::GetLastT : NO ANY VALUES, RETURN ZERO VALUE"<<std::endl;
156 const std::vector<Double_t> & t,
157 Int_t k, Double_t & DCA, Double_t & outtime){
160 if(k<=0 || k>=(Int_t)d2.size()-1)
return;
162 Double_t s0 = t[k-1]-t[k];
163 Double_t s2 = t[k+1]-t[k];
164 if(!(s0<0. && s2>0.))
return;
167 Double_t q0 = (d2[k-1]-y1)/s0;
168 Double_t q2 = (d2[k+1]-y1)/s2;
169 Double_t a = (q0-q2)/(s0-s2);
171 Double_t b = q2-a*s2;
172 Double_t sm = -b/(2.*a);
173 if(sm<s0 || sm>s2)
return;
175 Double_t dmin2 = y1-b*b/(4.*a);
176 if(dmin2<0.) dmin2 = 0.;
181void path::GetDCA(
const TVector3 pos_, Double_t & DCA, Double_t & outtime, Bool_t verbose, Bool_t interpolate){
185 if(
pos.empty() ||
pos.size()!=
t.size()){
186 std::cerr<<
"path::GetDCA : EMPTY OR INCONSISTENT PATH, RETURN DCA=-1, TIME=-1"<<std::endl;
190 std::vector<Double_t> d2(
pos.size());
192 for(Int_t i=0; i<(Int_t)
pos.size(); i++){
194 d2[i] = (
pos[i]-pos_).Mag2();
195 if(d2[i]<d2[resultTI]) resultTI = i;
202 DCA = sqrt(d2[resultTI]);
203 outtime =
t[resultTI];
206 std::cerr<<
"path::GetDCA : index "<<resultTI<<
" DCA "<<DCA<<
" time "<<outtime<<std::endl;
210void path::GetDCA(
path* timepath, Double_t & DCA, Double_t & outtime, Bool_t verbose, Bool_t interpolate){
214 if(timepath==
nullptr){
215 std::cerr<<
"path::GetDCA : NULL PATH, RETURN DCA=-1, TIME=-1"<<std::endl;
219 std::cerr<<
"path::GetDCA : PATHS DO NOT SHARE TIME GRID, RETURN DCA=-1, TIME=-1"<<std::endl;
222 if(
pos.empty() ||
pos.size()!=
t.size() || timepath->
pos.size()!=
pos.size()){
223 std::cerr<<
"path::GetDCA : EMPTY OR INCONSISTENT PATH, RETURN DCA=-1, TIME=-1"<<std::endl;
227 std::vector<Double_t> d2(
pos.size());
229 for(Int_t i=0; i<(Int_t)
pos.size(); ++i){
230 d2[i] = (timepath->
pos[i]-
pos[i]).Mag2();
231 if(d2[i]<d2[resultTI]) resultTI = i;
238 DCA = sqrt(d2[resultTI]);
239 outtime =
t[resultTI];
242 std::cerr<<
"path::GetDCA : index "<<resultTI<<
" DCA "<<DCA<<
" time "<<outtime<<std::endl;
248 std::cerr<<
"path::lengthChk : LENGTH CHK ERROR (NOT SAME)"<<std::endl;
263 std::cerr<<
"path::timeChk : TIME CHK ERROR: "<< i << std::endl;
Time-ordered list of (position, velocity, time) samples of one particle.
Bool_t lengthChk(path *target)
True if target has the same number of records; otherwise prints a message on std::cerr and returns fa...
void GetInit(TVector3 &x_, TVector3 &v_, Double_t &t_)
First record as position (fm), velocity (c) and time (fm/c).
Double_t GetLastT()
Time of the last stored record (fm/c); 0 plus message if empty.
TVector3 GetRecordV(Int_t i)
Velocity of record i (c); same failure behaviour as GetRecordX().
std::vector< TVector3 > pos
positions (fm)
TVector3 GetRecordX(Int_t i)
Position of record i (fm).
path()
Create an empty path.
std::vector< TVector3 > vel
velocities (c)
std::vector< Double_t > t
times (fm/c)
Bool_t timeChk(path *target)
True if target has the same length and exactly equal times in every record; prints a message on std::...
void GetDCA(const TVector3 pos_, Double_t &DCA, Double_t &outtime, Bool_t verbose=false, Bool_t interpolate=true)
Distance of closest approach of this path to a fixed point.
TVector3 GetLastV()
Velocity of the last stored record (c); null vector plus message if empty.
void GetRecord(Int_t i, TVector3 &x_, TVector3 &v_, Double_t &t_)
Position, velocity and time of record i in one call.
TVector3 GetLastX()
Position of the last stored record (fm); null vector plus message if empty.
void GetLast(TVector3 &x_, TVector3 &v_, Double_t &t_)
Last stored record as position (fm), velocity (c) and time (fm/c).
Long64_t GetMaxNumber()
Number of stored time stamps (as a 64-bit integer); equals GetRecordSize().
TVector3 GetInitX()
Position of the first record (fm); null vector plus message if the path is empty.
void AddRecord(TVector3 x_, TVector3 v_, Double_t time_)
Append one record at the end.
~path()
Destructor: clears the records.
Double_t GetRecordT(Int_t i)
Time of record i (fm/c).
TVector3 GetInitV()
Velocity of the first record (c); null vector plus message if the path is empty.
Double_t GetInitT()
Time of the first record (fm/c); 0 plus message if the path is empty.
static const Double_t kPathDCAInvalid
static void RefineMinimum(const std::vector< Double_t > &d2, const std::vector< Double_t > &t, Int_t k, Double_t &DCA, Double_t &outtime)
Recorded trajectory of one particle (path) and distance-of-closest-approach helpers.