ATLAS Offline Software
PixelRIO_OnTrackErrorScaling.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
6 
8  "PixPhi Barrel",
9  "PixEta Barrel",
10  "PixPhi Endcap",
11  "PixEta Endcap",
12  "PixPhi IBL",
13  "PixEta IBL"
14  };
15 
16 namespace {
17  inline double square(double a) { return a*a; }
18 
19  void scale2by2( Amg::MatrixX& cov,
20  const std::vector<double>& phiTrafo,
21  const std::vector<double>& etaTrafo)
22  {
23  // careful not to change character of error
24  double corr = (std::abs(cov(0,1)) > 1.0e-20)
25  ? cov(0,1)/(cov(0,0)*cov(1,1))
26  : 0.0;
27  cov(0,0) *= square(phiTrafo[0]);
28  cov(0,0) += square(phiTrafo[1]);
29  cov(1,1) *= square(etaTrafo[0]);
30  cov(1,1) += square(etaTrafo[1]);
31  if (corr !=0.0) {
32  cov(0,1) = corr*cov(0,0)*cov(1,1);
33  cov(1,0) = cov(0,1);
34  }
35  }
36 }
37 
40 }
41 
43  if (params().size() != kPixIBLPhi && params().size() != kNParamTypes ) {
44  std::stringstream message;
45  message << " PixelRIO_OnTrackErrorScaling: Expecting parameters for";
46  {
47  unsigned int idx=0;
48  for (; idx < kPixIBLPhi; ++idx) {
49  message << " " << s_names[idx];
50  }
51  message << "(" << kPixIBLPhi << ")" << " and ";
52  for (; idx < kNParamTypes; ++idx) {
53  message << " " << s_names[idx];
54  }
55  message << "(" << kNParamTypes << ") for run2.";
56  }
57  message << " But got " << params().size() << ".";
58  throw std::runtime_error( message.str() );
59  }
60  for (unsigned int idx=0; idx <params().size(); ++idx) {
61  if (params()[idx].size()!=2 ) {
62  assert( idx < kNParamTypes);
63  std::stringstream message;
64  message << " PixelRIO_OnTrackErrorScaling: Expected 2 parameters for " << s_names[idx] << " but got " << params()[idx].size()
65  << ".";
66  throw std::runtime_error( message.str() );
67  }
68  }
69  return true;
70 }
71 
73  const PixelID &pixel_id,
74  const Identifier& id) const
75 {
76 
77  Amg::MatrixX newCov = std::move(cov_input);
78 
79  // from SiDetectorElement::isEndcap
80  bool is_endcap = !(pixel_id.is_barrel(id) || pixel_id.is_dbm(id));
81  unsigned int idx=kNParamTypes;
82 
83  if (is_endcap) {
85  } else {
86 
87  // from PixelDigitizationTool::getReadoutTech
88  int barrel_ec = pixel_id.barrel_ec(id);
89  bool is_ibl = abs(barrel_ec)==4 || pixel_id.eta_module_max(id)>6;
90  if (is_ibl) {
91  idx = kPixIBLPhi;
92  }
93  else {
95  }
96  }
97 
98  // checked in postprocess
99  assert(params().size() > idx + 1);
100  assert(params()[idx].size() > 1 && params()[idx + 1].size() > 1);
101 
102  scale2by2(newCov,params()[idx] /* phi */ ,params()[idx+1] /* eta */);
103  return newCov;
104 }
105 
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:29
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
PixelRIO_OnTrackErrorScaling::clid
virtual CLID clid() const override final
Definition: PixelRIO_OnTrackErrorScaling.cxx:38
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
PixelRIO_OnTrackErrorScaling::postProcess
virtual bool postProcess() override final
Definition: PixelRIO_OnTrackErrorScaling.cxx:42
ReweightUtils.message
message
Definition: ReweightUtils.py:15
PixelID::eta_module_max
int eta_module_max(const Identifier &id) const
Definition: PixelID.cxx:79
PixelRIO_OnTrackErrorScaling::kPixIBLPhi
@ kPixIBLPhi
Definition: PixelRIO_OnTrackErrorScaling.h:27
PixelRIO_OnTrackErrorScaling::s_names
static const char *const s_names[kNParamTypes]
Definition: PixelRIO_OnTrackErrorScaling.h:37
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
PixelID::is_barrel
bool is_barrel(const Identifier &id) const
Test for barrel - WARNING: id MUST be pixel id, otherwise answer is not accurate. Use SiliconID for g...
Definition: PixelID.h:605
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
PixelRIO_OnTrackErrorScaling::kNParamTypes
@ kNParamTypes
Definition: PixelRIO_OnTrackErrorScaling.h:29
PixelRIO_OnTrackErrorScaling::kPixEndcapPhi
@ kPixEndcapPhi
Definition: PixelRIO_OnTrackErrorScaling.h:25
PixelID::is_dbm
bool is_dbm(const Identifier &id) const
Test for dbm - WARNING: id MUST be pixel id, otherwise answer is not accurate. Use SiliconID for gene...
Definition: PixelID.h:612
a
TList * a
Definition: liststreamerinfos.cxx:10
PixelRIO_OnTrackErrorScaling.h
PixelRIO_OnTrackErrorScaling::kPixBarrelPhi
@ kPixBarrelPhi
Definition: PixelRIO_OnTrackErrorScaling.h:23
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
RIO_OnTrackErrorScaling::params
std::vector< std::vector< double > > & params()
Definition: RIO_OnTrackErrorScaling.h:29
PixelID
Definition: PixelID.h:67
PixelRIO_OnTrackErrorScaling::getScaledCovariance
Amg::MatrixX getScaledCovariance(Amg::MatrixX &&cov_input, const PixelID &pixel_id, const Identifier &id) const
Definition: PixelRIO_OnTrackErrorScaling.cxx:72