ATLAS Offline Software
RecMuonRoI.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2024 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 
25 using namespace std;
26 using namespace TrigConf;
27 
28 
29 LVL1::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 
37 LVL1::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 
45 void
46 LVL1::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;
52  m_firstCandidateFlag = false;
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 ) {
65  m_firstCandidateFlag = true;
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
79  m_thresholdNumber = this->getBitMaskValue( &m_roiWord, ThresNumMask );
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
126  m_thresholdValue = 0;
127  for(const TrigConf::TriggerThreshold* thr : *theMuonConfig) {
128  if( thr->type() == L1DataDef::muonType() &&
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 
137 void
138 LVL1::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 ) {
157  m_firstCandidateFlag = true;
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
171  m_thresholdNumber = this->getBitMaskValue( &m_roiWord, ThresNumMask );
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
207  m_thresholdValue = 0;
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 
222  if( m_roiWord & TGCCandidateSignMask ) {
223  return POSITIVE;
224  } else {
225  return NEGATIVE;
226  }
227 }
228 
229 bool
231 {
232  return ( m_roiWord & CandidateVetoMask );
233 }
234 
238 unsigned int
239 LVL1::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 
256 std::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 
LVL1::RecMuonRoI::getBitMaskValue
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
Definition: RecMuonRoI.cxx:239
TrigConf::TriggerThresholdValue
Definition: TriggerThresholdValue.h:22
LVL1::TrigT1MuonRecRoiData
Definition: TrigT1MuonRecRoiData.h:10
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
LVL1::SectOflMask
@ SectOflMask
Definition: RecMuonRoI.h:52
get_generator_info.result
result
Definition: get_generator_info.py:21
LVL1::CandidateVetoMask
@ CandidateVetoMask
Definition: RecMuonRoI.h:54
LVL1::TGCCandidateSignMask
@ TGCCandidateSignMask
Definition: RecMuonRoI.h:53
LVL1::RecMuonRoI::RecMuonRoI
RecMuonRoI()
Definition: RecMuonRoI.h:71
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
LVL1::RecMuonRoI::construct
void construct(unsigned int roIWord, const RecMuonRoiSvc *theRecRPCRoiSvc, const RecMuonRoiSvc *theRecTGCRoiSvc, const std::vector< TrigConf::TriggerThreshold * > *theMuonConfig)
LVL1::RecMuonRoI::ChargeSign
ChargeSign
Charge sign of the muon candidate.
Definition: RecMuonRoI.h:64
TrigConf::TriggerThresholdValue::ptcut
float ptcut() const
Definition: TriggerThresholdValue.h:45
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
LVL1::TrigT1MuonRecRoiData::eta
double eta(void) const
Definition: TrigT1MuonRecRoiData.h:22
RecMuonRoI.h
TrigConf::L1Menu
L1 menu configuration.
Definition: L1Menu.h:28
LVL1::SubSysIDMask
@ SubSysIDMask
Definition: RecMuonRoI.h:40
LVL1::ITrigT1MuonRecRoiTool::roiData
virtual StatusCode roiData(const unsigned int &roiWord, TrigT1MuonRecRoiData &data) const =0
pure virtual function to return eta and phi coord of RoI
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
LVL1::BarrelRoIMask
@ BarrelRoIMask
Definition: RecMuonRoI.h:46
LVL1::ITrigT1MuonRecRoiTool
Definition: ITrigT1MuonRecRoiTool.h:13
LVL1::FirsCandMask
@ FirsCandMask
Definition: RecMuonRoI.h:37
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition: Config.h:22
LVL1::SectNumEndcapMask
@ SectNumEndcapMask
Definition: RecMuonRoI.h:42
LVL1::RoIOvlMask
@ RoIOvlMask
Definition: RecMuonRoI.h:45
UNDEFINED
@ UNDEFINED
Definition: sTGCenumeration.h:18
LVL1::RecMuonRoI::candidateVetoed
bool candidateVetoed() const
Returns true if the candidate was vetoed in the multiplicity sum.
Definition: RecMuonRoI.cxx:230
LVL1::EndcapRoIMask
@ EndcapRoIMask
Definition: RecMuonRoI.h:48
LVL1::ThresNumMask
@ ThresNumMask
Definition: RecMuonRoI.h:44
TriggerThreshold.h
ITrigT1MuonRecRoiTool.h
LVL1::TrigT1MuonRecRoiData::phi
double phi(void) const
Definition: TrigT1MuonRecRoiData.h:23
TriggerThresholdValue.h
LVL1::PadOflMask
@ PadOflMask
Definition: RecMuonRoI.h:51
LVL1::ForwardRoIMask
@ ForwardRoIMask
Definition: RecMuonRoI.h:50
LVL1::SectorAddressMask
@ SectorAddressMask
Definition: RecMuonRoI.h:38
L1DataDef.h
LVL1::EndcapOvlMask
@ EndcapOvlMask
Definition: RecMuonRoI.h:49
LVL1::SectNumForwardMask
@ SectNumForwardMask
Definition: RecMuonRoI.h:43
TrigConf::L1Threshold_MU
Definition: L1Threshold.h:400
LVL1::BarrelOvlMask
@ BarrelOvlMask
Definition: RecMuonRoI.h:47
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
LVL1::RecMuonRoI::getDebugString
std::string getDebugString()
Definition: RecMuonRoI.cxx:257
LVL1::RecMuonRoI::candidateCharge
ChargeSign candidateCharge() const
Returns the change sign of the candidate.
Definition: RecMuonRoI.cxx:217
L1Menu.h
TrigConf::TriggerThreshold
Definition: TriggerThreshold.h:20
TrigConf::L1Threshold_MU::ptBarrel
unsigned int ptBarrel() const
Definition: L1Threshold.h:413
LVL1::SectNumBarrelMask
@ SectNumBarrelMask
Definition: RecMuonRoI.h:41
LVL1::SysIDMask
@ SysIDMask
Definition: RecMuonRoI.h:39