Loading [MathJax]/jax/input/TeX/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TrigmuRoI.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "TrigmuRoI.h"
8 #include "CxxUtils/phihelper.h"
9 
10 // ================================================================================
11 // ================================================================================
12 
13 TrigmuRoI::TrigmuRoI(const std::string& name, ISvcLocator* pSvcLocator)
14  : AthReentrantAlgorithm(name, pSvcLocator)
15 {
16 }
17 
18 
19 // ================================================================================
20 // ================================================================================
21 
23 {
24 
25  // Retrieve the tools/services
31 
32  if (!m_monTool.empty()) {
33  ATH_MSG_DEBUG("Retrieving monTool");
34  CHECK(m_monTool.retrieve());
35  } else {
36  ATH_MSG_INFO("No monTool configured => NO MONITORING");
37  }
38 
39  return StatusCode::SUCCESS;
40 }
41 
42 
43 // ================================================================================
44 // ================================================================================
45 
46 unsigned int TrigmuRoI::getBitMaskValue( const unsigned int uintValue, const unsigned int mask ) const {
47  unsigned int result;
48  unsigned int maskcopy;
49  maskcopy = mask;
50  result = uintValue & mask;
51  if ( mask != 0 ) {
52  while ( ( maskcopy & 0x00000001 ) == 0 ) {
53  maskcopy = maskcopy >> 1;
54  result = result >> 1;
55  }
56  }
57  return result;
58 }
59 
60 
61 // ================================================================================
62 // ================================================================================
63 
64 StatusCode TrigmuRoI::readAndAppendTrigRoiDescriptors(const EventContext& ctx, TrigRoiDescriptorCollection* roiColl, const SG::ReadHandleKey<xAOD::MuonRoIContainer>& readHandleKey, int bc_shift, unsigned int& roi_id, std::vector<int>& RpcBCShift, std::vector<int>& TgcBCShift, std::vector<float>& RoIEta, std::vector<float>& RoIPhi) const
65 {
66 
67  // check validity of the key
68  if (readHandleKey.empty()) {
69  ATH_MSG_VERBOSE("Empty ReadHandleKey for the out-of-time muon RoIs.");
70  return StatusCode::SUCCESS;
71  }
72 
73  // create the read handle from the key
74  SG::ReadHandle<xAOD::MuonRoIContainer> rh_outOfTimeRoIs(readHandleKey, ctx);
75 
76  // check validity of the read handle
77  ATH_CHECK(rh_outOfTimeRoIs.isPresent());
78  ATH_CHECK(rh_outOfTimeRoIs.isValid());
79 
80  // loop over the RoIs
81  for (const xAOD::MuonRoI* roi : *rh_outOfTimeRoIs) {
82 
83  // debug messages
84  ATH_MSG_DEBUG("====== (late-muon) RoI debug info for out-of-time RoI =====");
85  ATH_MSG_DEBUG("out-of-time bunch crossing shift : " << bc_shift);
86  ATH_MSG_DEBUG("RoI ID (within TrigmuRoI) : " << roi_id);
87  ATH_MSG_DEBUG("RoI pT threshold : name: " << roi->thrName() << ", number: "<< roi->getThrNumber() << ", value: " << roi->thrValue());
88  ATH_MSG_DEBUG("RoI eta : " << roi->eta());
89  ATH_MSG_DEBUG("RoI phi : " << roi->phi());
90  ATH_MSG_DEBUG("RoI word : 0x" << MSG::hex << roi->roiWord() << MSG::dec);
91  ATH_MSG_DEBUG("Sector ID : " << roi->getSectorID());
92  ATH_MSG_DEBUG("Sector address : 0x" << MSG::hex << roi->getSectorAddress() << MSG::dec);
93  ATH_MSG_DEBUG("==========================================================");
94 
95  // fill monitoring collections: monitor the roi's eta and phi
96  RoIEta.push_back(roi->eta());
97  RoIPhi.push_back(roi->phi());
98 
99  // fill monitoring collections: construct the system ID
100  unsigned int temp_sysID = getBitMaskValue(roi->getSectorAddress(), LVL1::SysIDMask );
101  unsigned int sysID = 0; // Barrel
102  if( temp_sysID & 0x2 ) sysID = 1; // Endcap
103  else if( temp_sysID & 0x1 ) sysID = 2; // Forward
104 
105  // fill monitoring collections: monitor the covered bunch crossing shift values for RPC and TGC
106  if ( sysID == 0 ) RpcBCShift.push_back(bc_shift);
107  else TgcBCShift.push_back(bc_shift);
108 
109  // now create the new RoI descriptor and add it to the collection
110  roiColl->push_back(std::make_unique<TrigRoiDescriptor>(
111  roi->roiWord(), 0u, roi_id,
112  roi->eta(), roi->eta()-m_roiHalfWidthEta, roi->eta()+m_roiHalfWidthEta,
113  roi->phi(), CxxUtils::wrapToPi(roi->phi()-m_roiHalfWidthPhi), CxxUtils::wrapToPi(roi->phi()+m_roiHalfWidthPhi)
114  ));
115 
116  // bump up ID
117  roi_id += 1;
118  }
119 
120  // all done
121  return StatusCode::SUCCESS;
122 
123 }
124 
125 // ================================================================================
126 // ================================================================================
127 
128 StatusCode TrigmuRoI::execute(const EventContext& ctx) const
129 {
130 
131  // set up monitoring
132  std::vector<int> RpcBCShift, TgcBCShift;
133  std::vector<float> RoIEta, RoIPhi;
134  auto Rpc_OutOfTimeBCShift = Monitored::Collection("Rpc_OutOfTimeBCShift", RpcBCShift);
135  auto Tgc_OutOfTimeBCShift = Monitored::Collection("Tgc_OutOfTimeBCShift", TgcBCShift);
136  auto OutOfTimeRoI_Eta = Monitored::Collection("OutOfTimeRoI_Eta", RoIEta);
137  auto OutOfTimeRoI_Phi = Monitored::Collection("OutOfTimeRoI_Phi", RoIPhi);
138  auto mon = Monitored::Group(m_monTool, Rpc_OutOfTimeBCShift, Tgc_OutOfTimeBCShift, OutOfTimeRoI_Eta, OutOfTimeRoI_Phi);
139 
140  // make an empty roi descriptor collection
142  ATH_CHECK(wh_roiCollection.record(std::make_unique<TrigRoiDescriptorCollection>()));
143  TrigRoiDescriptorCollection* roiColl = wh_roiCollection.ptr();
144 
145  // set up an id counter
146  unsigned int roi_id = 0;
147 
148  // construct the trigger RoI descriptors for the four out-of-time bunch crossings (they are then added to the roiColl)
149  ATH_CHECK(readAndAppendTrigRoiDescriptors(ctx, roiColl, m_L1OutOfTimeRoIBCm2Key, -2, roi_id, RpcBCShift, TgcBCShift, RoIEta, RoIPhi));
150  ATH_CHECK(readAndAppendTrigRoiDescriptors(ctx, roiColl, m_L1OutOfTimeRoIBCm1Key, -1, roi_id, RpcBCShift, TgcBCShift, RoIEta, RoIPhi));
151  ATH_CHECK(readAndAppendTrigRoiDescriptors(ctx, roiColl, m_L1OutOfTimeRoIBCp1Key, +1, roi_id, RpcBCShift, TgcBCShift, RoIEta, RoIPhi));
152  ATH_CHECK(readAndAppendTrigRoiDescriptors(ctx, roiColl, m_L1OutOfTimeRoIBCp2Key, +2, roi_id, RpcBCShift, TgcBCShift, RoIEta, RoIPhi));
153 
154  // all done
155  return StatusCode::SUCCESS;
156 
157 }
158 
159 
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
TrigmuRoI::m_L1OutOfTimeRoIBCp1Key
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_L1OutOfTimeRoIBCp1Key
Definition: TrigmuRoI.h:31
TrigmuRoI::m_L1OutOfTimeRoIBCp2Key
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_L1OutOfTimeRoIBCp2Key
Definition: TrigmuRoI.h:32
TrigmuRoI::readAndAppendTrigRoiDescriptors
StatusCode readAndAppendTrigRoiDescriptors(const EventContext &ctx, TrigRoiDescriptorCollection *roiColl, const SG::ReadHandleKey< xAOD::MuonRoIContainer > &readHandleKey, int bc_shift, unsigned int &roi_id, std::vector< int > &RpcBCShift, std::vector< int > &TgcBCShift, std::vector< float > &RoIEta, std::vector< float > &RoIPhi) const
Definition: TrigmuRoI.cxx:64
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
get_generator_info.result
result
Definition: get_generator_info.py:21
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
RoIBResult.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
CxxUtils::wrapToPi
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition: phihelper.h:24
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
RecMuonRoI.h
roi_id
std::vector< QString > roi_id
Definition: VP1TriggerHandleL1.cxx:38
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::ReadHandleKey< xAOD::MuonRoIContainer >
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
TrigmuRoI::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigmuRoI.h:26
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
TrigmuRoI::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: TrigmuRoI.cxx:128
TrigmuRoI::m_roisWriteHandleKey
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
Definition: TrigmuRoI.h:28
TrigmuRoI::m_L1OutOfTimeRoIBCm1Key
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_L1OutOfTimeRoIBCm1Key
Definition: TrigmuRoI.h:30
TrigmuRoI::getBitMaskValue
unsigned int getBitMaskValue(const unsigned int uintValue, const unsigned int mask) const
Definition: TrigmuRoI.cxx:46
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::MuonRoI_v1
Class describing a LVL1 muon region of interest.
Definition: MuonRoI_v1.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
TrigmuRoI::initialize
virtual StatusCode initialize() override
Definition: TrigmuRoI.cxx:22
TrigmuRoI::TrigmuRoI
TrigmuRoI(const std::string &name, ISvcLocator *pSvcLocator)
std Gaudi algorthm constructor
Definition: TrigmuRoI.cxx:13
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TrigmuRoI.h
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
phihelper.h
Helper for azimuthal angle calculations.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
TrigmuRoI::m_roiHalfWidthPhi
Gaudi::Property< float > m_roiHalfWidthPhi
Definition: TrigmuRoI.h:35
SG::WriteHandle< TrigRoiDescriptorCollection >
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
TrigRoiDescriptorCollection
Definition: TrigRoiDescriptorCollection.h:21
plotBeamSpotMon.mon
mon
Definition: plotBeamSpotMon.py:67
SG::VarHandleBase::isPresent
bool isPresent() const
Is the referenced object present in SG?
Definition: StoreGate/src/VarHandleBase.cxx:400
TrigmuRoI::m_roiHalfWidthEta
Gaudi::Property< float > m_roiHalfWidthEta
Definition: TrigmuRoI.h:34
TrigmuRoI::m_L1OutOfTimeRoIBCm2Key
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_L1OutOfTimeRoIBCm2Key
Definition: TrigmuRoI.h:29
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
LVL1::SysIDMask
@ SysIDMask
Definition: RecMuonRoI.h:39