ATLAS Offline Software
RoiUpdaterTool.cxx
Go to the documentation of this file.
1 
2 /*
3 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4 */
5 
7 #include "RoiUpdaterTool.h"
8 
9 
10 
11 RoiUpdaterTool::RoiUpdaterTool(const std::string& type, const std::string& name, const IInterface* parent)
12  : base_class(type, name, parent), m_update(false)
13 {}
14 
15 
16 
18 
19  ATH_MSG_DEBUG("initialize()");
20 
21  if ( m_etaWidth!=-999 || m_phiWidth!=-999 || m_zedWidth!=-999 ) m_update = true;
22 
23  if ( m_useBeamspot ) {
24  m_update = true;
26  }
27 
28  return StatusCode::SUCCESS;
29 }
30 
31 
32 
33 void zrange( double nsigma, double fence, double& zed, double& zedMinus, double& zedPlus, const SG::ReadCondHandleKey<InDet::BeamSpotData>& bs, const EventContext& ctx ) {
34 
35  SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle( bs, ctx );
36 
37  uint32_t bitmap = beamSpotHandle->beamStatus();
38 
40  if ( ( (bitmap & 0x7) == 0x7 ) || !(bitmap & 0x4) ) {
41  double zsigma = beamSpotHandle->beamSigma(2);
42  double zpos = beamSpotHandle->beamPos()[2];
43 
44  zed = zpos;
45  zedMinus = zpos - nsigma*zsigma - fence;
46  zedPlus = zpos + nsigma*zsigma + fence;
47  }
48  else {
49  zedMinus = -RoiDescriptor::zedWidthDefault();
50  zedPlus = RoiDescriptor::zedWidthDefault();
51  }
52 
53 }
54 
55 
56 
57 
58 std::unique_ptr<TrigRoiDescriptor> RoiUpdaterTool::execute( const EventContext& ctx ) const {
61  return execute( &troi, ctx );
62 }
63 
64 
65 std::unique_ptr<TrigRoiDescriptor> RoiUpdaterTool::execute( const IRoiDescriptor* iroi, const EventContext& ctx ) const {
66 
67  ATH_MSG_DEBUG( "execute()" );
68 
71  if ( !m_update ) return std::make_unique<TrigRoiDescriptor>( *iroi );
72 
77  if ( iroi->composite() ) {
78  ATH_MSG_WARNING( "Will not update composite Roi parameters: " << *iroi );
79  return std::make_unique<TrigRoiDescriptor>( *iroi );
80  }
81 
82  double eta = iroi->eta();
83  double etaMinus = iroi->etaMinus();
84  double etaPlus = iroi->etaPlus();
85 
86  double phi = iroi->phi();
87  double phiMinus = iroi->phiMinus();
88  double phiPlus = iroi->phiPlus();
89 
90  double zed = iroi->zed();
91  double zedMinus = iroi->zedMinus();
92  double zedPlus = iroi->zedPlus();
93 
94  if ( m_etaWidth!=-999 ) {
95  etaMinus = eta - m_etaWidth;
96  etaPlus = eta + m_etaWidth;
97  }
98 
99  if ( m_phiWidth!=-999 ) {
102  phiMinus = phi - m_phiWidth;
103  phiPlus = phi + m_phiWidth;
104  }
105 
106  if ( m_zedWidth!=-999 ) {
107  zedMinus = zed - m_zedWidth;
108  zedPlus = zed + m_zedWidth;
109  }
110 
112  if ( m_useBeamspot ) zrange( m_nsigma, m_fence, zed, zedMinus, zedPlus, m_beamspotKey, ctx );
113 
115  if ( zedMinus<-RoiDescriptor::zedWidthDefault() ) zedMinus = -RoiDescriptor::zedWidthDefault();
116  if ( zedPlus> RoiDescriptor::zedWidthDefault() ) zedPlus = RoiDescriptor::zedWidthDefault();
117 
124  return std::make_unique<TrigRoiDescriptor>( eta, etaMinus, etaPlus, phi, phiMinus, phiPlus, zed, zedMinus, zedPlus );
125 
126 }
127 
IRoiDescriptor::phi
virtual double phi() const =0
Methods to retrieve data members.
RoiUpdaterTool::m_useBeamspot
Gaudi::Property< bool > m_useBeamspot
Definition: RoiUpdaterTool.h:46
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
RoiUpdaterTool::m_update
bool m_update
whether to update the RoiDescritor or not - determiuned from whether any of update parameters are set
Definition: RoiUpdaterTool.h:37
IRoiDescriptor::etaMinus
virtual double etaMinus() const =0
RoiUpdaterTool::RoiUpdaterTool
RoiUpdaterTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RoiUpdaterTool.cxx:11
IRoiDescriptor::etaPlus
virtual double etaPlus() const =0
RoiUpdaterTool::m_phiWidth
Gaudi::Property< double > m_phiWidth
Definition: RoiUpdaterTool.h:43
IRoiDescriptor::eta
virtual double eta() const =0
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IRoiDescriptor
Describes the API of the Region of Ineterest geometry.
Definition: IRoiDescriptor.h:23
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
RoiUpdaterTool::m_etaWidth
Gaudi::Property< double > m_etaWidth
don't want these parameters used if not set
Definition: RoiUpdaterTool.h:42
RoiUpdaterTool::m_nsigma
Gaudi::Property< double > m_nsigma
default settings - should be retuned with data
Definition: RoiUpdaterTool.h:48
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IRoiDescriptor::phiMinus
virtual double phiMinus() const =0
RoiDescriptor
Describes the Region of Ineterest geometry It has basically 9 parameters.
Definition: RoiDescriptor.h:40
IRoiDescriptor::phiPlus
virtual double phiPlus() const =0
extreme phi values
InDet::BeamSpotData::beamPos
const Amg::Vector3D & beamPos() const noexcept
Definition: BeamSpotData.h:68
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
RoiUpdaterTool::m_zedWidth
Gaudi::Property< double > m_zedWidth
Definition: RoiUpdaterTool.h:44
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
RoiUpdaterTool::m_beamspotKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamspotKey
do we need an mm unit here ?
Definition: RoiUpdaterTool.h:51
RoiUpdaterTool.h
zrange
void zrange(double nsigma, double fence, double &zed, double &zedMinus, double &zedPlus, const SG::ReadCondHandleKey< InDet::BeamSpotData > &bs, const EventContext &ctx)
Definition: RoiUpdaterTool.cxx:33
SG::ReadCondHandleKey< InDet::BeamSpotData >
RoiUpdaterTool::m_fence
Gaudi::Property< double > m_fence
Definition: RoiUpdaterTool.h:49
IRoiDescriptor::zedPlus
virtual double zedPlus() const =0
the zed and eta values at the most forward and most rear ends of the RoI
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
RoiUpdaterTool::initialize
virtual StatusCode initialize() override
Definition: RoiUpdaterTool.cxx:17
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
RoiDescriptor::zedWidthDefault
static double zedWidthDefault()
Definition: RoiDescriptor.h:183
RoiDescriptor::FULLSCAN
static constexpr bool FULLSCAN
convenient
Definition: RoiDescriptor.h:45
IRoiDescriptor::zed
virtual double zed() const =0
IRoiDescriptor::zedMinus
virtual double zedMinus() const =0
InDet::BeamSpotData::beamStatus
int beamStatus() const noexcept
Definition: BeamSpotData.h:76
TrigRoiDescriptorCollection.h
RoiUpdaterTool::execute
std::unique_ptr< TrigRoiDescriptor > execute(const EventContext &ctx) const override
Definition: RoiUpdaterTool.cxx:58
IRoiDescriptor::composite
virtual bool composite() const =0
Super RoI access methods.
InDet::BeamSpotData::beamSigma
float beamSigma(int i) const noexcept
Returns the beam sigma for the i-th error matrix element.
Definition: BeamSpotData.h:70