ATLAS Offline Software
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  ATH_MSG_DEBUG("MinValueForOutOfTimeBC: "<<m_minValueForOutOfTimeBC);
26  ATH_MSG_DEBUG("MaxValueForOutOfTimeBC: "<<m_maxValueForOutOfTimeBC);
27 
28  // Retrieve the tools/services
29  ATH_CHECK(m_trigMuonRoITool.retrieve());
30  ATH_CHECK(m_recRPCRoiTool.retrieve());
31  ATH_CHECK(m_recTGCRoiTool.retrieve());
33 
34  if (!m_monTool.empty()) {
35  ATH_MSG_DEBUG("Retrieving monTool");
36  CHECK(m_monTool.retrieve());
37  } else {
38  ATH_MSG_INFO("No monTool configured => NO MONITORING");
39  }
40 
41  return StatusCode::SUCCESS;
42 }
43 
44 // ================================================================================
45 // ================================================================================
46 
47 unsigned int TrigmuRoI::getBitMaskValue( const unsigned int uintValue, const unsigned int mask ) const {
48  unsigned int result;
49  unsigned int maskcopy;
50  maskcopy = mask;
51  result = uintValue & mask;
52  if ( mask != 0 ) {
53  while ( ( maskcopy & 0x00000001 ) == 0 ) {
54  maskcopy = maskcopy >> 1;
55  result = result >> 1;
56  }
57  }
58  return result;
59 }
60 
61 // ================================================================================
62 // ================================================================================
63 
64 StatusCode TrigmuRoI::execute(const EventContext& ctx) const
65 {
66 
67  std::vector<int> outOfTimeRpc, outOfTimeTgc;
68  std::vector<float> etaRoI, phiRoI;
69  auto rpcOutOfTime = Monitored::Collection("RpcOutOfTime", outOfTimeRpc);
70  auto tgcOutOfTime = Monitored::Collection("TgcOutOfTime", outOfTimeTgc);
71  auto etaOutOfTimeRoI = Monitored::Collection("EtaOutOfTime", etaRoI);
72  auto phiOutOfTimeRoI = Monitored::Collection("PhiOutOfTime", phiRoI);
73 
74  auto mon = Monitored::Group(m_monTool, rpcOutOfTime, tgcOutOfTime, etaOutOfTimeRoI, phiOutOfTimeRoI);
75 
76  int roi_id = 0;
77 
78  //--------------------------------------------------------------------------
79  // Gather the Muon RoIs out of time by the
80  //--------------------------------------------------------------------------
81 
83  ATH_CHECK(wh_roiCollection.record(std::make_unique<TrigRoiDescriptorCollection>()));
84  auto roiColl = wh_roiCollection.ptr();
85 
86  //get rois and loop over out of time rois
87  auto roiVectors = m_trigMuonRoITool->decodeMuCTPi(ctx);
88  if(!roiVectors){
89  ATH_MSG_VERBOSE("No RoIs found");
90  return StatusCode::SUCCESS;
91  }
92  for(auto it : roiVectors->outOfTimeRois){
93 
94  if (msgLvl(MSG::DEBUG)) {
95  ATH_MSG_DEBUG(" Difference(RoI(BCID) - Event(BCID)) = " << (it).second);
96  ATH_MSG_DEBUG(" ------------------------------------- ");
97  ATH_MSG_DEBUG("RoIB word : 0x" << MSG::hex << ((it).first).roIWord() << MSG::dec);
98  ATH_MSG_DEBUG("Threshold : pt" << ((it).first).pt());
99  ATH_MSG_DEBUG("Sector ID : " << ((it).first).getSectorID());
100  ATH_MSG_DEBUG("Sector addr : 0x" << MSG::hex << ((it).first).getSectorAddress() << MSG::dec);
101  ATH_MSG_DEBUG("Sector overflow : " << ((it).first).getSectorOverflow());
102  ATH_MSG_DEBUG("RoI overflow : " << ((it).first).getRoiOverflow());
103  ATH_MSG_DEBUG("RoI number : " << ((it).first).getRoiNumber());
104  ATH_MSG_DEBUG("IsHighestPt : " << ((it).first).getCandidateIsHighestPt());
105  ATH_MSG_DEBUG("=================================================");
106  }
107 
108  unsigned int temp_sysID = getBitMaskValue(((it).first).getSectorAddress(), LVL1::SysIDMask );
109  unsigned int sysID = 0; // Barrel
110  if( temp_sysID & 0x2 ) sysID = 1; // Endcap
111  else if( temp_sysID & 0x1 ) sysID = 2; // Forward
112 
113 
114  if ( sysID == 0 ) outOfTimeRpc.push_back((it).second);
115  else outOfTimeTgc.push_back((it).second);
116 
118  //std::string region = "";
119  if( sysID == 0 ) {
120  ATH_CHECK( m_recRPCRoiTool->roiData(((it).first).roIWord(),roiData) );
121  //region = "Barrel region";
122  } else if ( sysID == 1 ){
123  ATH_CHECK( m_recTGCRoiTool->roiData(((it).first).roIWord(),roiData) );
124  //region = "Endcap region";
125  } else {
126  ATH_CHECK( m_recTGCRoiTool->roiData(((it).first).roIWord(),roiData) );
127  //region = "Forward region";
128  }
129 
130  // create new trigger element for this out of time RoI
131  double eta = roiData.eta();
132  double phi = roiData.phi();
133  etaRoI.push_back(eta);
134  phiRoI.push_back(phi);
135 
136  double etamin = eta - 0.2;
137  double etamax = eta + 0.2;
138  double phimin = CxxUtils::wrapToPi(phi - 0.2);
139  double phimax = CxxUtils::wrapToPi(phi + 0.2);
140 
143 
144  // generic TrigRoiDescriptor
145  auto roiDescriptor = new TrigRoiDescriptor( ((it).first).roIWord(), 0, roi_id, eta, etamin, etamax, phi, phimin, phimax,0,-255,255);
146  roiColl->push_back(roiDescriptor);
147 
148  ATH_MSG_DEBUG("Created RoI descriptor with id, eta, phi: "<<roi_id<<" "<<eta<<" "<<phi);
149  }
150  roi_id += 1;
151  }
152 
153  return StatusCode::SUCCESS;
154 }
155 
LVL1::TrigT1MuonRecRoiData
Definition: TrigT1MuonRecRoiData.h:10
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
get_generator_info.result
result
Definition: get_generator_info.py:21
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
RoIBResult.h
TrigmuRoI::m_recRPCRoiTool
ToolHandle< LVL1::ITrigT1MuonRecRoiTool > m_recRPCRoiTool
Definition: TrigmuRoI.h:26
TrigmuRoI::m_trigMuonRoITool
ToolHandle< ITrigMuonRoITool > m_trigMuonRoITool
Definition: TrigmuRoI.h:25
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
TrigmuRoI::m_recTGCRoiTool
ToolHandle< LVL1::ITrigT1MuonRecRoiTool > m_recTGCRoiTool
Definition: TrigmuRoI.h:27
CxxUtils::wrapToPi
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition: phihelper.h:24
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
skel.it
it
Definition: skel.GENtoEVGEN.py:396
test_pyathena.pt
pt
Definition: test_pyathena.py:11
LVL1::TrigT1MuonRecRoiData::eta
double eta(void) const
Definition: TrigT1MuonRecRoiData.h:22
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
RecMuonRoI.h
TrigmuRoI::m_minValueForOutOfTimeBC
Gaudi::Property< int > m_minValueForOutOfTimeBC
Definition: TrigmuRoI.h:32
TrigmuRoI::m_maxValueForOutOfTimeBC
Gaudi::Property< int > m_maxValueForOutOfTimeBC
Definition: TrigmuRoI.h:33
roi_id
std::vector< QString > roi_id
Definition: VP1TriggerHandleL1.cxx:38
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TrigmuRoI::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: TrigmuRoI.h:31
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:83
TrigmuRoI::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: TrigmuRoI.cxx:64
TrigmuRoI::m_roisWriteHandleKey
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
Definition: TrigmuRoI.h:29
TrigmuRoI::getBitMaskValue
unsigned int getBitMaskValue(const unsigned int uintValue, const unsigned int mask) const
Definition: TrigmuRoI.cxx:47
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
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
LVL1::TrigT1MuonRecRoiData::phi
double phi(void) const
Definition: TrigT1MuonRecRoiData.h:23
TrigmuRoI.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
phihelper.h
Helper for azimuthal angle calculations.
SG::WriteHandle< TrigRoiDescriptorCollection >
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
DeMoScan.first
bool first
Definition: DeMoScan.py:536
DEBUG
#define DEBUG
Definition: page_access.h:11
plotBeamSpotMon.mon
mon
Definition: plotBeamSpotMon.py:67
TrigRoiDescriptor
Athena::TPCnvVers::Current TrigRoiDescriptor
Definition: TrigSteeringEventTPCnv.cxx:68
LArCellBinning.etamin
etamin
Definition: LArCellBinning.py:137
LVL1::SysIDMask
@ SysIDMask
Definition: RecMuonRoI.h:39