ATLAS Offline Software
PtFromRadius.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 "PtFromRadius.h"
6 
7 #include "TMath.h"
8 
10 
11 // --------------------------------------------------------------------------------
12 // --------------------------------------------------------------------------------
13 
15  const std::string& name,
16  const IInterface* parent):
18 {
19 }
20 
21 // --------------------------------------------------------------------------------
22 // --------------------------------------------------------------------------------
23 
24 void TrigL2MuonSA::PtFromRadius::setMCFlag(const BooleanProperty& use_mcLUT,
25  const TrigL2MuonSA::PtBarrelLUTSvc* ptBarrelLUTSvc)
26 {
27  m_use_mcLUT = use_mcLUT;
28  m_ptBarrelLUT = ptBarrelLUTSvc->ptBarrelLUT();
29 }
30 
31 // --------------------------------------------------------------------------------
32 // --------------------------------------------------------------------------------
33 
35 {
36  const double ZERO_LIMIT = 1e-5;
37 
38  const PtBarrelLUT::LUT& lut = (*m_ptBarrelLUT)->lut();
39  const PtBarrelLUT::LUTsp& lutSP = (*m_ptBarrelLUT)->lutSP();
40 
41  TrigL2MuonSA::SuperPoint* superPoints[3];
42  for (int i_station=0; i_station<3; i_station++) {
43  superPoints[i_station] = &(trackPattern.superPoints[i_station]);
44  }
45 
46  int etabin,phibin,neweta,newphi,ch,add;
47  float phistep,etastep,pstep,dist,distp,disteta,distphi;
48  float A0[6]={0.,0.,0.,0.,0.,0.},A1[6]={0.,0.,0.,0.,0.,0.};
49 
50  const float scale = 0.1;
51 
52  if(trackPattern.barrelRadius > ZERO_LIMIT) {
53  add = trackPattern.s_address;
54  etabin = (int)((trackPattern.etaMap - lut.EtaMin[add])/lut.EtaStep[add]);
55  phibin = (int)((trackPattern.phiMap - lut.PhiMin[add])/lut.PhiStep[add]);
56 
57  if(etabin<=-1) etabin = 0;
58  if(etabin>=lut.NbinEta[add]) etabin = lut.NbinEta[add]-1;
59  if(phibin<=-1) phibin = 0;
60  if(phibin>=lut.NbinPhi[add]) phibin = lut.NbinPhi[add]-1;
61 
62  trackPattern.etaBin = etabin;
63  trackPattern.phiBin = phibin;
64 
65  disteta = trackPattern.etaMap - (etabin*lut.EtaStep[add] +
66  lut.EtaStep[add]/2. + lut.EtaMin[add]);
67  distphi = trackPattern.phiMap - (phibin*lut.PhiStep[add] +
68  lut.PhiStep[add]/2. + lut.PhiMin[add]);
69  neweta = (disteta >= 0.) ? etabin+1 : etabin-1;
70  newphi = (distphi >= 0.) ? phibin+1 : phibin-1;
71  etastep = (disteta >= 0.) ? lut.EtaStep[add] : -lut.EtaStep[add];
72  phistep = (distphi >= 0.) ? lut.PhiStep[add] : -lut.PhiStep[add];
73 
74  ch = (trackPattern.charge>=0.)? 1 : 0;
75 
76  if( add==1 ) {
77  // Use special table for Large-SP data
78 
79  int iR = ( superPoints[0]->R > 5800 )? 1: 0;
80  int qeta = ( trackPattern.charge*trackPattern.etaMap >= 0.)? 1 : 0;
81 
82  A0[0] = lutSP.table_LargeSP[qeta][iR][etabin][phibin][0];
83  A1[0] = lutSP.table_LargeSP[qeta][iR][etabin][phibin][1];
84 
85  trackPattern.pt = trackPattern.barrelRadius*A0[0] + A1[0];
86 
87  } else {
88 
89  A0[0] = lut.table[add][ch][etabin][phibin][0];
90  A1[0] = lut.table[add][ch][etabin][phibin][1];
91  if((neweta<0||neweta>=lut.NbinEta[add])&&
92  (newphi<0||newphi>=lut.NbinPhi[add])) {
93  trackPattern.pt = trackPattern.barrelRadius*scale*A0[0] + A1[0];
94  } else if (neweta<0||neweta>=lut.NbinEta[add]) {
95  A0[1] = lut.table[add][ch][etabin][newphi][0];
96  A1[1] = lut.table[add][ch][etabin][newphi][1];
97  A0[2] = A0[0] + ((A0[1] - A0[0])/phistep)*distphi;
98  A1[2] = A1[0] + ((A1[1] - A1[0])/phistep)*distphi;
99  trackPattern.pt = trackPattern.barrelRadius*scale*A0[2] + A1[2];
100  } else if (newphi<0||newphi>=lut.NbinPhi[add]) {
101  A0[1] = lut.table[add][ch][neweta][phibin][0];
102  A1[1] = lut.table[add][ch][neweta][phibin][1];
103  A0[2] = A0[0] + ((A0[1] - A0[0])/etastep)*disteta;
104  A1[2] = A1[0] + ((A1[1] - A1[0])/etastep)*disteta;
105  trackPattern.pt = trackPattern.barrelRadius*scale*A0[2] + A1[2];
106  } else {
107  if(disteta >= distphi*lut.EtaStep[add]/lut.PhiStep[add]) {
108  A0[1] = lut.table[add][ch][neweta][phibin][0];
109  A1[1] = lut.table[add][ch][neweta][phibin][1];
110  A0[2] = lut.table[add][ch][neweta][newphi][0];
111  A1[2] = lut.table[add][ch][neweta][newphi][1];
112  A0[3] = A0[0] + ((A0[1] - A0[0])/etastep)*disteta;
113  A1[3] = A1[0] + ((A1[1] - A1[0])/etastep)*disteta;
114  dist = std::sqrt(phistep*phistep + etastep*etastep);
115  distp = std::sqrt(disteta*disteta + distphi*distphi);
116  A0[4] = A0[0] + ((A0[2] - A0[0])/dist)*distp;
117  A1[4] = A1[0] + ((A1[2] - A1[0])/dist)*distp;
118  pstep = (phistep/dist)*distp;
119  A0[5] = A0[3] + ((A0[4] - A0[3])/pstep)*distphi;
120  A1[5] = A1[3] + ((A1[4] - A1[3])/pstep)*distphi;
121  trackPattern.pt = trackPattern.barrelRadius*scale*A0[5] + A1[5];
122  } else {
123  A0[1] = lut.table[add][ch][etabin][newphi][0];
124  A1[1] = lut.table[add][ch][etabin][newphi][1];
125  A0[2] = lut.table[add][ch][neweta][newphi][0];
126  A1[2] = lut.table[add][ch][neweta][newphi][1];
127  A0[3] = A0[0] + ((A0[1] - A0[0])/phistep)*distphi;
128  A1[3] = A1[0] + ((A1[1] - A1[0])/phistep)*distphi;
129  dist = std::sqrt(phistep*phistep + etastep*etastep);
130  distp = std::sqrt(disteta*disteta + distphi*distphi);
131  A0[4] = A0[0] + ((A0[2] - A0[0])/dist)*distp;
132  A1[4] = A1[0] + ((A1[2] - A1[0])/dist)*distp;
133  pstep = (etastep/dist)*distp;
134  A0[5] = A0[3] + ((A0[4] - A0[3])/pstep)*disteta;
135  A1[5] = A1[3] + ((A1[4] - A1[3])/pstep)*disteta;
136  trackPattern.pt = trackPattern.barrelRadius*scale*A0[5] + A1[5];
137  }
138  }
139  }
140  }
141 
142  ATH_MSG_DEBUG("pT determined from radius: barrelRadius/barrelSagitta/pT/charge/s_address="
143  << trackPattern.barrelRadius << "/" << trackPattern.barrelSagitta << "/"
144  << trackPattern.pt << "/" << trackPattern.charge << "/" << trackPattern.s_address);
145 
146 
147  return StatusCode::SUCCESS;
148 }
149 
150 // --------------------------------------------------------------------------------
151 // --------------------------------------------------------------------------------
152 
TrigL2MuonSA::TrackPattern::phiMap
double phiMap
Definition: TrackData.h:78
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
TrigL2MuonSA::TrackPattern::superPoints
TrigL2MuonSA::SuperPoint superPoints[s_NCHAMBER]
Definition: TrackData.h:60
AthMsgStreamMacros.h
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TrigL2MuonSA::TrackPattern::barrelRadius
double barrelRadius
Definition: TrackData.h:84
TrigL2MuonSA::PtBarrelLUT::LUT
Definition: PtBarrelLUT.h:19
TrigL2MuonSA::PtBarrelLUTSvc::ptBarrelLUT
const ToolHandle< PtBarrelLUT > * ptBarrelLUT(void) const
Definition: PtBarrelLUTSvc.h:38
TrigL2MuonSA::PtBarrelLUT::LUTsp
Definition: PtBarrelLUT.h:31
TrigL2MuonSA::TrackPattern::s_address
int s_address
Definition: TrackData.h:72
TrigL2MuonSA::PtFromRadius::setPt
StatusCode setPt(TrigL2MuonSA::TrackPattern &trackPattern) const
Definition: PtFromRadius.cxx:34
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
ITkPixEncoding::lut
constexpr auto lut(Generator &&f)
Definition: ITkPixQCoreEncodingLUT.h:19
TrigL2MuonSA::SuperPoint::R
float R
Definition: SuperPointData.h:102
TrigL2MuonSA::TrackPattern
Definition: TrackData.h:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TrigL2MuonSA::TrackPattern::barrelSagitta
double barrelSagitta
Definition: TrackData.h:85
TrigL2MuonSA::PtBarrelLUTSvc
Definition: PtBarrelLUTSvc.h:19
test_pyathena.parent
parent
Definition: test_pyathena.py:15
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
TrigL2MuonSA::PtFromRadius::PtFromRadius
PtFromRadius(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PtFromRadius.cxx:14
ZERO_LIMIT
const float ZERO_LIMIT
Definition: VP1TriggerHandleL2.cxx:37
TrigL2MuonSA::TrackPattern::charge
double charge
Definition: TrackData.h:63
TrigL2MuonSA::TrackPattern::pt
double pt
Definition: TrackData.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigL2MuonSA::TrackPattern::phiBin
int phiBin
Definition: TrackData.h:81
TrigL2MuonSA::TrackPattern::etaBin
int etaBin
Definition: TrackData.h:80
TrigL2MuonSA::PtBarrelLUT::LUTsp::table_LargeSP
float table_LargeSP[2][2][30][30][2]
Definition: PtBarrelLUT.h:33
TrigL2MuonSA::TrackPattern::etaMap
double etaMap
Definition: TrackData.h:77
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigL2MuonSA::SuperPoint
Definition: SuperPointData.h:74
AthAlgTool
Definition: AthAlgTool.h:26
TrigL2MuonSA::PtFromRadius::setMCFlag
void setMCFlag(const BooleanProperty &m_use_mcLUT, const TrigL2MuonSA::PtBarrelLUTSvc *ptBarrelLUTSvc)
Definition: PtFromRadius.cxx:24
PtFromRadius.h