FEDRA emulsion software from the OPERA Collaboration
ShowRecCalculatingFunctions.cpp File Reference
This graph shows which files directly or indirectly include this file:

Functions

Double_t CalcIP (EdbSegP *s, double x, double y, double z)
 
Double_t CalcIP (EdbSegP *s, EdbVertex *v)
 
EdbVertexCalcVertex (TObjArray *segments)
 
void FillShowerAxis ()
 
Double_t GetDistToAxis (EdbSegP *segAxis, EdbSegP *segTest)
 
Double_t GetMinimumDist (EdbSegP *seg1, EdbSegP *seg2)
 
Bool_t IsSameSegment (EdbSegP *seg1, EdbSegP *seg2)
 

Function Documentation

◆ CalcIP() [1/2]

Double_t CalcIP ( EdbSegP s,
double  x,
double  y,
double  z 
)
112  {
113  // Calculate IP between a given segment and a given x,y,z.
114  // return the IP value.
115  double ax = s->TX();
116  double ay = s->TY();
117  double bx = s->X()-ax*s->Z();
118  double by = s->Y()-ay*s->Z();
119  double a;
120  double r;
121  double xx,yy,zz;
122  a = (ax*(x-bx)+ay*(y-by)+1.*(z-0.))/(ax*ax+ay*ay+1.);
123  xx = bx +ax*a;
124  yy = by +ay*a;
125  zz = 0. +1.*a;
126  r = sqrt((xx-x)*(xx-x)+(yy-y)*(yy-y)+(zz-z)*(zz-z));
127  return r;
128 }
void a()
Definition: check_aligned.C:59
Float_t TX() const
Definition: EdbSegP.h:172
Float_t X() const
Definition: EdbSegP.h:170
Float_t Z() const
Definition: EdbSegP.h:150
Float_t Y() const
Definition: EdbSegP.h:171
Float_t TY() const
Definition: EdbSegP.h:173
void r(int rid=2)
Definition: test.C:201
EdbSegP * s
Definition: tlg2pattern.C:32

◆ CalcIP() [2/2]

Double_t CalcIP ( EdbSegP s,
EdbVertex v 
)
98  {
99  // calculate IP for the selected tracks wrt the given vertex.
100  // if the vertex is not given, use the selected vertex.
101  if (NULL==v) {
102  printf("select a vertex!\n");
103  return 0;
104  }
105  if (gEDBDEBUGLEVEL>3) printf(" /// Calc IP w.r.t. Vertex %d %8.1lf %8.1lf %8.1lf (red vertex) ///\n",v->ID(), v->X(),v->Y(),v->Z() );
106  double r = CalcIP(s,v->X(),v->Y(),v->Z());
107  return r;
108 }
Double_t CalcIP(EdbSegP *s, EdbVertex *v)
Definition: ShowRecCalculatingFunctions.cpp:98
Int_t ID() const
Definition: EdbVertex.h:126
Float_t X() const
Definition: EdbVertex.h:130
Float_t Z() const
Definition: EdbVertex.h:132
Float_t Y() const
Definition: EdbVertex.h:131
gEDBDEBUGLEVEL
Definition: energy.C:7
#define NULL
Definition: nidaqmx.h:84

◆ CalcVertex()

EdbVertex* CalcVertex ( TObjArray *  segments)
3  {
4 
5  // Exactly same implementation as in EdbEDAUtil.C
6  // but I do not want to link in hardcoded all eda libraries.
7  // calc vertex point with given segments. just topological calculation.
8  // VTA is currently not set.
9  // in case of Single-stop. make a vertex 650 micron upstream ob base.
10  double xx,yy,zz,Det,Ax,Ay,Az,Bx,By,Bz,Cx,Cy,Cz,Dx,Dy,Dz;
11  Ax=0.;
12  Ay=0.;
13  Az=0.;
14  Bx=0.;
15  By=0.;
16  Bz=0.;
17  Cx=0.;
18  Cy=0.;
19  Cz=0.;
20  Dx=0.;
21  Dy=0.;
22  Dz=0.;
23 
24  if (segments->GetEntries()==1) {
25  // in case of Single-stop. make a vertex 650 micron upstream ob base.
26  EdbSegP *s = new EdbSegP(*((EdbSegP *) segments->At(0)));
27  s->PropagateTo(s->Z()-650);
28  xx=s->X();
29  yy=s->Y();
30  zz=s->Z();
31  delete s;
32  }
33  else {
34  for (int i=0; i<segments->GetEntries(); i++) {
35  EdbSegP *s = (EdbSegP *) segments->At(i);
36  double ax = s->TX();
37  double ay = s->TY();
38  double az = 1.0;
39  double x = s->X();
40  double y = s->Y();
41  double z = s->Z();
42  double a = ax*ax+ay*ay+az*az;
43  double c = -ax*x-ay*y-az*z;
44  double b = (ax*ax+ay*ay);
45  // double w = 1.0/a/a; // weight for small angle tracks.
46  double w = 1.0; // no weight
47 
48  Ax+=2.0*w/b*( a*(ay*ay+az*az) );
49  Bx+=2.0*w/b*( -a*ax*ay );
50  Cx+=2.0*w/b*( -a*ax*az );
51  Dx+=2.0*w/b*( -(a*x+c*ax)*(ax*ax-a)-(a*y+c*ay)*ax*ay-(a*z+c*az)*az*ax );
52 
53  Ay+=2.0*w/b*( -a*ay*ax );
54  By+=2.0*w/b*( a*(az*az+ax*ax) );
55  Cy+=2.0*w/b*( -a*ay*az );
56  Dy+=2.0*w/b*( -(a*y+c*ay)*(ay*ay-a)-(a*z+c*az)*ay*az-(a*x+c*ax)*ax*ay );
57 
58  Az+=2.0*w/b*( -a*az*ax );
59  Bz+=2.0*w/b*( -a*az*ay );
60  Cz+=2.0*w/b*( a*b );
61  Dz+=2.0*w/b*( -(a*z+c*az)*(az*az-a)-(a*x+c*ax)*az*ax-(a*y+c*ay)*ay*az );
62 
63  }
64 
65  Det=fabs( Ax*(By*Cz-Cy*Bz)-Bx*(Ay*Cz-Cy*Az)+Cx*(Ay*Bz-By*Az) );
66  xx=( (By*Cz-Cy*Bz)*Dx-(Bx*Cz-Cx*Bz)*Dy+(Bx*Cy-Cx*By)*Dz)/Det;
67  yy=(-(Ay*Cz-Cy*Az)*Dx+(Ax*Cz-Cx*Az)*Dy-(Ax*Cy-Cx*Ay)*Dz)/Det;
68  zz=( (Ay*Bz-By*Az)*Dx-(Ax*Bz-Bx*Az)*Dy+(Ax*By-Bx*Ay)*Dz)/Det;
69  }
70 
71  EdbVertex *v = new EdbVertex();
72  v->SetXYZ(xx,yy,zz);
73 
74  return v;
75 }
Expr< UnaryOp< Fabs< T >, Expr< A, T, D >, T >, T, D > fabs(const Expr< A, T, D > &rhs)
Definition: UnaryOperators.hh:96
Definition: EdbSegP.h:18
void PropagateTo(float z)
Definition: EdbSegP.cxx:292
Definition: EdbVertex.h:68
void SetXYZ(float x, float y, float z)
Definition: EdbVertex.h:157
void w(int rid=2, int nviews=2)
Definition: test.C:27

◆ FillShowerAxis()

void FillShowerAxis ( )
132  {
133  cout << "IMPLEMENTED IN ... TransferShowerObjectArrayIntoEntryOfTreebranchShowerTree ... CHECK THERE..."<<endl;
134  return;
135 }

◆ GetDistToAxis()

Double_t GetDistToAxis ( EdbSegP segAxis,
EdbSegP segTest 
)
185  {
186 
187 // cout << "GetDistToAxis(EdbSegP* segAxis,EdbSegP* segTest)" << endl;
188  // Calculates distance of the segTest to the Axis defined by the segAxis segment.
189  // Uses code from EdbMath, thats why it cannot simply be put in the EdbSegP class code.
190  float Point[3];
191  float LineStart[3];
192  float LineEnd[3];
193 
194 // cout << "segTest->PrintNice();" << endl;
195 // segTest->PrintNice();
196 
197  Point[0]=segTest->X();
198  Point[1]=segTest->Y();
199  Point[2]=segTest->Z();
200 
201  LineStart[0]=segAxis->X();
202  LineStart[1]=segAxis->Y();
203  LineStart[2]=segAxis->Z();
204 
205 // cout << "segAxis->PrintNice();" << endl;
206 // segAxis->PrintNice();
207 
208 // cout << "Propagate segment Z + 10000" << endl;
209  segAxis->PropagateTo(segAxis->Z()+10000);
210 // segAxis->PrintNice();
211  LineEnd[0]=segAxis->X();
212  LineEnd[1]=segAxis->Y();
213  LineEnd[2]=segAxis->Z();
214 
215 // cout << "Propagate segment Z - 10000" << endl;
216  segAxis->PropagateTo(segAxis->Z()-10000);
217 // segAxis->PrintNice();
218 
219  double dist = EdbMath::DistancePointLine3(Point, LineStart, LineEnd, 1);
220 // cout << dist << endl;
221 
222 // segAxis->PrintNice();
223 
224 // cout << "TO CHECK .... IF SEG IS PROPAGATET, IS IT THEN MODIFIED ? IF SO PROPAGATE IT BACK AGAIN, OR COPY THE SEGMENT FIRST ...." << endl;
225  return dist;
226 }
static double DistancePointLine3(float Point[3], float LineStart[3], float LineEnd[3], bool inside)
Definition: EdbMath.cxx:61

◆ GetMinimumDist()

Double_t GetMinimumDist ( EdbSegP seg1,
EdbSegP seg2 
)
140  {
141  // calculate minimum distance of 2 lines.
142  // use the data of (the selected object)->X(), Y(), Z(), TX(), TY().
143  // means, if the selected object == segment, use the data of the segment. or it == track, the use the fitted data.
144  // original code from Tomoko Ariga
145  // double calc_dmin(EdbSegP *seg1, EdbSegP *seg2, double *dminz = NULL){
146 
147  double x1,y1,z1,ax1,ay1;
148  double x2,y2,z2,ax2,ay2;
149  double s1,s2,s1bunsi,s1bunbo,s2bunsi,s2bunbo;
150  double p1x,p1y,p1z,p2x,p2y,p2z,p1p2;
151 
152  if (seg1->ID()==seg2->ID()&&seg1->PID()==seg2->PID()) return 0.0;
153 
154  x1 = seg1->X();
155  y1 = seg1->Y();
156  z1 = seg1->Z();
157  ax1= seg1->TX();
158  ay1= seg1->TY();
159 
160  x2 = seg2->X();
161  y2 = seg2->Y();
162  z2 = seg2->Z();
163  ax2= seg2->TX();
164  ay2= seg2->TY();
165 
166  s1bunsi=(ax2*ax2+ay2*ay2+1)*(ax1*(x2-x1)+ay1*(y2-y1)+z2-z1) - (ax1*ax2+ay1*ay2+1)*(ax2*(x2-x1)+ay2*(y2-y1)+z2-z1);
167  s1bunbo=(ax1*ax1+ay1*ay1+1)*(ax2*ax2+ay2*ay2+1) - (ax1*ax2+ay1*ay2+1)*(ax1*ax2+ay1*ay2+1);
168  s2bunsi=(ax1*ax2+ay1*ay2+1)*(ax1*(x2-x1)+ay1*(y2-y1)+z2-z1) - (ax1*ax1+ay1*ay1+1)*(ax2*(x2-x1)+ay2*(y2-y1)+z2-z1);
169  s2bunbo=(ax1*ax1+ay1*ay1+1)*(ax2*ax2+ay2*ay2+1) - (ax1*ax2+ay1*ay2+1)*(ax1*ax2+ay1*ay2+1);
170  s1=s1bunsi/s1bunbo;
171  s2=s2bunsi/s2bunbo;
172  p1x=x1+s1*ax1;
173  p1y=y1+s1*ay1;
174  p1z=z1+s1*1;
175  p2x=x2+s2*ax2;
176  p2y=y2+s2*ay2;
177  p2z=z2+s2*1;
178  p1p2=sqrt( (p1x-p2x)*(p1x-p2x)+(p1y-p2y)*(p1y-p2y)+(p1z-p2z)*(p1z-p2z) );
179 
180  return p1p2;
181 }
Int_t ID() const
Definition: EdbSegP.h:144
Int_t PID() const
Definition: EdbSegP.h:145
EdbSegP * s1
Definition: tlg2pattern.C:30
EdbSegP * s2
Definition: tlg2pattern.C:31

◆ IsSameSegment()

Bool_t IsSameSegment ( EdbSegP seg1,
EdbSegP seg2 
)
79  {
80  // This function checks on absolute values rather
81  // on adress of segments.
82  // This might be safer when dealing with copies
83  // of SegP objects in memory.
84  if (TMath::Abs(seg1->X()-seg2->X())<0.01) {
85  if (TMath::Abs(seg1->Y()-seg2->Y())<0.01) {
86  if (TMath::Abs(seg1->TY()-seg2->TY())<0.01) {
87  if (TMath::Abs(seg1->TX()-seg2->TX())<0.01) {
88  return kTRUE;
89  }
90  }
91  }
92  }
93  return kFALSE;
94 }