FEDRA emulsion software from the OPERA Collaboration
EdbVertexRec Class Reference

#include <EdbVertex.h>

Inheritance diagram for EdbVertexRec:
Collaboration diagram for EdbVertexRec:

Public Member Functions

void AcceptModifiedVTX (EdbVertex *eVertex, EdbVertex *eWorking)
 
void AcceptPolish ()
 
Int_t AddSegmentToVertex (EdbSegP *s, float ImpMax=25., float ProbMin=0.01, float Mom=0.3)
 
EdbVTAAddTrack (EdbVertex &edbv, EdbTrackP *track, int zpos)
 
EdbVertexAddTrackToVertex (EdbVertex *eVertex, EdbTrackP *eTr, int zpos)
 
void AddVertex (EdbVertex *vtx)
 
void AddVTA (EdbVTA *vta)
 
void CancelModifiedVTX (EdbVertex *eVertex, EdbVertex *eWorking)
 
Bool_t CheckDZ2 (float z1, float z2, int zpos1, int zpos2, float z)
 
Float_t CheckImpact (EdbSegP *s1, EdbSegP *s2, int zpos1, int zpos2, float pv[3])
 
Float_t CheckImpactN (EdbSegP *s1, EdbSegP *s2, float pv[3], bool &parallel, float dzMax=6000.)
 
int CheckTrack (EdbTrackP &track, int zpos)
 
void CheckVTX ()
 
bool CompatibleSegments (EdbSegP &spred, EdbSegP &stest, float impact, float dthetaMax, float dxy, float zminT, float zmaxT, float zminV, float zmaxV)
 
 EdbVertexRec ()
 
 EdbVertexRec (EdbVertexPar &vpar)
 
int EstimateVertexFlag (int zpos1, int zpos2)
 
Bool_t EstimateVertexPosition (EdbVertex &v)
 
Bool_t EstimateVertexQuality (EdbVertex &v)
 
void FillTracksStartEnd (TIndexCell &starts, TIndexCell &ends)
 
Int_t FindSimilarSegments (EdbSegP &spred, TObjArray &found, EdbPattern &pat, float impact, float dthetaMax, float dxy, float zminT, float zmaxT, float zminV, float zmaxV)
 
Int_t FindSimilarTracks (EdbTrackP &t, TObjArray &found, int nsegmin=2, float dMax=100., float dTheta=0.01, float dZmax=50000.)
 
Int_t FindSimilarTracksE (EdbSegP &spred, TObjArray &found, bool startend, float impact, float dthetaMax, float dxy, float zminT, float zmaxT, float zminV, float zmaxV)
 
Int_t FindVertex ()
 
EdbTrackPGetEdbTrack (const int index)
 
EdbVertexGetVertex (Int_t &i)
 
Bool_t IsInsideLimits (EdbSegP &s)
 
Int_t LinkedVertexes ()
 
Int_t LoopVertex (TIndexCell &list1, TIndexCell &list2, int zpos1, int zpos2)
 
EdbVertexMake1Vertex (TObjArray &tracks, float zexpected)
 
Int_t MakeV (EdbVertex &edbv, bool isRefit=false)
 
Double_t MoveTrackToOtherVertex (EdbVertex *v2, int it2max, EdbVertex *v1, int seltype, EdbVertex **v2n, EdbVertex **v1n)
 
Int_t Nvtx () const
 
EdbVertexProbVertex2 (EdbTrackP *tr1, EdbTrackP *tr2, int zpos1, int zpos2)
 
Int_t ProbVertexN ()
 
Int_t ProbVertexN_old ()
 
Int_t ProbVertexNpos (int zpos)
 
int RefitAll ()
 
void RejectPolish ()
 
EdbVertexRemoveTrackFromVertex (EdbVertex *eVertex, int itr)
 
EdbVertexRemoveVTAFromVertex (EdbVertex &vtx, EdbVTA &vta)
 
void Reset ()
 
Int_t SegmentNeighbor (EdbSegP *s, float RadMax=1000., int Dpat=1, float ImpMax=1000000., float SegWmin=9, TObjArray *aseg=0, TObjArray *atr=0, TObjArray *arv=0)
 
Int_t SelSegNeighbor (EdbSegP *s, int seltype, float RadMax, int Dpat, TObjArray *ao)
 
Int_t SelVertNeighbor (EdbVertex *v, int seltype, float RadMax, int Dpat, TObjArray *ao)
 
void Set0 ()
 
void SetPVRec (EdbPVRec *pvr)
 
void StatVertexN ()
 
EdbVertexStripBadTracks (EdbVertex &v, float impMax, int ntrMin)
 
Double_t Tdistance (const EdbSegP &s1, const EdbSegP &s2)
 
Double_t Tdistance (const VERTEX::Track &t1, const VERTEX::Track &t2)
 
Double_t TdistanceChi2 (const EdbSegP &s1, const EdbSegP &s2, float m)
 
Double_t TdistanceChi2 (const EdbTrackP &tr1, const EdbTrackP &tr2)
 
EdbVertexTestVTAGroup (TObjArray &arrvta)
 
Int_t VertexNeighbor (EdbVertex *v, float RadMax=1000., int Dpat=1, float ImpMax=1000000.)
 
Int_t VertexNeighbor (float RadMax=1000., int Dpat=1, float ImpMax=1000000.)
 
Int_t VertexPolish (EdbVertex *v, int refill=0, float RadMax=1000., int Dpat=2, float ImpMax=25., float ProbMin=0.01, float Mom=0.3)
 
Int_t VertexTuning (int seltype=0)
 
const TVector3 * Vmax () const
 
const TVector3 * Vmin () const
 
virtual ~EdbVertexRec ()
 
- Public Member Functions inherited from EdbVertexPar
 EdbVertexPar ()
 
virtual ~EdbVertexPar ()
 

Public Attributes

TObjArray * eEdbTracks
 
EdbPVRecePVR
 
TList eVTA
 
TObjArray * eVTX
 
- Public Attributes inherited from EdbVertexPar
Float_t eAbin
 
Float_t eDZmax
 
Float_t eImpMax
 
Float_t eImpMaxV
 
Float_t eProbMin
 
Int_t eQualityMode
 
Bool_t eUseKalman
 
Bool_t eUseLimits
 
Bool_t eUseMom
 
Bool_t eUseSegPar
 
TVector3 eVmax
 
TVector3 eVmin
 
Float_t eZbin
 

Private Attributes

EdbVertexeVertex
 
EdbVertexeWorking
 

Constructor & Destructor Documentation

◆ EdbVertexRec() [1/2]

EdbVertexRec::EdbVertexRec ( )
inline
209 { Set0(); }
void Set0()
Definition: EdbVertex.cxx:723

◆ EdbVertexRec() [2/2]

EdbVertexRec::EdbVertexRec ( EdbVertexPar vpar)
inline
210 : EdbVertexPar(vpar) { Set0(); }
EdbVertexPar()
Definition: EdbVertex.cxx:708

◆ ~EdbVertexRec()

EdbVertexRec::~EdbVertexRec ( )
virtual
735 {
736  if ((gROOT->GetListOfSpecials())->FindObject(this))
737  {
738  (gROOT->GetListOfSpecials())->Remove(this);
739  }
740  Reset();
741 }
void Reset()
Definition: EdbVertex.cxx:744

Member Function Documentation

◆ AcceptModifiedVTX()

void EdbVertexRec::AcceptModifiedVTX ( EdbVertex eVertex,
EdbVertex eWorking 
)
2707 {
2708  if (eWorking && eVertex)
2709  {
2710  EdbVertex *eW = eWorking;
2711  int ind = eVertex->ID();
2712  eW->SetID(ind);
2713  eW->SetQuality(eW->V()->prob()/
2714  (eW->V()->vtx_cov_x()+eW->V()->vtx_cov_y()));
2715  int ntr = eVertex->N();
2716  for(int i=0; i<ntr; i++)
2717  {
2718  eVTA.Remove(eVertex->GetVTa(i));
2719  }
2720 
2721  eW->ResetTracks();
2722  ntr = eW->N();
2723  int ifl = 0;
2724  for(int i=0; i<ntr; i++)
2725  {
2726  if (eW->Zpos(i)) ifl = ifl | 1;
2727  else ifl = ifl | 2;
2728  }
2729  ifl = 4 - ifl;
2730  if (ifl == 3) ifl = 0;
2731  if (eW->Nv()) ifl += 3;
2732  eW->SetFlag(ifl);
2733  if (eVTX) eVTX->AddAt(eW, ind);
2734  for(int i=0; i<ntr; i++)
2735  {
2736  AddVTA(eW->GetVTa(i));
2737  }
2738  ntr = eVertex->Nn();
2739  for(int i=0; i<ntr; i++)
2740  {
2741  eW->AddVTA(eVertex->GetVTn(i));
2742  }
2743 // if (eVertex) delete eVertex;
2744  eW->ResetTracks();
2745  }
2746 }
TObjArray * eVTX
Definition: EdbVertex.h:205
EdbVertex * eWorking
Definition: EdbVertex.h:199
void AddVTA(EdbVTA *vta)
Definition: EdbVertex.h:286
EdbVertex * eVertex
Definition: EdbVertex.h:198
TList eVTA
Definition: EdbVertex.h:203
Definition: EdbVertex.h:68
Int_t ID() const
Definition: EdbVertex.h:126
void SetQuality(float q=0)
Definition: EdbVertex.h:161
EdbVTA * GetVTn(int i)
Definition: EdbVertex.h:140
void AddVTA(EdbVTA *vta)
Definition: EdbVertex.cxx:377
void SetID(int ID=0)
Definition: EdbVertex.h:156
Int_t N() const
Definition: EdbVertex.h:121
VERTEX::Vertex * V() const
Definition: EdbVertex.h:154
Int_t Nn() const
Definition: EdbVertex.h:122
void SetFlag(int flag=0)
Definition: EdbVertex.h:158
EdbVTA * GetVTa(int i)
Definition: EdbVertex.h:139
void ResetTracks()
Definition: EdbVertex.cxx:209
Int_t Zpos(int i)
Definition: EdbVertex.h:127
Int_t Nv()
Definition: EdbVertex.cxx:389
float vtx_cov_x() const
$\sigma_x^2$ of vertex
Definition: VtVertex.C:254
float vtx_cov_y() const
$\sigma_y^2$ of vertex
Definition: VtVertex.C:255
float prob() const
upper tail $\chi^2$ probability
Definition: VtVertex.C:237

◆ AcceptPolish()

void EdbVertexRec::AcceptPolish ( )
2206 {
2208 }
void AcceptModifiedVTX(EdbVertex *eVertex, EdbVertex *eWorking)
Definition: EdbVertex.cxx:2706

◆ AddSegmentToVertex()

int EdbVertexRec::AddSegmentToVertex ( EdbSegP s,
float  ImpMax = 25.,
float  ProbMin = 0.01,
float  Mom = 0.3 
)
2001 {
2002  EdbVTA *vta = 0;
2003  EdbVertex *ePrevious = 0;
2004 
2005  if (eWorking == 0)
2006  {
2007  eWorking = new EdbVertex();
2008  int ntr = eVertex->N();
2009  int i = 0, n = 0;
2010  for(i=0; i<ntr; i++)
2011  {
2012  if ((vta = AddTrack(*(eWorking), eVertex->GetTrack(i), eVertex->Zpos(i))))
2013  {
2014  eVertex->GetTrack(i)->AddVTA(vta);
2015  n++;
2016  }
2017  }
2018  if (n < 2)
2019  {
2020  SafeDelete(eWorking);
2021  eVertex->ResetTracks();
2022  printf("Can't create working copy of the vertex!\n");
2023  fflush(stdout);
2024  return 0;
2025  }
2026 
2027  if (!MakeV(*(eWorking)))
2028  {
2029  SafeDelete(eWorking);
2030  eVertex->ResetTracks();
2031  printf("Can't create working copy of the vertex!\n");
2032  fflush(stdout);
2033  return 0;
2034  }
2035  }
2036  else
2037  {
2038  ePrevious = eWorking;
2039  eWorking = new EdbVertex();
2040  int ntr = ePrevious->N();
2041  int i = 0, n = 0;
2042  for(i=0; i<ntr; i++)
2043  {
2044  if ((vta = AddTrack(*(eWorking),(ePrevious)->GetTrack(i), (ePrevious)->Zpos(i))))
2045  {
2046  (ePrevious->GetTrack(i))->AddVTA(vta);
2047  n++;
2048  }
2049  }
2050  if (n < 2)
2051  {
2052  SafeDelete(eWorking);
2053  if (ePrevious)
2054  {
2055  eWorking = ePrevious;
2056  eWorking->ResetTracks();
2057  }
2058  else
2059  {
2060  eVertex->ResetTracks();
2061  }
2062  printf("Can't create working copy of the vertex!\n");
2063  fflush(stdout);
2064  return 0;
2065  }
2066 
2067  if (!MakeV(*(eWorking)))
2068  {
2069  SafeDelete(eWorking);
2070 
2071  if (ePrevious)
2072  {
2073  eWorking = ePrevious;
2074  eWorking->ResetTracks();
2075  }
2076  else
2077  {
2078  eVertex->ResetTracks();
2079  }
2080  printf("Can't create working copy of the vertex!\n");
2081  fflush(stdout);
2082  return 0;
2083  }
2084  }
2085  float mass = 0.139; //pion
2086  EdbTrackP *Tr = new EdbTrackP(s, mass);
2087  Tr->SetP(Mom);
2088  Tr->FitTrackKFS();
2089  float ImpMaxSave = eImpMax;
2090  eImpMax = ImpMax;
2091  float ProbMinSave = eProbMin;
2092  eProbMin = ProbMin;
2093  if ((vta = AddTrack(*(eWorking), Tr, 1)))
2094  {
2095  if ( Tr->Z() >= eWorking->VZ() ) vta->SetZpos(1);
2096  else vta->SetZpos(0);
2097  Tr->AddVTA(vta);
2098  EdbVertex *eW = eWorking;
2099  eW->SetID(eVertex->ID());
2100  eW->V()->rmsDistAngle();
2101  int trind = eEdbTracks->GetEntriesFast();
2102  Tr->SetID(trind);
2103  eEdbTracks->Add(Tr);
2104  Tr->SetSegmentsTrack();
2105  eImpMax = ImpMaxSave;
2106  eProbMin = ProbMinSave;
2107  }
2108  else
2109  {
2110  printf("Track not added! May be Prob < ProbMin=%f. Change ProbMin with 'TrackParams' button!\n",ProbMin);
2111  fflush(stdout);
2112  delete Tr;
2113 
2114  SafeDelete(eWorking);
2115  if (ePrevious)
2116  {
2117  eWorking = ePrevious;
2118  eWorking->ResetTracks();
2119  }
2120  else
2121  {
2122  eVertex->ResetTracks();
2123  }
2124  eImpMax = ImpMaxSave;
2125  eProbMin = ProbMinSave;
2126  return 0;
2127  }
2128  return 1;
2129 }
FILE * stdout
void SetID(int id)
Definition: EdbSegP.h:125
Float_t Z() const
Definition: EdbSegP.h:150
void SetP(float p)
Definition: EdbSegP.h:130
Definition: EdbPattern.h:118
void AddVTA(EdbVTA *vta)
Definition: EdbPattern.cxx:493
int FitTrackKFS(bool zmax=false, float X0=5810., int design=0)
Definition: EdbPattern.cxx:765
int SetSegmentsTrack(int id)
Definition: EdbPattern.h:252
Definition: EdbVertex.h:25
void SetZpos(int zpos)
Definition: EdbVertex.h:54
Float_t eImpMax
Definition: EdbVertex.h:179
Float_t eProbMin
Definition: EdbVertex.h:178
Int_t MakeV(EdbVertex &edbv, bool isRefit=false)
Definition: EdbVertex.cxx:813
TObjArray * eEdbTracks
Definition: EdbVertex.h:204
EdbVTA * AddTrack(EdbVertex &edbv, EdbTrackP *track, int zpos)
Definition: EdbVertex.cxx:900
EdbTrackP * GetTrack(int i)
Definition: EdbVertex.h:141
Float_t VZ() const
Definition: EdbVertex.h:135
double rmsDistAngle() const
calc rms dist and rms angle
Definition: VtVertex.C:1073
float mass
Definition: check_vertex.C:21
float ImpMax
Definition: check_vertex.C:30
EdbSegP * s
Definition: tlg2pattern.C:32

◆ AddTrack()

EdbVTA * EdbVertexRec::AddTrack ( EdbVertex edbv,
EdbTrackP track,
int  zpos 
)
901 {
902  // add track to already existing vertex if prob > eProbMin
903  // if vertex do not exist yet - calculate medium x,y,z
904 
905  if (!track) return 0;
906  EdbSegP *seg = track->TrackExtremity( zpos, eUseSegPar);
907  if (!seg) return 0;
908  int ntr = edbv.N();
909  if(edbv.TrackInVertex(track)) return 0;
910  //for (int i=0; i<ntr; i++) if(track == edbv.GetTrack(i)) return 0;
911 
912  EdbVTA *vta = new EdbVTA(track, &edbv);
913  vta->SetZpos(zpos);
914  vta->SetFlag(2);
915  edbv.AddVTA(vta);
916 
917  if(ntr<1) // this is the first track in the vertex
918  {
919  edbv.SetXYZ( seg->X(), seg->Y(), seg->Z());
920  return vta;
921  }
922  else
923  {
924  if( MakeV(edbv) )
925  if( (edbv.V()->prob() > eProbMin) ) return vta;
926  }
927  edbv.RemoveVTA(vta);
928  if(ntr>1)
929  if( !MakeV(edbv) ) Log(1,"EdbVertexRec::AddTrack","vertex lost! ntr = %d",ntr);
930  SafeDelete(vta);
931  return 0;
932 }
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
Definition: EdbSegP.h:18
Float_t X() const
Definition: EdbSegP.h:170
Float_t Y() const
Definition: EdbSegP.h:171
void SetFlag(int flag)
Definition: EdbVertex.h:55
Bool_t eUseSegPar
Definition: EdbVertex.h:182
Bool_t TrackInVertex(EdbTrackP *t)
Definition: EdbVertex.cxx:221
void SetXYZ(float x, float y, float z)
Definition: EdbVertex.h:157
void RemoveVTA(EdbVTA *vta)
Definition: EdbVertex.cxx:383
Definition: bitview.h:14

◆ AddTrackToVertex()

EdbVertex * EdbVertexRec::AddTrackToVertex ( EdbVertex eVertex,
EdbTrackP eTr,
int  zpos 
)
2544 {
2545  EdbVTA *vta = 0;
2546  EdbVertex *old = 0;
2547  EdbVertex *eWorking = 0;
2548  if (!eVertex)
2549  {
2550 
2551  printf("No working vertex selected!\n");
2552  fflush(stdout);
2553  return 0;
2554  }
2555  if (!eTr)
2556  {
2557 
2558  printf("No working track selected!\n");
2559  fflush(stdout);
2560  return 0;
2561  }
2562  if ((old = eTr->VertexS()) && (zpos == 1))
2563  {
2564 
2565  printf("Track alredy connected to a vertex by this edge!\n");
2566  fflush(stdout);
2567  return 0;
2568  }
2569  if ((old = eTr->VertexE()) && (zpos == 0))
2570  {
2571 
2572  printf("Track alredy connected to a vertex by this edge!\n");
2573  fflush(stdout);
2574  return 0;
2575  }
2576  if (eWorking == 0)
2577  {
2578  eWorking = new EdbVertex();
2579  int ntr = eVertex->N();
2580  int i = 0, n = 0;
2581  for(i=0; i<ntr; i++)
2582  {
2583  if ((vta = AddTrack(*(eWorking), (eVertex)->GetTrack(i), (eVertex)->Zpos(i))))
2584  {
2585  (eVertex)->GetTrack(i)->AddVTA(vta);
2586  n++;
2587  }
2588  }
2589  if (n < 2)
2590  {
2591  SafeDelete(eWorking);
2592  (eVertex)->ResetTracks();
2593  printf("Can't create working copy of the vertex!\n");
2594  fflush(stdout);
2595  return 0;
2596  }
2597 
2598  if (!MakeV(*eWorking))
2599  {
2600  SafeDelete(eWorking);
2601  eVertex->ResetTracks();
2602  printf("Can't create working copy of the vertex!\n");
2603  fflush(stdout);
2604  return 0;
2605  }
2606  }
2607  if ((vta = AddTrack(*eWorking, eTr, zpos)))
2608  {
2609  eTr->AddVTA(vta);
2610  eWorking->SetID(eVertex->ID());
2611  }
2612  else
2613  {
2614 // printf("Track not added! May be Prob < ProbMin.\n");
2615 // fflush(stdout);
2616  SafeDelete(eWorking);
2617  eVertex->ResetTracks();
2618  return 0;
2619  }
2620  return eWorking;
2621 }
EdbVertex * VertexS()
Definition: EdbPattern.cxx:1284
EdbVertex * VertexE()
Definition: EdbPattern.cxx:1291

◆ AddVertex()

void EdbVertexRec::AddVertex ( EdbVertex vtx)
inline
290  {
291  if (!eVTX) eVTX = new TObjArray();
292  eVTX->Add((TObject*)vtx);
293  }

◆ AddVTA()

void EdbVertexRec::AddVTA ( EdbVTA vta)
inline
286 {eVTA.Add((TObject*)vta);}

◆ CancelModifiedVTX()

void EdbVertexRec::CancelModifiedVTX ( EdbVertex eVertex,
EdbVertex eWorking 
)
2749 {
2750  SafeDelete(eWorking);
2751  if (eVertex) eVertex->ResetTracks();
2752 }

◆ CheckDZ2()

Bool_t EdbVertexRec::CheckDZ2 ( float  z1,
float  z2,
int  zpos1,
int  zpos2,
float  z 
)
1422 {
1423  // return 1 if the vertex position (z) is in agreement with limits defined by eZbin and eDZmax
1424 
1425  float zvmin,zvmax;
1426  if (zpos1 == 0 && zpos2 == 1) // ends & starts
1427  {
1428  zvmin = TMath::Min(z1,z2) - 0.5*eZbin;
1429  zvmax = TMath::Max(z1,z2) + 0.5*eZbin;
1430  if (z < zvmin || z > zvmax) return 0;
1431  }
1432  else if (zpos1 == 1 && zpos2 == 1) // starts & starts
1433  {
1434  zvmax = TMath::Min(z1,z2) + eZbin;
1435  zvmin = TMath::Max(z1,z2) - eDZmax;
1436  if (z > zvmax || z < zvmin) return 0;
1437  }
1438  else if (zpos1 == 0 && zpos2 == 0) // ends & ends
1439  {
1440  zvmin = TMath::Max(z1 ,z2);
1441  zvmax = TMath::Min(z1 ,z2) + eDZmax + eZbin;
1442  if (z < zvmin || z > zvmax ) return 0;
1443  }
1444  return 1;
1445 }
Float_t eZbin
Definition: EdbVertex.h:175
Float_t eDZmax
Definition: EdbVertex.h:177

◆ CheckImpact()

float EdbVertexRec::CheckImpact ( EdbSegP s1,
EdbSegP s2,
int  zpos1,
int  zpos2,
float  pv[3] 
)
1245 {
1246  // Return: the distance between 2 lines defined by s1 and s2
1247  // Input: s1,s2,zpos1,zpos2, where
1248  // zpos1, zpos2: 0 - end of the track (to be propagated forward in z)
1249  // zpos1, zpos2: 1 - start of the track (to be propagated backward in z)
1250  // Output: pv - "vertex position" - the nearest point to the both lines
1251 
1252  float p1[3], p2[3]; // first line
1253  float p3[3], p4[3]; // second line
1254  float pa[3], pb[3]; // shortest line
1255  double mua, mub;
1256 
1257  float dz;
1258 
1259  p1[0] = s1->X();
1260  p1[1] = s1->Y();
1261  p1[2] = s1->Z();
1262  dz = zpos1? -eDZmax : eDZmax;
1263  p2[0] = s1->X() + dz*s1->TX();
1264  p2[1] = s1->Y() + dz*s1->TY();
1265  p2[2] = s1->Z() + dz;
1266 
1267  p3[0] = s2->X();
1268  p3[1] = s2->Y();
1269  p3[2] = s2->Z();
1270  dz = zpos2? -eDZmax : eDZmax;
1271  p4[0] = s2->X() + dz*s2->TX();
1272  p4[1] = s2->Y() + dz*s2->TY();
1273  p4[2] = s2->Z() + dz;
1274 
1275  if( !EdbMath::LineLineIntersect( p1, p2, p3, p4, pa, pb, mua, mub ) ) return 10e+10;
1276  if (pv) for (int i = 0; i<3; i++) pv[i] = 0.5*(pa[i] + pb[i]);
1277  return EdbMath::Magnitude3( pa, pb );
1278 }
brick dz
Definition: RecDispMC.C:107
static double Magnitude3(float Point1[3], float Point2[3])
Definition: EdbMath.cxx:52
static bool LineLineIntersect(float p1[3], float p2[3], float p3[3], float p4[3], float pa[3], float pb[3], double &mua, double &mub)
Definition: EdbMath.cxx:88
Float_t TX() const
Definition: EdbSegP.h:172
Float_t TY() const
Definition: EdbSegP.h:173
EdbSegP * s1
Definition: tlg2pattern.C:30
EdbSegP * s2
Definition: tlg2pattern.C:31

◆ CheckImpactN()

float EdbVertexRec::CheckImpactN ( EdbSegP s1,
EdbSegP s2,
float  pv[3],
bool &  parallel,
float  dzMax = 6000. 
)
1284 {
1285  // Return: the distance between 2 lines defined by s1 and s2
1286  // Output: pv - "vertex position" - the nearest point to the both lines
1287 
1288  float imp = 1e+10;
1289  float p1[3], p2[3]; // first line
1290  float p3[3], p4[3]; // second line
1291  float pa[3], pb[3]; // shortest line
1292  double mua, mub;
1293 
1294  p1[0] = s1->X() - dzMax*s1->TX();
1295  p1[1] = s1->Y() - dzMax*s1->TY();
1296  p1[2] = s1->Z() - dzMax;
1297  p2[0] = s1->X() + dzMax*s1->TX();
1298  p2[1] = s1->Y() + dzMax*s1->TY();
1299  p2[2] = s1->Z() + dzMax;
1300 
1301  p3[0] = s2->X() - dzMax*s2->TX();
1302  p3[1] = s2->Y() - dzMax*s2->TY();
1303  p3[2] = s2->Z() - dzMax;
1304  p4[0] = s2->X() + dzMax*s2->TX();
1305  p4[1] = s2->Y() + dzMax*s2->TY();
1306  p4[2] = s2->Z() + dzMax;
1307 
1308  if( EdbMath::LineLineIntersect( p1, p2, p3, p4, pa, pb, mua, mub ) ) {
1309  parallel = false;
1310  for (int i = 0; i<3; i++) pv[i] = 0.5*(pa[i] + pb[i]);
1311  imp = EdbMath::Magnitude3( pa, pb );
1312  } else { // the lines are parallel: take as vertex the mean point, calc. the distance to line
1313  parallel = true;
1314  pv[0] = 0.5*(s1->X()+s2->X());
1315  pv[1] = 0.5*(s1->Y()+s2->Y());
1316  pv[2] = 0.5*(s1->Z()+s2->Z());
1317  bool inside=0;
1318  imp = 2. * EdbMath::DistancePointLine3(pv, p1,p2, &inside);
1319  }
1320  return imp;
1321 }
static double DistancePointLine3(float Point[3], float LineStart[3], float LineEnd[3], bool inside)
Definition: EdbMath.cxx:61

◆ CheckTrack()

int EdbVertexRec::CheckTrack ( EdbTrackP track,
int  zpos 
)
3265 {
3266  // loop for all tracks and check if some of them can form the vertex with tr
3267  int ntr = eEdbTracks->GetEntriesFast();
3268  if(ntr<1) return 0;
3269  int nvtx=0;
3270 
3271  EdbTrackP *t=0;
3272  for(int itr=0; itr<ntr; itr++) {
3273  t = (EdbTrackP*)(eEdbTracks->At(itr));
3274  if (t == &track) continue;
3275  if (t->Flag() < 0) continue;
3276 
3277  EdbVertex *vtx0 = ProbVertex2( &track, t, zpos, 0 );
3278  if(vtx0) {
3279  AddVertex(vtx0);
3280  nvtx++;
3281  }
3282  EdbVertex *vtx1 = ProbVertex2( &track, t, zpos, 1 );
3283  if(vtx1) {
3284  AddVertex(vtx1);
3285  nvtx++;
3286  }
3287 
3288  }
3289  Log(2,"EdbVertexRec::CheckTrack","%d couples found",nvtx);
3290  return nvtx;
3291 }
TTree * t
Definition: check_shower.C:4
void AddVertex(EdbVertex *vtx)
Definition: EdbVertex.h:290
EdbVertex * ProbVertex2(EdbTrackP *tr1, EdbTrackP *tr2, int zpos1, int zpos2)
Definition: EdbVertex.cxx:1324

◆ CheckVTX()

void EdbVertexRec::CheckVTX ( )
1521 {
1522  // rank the vertices and reassign tracks according to the major vertex weight
1523 
1524  if(!eVTX) return;
1525  int nvtx = eVTX->GetEntriesFast();
1526  Log(2,"EdbVertexRec::CheckVTX","%d vertices",nvtx);
1527  if(nvtx<1) return;
1528 
1529  TArrayF weight(nvtx); // the vertex "weight" = 10*ntr+prob
1530  TArrayI ind(nvtx);
1531  EdbVertex *vtx=0;
1532  for(int i=0; i<nvtx; i++) {
1533  vtx = GetVertex(i);
1534  //vtx->SetFlag(0); // to check!!!
1535  weight[i] = 10*vtx->N() + vtx->V()->prob();
1536  }
1537  TMath::Sort(nvtx,weight.GetArray(),ind.GetArray(),0); // sort in ascending order
1538  for(int i=0; i<nvtx; i++) {
1539  vtx = GetVertex(ind[i]);
1540  vtx->ResetTracks();
1541  }
1542 
1543  // discard vertices with the detached tracks
1544  for(int i=0; i<nvtx; i++) {
1545  vtx = GetVertex(ind[i]);
1546  int ndisc = vtx->CheckDiscardedTracks();
1547  if(ndisc>0) {
1548  Log(2,"EdbVertexRec::CheckVTX","discard vtx i=%d ntr=%d flag before: %d disc tracks: %d",i, vtx->N(), vtx->Flag(), ndisc);
1549  vtx->SetFlag(-10);
1550  } else {
1551  vtx->EstimateVertexFlag();
1552  }
1553  }
1554 
1555  // reassign the vertex id's
1556  for (Int_t i = 0; i < nvtx; i++) GetVertex(i)->SetID(i);
1557 
1558  //eVTA.Clear(); //TODO?
1559 }
EdbVertex * GetVertex(Int_t &i)
Definition: EdbVertex.h:288
Int_t EstimateVertexFlag()
Definition: EdbVertex.cxx:184
Int_t Flag() const
Definition: EdbVertex.h:124
Int_t CheckDiscardedTracks()
Definition: EdbVertex.cxx:168

◆ CompatibleSegments()

bool EdbVertexRec::CompatibleSegments ( EdbSegP spred,
EdbSegP stest,
float  impact,
float  dthetaMax,
float  dxy,
float  zminT,
float  zmaxT,
float  zminV,
float  zmaxV 
)
1001 {
1002  float impMin = 5; // limits for the tracks separability
1003  float thetaMin = 0.005; //
1004 
1005  if( TMath::Abs(stest.X()-pred.X()) > dxy ) return 0;
1006  if( TMath::Abs(stest.Y()-pred.Y()) > dxy ) return 0;
1007  if( stest.Z() < zminT ) return 0;
1008  if( stest.Z() > zmaxT ) return 0;
1009 
1010  float dtheta = TMath::Sqrt( (stest.TX()-pred.TX())*(stest.TX()-pred.TX()) + (stest.TY()-pred.TY())*(stest.TY()-pred.TY()) );
1011  if(dtheta>dthetaMax) return 0;
1012  float pv[3];
1013  bool parallel;
1014  float imp = CheckImpactN( &pred,&stest,pv, parallel, eDZmax);
1015  if(imp>impact) return 0;
1016 
1017  //printf("v: %f %f %f\n", pv[0],pv[1],pv[2]);
1018  //pred.PrintNice();
1019 
1020  if( dtheta<thetaMin && imp > 3*impMin) return 0; // parallel not close tracks ( can be interesting for decay search??)
1021 
1022  if( dtheta>thetaMin) { // check z of the vertex
1023  float marg = impMin/dtheta;
1024  if( pv[2] < zminV-marg ) return 0;
1025  if( pv[2] > zmaxV+marg ) return 0;
1026  }
1027 
1028  Log(2,"EdbVertexRec::CompatibleSegments","ids = %6d and %6d PH: %3d imp = %7.3f dtheta = %7.3f dzT = %7.3f dzV = %7.3f",
1029  pred.ID(), stest.ID(), int(stest.W()), imp, dtheta, stest.Z()-pred.Z(), pv[2]-pred.Z());
1030  return 1;
1031 }
Int_t ID() const
Definition: EdbSegP.h:144
Float_t W() const
Definition: EdbSegP.h:148
Float_t CheckImpactN(EdbSegP *s1, EdbSegP *s2, float pv[3], bool &parallel, float dzMax=6000.)
Definition: EdbVertex.cxx:1282

◆ EstimateVertexFlag()

int EdbVertexRec::EstimateVertexFlag ( int  zpos1,
int  zpos2 
)
1399 {
1400  if (zpos1 == 0 && zpos2 == 1) return 1; // end & start
1401  else if (zpos1 == 1 && zpos2 == 0) return 1; // end & start
1402  else if (zpos1 == 1 && zpos2 == 1) return 0; // start & start
1403  else if (zpos1 == 0 && zpos2 == 0) return 2; // end & end
1404  return -1;
1405 }

◆ EstimateVertexPosition()

Bool_t EdbVertexRec::EstimateVertexPosition ( EdbVertex v)
776 {
777  // make approximate (without matrix) estimation of the vertex and set the reference point of
778  // the vertex XYZ in the estimated position
779 
780  int nt = v.N();
781  if(nt<2) return false;
782 
783  EdbSegP *s1=0,*s2=0;
784  bool zpos1,zpos2;
785  float vxyz[3], vsum[3];
786  for(int i=0; i<3; i++) vsum[i]=0;
787  int count=0;
788  for(int i1=0; i1<nt-1; i1++) {
789  s1 = v.GetTrackV(i1,eUseSegPar);
790  zpos1 = v.Zpos(i1);
791  for(int i2=1; i2<nt; i2++) {
792  s2 = v.GetTrackV(i2,eUseSegPar);
793  zpos2 = v.Zpos(i2);
794  if( CheckImpact(s1,s2,zpos1,zpos2, vxyz) > 2.*eImpMax) continue;
795  for(int i=0; i<3; i++) vsum[i]+=vxyz[i];
796  count++;
797  }
798  }
799  if(count) for(int i=0; i<3; i++) vsum[i]/=count;
800  else { // take just mean tracks position
801  for(int i=0; i<nt; i++) {
802  EdbSegP *s = v.GetTrackV(i,eUseSegPar);
803  vsum[0] += s->X(); vsum[1] += s->Y(); vsum[2] += s->Z();
804  }
805  for(int i=0; i<3; i++) vsum[i]/=nt;
806  }
807  v.SetXYZ(vsum[0],vsum[1],vsum[2]);
808  Log(3,"EdbVertexRec::EstimateVertexPosition","%f %f %f",vsum[0],vsum[1],vsum[2]);
809  return true;
810 }
float vxyz[3]
Definition: RecDispMC.C:144
Float_t CheckImpact(EdbSegP *s1, EdbSegP *s2, int zpos1, int zpos2, float pv[3])
Definition: EdbVertex.cxx:1243
EdbSegP * GetTrackV(int i, bool usesegpar=false)
Definition: EdbVertex.cxx:159

◆ EstimateVertexQuality()

Bool_t EdbVertexRec::EstimateVertexQuality ( EdbVertex v)
752 {
753  // TODO! razobratsia s etimi qualitiami!!
754 
755  float quality=0.;
756  vtx.SetQuality(quality);
757  Vertex *v = vtx.V();
758  if(!v) return 0;
759  if(!v->valid()) return 0;
760 
761  if (eQualityMode == 0) quality = v->prob()/(v->vtx_cov_x()+v->vtx_cov_y());
762  else if (eQualityMode == 1)
763  {
764  double rms=v->rmsDistAngle();
765  if (rms != 0.) quality= (float)(1./rms);
766  else quality = 10.e+35;
767  }
768  else quality= 1.;
769 
770  vtx.SetQuality(quality);
771  return 1;
772 }
Int_t eQualityMode
Definition: EdbVertex.h:183
Definition: VtVertex.hh:88
bool valid() const
is vertex valid?

◆ FillTracksStartEnd()

void EdbVertexRec::FillTracksStartEnd ( TIndexCell starts,
TIndexCell ends 
)
1136 {
1137  // fill tracks starts and ends lookup tables "z:entry"
1138  // inside sorted tracks: starts - minimal Z; ends - maximal Z
1139 
1140  EdbTrackP *tr=0;
1141  int ntr = eEdbTracks->GetEntriesFast();
1142  Long_t v[2];
1143 
1144  EdbSegP *s=0;
1145  for(int itr=0; itr<ntr; itr++) {
1146  tr = (EdbTrackP*)(eEdbTracks->At(itr));
1147  if (tr->Flag() < 0) continue;
1148  s = tr->TrackZmin(eUseSegPar);
1149  if(eUseLimits) if( !IsInsideLimits(*s) ) continue;
1150  v[0] = (Long_t)(s->Z()/eZbin);
1151  v[1] = itr;
1152  starts.Add(2,v);
1153  s = tr->TrackZmax(eUseSegPar);
1154  if(eUseLimits) if( !IsInsideLimits(*s) ) continue;
1155  v[0] = (Long_t)(s->Z()/eZbin);
1156  v[1] = itr;
1157  ends.Add(2,v);
1158  }
1159  starts.Sort();
1160  ends.Sort();
1161 }
TTree * tr
Definition: Shower_E_FromShowerRoot.C:5
Bool_t eUseLimits
Definition: EdbVertex.h:185
Bool_t IsInsideLimits(EdbSegP &s)
Definition: EdbVertex.cxx:1408
void Sort(Int_t upto=kMaxInt)
Definition: TIndexCell.cpp:539
Int_t Add(Int_t narg, Long_t varg[])
Definition: TIndexCell.cpp:602

◆ FindSimilarSegments()

Int_t EdbVertexRec::FindSimilarSegments ( EdbSegP spred,
TObjArray &  found,
EdbPattern pat,
float  impact,
float  dthetaMax,
float  dxy,
float  zminT,
float  zmaxT,
float  zminV,
float  zmaxV 
)
1037 {
1038  // Find all segments from path compatible with the pred segment and add them to found array
1039 
1040  int nseg = pat.N(); if(nseg<1) return 0;
1041  int nfound=0;
1042  for(int i=0; i<nseg; i++) {
1043  EdbSegP *s = pat.GetSegment(i);
1044  if (s->Flag() < 0) continue; // sure?
1045  if( CompatibleSegments( spred,*s, impact, dthetaMax, dxy, zminT, zmaxT, zminV, zmaxV) ) found.Add(s);
1046  else continue;
1047  nfound++;
1048  }
1049  Log(2,"EdbVertexRec::FindSimilarSegments","%d segments are found",nfound);
1050  return nfound;
1051 }
Int_t Flag() const
Definition: EdbSegP.h:146
Int_t N() const
Definition: EdbPattern.h:89
EdbSegP * GetSegment(int i) const
Definition: EdbPattern.h:66
bool CompatibleSegments(EdbSegP &spred, EdbSegP &stest, float impact, float dthetaMax, float dxy, float zminT, float zmaxT, float zminV, float zmaxV)
Definition: EdbVertex.cxx:998

◆ FindSimilarTracks()

Int_t EdbVertexRec::FindSimilarTracks ( EdbTrackP t,
TObjArray &  found,
int  nsegmin = 2,
float  dMax = 100.,
float  dTheta = 0.01,
float  dZmax = 50000. 
)
936 {
937  // find all tracks close to the "track" and return them in "found"
938  // nsegmin - min number of segments for the interesting tracks
939  // gMax - max 3-d distance between track lines
940  // dTheta - max spatial angle between track lines
941  // dZmax - max distance in z between track lines
942 
943  using namespace TMath;
944  int ntr = eEdbTracks->GetEntriesFast();
945  if(ntr<1) return 0;
946 
947  EdbTrackP *t=0;
948  EdbSegP *s=track.TrackZmin(eUseSegPar);
949  EdbSegP *e=track.TrackZmax(eUseSegPar);
950  EdbSegP *ts=0, *te=0; // start and end for the other tracks
951 
952  track.FitTrack();
953  EdbSegP *t1=(EdbSegP*)(&track);
954  EdbSegP *t2;
955  int nfound=0;
956  float pv[3], imp, dtheta;
957  for(int itr=0; itr<ntr; itr++) {
958  t = (EdbTrackP*)(eEdbTracks->At(itr));
959  if (t == &track) continue;
960  if (t->Flag() < 0) continue;
961  ts = t->TrackZmin(eUseSegPar);
962  te = t->TrackZmax(eUseSegPar);
963  if( Min(ts->X(),te->X()) - Max(s->X(),e->X()) > dMax ) continue;
964  if( Min(s->X(),e->X()) - Max(ts->X(),te->X()) > dMax ) continue;
965  if( Min(ts->Y(),te->Y()) - Max(s->Y(),e->Y()) > dMax ) continue;
966  if( Min(s->Y(),e->Y()) - Max(ts->Y(),te->Y()) > dMax ) continue;
967  if( Min(ts->Z(),te->Z()) - Max(s->Z(),e->Z()) > dZmax ) continue;
968  if( Min(s->Z(),e->Z()) - Max(ts->Z(),te->Z()) > dZmax ) continue;
969 
970  t->FitTrack();
971  t2 = (EdbSegP*)t;
972  dtheta = Sqrt( (t2->TX()-t1->TX())*(t2->TX()-t1->TX()) + (t2->TY()-t1->TY())*(t2->TY()-t1->TY()) );
973  if(dtheta>dTheta) continue;
974  imp = CheckImpact( t1,t2,1,1, pv);
975  if(imp>dMax) continue;
976 
977  found.Add(t);
978  nfound++;
979  }
980 
981  Log(2,"EdbVertexRec::FindSimilarTracks","%d tracks found",nfound);
982  if(gEDBDEBUGLEVEL>1) {
983  for(int i=0; i<found.GetEntriesFast(); i++) {
984  t = (EdbTrackP*)found.At(i);
985  t2 = (EdbSegP*)t;
986  dtheta = Sqrt( (t2->TX()-t1->TX())*(t2->TX()-t1->TX()) + (t2->TY()-t1->TY())*(t2->TY()-t1->TY()) );
987  imp = CheckImpact( t1,t2,1,1, pv);
988  Log(3,"EdbVertexRec::FindSimilarTracks",
989  "id =%6d imp = %7.3f dtheta = %7.3f nseg =%3d\n", t->ID(), imp, dtheta,t->N());
990  }
991  }
992 
993  return nfound;
994 }
gEDBDEBUGLEVEL
Definition: energy.C:7

◆ FindSimilarTracksE()

Int_t EdbVertexRec::FindSimilarTracksE ( EdbSegP spred,
TObjArray &  found,
bool  startend,
float  impact,
float  dthetaMax,
float  dxy,
float  zminT,
float  zmaxT,
float  zminV,
float  zmaxV 
)
1057 {
1058  // Find all tracks with the requested extremity close to the pred segment and add them to found array
1059  //
1060  // startend - selecting tracks extremity to be used: 0-tracks starts (zmin) 1-tracks ends (zmax)
1061  // impact - max 3D distance between segment lines
1062  // dthetaMax - max spatial angle between track lines
1063  // dxy - preliminary distance cut between segments
1064  // zminT,zmaxT - limits in Z for the tracks extremity
1065  // zminV,zmaxV - limits in Z for the estimated vertex position
1066 
1067  int ntr = eEdbTracks->GetEntriesFast();
1068  if(ntr<1) return 0;
1069  int nfound=0;
1070 
1071  EdbSegP *t1=&spred;
1072  for(int itr=0; itr<ntr; itr++) {
1073  EdbTrackP *t = (EdbTrackP*)(eEdbTracks->At(itr));
1074  if (t->Flag() < 0) continue;
1075  EdbSegP *te = t->TrackExtremity(startend,eUseSegPar); // select track extremity
1076 
1077  if( CompatibleSegments( *t1,*te, impact, dthetaMax, dxy, zminT, zmaxT, zminV, zmaxV) ) found.Add(t);
1078  else continue;
1079 
1080  nfound++;
1081  }
1082  Log(2,"EdbVertexRec::FindSimilarTracksE","%d tracks found",nfound);
1083  return nfound;
1084 }

◆ FindVertex()

int EdbVertexRec::FindVertex ( )
1088 {
1089  // Note: in this function is assumed that all tracks selections are already done
1090  // ProbMin - minimal probability for chi2-distance between tracks
1091 
1092  //if(!ePVR) ePVR = ((EdbPVRec *)(gROOT->GetListOfSpecials()->FindObject("EdbPVRec")));
1093  if (ePVR) if (ePVR->IsA() != EdbPVRec::Class()) ePVR = 0;
1094  if(!ePVR) {Log(1,"EdbVertexRec::FindVertex","Error! EdbPVRec not defined, use SetPVRec(...)"); return 0;}
1095 
1096  EdbVertex *edbv = 0;
1097  TIndexCell starts,ends; // "ist:entry" "iend:entry"
1098  FillTracksStartEnd( starts, ends );
1099 
1100  if(gEDBDEBUGLEVEL>1) printf("-----Search 2-track vertices----------------------------\n");
1101 
1102  int nvtx = 0;
1103 
1104  if(gEDBDEBUGLEVEL>1) printf(" End-Begin tracks combinations:\n");
1105  nvtx += LoopVertex(ends , starts, 0, 1 );
1106 
1107  if(gEDBDEBUGLEVEL>1) printf(" Begin-Begin tracks combinations:\n");
1108  nvtx += LoopVertex(starts, starts, 1, 1 );
1109 
1110  if(gEDBDEBUGLEVEL>1) printf(" End-End tracks combinations:\n");
1111  nvtx += LoopVertex(ends , ends, 0, 0 );
1112 
1113  int nvtxt = 0;
1114  if (eVTX) nvtxt = eVTX->GetEntriesFast();
1115 
1116  if(nvtx!=nvtxt) printf("ERROR: EdbVertexRec::FindVertex(): nvtx =%d nvtxt =%d\n",nvtx,nvtxt);
1117 
1118  //for (Int_t i = 0; i < nvtxt; i++) GetVertex(i)->SetID(i);
1119 
1120  if (nvtxt) eVTX->Sort(nvtxt-1);
1121 
1122  for (Int_t i = nvtx-1; i >= 0; i--) {
1123  edbv = GetVertex(i);
1124  if (!edbv) continue;
1125  edbv->SetID(i);
1126  edbv->ResetTracks();
1127  }
1128 
1129  if(gEDBDEBUGLEVEL>1) printf("----------------- %d vtx ---------------------------------------\n", nvtx);
1130 
1131  return nvtx;
1132 }
Int_t LoopVertex(TIndexCell &list1, TIndexCell &list2, int zpos1, int zpos2)
Definition: EdbVertex.cxx:1164
void FillTracksStartEnd(TIndexCell &starts, TIndexCell &ends)
Definition: EdbVertex.cxx:1135
EdbPVRec * ePVR
Definition: EdbVertex.h:206
Definition: TIndexCell.h:19

◆ GetEdbTrack()

EdbTrackP * EdbVertexRec::GetEdbTrack ( const int  index)
3258 {
3259  if (eEdbTracks) return (EdbTrackP *)eEdbTracks->At(index);
3260  else return 0;
3261 }

◆ GetVertex()

EdbVertex* EdbVertexRec::GetVertex ( Int_t &  i)
inline
288 {return eVTX ? (EdbVertex*)eVTX->At(i):0;}

◆ IsInsideLimits()

Bool_t EdbVertexRec::IsInsideLimits ( EdbSegP s)
1409 {
1410  // return 1 if the segment position (x,y,z) is inside the limits defined by eVmin,eVmax
1411  if(s.X()<eVmin.X()) return 0;
1412  if(s.Y()<eVmin.Y()) return 0;
1413  if(s.Z()<eVmin.Z()) return 0;
1414  if(s.X()>eVmax.X()) return 0;
1415  if(s.Y()>eVmax.Y()) return 0;
1416  if(s.Z()>eVmax.Z()) return 0;
1417  return 1;
1418 }
TVector3 eVmax
Definition: EdbVertex.h:186
TVector3 eVmin
Definition: EdbVertex.h:186

◆ LinkedVertexes()

int EdbVertexRec::LinkedVertexes ( )
1832 {
1833  // calculate the number of linked vertices (with Nv()>0) and set flag+3 for them
1834  int nvt = Nvtx();
1835  if (!nvt) return 0;
1836  EdbVertex *v = 0;
1837  int nvl = 0;
1838  for (int iv=0; iv<nvt; iv++) {
1839  v = GetVertex(iv);
1840  if (v)
1841  if (v->Flag() != -10)
1842  if (v->Nv() != 0) {
1843  if (v->Flag() < 3) v->SetFlag(v->Flag()+3);
1844  nvl++;
1845  }
1846  }
1847  return nvl;
1848 }
Int_t Nvtx() const
Definition: EdbVertex.h:287

◆ LoopVertex()

int EdbVertexRec::LoopVertex ( TIndexCell list1,
TIndexCell list2,
int  zpos1,
int  zpos2 
)
1166 {
1167 
1168  // zpos1 - the direction flag for the first track 1-start, 0-end
1169  // zpos2 - the direction flag for the second track
1170  // in cycles is assumed that members of list1 has z <= members of list2
1171 
1172  Log(3,"EdbVertexRec::LoopVertex"," Selection: dZmax=%.0f Abin=%.3f ProbMin=%f zBin=%.0f usemom=%d",
1174 
1175  int nvtx = 0;
1176  int ncombin = 0;
1177  int ncount = 0;
1178 
1179  TIndexCell *c1=0, *c2=0;
1180  EdbTrackP *tr1=0, *tr2=0;
1181  int itr1, itr2;
1182 
1183  int nz1 = list1.GetEntriesFast();
1184  int nz2 = list2.GetEntriesFast();
1185  float z1, z2;
1186 
1187  //int ntot = nz1*nz2;
1188  //printf(" 2-track vertices search in progress... %3d%%", 0);
1189 
1190  for(int iz1=0; iz1<nz1; iz1++) { // first z-group
1191  c1 = list1.At(iz1);
1192  z1 = c1->Value()*eZbin;
1193  int nc1=c1->GetEntriesFast();
1194 
1195  for(int iz2=0; iz2<nz2; iz2++) { // second z-group
1196  c2 = list2.At(iz2);
1197  z2 = c2->Value()*eZbin;
1198 
1199  if( z2 < z1 ) continue;
1200  if( z2-z1 > eDZmax ) break;
1201 
1202  ncount++;
1203  //printf("\b\b\b\b%3d%%",(int)((double)ncount/double(ntot)*100.));
1204  fflush(stdout);
1205 
1206  int nc2=c2->GetEntriesFast();
1207  for(int ic1=0; ic1<nc1; ic1++) { // first z-group entries
1208 
1209  itr1 = c1->At(ic1)->Value();
1210  tr1 = (EdbTrackP*)((*eEdbTracks)[itr1]);
1211  if(!tr1) continue;
1212 
1213  int ic2start=0;
1214  if(c1==c2) ic2start=ic1+1;
1215 
1216  for(int ic2=ic2start; ic2<nc2; ic2++) { // second z-group entries
1217  ncombin++;
1218 
1219  itr2 = c2->At(ic2)->Value();
1220  if(itr2==itr1) continue;
1221  tr2 = (EdbTrackP*)((*eEdbTracks)[itr2]);
1222  if(!tr2) continue;
1223 
1224  EdbVertex *vtx = ProbVertex2( tr1, tr2, zpos1, zpos2 );
1225  if(vtx) {
1226  AddVertex(vtx);
1227  nvtx++;
1228  }
1229 
1230  }
1231  }
1232  }
1233  }
1234 
1235  //printf("\b\b\b\b%3d%%\n",100);
1236 
1237  Log(3,"EdbVertexRec::LoopVertex"," %6d pairs -> %d vertices accepted\n", ncombin, nvtx);
1238 
1239  return nvtx;
1240 }
Bool_t eUseMom
Definition: EdbVertex.h:181
Float_t eAbin
Definition: EdbVertex.h:176
Int_t GetEntriesFast() const
Definition: TIndexCell.h:82
TIndexCell const * At(Int_t narg, Int_t vind[]) const
Definition: TIndexCell.cpp:519
TCanvas * c1
Definition: energy.C:13
TCanvas * c2
Definition: energy.C:26

◆ Make1Vertex()

EdbVertex * EdbVertexRec::Make1Vertex ( TObjArray &  tracks,
float  zexpected 
)
880 {
881  // make a single vertex using tracks array
882 
883  EdbVertex *v = new EdbVertex();
884  v->SetXYZ( 0,0, zexpected );
885  int ntr = tracks.GetEntriesFast();
886  for(int i=0; i<ntr; i++) {
887  EdbTrackP *t = (EdbTrackP*)tracks.At(i);
888  EdbVTA *vta = new EdbVTA(t,v);
889  vta->SetFlag(2);
890  v->AddVTA(vta);
891  (t->Z() >= v->Z())? vta->SetZpos(1) : vta->SetZpos(0);
892  t->AddVTA(vta);
893  }
894  if( MakeV(*v) ) AddVertex(v);
895  else { SafeDelete(v); return 0; } // vertex is not valid
896  return v;
897 }
Float_t Z() const
Definition: EdbVertex.h:132
TTree * tracks
Definition: check_tr.C:19

◆ MakeV()

int EdbVertexRec::MakeV ( EdbVertex edbv,
bool  isRefit = false 
)
814 {
815  // create new VtVertex and add tracks to this one
816  // if isRefit - use input vertex position to improve the fit (default is false)
817 
818  if (ePVR) if (ePVR->IsA() != EdbPVRec::Class()) ePVR = 0;
819  if(!ePVR) {Log(1,"EdbVertexRec::MakeV","ERROR: EdbPVRec not defined, use SetPVRec(...)"); return 0;}
820 
821  int n = edbv.N();
822  if (n<2) return 0;
823 
824  if(isRefit) edbv.SetXYZ(edbv.VX(),edbv.VY(),edbv.VZ());
825  else EstimateVertexPosition(edbv);
826  edbv.ClearV();
827  Vertex *v = new Vertex();
829  v->use_momentum(eUseMom);
830 
831  float X0 = ePVR->GetScanCond()->RadX0();
832  if(!eUseMom) X0 = -1.; // ignore multiple scattering contribution if eUseMom is false
833 
834  EdbSegP *seg=0;
835  for (int i=0; i<n; i++)
836  {
837  seg = edbv.GetTrackV(i,eUseSegPar);
838  Track *t = new Track();
839  //seg->PrintNice();
840  //printf("%f\n",edbv.Z());
841  edbv.Edb2Vt(*seg, *t, X0, edbv.GetTrack(i)->M());
842  v->add_track(*t);
843  }
844  if (!v->findVertexVt()) { Log(3,"MakeV","can not find VtVertex" ); return 0; }
845  if (!(v->valid())) { Log(3,"MakeV","VtVertex is not valid" ); return 0; }
846  edbv.SetV(v);
847  for(int i=0; i<n; i++)
848  {
849  edbv.GetVTa(i)->SetDist( edbv.VZ() - edbv.GetTrackV(i,eUseSegPar)->Z() );
850  edbv.GetVTa(i)->SetImp( distance(v->get_track(i),*v) );
851 // printf("dist = %f imp = %f\n", edbv.GetVTa(i)->Dist(), edbv.GetVTa(i)->Imp() );
852 // edbv.GetTrack(i)->PrintNice();
853  }
854  EstimateVertexQuality(edbv);
855  Log( 3,"EdbVertexRec::MakeV","impmax = %f",edbv.MaxImpact() );
856  return 1;
857 }
EdbScanCond const * GetScanCond()
Definition: EdbPVRec.h:172
float RadX0() const
Definition: EdbScanCond.h:58
Float_t M() const
Definition: EdbPattern.h:160
void SetImp(float imp)
Definition: EdbVertex.h:56
void SetDist(float dist)
Definition: EdbVertex.h:57
Bool_t eUseKalman
Definition: EdbVertex.h:184
Bool_t EstimateVertexQuality(EdbVertex &v)
Definition: EdbVertex.cxx:751
Bool_t EstimateVertexPosition(EdbVertex &v)
Definition: EdbVertex.cxx:775
Float_t VX() const
Definition: EdbVertex.h:133
void SetV(VERTEX::Vertex *v)
Definition: EdbVertex.h:160
Float_t VY() const
Definition: EdbVertex.h:134
void ClearV()
Definition: EdbVertex.cxx:115
Float_t MaxImpact()
Definition: EdbVertex.h:116
void Edb2Vt(const EdbTrackP &tr, VERTEX::Track &t, float X0=0., float m=0.139)
Definition: EdbVertex.cxx:590
Definition: VtTrack.hh:64
void use_kalman(const bool use)
use refitted track parameters or not
void add_track(Track &t)
Definition: VtVertex.C:261
void use_momentum(const bool use)
set for all tracks whether momentum should be used or not
Definition: VtVertex.C:279
const Track * get_track(int i) const
Definition: VtVertex.C:266
const bool findVertexVt()
Vt Kalman-filter.
Definition: VtVertex.C:1174
float X0
Definition: emthickness.cpp:69
@ Track
Definition: tlg2pattern.C:53
double distance(const Track &t, const Vertex &v)
spatial distance track - vertex
Definition: VtDistance.C:49

◆ MoveTrackToOtherVertex()

double EdbVertexRec::MoveTrackToOtherVertex ( EdbVertex v2,
int  it2max,
EdbVertex v1,
int  seltype,
EdbVertex **  v2n,
EdbVertex **  v1n 
)
2470 {
2471 // printf("Rearrange vertexies %d and %d\n",v1->ID(),v2->ID());
2472  *v1no = 0;
2473  *v2no = 0;
2474  if (!v1 || !v2) return 0.;
2475  if (v2->N() < 3) return 0.;
2476  if (it2max >= v2->N()) return 0.;
2477  EdbVertex *v1n = 0, *v2n = 0;
2478  EdbTrackP *tr2 = 0;
2479  int zpos = 0;
2480  double dx, dy, dz, dist1, dist2, imp, vchisum, vdistsum;
2481  tr2 = v2->GetTrack(it2max);
2482  dx = v1->VX() - tr2->TrackZmin()->X();
2483  dy = v1->VY() - tr2->TrackZmin()->Y();
2484  dz = v1->VZ() - tr2->TrackZmin()->Z();
2485  dist1 = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
2486  dx = v1->VX() - tr2->TrackZmax()->X();
2487  dy = v1->VY() - tr2->TrackZmax()->Y();
2488  dz = v1->VZ() - tr2->TrackZmax()->Z();
2489  dist2 = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
2490  if (dist2 < dist1)
2491  {
2492  zpos = 0;
2493  }
2494  else
2495  {
2496  zpos = 1;
2497  }
2498  imp = v1->DistTrack(tr2, zpos);
2499  if (imp > 1.2*eImpMax) return 0.;
2500  if ((v2n = RemoveTrackFromVertex(v2, it2max)))
2501  {
2502  *v2no = v2n;
2503  v1n = AddTrackToVertex(v1, tr2, zpos);
2504  if (!v1n)
2505  {
2506 // CancelModifiedVTX(v2,v2n);
2507  return 0.;
2508  }
2509  *v1no = v1n;
2510  vchisum = v1n->V()->chi2() + v2n->V()->chi2();
2511  vdistsum = v1n->V()->rmsDistAngle() + v2n->V()->rmsDistAngle();
2512  if (seltype == 0)
2513  {
2514  return vdistsum;
2515  }
2516  else
2517  {
2518  return vchisum;
2519  }
2520  }
2521  return 0.;
2522 }
EdbSegP * TrackZmin(bool usesegpar=false) const
Definition: EdbPattern.h:203
EdbSegP * TrackZmax(bool usesegpar=false) const
Definition: EdbPattern.h:204
EdbVertex * RemoveTrackFromVertex(EdbVertex *eVertex, int itr)
Definition: EdbVertex.cxx:2641
EdbVertex * AddTrackToVertex(EdbVertex *eVertex, EdbTrackP *eTr, int zpos)
Definition: EdbVertex.cxx:2543
Float_t DistTrack(EdbTrackP *tr, int zpos, float X0=0.)
Definition: EdbVertex.cxx:684
float chi2() const
$\chi^2$ of vertex fit
Definition: VtVertex.C:236

◆ Nvtx()

Int_t EdbVertexRec::Nvtx ( ) const
inline
287 {return eVTX ? eVTX->GetEntriesFast() : 0;}

◆ ProbVertex2()

EdbVertex * EdbVertexRec::ProbVertex2 ( EdbTrackP tr1,
EdbTrackP tr2,
int  zpos1,
int  zpos2 
)
1326 {
1327  // Check if 2 tracks can form the vertex. If yes - return the pointer to the new EdbVertex object
1328  Log(3,"EdbVertexRec::ProbVertex2", "try tracks %d and %d", tr1->ID(), tr2->ID() );
1329 
1330  if(!tr1) return 0;
1331  if(!tr2) return 0;
1332  if(tr1==tr2) return 0;
1333  EdbSegP *s1 = tr1->TrackExtremity(zpos1,eUseSegPar);
1334  EdbSegP *s2 = tr2->TrackExtremity(zpos2,eUseSegPar);
1335 //zpos2? tr2->TrackZmin(eUseSegPar):tr2->TrackZmax(eUseSegPar);
1336  if(!s1) return 0;
1337  if(!s2) return 0;
1338 
1339  // check the dZ position agreement
1340  float dz = TMath::Abs(s2->Z()-s1->Z());
1341  if( dz > eDZmax ) return 0;
1342 
1343  // check the dX dY position agreement
1344  int isign;
1345  float dtx,dty,deltaZ=0;
1346  if(zpos1!=zpos2) { // start-end, end-start
1347  deltaZ = (dz+eZbin);
1348  isign = -1;
1349  } else { // start-start, end-end
1350  deltaZ = (eDZmax-dz/2.);
1351  isign = +1;
1352  }
1353  dtx = TMath::Abs(s2->TX() - isign*s1->TX())+eAbin;
1354  if( TMath::Abs(s2->X()-s1->X()) > dtx*deltaZ ) return 0;
1355  dty = TMath::Abs(s2->TY() - isign*s1->TY())+eAbin;
1356  if( TMath::Abs(s2->Y()-s1->Y()) > dty*deltaZ ) return 0;
1357 
1358  // check the impact
1359  float vestim[3];
1360  //float imp = CheckImpact( s1, s2, zpos1, zpos2, vestim );
1361  bool parallel;
1362  float imp = CheckImpactN( s1, s2, vestim, parallel, eDZmax );
1363  Log(3,"EdbVertexRec::ProbVertex2", "impact = %f", imp );
1364  if(imp>eImpMax) return 0;
1365 
1366  // create the new EdbVertex
1367  EdbVertex *vtx = new EdbVertex();
1368  vtx->SetXYZ(vestim[0],vestim[1],vestim[2]);
1369 
1370  EdbVTA *vta1 = new EdbVTA(tr1,vtx);
1371  vta1->SetZpos(zpos1);
1372  vta1->SetFlag(2);
1373  vtx->AddVTA(vta1);
1374 
1375  EdbVTA *vta2 = new EdbVTA(tr2,vtx);
1376  vta2->SetZpos(zpos2);
1377  vta2->SetFlag(2);
1378  vtx->AddVTA(vta2);
1379 
1380  if(MakeV(*vtx)) {
1381  vtx->SetFlag( EstimateVertexFlag(zpos1,zpos2) );
1382  //if(imp<eImpMaxV) // accept the vertex even if prob is small (parallel tracks)
1383  // return vtx;
1384  //else // do additional checks
1385  if( vtx->V()->prob() >= eProbMin ) {
1386  if( Log(3,"EdbVertexRec::ProbVertex2", "prob = %f", vtx->V()->prob()) ) vtx->Print();
1387  if( CheckDZ2( s1->Z(), s2->Z(), zpos1,zpos2, vtx->VZ() ) )
1388  return vtx;
1389  }
1390  }
1391  SafeDelete(vta1);
1392  SafeDelete(vta2);
1393  SafeDelete(vtx);
1394  return 0;
1395 }
EdbSegP * TrackExtremity(bool zpos, bool usesegpar=false) const
Definition: EdbPattern.h:206
int EstimateVertexFlag(int zpos1, int zpos2)
Definition: EdbVertex.cxx:1398
Bool_t CheckDZ2(float z1, float z2, int zpos1, int zpos2, float z)
Definition: EdbVertex.cxx:1421
void Print()
Definition: EdbVertex.cxx:328

◆ ProbVertexN()

int EdbVertexRec::ProbVertexN ( )
1449 {
1450  if(gEDBDEBUGLEVEL>1) printf("*** on entry to ProbVertexN: nv = %d\n", eVTX->GetEntriesFast());
1451  ProbVertexNpos(0); // find n-track vtx attached to left edges
1452  if(gEDBDEBUGLEVEL>1) printf("*** npoz 0 ProbVertexN: nv = %d\n", eVTX->GetEntriesFast());
1453  ProbVertexNpos(1); // to right edges
1454  if(gEDBDEBUGLEVEL>1) printf("*** npoz 1 ProbVertexN: nv = %d\n", eVTX->GetEntriesFast());
1455 
1456  CheckVTX(); // rank the vertices and reassign tracks according to the major rank
1457  if(gEDBDEBUGLEVEL>0) StatVertexN(); // print vertex statistics
1458  return 0;
1459 }
Int_t ProbVertexNpos(int zpos)
Definition: EdbVertex.cxx:1462
void StatVertexN()
Definition: EdbVertex.cxx:1806
void CheckVTX()
Definition: EdbVertex.cxx:1520

◆ ProbVertexN_old()

int EdbVertexRec::ProbVertexN_old ( )
1602 {
1603  // deprecated function (VT: 7/05/2008. Keeped for back-compatibility tests.
1604  // After the complete testing of the new ProbVertexN this function can be removed
1605 
1606  EdbVTA *vta = NULL, *vta1 = NULL, *vta2 = NULL;
1607  EdbVertex *edbv1 = NULL;
1608  EdbVertex *edbv2 = NULL;
1609  Vertex *v = 0;
1610  EdbTrackP *tr = 0;
1611  EdbTrackP *tr2 = 0;
1612  Int_t zpos = 0;
1613  int nvtx = 0;
1614  int nadd = 0;
1615  int ncombin = 0;
1616  int ncombinv = 0;
1617  bool wasadded = false;
1618  float dz = 0.;
1619 
1620  if (eVTX) {
1621  nvtx = eVTX->GetEntriesFast();
1622  for (Int_t i = 0; i < nvtx; i++) {
1623  edbv1 = GetVertex(i);
1624  if (edbv1) {
1625  if (edbv1->N() > 2) {
1626  for (Int_t j = 0; j<edbv1->N(); j++) eVTA.Remove(edbv1->GetVTa(j));
1627  for (Int_t j = 0; j<edbv1->Nn(); j++) eVTA.Remove(edbv1->GetVTn(j));
1628  tr = edbv1->GetTrack(0);
1629  tr2 = edbv1->GetTrack(1);
1630  edbv1->Clear();
1631  vta1 = AddTrack(*edbv1, tr, edbv1->Zpos(0));
1632  vta2 = AddTrack(*edbv1, tr2, edbv1->Zpos(1));
1633  MakeV(*edbv1);
1634  v = edbv1->V();
1635  v->findVertexVt();
1636 
1637  if (!eQualityMode)
1638  edbv1->SetQuality(v->prob()/(v->vtx_cov_x()+v->vtx_cov_y()));
1639  else if (eQualityMode == 1) {
1640  Double_t rms = v->rmsDistAngle();
1641  if (rms) edbv1->SetQuality((Float_t)(1./rms));
1642  else edbv1->SetQuality(10.e+35);
1643  }
1644  else edbv1->SetQuality(1.);
1645 
1646  tr->AddVTA(vta1);
1647  tr2->AddVTA(vta2);
1648  AddVTA(vta1);
1649  AddVTA(vta2);
1650  }
1651  else {
1652  if (edbv1->Flag() < 0) {
1653  zpos = edbv1->Zpos(0) + edbv1->Zpos(1);
1654  if (!zpos) edbv1->SetFlag(2);
1655  else if (zpos == 1) edbv1->SetFlag(1);
1656  else if (zpos == 2) edbv1->SetFlag(0);
1657  }
1658  }
1659  }
1660  }
1661  edbv1 = 0;
1662  }
1663  else return 0;
1664 
1665  zpos = 0;
1666 
1667  nvtx = eVTX->GetEntriesFast();
1668  printf("-----Merge 2-track vertex pairs to N-track vertices-----\n");
1669  printf("N-track vertices search in progress... %3d%%", 0);
1670 
1671  int nprint = (int)(0.05*(double)nvtx);
1672  if (nprint <= 0) nprint = 1;
1673 
1674  for (Int_t i1 = 0; i1 < nvtx; i1++) {
1675  wasadded = false;
1676  edbv1 = GetVertex(i1);
1677  if (!(i1%nprint)) {
1678  printf("\b\b\b\b%3d%%",(int)((double)i1/double(nvtx)*100.));
1679  fflush(stdout);
1680  }
1681  if (!edbv1) continue;
1682  if (edbv1->Flag() == -10) continue;
1683  Int_t nt1 = edbv1->N();
1684  bool exist = false;
1685  if (nt1 == 2) {
1686  for (Int_t ic1 = 0; ic1 < nt1; ic1++) {
1687  tr = edbv1->GetTrack(ic1);
1688  zpos = edbv1->Zpos(ic1);
1689  if (zpos) {
1690  if (tr->VertexS()) {
1691  if (nt1 < tr->VertexS()->N()) {
1692  exist = true;
1693  break;
1694  }
1695  }
1696  }
1697  else {
1698  if (tr->VertexE()) {
1699  if (nt1 < tr->VertexE()->N()) {
1700  exist = true;
1701  break;
1702  }
1703  }
1704  }
1705  }
1706 
1707  if (exist) {
1708  edbv1->SetFlag(-10);
1709  continue;
1710  }
1711  }
1712  for (Int_t i2 = i1+1; i2<nvtx; i2++) {
1713  edbv2 = GetVertex(i2);
1714  if (!edbv2) continue;
1715  if (edbv2->Flag() == -10) continue;
1716  if (edbv2->N() == 2) {
1717  // printf(" v1 id %d, v2 id %d\n", edbv1->ID(), edbv2->ID());
1718  nt1 = edbv1->N();
1719  int nt2 = edbv2->N();
1720  int it1=0;
1721  int nomatch = 1;
1722  while (it1 < nt1 && nomatch) {
1723  int it2=0;
1724  tr = edbv1->GetTrack(it1);
1725  while ( (it2<nt2) && nomatch) {
1726  if (edbv2->GetTrack(it2) == tr &&
1727  edbv1->Zpos(it1) == edbv2->Zpos(it2)) {
1728  ncombin++;
1729  if (!it2) {
1730  tr2 = edbv2->GetTrack(1);
1731  zpos = edbv2->Zpos(1);
1732  }
1733  else if (it2 == 1) {
1734  tr2 = edbv2->GetTrack(0);
1735  zpos = edbv2->Zpos(0);
1736  }
1737 
1738  exist = false;
1739  for (int ic1=0; ic1<edbv1->N(); ic1++)
1740  if (tr2 == edbv1->GetTrack(ic1)) exist = true;
1741 
1742  if (zpos) {
1743  if (tr2->VertexS()) {
1744  if (tr2->VertexS()->N() > edbv1->N()) exist = true;
1745  }
1746  }
1747  else {
1748  if (tr2->VertexE()) {
1749  if (tr2->VertexE()->N() > edbv1->N()) {
1750  exist = true;
1751  }
1752  }
1753  }
1754  if (!exist) {
1755  ncombinv++;
1756  if (zpos) dz = edbv1->VZ() - tr2->TrackZmin(eUseSegPar)->Z();
1757  else dz = tr2->TrackZmax(eUseSegPar)->Z() - edbv1->VZ();
1758  if(dz <= eZbin)
1759  if ((vta = AddTrack(*edbv1, tr2, zpos))) {
1760  nomatch = 0;
1761  wasadded = true;
1762  edbv2->SetFlag(-10);
1763  tr2->AddVTA(vta);
1764  AddVTA(vta);
1765  int vfl=edbv1->Flag();
1766  if (vfl==0&&zpos==0) edbv1->SetFlag(1);
1767  else if (vfl==2&&zpos==1) edbv1->SetFlag(1);
1768  // printf("Add track ID %d from vertex %d to vertex %d\n",
1769  // tr2->ID(), i2, i1);
1770  }
1771  }
1772  else {
1773  nomatch = 0;
1774  }
1775  edbv2->SetFlag(-10);
1776  } // if one of tracks vertex 2 equal any track in vertex 1
1777  it2++;
1778  } // tracks in vertex 2
1779  it1++;
1780  } // tracks in vertex 1
1781  } // if vertex 2 has rank 2
1782  } // second vertex loop
1783  if (wasadded) nadd++;
1784  } // first vertex loop
1785 
1786  printf("\b\b\b\b%3d%%\n",100);
1787 
1788  printf(" %6d 2-track vertex pairs with common track\n", ncombin);
1789  printf(" %6d pairs when common track not yet attached\n %6d N-track vertices with Prob > %f\n",
1790  ncombinv, nadd, eProbMin);
1791  printf("--------------------------------------------------------\n");
1792 
1793  for (int i1=0; (i1<nvtx); i1++) {
1794  edbv1 = GetVertex(i1);
1795  if (!edbv1) continue;
1796  if (edbv1->Flag() == -10) continue;
1797  edbv1->ResetTracks();
1798  }
1799 
1800  StatVertexN();
1801  return nadd;
1802 }
void Clear()
Definition: EdbVertex.cxx:125
#define NULL
Definition: nidaqmx.h:84

◆ ProbVertexNpos()

int EdbVertexRec::ProbVertexNpos ( int  zpos)
1463 {
1464  // cycle by all vertices, check if it is possible to join some of them by common track, do it
1465 
1466  if (!eVTX) return 0;
1467  int nv2 = eVTX->GetEntriesFast(); // number of vertices
1468  if(nv2<2) return 0;
1469 
1470  Log(2,"EdbVertexRec::ProbVertexNpos","%d vertices as input",nv2);
1471 
1472  // first group vertices with a common track
1473 
1474  TMap maptr; //key is track, value is TObjArray of vertices
1475  TObjArray *arr=0;
1476  EdbVertex *vtx=0;
1477  EdbTrackP *t=0;
1478  for( int i=0; i<nv2; i++) {
1479  vtx = GetVertex(i);
1480  if(!vtx) Log(1,"EdbVertexRec::ProbVertexNpos","vertex not found!");
1481  for( int j=0; j<vtx->N(); j++) {
1482  t = vtx->GetTrack(j);
1483  if(!t) Log(1,"EdbVertexRec::ProbVertexNpos","track not found!");
1484  if(!(vtx->Zpos(j)==zpos)) continue;
1485  arr = (TObjArray*)maptr.GetValue(t);
1486  if(!arr) {
1487  arr = new TObjArray();
1488  maptr.Add(t,arr);
1489  }
1490  arr->Add(vtx);
1491  }
1492  }
1493 
1494  TIter next(maptr.GetTable());
1495  TPair *a;
1496  while ((a = (TPair*) next())) { // cycle by all keys (tracks)
1497  t = (EdbTrackP*)a->Key();
1498  arr = (TObjArray*)a->Value();
1499  int nv = arr->GetEntriesFast();
1500  //printf( "nv = %d\n", nv );
1501  if(nv<2) continue;
1502  TObjArray arrvta; // group of vta of tracks attached to t
1503  for(int iv=0; iv<nv; iv++) {
1504  vtx = (EdbVertex*)arr->At(iv);
1505  for(int it=0; it<vtx->N(); it++) { arrvta.Add(vtx->GetVTa(it)); }
1506  }
1507  EdbVertex *newvtx=TestVTAGroup(arrvta);
1508  if(newvtx) {
1509  Log(3,"EdbVertexRec::ProbVertexNpos","add new vtx with %d tracks and flag = %d\n",newvtx->N(),newvtx->Flag() );
1510  eVTX->Add(newvtx);
1511  }
1512  }
1513 
1514  Log(2,"EdbVertexRec::ProbVertexNpos","%d entries in the map for zpos = %d",maptr.GetSize(), zpos);
1515 
1516  return 0;
1517 }
void a()
Definition: check_aligned.C:59
EdbVertex * TestVTAGroup(TObjArray &arrvta)
Definition: EdbVertex.cxx:1562

◆ RefitAll()

int EdbVertexRec::RefitAll ( )
2526 {
2527  // use already found vertex position to improve the fit
2528  int nv = eVTX->GetEntriesFast();
2529  EdbVertex *vtx = 0;
2530  int cnt=0;
2531  for (int i=0; i<nv; i++) {
2532  vtx = GetVertex(i);
2533  if(vtx)
2534  if(vtx->Flag()>-1) {
2535  MakeV(*vtx,true);
2536  cnt++;
2537  }
2538  }
2539  return cnt;
2540 }

◆ RejectPolish()

void EdbVertexRec::RejectPolish ( )
2211 {
2213 }
void CancelModifiedVTX(EdbVertex *eVertex, EdbVertex *eWorking)
Definition: EdbVertex.cxx:2748

◆ RemoveTrackFromVertex()

EdbVertex * EdbVertexRec::RemoveTrackFromVertex ( EdbVertex eVertex,
int  itr 
)
2642 {
2643  if (!eVertex)
2644  {
2645 
2646  printf("No working vertex selected!\n");
2647  fflush(stdout);
2648  return 0;
2649  }
2650  EdbVTA *vta = 0;
2651  EdbVertex *eWorking = 0; // is a bug?? redeclaration of a member; noted VT:25/08/2011
2652  int n = 0;
2653  int ntr = 0;
2654  if (eWorking == 0)
2655  {
2656  ntr = eVertex->N();
2657  if (ntr < 3)
2658  {
2659 
2660  printf("Working vertex has 2 prongs only!\n");
2661  fflush(stdout);
2662  return 0;
2663  }
2664  eWorking = new EdbVertex();
2665  int i = 0;
2666  for(i=0; i<ntr; i++)
2667  {
2668  if (i == itr)
2669  {
2670  (eVertex->GetTrack(i))->ClearVTA(eVertex->GetVTa(i));
2671  continue;
2672  }
2673  if ((vta = AddTrack( *eWorking, eVertex->GetTrack(i), eVertex->Zpos(i))))
2674  {
2675  (eWorking->GetTrack(n))->AddVTA(vta);
2676  n++;
2677  }
2678  }
2679  }
2680  if ((n < 2)||(n == ntr))
2681  {
2682  printf("Can't create working copy of the vertex!\n");
2683  fflush(stdout);
2684  SafeDelete(eWorking);
2685  eVertex->ResetTracks();
2686  return 0;
2687  }
2688 
2689  if (MakeV(*eWorking))
2690  {
2691  EdbVertex *eW = eWorking;
2692  eW->ResetTracks();
2693  eW->SetID(eVertex->ID());
2694  }
2695  else
2696  {
2697  printf("Can't create working copy of the vertex!\n");
2698  fflush(stdout);
2699  SafeDelete(eWorking);
2700  eVertex->ResetTracks();
2701  return 0;
2702  }
2703  return eWorking;
2704 }

◆ RemoveVTAFromVertex()

EdbVertex * EdbVertexRec::RemoveVTAFromVertex ( EdbVertex vtx,
EdbVTA vta 
)
2625 {
2626  int ntr = v.N();
2627  TObjArray tracks;
2628  for(int i=0; i<ntr; i++) {
2629  if( v.GetVTa(i) != &vta ) tracks.Add( v.GetVTa(i)->GetTrack() );
2630  }
2631  EdbVertex *vnew = Make1Vertex( tracks, v.Z() );
2632 
2633  int nn = v.Nn();
2634  for(int i=0; i<nn; i++) {
2635  vnew->AddVTA( v.GetVTn(i) );
2636  }
2637  return vnew;
2638 }
EdbVertex * Make1Vertex(TObjArray &tracks, float zexpected)
Definition: EdbVertex.cxx:879

◆ Reset()

void EdbVertexRec::Reset ( )
745 {
746  SafeDelete(eVTX);
747  eVTA.Clear("nodelete");
748 }

◆ SegmentNeighbor()

int EdbVertexRec::SegmentNeighbor ( EdbSegP s,
float  RadMax = 1000.,
int  Dpat = 1,
float  ImpMax = 1000000.,
float  SegWmin = 9,
TObjArray *  aseg = 0,
TObjArray *  atr = 0,
TObjArray *  arv = 0 
)
3028 {
3029  //if(!ePVR) ePVR = ((EdbPVRec *)(gROOT->GetListOfSpecials()->FindObject("EdbPVRec")));
3030  if (ePVR) if (ePVR->IsA() != EdbPVRec::Class()) ePVR = 0;
3031  if(!ePVR) {printf("Warning: EdbVertexRec::SegmentNeighbor: EdbPVRec not defined, use SetPVRec(...)\n"); return 0;}
3032 
3033  EdbTrackP *tr = 0, *trown = 0;
3034  const EdbSegP *ss = 0;
3035  const EdbSegP *se = 0;
3036  int nn = 0;
3037  float distxs, distys, distzs1, distzs, dists;
3038  float distxe = 0., distye = 0., distze1= 0., distze = 0., diste = 0.;
3039  float xseg = 0, yseg = 0, zseg = 0;
3040  EdbTrackP *trv = 0;
3041  EdbVertex *ve = 0;
3042  float dx = 0., dy = 0.;
3043  float dz = 0;
3044  Float_t Zbin = TMath::Abs(ePVR->GetPattern(1)->Z() - ePVR->GetPattern(0)->Z());
3045  TObjArray an(200);
3046 
3047  xseg = s->X();
3048  yseg = s->Y();
3049  zseg = s->Z();
3050  an.Clear();
3051  if (s->Track() >= 0)
3052  {
3053  trown = (EdbTrackP *)ePVR->eTracks->At(s->Track());
3054  }
3055  // Select tracks neigborhood
3056  int nvn = SelSegNeighbor(s, 0, RadMax, Dpat, &an);
3057  if (trown) an.Add(trown);
3058  nvn = an.GetEntriesFast();
3059  for (int it=0; it<nvn; it++) {
3060  tr = (EdbTrackP*)(an.At(it));
3061  if (tr)
3062  {
3063  if (tr != trown)
3064  {
3065  ss = tr->TrackZmin();
3066  distxs = (xseg - ss->X());
3067  distxs *= distxs;
3068  distys = (yseg - ss->Y());
3069  distys *= distys;
3070  distzs1 = (zseg - ss->Z());
3071  distzs = distzs1*distzs1;
3072  dists = distxs + distys + distzs;
3073  dists = TMath::Sqrt(dists);
3074  se = tr->TrackZmax();
3075  distxe = (xseg - se->X());
3076  distxe *= distxe;
3077  distye = (yseg - se->Y());
3078  distye *= distye;
3079  distze1 = (zseg - se->Z());
3080  distze = distze1*distze1;
3081  diste = distxe + distye + distze;
3082  diste = TMath::Sqrt(diste);
3083  if (diste < dists)
3084  {
3085  if (TMath::Sqrt(distxe+distye) > RadMax) continue;
3086  if (TMath::Abs(distze1) > Dpat*Zbin) continue;
3087  if (Tdistance(*(const EdbSegP *)s, *se) > ImpMax) continue;
3088  }
3089  else
3090  {
3091  if (TMath::Sqrt(distxs+distys) > RadMax) continue;
3092  if (TMath::Abs(distzs1) > Dpat*Zbin) continue;
3093  if (Tdistance(*(const EdbSegP *)s, *ss) > ImpMax) continue;
3094  }
3095  }
3096  if (arrt) arrt->Add(tr);
3097  nn++;
3098 //--------------------------Add vertex neighborhood
3099  tr->SetMC(-tr->MCEvt()-2000, tr->MCTrack());
3100  ve = tr->VertexS();
3101  if (ve && ve->Flag() >= -99 && ve->Flag() != -10)
3102  {
3103  dx = ve->VX() - xseg;
3104  dy = ve->VY() - yseg;
3105  if (TMath::Sqrt(dx*dx + dy*dy) <= RadMax)
3106  {
3107  dz = ve->VZ() - zseg;
3108  if (TMath::Abs(dz) <= Dpat*Zbin)
3109  {
3110  ve->SetFlag(-ve->Flag()-200);
3111  if (arrv) arrv->Add(ve);
3112  for(int j=0; j<ve->N(); j++)
3113  {
3114  trv = ve->GetTrack(j);
3115  if (trv->MCEvt() < -999) continue;
3116  if (ve->Zpos(j) == 0)
3117  ss = trv->TrackZmax();
3118  else
3119  ss = trv->TrackZmin();
3120  dx = ss->X() - xseg;
3121  dy = ss->Y() - yseg;
3122  dz = ss->Z() - zseg;
3123  if (TMath::Sqrt(dx*dx+dy*dy) > RadMax) continue;
3124  if (TMath::Abs(dz) > Dpat*Zbin) continue;
3125  //if (TDistance(*(const EdbSegP *)s, *ss) > ImpMax) continue;
3126  if (arrt) arrt->Add(trv);
3127  trv->SetMC(-trv->MCEvt()-2000, trv->MCTrack());
3128  }
3129  }
3130  }
3131  }
3132  ve = tr->VertexE();
3133  if (ve && ve->Flag() >= -99 && ve->Flag() != -10)
3134  {
3135  dx = ve->VX() - xseg;
3136  dy = ve->VY() - yseg;
3137  if (TMath::Sqrt(dx*dx + dy*dy) <= RadMax)
3138  {
3139  dy = ve->VZ() - zseg;
3140  if (TMath::Abs(dz) <= Dpat*Zbin)
3141  {
3142  ve->SetFlag(-ve->Flag()-200);
3143  if (arrv) arrv->Add(ve);
3144  for(int j=0; j<ve->N(); j++)
3145  {
3146  trv = ve->GetTrack(j);
3147  if (trv->MCEvt() < -999) continue;
3148  if (ve->Zpos(j) == 0)
3149  ss = trv->TrackZmax();
3150  else
3151  ss = trv->TrackZmin();
3152  dx = ss->X() - xseg;
3153  dy = ss->Y() - yseg;
3154  dz = ss->Z() - zseg;
3155  if (TMath::Sqrt(dx*dx+dy*dy) > RadMax) continue;
3156  if (TMath::Abs(dz) > Dpat*Zbin) continue;
3157  //if (TDistance(*(const EdbSegP *)s, *ss) > ImpMax) continue;
3158  if (arrt) arrt->Add(trv);
3159  trv->SetMC(-trv->MCEvt()-2000, trv->MCTrack());
3160  }
3161  }
3162  }
3163  }
3164  }
3165  }
3166 //----------Restore MCEvt
3167  int nv = arrv->GetEntriesFast();
3168  for (int i=0; i<nv; i++)
3169  {
3170  ve = (EdbVertex *)arrv->At(i);
3171  if (ve->Flag() < -99 ) ve->SetFlag(-ve->Flag()-200);
3172  }
3173  int ntr = arrt->GetEntriesFast();
3174  for (int i=0; i<ntr; i++)
3175  {
3176  tr = (EdbTrackP *)arrt->At(i);
3177  if (tr->MCEvt() < -999 ) tr->SetMC(-tr->MCEvt()-2000, tr->MCTrack());
3178  }
3179  // Select segments neigborhood
3180  //nvn = SelSegNeighbor(s, 1, RadMax, Dpat, arrs);
3181  an.Clear();
3182  nvn = SelSegNeighbor(s, 1, RadMax, Dpat, &an);
3183  nvn = an.GetEntriesFast();
3184  for (int is=0; is<nvn; is++) {
3185  ss = (EdbSegP*)(an.At(is));
3186  if (ss)
3187  {
3188  if (ss != s)
3189  {
3190  if ( ss->W() < SegWmin) continue;
3191  if (Tdistance(*(const EdbSegP *)s, *ss) > ImpMax) continue;
3192  arrs->Add((TObject *)ss);
3193  nn++;
3194  }
3195  }
3196  }
3197 // printf("Selected %d segments\n", nvn);
3198 // nn += nvn;
3199  return nn;
3200 }
TObjArray * arrs
Definition: RecDispMC.C:128
TObjArray * arrv
Definition: RecDispMC.C:130
TObjArray * eTracks
Definition: EdbPVRec.h:161
EdbPattern * GetPattern(int id) const
Definition: EdbPattern.cxx:1887
Int_t Track() const
Definition: EdbSegP.h:147
void SetMC(int mEvt, int mTrack)
Definition: EdbSegP.h:138
Int_t MCTrack() const
Definition: EdbSegP.h:143
Int_t MCEvt() const
Definition: EdbSegP.h:142
Float_t Z() const
Definition: EdbPattern.h:87
Double_t Tdistance(const VERTEX::Track &t1, const VERTEX::Track &t2)
Definition: EdbVertex.cxx:3203
Int_t SelSegNeighbor(EdbSegP *s, int seltype, float RadMax, int Dpat, TObjArray *ao)
Definition: EdbVertex.cxx:1927
ss
Definition: energy.C:62

◆ SelSegNeighbor()

int EdbVertexRec::SelSegNeighbor ( EdbSegP s,
int  seltype,
float  RadMax,
int  Dpat,
TObjArray *  ao 
)
1928 {
1929  EdbSegP ss; // the virtual "vertex" segment
1930 
1931  if (!sin) return 0;
1932 
1933  ss.SetX(sin->X());
1934  ss.SetY(sin->Y());
1935  ss.SetZ(sin->Z());
1936  ss.SetTX(sin->TX());
1937  ss.SetTY(sin->TY());
1938  ss.SetErrors(RadMax*RadMax, RadMax*RadMax, 0., 0., 0., 0.);
1939 
1940  TObjArray arr(1000);
1941 
1942  ePVR->FindComplimentsVol(ss,arr,1,1,Dpat);
1943 
1944  int nseg = arr.GetEntriesFast();
1945  EdbTrackP *tr = 0;
1946  EdbSegP *s = 0;
1947  int trflg = 0;
1948  int trind = 0;
1949  int ntr = 0;
1950  if (eEdbTracks) ntr = eEdbTracks->GetEntriesFast();
1951 
1952  int nadd = 0;
1953  for (int i=0; i<nseg; i++)
1954  {
1955  s = (EdbSegP *)(arr.At(i));
1956  if (!s) continue;
1957  tr = 0;
1958  trind = s->Track();
1959  trflg = 0;
1960  if ( trind >= 0 && trind < ntr)
1961  {
1962  if ((tr = (EdbTrackP *)eEdbTracks->At(trind)))
1963  {
1964  trflg = tr->Flag();
1965  if (trflg != -10 && seltype == 0 && tr->MCEvt() >= -999)
1966  {
1967 // if (!(ao->FindObject(tr)))
1968 // {
1969  if (ao)
1970  {
1971  tr->SetMC(-tr->MCEvt()-2000, tr->MCTrack());
1972  ao->Add(tr);
1973  }
1974  nadd++;
1975 // }
1976  continue;
1977  }
1978  }
1979  }
1980  if((trind < 0 || trflg == -10)&&(seltype == 1))
1981  {
1982  if (ao) ao->Add(s);
1983  nadd++;
1984  }
1985  }
1986 
1987  if (seltype == 0)
1988  {
1989  nseg = ao->GetEntriesFast();
1990  for (int i=0; i<nseg; i++)
1991  {
1992  tr = (EdbTrackP *)(ao->At(i));
1993  if (tr && (tr->MCEvt() < -999)) tr->SetMC( -tr->MCEvt()-2000, tr->MCTrack());
1994  }
1995  }
1996 
1997  return nadd;
1998 }
int FindComplimentsVol(EdbSegP &s, TObjArray &arr, float nsig, float nsigt, int dpat)
Definition: EdbPattern.cxx:2104

◆ SelVertNeighbor()

int EdbVertexRec::SelVertNeighbor ( EdbVertex v,
int  seltype,
float  RadMax,
int  Dpat,
TObjArray *  ao 
)
1852 {
1853  EdbSegP ss; // the virtual "vertex" segment
1854 
1855  if (!v) return 0;
1856 
1857  float x = v->VX();
1858  float y = v->VY();
1859  float z = v->VZ();
1860 
1861  ss.SetX(x);
1862  ss.SetY(y);
1863  ss.SetZ(z);
1864  ss.SetTX(0.);
1865  ss.SetTY(0.);
1866  ss.SetErrors(RadMax*RadMax, RadMax*RadMax, 0., 0., 0., 0.);
1867 
1868  TObjArray arr(20);
1869  ePVR->FindComplimentsVol(ss,arr,1,1,Dpat);
1870 
1871  int nseg = arr.GetEntriesFast();
1872  EdbTrackP *tr = 0;
1873  EdbSegP *s = 0;
1874  int trflg = 0;
1875  int trind = 0;
1876  int ntr = eEdbTracks->GetEntriesFast();
1877 
1878  int nadd = 0;
1879  for (int i=0; i<nseg; i++)
1880  {
1881  s = (EdbSegP *)(arr.At(i));
1882  if (!s) continue;
1883  tr = 0;
1884  trind = s->Track();
1885  trflg = 0;
1886  if ( trind >= 0 && trind < ntr)
1887  {
1888  if ((tr = (EdbTrackP *)eEdbTracks->At(trind)))
1889  {
1890  trflg = tr->Flag();
1891  if (trflg != -10 && seltype == 0 && tr->MCEvt() >= -999)
1892  {
1893 // if (!(ao->FindObject(tr)))
1894 // {
1895  if (ao)
1896  {
1897  tr->SetMC(-tr->MCEvt()-2000, tr->MCTrack());
1898  ao->Add(tr);
1899  }
1900  nadd++;
1901 // }
1902  continue;
1903  }
1904  }
1905  }
1906  if((trind < 0 || trflg == -10)&&(seltype == 1))
1907  {
1908  if (ao) ao->Add(s);
1909  nadd++;
1910  }
1911  }
1912 
1913  if (seltype == 0)
1914  {
1915  nseg = ao->GetEntriesFast();
1916  for (int i=0; i<nseg; i++)
1917  {
1918  tr = (EdbTrackP *)(ao->At(i));
1919  if (tr && (tr->MCEvt() < -999)) tr->SetMC( -tr->MCEvt()-2000, tr->MCTrack());
1920  }
1921  }
1922 
1923  return nadd;
1924 }

◆ Set0()

void EdbVertexRec::Set0 ( )
724 {
725  eEdbTracks = 0;
726  eVTX = 0;
727  ePVR = 0;
728  eVertex = 0;
729  eWorking = 0;
730  (gROOT->GetListOfSpecials())->Add(this); // To check if this can cause memory leak!
731 }

◆ SetPVRec()

void EdbVertexRec::SetPVRec ( EdbPVRec pvr)
inline
285 {ePVR = pvr;}

◆ StatVertexN()

void EdbVertexRec::StatVertexN ( )
1807 {
1808  Int_t nvt = Nvtx();
1809  if (!nvt) return;
1810  TArrayI navtx(10);
1811  EdbVertex *v=0;
1812  Int_t ntv = 0;
1813  for (Int_t i = 0; i < nvt; i++) {
1814  v = GetVertex(i);
1815  if (!v || v->Flag() < 0) continue;
1816  ntv = v->N();
1817  if (ntv > 11) ntv = 11;
1818  navtx[ntv-2]++;
1819  }
1820  for (ntv = 0; ntv < 10; ntv++) {
1821  if (ntv < 9)
1822  printf("%5d vertices with number of tracks = %2d was found\n",
1823  navtx[ntv], ntv+2);
1824  else
1825  printf("%5d vertices with number of tracks >= %2d was found\n",
1826  navtx[ntv], ntv+2);
1827  }
1828 }

◆ StripBadTracks()

EdbVertex * EdbVertexRec::StripBadTracks ( EdbVertex v,
float  impMax,
int  ntrMin 
)
861 {
862  EdbVertex *v = &vtx;
863  int ntr0 = v->N();
864  int ntr = v->N();
865  while( v && ntr>ntrMin && v->MaxImpact()>impMax )
866  {
867  Log(2,"EdbVertexRec::StripBadTracks"," ntr = %d maximp = %f", ntr,v->MaxImpact() );
868  EdbVTA *vta = v->GetMaxImpVTA();
869  v = RemoveVTAFromVertex( *v, *vta );
870  vta->SetFlag(0); v->AddVTA(vta); // add it as VTn
871  ntr = v->N();
872  }
873 
874  Log(2,"EdbVertexRec::StripBadTracks"," %d -> %d + %d maximp = %f", ntr0, v->N(), v->Nn() ,v->MaxImpact() );
875  return v;
876 }
EdbVertex * RemoveVTAFromVertex(EdbVertex &vtx, EdbVTA &vta)
Definition: EdbVertex.cxx:2624
EdbVTA * GetMaxImpVTA()
Definition: EdbVertex.cxx:140

◆ Tdistance() [1/2]

double EdbVertexRec::Tdistance ( const EdbSegP s1,
const EdbSegP s2 
)
3226 {
3227  EdbVertex edbv;
3228  Track t1,t2;
3229  edbv.Edb2Vt(s1,t1);
3230  edbv.Edb2Vt(s2,t2);
3231  return Tdistance(t1,t2);
3232 }

◆ Tdistance() [2/2]

double EdbVertexRec::Tdistance ( const VERTEX::Track t1,
const VERTEX::Track t2 
)
3203  {
3204  //
3205  // geometrical distance between 2 track lines in the space XYZ
3206  //
3207  const double a = t1.tx();
3208  const double b = t1.ty();
3209  const double c = 1.;
3210  const double a1 = t2.tx();
3211  const double b1 = t2.ty();
3212  const double c1 = 1.;
3213 
3214  const double det = square(a*b1 - b*a1) + square(b*c1 - c*b1) + square(c*a1 - a*c1);
3215  const SVector<double,3> dx = t2.xvec() - t1.xvec();
3216  // are tracks parallel?
3217  if(det==0) return mag(cross(dx,t1.evec()));
3218 
3219  const double det2 = dx[0]*(b*c1 - c*b1) + dx[1]*(c*a1 - a*c1) + dx[2]*(a*b1 - b*a1);
3220 
3221  return fabs(det2/sqrt(det));
3222 }
T mag(const SVector< T, D > &rhs)
Definition: Functions.hh:216
SVector< T, 3 > cross(const SVector< T, 3 > &lhs, const SVector< T, 3 > &rhs)
Definition: Functions.hh:283
const T square(const T &x)
Definition: Functions.hh:46
Expr< UnaryOp< Fabs< T >, Expr< A, T, D >, T >, T, D > fabs(const Expr< A, T, D > &rhs)
Definition: UnaryOperators.hh:96
MATRIX::VtVector evec() const
$\vec{v} = (e_x,e_y,e_z)$ unit vector along refitted track
Definition: VtTrack.hh:137
float ty() const
slope (in Vt: p(2,..))
Definition: VtTrack.C:154
float tx() const
slope (in Vt: p(1,..))
Definition: VtTrack.C:153

◆ TdistanceChi2() [1/2]

double EdbVertexRec::TdistanceChi2 ( const EdbSegP s1,
const EdbSegP s2,
float  m 
)
3247 {
3248  EdbVertex edbv;
3249  Track t1,t2;
3250  float X0 = ePVR->GetScanCond()->RadX0();
3251  edbv.Edb2Vt(s1,t1,X0,m);
3252  edbv.Edb2Vt(s2,t2,X0,m);
3253  return distanceChi2(t1,t2);
3254 }
double distanceChi2(Track &t1, Track &t2)
$\chi^2$ distance track - track, $ndf = 1$
Definition: VtDistance.C:40

◆ TdistanceChi2() [2/2]

double EdbVertexRec::TdistanceChi2 ( const EdbTrackP tr1,
const EdbTrackP tr2 
)
3236 {
3237  EdbVertex edbv;
3238  Track t1,t2;
3239  float X0 = ePVR->GetScanCond()->RadX0();
3240  edbv.Edb2Vt(tr1,t1,X0,tr1.M());
3241  edbv.Edb2Vt(tr2,t2,X0,tr2.M());
3242  return distanceChi2(t1,t2);
3243 }

◆ TestVTAGroup()

EdbVertex * EdbVertexRec::TestVTAGroup ( TObjArray &  arrvta)
1563 {
1564  // Try to create N-prong vertex from vta's group
1565  // Input: array of preselected vta's
1566  // return the new vertex if successful
1567 
1568  int nvta=arrvta.GetEntriesFast();
1569  Log(3,"EdbVertexRec::TestVTAGroup","nvta = %d\n",nvta);
1570 
1571  EdbVTA *vta=0, *newvta=0;
1572  EdbVertex *newvtx = new EdbVertex();
1573  for(int i=0; i<nvta; i++) {
1574  vta = (EdbVTA*)arrvta.At(i);
1575  if( newvtx->TrackInVertex(vta->GetTrack()) ) continue;
1576  newvta = new EdbVTA(vta->GetTrack(),newvtx);
1577  newvta->SetZpos(vta->Zpos());
1578  newvta->SetFlag(2);
1579  newvtx->AddVTA(newvta);
1580  }
1581 
1582  if(MakeV(*newvtx))
1583  if( newvtx->V() )
1584  if( newvtx->V()->valid() ) {
1585  //printf("prob = %f\n", newvtx->V()->prob() );
1586  if( newvtx->V()->prob() >= eProbMin ) // accept new N-tracks vertex
1587  {
1588  for(int i=0; i<nvta; i++) {
1589  if( ((EdbVTA*)arrvta.At(i))->GetVertex() != newvtx )
1590  ((EdbVTA*)arrvta.At(i))->GetVertex()->SetFlag(-10);
1591  }
1592  //printf("accepted!\n");
1593  return newvtx;
1594  }
1595  }
1596  SafeDelete(newvtx); // discard new vertex
1597  return 0;
1598 }
Int_t Zpos() const
Definition: EdbVertex.h:46
EdbTrackP * GetTrack() const
Definition: EdbVertex.h:50

◆ VertexNeighbor() [1/2]

int EdbVertexRec::VertexNeighbor ( EdbVertex v,
float  RadMax = 1000.,
int  Dpat = 1,
float  ImpMax = 1000000. 
)
2786 {
2787  //if(!ePVR) ePVR = ((EdbPVRec *)(gROOT->GetListOfSpecials()->FindObject("EdbPVRec")));
2788  if (ePVR) if (ePVR->IsA() != EdbPVRec::Class()) ePVR = 0;
2789  if(!ePVR) {printf("Warning: EdbVertexRec::VertexNeighbor: EdbPVRec not defined, use SetPVRec(...)\n"); return 0;}
2790 
2791  EdbVTA *vta = 0;
2792  EdbTrackP *tr = 0;
2793  const EdbSegP *ss = 0;
2794  const EdbSegP *se = 0;
2795  EdbTrackP *trv = 0;
2796  EdbVertex *ve = 0;
2797  float dx = 0., dy = 0.;
2798  float dz = 0;
2799  int zpos = 0;
2800  int nn = 0, nntr = 0;
2801  float distxs, distys, distzs1, distzs, dists, dist = 0.;
2802  float distxe = 0., distye = 0., distze1= 0., distze = 0., diste = 0.;
2803  float xvert = 0, yvert = 0, zvert = 0;
2804  Float_t Zbin = TMath::Abs((ePVR->GetPattern(1))->Z() - (ePVR->GetPattern(0))->Z());
2805  TObjArray an(20);
2806 
2807  if (v->Flag() != -10)
2808  {
2809  v->ClearNeighborhood();
2810  xvert = v->VX();
2811  yvert = v->VY();
2812  zvert = v->VZ();
2813  // Select tracks neigborhood
2814  an.Clear();
2815  int ntr = v->N();
2816  for(int i=0; i<ntr; i++)
2817  {
2818  tr = v->GetTrack(i);
2819  tr->SetMC(-tr->MCEvt()-2000, tr->MCTrack());
2820  if (v->Zpos(i) == 1)
2821  ve = tr->VertexE();
2822  else
2823  ve = tr->VertexS();
2824  if (ve && ve->Flag() >= -99 && ve->Flag() != -10)
2825  {
2826  dx = ve->VX() - xvert;
2827  dy = ve->VY() - yvert;
2828  if (TMath::Sqrt(dx*dx + dy*dy) > RadMax) continue;
2829  dz = ve->VZ() - zvert;
2830  if (TMath::Abs(dz) > Dpat*Zbin) continue;
2831  vta = new EdbVTA((EdbTrackP *)ve, v);
2832  vta->SetFlag(3);
2833  vta->SetDist(TMath::Sqrt(dx*dx+dy*dy+dz*dz));
2834  v->AddVTA(vta);
2835  ve->SetFlag(-ve->Flag()-200);
2836  for(int j=0; j<ve->N(); j++)
2837  {
2838  trv = ve->GetTrack(j);
2839  if (trv->MCEvt() < -999) continue;
2840  if (ve->Zpos(j) == 0)
2841  ss = trv->TrackZmax();
2842  else
2843  ss = trv->TrackZmin();
2844  dx = ss->X() - xvert;
2845  dy = ss->Y() - yvert;
2846  dz = ss->Z() - zvert;
2847  if (TMath::Sqrt(dx*dx+dy*dy) > RadMax) continue;
2848  if (TMath::Abs(dz) > Dpat*Zbin) continue;
2849  dist = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
2850  vta = v->CheckImp(trv, 10.e+10, ve->Zpos(j), dist);
2851  if (vta) trv->SetMC(-trv->MCEvt()-2000, trv->MCTrack());
2852  }
2853  }
2854  }
2855  int nvn = SelVertNeighbor(v, 0, RadMax, Dpat, &an);
2856  for (int it=0; it<nvn; it++) {
2857  tr = (EdbTrackP*)(an.At(it));
2858  if (tr)
2859  {
2860  if (tr->MCEvt() < -999) continue;
2861  ss = tr->TrackZmin();
2862  distxs = (xvert - ss->X());
2863  distxs *= distxs;
2864  distys = (yvert - ss->Y());
2865  distys *= distys;
2866  distzs1 = (zvert - ss->Z());
2867  distzs = distzs1*distzs1;
2868  dists = distxs + distys + distzs;
2869  dists = TMath::Sqrt(dists);
2870  se = tr->TrackZmax();
2871  distxe = (xvert - se->X());
2872  distxe *= distxe;
2873  distye = (yvert - se->Y());
2874  distye *= distye;
2875  distze1 = (zvert - se->Z());
2876  distze = distze1*distze1;
2877  diste = distxe + distye + distze;
2878  diste = TMath::Sqrt(diste);
2879  if (diste < dists)
2880  {
2881  if (TMath::Sqrt(distxe+distye) > RadMax) continue;
2882  if (TMath::Abs(distze1) > Dpat*Zbin) continue;
2883  dist = diste;
2884  zpos = 0;
2885  }
2886  else
2887  {
2888  if (TMath::Sqrt(distxs+distys) > RadMax) continue;
2889  if (TMath::Abs(distzs1) > Dpat*Zbin) continue;
2890  dist = dists;
2891  zpos = 1;
2892  }
2893  vta = v->CheckImp(tr, ImpMax, zpos, dist);
2894  if (vta)
2895  {
2896  nn++;
2897  tr->SetMC(-tr->MCEvt()-2000, tr->MCTrack());
2898  ve = tr->VertexS();
2899  if (ve && ve->Flag() >= -99 && ve->Flag() != -10 && ve != v)
2900  {
2901  dx = ve->VX() - xvert;
2902  dy = ve->VY() - yvert;
2903  if (TMath::Sqrt(dx*dx + dy*dy) <= RadMax)
2904  {
2905  dz = TMath::Abs(ve->VZ() - zvert);
2906  if (dz <= Dpat*Zbin)
2907  {
2908  ve->SetFlag(-ve->Flag()-200);
2909  vta = new EdbVTA((EdbTrackP *)ve, v);
2910  vta->SetFlag(3);
2911  vta->SetDist(TMath::Sqrt(dx*dx+dy*dy+dz*dz));
2912  v->AddVTA(vta);
2913  for(int j=0; j<ve->N(); j++)
2914  {
2915  trv = ve->GetTrack(j);
2916  if (trv->MCEvt() < -999) continue;
2917  if (ve->Zpos(j) == 0)
2918  ss = trv->TrackZmax();
2919  else
2920  ss = trv->TrackZmin();
2921  dx = ss->X() - xvert;
2922  dy = ss->Y() - yvert;
2923  dz = ss->Z() - zvert;
2924  if (TMath::Sqrt(dx*dx+dy*dy) > RadMax) continue;
2925  if (TMath::Abs(dz) > Dpat*Zbin) continue;
2926  dist = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
2927  vta = v->CheckImp(trv, 10.e+10, ve->Zpos(j), dist);
2928  if (vta) trv->SetMC(-trv->MCEvt()-2000, trv->MCTrack());
2929  }
2930  }
2931  }
2932  }
2933  ve = tr->VertexE();
2934  if (ve && ve->Flag() >= -99 && ve->Flag() != -10 && ve != v)
2935  {
2936  dx = ve->VX() - xvert;
2937  dy = ve->VY() - yvert;
2938  if (TMath::Sqrt(dx*dx + dy*dy) <= RadMax)
2939  {
2940  dz = TMath::Abs(ve->VZ() - zvert);
2941  if (dz <= Dpat*Zbin)
2942  {
2943  ve->SetFlag(-ve->Flag()-200);
2944  vta = new EdbVTA((EdbTrackP *)ve, v);
2945  vta->SetFlag(3);
2946  vta->SetDist(TMath::Sqrt(dx*dx+dy*dy+dz*dz));
2947  v->AddVTA(vta);
2948  for(int j=0; j<ve->N(); j++)
2949  {
2950  trv = ve->GetTrack(j);
2951  if (trv->MCEvt() < -999) continue;
2952  if (ve->Zpos(j) == 0)
2953  ss = trv->TrackZmax();
2954  else
2955  ss = trv->TrackZmin();
2956  dx = ss->X() - xvert;
2957  dy = ss->Y() - yvert;
2958  dz = ss->Z() - zvert;
2959  if (TMath::Sqrt(dx*dx+dy*dy) > RadMax) continue;
2960  if (TMath::Abs(dz) > Dpat*Zbin) continue;
2961  dist = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
2962  vta = v->CheckImp(trv, 10.e+10, ve->Zpos(j), dist);
2963  if (vta) trv->SetMC(-trv->MCEvt()-2000, trv->MCTrack());
2964  }
2965  }
2966  }
2967  }
2968  }
2969  }
2970  }
2971  ntr = v->N();
2972  for(int i=0; i<ntr; i++)
2973  {
2974  tr = v->GetTrack(i);
2975  tr->SetMC(-tr->MCEvt()-2000, tr->MCTrack());
2976  }
2977  nntr = v->Nn();
2978  for(int i=0; i<nntr; i++)
2979  {
2980  if ((vta = v->GetVTn(i)))
2981  {
2982  if (vta->Flag() == 0) //track
2983  {
2984  tr = vta->GetTrack();
2985  if (tr->MCEvt() < -999 ) tr->SetMC(-tr->MCEvt()-2000, tr->MCTrack());
2986  }
2987  else if (vta->Flag() == 3) //vertex
2988  {
2989  ve = (EdbVertex *)vta->GetTrack();
2990  if (ve->Flag() < -99 ) ve->SetFlag(-ve->Flag()-200);
2991  }
2992  }
2993  }
2994  // Select segments neigborhood
2995  an.Clear();
2996  nvn = SelVertNeighbor(v, 1, RadMax, Dpat, &an);
2997  for (int it=0; it<nvn; it++) {
2998  ss = (EdbSegP*)(an.At(it));
2999  if (ss)
3000  {
3001  distxs = (xvert - ss->X());
3002  distxs *= distxs;
3003  distys = (yvert - ss->Y());
3004  distys *= distys;
3005  distzs1 = (zvert - ss->Z());
3006  distzs = distzs1*distzs1;
3007  dists = distxs + distys + distzs;
3008  dists = TMath::Sqrt(dists);
3009 // if (TMath::Sqrt(distxs+distys) > RadMax) continue;
3010 // if (TMath::Abs(distzs1) > Dpat*Zbin) continue;
3011 // vta = v->CheckImp((EdbTrackP *)ss, ImpMax, zpos, dists);
3012  if (v->DistSeg((EdbSegP *)ss) > ImpMax) continue;
3013  vta = new EdbVTA((EdbTrackP *)ss, v);
3014  vta->SetZpos(1);
3015  vta->SetFlag(1);
3016  vta->SetImp(0.);
3017  vta->SetDist(dists);
3018  v->AddVTA(vta);
3019  nn++;
3020  }
3021  }
3022  }
3023  return nn;
3024 }
Int_t Flag() const
Definition: EdbVertex.h:47
Int_t SelVertNeighbor(EdbVertex *v, int seltype, float RadMax, int Dpat, TObjArray *ao)
Definition: EdbVertex.cxx:1851
Float_t DistSeg(EdbSegP *seg, float X0=0.)
Definition: EdbVertex.cxx:694
float CheckImp(const EdbTrackP *tr)
Definition: EdbVertex.cxx:463
void ClearNeighborhood()
Definition: EdbVertex.cxx:275

◆ VertexNeighbor() [2/2]

int EdbVertexRec::VertexNeighbor ( float  RadMax = 1000.,
int  Dpat = 1,
float  ImpMax = 1000000. 
)
2755 {
2756  //if(!ePVR) ePVR = ((EdbPVRec *)(gROOT->GetListOfSpecials()->FindObject("EdbPVRec")));
2757  if (ePVR) if (ePVR->IsA() != EdbPVRec::Class()) ePVR = 0;
2758  if(!ePVR) {printf("Warning: EdbVertexRec::VertexNeighbor: EdbPVRec not defined, use SetPVRec(...)\n"); return 0;}
2759 
2760  int nn = 0, iv = 0;
2761 // int i = 0, nntr = 0;
2762  int nvt = 0;
2763  int ntr = 0;
2764  if (eVTX) nvt = eVTX->GetEntriesFast();
2765  if (eEdbTracks) ntr = eEdbTracks->GetEntriesFast();
2766  if (!nvt) return 0;
2767  if (!ntr) return 0;
2768 
2769  EdbVertex *v = 0;
2770 
2771  for (iv=0; iv<nvt; iv++) {
2772  v = GetVertex(iv);
2773  if (v)
2774  {
2775  nn += VertexNeighbor(v, RadMax, Dpat, ImpMax);
2776 // nntr = v->Nn();
2777 // for(i=0; i<nntr; i++) AddVTA(v->GetVTn(i));
2778  }
2779  }
2780 
2781  return nn;
2782 }
Int_t VertexNeighbor(float RadMax=1000., int Dpat=1, float ImpMax=1000000.)
Definition: EdbVertex.cxx:2754

◆ VertexPolish()

int EdbVertexRec::VertexPolish ( EdbVertex v,
int  refill = 0,
float  RadMax = 1000.,
int  Dpat = 2,
float  ImpMax = 25.,
float  ProbMin = 0.01,
float  Mom = 0.3 
)
2132 {
2133  if (refill) if (!VertexNeighbor(v, RadMax, Dpat, ImpMax)) return 0;
2134 
2135  EdbVTA *vta = 0;
2136  EdbTrackP *tn = 0;
2137  EdbSegP *sn = 0;
2138  EdbVertex *w = 0;
2139 
2140  int nt = v->N();
2141  int nn = v->Nn();
2142  int naddtot = 0, nmod = 0;
2143  int news = 0;
2144  if (nn)
2145  {
2146  // first of all try to propagate existing tracks with new momentum
2147  double p = Mom;
2148  int nadd = 0;
2149  for(int i=0; i<nt; i++)
2150  {
2151  nadd = 0;
2152  tn = v->GetTrack(i);
2153  for (int ip=0; ip<2; ip++)
2154  {
2155  p = Mom/(ip+1);
2156  tn->SetErrorP(0.2*0.2*p*p);
2157  tn->SetP(p);
2158  if (v->Zpos(i)) nadd += ePVR->PropagateTrack( *tn, true, 0.01, 3, 0 );
2159  else nadd += ePVR->PropagateTrack( *tn, false, 0.01, 3, 0 );
2160  }
2161  if (nadd) nmod++;
2162  naddtot += nadd;
2163  }
2164 
2165  // then attach single segments with small impact to the vertex
2166  eVertex = v;
2167  for(int i=0; i<nn; i++)
2168  {
2169  vta = eVertex->GetVTn(i);
2170  if (vta->Flag() == 1) // neighbour segment
2171  {
2172  sn = (EdbSegP *)vta->GetTrack();
2173  news += AddSegmentToVertex(sn, ImpMax, ProbMin, Mom);
2174  }
2175  }
2176  w = eVertex;
2177  if (eWorking != 0) w = eWorking;
2178  nt = w->N();
2179  p = Mom;
2180  nadd = 0;
2181  // then try to propagate one-segment tracks with new momentum
2182  for(int i=0; i<nt; i++)
2183  {
2184  nadd = 0;
2185  tn = w->GetTrack(i);
2186  if (tn->N() > 1) continue;
2187  for (int ip=0; ip<2; ip++)
2188  {
2189  p = Mom/(ip+1);
2190  tn->SetErrorP(0.2*0.2*p*p);
2191  tn->SetP(p);
2192  if (w->Zpos(i)) nadd += ePVR->PropagateTrack( *tn, true, 0.01, 3, 0 );
2193  else nadd += ePVR->PropagateTrack( *tn, false, 0.01, 3, 0 );
2194  }
2195  if (nadd) nmod++;
2196  naddtot += nadd;
2197  }
2198  }
2199  printf("%d single segments are attached, %d tracks are propagated (total %d segments are added).\n",
2200  news, nmod, naddtot);
2201  fflush(stdout);
2202  return (news+nmod);
2203 }
int PropagateTrack(EdbTrackP &tr, bool followZ, float probMin=0.05, int ngapMax=3, int design=0)
Definition: EdbPVRec.cxx:2565
void SetErrorP(float sp2)
Definition: EdbSegP.h:93
Int_t N() const
Definition: EdbPattern.h:182
Int_t AddSegmentToVertex(EdbSegP *s, float ImpMax=25., float ProbMin=0.01, float Mom=0.3)
Definition: EdbVertex.cxx:2000
p
Definition: testBGReduction_AllMethods.C:8
void w(int rid=2, int nviews=2)
Definition: test.C:27

◆ VertexTuning()

int EdbVertexRec::VertexTuning ( int  seltype = 0)
2216 {
2217  //if(!ePVR) ePVR = ((EdbPVRec *)(gROOT->GetListOfSpecials()->FindObject("EdbPVRec")));
2218  if (ePVR) if (ePVR->IsA() != EdbPVRec::Class()) ePVR = 0;
2219  if(!ePVR) {printf("Warning: EdbVertexRec::VertexNeighbor: EdbPVRec not defined, use SetPVRec(...)\n"); return 0;}
2220 
2221  int iv = 0, nntr = 0, nn = 0;
2222  int nvt = 0;
2223  int ntr = 0;
2224  if (eEdbTracks) ntr = eEdbTracks->GetEntriesFast();
2225  if (!ntr) return 0;
2226  if (eVTX) nvt = eVTX->GetEntriesFast();
2227  if (!nvt) return 0;
2228 
2229  EdbVertex *v1 = 0, *v2 = 0;
2230  EdbVertex *v1n = 0, *v2n = 0;
2231  EdbVTA *vta = 0;
2232  EdbTrackP *tr1 = 0, *tr2 = 0;
2233  int ntr1 = 0, ntr2 = 0, was = 0;
2234  double impa1[50] = {0.}, chia1[50] = {0.}, imp1max = 0., chi1max = 0.;
2235  double impa2[50] = {0.}, chia2[50] = {0.}, imp2max = 0., chi2max = 0.;
2236  double cri1max = 0., cri2max = 0.;
2237  int it1impmax = -1, it1chimax = -1, it1max = -1;
2238  int it2impmax = -1, it2chimax = -1, it2max = -1;
2239  double vchisumorig = 0., vdistsumorig = 0.;
2240  double v1chiorig = 0., v1distorig = 0.;
2241  double v2chiorig = 0., v2distorig = 0., crit = 0., critorig = 0.;
2242 
2243  for (iv=0; iv<nvt; iv++) { // loop on all vertices
2244  v1 = GetVertex(iv);
2245  if (v1)
2246  {
2247  if (v1->Flag() < 0) continue;
2248  if ((!(v1->V()))) continue;
2249  ntr1 = v1->N();
2250  imp1max = -1.;
2251  chi1max = -1.;
2252  it1max = -1;
2253  for(int it1=0; it1<v1->N() && it1<50; it1++)
2254  {
2255  tr1 = v1->GetTrack(it1);
2256  impa1[it1] = v1->ImpTrack(it1);
2257  if (impa1[it1] > imp1max)
2258  {
2259  imp1max = impa1[it1];
2260  it1impmax = it1;
2261  }
2262  chia1[it1] = v1->Chi2Track(tr1, v1->Zpos(it1), 0.);
2263  if (chia1[it1] > chi1max)
2264  {
2265  chi1max = chia1[it1];
2266  it1chimax = it1;
2267  }
2268  }
2269  if (seltype == 0)
2270  {
2271  it1max = it1impmax;
2272  }
2273  else
2274  {
2275  it1max = it1chimax;
2276  }
2277  nntr = v1->Nn();
2278  v1chiorig = v1->V()->chi2();
2279  v1distorig = v1->V()->rmsDistAngle();
2280  if (nntr)
2281  {
2282  for(int i=0; i<nntr; i++)
2283  {
2284  vta = v1->GetVTn(i);
2285  if (vta->Flag() == 0) // neighbour track
2286  {
2287 // EdbTrackP *tn = vta->GetTrack();
2288  }
2289  else if (vta->Flag() == 1) // neighbour segment
2290  {
2291 // EdbSegP *sn = (EdbSegP *)vta->GetTrack();
2292  }
2293  else if (vta->Flag() == 3) // neighbour vertex
2294  {
2295  v2 = (EdbVertex *)vta->GetTrack();
2296  if ((!v2) || v2->Flag() == -10) continue;
2297  if ((!(v2->V()))) continue;
2298  ntr2 = v2->N();
2299  v2chiorig = v2->V()->chi2();
2300  v2distorig = v2->V()->rmsDistAngle();
2301  vchisumorig = v1chiorig + v2chiorig;
2302  vdistsumorig = v1distorig + v2distorig;
2303  if (seltype == 0)
2304  {
2305  critorig = vdistsumorig;
2306  }
2307  else
2308  {
2309  critorig = vchisumorig;
2310  }
2311  was = 0;
2312  if (ntr1==2 && ntr2>2)
2313  {
2314  imp2max = 0.;
2315  chi2max = 0.;
2316  it2max = -1;
2317  for(int it2=0; it2<ntr2 && it2<50; it2++)
2318  {
2319  tr2 = v2->GetTrack(it2);
2320  impa2[it2] = v2->ImpTrack(it2);
2321  if (impa2[it2] > imp2max)
2322  {
2323  imp2max = impa2[it2];
2324  it2impmax = it2;
2325  }
2326  chia2[it2] = v2->Chi2Track(tr2, v2->Zpos(it2), 0.);
2327  if (chia2[it2] > chi2max)
2328  {
2329  chi2max = chia2[it2];
2330  it2chimax = it2;
2331  }
2332  }
2333  if (seltype == 0)
2334  {
2335  it2max = it2impmax;
2336  }
2337  else
2338  {
2339  it2max = it2chimax;
2340  }
2341  if (it2max < 0) continue;
2342  if (v2->GetConnectedVertexForTrack(it2max)==v1) continue;
2343  crit = MoveTrackToOtherVertex(v2, it2max, v1, seltype, &v2n, &v1n);
2344  was = 1;
2345  }
2346  else if (ntr1>2 && ntr2==2)
2347  {
2348  imp1max = 0.;
2349  chi1max = 0.;
2350  it1max = -1;
2351  for(int it1=0; it1<ntr1 && it1<50; it1++)
2352  {
2353  tr1 = v1->GetTrack(it1);
2354  impa1[it1] = v1->ImpTrack(it1);
2355  if (impa1[it1] > imp1max)
2356  {
2357  imp1max = impa1[it1];
2358  it1impmax = it1;
2359  }
2360  chia1[it1] = v1->Chi2Track(tr1, v1->Zpos(it1), 0.);
2361  if (chia1[it1] > chi1max)
2362  {
2363  chi1max = chia1[it1];
2364  it1chimax = it1;
2365  }
2366  }
2367  if (seltype == 0)
2368  {
2369  it1max = it1impmax;
2370  }
2371  else
2372  {
2373  it1max = it1chimax;
2374  }
2375  if (it1max < 0) continue;
2376  if (v1->GetConnectedVertexForTrack(it1max)==v2) continue;
2377  crit = MoveTrackToOtherVertex(v1, it1max, v2, seltype, &v2n, &v1n);
2378  was = 1;
2379  }
2380  else if (ntr1>2 && ntr2>2)
2381  {
2382  imp2max = 0.;
2383  chi2max = 0.;
2384  it2max = -1;
2385  for(int it2=0; it2<ntr2 && it2<50; it2++)
2386  {
2387  tr2 = v2->GetTrack(it2);
2388  impa2[it2] = v2->ImpTrack(it2);
2389  if (impa2[it2] > imp2max)
2390  {
2391  imp2max = impa2[it2];
2392  it2impmax = it2;
2393  }
2394  chia2[it2] = v2->Chi2Track(tr2, v2->Zpos(it2), 0.);
2395  if (chia2[it2] > chi2max)
2396  {
2397  chi2max = chia2[it2];
2398  it2chimax = it2;
2399  }
2400  }
2401  if (seltype == 0)
2402  {
2403  it2max = it2impmax;
2404  cri1max = imp1max;
2405  cri2max = imp2max;
2406  }
2407  else
2408  {
2409  it2max = it2chimax;
2410  cri1max = chi1max;
2411  cri2max = chi2max;
2412  }
2413  if (it1max < 0) continue;
2414  if (it2max < 0) continue;
2415  if (cri2max > cri1max)
2416  {
2417  if (v2->GetConnectedVertexForTrack(it2max)==v1) continue;
2418  crit = MoveTrackToOtherVertex(v2, it2max, v1, seltype, &v2n, &v1n);
2419  was = 1;
2420  }
2421  else
2422  {
2423  if (v1->GetConnectedVertexForTrack(it1max)==v2) continue;
2424  crit = MoveTrackToOtherVertex(v1, it1max, v2, seltype, &v2n, &v1n);
2425  was = 1;
2426  } // variants of changing
2427  } // multiplicities
2428  if (was)
2429  {
2430  if ((crit < critorig) && v1n && v2n)
2431  {
2432  AcceptModifiedVTX(v1,v1n);
2433  AcceptModifiedVTX(v2,v2n);
2434  v1 = v1n;
2435  v2 = v2n;
2436  if (v2->Flag() > -11) v2->SetFlag(-v2->Flag()-11);
2437  nn++;
2438  //break;
2439  }
2440  else
2441  {
2442  CancelModifiedVTX(v1,v1n);
2443  CancelModifiedVTX(v2,v2n);
2444  }
2445  }
2446  } // neighbor vertex
2447  } // loop on neighbor
2448  } // neighbor exist
2449  } // good v1
2450  } // loop on vertices
2451 
2452  nvt = eVTX->GetEntriesFast();
2453 
2454  for (iv=0; iv<nvt; iv++) {
2455  v1 = GetVertex(iv);
2456  if (v1)
2457  {
2458  if (v1->Flag()<-10)
2459  {
2460  v1->SetFlag(-v1->Flag()-11);
2461  }
2462  }
2463  }
2464 
2465  return nn;
2466 }
Double_t MoveTrackToOtherVertex(EdbVertex *v2, int it2max, EdbVertex *v1, int seltype, EdbVertex **v2n, EdbVertex **v1n)
Definition: EdbVertex.cxx:2468
Float_t Chi2Track(EdbTrackP *tr, int zpos, float X0=0.)
Definition: EdbVertex.cxx:657
EdbVertex * GetConnectedVertexForTrack(int it)
Definition: EdbVertex.cxx:406
Float_t ImpTrack(int i)
Definition: EdbVertex.h:152

◆ Vmax()

const TVector3* EdbVertexRec::Vmax ( ) const
inline
216 {return &eVmax;}

◆ Vmin()

const TVector3* EdbVertexRec::Vmin ( ) const
inline
215 {return &eVmin;}

Member Data Documentation

◆ eEdbTracks

TObjArray* EdbVertexRec::eEdbTracks

◆ ePVR

EdbPVRec* EdbVertexRec::ePVR

◆ eVertex

EdbVertex* EdbVertexRec::eVertex
private

◆ eVTA

TList EdbVertexRec::eVTA

◆ eVTX

TObjArray* EdbVertexRec::eVTX

◆ eWorking

EdbVertex* EdbVertexRec::eWorking
private

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