ATLAS Offline Software
PtFromAlphaBeta.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 "PtFromAlphaBeta.h"
6 
8 
10 
11 // --------------------------------------------------------------------------------
12 // --------------------------------------------------------------------------------
13 
15  const std::string& name,
16  const IInterface* parent):
18 {
19 }
20 
21 // --------------------------------------------------------------------------------
22 // --------------------------------------------------------------------------------
23 
25 {
26  ATH_MSG_DEBUG(m_use_cscpt);
27  //
28  return StatusCode::SUCCESS;
29 }
30 
31 // --------------------------------------------------------------------------------
32 // --------------------------------------------------------------------------------
33 
34 void TrigL2MuonSA::PtFromAlphaBeta::setMCFlag(const BooleanProperty& use_mcLUT,
35  const TrigL2MuonSA::PtEndcapLUTSvc* ptEndcapLUTSvc)
36 {
37  m_use_mcLUT = use_mcLUT;
38  m_ptEndcapLUT = ptEndcapLUTSvc->ptEndcapLUT();
39 }
40 
41 // --------------------------------------------------------------------------------
42 // --------------------------------------------------------------------------------
43 
45  TrigL2MuonSA::TgcFitResult& tgcFitResult) const
46 {
47 
48  if (trackPattern.etaBin < -1)
49  return StatusCode::SUCCESS;
50 
51  const float ZERO_LIMIT = 1e-5;
52 
53  // use the TGC PT if the MDT fit is not available
54  if ( std::abs(trackPattern.slope)<ZERO_LIMIT && std::abs(trackPattern.intercept)<ZERO_LIMIT )
55  return StatusCode::SUCCESS;
56 
57  const float tgcPt = tgcFitResult.tgcPT ;
58 
59  // MDT pT by alpha
60  const int side = (trackPattern.etaMap <= 0.0) ? 0 : 1;
61  const int charge = (trackPattern.intercept * trackPattern.etaMap) < 0.0 ? 0 : 1;
62 
63  float mdtPt = (*m_ptEndcapLUT)->lookup(side, charge, PtEndcapLUT::ALPHAPOL2, trackPattern.etaBin,
64  trackPattern.phiBin, trackPattern.endcapAlpha) / 1000;
65 
66  if (charge == 0) mdtPt = -mdtPt;
67  trackPattern.ptEndcapAlpha = mdtPt;//pt calculated by alpha
68  //
69  const float ALPHA_TO_BETA_PT = 10;
70  const float ALPHA_TO_BETA_RATIO = 0.5;
71  const float ALPHA_TO_CSC_RATIO = 0.3;
72  const float ALPHA_TO_CSC_RATIO_PT = 0.025;
73 
74  // use MDT beta if condition allows
75  if (std::abs(mdtPt) > ALPHA_TO_BETA_PT && std::abs(trackPattern.endcapBeta)>ZERO_LIMIT) {
76  float betaPt = (*m_ptEndcapLUT)->lookup(side, charge, PtEndcapLUT::BETAPOL2, trackPattern.etaBin,
77  trackPattern.phiBin, trackPattern.endcapBeta) / 1000;
78 
79  if (charge == 0) betaPt = -betaPt;
80  trackPattern.ptEndcapBeta = betaPt;//pt calculated by beta
81 
83  if ( std::abs((betaPt - mdtPt) / mdtPt) < ALPHA_TO_BETA_RATIO ) {
84  mdtPt = betaPt;
85  } else if ( std::abs(trackPattern.superPoints[outer].Z) < ZERO_LIMIT) {
86  if( std::abs(betaPt) > std::abs(mdtPt) || (std::abs((tgcPt-mdtPt)/mdtPt) > std::abs((tgcPt-betaPt)/betaPt)) ) mdtPt = betaPt;
87  }
88  }
89  if (trackPattern.endcapRadius3P>0) {//calculate pt from radius
90  ATH_MSG_DEBUG("calculate pt from Radius");
91  const float invR = 1. / trackPattern.endcapRadius3P;
92 
93  if (trackPattern.etaBin<8){
94  trackPattern.ptEndcapRadius = (*m_ptEndcapLUT)->lookup(side, charge, PtEndcapLUT::INVRADIUSPOL2,
95  trackPattern.etaBin, trackPattern.phiBinEE, invR) / 1000;
96  }
97  }
98  if ( std::abs(trackPattern.cscGamma)>ZERO_LIMIT ){
99 
100  float cscPt = (*m_ptEndcapLUT)->lookup(side, charge, PtEndcapLUT::CSCPOL2, trackPattern.etaBin,
101  trackPattern.phiBin, trackPattern.cscGamma) / 1000;
102  if (charge == 0) cscPt = -cscPt;
103  trackPattern.ptCSC = cscPt;
104  }
105  if(mdtPt!=0.0) {
106  trackPattern.pt = std::abs(mdtPt);
107  trackPattern.charge = mdtPt / std::abs(mdtPt);
108  }
109 
110  if (trackPattern.ptEndcapRadius>0 && trackPattern.ptEndcapRadius<500)
111  trackPattern.pt = trackPattern.ptEndcapRadius;//use pt calculated from endcap radius
112 
113  if(m_use_cscpt){
114  const float &cscPt = trackPattern.ptCSC;
115  const int &etabin = trackPattern.etaBin;
116  const bool validrange = (20<=etabin && etabin<=27) || (etabin==20 && std::abs(side-charge)!=1);//side-charge==0 <=> Qeta==1
117  const bool validchamber = !m_avoid_misaligned_cscs || (16!=trackPattern.hashID_CSC && 17!=trackPattern.hashID_CSC);
118  if( etabin !=23 && etabin!=24 && validrange && validchamber){
119  if(std::abs(trackPattern.ptEndcapBeta)<ZERO_LIMIT && std::abs(cscPt)>ZERO_LIMIT
120  && std::abs((cscPt - mdtPt) / mdtPt)<ALPHA_TO_CSC_RATIO && std::abs(1./cscPt-1./mdtPt)<ALPHA_TO_CSC_RATIO_PT ){
121  trackPattern.pt = std::abs(cscPt);
122  //trackPattern.charge = cscPt/std::abs(cscPt);//not need
123  }
124  }
125  }//use pt calculated from CSC-gamma
126 
127 
128  bool pTCB = false;
129  if( pTCB ){
130  double Co_APt = 0.;
131  double Co_BPt = 0.;
132 
133  double tmpalphaPt = (*m_ptEndcapLUT)->lookup(side, charge, PtEndcapLUT::ALPHAPOL2, trackPattern.etaBin, trackPattern.phiBin, trackPattern.endcapAlpha) / 1000;
134  trackPattern.ptEndcapAlpha = tmpalphaPt;
135 
136  double tmpbetaPt = 0.;
137  if(std::abs(trackPattern.endcapBeta)>ZERO_LIMIT) tmpbetaPt = (*m_ptEndcapLUT)->lookup(side, charge, PtEndcapLUT::BETAPOL2, trackPattern.etaBin, trackPattern.phiBin, trackPattern.endcapBeta) / 1000;
138  trackPattern.ptEndcapBeta = tmpbetaPt;
139 
140  double tmp_pt = (*m_ptEndcapLUT)->ptcombined(trackPattern.etaBin, trackPattern.phiBin, tmpalphaPt,tmpbetaPt, Co_APt, Co_BPt);
141 
142  float final_pt = 0.;
143  if(std::abs(Co_APt)>ZERO_LIMIT && std::abs(Co_BPt)>ZERO_LIMIT && std::abs(Co_BPt-Co_APt)/std::abs(Co_APt) < 0.5){
144  final_pt = tmp_pt;
145  }else{
146  final_pt = Co_APt;
147  }
148  if(final_pt == 0.)final_pt = tgcPt;
149  }
150 
151  ATH_MSG_DEBUG("pT determined from alpha and beta: endcapAlpha/endcapBeta/endcapRadius3P/cscGamma/pT/charge/s_address="
152  << trackPattern.endcapAlpha << "/" << trackPattern.endcapBeta << "/" << trackPattern.endcapRadius3P << "/" << trackPattern.cscGamma << "/"
153  << trackPattern.pt
154  << "/" << trackPattern.charge << "/" << trackPattern.s_address);
155  ATH_MSG_DEBUG("ptEndcapAlpha/ptEndcapBeta/tgcPt/ptEndcapRadius/ptCSC="
156  << trackPattern.ptEndcapAlpha << "/" << trackPattern.ptEndcapBeta << "/"
157  << tgcPt << "/" << trackPattern.ptEndcapRadius << "/" << trackPattern.ptCSC);
158 
159  return StatusCode::SUCCESS;
160 }
161 
162 // --------------------------------------------------------------------------------
163 // --------------------------------------------------------------------------------
164 
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
TrigL2MuonSA::TrackPattern::ptEndcapBeta
double ptEndcapBeta
Definition: TrackData.h:98
TrigL2MuonSA::TrackPattern::slope
double slope
Definition: TrackData.h:93
TrigL2MuonSA::TrackPattern::superPoints
TrigL2MuonSA::SuperPoint superPoints[s_NCHAMBER]
Definition: TrackData.h:60
AthMsgStreamMacros.h
TrigL2MuonSA::TrackPattern::cscGamma
double cscGamma
Definition: TrackData.h:91
TrigL2MuonSA::TrackPattern::ptCSC
double ptCSC
Definition: TrackData.h:100
TrigL2MuonSA::PtEndcapLUT::INVRADIUSPOL2
@ INVRADIUSPOL2
Definition: PtEndcapLUT.h:24
TrigL2MuonSA::TgcFitResult
Definition: TgcFitResult.h:11
TrigL2MuonSA::TrackPattern::s_address
int s_address
Definition: TrackData.h:72
TrigL2MuonSA::TrackPattern::endcapBeta
double endcapBeta
Definition: TrackData.h:88
TrigL2MuonSA::PtFromAlphaBeta::setPt
StatusCode setPt(TrigL2MuonSA::TrackPattern &trackPattern, TrigL2MuonSA::TgcFitResult &tgcFitResult) const
Definition: PtFromAlphaBeta.cxx:44
TrigL2MuonSA::TrackPattern::endcapRadius3P
double endcapRadius3P
Definition: TrackData.h:90
TrigL2MuonSA::TrackPattern::hashID_CSC
int hashID_CSC
Definition: TrackData.h:108
TrigL2MuonSA::TrackPattern
Definition: TrackData.h:16
TRT::Hit::side
@ side
Definition: HitInfo.h:83
TrigL2MuonSA::PtFromAlphaBeta::setMCFlag
void setMCFlag(const BooleanProperty &use_mcLUT, const TrigL2MuonSA::PtEndcapLUTSvc *ptEndcapLUTSvc)
Definition: PtFromAlphaBeta.cxx:34
xAOD::tgcPt
setTeId setLumiBlock setRoiId setRoiSubsystem setRoiNumber setRoiEta tgcPt
Definition: L2StandAloneMuon_v2.cxx:352
TrigL2MuonSA::PtEndcapLUT::CSCPOL2
@ CSCPOL2
Definition: PtEndcapLUT.h:24
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::ptEndcapAlpha
double ptEndcapAlpha
Definition: TrackData.h:97
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TrigL2MuonSA::PtEndcapLUT::ALPHAPOL2
@ ALPHAPOL2
Definition: PtEndcapLUT.h:24
TrigL2MuonSA::TrackPattern::intercept
double intercept
Definition: TrackData.h:94
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
TrigL2MuonSA::PtEndcapLUTSvc::ptEndcapLUT
const ToolHandle< PtEndcapLUT > * ptEndcapLUT(void) const
Definition: PtEndcapLUTSvc.h:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TrigL2MuonSA::TrackPattern::phiBin
int phiBin
Definition: TrackData.h:81
TrigL2MuonSA::TrackPattern::etaBin
int etaBin
Definition: TrackData.h:80
charge
double charge(const T &p)
Definition: AtlasPID.h:538
TrigL2MuonSA::PtFromAlphaBeta::PtFromAlphaBeta
PtFromAlphaBeta(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PtFromAlphaBeta.cxx:14
TrigMuonDefs.h
TrigL2MuonSA::TgcFitResult::tgcPT
float tgcPT
Definition: TgcFitResult.h:63
TrigL2MuonSA::TrackPattern::etaMap
double etaMap
Definition: TrackData.h:77
TrigL2MuonSA::TrackPattern::phiBinEE
int phiBinEE
Definition: TrackData.h:82
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
PtFromAlphaBeta.h
TrigL2MuonSA::SuperPoint::Z
float Z
Definition: SuperPointData.h:103
TrigL2MuonSA::PtEndcapLUT::BETAPOL2
@ BETAPOL2
Definition: PtEndcapLUT.h:24
AthAlgTool
Definition: AthAlgTool.h:26
TrigL2MuonSA::PtFromAlphaBeta::initialize
virtual StatusCode initialize() override
Definition: PtFromAlphaBeta.cxx:24
TrigL2MuonSA::TrackPattern::ptEndcapRadius
double ptEndcapRadius
Definition: TrackData.h:99
xAOD::L2MuonParameters::EndcapOuter
@ EndcapOuter
Outer station in the endcap spectrometer.
Definition: TrigMuonDefs.h:21
TrigL2MuonSA::TrackPattern::endcapAlpha
double endcapAlpha
Definition: TrackData.h:87
TrigL2MuonSA::PtEndcapLUTSvc
Definition: PtEndcapLUTSvc.h:20