ATLAS Offline Software
RecMuonRoI.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2021 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):
25 
26 using namespace std;
27 using namespace TrigConf;
28 
29 
30 LVL1::RecMuonRoI::RecMuonRoI( unsigned int roIWord,
31  const RecMuonRoiSvc* theRecRPCRoiSvc,
32  const RecMuonRoiSvc* theRecTGCRoiSvc,
33  const std::vector< TriggerThreshold* >* theMuonConfig )
34 {
35  construct( roIWord, theRecRPCRoiSvc, theRecTGCRoiSvc, theMuonConfig );
36 }
37 
38 LVL1::RecMuonRoI::RecMuonRoI( unsigned int roIWord,
39  const LVL1::ITrigT1MuonRecRoiTool* theRecRPCRoiTool,
40  const LVL1::ITrigT1MuonRecRoiTool* theRecTGCRoiTool,
41  const std::vector< TriggerThreshold* >* theMuonConfig )
42 {
43  construct( roIWord, theRecRPCRoiTool, theRecTGCRoiTool, theMuonConfig );
44 }
45 
46 LVL1::RecMuonRoI::RecMuonRoI( unsigned int roIWord,
47  const LVL1::ITrigT1MuonRecRoiTool* theRecRPCRoiTool,
48  const LVL1::ITrigT1MuonRecRoiTool* theRecTGCRoiTool,
49  const TrigConf::L1Menu* const l1menu )
50 {
51  construct( roIWord, theRecRPCRoiTool, theRecTGCRoiTool, l1menu );
52 }
53 
54 void
55 LVL1::RecMuonRoI::construct( unsigned int roIWord,
56  const RecMuonRoiSvc* theRecRPCRoiSvc,
57  const RecMuonRoiSvc* theRecTGCRoiSvc,
58  const std::vector< TriggerThreshold* >* theMuonConfig )
59 {
60  m_roiWord = roIWord;
61  m_firstCandidateFlag = false;
62  m_sectorOflFlag = false;
63  m_padOflFlag = false;
64  m_eta = 0;
65  m_phi = 0;
66 
67  // first extract the parts holding the sector address and
68  // and the RoI/Overlap from the 32 bit word
69  unsigned int sectorAddress = this->getBitMaskValue( &m_roiWord, SectorAddressMask );
70  unsigned int sectorRoIOvl = this->getBitMaskValue( &m_roiWord, RoIOvlMask );
71 
72  // the first candidate flag
73  if ( this->getBitMaskValue( &m_roiWord, FirsCandMask ) == 1 ) {
74  m_firstCandidateFlag = true;
75  }
76 
77  // the sector overflow flag
78  if ( this->getBitMaskValue( &m_roiWord, SectOflMask ) == 1 ) {
79  m_sectorOflFlag = true;
80  }
81 
82  // the pad overflow flag
83  if ( this->getBitMaskValue( &m_roiWord, PadOflMask ) == 1 ) {
84  m_padOflFlag = true;
85  }
86 
87  // the pt threshold number
88  m_thresholdNumber = this->getBitMaskValue( &m_roiWord, ThresNumMask );
89 
90  // the RoI and sector ID encoding is system dependent - need 3 cases
91 
92  unsigned int temp_sysID = this->getBitMaskValue( &sectorAddress, SysIDMask );
93  m_sysID = 0; // The default is the barrel
94  if( temp_sysID & 0x2 ) m_sysID = 1; // If the higher bit is set, it's from the endcap region
95  else if( temp_sysID & 0x1 ) m_sysID = 2; // if the lower bit is set, it's from the forward region
96 
97  m_subSysID = this->getBitMaskValue( &sectorAddress, SubSysIDMask );
98  if ( m_sysID == 0 ) { // Barrel
99  m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumBarrelMask );
100  m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, BarrelRoIMask );
101  m_overlap = this->getBitMaskValue( &sectorRoIOvl, BarrelOvlMask );
102  } else if ( m_sysID == 2 ) { // Forward
103  m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumForwardMask );
104  m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, ForwardRoIMask );
105  m_overlap = 0;
106  } else if ( m_sysID == 1 ) { // Endcap
107  m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumEndcapMask );
108  m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, EndcapRoIMask );
109  m_overlap = this->getBitMaskValue( &sectorRoIOvl, EndcapOvlMask );
110  }
111 
112  // set RecMuonRoiSvc pointer
113  const RecMuonRoiSvc* l_recMuonRoiSvc;
114 
115  if( m_sysID == 0 ) { // RPC
116  l_recMuonRoiSvc = theRecRPCRoiSvc;
117  } else { // TGC
118  l_recMuonRoiSvc = theRecTGCRoiSvc;
119  }
120 
121  if( l_recMuonRoiSvc ) {
122  // set eta and phi values
123  l_recMuonRoiSvc->reconstruct( roIWord );
124  m_eta = l_recMuonRoiSvc->eta();
125  m_phi = l_recMuonRoiSvc->phi();
126  }
127 
128  // Get the threshold value
129  // Don't bother casting TriggerThresholdValue to MuonThresholdValue as the latter
130  // currently only adds a printout function
131  m_thresholdValue = 0;
132  for( std::vector< TriggerThreshold* >::const_iterator it = theMuonConfig->begin();
133  it != theMuonConfig->end(); ++it ) {
134  if( ( *it )->type() == L1DataDef::muonType() &&
135  ( *it )->thresholdNumber() + 1 == static_cast< int >( m_thresholdNumber ) ) {
136 
137  TriggerThresholdValue* ttv = ( *it )->triggerThresholdValue( 0, 0 );
138  m_thresholdValue = static_cast< unsigned int >( ttv->ptcut() );
139  }
140  }
141 }
142 
143 void
144 LVL1::RecMuonRoI::construct( unsigned int roIWord,
145  const LVL1::ITrigT1MuonRecRoiTool* theRecRPCRoiTool,
146  const LVL1::ITrigT1MuonRecRoiTool* theRecTGCRoiTool,
147  const std::vector< TriggerThreshold* >* theMuonConfig )
148 {
149  m_roiWord = roIWord;
150  m_firstCandidateFlag = false;
151  m_sectorOflFlag = false;
152  m_padOflFlag = false;
153  m_eta = 0;
154  m_phi = 0;
155 
156  // first extract the parts holding the sector address and
157  // and the RoI/Overlap from the 32 bit word
158  unsigned int sectorAddress = this->getBitMaskValue( &m_roiWord, SectorAddressMask );
159  unsigned int sectorRoIOvl = this->getBitMaskValue( &m_roiWord, RoIOvlMask );
160 
161  // the first candidate flag
162  if ( this->getBitMaskValue( &m_roiWord, FirsCandMask ) == 1 ) {
163  m_firstCandidateFlag = true;
164  }
165 
166  // the sector overflow flag
167  if ( this->getBitMaskValue( &m_roiWord, SectOflMask ) == 1 ) {
168  m_sectorOflFlag = true;
169  }
170 
171  // the pad overflow flag
172  if ( this->getBitMaskValue( &m_roiWord, PadOflMask ) == 1 ) {
173  m_padOflFlag = true;
174  }
175 
176  // the pt threshold number
177  m_thresholdNumber = this->getBitMaskValue( &m_roiWord, ThresNumMask );
178 
179  // the RoI and sector ID encoding is system dependent - need 3 cases
180 
181  unsigned int temp_sysID = this->getBitMaskValue( &sectorAddress, SysIDMask );
182  m_sysID = 0; // The default is the barrel
183  if( temp_sysID & 0x2 ) m_sysID = 1; // If the higher bit is set, it's from the endcap region
184  else if( temp_sysID & 0x1 ) m_sysID = 2; // if the lower bit is set, it's from the forward region
185 
186  m_subSysID = this->getBitMaskValue( &sectorAddress, SubSysIDMask );
187  if ( m_sysID == 0 ) { // Barrel
188  m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumBarrelMask );
189  m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, BarrelRoIMask );
190  m_overlap = this->getBitMaskValue( &sectorRoIOvl, BarrelOvlMask );
191  } else if ( m_sysID == 2 ) { // Forward
192  m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumForwardMask );
193  m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, ForwardRoIMask );
194  m_overlap = 0;
195  } else if ( m_sysID == 1 ) { // Endcap
196  m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumEndcapMask );
197  m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, EndcapRoIMask );
198  m_overlap = this->getBitMaskValue( &sectorRoIOvl, EndcapOvlMask );
199  }
200 
201  if( m_sysID == 0 ) { // RPC
202  if( theRecRPCRoiTool ) {
203  // set eta and phi values
205  if( theRecRPCRoiTool->roiData( roIWord, roiData ).isSuccess() ){
206  m_eta = roiData.eta();
207  m_phi = roiData.phi();
208  }
209  }
210  } else { // TGC
211  if( theRecTGCRoiTool ) {
212  // set eta and phi values
214  if( theRecTGCRoiTool->roiData( roIWord, roiData ).isSuccess() ){
215  m_eta = roiData.eta();
216  m_phi = roiData.phi();
217  }
218  }
219  }
220 
221  // Get the threshold value
222  // Don't bother casting TriggerThresholdValue to MuonThresholdValue as the latter
223  // currently only adds a printout function
224  m_thresholdValue = 0;
225  for(const TrigConf::TriggerThreshold* thr : *theMuonConfig) {
226  if( thr->type() == L1DataDef::muonType() &&
227  thr->thresholdNumber() + 1 == static_cast< int >( m_thresholdNumber ) ) {
228 
229  TrigConf::TriggerThresholdValue* ttv = thr->triggerThresholdValue( 0, 0 );
230  m_thresholdValue = static_cast< unsigned int >( ttv->ptcut() );
231  }
232  }
233 }
234 
235 void
236 LVL1::RecMuonRoI::construct( unsigned int roIWord,
237  const LVL1::ITrigT1MuonRecRoiTool* theRecRPCRoiTool,
238  const LVL1::ITrigT1MuonRecRoiTool* theRecTGCRoiTool,
239  const TrigConf::L1Menu * const l1menu )
240 {
241  m_roiWord = roIWord;
242  m_firstCandidateFlag = false;
243  m_sectorOflFlag = false;
244  m_padOflFlag = false;
245  m_eta = 0;
246  m_phi = 0;
247 
248  // first extract the parts holding the sector address and
249  // and the RoI/Overlap from the 32 bit word
250  unsigned int sectorAddress = this->getBitMaskValue( &m_roiWord, SectorAddressMask );
251  unsigned int sectorRoIOvl = this->getBitMaskValue( &m_roiWord, RoIOvlMask );
252 
253  // the first candidate flag
254  if ( this->getBitMaskValue( &m_roiWord, FirsCandMask ) == 1 ) {
255  m_firstCandidateFlag = true;
256  }
257 
258  // the sector overflow flag
259  if ( this->getBitMaskValue( &m_roiWord, SectOflMask ) == 1 ) {
260  m_sectorOflFlag = true;
261  }
262 
263  // the pad overflow flag
264  if ( this->getBitMaskValue( &m_roiWord, PadOflMask ) == 1 ) {
265  m_padOflFlag = true;
266  }
267 
268  // the pt threshold number
269  m_thresholdNumber = this->getBitMaskValue( &m_roiWord, ThresNumMask );
270 
271  // the RoI and sector ID encoding is system dependent - need 3 cases
272 
273  unsigned int temp_sysID = this->getBitMaskValue( &sectorAddress, SysIDMask );
274  m_sysID = 0; // The default is the barrel
275  if( temp_sysID & 0x2 ) m_sysID = 1; // If the higher bit is set, it's from the endcap region
276  else if( temp_sysID & 0x1 ) m_sysID = 2; // if the lower bit is set, it's from the forward region
277 
278  m_subSysID = this->getBitMaskValue( &sectorAddress, SubSysIDMask );
279  if ( m_sysID == 0 ) { // Barrel
280  m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumBarrelMask );
281  m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, BarrelRoIMask );
282  m_overlap = this->getBitMaskValue( &sectorRoIOvl, BarrelOvlMask );
283  } else if ( m_sysID == 2 ) { // Forward
284  m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumForwardMask );
285  m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, ForwardRoIMask );
286  m_overlap = 0;
287  } else if ( m_sysID == 1 ) { // Endcap
288  m_sectorID = this->getBitMaskValue( &sectorAddress, SectNumEndcapMask );
289  m_roiNumber = this->getBitMaskValue( &sectorRoIOvl, EndcapRoIMask );
290  m_overlap = this->getBitMaskValue( &sectorRoIOvl, EndcapOvlMask );
291  }
292 
293  // m_sysID == 0 (RPC) or 1 (TGC)
294  const ITrigT1MuonRecRoiTool* theRecRoiTool = (m_sysID == 0) ? theRecRPCRoiTool : theRecTGCRoiTool;
295  if( theRecRoiTool ) {
296  // set eta and phi values
298  if( theRecRoiTool->roiData( roIWord, roiData ).isSuccess() ){
299  m_eta = roiData.eta();
300  m_phi = roiData.phi();
301  }
302  }
303 
304  // Get the threshold value
305  m_thresholdValue = 0;
306  for( shared_ptr<TrigConf::L1Threshold> thr : l1menu->thresholds("MU")) {
307  auto muonThr = std::dynamic_pointer_cast<TrigConf::L1Threshold_MU>(thr);
308  if( muonThr->mapping() + 1 == m_thresholdNumber ) {
309  m_thresholdValue = muonThr->ptBarrel(); // for new muon thresholds this must be properly chosen, depending on the regiom
310  }
311  }
312 }
313 
316 
317  // If it's a barrel muon then we don't know its sign:
318  if( sysID() == 0 ) return UNDEFINED;
319 
320  if( m_roiWord & TGCCandidateSignMask ) {
321  return POSITIVE;
322  } else {
323  return NEGATIVE;
324  }
325 }
326 
327 bool
329 {
330  return ( m_roiWord & CandidateVetoMask );
331 }
332 
336 unsigned int
337 LVL1::RecMuonRoI::getBitMaskValue( const unsigned int * uintValue, const unsigned int mask )
338 {
339  unsigned int result;
340  unsigned int maskcopy;
341  // make a copy of the mask, because a mask is a mask and
342  // one should stay a mask (i.e. should be something constant!)
343  maskcopy = mask;
344  result = *uintValue & mask;
345  if ( mask != 0 ) {
346  while ( ( maskcopy & 0x00000001 ) == 0 ) {
347  maskcopy = maskcopy >> 1;
348  result = result >> 1;
349  }
350  }
351  return result;
352 }
353 
354 std::string
356 {
357  ostringstream out;
358  string system;
359  string hemisphere = "-";
360 
361  if ( this->sysID() == 0 ) {system = "B";}
362  if ( this->sysID() == 1 ) {system = "F";}
363  if ( this->sysID() > 1 ) {system = "E";}
364 
365  if ( this->subsysID() == 1 ) {hemisphere = "+";}
366 
367  out << " Addr: " << hemisphere << system << " "
368  << setw( 2 ) << ios::dec << this-> sectorID()
369  << " Pt/RoI: " << this->getThresholdNumber()
370  << " " << setw( 2 ) << this->getRoINumber() << std::setfill( ' ' )
371  << " Ovl: " << this->getOverlap()
372  << " pad/secOF: " << setw( 2 ) << this->padOverflow()
373  << setw( 2 ) << this->sectorOverflow()
374  << " First: " << this->firstCandidate();
375 
376  return out.str();
377 }
378 
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:337
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::RecMuonRoiSvc::eta
virtual double eta(void) const =0
pure virtual function returns eta coord of RoI
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)
Definition: RecMuonRoI.cxx:55
LVL1::RecMuonRoI::ChargeSign
ChargeSign
Charge sign of the muon candidate.
Definition: RecMuonRoI.h:64
skel.it
it
Definition: skel.GENtoEVGEN.py:423
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::RecMuonRoiSvc
Base class for the RPC and TGC RoI reconstruction services.
Definition: RecMuonRoiSvc.h:35
LVL1::RecMuonRoI::candidateVetoed
bool candidateVetoed() const
Returns true if the candidate was vetoed in the multiplicity sum.
Definition: RecMuonRoI.cxx:328
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::RecMuonRoiSvc::phi
virtual double phi(void) const =0
pure virtual function to return phi coord of RoI
RecMuonRoiSvc.h
LVL1::SectorAddressMask
@ SectorAddressMask
Definition: RecMuonRoI.h:38
L1DataDef.h
LVL1::EndcapOvlMask
@ EndcapOvlMask
Definition: RecMuonRoI.h:49
LVL1::SectNumForwardMask
@ SectNumForwardMask
Definition: RecMuonRoI.h:43
LVL1::BarrelOvlMask
@ BarrelOvlMask
Definition: RecMuonRoI.h:47
python.XMLReader.l1menu
l1menu
Definition: XMLReader.py:73
LVL1::RecMuonRoI::getDebugString
std::string getDebugString()
Definition: RecMuonRoI.cxx:355
LVL1::RecMuonRoI::candidateCharge
ChargeSign candidateCharge() const
Returns the change sign of the candidate.
Definition: RecMuonRoI.cxx:315
L1Menu.h
LVL1::RecMuonRoiSvc::reconstruct
virtual void reconstruct(const unsigned int &roiWord) const =0
pure virtual function for sub-detector-specific RoI reconstruction
TrigConf::TriggerThreshold
Definition: TriggerThreshold.h:20
LVL1::SectNumBarrelMask
@ SectNumBarrelMask
Definition: RecMuonRoI.h:41
LVL1::SysIDMask
@ SysIDMask
Definition: RecMuonRoI.h:39