ATLAS Offline Software
Loading...
Searching...
No Matches
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"
9
10// ================================================================================
11// ================================================================================
12
13TrigmuRoI::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
26 ATH_CHECK(m_roisWriteHandleKey.initialize());
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
46unsigned 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
64StatusCode 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,
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
128StatusCode 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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
std::vector< QString > roi_id
An algorithm that can be simultaneously executed in multiple threads.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
Group of local monitoring quantities and retain correlation when filling histograms
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
bool isPresent() const
Is the referenced object present in SG?
bool empty() const
Test if the key is blank.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_L1OutOfTimeRoIBCp2Key
Definition TrigmuRoI.h:32
ToolHandle< GenericMonitoringTool > m_monTool
Definition TrigmuRoI.h:26
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
Definition TrigmuRoI.h:28
virtual StatusCode execute(const EventContext &ctx) const override
Gaudi::Property< float > m_roiHalfWidthPhi
Definition TrigmuRoI.h:35
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_L1OutOfTimeRoIBCp1Key
Definition TrigmuRoI.h:31
virtual StatusCode initialize() override
Definition TrigmuRoI.cxx:22
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_L1OutOfTimeRoIBCm2Key
Definition TrigmuRoI.h:29
unsigned int getBitMaskValue(const unsigned int uintValue, const unsigned int mask) const
Definition TrigmuRoI.cxx:46
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
SG::ReadHandleKey< xAOD::MuonRoIContainer > m_L1OutOfTimeRoIBCm1Key
Definition TrigmuRoI.h:30
TrigmuRoI(const std::string &name, ISvcLocator *pSvcLocator)
std Gaudi algorthm constructor
Definition TrigmuRoI.cxx:13
Gaudi::Property< float > m_roiHalfWidthEta
Definition TrigmuRoI.h:34
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition phihelper.h:24
@ SysIDMask
Definition RecMuonRoI.h:39
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
MuonRoI_v1 MuonRoI
Definition MuonRoI.h:15
Helper for azimuthal angle calculations.