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
 patterns volume (optional) More...
 
TList eVTA
 vertex-track associations More...
 
TObjArray * eVTX
 array of vertex More...
 
- Public Attributes inherited from EdbVertexPar
Float_t eAbin
 safety margin for angular aperture of vertex products More...
 
Float_t eDZmax
 maximum z-gap in the track-vertex group More...
 
Float_t eImpMax
 maximal acceptable impact parameter (preliminary check) More...
 
Float_t eImpMaxV
 if the impact is <= eImpMaxV the 2-vertex is accepted disregard to it's probability More...
 
Float_t eProbMin
 minimum acceptable probability for chi2-distance between tracks More...
 
Int_t eQualityMode
 vertex quality estimation method (0:=Prob/(sigVX^2+sigVY^2); 1:= inverse average track-vertex distance) More...
 
Bool_t eUseKalman
 use or not Kalman for the vertex fit. Default is true More...
 
Bool_t eUseLimits
 if true - look for the vertex only inside limits defined by eVmin:eVmax, default is false More...
 
Bool_t eUseMom
 use or not track momentum for vertex calculations More...
 
Bool_t eUseSegPar
 use only the nearest measured segments for vertex fit (as Neuchatel) More...
 
TVector3 eVmax
 limits for the vertex search More...
 
TVector3 eVmin
 
Float_t eZbin
 z- granularity (default is 100 microns) More...
 

Private Attributes

EdbVertexeVertex
 
EdbVertexeWorking
 

Constructor & Destructor Documentation

◆ EdbVertexRec() [1/2]

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

◆ EdbVertexRec() [2/2]

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

◆ ~EdbVertexRec()

EdbVertexRec::~EdbVertexRec ( )
virtual
713{
714 if ((gROOT->GetListOfSpecials())->FindObject(this))
715 {
716 (gROOT->GetListOfSpecials())->Remove(this);
717 }
718 Reset();
719}
void Reset()
Definition: EdbVertex.cxx:722

Member Function Documentation

◆ AcceptModifiedVTX()

void EdbVertexRec::AcceptModifiedVTX ( EdbVertex eVertex,
EdbVertex eWorking 
)
2685{
2686 if (eWorking && eVertex)
2687 {
2688 EdbVertex *eW = eWorking;
2689 int ind = eVertex->ID();
2690 eW->SetID(ind);
2691 eW->SetQuality(eW->V()->prob()/
2692 (eW->V()->vtx_cov_x()+eW->V()->vtx_cov_y()));
2693 int ntr = eVertex->N();
2694 for(int i=0; i<ntr; i++)
2695 {
2696 eVTA.Remove(eVertex->GetVTa(i));
2697 }
2698
2699 eW->ResetTracks();
2700 ntr = eW->N();
2701 int ifl = 0;
2702 for(int i=0; i<ntr; i++)
2703 {
2704 if (eW->Zpos(i)) ifl = ifl | 1;
2705 else ifl = ifl | 2;
2706 }
2707 ifl = 4 - ifl;
2708 if (ifl == 3) ifl = 0;
2709 if (eW->Nv()) ifl += 3;
2710 eW->SetFlag(ifl);
2711 if (eVTX) eVTX->AddAt(eW, ind);
2712 for(int i=0; i<ntr; i++)
2713 {
2714 AddVTA(eW->GetVTa(i));
2715 }
2716 ntr = eVertex->Nn();
2717 for(int i=0; i<ntr; i++)
2718 {
2719 eW->AddVTA(eVertex->GetVTn(i));
2720 }
2721// if (eVertex) delete eVertex;
2722 eW->ResetTracks();
2723 }
2724}
TObjArray * eVTX
array of vertex
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
vertex-track associations
Definition: EdbVertex.h:203
Definition: EdbVertex.h:69
Int_t ID() const
Definition: EdbVertex.h:126
void SetQuality(float q=0)
Definition: EdbVertex.h:161
void AddVTA(EdbVTA *vta)
Definition: EdbVertex.cxx:355
void SetID(int ID=0)
Definition: EdbVertex.h:156
EdbVTA * GetVTa(int i)
Definition: EdbVertex.h:139
VERTEX::Vertex * V() const
Definition: EdbVertex.h:154
Int_t N() const
Definition: EdbVertex.h:121
EdbVTA * GetVTn(int i)
Definition: EdbVertex.h:140
Int_t Nn() const
Definition: EdbVertex.h:122
void SetFlag(int flag=0)
Definition: EdbVertex.h:158
void ResetTracks()
Definition: EdbVertex.cxx:209
Int_t Zpos(int i)
Definition: EdbVertex.h:127
Int_t Nv()
Definition: EdbVertex.cxx:367
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 ( )
2184{
2186}
void AcceptModifiedVTX(EdbVertex *eVertex, EdbVertex *eWorking)
Definition: EdbVertex.cxx:2684

◆ AddSegmentToVertex()

int EdbVertexRec::AddSegmentToVertex ( EdbSegP s,
float  ImpMax = 25.,
float  ProbMin = 0.01,
float  Mom = 0.3 
)
1979{
1980 EdbVTA *vta = 0;
1981 EdbVertex *ePrevious = 0;
1982
1983 if (eWorking == 0)
1984 {
1985 eWorking = new EdbVertex();
1986 int ntr = eVertex->N();
1987 int i = 0, n = 0;
1988 for(i=0; i<ntr; i++)
1989 {
1990 if ((vta = AddTrack(*(eWorking), eVertex->GetTrack(i), eVertex->Zpos(i))))
1991 {
1992 eVertex->GetTrack(i)->AddVTA(vta);
1993 n++;
1994 }
1995 }
1996 if (n < 2)
1997 {
1998 SafeDelete(eWorking);
2000 printf("Can't create working copy of the vertex!\n");
2001 fflush(stdout);
2002 return 0;
2003 }
2004
2005 if (!MakeV(*(eWorking)))
2006 {
2007 SafeDelete(eWorking);
2009 printf("Can't create working copy of the vertex!\n");
2010 fflush(stdout);
2011 return 0;
2012 }
2013 }
2014 else
2015 {
2016 ePrevious = eWorking;
2017 eWorking = new EdbVertex();
2018 int ntr = ePrevious->N();
2019 int i = 0, n = 0;
2020 for(i=0; i<ntr; i++)
2021 {
2022 if ((vta = AddTrack(*(eWorking),(ePrevious)->GetTrack(i), (ePrevious)->Zpos(i))))
2023 {
2024 (ePrevious->GetTrack(i))->AddVTA(vta);
2025 n++;
2026 }
2027 }
2028 if (n < 2)
2029 {
2030 SafeDelete(eWorking);
2031 if (ePrevious)
2032 {
2033 eWorking = ePrevious;
2035 }
2036 else
2037 {
2039 }
2040 printf("Can't create working copy of the vertex!\n");
2041 fflush(stdout);
2042 return 0;
2043 }
2044
2045 if (!MakeV(*(eWorking)))
2046 {
2047 SafeDelete(eWorking);
2048
2049 if (ePrevious)
2050 {
2051 eWorking = ePrevious;
2053 }
2054 else
2055 {
2057 }
2058 printf("Can't create working copy of the vertex!\n");
2059 fflush(stdout);
2060 return 0;
2061 }
2062 }
2063 float mass = 0.139; //pion
2064 EdbTrackP *Tr = new EdbTrackP(s, mass);
2065 Tr->SetP(Mom);
2066 Tr->FitTrackKFS();
2067 float ImpMaxSave = eImpMax;
2068 eImpMax = ImpMax;
2069 float ProbMinSave = eProbMin;
2070 eProbMin = ProbMin;
2071 if ((vta = AddTrack(*(eWorking), Tr, 1)))
2072 {
2073 if ( Tr->Z() >= eWorking->VZ() ) vta->SetZpos(1);
2074 else vta->SetZpos(0);
2075 Tr->AddVTA(vta);
2076 EdbVertex *eW = eWorking;
2077 eW->SetID(eVertex->ID());
2078 eW->V()->rmsDistAngle();
2079 int trind = eEdbTracks->GetEntries();
2080 Tr->SetID(trind);
2081 eEdbTracks->Add(Tr);
2082 Tr->SetSegmentsTrack();
2083 eImpMax = ImpMaxSave;
2084 eProbMin = ProbMinSave;
2085 }
2086 else
2087 {
2088 printf("Track not added! May be Prob < ProbMin=%f. Change ProbMin with 'TrackParams' button!\n",ProbMin);
2089 fflush(stdout);
2090 delete Tr;
2091
2092 SafeDelete(eWorking);
2093 if (ePrevious)
2094 {
2095 eWorking = ePrevious;
2097 }
2098 else
2099 {
2101 }
2102 eImpMax = ImpMaxSave;
2103 eProbMin = ProbMinSave;
2104 return 0;
2105 }
2106 return 1;
2107}
FILE * stdout
void SetID(int id)
Definition: EdbSegP.h:128
Float_t Z() const
Definition: EdbSegP.h:153
void SetP(float p)
Definition: EdbSegP.h:133
Definition: EdbPattern.h:113
void AddVTA(EdbVTA *vta)
Definition: EdbPattern.cxx:450
int FitTrackKFS(bool zmax=false, float X0=5810., int design=0)
Definition: EdbPattern.cxx:722
int SetSegmentsTrack(int id)
Definition: EdbPattern.h:246
Definition: EdbVertex.h:26
void SetZpos(int zpos)
Definition: EdbVertex.h:55
Float_t eImpMax
maximal acceptable impact parameter (preliminary check)
Definition: EdbVertex.h:179
Float_t eProbMin
minimum acceptable probability for chi2-distance between tracks
Definition: EdbVertex.h:178
Int_t MakeV(EdbVertex &edbv, bool isRefit=false)
Definition: EdbVertex.cxx:791
TObjArray * eEdbTracks
Definition: EdbVertex.h:204
EdbVTA * AddTrack(EdbVertex &edbv, EdbTrackP *track, int zpos)
Definition: EdbVertex.cxx:878
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
s
Definition: check_shower.C:55
float mass
Definition: check_vertex.C:21
float ImpMax
Definition: check_vertex.C:30

◆ AddTrack()

EdbVTA * EdbVertexRec::AddTrack ( EdbVertex edbv,
EdbTrackP track,
int  zpos 
)

add track to already existing vertex if prob > eProbMin
if vertex do not exist yet - calculate medium x,y,z

879{
882
883 if (!track) return 0;
884 EdbSegP *seg = track->TrackExtremity( zpos, eUseSegPar);
885 if (!seg) return 0;
886 int ntr = edbv.N();
887 if(edbv.TrackInVertex(track)) return 0;
888 //for (int i=0; i<ntr; i++) if(track == edbv.GetTrack(i)) return 0;
889
890 EdbVTA *vta = new EdbVTA(track, &edbv);
891 vta->SetZpos(zpos);
892 vta->SetFlag(2);
893 edbv.AddVTA(vta);
894
895 if(ntr<1) // this is the first track in the vertex
896 {
897 edbv.SetXYZ( seg->X(), seg->Y(), seg->Z());
898 return vta;
899 }
900 else
901 {
902 if( MakeV(edbv) )
903 if( (edbv.V()->prob() > eProbMin) ) return vta;
904 }
905 edbv.RemoveVTA(vta);
906 if(ntr>1)
907 if( !MakeV(edbv) ) Log(1,"EdbVertexRec::AddTrack","vertex lost! ntr = %d",ntr);
908 SafeDelete(vta);
909 return 0;
910}
bool Log(int level, const char *location, const char *fmt,...)
Definition: EdbLog.cxx:75
Definition: EdbSegP.h:21
Float_t X() const
Definition: EdbSegP.h:173
Float_t Y() const
Definition: EdbSegP.h:174
void SetFlag(int flag)
Definition: EdbVertex.h:56
Bool_t eUseSegPar
use only the nearest measured segments for vertex fit (as Neuchatel)
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:361
Definition: bitview.h:14

◆ AddTrackToVertex()

EdbVertex * EdbVertexRec::AddTrackToVertex ( EdbVertex eVertex,
EdbTrackP eTr,
int  zpos 
)
2522{
2523 EdbVTA *vta = 0;
2524 EdbVertex *old = 0;
2525 EdbVertex *eWorking = 0;
2526 if (!eVertex)
2527 {
2528
2529 printf("No working vertex selected!\n");
2530 fflush(stdout);
2531 return 0;
2532 }
2533 if (!eTr)
2534 {
2535
2536 printf("No working track selected!\n");
2537 fflush(stdout);
2538 return 0;
2539 }
2540 if ((old = eTr->VertexS()) && (zpos == 1))
2541 {
2542
2543 printf("Track alredy connected to a vertex by this edge!\n");
2544 fflush(stdout);
2545 return 0;
2546 }
2547 if ((old = eTr->VertexE()) && (zpos == 0))
2548 {
2549
2550 printf("Track alredy connected to a vertex by this edge!\n");
2551 fflush(stdout);
2552 return 0;
2553 }
2554 if (eWorking == 0)
2555 {
2556 eWorking = new EdbVertex();
2557 int ntr = eVertex->N();
2558 int i = 0, n = 0;
2559 for(i=0; i<ntr; i++)
2560 {
2561 if ((vta = AddTrack(*(eWorking), (eVertex)->GetTrack(i), (eVertex)->Zpos(i))))
2562 {
2563 (eVertex)->GetTrack(i)->AddVTA(vta);
2564 n++;
2565 }
2566 }
2567 if (n < 2)
2568 {
2569 SafeDelete(eWorking);
2570 (eVertex)->ResetTracks();
2571 printf("Can't create working copy of the vertex!\n");
2572 fflush(stdout);
2573 return 0;
2574 }
2575
2576 if (!MakeV(*eWorking))
2577 {
2578 SafeDelete(eWorking);
2580 printf("Can't create working copy of the vertex!\n");
2581 fflush(stdout);
2582 return 0;
2583 }
2584 }
2585 if ((vta = AddTrack(*eWorking, eTr, zpos)))
2586 {
2587 eTr->AddVTA(vta);
2588 eWorking->SetID(eVertex->ID());
2589 }
2590 else
2591 {
2592// printf("Track not added! May be Prob < ProbMin.\n");
2593// fflush(stdout);
2594 SafeDelete(eWorking);
2596 return 0;
2597 }
2598 return eWorking;
2599}
EdbVertex * VertexS()
Definition: EdbPattern.cxx:1191
EdbVertex * VertexE()
Definition: EdbPattern.cxx:1198

◆ 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 
)
2727{
2728 SafeDelete(eWorking);
2729 if (eVertex) eVertex->ResetTracks();
2730}

◆ CheckDZ2()

Bool_t EdbVertexRec::CheckDZ2 ( float  z1,
float  z2,
int  zpos1,
int  zpos2,
float  z 
)

return 1 if the vertex position (z) is in agreement with limits defined by eZbin and eDZmax

1400{
1402
1403 float zvmin,zvmax;
1404 if (zpos1 == 0 && zpos2 == 1) // ends & starts
1405 {
1406 zvmin = TMath::Min(z1,z2) - 0.5*eZbin;
1407 zvmax = TMath::Max(z1,z2) + 0.5*eZbin;
1408 if (z < zvmin || z > zvmax) return 0;
1409 }
1410 else if (zpos1 == 1 && zpos2 == 1) // starts & starts
1411 {
1412 zvmax = TMath::Min(z1,z2) + eZbin;
1413 zvmin = TMath::Max(z1,z2) - eDZmax;
1414 if (z > zvmax || z < zvmin) return 0;
1415 }
1416 else if (zpos1 == 0 && zpos2 == 0) // ends & ends
1417 {
1418 zvmin = TMath::Max(z1 ,z2);
1419 zvmax = TMath::Min(z1 ,z2) + eDZmax + eZbin;
1420 if (z < zvmin || z > zvmax ) return 0;
1421 }
1422 return 1;
1423}
Float_t eZbin
z- granularity (default is 100 microns)
Definition: EdbVertex.h:175
Float_t eDZmax
maximum z-gap in the track-vertex group
Definition: EdbVertex.h:177

◆ CheckImpact()

float EdbVertexRec::CheckImpact ( EdbSegP s1,
EdbSegP s2,
int  zpos1,
int  zpos2,
float  pv[3] 
)

Return: the distance between 2 lines defined by s1 and s2
Input: s1,s2,zpos1,zpos2, where
zpos1, zpos2: 0 - end of the track (to be propagated forward in z)
zpos1, zpos2: 1 - start of the track (to be propagated backward in z)
Output: pv - "vertex position" - the nearest point to the both lines

1223{
1229
1230 float p1[3], p2[3]; // first line
1231 float p3[3], p4[3]; // second line
1232 float pa[3], pb[3]; // shortest line
1233 double mua, mub;
1234
1235 float dz;
1236
1237 p1[0] = s1->X();
1238 p1[1] = s1->Y();
1239 p1[2] = s1->Z();
1240 dz = zpos1? -eDZmax : eDZmax;
1241 p2[0] = s1->X() + dz*s1->TX();
1242 p2[1] = s1->Y() + dz*s1->TY();
1243 p2[2] = s1->Z() + dz;
1244
1245 p3[0] = s2->X();
1246 p3[1] = s2->Y();
1247 p3[2] = s2->Z();
1248 dz = zpos2? -eDZmax : eDZmax;
1249 p4[0] = s2->X() + dz*s2->TX();
1250 p4[1] = s2->Y() + dz*s2->TY();
1251 p4[2] = s2->Z() + dz;
1252
1253 if( !EdbMath::LineLineIntersect( p1, p2, p3, p4, pa, pb, mua, mub ) ) return 10e+10;
1254 if (pv) for (int i = 0; i<3; i++) pv[i] = 0.5*(pa[i] + pb[i]);
1255 return EdbMath::Magnitude3( pa, pb );
1256}
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
tangens = deltaX/deltaZ
Definition: EdbSegP.h:175
Float_t TY() const
tangens = deltaY/deltaZ
Definition: EdbSegP.h:176
EdbSegP * s1
Definition: tlg2couples.C:29
EdbSegP * s2
Definition: tlg2couples.C:30

◆ CheckImpactN()

float EdbVertexRec::CheckImpactN ( EdbSegP s1,
EdbSegP s2,
float  pv[3],
bool &  parallel,
float  dzMax = 6000. 
)

Return: the distance between 2 lines defined by s1 and s2
Output: pv - "vertex position" - the nearest point to the both lines

1262{
1265
1266 float imp = 1e+10;
1267 float p1[3], p2[3]; // first line
1268 float p3[3], p4[3]; // second line
1269 float pa[3], pb[3]; // shortest line
1270 double mua, mub;
1271
1272 p1[0] = s1->X() - dzMax*s1->TX();
1273 p1[1] = s1->Y() - dzMax*s1->TY();
1274 p1[2] = s1->Z() - dzMax;
1275 p2[0] = s1->X() + dzMax*s1->TX();
1276 p2[1] = s1->Y() + dzMax*s1->TY();
1277 p2[2] = s1->Z() + dzMax;
1278
1279 p3[0] = s2->X() - dzMax*s2->TX();
1280 p3[1] = s2->Y() - dzMax*s2->TY();
1281 p3[2] = s2->Z() - dzMax;
1282 p4[0] = s2->X() + dzMax*s2->TX();
1283 p4[1] = s2->Y() + dzMax*s2->TY();
1284 p4[2] = s2->Z() + dzMax;
1285
1286 if( EdbMath::LineLineIntersect( p1, p2, p3, p4, pa, pb, mua, mub ) ) {
1287 parallel = false;
1288 for (int i = 0; i<3; i++) pv[i] = 0.5*(pa[i] + pb[i]);
1289 imp = EdbMath::Magnitude3( pa, pb );
1290 } else { // the lines are parallel: take as vertex the mean point, calc. the distance to line
1291 parallel = true;
1292 pv[0] = 0.5*(s1->X()+s2->X());
1293 pv[1] = 0.5*(s1->Y()+s2->Y());
1294 pv[2] = 0.5*(s1->Z()+s2->Z());
1295 bool inside=0;
1296 imp = 2. * EdbMath::DistancePointLine3(pv, p1,p2, &inside);
1297 }
1298 return imp;
1299}
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 
)

loop for all tracks and check if some of them can form the vertex with tr

3243{
3245 int ntr = eEdbTracks->GetEntries();
3246 if(ntr<1) return 0;
3247 int nvtx=0;
3248
3249 EdbTrackP *t=0;
3250 for(int itr=0; itr<ntr; itr++) {
3251 t = (EdbTrackP*)(eEdbTracks->At(itr));
3252 if (t == &track) continue;
3253 if (t->Flag() < 0) continue;
3254
3255 EdbVertex *vtx0 = ProbVertex2( &track, t, zpos, 0 );
3256 if(vtx0) {
3257 AddVertex(vtx0);
3258 nvtx++;
3259 }
3260 EdbVertex *vtx1 = ProbVertex2( &track, t, zpos, 1 );
3261 if(vtx1) {
3262 AddVertex(vtx1);
3263 nvtx++;
3264 }
3265
3266 }
3267 Log(2,"EdbVertexRec::CheckTrack","%d couples found",nvtx);
3268 return nvtx;
3269}
void AddVertex(EdbVertex *vtx)
Definition: EdbVertex.h:290
EdbVertex * ProbVertex2(EdbTrackP *tr1, EdbTrackP *tr2, int zpos1, int zpos2)
Definition: EdbVertex.cxx:1302
TTree * t
Definition: check_shower.C:4

◆ CheckVTX()

void EdbVertexRec::CheckVTX ( )

rank the vertices and reassign tracks according to the major vertex weight

1499{
1501
1502 if(!eVTX) return;
1503 int nvtx = eVTX->GetEntries();
1504 Log(2,"EdbVertexRec::CheckVTX","%d vertices",nvtx);
1505 if(nvtx<1) return;
1506
1507 TArrayF weight(nvtx); // the vertex "weight" = 10*ntr+prob
1508 TArrayI ind(nvtx);
1509 EdbVertex *vtx=0;
1510 for(int i=0; i<nvtx; i++) {
1511 vtx = GetVertex(i);
1512 //vtx->SetFlag(0); // to check!!!
1513 weight[i] = 10*vtx->N() + vtx->V()->prob();
1514 }
1515 TMath::Sort(nvtx,weight.GetArray(),ind.GetArray(),0); // sort in ascending order
1516 for(int i=0; i<nvtx; i++) {
1517 vtx = GetVertex(ind[i]);
1518 vtx->ResetTracks();
1519 }
1520
1521 // discard vertices with the detached tracks
1522 for(int i=0; i<nvtx; i++) {
1523 vtx = GetVertex(ind[i]);
1524 int ndisc = vtx->CheckDiscardedTracks();
1525 if(ndisc>0) {
1526 Log(2,"EdbVertexRec::CheckVTX","discard vtx i=%d ntr=%d flag before: %d disc tracks: %d",i, vtx->N(), vtx->Flag(), ndisc);
1527 vtx->SetFlag(-10);
1528 } else {
1529 vtx->EstimateVertexFlag();
1530 }
1531 }
1532
1533 // reassign the vertex id's
1534 for (Int_t i = 0; i < nvtx; i++) GetVertex(i)->SetID(i);
1535
1536 //eVTA.Clear(); //TODO?
1537}
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 
)
979{
980 float impMin = 5; // limits for the tracks separability
981 float thetaMin = 0.005; //
982
983 if( TMath::Abs(stest.X()-pred.X()) > dxy ) return 0;
984 if( TMath::Abs(stest.Y()-pred.Y()) > dxy ) return 0;
985 if( stest.Z() < zminT ) return 0;
986 if( stest.Z() > zmaxT ) return 0;
987
988 float dtheta = TMath::Sqrt( (stest.TX()-pred.TX())*(stest.TX()-pred.TX()) + (stest.TY()-pred.TY())*(stest.TY()-pred.TY()) );
989 if(dtheta>dthetaMax) return 0;
990 float pv[3];
991 bool parallel;
992 float imp = CheckImpactN( &pred,&stest,pv, parallel, eDZmax);
993 if(imp>impact) return 0;
994
995 //printf("v: %f %f %f\n", pv[0],pv[1],pv[2]);
996 //pred.PrintNice();
997
998 if( dtheta<thetaMin && imp > 3*impMin) return 0; // parallel not close tracks ( can be interesting for decay search??)
999
1000 if( dtheta>thetaMin) { // check z of the vertex
1001 float marg = impMin/dtheta;
1002 if( pv[2] < zminV-marg ) return 0;
1003 if( pv[2] > zmaxV+marg ) return 0;
1004 }
1005
1006 Log(2,"EdbVertexRec::CompatibleSegments","ids = %6d and %6d PH: %3d imp = %7.3f dtheta = %7.3f dzT = %7.3f dzV = %7.3f",
1007 pred.ID(), stest.ID(), int(stest.W()), imp, dtheta, stest.Z()-pred.Z(), pv[2]-pred.Z());
1008 return 1;
1009}
Int_t ID() const
Definition: EdbSegP.h:147
Float_t W() const
Definition: EdbSegP.h:151
Float_t CheckImpactN(EdbSegP *s1, EdbSegP *s2, float pv[3], bool &parallel, float dzMax=6000.)
Definition: EdbVertex.cxx:1260

◆ EstimateVertexFlag()

int EdbVertexRec::EstimateVertexFlag ( int  zpos1,
int  zpos2 
)
1377{
1378 if (zpos1 == 0 && zpos2 == 1) return 1; // end & start
1379 else if (zpos1 == 1 && zpos2 == 0) return 1; // end & start
1380 else if (zpos1 == 1 && zpos2 == 1) return 0; // start & start
1381 else if (zpos1 == 0 && zpos2 == 0) return 2; // end & end
1382 return -1;
1383}

◆ EstimateVertexPosition()

Bool_t EdbVertexRec::EstimateVertexPosition ( EdbVertex v)

make approximate (without matrix) estimation of the vertex and set the reference point of the vertex XYZ in the estimated position

754{
757
758 int nt = v.N();
759 if(nt<2) return false;
760
761 EdbSegP *s1=0,*s2=0;
762 bool zpos1,zpos2;
763 float vxyz[3], vsum[3];
764 for(int i=0; i<3; i++) vsum[i]=0;
765 int count=0;
766 for(int i1=0; i1<nt-1; i1++) {
767 s1 = v.GetTrackV(i1,eUseSegPar);
768 zpos1 = v.Zpos(i1);
769 for(int i2=1; i2<nt; i2++) {
770 s2 = v.GetTrackV(i2,eUseSegPar);
771 zpos2 = v.Zpos(i2);
772 if( CheckImpact(s1,s2,zpos1,zpos2, vxyz) > 2.*eImpMax) continue;
773 for(int i=0; i<3; i++) vsum[i]+=vxyz[i];
774 count++;
775 }
776 }
777 if(count) for(int i=0; i<3; i++) vsum[i]/=count;
778 else { // take just mean tracks position
779 for(int i=0; i<nt; i++) {
781 vsum[0] += s->X(); vsum[1] += s->Y(); vsum[2] += s->Z();
782 }
783 for(int i=0; i<3; i++) vsum[i]/=nt;
784 }
785 v.SetXYZ(vsum[0],vsum[1],vsum[2]);
786 Log(3,"EdbVertexRec::EstimateVertexPosition","%f %f %f",vsum[0],vsum[1],vsum[2]);
787 return true;
788}
float vxyz[3]
Definition: RecDispMC.C:144
Float_t CheckImpact(EdbSegP *s1, EdbSegP *s2, int zpos1, int zpos2, float pv[3])
Definition: EdbVertex.cxx:1221
EdbSegP * GetTrackV(int i, bool usesegpar=false)
Definition: EdbVertex.cxx:159

◆ EstimateVertexQuality()

Bool_t EdbVertexRec::EstimateVertexQuality ( EdbVertex v)

TODO! razobratsia s etimi qualitiami!!

730{
732
733 float quality=0.;
734 vtx.SetQuality(quality);
735 Vertex *v = vtx.V();
736 if(!v) return 0;
737 if(!v->valid()) return 0;
738
739 if (eQualityMode == 0) quality = v->prob()/(v->vtx_cov_x()+v->vtx_cov_y());
740 else if (eQualityMode == 1)
741 {
742 double rms=v->rmsDistAngle();
743 if (rms != 0.) quality= (float)(1./rms);
744 else quality = 10.e+35;
745 }
746 else quality= 1.;
747
748 vtx.SetQuality(quality);
749 return 1;
750}
Int_t eQualityMode
vertex quality estimation method (0:=Prob/(sigVX^2+sigVY^2); 1:= inverse average track-vertex distanc...
Definition: EdbVertex.h:183
Definition: VtVertex.hh:88
bool valid() const
is vertex valid?

◆ FillTracksStartEnd()

void EdbVertexRec::FillTracksStartEnd ( TIndexCell starts,
TIndexCell ends 
)

fill tracks starts and ends lookup tables "z:entry" inside sorted tracks: starts - minimal Z; ends - maximal Z

1114{
1117
1118 EdbTrackP *tr=0;
1119 int ntr = eEdbTracks->GetEntries();
1120 Long_t v[2];
1121
1122 EdbSegP *s=0;
1123 for(int itr=0; itr<ntr; itr++) {
1124 tr = (EdbTrackP*)(eEdbTracks->At(itr));
1125 if (tr->Flag() < 0) continue;
1126 s = tr->TrackZmin(eUseSegPar);
1127 if(eUseLimits) if( !IsInsideLimits(*s) ) continue;
1128 v[0] = (Long_t)(s->Z()/eZbin);
1129 v[1] = itr;
1130 starts.Add(2,v);
1131 s = tr->TrackZmax(eUseSegPar);
1132 if(eUseLimits) if( !IsInsideLimits(*s) ) continue;
1133 v[0] = (Long_t)(s->Z()/eZbin);
1134 v[1] = itr;
1135 ends.Add(2,v);
1136 }
1137 starts.Sort();
1138 ends.Sort();
1139}
TTree * tr
Definition: Shower_E_FromShowerRoot.C:5
Bool_t eUseLimits
if true - look for the vertex only inside limits defined by eVmin:eVmax, default is false
Definition: EdbVertex.h:185
Bool_t IsInsideLimits(EdbSegP &s)
Definition: EdbVertex.cxx:1386
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 
)

Find all segments from path compatible with the pred segment and add them to found array

1015{
1017
1018 int nseg = pat.N(); if(nseg<1) return 0;
1019 int nfound=0;
1020 for(int i=0; i<nseg; i++) {
1021 EdbSegP *s = pat.GetSegment(i);
1022 if (s->Flag() < 0) continue; // sure?
1023 if( CompatibleSegments( spred,*s, impact, dthetaMax, dxy, zminT, zmaxT, zminV, zmaxV) ) found.Add(s);
1024 else continue;
1025 nfound++;
1026 }
1027 Log(2,"EdbVertexRec::FindSimilarSegments","%d segments are found",nfound);
1028 return nfound;
1029}
Int_t N() const
Definition: EdbPattern.h:86
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:976

◆ FindSimilarTracks()

Int_t EdbVertexRec::FindSimilarTracks ( EdbTrackP t,
TObjArray &  found,
int  nsegmin = 2,
float  dMax = 100.,
float  dTheta = 0.01,
float  dZmax = 50000. 
)

find all tracks close to the "track" and return them in "found"
nsegmin - min number of segments for the interesting tracks
gMax - max 3-d distance between track lines
dTheta - max spatial angle between track lines
dZmax - max distance in z between track lines

914{
920
921 using namespace TMath;
922 int ntr = eEdbTracks->GetEntries();
923 if(ntr<1) return 0;
924
925 EdbTrackP *t=0;
926 EdbSegP *s=track.TrackZmin(eUseSegPar);
927 EdbSegP *e=track.TrackZmax(eUseSegPar);
928 EdbSegP *ts=0, *te=0; // start and end for the other tracks
929
930 track.FitTrack();
931 EdbSegP *t1=(EdbSegP*)(&track);
932 EdbSegP *t2;
933 int nfound=0;
934 float pv[3], imp, dtheta;
935 for(int itr=0; itr<ntr; itr++) {
936 t = (EdbTrackP*)(eEdbTracks->At(itr));
937 if (t == &track) continue;
938 if (t->Flag() < 0) continue;
939 ts = t->TrackZmin(eUseSegPar);
940 te = t->TrackZmax(eUseSegPar);
941 if( Min(ts->X(),te->X()) - Max(s->X(),e->X()) > dMax ) continue;
942 if( Min(s->X(),e->X()) - Max(ts->X(),te->X()) > dMax ) continue;
943 if( Min(ts->Y(),te->Y()) - Max(s->Y(),e->Y()) > dMax ) continue;
944 if( Min(s->Y(),e->Y()) - Max(ts->Y(),te->Y()) > dMax ) continue;
945 if( Min(ts->Z(),te->Z()) - Max(s->Z(),e->Z()) > dZmax ) continue;
946 if( Min(s->Z(),e->Z()) - Max(ts->Z(),te->Z()) > dZmax ) continue;
947
948 t->FitTrack();
949 t2 = (EdbSegP*)t;
950 dtheta = Sqrt( (t2->TX()-t1->TX())*(t2->TX()-t1->TX()) + (t2->TY()-t1->TY())*(t2->TY()-t1->TY()) );
951 if(dtheta>dTheta) continue;
952 imp = CheckImpact( t1,t2,1,1, pv);
953 if(imp>dMax) continue;
954
955 found.Add(t);
956 nfound++;
957 }
958
959 Log(2,"EdbVertexRec::FindSimilarTracks","%d tracks found",nfound);
960 if(gEDBDEBUGLEVEL>1) {
961 for(int i=0; i<found.GetEntries(); i++) {
962 t = (EdbTrackP*)found.At(i);
963 t2 = (EdbSegP*)t;
964 dtheta = Sqrt( (t2->TX()-t1->TX())*(t2->TX()-t1->TX()) + (t2->TY()-t1->TY())*(t2->TY()-t1->TY()) );
965 imp = CheckImpact( t1,t2,1,1, pv);
966 Log(3,"EdbVertexRec::FindSimilarTracks",
967 "id =%6d imp = %7.3f dtheta = %7.3f nseg =%3d\n", t->ID(), imp, dtheta,t->N());
968 }
969 }
970
971 return nfound;
972}
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 
)

Find all tracks with the requested extremity close to the pred segment and add them to found array

startend - selecting tracks extremity to be used: 0-tracks starts (zmin) 1-tracks ends (zmax)
impact - max 3D distance between segment lines
dthetaMax - max spatial angle between track lines
dxy - preliminary distance cut between segments
zminT,zmaxT - limits in Z for the tracks extremity
zminV,zmaxV - limits in Z for the estimated vertex position

1035{
1044
1045 int ntr = eEdbTracks->GetEntries();
1046 if(ntr<1) return 0;
1047 int nfound=0;
1048
1049 EdbSegP *t1=&spred;
1050 for(int itr=0; itr<ntr; itr++) {
1051 EdbTrackP *t = (EdbTrackP*)(eEdbTracks->At(itr));
1052 if (t->Flag() < 0) continue;
1053 EdbSegP *te = t->TrackExtremity(startend,eUseSegPar); // select track extremity
1054
1055 if( CompatibleSegments( *t1,*te, impact, dthetaMax, dxy, zminT, zmaxT, zminV, zmaxV) ) found.Add(t);
1056 else continue;
1057
1058 nfound++;
1059 }
1060 Log(2,"EdbVertexRec::FindSimilarTracksE","%d tracks found",nfound);
1061 return nfound;
1062}

◆ FindVertex()

int EdbVertexRec::FindVertex ( )

Note: in this function is assumed that all tracks selections are already done
ProbMin - minimal probability for chi2-distance between tracks

1066{
1069
1070 //if(!ePVR) ePVR = ((EdbPVRec *)(gROOT->GetListOfSpecials()->FindObject("EdbPVRec")));
1071 if (ePVR) if (ePVR->IsA() != EdbPVRec::Class()) ePVR = 0;
1072 if(!ePVR) {Log(1,"EdbVertexRec::FindVertex","Error! EdbPVRec not defined, use SetPVRec(...)"); return 0;}
1073
1074 EdbVertex *edbv = 0;
1075 TIndexCell starts,ends; // "ist:entry" "iend:entry"
1076 FillTracksStartEnd( starts, ends );
1077
1078 if(gEDBDEBUGLEVEL>1) printf("-----Search 2-track vertexes----------------------------\n");
1079
1080 int nvtx = 0;
1081
1082 if(gEDBDEBUGLEVEL>1) printf(" End-Begin tracks combinations:\n");
1083 nvtx += LoopVertex(ends , starts, 0, 1 );
1084
1085 if(gEDBDEBUGLEVEL>1) printf(" Begin-Begin tracks combinations:\n");
1086 nvtx += LoopVertex(starts, starts, 1, 1 );
1087
1088 if(gEDBDEBUGLEVEL>1) printf(" End-End tracks combinations:\n");
1089 nvtx += LoopVertex(ends , ends, 0, 0 );
1090
1091 int nvtxt = 0;
1092 if (eVTX) nvtxt = eVTX->GetEntries();
1093
1094 if(nvtx!=nvtxt) printf("ERROR: EdbVertexRec::FindVertex(): nvtx =%d nvtxt =%d\n",nvtx,nvtxt);
1095
1096 //for (Int_t i = 0; i < nvtxt; i++) GetVertex(i)->SetID(i);
1097
1098 if (nvtxt) eVTX->Sort(nvtxt-1);
1099
1100 for (Int_t i = nvtx-1; i >= 0; i--) {
1101 edbv = GetVertex(i);
1102 if (!edbv) continue;
1103 edbv->SetID(i);
1104 edbv->ResetTracks();
1105 }
1106
1107 if(gEDBDEBUGLEVEL>1) printf("----------------- %d vtx ---------------------------------------\n", nvtx);
1108
1109 return nvtx;
1110}
Int_t LoopVertex(TIndexCell &list1, TIndexCell &list2, int zpos1, int zpos2)
Definition: EdbVertex.cxx:1142
void FillTracksStartEnd(TIndexCell &starts, TIndexCell &ends)
Definition: EdbVertex.cxx:1113
EdbPVRec * ePVR
patterns volume (optional)
Definition: EdbVertex.h:206
sort collection with attributes
Definition: TIndexCell.h:19

◆ GetEdbTrack()

EdbTrackP * EdbVertexRec::GetEdbTrack ( const int  index)
3236{
3237 if (eEdbTracks) return (EdbTrackP *)eEdbTracks->At(index);
3238 else return 0;
3239}

◆ GetVertex()

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

◆ IsInsideLimits()

Bool_t EdbVertexRec::IsInsideLimits ( EdbSegP s)

return 1 if the segment position (x,y,z) is inside the limits defined by eVmin,eVmax

1387{
1389 if(s.X()<eVmin.X()) return 0;
1390 if(s.Y()<eVmin.Y()) return 0;
1391 if(s.Z()<eVmin.Z()) return 0;
1392 if(s.X()>eVmax.X()) return 0;
1393 if(s.Y()>eVmax.Y()) return 0;
1394 if(s.Z()>eVmax.Z()) return 0;
1395 return 1;
1396}
TVector3 eVmax
limits for the vertex search
Definition: EdbVertex.h:186
TVector3 eVmin
Definition: EdbVertex.h:186

◆ LinkedVertexes()

int EdbVertexRec::LinkedVertexes ( )

calculate the number of linked vertices (with Nv()>0) and set flag+3 for them

1810{
1812 int nvt = Nvtx();
1813 if (!nvt) return 0;
1814 EdbVertex *v = 0;
1815 int nvl = 0;
1816 for (int iv=0; iv<nvt; iv++) {
1817 v = GetVertex(iv);
1818 if (v)
1819 if (v->Flag() != -10)
1820 if (v->Nv() != 0) {
1821 if (v->Flag() < 3) v->SetFlag(v->Flag()+3);
1822 nvl++;
1823 }
1824 }
1825 return nvl;
1826}
Int_t Nvtx() const
Definition: EdbVertex.h:287

◆ LoopVertex()

int EdbVertexRec::LoopVertex ( TIndexCell list1,
TIndexCell list2,
int  zpos1,
int  zpos2 
)

zpos1 - the direction flag for the first track 1-start, 0-end
zpos2 - the direction flag for the second track
in cycles is assumed that members of list1 has z <= members of list2

1144{
1145
1149
1150 Log(3,"EdbVertexRec::LoopVertex"," Selection: dZmax=%.0f Abin=%.3f ProbMin=%f zBin=%.0f usemom=%d",
1152
1153 int nvtx = 0;
1154 int ncombin = 0;
1155 int ncount = 0;
1156
1157 TIndexCell *c1=0, *c2=0;
1158 EdbTrackP *tr1=0, *tr2=0;
1159 int itr1, itr2;
1160
1161 int nz1 = list1.GetEntries();
1162 int nz2 = list2.GetEntries();
1163 float z1, z2;
1164
1165 //int ntot = nz1*nz2;
1166 //printf(" 2-track vertexes search in progress... %3d%%", 0);
1167
1168 for(int iz1=0; iz1<nz1; iz1++) { // first z-group
1169 c1 = list1.At(iz1);
1170 z1 = c1->Value()*eZbin;
1171 int nc1=c1->GetEntries();
1172
1173 for(int iz2=0; iz2<nz2; iz2++) { // second z-group
1174 c2 = list2.At(iz2);
1175 z2 = c2->Value()*eZbin;
1176
1177 if( z2 < z1 ) continue;
1178 if( z2-z1 > eDZmax ) break;
1179
1180 ncount++;
1181 //printf("\b\b\b\b%3d%%",(int)((double)ncount/double(ntot)*100.));
1182 fflush(stdout);
1183
1184 int nc2=c2->GetEntries();
1185 for(int ic1=0; ic1<nc1; ic1++) { // first z-group entries
1186
1187 itr1 = c1->At(ic1)->Value();
1188 tr1 = (EdbTrackP*)((*eEdbTracks)[itr1]);
1189 if(!tr1) continue;
1190
1191 int ic2start=0;
1192 if(c1==c2) ic2start=ic1+1;
1193
1194 for(int ic2=ic2start; ic2<nc2; ic2++) { // second z-group entries
1195 ncombin++;
1196
1197 itr2 = c2->At(ic2)->Value();
1198 if(itr2==itr1) continue;
1199 tr2 = (EdbTrackP*)((*eEdbTracks)[itr2]);
1200 if(!tr2) continue;
1201
1202 EdbVertex *vtx = ProbVertex2( tr1, tr2, zpos1, zpos2 );
1203 if(vtx) {
1204 AddVertex(vtx);
1205 nvtx++;
1206 }
1207
1208 }
1209 }
1210 }
1211 }
1212
1213 //printf("\b\b\b\b%3d%%\n",100);
1214
1215 Log(3,"EdbVertexRec::LoopVertex"," %6d pairs -> %d vertices accepted\n", ncombin, nvtx);
1216
1217 return nvtx;
1218}
Bool_t eUseMom
use or not track momentum for vertex calculations
Definition: EdbVertex.h:181
Float_t eAbin
safety margin for angular aperture of vertex products
Definition: EdbVertex.h:176
Int_t GetEntries() 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 
)

make a single vertex using tracks array

858{
860
861 EdbVertex *v = new EdbVertex();
862 v->SetXYZ( 0,0, zexpected );
863 int ntr = tracks.GetEntries();
864 for(int i=0; i<ntr; i++) {
865 EdbTrackP *t = (EdbTrackP*)tracks.At(i);
866 EdbVTA *vta = new EdbVTA(t,v);
867 vta->SetFlag(2);
868 v->AddVTA(vta);
869 (t->Z() >= v->Z())? vta->SetZpos(1) : vta->SetZpos(0);
870 t->AddVTA(vta);
871 }
872 if( MakeV(*v) ) AddVertex(v);
873 else { SafeDelete(v); return 0; } // vertex is not valid
874 return v;
875}
Float_t Z() const
Definition: EdbVertex.h:132
TTree * tracks
Definition: check_tr.C:19

◆ MakeV()

int EdbVertexRec::MakeV ( EdbVertex edbv,
bool  isRefit = false 
)

create new VtVertex and add tracks to this one
if isRefit - use input vertex position to improve the fit (default is false)

792{
795
796 if (ePVR) if (ePVR->IsA() != EdbPVRec::Class()) ePVR = 0;
797 if(!ePVR) {Log(1,"EdbVertexRec::MakeV","ERROR: EdbPVRec not defined, use SetPVRec(...)"); return 0;}
798
799 int n = edbv.N();
800 if (n<2) return 0;
801
802 if(isRefit) edbv.SetXYZ(edbv.VX(),edbv.VY(),edbv.VZ());
803 else EstimateVertexPosition(edbv);
804 edbv.ClearV();
805 Vertex *v = new Vertex();
808
809 float X0 = ePVR->GetScanCond()->RadX0();
810 if(!eUseMom) X0 = -1.; // ignore multiple scattering contribution if eUseMom is false
811
812 EdbSegP *seg=0;
813 for (int i=0; i<n; i++)
814 {
815 seg = edbv.GetTrackV(i,eUseSegPar);
816 Track *t = new Track();
817 //seg->PrintNice();
818 //printf("%f\n",edbv.Z());
819 edbv.Edb2Vt(*seg, *t, X0, edbv.GetTrack(i)->M());
820 v->add_track(*t);
821 }
822 if (!v->findVertexVt()) { Log(3,"MakeV","can not find VtVertex" ); return 0; }
823 if (!(v->valid())) { Log(3,"MakeV","VtVertex is not valid" ); return 0; }
824 edbv.SetV(v);
825 for(int i=0; i<n; i++)
826 {
827 edbv.GetVTa(i)->SetDist( edbv.VZ() - edbv.GetTrackV(i,eUseSegPar)->Z() );
828 edbv.GetVTa(i)->SetImp( distance(v->get_track(i),*v) );
829// printf("dist = %f imp = %f\n", edbv.GetVTa(i)->Dist(), edbv.GetVTa(i)->Imp() );
830// edbv.GetTrack(i)->PrintNice();
831 }
833 Log( 3,"EdbVertexRec::MakeV","impmax = %f",edbv.MaxImpact() );
834 return 1;
835}
brick X0
Definition: RecDispMC.C:112
EdbScanCond const * GetScanCond()
Definition: EdbPVRec.h:172
float RadX0() const
Definition: EdbScanCond.h:58
Float_t M() const
Definition: EdbPattern.h:155
void SetImp(float imp)
Definition: EdbVertex.h:57
void SetDist(float dist)
Definition: EdbVertex.h:58
Bool_t eUseKalman
use or not Kalman for the vertex fit. Default is true
Definition: EdbVertex.h:184
Bool_t EstimateVertexQuality(EdbVertex &v)
Definition: EdbVertex.cxx:729
Bool_t EstimateVertexPosition(EdbVertex &v)
Definition: EdbVertex.cxx:753
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:568
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
@ Track
Definition: tlg2couples.C:52
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 
)
2448{
2449// printf("Rearrange vertexies %d and %d\n",v1->ID(),v2->ID());
2450 *v1no = 0;
2451 *v2no = 0;
2452 if (!v1 || !v2) return 0.;
2453 if (v2->N() < 3) return 0.;
2454 if (it2max >= v2->N()) return 0.;
2455 EdbVertex *v1n = 0, *v2n = 0;
2456 EdbTrackP *tr2 = 0;
2457 int zpos = 0;
2458 double dx, dy, dz, dist1, dist2, imp, vchisum, vdistsum;
2459 tr2 = v2->GetTrack(it2max);
2460 dx = v1->VX() - tr2->TrackZmin()->X();
2461 dy = v1->VY() - tr2->TrackZmin()->Y();
2462 dz = v1->VZ() - tr2->TrackZmin()->Z();
2463 dist1 = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
2464 dx = v1->VX() - tr2->TrackZmax()->X();
2465 dy = v1->VY() - tr2->TrackZmax()->Y();
2466 dz = v1->VZ() - tr2->TrackZmax()->Z();
2467 dist2 = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
2468 if (dist2 < dist1)
2469 {
2470 zpos = 0;
2471 }
2472 else
2473 {
2474 zpos = 1;
2475 }
2476 imp = v1->DistTrack(tr2, zpos);
2477 if (imp > 1.2*eImpMax) return 0.;
2478 if ((v2n = RemoveTrackFromVertex(v2, it2max)))
2479 {
2480 *v2no = v2n;
2481 v1n = AddTrackToVertex(v1, tr2, zpos);
2482 if (!v1n)
2483 {
2484// CancelModifiedVTX(v2,v2n);
2485 return 0.;
2486 }
2487 *v1no = v1n;
2488 vchisum = v1n->V()->chi2() + v2n->V()->chi2();
2489 vdistsum = v1n->V()->rmsDistAngle() + v2n->V()->rmsDistAngle();
2490 if (seltype == 0)
2491 {
2492 return vdistsum;
2493 }
2494 else
2495 {
2496 return vchisum;
2497 }
2498 }
2499 return 0.;
2500}
EdbSegP * TrackZmax(bool usesegpar=false) const
Definition: EdbPattern.h:199
EdbSegP * TrackZmin(bool usesegpar=false) const
Definition: EdbPattern.h:198
EdbVertex * RemoveTrackFromVertex(EdbVertex *eVertex, int itr)
Definition: EdbVertex.cxx:2619
EdbVertex * AddTrackToVertex(EdbVertex *eVertex, EdbTrackP *eTr, int zpos)
Definition: EdbVertex.cxx:2521
Float_t DistTrack(EdbTrackP *tr, int zpos, float X0=0.)
Definition: EdbVertex.cxx:662
float chi2() const
$\chi^2$ of vertex fit
Definition: VtVertex.C:236

◆ Nvtx()

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

◆ ProbVertex2()

EdbVertex * EdbVertexRec::ProbVertex2 ( EdbTrackP tr1,
EdbTrackP tr2,
int  zpos1,
int  zpos2 
)

Check if 2 tracks can form the vertex. If yes - return the pointer to the new EdbVertex object

1304{
1306 Log(3,"EdbVertexRec::ProbVertex2", "try tracks %d and %d", tr1->ID(), tr2->ID() );
1307
1308 if(!tr1) return 0;
1309 if(!tr2) return 0;
1310 if(tr1==tr2) return 0;
1311 EdbSegP *s1 = tr1->TrackExtremity(zpos1,eUseSegPar);
1312 EdbSegP *s2 = tr2->TrackExtremity(zpos2,eUseSegPar);
1313//zpos2? tr2->TrackZmin(eUseSegPar):tr2->TrackZmax(eUseSegPar);
1314 if(!s1) return 0;
1315 if(!s2) return 0;
1316
1317 // check the dZ position agreement
1318 float dz = TMath::Abs(s2->Z()-s1->Z());
1319 if( dz > eDZmax ) return 0;
1320
1321 // check the dX dY position agreement
1322 int isign;
1323 float dtx,dty,deltaZ=0;
1324 if(zpos1!=zpos2) { // start-end, end-start
1325 deltaZ = (dz+eZbin);
1326 isign = -1;
1327 } else { // start-start, end-end
1328 deltaZ = (eDZmax-dz/2.);
1329 isign = +1;
1330 }
1331 dtx = TMath::Abs(s2->TX() - isign*s1->TX())+eAbin;
1332 if( TMath::Abs(s2->X()-s1->X()) > dtx*deltaZ ) return 0;
1333 dty = TMath::Abs(s2->TY() - isign*s1->TY())+eAbin;
1334 if( TMath::Abs(s2->Y()-s1->Y()) > dty*deltaZ ) return 0;
1335
1336 // check the impact
1337 float vestim[3];
1338 //float imp = CheckImpact( s1, s2, zpos1, zpos2, vestim );
1339 bool parallel;
1340 float imp = CheckImpactN( s1, s2, vestim, parallel, eDZmax );
1341 Log(3,"EdbVertexRec::ProbVertex2", "impact = %f", imp );
1342 if(imp>eImpMax) return 0;
1343
1344 // create the new EdbVertex
1345 EdbVertex *vtx = new EdbVertex();
1346 vtx->SetXYZ(vestim[0],vestim[1],vestim[2]);
1347
1348 EdbVTA *vta1 = new EdbVTA(tr1,vtx);
1349 vta1->SetZpos(zpos1);
1350 vta1->SetFlag(2);
1351 vtx->AddVTA(vta1);
1352
1353 EdbVTA *vta2 = new EdbVTA(tr2,vtx);
1354 vta2->SetZpos(zpos2);
1355 vta2->SetFlag(2);
1356 vtx->AddVTA(vta2);
1357
1358 if(MakeV(*vtx)) {
1359 vtx->SetFlag( EstimateVertexFlag(zpos1,zpos2) );
1360 //if(imp<eImpMaxV) // accept the vertex even if prob is small (parallel tracks)
1361 // return vtx;
1362 //else // do additional checks
1363 if( vtx->V()->prob() >= eProbMin ) {
1364 if( Log(3,"EdbVertexRec::ProbVertex2", "prob = %f", vtx->V()->prob()) ) vtx->Print();
1365 if( CheckDZ2( s1->Z(), s2->Z(), zpos1,zpos2, vtx->VZ() ) )
1366 return vtx;
1367 }
1368 }
1369 SafeDelete(vta1);
1370 SafeDelete(vta2);
1371 SafeDelete(vtx);
1372 return 0;
1373}
EdbSegP * TrackExtremity(bool zpos, bool usesegpar=false) const
Definition: EdbPattern.h:201
int EstimateVertexFlag(int zpos1, int zpos2)
Definition: EdbVertex.cxx:1376
Bool_t CheckDZ2(float z1, float z2, int zpos1, int zpos2, float z)
Definition: EdbVertex.cxx:1399
void Print()
Definition: EdbVertex.cxx:328

◆ ProbVertexN()

int EdbVertexRec::ProbVertexN ( )
1427{
1428 if(gEDBDEBUGLEVEL>1) printf("*** on entry to ProbVertexN: nv = %d\n", eVTX->GetEntries());
1429 ProbVertexNpos(0); // find n-track vtx attached to left edges
1430 if(gEDBDEBUGLEVEL>1) printf("*** npoz 0 ProbVertexN: nv = %d\n", eVTX->GetEntries());
1431 ProbVertexNpos(1); // to right edges
1432 if(gEDBDEBUGLEVEL>1) printf("*** npoz 1 ProbVertexN: nv = %d\n", eVTX->GetEntries());
1433
1434 CheckVTX(); // rank the vertices and reassign tracks according to the major rank
1435 if(gEDBDEBUGLEVEL>0) StatVertexN(); // print vertex statistics
1436 return 0;
1437}
Int_t ProbVertexNpos(int zpos)
Definition: EdbVertex.cxx:1440
void StatVertexN()
Definition: EdbVertex.cxx:1784
void CheckVTX()
Definition: EdbVertex.cxx:1498

◆ ProbVertexN_old()

int EdbVertexRec::ProbVertexN_old ( )

deprecated function (VT: 7/05/2008. Keeped for back-compatibility tests.
After the complete testing of the new ProbVertexN this function can be removed

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

◆ ProbVertexNpos()

int EdbVertexRec::ProbVertexNpos ( int  zpos)

cycle by all vertices, check if it is possible to join some of them by common track, do it

1441{
1443
1444 if (!eVTX) return 0;
1445 int nv2 = eVTX->GetEntries(); // number of vertices
1446 if(nv2<2) return 0;
1447
1448 Log(2,"EdbVertexRec::ProbVertexNpos","%d vertices as input",nv2);
1449
1450 // first group vertices with a common track
1451
1452 TMap maptr; //key is track, value is TObjArray of vertices
1453 TObjArray *arr=0;
1454 EdbVertex *vtx=0;
1455 EdbTrackP *t=0;
1456 for( int i=0; i<nv2; i++) {
1457 vtx = GetVertex(i);
1458 if(!vtx) Log(1,"EdbVertexRec::ProbVertexNpos","vertex not found!");
1459 for( int j=0; j<vtx->N(); j++) {
1460 t = vtx->GetTrack(j);
1461 if(!t) Log(1,"EdbVertexRec::ProbVertexNpos","track not found!");
1462 if(!(vtx->Zpos(j)==zpos)) continue;
1463 arr = (TObjArray*)maptr.GetValue(t);
1464 if(!arr) {
1465 arr = new TObjArray();
1466 maptr.Add(t,arr);
1467 }
1468 arr->Add(vtx);
1469 }
1470 }
1471
1472 TIter next(maptr.GetTable());
1473 TPair *a;
1474 while ((a = (TPair*) next())) { // cycle by all keys (tracks)
1475 t = (EdbTrackP*)a->Key();
1476 arr = (TObjArray*)a->Value();
1477 int nv = arr->GetEntries();
1478 //printf( "nv = %d\n", nv );
1479 if(nv<2) continue;
1480 TObjArray arrvta; // group of vta of tracks attached to t
1481 for(int iv=0; iv<nv; iv++) {
1482 vtx = (EdbVertex*)arr->At(iv);
1483 for(int it=0; it<vtx->N(); it++) { arrvta.Add(vtx->GetVTa(it)); }
1484 }
1485 EdbVertex *newvtx=TestVTAGroup(arrvta);
1486 if(newvtx) {
1487 Log(3,"EdbVertexRec::ProbVertexNpos","add new vtx with %d tracks and flag = %d\n",newvtx->N(),newvtx->Flag() );
1488 eVTX->Add(newvtx);
1489 }
1490 }
1491
1492 Log(2,"EdbVertexRec::ProbVertexNpos","%d entries in the map for zpos = %d",maptr.GetEntries(), zpos);
1493
1494 return 0;
1495}
void a()
Definition: check_aligned.C:59
EdbVertex * TestVTAGroup(TObjArray &arrvta)
Definition: EdbVertex.cxx:1540

◆ RefitAll()

int EdbVertexRec::RefitAll ( )

use already found vertex position to improve the fit

2504{
2506 int nv = eVTX->GetEntries();
2507 EdbVertex *vtx = 0;
2508 int cnt=0;
2509 for (int i=0; i<nv; i++) {
2510 vtx = GetVertex(i);
2511 if(vtx)
2512 if(vtx->Flag()>-1) {
2513 MakeV(*vtx,true);
2514 cnt++;
2515 }
2516 }
2517 return cnt;
2518}

◆ RejectPolish()

void EdbVertexRec::RejectPolish ( )
2189{
2191}
void CancelModifiedVTX(EdbVertex *eVertex, EdbVertex *eWorking)
Definition: EdbVertex.cxx:2726

◆ RemoveTrackFromVertex()

EdbVertex * EdbVertexRec::RemoveTrackFromVertex ( EdbVertex eVertex,
int  itr 
)
2620{
2621 if (!eVertex)
2622 {
2623
2624 printf("No working vertex selected!\n");
2625 fflush(stdout);
2626 return 0;
2627 }
2628 EdbVTA *vta = 0;
2629 EdbVertex *eWorking = 0; // is a bug?? redeclaration of a member; noted VT:25/08/2011
2630 int n = 0;
2631 int ntr = 0;
2632 if (eWorking == 0)
2633 {
2634 ntr = eVertex->N();
2635 if (ntr < 3)
2636 {
2637
2638 printf("Working vertex has 2 prongs only!\n");
2639 fflush(stdout);
2640 return 0;
2641 }
2642 eWorking = new EdbVertex();
2643 int i = 0;
2644 for(i=0; i<ntr; i++)
2645 {
2646 if (i == itr)
2647 {
2648 (eVertex->GetTrack(i))->ClearVTA(eVertex->GetVTa(i));
2649 continue;
2650 }
2651 if ((vta = AddTrack( *eWorking, eVertex->GetTrack(i), eVertex->Zpos(i))))
2652 {
2653 (eWorking->GetTrack(n))->AddVTA(vta);
2654 n++;
2655 }
2656 }
2657 }
2658 if ((n < 2)||(n == ntr))
2659 {
2660 printf("Can't create working copy of the vertex!\n");
2661 fflush(stdout);
2662 SafeDelete(eWorking);
2664 return 0;
2665 }
2666
2667 if (MakeV(*eWorking))
2668 {
2669 EdbVertex *eW = eWorking;
2670 eW->ResetTracks();
2671 eW->SetID(eVertex->ID());
2672 }
2673 else
2674 {
2675 printf("Can't create working copy of the vertex!\n");
2676 fflush(stdout);
2677 SafeDelete(eWorking);
2679 return 0;
2680 }
2681 return eWorking;
2682}

◆ RemoveVTAFromVertex()

EdbVertex * EdbVertexRec::RemoveVTAFromVertex ( EdbVertex vtx,
EdbVTA vta 
)
2603{
2604 int ntr = v.N();
2605 TObjArray tracks;
2606 for(int i=0; i<ntr; i++) {
2607 if( v.GetVTa(i) != &vta ) tracks.Add( v.GetVTa(i)->GetTrack() );
2608 }
2609 EdbVertex *vnew = Make1Vertex( tracks, v.Z() );
2610
2611 int nn = v.Nn();
2612 for(int i=0; i<nn; i++) {
2613 vnew->AddVTA( v.GetVTn(i) );
2614 }
2615 return vnew;
2616}
EdbVertex * Make1Vertex(TObjArray &tracks, float zexpected)
Definition: EdbVertex.cxx:857

◆ Reset()

void EdbVertexRec::Reset ( )
723{
724 SafeDelete(eVTX);
725 eVTA.Clear("nodelete");
726}

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

◆ SelSegNeighbor()

int EdbVertexRec::SelSegNeighbor ( EdbSegP s,
int  seltype,
float  RadMax,
int  Dpat,
TObjArray *  ao 
)
1906{
1907 EdbSegP ss; // the virtual "vertex" segment
1908
1909 if (!sin) return 0;
1910
1911 ss.SetX(sin->X());
1912 ss.SetY(sin->Y());
1913 ss.SetZ(sin->Z());
1914 ss.SetTX(sin->TX());
1915 ss.SetTY(sin->TY());
1916 ss.SetErrors(RadMax*RadMax, RadMax*RadMax, 0., 0., 0., 0.);
1917
1918 TObjArray arr(1000);
1919
1920 ePVR->FindComplimentsVol(ss,arr,1,1,Dpat);
1921
1922 int nseg = arr.GetEntries();
1923 EdbTrackP *tr = 0;
1924 EdbSegP *s = 0;
1925 int trflg = 0;
1926 int trind = 0;
1927 int ntr = 0;
1928 if (eEdbTracks) ntr = eEdbTracks->GetEntries();
1929
1930 int nadd = 0;
1931 for (int i=0; i<nseg; i++)
1932 {
1933 s = (EdbSegP *)(arr.At(i));
1934 if (!s) continue;
1935 tr = 0;
1936 trind = s->Track();
1937 trflg = 0;
1938 if ( trind >= 0 && trind < ntr)
1939 {
1940 if ((tr = (EdbTrackP *)eEdbTracks->At(trind)))
1941 {
1942 trflg = tr->Flag();
1943 if (trflg != -10 && seltype == 0 && tr->MCEvt() >= -999)
1944 {
1945// if (!(ao->FindObject(tr)))
1946// {
1947 if (ao)
1948 {
1949 tr->SetMC(-tr->MCEvt()-2000, tr->MCTrack());
1950 ao->Add(tr);
1951 }
1952 nadd++;
1953// }
1954 continue;
1955 }
1956 }
1957 }
1958 if((trind < 0 || trflg == -10)&&(seltype == 1))
1959 {
1960 if (ao) ao->Add(s);
1961 nadd++;
1962 }
1963 }
1964
1965 if (seltype == 0)
1966 {
1967 nseg = ao->GetEntries();
1968 for (int i=0; i<nseg; i++)
1969 {
1970 tr = (EdbTrackP *)(ao->At(i));
1971 if (tr && (tr->MCEvt() < -999)) tr->SetMC( -tr->MCEvt()-2000, tr->MCTrack());
1972 }
1973 }
1974
1975 return nadd;
1976}
int FindComplimentsVol(EdbSegP &s, TObjArray &arr, float nsig, float nsigt, int dpat)
Definition: EdbPattern.cxx:1938

◆ SelVertNeighbor()

int EdbVertexRec::SelVertNeighbor ( EdbVertex v,
int  seltype,
float  RadMax,
int  Dpat,
TObjArray *  ao 
)
1830{
1831 EdbSegP ss; // the virtual "vertex" segment
1832
1833 if (!v) return 0;
1834
1835 float x = v->VX();
1836 float y = v->VY();
1837 float z = v->VZ();
1838
1839 ss.SetX(x);
1840 ss.SetY(y);
1841 ss.SetZ(z);
1842 ss.SetTX(0.);
1843 ss.SetTY(0.);
1844 ss.SetErrors(RadMax*RadMax, RadMax*RadMax, 0., 0., 0., 0.);
1845
1846 TObjArray arr(20);
1847 ePVR->FindComplimentsVol(ss,arr,1,1,Dpat);
1848
1849 int nseg = arr.GetEntries();
1850 EdbTrackP *tr = 0;
1851 EdbSegP *s = 0;
1852 int trflg = 0;
1853 int trind = 0;
1854 int ntr = eEdbTracks->GetEntries();
1855
1856 int nadd = 0;
1857 for (int i=0; i<nseg; i++)
1858 {
1859 s = (EdbSegP *)(arr.At(i));
1860 if (!s) continue;
1861 tr = 0;
1862 trind = s->Track();
1863 trflg = 0;
1864 if ( trind >= 0 && trind < ntr)
1865 {
1866 if ((tr = (EdbTrackP *)eEdbTracks->At(trind)))
1867 {
1868 trflg = tr->Flag();
1869 if (trflg != -10 && seltype == 0 && tr->MCEvt() >= -999)
1870 {
1871// if (!(ao->FindObject(tr)))
1872// {
1873 if (ao)
1874 {
1875 tr->SetMC(-tr->MCEvt()-2000, tr->MCTrack());
1876 ao->Add(tr);
1877 }
1878 nadd++;
1879// }
1880 continue;
1881 }
1882 }
1883 }
1884 if((trind < 0 || trflg == -10)&&(seltype == 1))
1885 {
1886 if (ao) ao->Add(s);
1887 nadd++;
1888 }
1889 }
1890
1891 if (seltype == 0)
1892 {
1893 nseg = ao->GetEntries();
1894 for (int i=0; i<nseg; i++)
1895 {
1896 tr = (EdbTrackP *)(ao->At(i));
1897 if (tr && (tr->MCEvt() < -999)) tr->SetMC( -tr->MCEvt()-2000, tr->MCTrack());
1898 }
1899 }
1900
1901 return nadd;
1902}

◆ Set0()

void EdbVertexRec::Set0 ( )
702{
703 eEdbTracks = 0;
704 eVTX = 0;
705 ePVR = 0;
706 eVertex = 0;
707 eWorking = 0;
708 (gROOT->GetListOfSpecials())->Add(this); // To check if this can cause memory leak!
709}

◆ SetPVRec()

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

◆ StatVertexN()

void EdbVertexRec::StatVertexN ( )
1785{
1786 Int_t nvt = Nvtx();
1787 if (!nvt) return;
1788 TArrayI navtx(10);
1789 EdbVertex *v=0;
1790 Int_t ntv = 0;
1791 for (Int_t i = 0; i < nvt; i++) {
1792 v = GetVertex(i);
1793 if (!v || v->Flag() < 0) continue;
1794 ntv = v->N();
1795 if (ntv > 11) ntv = 11;
1796 navtx[ntv-2]++;
1797 }
1798 for (ntv = 0; ntv < 10; ntv++) {
1799 if (ntv < 9)
1800 printf("%5d vertexes with number of tracks = %2d was found\n",
1801 navtx[ntv], ntv+2);
1802 else
1803 printf("%5d vertexes with number of tracks >= %2d was found\n",
1804 navtx[ntv], ntv+2);
1805 }
1806}

◆ StripBadTracks()

EdbVertex * EdbVertexRec::StripBadTracks ( EdbVertex v,
float  impMax,
int  ntrMin 
)
839{
840 EdbVertex *v = &vtx;
841 int ntr0 = v->N();
842 int ntr = v->N();
843 while( v && ntr>ntrMin && v->MaxImpact()>impMax )
844 {
845 Log(2,"EdbVertexRec::StripBadTracks"," ntr = %d maximp = %f", ntr,v->MaxImpact() );
846 EdbVTA *vta = v->GetMaxImpVTA();
847 v = RemoveVTAFromVertex( *v, *vta );
848 vta->SetFlag(0); v->AddVTA(vta); // add it as VTn
849 ntr = v->N();
850 }
851
852 Log(2,"EdbVertexRec::StripBadTracks"," %d -> %d + %d maximp = %f", ntr0, v->N(), v->Nn() ,v->MaxImpact() );
853 return v;
854}
EdbVertex * RemoveVTAFromVertex(EdbVertex &vtx, EdbVTA &vta)
Definition: EdbVertex.cxx:2602
EdbVTA * GetMaxImpVTA()
Definition: EdbVertex.cxx:140

◆ Tdistance() [1/2]

double EdbVertexRec::Tdistance ( const EdbSegP s1,
const EdbSegP s2 
)
3204{
3205 EdbVertex edbv;
3206 Track t1,t2;
3207 edbv.Edb2Vt(s1,t1);
3208 edbv.Edb2Vt(s2,t2);
3209 return Tdistance(t1,t2);
3210}

◆ Tdistance() [2/2]

double EdbVertexRec::Tdistance ( const VERTEX::Track t1,
const VERTEX::Track t2 
)

geometrical distance between 2 track lines in the space XYZ

3181 {
3185 const double a = t1.tx();
3186 const double b = t1.ty();
3187 const double c = 1.;
3188 const double a1 = t2.tx();
3189 const double b1 = t2.ty();
3190 const double c1 = 1.;
3191
3192 const double det = square(a*b1 - b*a1) + square(b*c1 - c*b1) + square(c*a1 - a*c1);
3193 const SVector<double,3> dx = t2.xvec() - t1.xvec();
3194 // are tracks parallel?
3195 if(det==0) return mag(cross(dx,t1.evec()));
3196
3197 const double det2 = dx[0]*(b*c1 - c*b1) + dx[1]*(c*a1 - a*c1) + dx[2]*(a*b1 - b*a1);
3198
3199 return fabs(det2/sqrt(det));
3200}
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 
)
3225{
3226 EdbVertex edbv;
3227 Track t1,t2;
3228 float X0 = ePVR->GetScanCond()->RadX0();
3229 edbv.Edb2Vt(s1,t1,X0,m);
3230 edbv.Edb2Vt(s2,t2,X0,m);
3231 return distanceChi2(t1,t2);
3232}
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 
)
3214{
3215 EdbVertex edbv;
3216 Track t1,t2;
3217 float X0 = ePVR->GetScanCond()->RadX0();
3218 edbv.Edb2Vt(tr1,t1,X0,tr1.M());
3219 edbv.Edb2Vt(tr2,t2,X0,tr2.M());
3220 return distanceChi2(t1,t2);
3221}

◆ TestVTAGroup()

EdbVertex * EdbVertexRec::TestVTAGroup ( TObjArray &  arrvta)

Try to create N-prong vertex from vta's group
Input: array of preselected vta's
return the new vertex if successful

1541{
1545
1546 int nvta=arrvta.GetEntries();
1547 Log(3,"EdbVertexRec::TestVTAGroup","nvta = %d\n",nvta);
1548
1549 EdbVTA *vta=0, *newvta=0;
1550 EdbVertex *newvtx = new EdbVertex();
1551 for(int i=0; i<nvta; i++) {
1552 vta = (EdbVTA*)arrvta.At(i);
1553 if( newvtx->TrackInVertex(vta->GetTrack()) ) continue;
1554 newvta = new EdbVTA(vta->GetTrack(),newvtx);
1555 newvta->SetZpos(vta->Zpos());
1556 newvta->SetFlag(2);
1557 newvtx->AddVTA(newvta);
1558 }
1559
1560 if(MakeV(*newvtx))
1561 if( newvtx->V() )
1562 if( newvtx->V()->valid() ) {
1563 //printf("prob = %f\n", newvtx->V()->prob() );
1564 if( newvtx->V()->prob() >= eProbMin ) // accept new N-tracks vertex
1565 {
1566 for(int i=0; i<nvta; i++) {
1567 if( ((EdbVTA*)arrvta.At(i))->GetVertex() != newvtx )
1568 ((EdbVTA*)arrvta.At(i))->GetVertex()->SetFlag(-10);
1569 }
1570 //printf("accepted!\n");
1571 return newvtx;
1572 }
1573 }
1574 SafeDelete(newvtx); // discard new vertex
1575 return 0;
1576}
EdbTrackP * GetTrack() const
Definition: EdbVertex.h:51
Int_t Zpos() const
Definition: EdbVertex.h:47

◆ VertexNeighbor() [1/2]

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

◆ VertexNeighbor() [2/2]

int EdbVertexRec::VertexNeighbor ( float  RadMax = 1000.,
int  Dpat = 1,
float  ImpMax = 1000000. 
)
2733{
2734 //if(!ePVR) ePVR = ((EdbPVRec *)(gROOT->GetListOfSpecials()->FindObject("EdbPVRec")));
2735 if (ePVR) if (ePVR->IsA() != EdbPVRec::Class()) ePVR = 0;
2736 if(!ePVR) {printf("Warning: EdbVertexRec::VertexNeighbor: EdbPVRec not defined, use SetPVRec(...)\n"); return 0;}
2737
2738 int nn = 0, iv = 0;
2739// int i = 0, nntr = 0;
2740 int nvt = 0;
2741 int ntr = 0;
2742 if (eVTX) nvt = eVTX->GetEntries();
2743 if (eEdbTracks) ntr = eEdbTracks->GetEntries();
2744 if (!nvt) return 0;
2745 if (!ntr) return 0;
2746
2747 EdbVertex *v = 0;
2748
2749 for (iv=0; iv<nvt; iv++) {
2750 v = GetVertex(iv);
2751 if (v)
2752 {
2753 nn += VertexNeighbor(v, RadMax, Dpat, ImpMax);
2754// nntr = v->Nn();
2755// for(i=0; i<nntr; i++) AddVTA(v->GetVTn(i));
2756 }
2757 }
2758
2759 return nn;
2760}
Int_t VertexNeighbor(float RadMax=1000., int Dpat=1, float ImpMax=1000000.)
Definition: EdbVertex.cxx:2732

◆ 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 
)
2110{
2111 if (refill) if (!VertexNeighbor(v, RadMax, Dpat, ImpMax)) return 0;
2112
2113 EdbVTA *vta = 0;
2114 EdbTrackP *tn = 0;
2115 EdbSegP *sn = 0;
2116 EdbVertex *w = 0;
2117
2118 int nt = v->N();
2119 int nn = v->Nn();
2120 int naddtot = 0, nmod = 0;
2121 int news = 0;
2122 if (nn)
2123 {
2124 // first of all try to propagate existing tracks with new momentum
2125 double p = Mom;
2126 int nadd = 0;
2127 for(int i=0; i<nt; i++)
2128 {
2129 nadd = 0;
2130 tn = v->GetTrack(i);
2131 for (int ip=0; ip<2; ip++)
2132 {
2133 p = Mom/(ip+1);
2134 tn->SetErrorP(0.2*0.2*p*p);
2135 tn->SetP(p);
2136 if (v->Zpos(i)) nadd += ePVR->PropagateTrack( *tn, true, 0.01, 3, 0 );
2137 else nadd += ePVR->PropagateTrack( *tn, false, 0.01, 3, 0 );
2138 }
2139 if (nadd) nmod++;
2140 naddtot += nadd;
2141 }
2142
2143 // then attach single segments with small impact to the vertex
2144 eVertex = v;
2145 for(int i=0; i<nn; i++)
2146 {
2147 vta = eVertex->GetVTn(i);
2148 if (vta->Flag() == 1) // neighbour segment
2149 {
2150 sn = (EdbSegP *)vta->GetTrack();
2151 news += AddSegmentToVertex(sn, ImpMax, ProbMin, Mom);
2152 }
2153 }
2154 w = eVertex;
2155 if (eWorking != 0) w = eWorking;
2156 nt = w->N();
2157 p = Mom;
2158 nadd = 0;
2159 // then try to propagate one-segment tracks with new momentum
2160 for(int i=0; i<nt; i++)
2161 {
2162 nadd = 0;
2163 tn = w->GetTrack(i);
2164 if (tn->N() > 1) continue;
2165 for (int ip=0; ip<2; ip++)
2166 {
2167 p = Mom/(ip+1);
2168 tn->SetErrorP(0.2*0.2*p*p);
2169 tn->SetP(p);
2170 if (w->Zpos(i)) nadd += ePVR->PropagateTrack( *tn, true, 0.01, 3, 0 );
2171 else nadd += ePVR->PropagateTrack( *tn, false, 0.01, 3, 0 );
2172 }
2173 if (nadd) nmod++;
2174 naddtot += nadd;
2175 }
2176 }
2177 printf("%d single segments are attached, %d tracks are propagated (total %d segments are added).\n",
2178 news, nmod, naddtot);
2179 fflush(stdout);
2180 return (news+nmod);
2181}
int PropagateTrack(EdbTrackP &tr, bool followZ, float probMin=0.05, int ngapMax=3, int design=0)
Definition: EdbPVRec.cxx:2569
void SetErrorP(float sp2)
Definition: EdbSegP.h:94
Int_t N() const
Definition: EdbPattern.h:177
Int_t AddSegmentToVertex(EdbSegP *s, float ImpMax=25., float ProbMin=0.01, float Mom=0.3)
Definition: EdbVertex.cxx:1978
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)
2194{
2195 //if(!ePVR) ePVR = ((EdbPVRec *)(gROOT->GetListOfSpecials()->FindObject("EdbPVRec")));
2196 if (ePVR) if (ePVR->IsA() != EdbPVRec::Class()) ePVR = 0;
2197 if(!ePVR) {printf("Warning: EdbVertexRec::VertexNeighbor: EdbPVRec not defined, use SetPVRec(...)\n"); return 0;}
2198
2199 int iv = 0, nntr = 0, nn = 0;
2200 int nvt = 0;
2201 int ntr = 0;
2202 if (eEdbTracks) ntr = eEdbTracks->GetEntries();
2203 if (!ntr) return 0;
2204 if (eVTX) nvt = eVTX->GetEntries();
2205 if (!nvt) return 0;
2206
2207 EdbVertex *v1 = 0, *v2 = 0;
2208 EdbVertex *v1n = 0, *v2n = 0;
2209 EdbVTA *vta = 0;
2210 EdbTrackP *tr1 = 0, *tr2 = 0;
2211 int ntr1 = 0, ntr2 = 0, was = 0;
2212 double impa1[50] = {0.}, chia1[50] = {0.}, imp1max = 0., chi1max = 0.;
2213 double impa2[50] = {0.}, chia2[50] = {0.}, imp2max = 0., chi2max = 0.;
2214 double cri1max = 0., cri2max = 0.;
2215 int it1impmax = -1, it1chimax = -1, it1max = -1;
2216 int it2impmax = -1, it2chimax = -1, it2max = -1;
2217 double vchisumorig = 0., vdistsumorig = 0.;
2218 double v1chiorig = 0., v1distorig = 0.;
2219 double v2chiorig = 0., v2distorig = 0., crit = 0., critorig = 0.;
2220
2221 for (iv=0; iv<nvt; iv++) { // loop on all vertexes
2222 v1 = GetVertex(iv);
2223 if (v1)
2224 {
2225 if (v1->Flag() < 0) continue;
2226 if ((!(v1->V()))) continue;
2227 ntr1 = v1->N();
2228 imp1max = -1.;
2229 chi1max = -1.;
2230 it1max = -1;
2231 for(int it1=0; it1<v1->N() && it1<50; it1++)
2232 {
2233 tr1 = v1->GetTrack(it1);
2234 impa1[it1] = v1->ImpTrack(it1);
2235 if (impa1[it1] > imp1max)
2236 {
2237 imp1max = impa1[it1];
2238 it1impmax = it1;
2239 }
2240 chia1[it1] = v1->Chi2Track(tr1, v1->Zpos(it1), 0.);
2241 if (chia1[it1] > chi1max)
2242 {
2243 chi1max = chia1[it1];
2244 it1chimax = it1;
2245 }
2246 }
2247 if (seltype == 0)
2248 {
2249 it1max = it1impmax;
2250 }
2251 else
2252 {
2253 it1max = it1chimax;
2254 }
2255 nntr = v1->Nn();
2256 v1chiorig = v1->V()->chi2();
2257 v1distorig = v1->V()->rmsDistAngle();
2258 if (nntr)
2259 {
2260 for(int i=0; i<nntr; i++)
2261 {
2262 vta = v1->GetVTn(i);
2263 if (vta->Flag() == 0) // neighbour track
2264 {
2265// EdbTrackP *tn = vta->GetTrack();
2266 }
2267 else if (vta->Flag() == 1) // neighbour segment
2268 {
2269// EdbSegP *sn = (EdbSegP *)vta->GetTrack();
2270 }
2271 else if (vta->Flag() == 3) // neighbour vertex
2272 {
2273 v2 = (EdbVertex *)vta->GetTrack();
2274 if ((!v2) || v2->Flag() == -10) continue;
2275 if ((!(v2->V()))) continue;
2276 ntr2 = v2->N();
2277 v2chiorig = v2->V()->chi2();
2278 v2distorig = v2->V()->rmsDistAngle();
2279 vchisumorig = v1chiorig + v2chiorig;
2280 vdistsumorig = v1distorig + v2distorig;
2281 if (seltype == 0)
2282 {
2283 critorig = vdistsumorig;
2284 }
2285 else
2286 {
2287 critorig = vchisumorig;
2288 }
2289 was = 0;
2290 if (ntr1==2 && ntr2>2)
2291 {
2292 imp2max = 0.;
2293 chi2max = 0.;
2294 it2max = -1;
2295 for(int it2=0; it2<ntr2 && it2<50; it2++)
2296 {
2297 tr2 = v2->GetTrack(it2);
2298 impa2[it2] = v2->ImpTrack(it2);
2299 if (impa2[it2] > imp2max)
2300 {
2301 imp2max = impa2[it2];
2302 it2impmax = it2;
2303 }
2304 chia2[it2] = v2->Chi2Track(tr2, v2->Zpos(it2), 0.);
2305 if (chia2[it2] > chi2max)
2306 {
2307 chi2max = chia2[it2];
2308 it2chimax = it2;
2309 }
2310 }
2311 if (seltype == 0)
2312 {
2313 it2max = it2impmax;
2314 }
2315 else
2316 {
2317 it2max = it2chimax;
2318 }
2319 if (it2max < 0) continue;
2320 if (v2->GetConnectedVertexForTrack(it2max)==v1) continue;
2321 crit = MoveTrackToOtherVertex(v2, it2max, v1, seltype, &v2n, &v1n);
2322 was = 1;
2323 }
2324 else if (ntr1>2 && ntr2==2)
2325 {
2326 imp1max = 0.;
2327 chi1max = 0.;
2328 it1max = -1;
2329 for(int it1=0; it1<ntr1 && it1<50; it1++)
2330 {
2331 tr1 = v1->GetTrack(it1);
2332 impa1[it1] = v1->ImpTrack(it1);
2333 if (impa1[it1] > imp1max)
2334 {
2335 imp1max = impa1[it1];
2336 it1impmax = it1;
2337 }
2338 chia1[it1] = v1->Chi2Track(tr1, v1->Zpos(it1), 0.);
2339 if (chia1[it1] > chi1max)
2340 {
2341 chi1max = chia1[it1];
2342 it1chimax = it1;
2343 }
2344 }
2345 if (seltype == 0)
2346 {
2347 it1max = it1impmax;
2348 }
2349 else
2350 {
2351 it1max = it1chimax;
2352 }
2353 if (it1max < 0) continue;
2354 if (v1->GetConnectedVertexForTrack(it1max)==v2) continue;
2355 crit = MoveTrackToOtherVertex(v1, it1max, v2, seltype, &v2n, &v1n);
2356 was = 1;
2357 }
2358 else if (ntr1>2 && ntr2>2)
2359 {
2360 imp2max = 0.;
2361 chi2max = 0.;
2362 it2max = -1;
2363 for(int it2=0; it2<ntr2 && it2<50; it2++)
2364 {
2365 tr2 = v2->GetTrack(it2);
2366 impa2[it2] = v2->ImpTrack(it2);
2367 if (impa2[it2] > imp2max)
2368 {
2369 imp2max = impa2[it2];
2370 it2impmax = it2;
2371 }
2372 chia2[it2] = v2->Chi2Track(tr2, v2->Zpos(it2), 0.);
2373 if (chia2[it2] > chi2max)
2374 {
2375 chi2max = chia2[it2];
2376 it2chimax = it2;
2377 }
2378 }
2379 if (seltype == 0)
2380 {
2381 it2max = it2impmax;
2382 cri1max = imp1max;
2383 cri2max = imp2max;
2384 }
2385 else
2386 {
2387 it2max = it2chimax;
2388 cri1max = chi1max;
2389 cri2max = chi2max;
2390 }
2391 if (it1max < 0) continue;
2392 if (it2max < 0) continue;
2393 if (cri2max > cri1max)
2394 {
2395 if (v2->GetConnectedVertexForTrack(it2max)==v1) continue;
2396 crit = MoveTrackToOtherVertex(v2, it2max, v1, seltype, &v2n, &v1n);
2397 was = 1;
2398 }
2399 else
2400 {
2401 if (v1->GetConnectedVertexForTrack(it1max)==v2) continue;
2402 crit = MoveTrackToOtherVertex(v1, it1max, v2, seltype, &v2n, &v1n);
2403 was = 1;
2404 } // variants of changing
2405 } // multiplicities
2406 if (was)
2407 {
2408 if ((crit < critorig) && v1n && v2n)
2409 {
2410 AcceptModifiedVTX(v1,v1n);
2411 AcceptModifiedVTX(v2,v2n);
2412 v1 = v1n;
2413 v2 = v2n;
2414 if (v2->Flag() > -11) v2->SetFlag(-v2->Flag()-11);
2415 nn++;
2416 //break;
2417 }
2418 else
2419 {
2420 CancelModifiedVTX(v1,v1n);
2421 CancelModifiedVTX(v2,v2n);
2422 }
2423 }
2424 } // neighbor vertex
2425 } // loop on neighbor
2426 } // neighbor exist
2427 } // good v1
2428 } // loop on vertexes
2429
2430 nvt = eVTX->GetEntries();
2431
2432 for (iv=0; iv<nvt; iv++) {
2433 v1 = GetVertex(iv);
2434 if (v1)
2435 {
2436 if (v1->Flag()<-10)
2437 {
2438 v1->SetFlag(-v1->Flag()-11);
2439 }
2440 }
2441 }
2442
2443 return nn;
2444}
Double_t MoveTrackToOtherVertex(EdbVertex *v2, int it2max, EdbVertex *v1, int seltype, EdbVertex **v2n, EdbVertex **v1n)
Definition: EdbVertex.cxx:2446
Float_t Chi2Track(EdbTrackP *tr, int zpos, float X0=0.)
Definition: EdbVertex.cxx:635
EdbVertex * GetConnectedVertexForTrack(int it)
Definition: EdbVertex.cxx:384
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

patterns volume (optional)

◆ eVertex

EdbVertex* EdbVertexRec::eVertex
private

◆ eVTA

TList EdbVertexRec::eVTA

vertex-track associations

◆ eVTX

TObjArray* EdbVertexRec::eVTX

array of vertex

◆ eWorking

EdbVertex* EdbVertexRec::eWorking
private

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