ATLAS Offline Software
TrigInDetTrackFitParCnv_p2.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_p2 :: 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  TrigInDetTrackFitPar *transObj,
122  MsgStream& log )
123 {
124 
125  log << MSG::DEBUG << "TrigInDetTrackFitParCnv_p2::persToTrans" << endmsg;
126 
127  //restore param errors from the cov matrix
128  std::unique_ptr<std::vector<double> > cov (restoreCovariance(persObj));
129 
130  double ea0 = -999;
131  double ephi0 = -999;
132  double ez0 = -999;
133  double eeta = -999;
134  double epT = -999;
135  if (cov) {
136  ea0 = sqrt((*cov)[0]);
137  ephi0 = sqrt((*cov)[5]);
138  ez0 = sqrt((*cov)[9]);
139  eeta = sqrt((*cov)[12]);
140  epT = sqrt((*cov)[14]);
141  }
142 
143  *transObj = TrigInDetTrackFitPar (persObj->m_a0,
144  persObj->m_phi0,
145  persObj->m_z0,
146  persObj->m_eta,
147  persObj->m_pT,
148  ea0, ephi0, ez0, eeta, epT,
150  persObj->m_surfaceCoordinate,
151  cov.release());
152 }
153 
155  TrigInDetTrackFitPar_p2 *persObj,
156  MsgStream& log )
157 {
158 
159  log << MSG::DEBUG << "TrigInDetTrackFitParCnv_p2::transToPers" << endmsg;
160 
161  persObj->m_a0 = transObj->a0() ;
162  persObj->m_phi0 = transObj->phi0() ;
163  persObj->m_z0 = transObj->z0() ;
164  persObj->m_eta = transObj->eta() ;
165  persObj->m_pT = transObj->pT() ;
166 
167  calculateSquareRoot(transObj,persObj);
168 
169  persObj->m_surfaceType = transObj->surfaceType();
170  persObj->m_surfaceCoordinate = transObj->surfaceCoordinate();
171 }
TrigInDetTrackFitPar_p2::m_phi0
double m_phi0
Definition: TrigInDetTrackFitPar_p2.h:40
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
TrigInDetTrackFitPar::surfaceCoordinate
void surfaceCoordinate(double c)
Setter: surface reference coordinate for non-perigee surfaces.
Definition: TrigInDetTrackFitPar.h:227
TrigInDetTrackFitPar_p2::m_eta
double m_eta
Definition: TrigInDetTrackFitPar_p2.h:42
TrigInDetTrackFitPar
Definition: TrigInDetTrackFitPar.h:67
TrigInDetTrackFitParCnv_p2::transToPers
virtual void transToPers(const TrigInDetTrackFitPar *transObj, TrigInDetTrackFitPar_p2 *persObj, MsgStream &log)
Definition: TrigInDetTrackFitParCnv_p2.cxx:154
DMTest::C
C_v1 C
Definition: C.h:26
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
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
TrigInDetTrackFitPar_p2::m_cov
float m_cov[15]
Definition: TrigInDetTrackFitPar_p2.h:44
TrigInDetTrackFitPar_p2
Definition: TrigInDetTrackFitPar_p2.h:22
TrigInDetTrackFitPar_p2::m_a0
double m_a0
Definition: TrigInDetTrackFitPar_p2.h:39
TrigInDetTrackFitParCnv_p2::persToTrans
virtual void persToTrans(const TrigInDetTrackFitPar_p2 *persObj, TrigInDetTrackFitPar *transObj, MsgStream &log)
Definition: TrigInDetTrackFitParCnv_p2.cxx:120
TrigInDetTrackFitPar_p2::m_surfaceCoordinate
double m_surfaceCoordinate
Definition: TrigInDetTrackFitPar_p2.h:46
TrigInDetTrackFitPar_p2::m_pT
double m_pT
Definition: TrigInDetTrackFitPar_p2.h:43
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
lumiFormat.i
int i
Definition: lumiFormat.py:92
TrigInDetTrackFitPar::TrigSurfaceType
TrigSurfaceType
Definition: TrigInDetTrackFitPar.h:71
TrigInDetTrackFitPar_p2::m_surfaceType
int m_surfaceType
Definition: TrigInDetTrackFitPar_p2.h:45
TrigInDetTrackFitPar::surfaceType
void surfaceType(TrigSurfaceType s)
Setter: surface type PERIGEE=0, BARREL=1, ENDCAP=2.
Definition: TrigInDetTrackFitPar.h:225
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TrigInDetTrackFitParCnv_p2.h
TrigInDetTrackFitPar_p2::m_z0
double m_z0
Definition: TrigInDetTrackFitPar_p2.h:41
TrigInDetTrackFitPar.h
SignEnum::LT
@ LT
Definition: SignEnums.h:17
TrigInDetTrackFitParCnv_p2::CholeskyDecomposition
bool CholeskyDecomposition(double a[5][5], float L[5][5])
Definition: TrigInDetTrackFitParCnv_p2.cxx:86
TrigInDetTrackFitParCnv_p2::calculateSquareRoot
bool calculateSquareRoot(const TrigInDetTrackFitPar *, TrigInDetTrackFitPar_p2 *)
Definition: TrigInDetTrackFitParCnv_p2.cxx:11
TrigInDetTrackFitParCnv_p2::restoreCovariance
std::unique_ptr< std::vector< double > > restoreCovariance(const TrigInDetTrackFitPar_p2 *)
Definition: TrigInDetTrackFitParCnv_p2.cxx:49
TrigInDetTrackFitPar::a0
void a0(const double a0)
Setter: transverse impact parameter.
Definition: TrigInDetTrackFitPar.h:213
a
TList * a
Definition: liststreamerinfos.cxx:10
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
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
fitman.k
k
Definition: fitman.py:528