ATLAS Offline Software
MuonRoI_v1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // xAOD include(s):
7 
8 // Local include(s):
10 
11 // get bitsmasks from common definition source:
13 using namespace LVL1::MuCTPIBits;
14 
15 namespace xAOD{
16 
17  MuonRoI_v1::MuonRoI_v1()
18  : SG::AuxElement() {
19 
20  }
21 
31  void MuonRoI_v1::initialize( uint32_t roiword, float eta, float phi,
32  const std::string& thrname, float thrvalue,
33  uint32_t extraword ) {
34 
35  setRoIWord( roiword );
36  setEta( eta );
37  setPhi( phi );
38  setThrValue( thrvalue );
39  setThrName( thrname );
40  setRoIExtraWord( extraword );
41  return;
42  }
43 
45  //
46  // Raw/simple data accessor functions
47  //
48 
52  setRoIWord )
54  setThrValue )
55 
57  setThrName )
58  // for Run-4+ only
60  setRoIExtraWord )
61  //
63 
65  //
66  // Implementation of the RoI word decoder functions
67  // available only in Run-1/2/3
68  //
69 
76  int MuonRoI_v1::getThrNumber() const {
77  if (isRun4()) return 0; // TBI
78  else if (isRun3()) return ( ( roiWord() >> RUN3_CAND_PT_SHIFT ) & RUN3_CAND_PT_MASK );
79  else return ( ( roiWord() >> CAND_PT_SHIFT ) & CAND_PT_MASK );
80  }
81 
89  int MuonRoI_v1::getRoI() const {
90  if (isRun4()) {
91  return 0; // TBI
92  } else if (isRun3()) {
93  if( this->getSource() == Forward ) {
94  return ( ( roiWord() >> RUN3_ROI_SHIFT ) & FORWARD_ROI_MASK );
95  } else if( this->getSource() == Endcap ) {
96  return ( ( roiWord() >> RUN3_ROI_SHIFT ) & ENDCAP_ROI_MASK );
97  } else if( this->getSource() == Barrel ) {
98  return ( ( roiWord() >> RUN3_ROI_SHIFT ) & BARREL_ROI_MASK );
99  }
100  } else {
101  if( this->getSource() == Forward ) {
102  return ( ( roiWord() >> ROI_SHIFT ) & FORWARD_ROI_MASK );
103  } else if( this->getSource() == Endcap ) {
104  return ( ( roiWord() >> ROI_SHIFT ) & ENDCAP_ROI_MASK );
105  } else if( this->getSource() == Barrel ) {
106  return ( ( roiWord() >> ROI_SHIFT ) & BARREL_ROI_MASK );
107  }
108  }
109  return 0;
110  }
111 
123  if (isRun4()) return 0; // TBI
124  else if (isRun3()) return ( ( roiWord() >> RUN3_CAND_SECTOR_ADDRESS_SHIFT ) & CAND_SECTOR_ADDRESS_MASK );
125  else return ( ( roiWord() >> CAND_SECTOR_ADDRESS_SHIFT ) & CAND_SECTOR_ADDRESS_MASK );
126  }
127 
134  if (isRun4()) {
135  return 0; // TBI
136  } else if (isRun3()) {
137  if( this->getSource() == Forward ) {
138  return ( ( roiWord() >> RUN3_CAND_SECTORID_SHIFT ) & FORWARD_SECTORID_MASK );
139  } else if( this->getSource() == Endcap ) {
140  return ( ( roiWord() >> RUN3_CAND_SECTORID_SHIFT ) & ENDCAP_SECTORID_MASK );
141  } else if( this->getSource() == Barrel ) {
142  return ( ( roiWord() >> RUN3_CAND_SECTORID_SHIFT ) & BARREL_SECTORID_MASK );
143  }
144  } else {
145  if( this->getSource() == Forward ) {
146  return ( ( roiWord() >> CAND_SECTORID_SHIFT ) & FORWARD_SECTORID_MASK );
147  } else if( this->getSource() == Endcap ) {
148  return ( ( roiWord() >> CAND_SECTORID_SHIFT ) & ENDCAP_SECTORID_MASK );
149  } else if( this->getSource() == Barrel ) {
150  return ( ( roiWord() >> CAND_SECTORID_SHIFT ) & BARREL_SECTORID_MASK );
151  }
152  }
153  return 0;
154  }
155 
164  if (isRun4()) return true; // TBI
165  else if (isRun3()) return true; // undefined in run3, return default true
166  else return ( ( roiWord() >> CAND_HIGHEST_PT_SHIFT ) & CAND_HIGHEST_PT_MASK );
167  }
168 
175  if (isRun4()) {
176  return false; // TBI
177  } else if (isRun3()) {
178  if (getSource() == Barrel) return ( ( roiWord() >> RUN3_ROI_OVERFLOW_SHIFT ) & ROI_OVERFLOW_MASK );
179  else return false; // Endcap + Fwd have no flag for this
180  } else {
181  return ( ( roiWord() >> ROI_OVERFLOW_SHIFT ) & ROI_OVERFLOW_MASK );
182  }
183  }
184 
191  if (isRun4()) return false; // TBI
192  else if (isRun3()) return ( ( roiWord() >> RUN3_CAND_OVERFLOW_SHIFT ) & CAND_OVERFLOW_MASK );
193  else return ( ( roiWord() >> CAND_OVERFLOW_SHIFT ) & CAND_OVERFLOW_MASK );
194  }
195 
203  if (isRun4()) return Barrel; // TBI - not correct
204  //same mask for run2 and run3
205  if( this->getSectorAddress() & ENDCAP_ADDRESS_MASK ) {
206  return Endcap;
207  } else if( this->getSectorAddress() & FORWARD_ADDRESS_MASK ) {
208  return Forward;
209  } else {
210  return Barrel;
211  }
212  }
213 
221  if (isRun4()) return Positive; // TBI - not correct
222  //same mask for run2 and run3
223  if( this->getSectorAddress() & SECTOR_HEMISPHERE_MASK ) {
224  return Positive;
225  } else {
226  return Negative;
227  }
228  }
229 
235  if (isRun4()) return false; // TBI
236  if (isRun3()) {
237  if (getSource() == Barrel) return (roiWord() >> RUN3_CAND_WORD_CANDFLAGS_BA_PHIOVERLAP_SHIFT) & RUN3_CAND_WORD_CANDFLAGS_BA_PHIOVERLAP_MASK;
238  else return false;
239  } else {
240  if (getSource() == Barrel) return (roiWord() >> BARREL_OL_SHIFT) & BARREL_PHI_OL_MASK;
241  else return false;
242  }
243  }
244 
250  if (isRun4()) return false; // TBI
251  if (isRun3()) return false;
252  else {
253  if (getSource() == Barrel) return (roiWord() >> BARREL_OL_SHIFT) & BARREL_ETA_OL_MASK;
254  else return (roiWord() >> ENDCAP_OL_SHIFT) & ENDCAP_OL_MASK;
255  }
256  }
257 
265  if (isRun4()) {
266  return ((roiWord() >> CHARGE_SHIFT) & 0x1) ? Pos : Neg;
267  }
268 
269  if( getSource() == Barrel ) return Undef;
270 
271  if (isRun3()) {
272  if( ( roiWord() >> RUN3_CAND_TGC_CHARGE_SIGN_SHIFT) & 0x1 ) {
273  return Pos;
274  } else {
275  return Neg;
276  }
277  } else {
278  if( ( roiWord() >> CAND_TGC_CHARGE_SIGN_SHIFT) & 0x1 ) {
279  return Pos;
280  } else {
281  return Neg;
282  }
283  }
284  }
285 
290  if (isRun4()) return false; // TBI
291  if (isRun3() && getSource() != Barrel) return (roiWord() >> RUN3_CAND_TGC_BW2OR3_SHIFT) & 0x1;
292  else return false;
293  }
294 
295 
300  if (isRun4()) return false; // TBI
301  if (isRun3() && getSource() != Barrel) return (roiWord() >> RUN3_CAND_TGC_INNERCOIN_SHIFT) & 0x1;
302  else return false;
303  }
304 
305 
309  bool MuonRoI_v1::getGoodMF() const {
310  if (isRun4()) return false; // TBI
311  if (isRun3() && getSource() != Barrel) return (roiWord() >> RUN3_CAND_TGC_GOODMF_SHIFT) & 0x1;
312  else return false;
313  }
314 
319  bool MuonRoI_v1::isVetoed() const {
320  if (isRun4()) return false; // TBI
321  if (isRun3()) return ( ( roiWord() >> RUN3_CAND_VETO_SHIFT) & 0x1 );
322  else return ( ( roiWord() >> CAND_VETO_SHIFT) & 0x1 );
323  }
324 
328  bool MuonRoI_v1::isRun3() const {
329  return isRun4() ? false : (roiWord() >> 31 & 0x1);
330  }
331 
332  //
334 
336  //
337  // Implementation for Run-4+ only RoI interfaces
338  //
339 
342  float MuonRoI_v1::pt() const {
343  if (isRun4()) return static_cast<float>((roiWord() >> PT_SHIFT) & PT_MASK) * PT_WIDTH;
344  else return 0.;
345  }
346 
349  bool MuonRoI_v1::isRun4() const {
350  static const Accessor<uint32_t> acc{"roiExtraWord"};
351  if (!acc.isAvailable(*this)) {
352  return false;
353  } else {
354  return (roiExtraWord() > 0);
355  }
356  }
357 
358 } // namespace xAOD
xAOD::MuonRoI_v1::isRun4
bool isRun4() const
flag whether it is Run4+ RoI definition
Definition: MuonRoI_v1.cxx:349
xAOD::MuonRoI_v1::PT_WIDTH
static constexpr float PT_WIDTH
Definition: MuonRoI_v1.h:157
xAOD::MuonRoI_v1::initialize
void initialize(uint32_t roiword, float eta, float phi, const std::string &thrname, float thrvalue, uint32_t extraword=0u)
Initialise the object with all its properties.
Definition: MuonRoI_v1.cxx:31
xAOD::AUXSTORE_PRIMITIVE_SETTER_AND_GETTER
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
xAOD::MuonRoI_v1::getSectorAddress
int getSectorAddress() const
Get the full sector address.
Definition: MuonRoI_v1.cxx:122
xAOD::MuonRoI_v1::getPhiOverlap
bool getPhiOverlap() const
Returns whether there's overlap between barrel sectors.
Definition: MuonRoI_v1.cxx:234
xAOD::MuonRoI_v1::Endcap
@ Endcap
The muon candidate was detected in the endcap region.
Definition: MuonRoI_v1.h:35
xAOD::MuonRoI_v1::getInnerCoincidence
bool getInnerCoincidence() const
Returns whether or not there was an inner coincidence in the TGC.
Definition: MuonRoI_v1.cxx:299
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
AuxStoreAccessorMacros.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
xAOD::MuonRoI_v1::Neg
@ Neg
Candidate is a mu- from a TGC sector.
Definition: MuonRoI_v1.h:45
xAOD::MuonRoI_v1::getCharge
Charge getCharge() const
Returns the charge sign of the muon candidate.
Definition: MuonRoI_v1.cxx:264
xAOD::MuonRoI_v1::eta
float eta() const
The pseudorapidity ( ) of the muon candidate.
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::MuonRoI_v1::getHemisphere
Hemisphere getHemisphere() const
Returns the hemisphere that detected the muon candidate.
Definition: MuonRoI_v1.cxx:220
xAOD::MuonRoI_v1::setPhi
void setPhi(float v)
Set the azimuthal angle of the muon candidate.
xAOD::MuonRoI_v1::setRoIWord
void setRoIWord(uint32_t value)
Set the "raw" RoI word, describing the muon candidate.
Amg::setPhi
Amg::RotationMatrix3D setPhi(Amg::RotationMatrix3D mat, double angle, int convention=0)
Definition: EulerAnglesHelpers.h:102
xAOD::MuonRoI_v1::PT_MASK
static constexpr uint32_t PT_MASK
Definition: MuonRoI_v1.h:149
xAOD::phi
setEt phi
Definition: TrigEMCluster_v1.cxx:29
xAOD::roiWord
roiWord
Definition: TrigMissingET_v1.cxx:36
xAOD::MuonRoI_v1::isRun3
bool isRun3() const
Returns extra flag at end of RoI word indicating that it's in Run3 format.
Definition: MuonRoI_v1.cxx:328
xAOD::MuonRoI_v1::isMoreCandInRoI
bool isMoreCandInRoI() const
Returns if there were other muons detected in the same RoI.
Definition: MuonRoI_v1.cxx:174
xAOD::MuonRoI_v1::isVetoed
bool isVetoed() const
Returns the veto flag for the candidate.
Definition: MuonRoI_v1.cxx:319
xAOD::MuonRoI_v1::PT_SHIFT
static constexpr uint32_t PT_SHIFT
Definition: MuonRoI_v1.h:155
xAOD::MuonRoI_v1::setThrName
void setThrName(const std::string &value)
Set the name of the threshold passed by the muon candidate.
MuonRoI_v1.h
xAOD::MuonRoI_v1
Class describing a LVL1 muon region of interest.
Definition: MuonRoI_v1.h:29
xAOD::MuonRoI_v1::getSource
RoISource getSource() const
Returns the system that detected the muon candidate.
Definition: MuonRoI_v1.cxx:202
xAOD::MuonRoI_v1::setThrValue
void setThrValue(float v)
Set the threshold value passed by the muon candidate.
xAOD::MuonRoI_v1::Undef
@ Undef
This is an RPC candidate.
Definition: MuonRoI_v1.h:47
xAOD::MuonRoI_v1::getRoI
int getRoI() const
Get the "RoI number" (position inside the sector)
Definition: MuonRoI_v1.cxx:89
xAOD::MuonRoI_v1::setRoIExtraWord
void setRoIExtraWord(uint32_t value)
Set the second "raw" RoI word, describing extra information of the muon candidate.
xAOD::MuonRoI_v1::Charge
Charge
Charge sign.
Definition: MuonRoI_v1.h:44
xAOD::MuonRoI_v1::Barrel
@ Barrel
The muon candidate was detected in the barrel region.
Definition: MuonRoI_v1.h:34
xAOD::MuonRoI_v1::Negative
@ Negative
The candidate came from the -z side (side C)
Definition: MuonRoI_v1.h:41
xAOD::MuonRoI_v1::pt
float pt() const
the transverse momentum of the muon candidate
Definition: MuonRoI_v1.cxx:342
xAOD::roiExtraWord
setThrValue roiExtraWord
Definition: MuonRoI_v1.cxx:59
MuCTPI_Bits.h
xAOD::MuonRoI_v1::RoISource
RoISource
RoI source enumeration.
Definition: MuonRoI_v1.h:33
xAOD::MuonRoI_v1::isMoreCandInSector
bool isMoreCandInSector() const
Returns if there were other muons detected in the same sector.
Definition: MuonRoI_v1.cxx:190
xAOD::MuonRoI_v1::isFirstCandidate
bool isFirstCandidate() const
Returns if the candidate had the highest pT in the sector.
Definition: MuonRoI_v1.cxx:163
xAOD::MuonRoI_v1::Hemisphere
Hemisphere
RoI hemisphere enumeration.
Definition: MuonRoI_v1.h:39
LVL1::MuCTPIBits
Definition: HelpersPhase1.h:14
xAOD::MuonRoI_v1::Forward
@ Forward
The muon candidate was detected in the forward region.
Definition: MuonRoI_v1.h:36
xAOD::MuonRoI_v1::getBW3Coincidence
bool getBW3Coincidence() const
Returns whether or not there was a 3-station coincidence in the TGC.
Definition: MuonRoI_v1.cxx:289
xAOD::MuonRoI_v1::roiExtraWord
uint32_t roiExtraWord() const
The second "raw" RoI word describing extra information of the muon candidate.
xAOD::MuonRoI_v1::getSectorID
int getSectorID() const
Get the sector ID number.
Definition: MuonRoI_v1.cxx:133
xAOD::thrValue
thrValue
Definition: MuonRoI_v1.cxx:53
xAOD::MuonRoI_v1::CHARGE_SHIFT
static constexpr uint32_t CHARGE_SHIFT
Definition: MuonRoI_v1.h:154
xAOD::MuonRoI_v1::setEta
void setEta(float v)
Set the pseudorapidity of the muon candidate.
xAOD::MuonRoI_v1::Pos
@ Pos
Candidate is a mu+ from a TGC sector.
Definition: MuonRoI_v1.h:46
xAOD::MuonRoI_v1::Positive
@ Positive
The candidate came from the +z side (side A)
Definition: MuonRoI_v1.h:40
xAOD::MuonRoI_v1::roiWord
uint32_t roiWord() const
The "raw" RoI word describing the muon candidate.
xAOD::MuonRoI_v1::getEtaOverlap
bool getEtaOverlap() const
Returns whether there's overlap between the barrel-EC sectors.
Definition: MuonRoI_v1.cxx:249
xAOD::MuonRoI_v1::getGoodMF
bool getGoodMF() const
Returns whether or not there was a good magnetic field quality in the TGC.
Definition: MuonRoI_v1.cxx:309
xAOD::AUXSTORE_OBJECT_SETTER_AND_GETTER
AUXSTORE_OBJECT_SETTER_AND_GETTER(CaloRings_v1, RingSetLinks, ringSetLinks, setRingSetLinks) unsigned CaloRings_v1
Definition: CaloRings_v1.cxx:27
xAOD::MuonRoI_v1::phi
float phi() const
The azimuthal angle ( ) of the muon candidate.