ATLAS Offline Software
TrigInDetTrackFitParCnv_p3.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <cstring>
8 using std::memset;
9 
10 
12 {
13  int i{0},j{0},idx{0};
14  double a[5][5];
15  float L[5][5];
16 
17  if((p->cov()==0)||(p->cov()->size()==0))
18  {
19  memset(&pP->m_cov[0],0,sizeof(pP->m_cov));
20  pP->m_cov[0]=-999.0;
21  pP->m_cov[2]=-999.0;
22  pP->m_cov[5]=-999.0;
23  pP->m_cov[9]=-999.0;
24  pP->m_cov[14]=-999.0;
25  return false;
26  }
27 
28  for(i=0;i<5;i++)
29  for(j=i;j<5;j++) a[i][j]=a[j][i]=(*p->cov())[idx++];
30 
32  {
33  idx=0;
34  for(i=0;i<5;i++) for(j=0;j<=i;j++) pP->m_cov[idx++]=L[i][j];
35  }
36  else
37  {
38  memset(&pP->m_cov[0],0,sizeof(pP->m_cov));
39  pP->m_cov[0] =(float)sqrt( (*p->cov())[0] > 0 ? (*p->cov())[0] : 0 );
40  pP->m_cov[2] =(float)sqrt( (*p->cov())[5] > 0 ? (*p->cov())[5] : 0 );
41  pP->m_cov[5] =(float)sqrt( (*p->cov())[9] > 0 ? (*p->cov())[9] : 0 );
42  pP->m_cov[9] =(float)sqrt( (*p->cov())[12] > 0 ? (*p->cov())[12] : 0 );
43  pP->m_cov[14]=(float)sqrt( (*p->cov())[14] > 0 ? (*p->cov())[14] : 0 );
44  }
45  return true;
46 }
47 
48 std::unique_ptr<std::vector<double> >
50 {
51 
52  int i{0},j{0},k{0},idx{0};
53  float L[5][5], LT[5][5];
54  if(pP->m_cov[0]<0.0)
55  {
56  return nullptr;
57  }
58 
59  memset(&L[0][0],0,sizeof(L));memset(&LT[0][0],0,sizeof(LT));
60 
61  for(i=0;i<5;i++) for(j=0;j<=i;j++)
62  {
63  L[i][j]=LT[j][i]=pP->m_cov[idx++];
64  }
65 
66  auto pV = std::make_unique<std::vector<double> >();
67 
68  for(i=0;i<5;i++)
69 
70  for(j=i;j<5;j++)
71  {
72  // Note: use extended (long double) precision here.
73  // That happens implicitly on x86 with optimization on; saying it
74  // explicitly ensures that we get the same results with and without
75  // optimization. (If this is a performance issue for platforms
76  // other than x86, one could change to double for those platforms.)
77  long double C=0.0;
78  for(k=0;k<5;k++)
79  C+=(long double)L[i][k]*LT[k][j];
80  pV->push_back(C);
81  }
82 
83  return pV;
84 }
85 
86 bool TrigInDetTrackFitParCnv_p3 :: CholeskyDecomposition(double a[5][5], float L[5][5])
87 {
88 
89  int i{0},j{0},k{0};
90  double sum{0};
91  float p[5];
92 
93  for(i=0;i<5;i++)
94  {
95  for(j=i;j<5;j++)
96  {
97  sum=a[i][j];
98  for(k=i-1;k>=0;k--)
99  sum-=a[i][k]*a[j][k];
100  if(i==j)
101  {
102  if(sum<=0.0)
103  {
104  return false;
105  }
106  p[i]=sqrt(sum);L[i][i]=p[i];
107  }
108  else
109  {
110  a[j][i]=sum/p[i];
111  L[j][i]=a[j][i];
112  }
113  }
114  }
115  return true;
116 }
117 
118 
119 
121 ) {
122 
123  // log << MSG::DEBUG << "TrigInDetTrackFitParCnv_p3::persToTrans" << endmsg;
124 
125  std::unique_ptr<std::vector<double> > cov (restoreCovariance(persObj));
126 
127  double ea0 = -999;
128  double ephi0 = -999;
129  double ez0 = -999;
130  double eeta = -999;
131  double epT = -999;
132  if (cov) {
133  ea0 = sqrt((*cov)[0]);
134  ephi0 = sqrt((*cov)[5]);
135  ez0 = sqrt((*cov)[9]);
136  eeta = sqrt((*cov)[12]);
137  epT = sqrt((*cov)[14]);
138  }
139 
140  *transObj = TrigInDetTrackFitPar (persObj->m_allDoubles[0], // a0
141  persObj->m_allDoubles[1], // phi0
142  persObj->m_allDoubles[2], // z0
143  persObj->m_allDoubles[3], // eta
144  persObj->m_allDoubles[4], // pT
145  ea0, ephi0, ez0, eeta, epT,
147  persObj->m_allDoubles[5], // surfaceCoordinate
148  cov.release());
149 }
150 
151 
152 
154 ) {
155 
156  // log << MSG::DEBUG << "TrigInDetTrackFitParCnv_p3::transToPers" << endmsg;
157 
158 
159  persObj->m_allDoubles[0] = transObj->a0() ;
160  persObj->m_allDoubles[1] = transObj->phi0() ;
161  persObj->m_allDoubles[2] = transObj->z0() ;
162  persObj->m_allDoubles[3] = transObj->eta() ;
163  persObj->m_allDoubles[4] = transObj->pT() ;
164  persObj->m_allDoubles[5] = transObj->surfaceCoordinate();
165 
166  calculateSquareRoot(transObj,persObj);
167  persObj->m_surfaceType = transObj->surfaceType();
168 }
TrigInDetTrackFitPar::surfaceCoordinate
void surfaceCoordinate(double c)
Setter: surface reference coordinate for non-perigee surfaces.
Definition: TrigInDetTrackFitPar.h:227
TrigInDetTrackFitPar
Definition: TrigInDetTrackFitPar.h:67
DMTest::C
C_v1 C
Definition: C.h:26
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
TrigInDetTrackFitParCnv_p3::persToTrans
virtual void persToTrans(const TrigInDetTrackFitPar_p3 *persObj, TrigInDetTrackFitPar *transObj, MsgStream &log)
Definition: TrigInDetTrackFitParCnv_p3.cxx:120
TrigInDetTrackFitPar::eta
void eta(const double eta)
Setter: pseudorapidity.
Definition: TrigInDetTrackFitPar.h:219
TrigInDetTrackFitPar::z0
void z0(const double z0)
Setter: longitudinal impact parameter.
Definition: TrigInDetTrackFitPar.h:215
TrigInDetTrackFitParCnv_p3.h
TrigInDetTrackFitParCnv_p3::restoreCovariance
std::unique_ptr< std::vector< double > > restoreCovariance(const TrigInDetTrackFitPar_p3 *)
Definition: TrigInDetTrackFitParCnv_p3.cxx:49
TrigInDetTrackFitPar_p3::m_allDoubles
double m_allDoubles[6]
Definition: TrigInDetTrackFitPar_p3.h:41
TrigInDetTrackFitPar_p3
Definition: TrigInDetTrackFitPar_p3.h:20
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigInDetTrackFitPar::TrigSurfaceType
TrigSurfaceType
Definition: TrigInDetTrackFitPar.h:71
TrigInDetTrackFitPar::surfaceType
void surfaceType(TrigSurfaceType s)
Setter: surface type PERIGEE=0, BARREL=1, ENDCAP=2.
Definition: TrigInDetTrackFitPar.h:225
TrigInDetTrackFitPar.h
TrigInDetTrackFitPar_p3::m_surfaceType
int m_surfaceType
Definition: TrigInDetTrackFitPar_p3.h:43
SignEnum::LT
@ LT
Definition: SignEnums.h:17
TrigInDetTrackFitParCnv_p3::CholeskyDecomposition
bool CholeskyDecomposition(double a[5][5], float L[5][5])
Definition: TrigInDetTrackFitParCnv_p3.cxx:86
TrigInDetTrackFitPar::a0
void a0(const double a0)
Setter: transverse impact parameter.
Definition: TrigInDetTrackFitPar.h:213
TrigInDetTrackFitParCnv_p3::transToPers
virtual void transToPers(const TrigInDetTrackFitPar *transObj, TrigInDetTrackFitPar_p3 *persObj, MsgStream &log)
Definition: TrigInDetTrackFitParCnv_p3.cxx:153
a
TList * a
Definition: liststreamerinfos.cxx:10
TrigInDetTrackFitPar_p3::m_cov
float m_cov[15]
Definition: TrigInDetTrackFitPar_p3.h:42
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TrigInDetTrackFitPar::phi0
void phi0(const double phi0)
Setter: azimuthal angle of the momentum.
Definition: TrigInDetTrackFitPar.h:217
readCCLHist.float
float
Definition: readCCLHist.py:83
TrigInDetTrackFitPar::pT
void pT(const double pT)
Setter: transverse momentum.
Definition: TrigInDetTrackFitPar.h:221
TrigInDetTrackFitParCnv_p3::calculateSquareRoot
bool calculateSquareRoot(const TrigInDetTrackFitPar *, TrigInDetTrackFitPar_p3 *)
Definition: TrigInDetTrackFitParCnv_p3.cxx:11
fitman.k
k
Definition: fitman.py:528