ATLAS Offline Software
Loading...
Searching...
No Matches
RecMuonRoI.cxx
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3/***************************************************************************
4 * RecMuonRoI.cxx - description
5 * -------------------
6 * begin : Tue Feb 25 2003
7 * email : Thorsten.Wengler
8 **************************************************************************/
9
10
11// STL include(s):
12#include <iomanip>
13#include <sstream>
14
15// Trigger config includes:
19#include "TrigConfData/L1Menu.h"
20
21// Local include(s):
24
25using namespace std;
26using namespace TrigConf;
27
28
29LVL1::RecMuonRoI::RecMuonRoI( unsigned int roIWord,
30 const LVL1::ITrigT1MuonRecRoiTool* theRecRPCRoiTool,
31 const LVL1::ITrigT1MuonRecRoiTool* theRecTGCRoiTool,
32 const std::vector< TriggerThreshold* >* theMuonConfig )
33{
34 construct( roIWord, theRecRPCRoiTool, theRecTGCRoiTool, theMuonConfig );
35}
36
37LVL1::RecMuonRoI::RecMuonRoI( unsigned int roIWord,
38 const LVL1::ITrigT1MuonRecRoiTool* theRecRPCRoiTool,
39 const LVL1::ITrigT1MuonRecRoiTool* theRecTGCRoiTool,
40 const TrigConf::L1Menu* const l1menu )
41{
42 construct( roIWord, theRecRPCRoiTool, theRecTGCRoiTool, l1menu );
43}
44
45void
46LVL1::RecMuonRoI::construct( unsigned int roIWord,
47 const LVL1::ITrigT1MuonRecRoiTool* theRecRPCRoiTool,
48 const LVL1::ITrigT1MuonRecRoiTool* theRecTGCRoiTool,
49 const std::vector< TriggerThreshold* >* theMuonConfig )
50{
51 m_roiWord = roIWord;
53 m_sectorOflFlag = false;
54 m_padOflFlag = false;
55 m_eta = 0;
56 m_phi = 0;
57
58 // first extract the parts holding the sector address and
59 // and the RoI/Overlap from the 32 bit word
60 unsigned int sectorAddress = this->getBitMaskValue( &m_roiWord, SectorAddressMask );
61 unsigned int sectorRoIOvl = this->getBitMaskValue( &m_roiWord, RoIOvlMask );
62
63 // the first candidate flag
64 if ( this->getBitMaskValue( &m_roiWord, FirsCandMask ) == 1 ) {
66 }
67
68 // the sector overflow flag
69 if ( this->getBitMaskValue( &m_roiWord, SectOflMask ) == 1 ) {
70 m_sectorOflFlag = true;
71 }
72
73 // the pad overflow flag
74 if ( this->getBitMaskValue( &m_roiWord, PadOflMask ) == 1 ) {
75 m_padOflFlag = true;
76 }
77
78 // the pt threshold number
80
81 // the RoI and sector ID encoding is system dependent - need 3 cases
82
83 unsigned int temp_sysID = this->getBitMaskValue( &sectorAddress, SysIDMask );
84 m_sysID = 0; // The default is the barrel
85 if( temp_sysID & 0x2 ) m_sysID = 1; // If the higher bit is set, it's from the endcap region
86 else if( temp_sysID & 0x1 ) m_sysID = 2; // if the lower bit is set, it's from the forward region
87
88 m_subSysID = this->getBitMaskValue( &sectorAddress, SubSysIDMask );
89 if ( m_sysID == 0 ) { // Barrel
90 m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumBarrelMask );
91 m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, BarrelRoIMask );
92 m_overlap = this->getBitMaskValue( &sectorRoIOvl, BarrelOvlMask );
93 } else if ( m_sysID == 2 ) { // Forward
94 m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumForwardMask );
95 m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, ForwardRoIMask );
96 m_overlap = 0;
97 } else if ( m_sysID == 1 ) { // Endcap
98 m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumEndcapMask );
99 m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, EndcapRoIMask );
100 m_overlap = this->getBitMaskValue( &sectorRoIOvl, EndcapOvlMask );
101 }
102
103 if( m_sysID == 0 ) { // RPC
104 if( theRecRPCRoiTool ) {
105 // set eta and phi values
107 if( theRecRPCRoiTool->roiData( roIWord, roiData ).isSuccess() ){
108 m_eta = roiData.eta();
109 m_phi = roiData.phi();
110 }
111 }
112 } else { // TGC
113 if( theRecTGCRoiTool ) {
114 // set eta and phi values
116 if( theRecTGCRoiTool->roiData( roIWord, roiData ).isSuccess() ){
117 m_eta = roiData.eta();
118 m_phi = roiData.phi();
119 }
120 }
121 }
122
123 // Get the threshold value
124 // Don't bother casting TriggerThresholdValue to MuonThresholdValue as the latter
125 // currently only adds a printout function
127 for(const TrigConf::TriggerThreshold* thr : *theMuonConfig) {
128 if( thr->type() == L1DataDef::typeAsString(L1DataDef::MUON) &&
129 thr->thresholdNumber() + 1 == static_cast< int >( m_thresholdNumber ) ) {
130
131 TrigConf::TriggerThresholdValue* ttv = thr->triggerThresholdValue( 0, 0 );
132 m_thresholdValue = static_cast< unsigned int >( ttv->ptcut() );
133 }
134 }
135}
136
137void
138LVL1::RecMuonRoI::construct( unsigned int roIWord,
139 const LVL1::ITrigT1MuonRecRoiTool* theRecRPCRoiTool,
140 const LVL1::ITrigT1MuonRecRoiTool* theRecTGCRoiTool,
141 const TrigConf::L1Menu * const l1menu )
142{
143 m_roiWord = roIWord;
144 m_firstCandidateFlag = false;
145 m_sectorOflFlag = false;
146 m_padOflFlag = false;
147 m_eta = 0;
148 m_phi = 0;
149
150 // first extract the parts holding the sector address and
151 // and the RoI/Overlap from the 32 bit word
152 unsigned int sectorAddress = this->getBitMaskValue( &m_roiWord, SectorAddressMask );
153 unsigned int sectorRoIOvl = this->getBitMaskValue( &m_roiWord, RoIOvlMask );
154
155 // the first candidate flag
156 if ( this->getBitMaskValue( &m_roiWord, FirsCandMask ) == 1 ) {
158 }
159
160 // the sector overflow flag
161 if ( this->getBitMaskValue( &m_roiWord, SectOflMask ) == 1 ) {
162 m_sectorOflFlag = true;
163 }
164
165 // the pad overflow flag
166 if ( this->getBitMaskValue( &m_roiWord, PadOflMask ) == 1 ) {
167 m_padOflFlag = true;
168 }
169
170 // the pt threshold number
172
173 // the RoI and sector ID encoding is system dependent - need 3 cases
174
175 unsigned int temp_sysID = this->getBitMaskValue( &sectorAddress, SysIDMask );
176 m_sysID = 0; // The default is the barrel
177 if( temp_sysID & 0x2 ) m_sysID = 1; // If the higher bit is set, it's from the endcap region
178 else if( temp_sysID & 0x1 ) m_sysID = 2; // if the lower bit is set, it's from the forward region
179
180 m_subSysID = this->getBitMaskValue( &sectorAddress, SubSysIDMask );
181 if ( m_sysID == 0 ) { // Barrel
182 m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumBarrelMask );
183 m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, BarrelRoIMask );
184 m_overlap = this->getBitMaskValue( &sectorRoIOvl, BarrelOvlMask );
185 } else if ( m_sysID == 2 ) { // Forward
186 m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumForwardMask );
187 m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, ForwardRoIMask );
188 m_overlap = 0;
189 } else if ( m_sysID == 1 ) { // Endcap
190 m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumEndcapMask );
191 m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, EndcapRoIMask );
192 m_overlap = this->getBitMaskValue( &sectorRoIOvl, EndcapOvlMask );
193 }
194
195 // m_sysID == 0 (RPC) or 1 (TGC)
196 const ITrigT1MuonRecRoiTool* theRecRoiTool = (m_sysID == 0) ? theRecRPCRoiTool : theRecTGCRoiTool;
197 if( theRecRoiTool ) {
198 // set eta and phi values
200 if( theRecRoiTool->roiData( roIWord, roiData ).isSuccess() ){
201 m_eta = roiData.eta();
202 m_phi = roiData.phi();
203 }
204 }
205
206 // Get the threshold value
208 for( const shared_ptr<TrigConf::L1Threshold> &thr : l1menu->thresholds("MU")) {
209 auto muonThr = static_cast<TrigConf::L1Threshold_MU*>(thr.get());
210 if( muonThr->mapping() + 1 == m_thresholdNumber ) {
211 m_thresholdValue = muonThr->ptBarrel(); // for new muon thresholds this must be properly chosen, depending on the regiom
212 }
213 }
214}
215
218
219 // If it's a barrel muon then we don't know its sign:
220 if( sysID() == 0 ) return UNDEFINED;
221
223 return POSITIVE;
224 } else {
225 return NEGATIVE;
226 }
227}
228
229bool
234
238unsigned int
239LVL1::RecMuonRoI::getBitMaskValue( const unsigned int * uintValue, const unsigned int mask )
240{
241 unsigned int result;
242 unsigned int maskcopy;
243 // make a copy of the mask, because a mask is a mask and
244 // one should stay a mask (i.e. should be something constant!)
245 maskcopy = mask;
246 result = *uintValue & mask;
247 if ( mask != 0 ) {
248 while ( ( maskcopy & 0x00000001 ) == 0 ) {
249 maskcopy = maskcopy >> 1;
250 result = result >> 1;
251 }
252 }
253 return result;
254}
255
256std::string
258{
259 ostringstream out;
260 string system;
261 string hemisphere = "-";
262
263 if ( this->sysID() == 0 ) {system = "B";}
264 if ( this->sysID() == 1 ) {system = "F";}
265 if ( this->sysID() > 1 ) {system = "E";}
266
267 if ( this->subsysID() == 1 ) {hemisphere = "+";}
268
269 out << " Addr: " << hemisphere << system << " "
270 << setw( 2 ) << ios::dec << this-> sectorID()
271 << " Pt/RoI: " << this->getThresholdNumber()
272 << " " << setw( 2 ) << this->getRoINumber() << std::setfill( ' ' )
273 << " Ovl: " << this->getOverlap()
274 << " pad/secOF: " << setw( 2 ) << this->padOverflow()
275 << setw( 2 ) << this->sectorOverflow()
276 << " First: " << this->firstCandidate();
277
278 return out.str();
279}
280
virtual StatusCode roiData(const unsigned int &roiWord, TrigT1MuonRecRoiData &data) const =0
pure virtual function to return eta and phi coord of RoI
double m_phi
phi value
Definition RecMuonRoI.h:202
unsigned int getOverlap() const
return Overlap in hardware numbering scheme
Definition RecMuonRoI.h:129
ChargeSign
Charge sign of the muon candidate.
Definition RecMuonRoI.h:64
@ UNDEFINED
Candidate coming from the RPC.
Definition RecMuonRoI.h:67
@ NEGATIVE
Negative (mu minus) candidate in the TGC.
Definition RecMuonRoI.h:65
@ POSITIVE
Positive (mu plus) candidate in the TGC.
Definition RecMuonRoI.h:66
unsigned int m_sysID
the system ID for this RoI (Barrel=0, Endcap=1, Forward=2) extracted from m_roiWord in the constructo...
Definition RecMuonRoI.h:188
bool candidateVetoed() const
Returns true if the candidate was vetoed in the multiplicity sum.
unsigned int sectorID() const
returns sector ID ROI
Definition RecMuonRoI.h:111
unsigned int m_sectorID
the sector number for this RoI extracted from m_roiWord in the constructor
Definition RecMuonRoI.h:196
unsigned int m_thresholdNumber
the pt threshold number associated with this RoI - extracted from m_roiWord in the constructor
Definition RecMuonRoI.h:172
void construct(unsigned int roIWord, const RecMuonRoiSvc *theRecRPCRoiSvc, const RecMuonRoiSvc *theRecTGCRoiSvc, const std::vector< TrigConf::TriggerThreshold * > *theMuonConfig)
unsigned int m_roiWord
this is the actual format of the data sent from the LVL1 hardware.
Definition RecMuonRoI.h:156
unsigned int m_thresholdValue
The value of the threshold in GeV.
Definition RecMuonRoI.h:176
bool firstCandidate() const
returns true if this was the highest pt candidate in this sector
Definition RecMuonRoI.h:132
bool m_firstCandidateFlag
flag indicating if this was the highest pt candidate in this sector - extracted from m_roiWord in the...
Definition RecMuonRoI.h:160
unsigned int getThresholdNumber() const
returns the Threshold Number (1 to 6) associated with this RecRoI
Definition RecMuonRoI.h:120
bool m_sectorOflFlag
flag indicating if there were more than 2 candidates in this sector - extracted from m_roiWord in the...
Definition RecMuonRoI.h:164
unsigned int sysID() const
returns system ID ROI (Barrel=0, Endcap=1, Forward=2)
Definition RecMuonRoI.h:105
unsigned int subsysID() const
returns sub-system ID ROI (0=-z,1=+z)
Definition RecMuonRoI.h:108
bool sectorOverflow() const
returns true if there were > 2 candidates in this sector
Definition RecMuonRoI.h:135
unsigned int m_roiNumber
the RoI number of this RoI - extracted from m_roiWord in the constructor
Definition RecMuonRoI.h:180
bool padOverflow() const
returns true if there were > 1 candidates in this pad
Definition RecMuonRoI.h:138
ChargeSign candidateCharge() const
Returns the change sign of the candidate.
unsigned int m_subSysID
the subSystem ID for this RoI (0=-z,1=+z) extracted from m_roiWord in the constructor
Definition RecMuonRoI.h:192
std::string getDebugString()
unsigned int m_overlap
the overlap information for this RoI extracted from m_roiWord in the constructor
Definition RecMuonRoI.h:184
double m_eta
eta value
Definition RecMuonRoI.h:199
bool m_padOflFlag
flag indicating if there was more than 1 candidate in this pad - extracted from m_roiWord in the cons...
Definition RecMuonRoI.h:168
unsigned int getRoINumber() const
return RoI number in hardware numbering scheme
Definition RecMuonRoI.h:126
unsigned int getBitMaskValue(const unsigned int *uintValue, const unsigned int mask)
a helper function to extract the value corresponding to a bit mask from a 32 bit unsigned int
static std::string & typeAsString(TriggerType tt)
Definition L1DataDef.h:53
L1 menu configuration.
Definition L1Menu.h:28
@ SectorAddressMask
Definition RecMuonRoI.h:38
@ BarrelOvlMask
Definition RecMuonRoI.h:47
@ EndcapOvlMask
Definition RecMuonRoI.h:49
@ RoIOvlMask
Definition RecMuonRoI.h:45
@ SectNumEndcapMask
Definition RecMuonRoI.h:42
@ SectOflMask
Definition RecMuonRoI.h:52
@ PadOflMask
Definition RecMuonRoI.h:51
@ SectNumForwardMask
Definition RecMuonRoI.h:43
@ CandidateVetoMask
Definition RecMuonRoI.h:54
@ SysIDMask
Definition RecMuonRoI.h:39
@ SectNumBarrelMask
Definition RecMuonRoI.h:41
@ TGCCandidateSignMask
Definition RecMuonRoI.h:53
@ ThresNumMask
Definition RecMuonRoI.h:44
@ FirsCandMask
Definition RecMuonRoI.h:37
@ EndcapRoIMask
Definition RecMuonRoI.h:48
@ ForwardRoIMask
Definition RecMuonRoI.h:50
@ SubSysIDMask
Definition RecMuonRoI.h:40
@ BarrelRoIMask
Definition RecMuonRoI.h:46
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
STL namespace.