ATLAS Offline Software
AlignmentBarrelLUT.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "AlignmentBarrelLUT.h"
6 #include<fstream>
7 #include "TMath.h"
9 
10 // --------------------------------------------------------------------------------
11 // --------------------------------------------------------------------------------
12 
14  const std::string& name,
15  const IInterface* parent):
17 {
18 }
19 
20 // --------------------------------------------------------------------------------
21 // --------------------------------------------------------------------------------
22 
23 StatusCode TrigL2MuonSA::AlignmentBarrelLUT::readLUT(const std::string& lut_fileName)
24 {
25 
26  int saddress, innerR;
27  int N0, N1, N2;
28  double A0, A1, A2;
29  std::ifstream file;
30 
31 
32  for(int i_saddress=0; i_saddress<s_saddress; i_saddress++) {
33  for(int i_innerR=0; i_innerR<s_innerR; i_innerR++) {
34  m_NbinEta[i_saddress][i_innerR]=0;
35  m_EtaMin[i_saddress][i_innerR]=0;
36  m_EtaMax[i_saddress][i_innerR]=0;
37  m_EtaStep[i_saddress][i_innerR]=0;
38  m_NbinPhi[i_saddress][i_innerR]=0;
39  m_PhiMin[i_saddress][i_innerR]=0;
40  m_PhiMax[i_saddress][i_innerR]=0;
41  m_PhiStep[i_saddress][i_innerR]=0;
42 
43  for(int i_eta=0; i_eta<s_eta; i_eta++) {
44  for(int i_phi=0; i_phi<s_phi; i_phi++) {
45  for(int i_etaQ=0; i_etaQ<s_etaQ; i_etaQ++) {
46  m_dZ[i_saddress][i_innerR][i_eta][i_phi][i_etaQ] = 0;
47  }
48  }
49  }
50  }
51  }
52 
53  file.open(lut_fileName.c_str());
54  if (!file) {
55  ATH_MSG_INFO("Failed to open barrel alignment LUT file");
56  return StatusCode::FAILURE;
57  }
58 
59  for(int i_lut=0; i_lut<2; i_lut++) {
60 
61  file >> saddress >> innerR;
62  file >> m_EtaMin[saddress][innerR] >> m_EtaMax[saddress][innerR]
63  >> m_PhiMin[saddress][innerR] >> m_PhiMax[saddress][innerR]
64  >> m_NbinEta[saddress][innerR] >> m_NbinPhi[saddress][innerR];
65 
66  m_EtaStep[saddress][innerR] = (m_EtaMax[saddress][innerR] - m_EtaMin[saddress][innerR]) / (float)m_NbinEta[saddress][innerR];
67  m_PhiStep[saddress][innerR] = (m_PhiMax[saddress][innerR] - m_PhiMin[saddress][innerR]) / (float)m_NbinPhi[saddress][innerR];
68 
69  for (int i_eta=0; i_eta<s_eta; i_eta++) {
70  for (int i_phi=0; i_phi<s_phi; i_phi++) {
71  for (int i_etaQ=0; i_etaQ<s_etaQ; i_etaQ++) {
72 
73  file >> N0 >> N1 >> N2 >> A0 >> A1 >> A2;
74 
75  m_dZ[saddress][innerR][i_eta][i_phi][i_etaQ] = A0;
76 
77  } // etaQ loop
78  } // phi loop
79  } // eta loop
80  } // nlut loop
81 
82  file.close();
83  return StatusCode::SUCCESS;
84 }
85 
86 // --------------------------------------------------------------------------------
87 // --------------------------------------------------------------------------------
88 
90  double& etaMap,
91  double& phiMap,
92  double& MFphi,
93  float& sp1R) const
94 {
95  if (saddress == 1) {
96 
97  int innerR = (sp1R > 5800)? 1: 0;
98 
99  std::pair<int, int> bins = GetBinNumber(saddress, innerR, etaMap, phiMap);
100  int iEta = bins.first;
101  int iPhi = bins.second;
102 
103  int iChamber=( std::abs(MFphi)>90*TMath::DegToRad() ) ? 1:0;
104 
105  int iEta_inv=29-iEta;
106  int iPhi_inv=29-iPhi;
107 
108  int iEta_bin=iEta;
109  int iPhi_bin=iPhi;
110 
111  if( iEta<15 ){
112  if( iChamber == 0 ){
113  //do nothing
114  }else{
115  iPhi_bin=iPhi_inv;
116  }
117  }else{
118  if( iChamber == 0 ){
119  iEta_bin=iEta_inv;
120  }else{
121  iEta_bin=iEta_inv;
122  iPhi_bin=iPhi_inv;
123  }
124  }
125 
126  int sign_etam=(iEta>14)?-1:1;
127  int sign_etap=-sign_etam;
128 
129  return (m_dZ[saddress][innerR][iEta_bin][iPhi_bin][0]*sign_etam
130  + m_dZ[saddress][innerR][iEta_bin][iPhi_bin][1]*sign_etap) / 2.;
131 
132  } else {
133  ATH_MSG_INFO("Barrel alignment is implemented only for Large-SP");
134  return 0;
135  }
136 
137 }
138 
139 // --------------------------------------------------------------------------------
140 // --------------------------------------------------------------------------------
141 
142 std::pair<int, int> TrigL2MuonSA::AlignmentBarrelLUT::GetBinNumber(int saddress, int innerR, double etaMap, double phiMap) const
143 {
144 
145  if(saddress > 3 || saddress < 0 || innerR < 0 || innerR > 1) return std::make_pair(-5,-5);
146 
147  int etaBin = (int)((etaMap - m_EtaMin[saddress][innerR])/m_EtaStep[saddress][innerR]);
148  int phiBin = (int)((phiMap - m_PhiMin[saddress][innerR])/m_PhiStep[saddress][innerR]);
149 
150  if(etaBin <= -1) etaBin = 0;
151  if(etaBin >= m_NbinEta[saddress][innerR]) etaBin = m_NbinEta[saddress][innerR] - 1;
152 
153  if(phiBin <= -1) phiBin = 0;
154  if(phiBin >= m_NbinPhi[saddress][innerR]) phiBin = m_NbinPhi[saddress][innerR] - 1;
155 
156  return std::make_pair(etaBin,phiBin);
157 }
dqt_zlumi_pandas.N2
N2
Definition: dqt_zlumi_pandas.py:325
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
AthMsgStreamMacros.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TrigL2MuonSA::AlignmentBarrelLUT::AlignmentBarrelLUT
AlignmentBarrelLUT(const std::string &type, const std::string &name, const IInterface *parent)
Definition: AlignmentBarrelLUT.cxx:13
TrigL2MuonSA::AlignmentBarrelLUT::readLUT
StatusCode readLUT(const std::string &lut_fileName)
Definition: AlignmentBarrelLUT.cxx:23
TrigL2MuonSA::AlignmentBarrelLUT::GetBinNumber
std::pair< int, int > GetBinNumber(int saddress, int innerR, double etaMap, double phiMap) const
Definition: AlignmentBarrelLUT.cxx:142
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::etaMap
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner etaMap
Definition: L2StandAloneMuon_v1.cxx:144
file
TFile * file
Definition: tile_monitor.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
dqt_zlumi_pandas.N1
int N1
Definition: dqt_zlumi_pandas.py:322
plotting.yearwise_luminosity_vs_mu.bins
bins
Definition: yearwise_luminosity_vs_mu.py:30
AlignmentBarrelLUT.h
xAOD::phiMap
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius phiMap
Definition: L2StandAloneMuon_v2.cxx:140
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::phiBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setPhiMap phiBin
Definition: L2StandAloneMuon_v2.cxx:144
Trk::iPhi
@ iPhi
Definition: ParamDefs.h:47
TrigL2MuonSA::AlignmentBarrelLUT::GetDeltaZ
double GetDeltaZ(int &saddress, double &etaMap, double &phiMap, double &MFphi, float &sp1R) const
Definition: AlignmentBarrelLUT.cxx:89
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthAlgTool
Definition: AthAlgTool.h:26
xAOD::iEta
setScale setgFexType iEta
Definition: gFexJetRoI_v1.cxx:77