ATLAS Offline Software
ViewCreatorDVROITool.cxx
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "AthViews/ViewHelper.h"
8 #include "CxxUtils/phihelper.h"
9 #include "ViewCreatorDVROITool.h"
10 
12 
14  const std::string& name,
15  const IInterface* parent)
16  : base_class(type, name, parent)
17 {}
18 
19 
22 
23  return StatusCode::SUCCESS;
24 }
25 
26 
28  const EventContext& ctx ) const
29 {
30  ATH_MSG_DEBUG("ViewCreatorDVROITool::attachROILinks");
31  // ===================================================================================== //
32  // ===================================================================================== //
33  // Create output RoI collection
34 
36  // ===================================================================================== //
37  ATH_MSG_DEBUG("Create output RoI collection");
38 
39  // Only expect one object in container
40  if(decisions.size()!=1) {
41  ATH_MSG_DEBUG("Did not find exactly one decision object in decision container containing " << decisions.size() << " decisions");
42  }
43 
44  for (TrigCompositeUtils::Decision* outputDecision : decisions) {
45 
46  ATH_MSG_DEBUG("Loop over decisions");
47 
48  const std::vector< TrigCompositeUtils::LinkInfo<xAOD::TrigCompositeContainer> > dvSeedLinks = TrigCompositeUtils::findLinks< xAOD::TrigCompositeContainer >(outputDecision, TrigCompositeUtils::featureString(), TrigDefs::lastFeatureOfType);
49 
50  if (dvSeedLinks.size() != 1) {
51  ATH_MSG_DEBUG("Did not find exactly one most-recent " << m_featureLinkName << " for Decision object index "
52  << outputDecision->index() << ", found " << dvSeedLinks.size());
53  }
54 
55  for (const auto& dvLink : dvSeedLinks) {
56  // This is needed to merge the RoIs from each dv
57  std::unique_ptr<TrigRoiDescriptor> superRoI = std::make_unique<TrigRoiDescriptor>();
58  superRoI->setComposite(true);
59  superRoI->manageConstituents(true);
60 
61  if(!dvLink.link.isValid()) {
62  ATH_MSG_DEBUG("Received invalid hitDV link from decision object! " << m_featureLinkName << " : " << dvLink.link);
63  continue;
64  }
65 
66  ATH_MSG_DEBUG(" --- Find Link");
67  const xAOD::TrigCompositeContainer* dvCont = static_cast<const xAOD::TrigCompositeContainer*> ( (*dvLink.link)->container() );
68  ATH_MSG_DEBUG(" --- Found " << dvCont->size() << " presel DV seeds linked from decision object.");
69  ATH_MSG_DEBUG(" ");
70 
71  static const SG::ConstAccessor<float> hitDV_seed_etaAcc("hitDV_seed_eta");
72  static const SG::ConstAccessor<float> hitDV_seed_phiAcc("hitDV_seed_phi");
73  for(const xAOD::TrigComposite* dv : *dvCont) {
74  if ( !(hitDV_seed_etaAcc.isAvailable( *dv ) &&
75  hitDV_seed_etaAcc.isAvailable( *dv ) ) ) continue;
76 
77  float dvEta = hitDV_seed_etaAcc( *dv );
78  float dvPhi = hitDV_seed_phiAcc( *dv );
79 
80  ATH_MSG_DEBUG( "DV seed eta = " << dvEta <<
81  " phi = " << dvPhi );
82 
83  // create ROIs
84  ATH_MSG_DEBUG("Adding RoI to RoI container");
85  ATH_MSG_DEBUG( " ** Imposing Z constraint while building RoI" );
86  double etaMinus = dvEta - m_roiEtaWidth;
87  double etaPlus = dvEta + m_roiEtaWidth;
88 
89  double phiMinus = CxxUtils::wrapToPi( dvPhi - m_roiPhiWidth );
90  double phiPlus = CxxUtils::wrapToPi( dvPhi + m_roiPhiWidth );
91 
92  // Should retrieve beamspot offset from somewhere
93  double zMinus = -1. * m_roiZWidth;
94  double zPlus = m_roiZWidth;
95 
96  std::unique_ptr<TrigRoiDescriptor> newROI =
97  std::make_unique<TrigRoiDescriptor>( dvEta, etaMinus, etaPlus,
98  dvPhi, phiMinus, phiPlus,
99  0.,zMinus,zPlus );
100 
101  superRoI->push_back( newROI.release() );
102  }
103 
104 
105  roisWriteHandle->push_back(superRoI.release());
106  const ElementLink< TrigRoiDescriptorCollection > roiEL = ElementLink< TrigRoiDescriptorCollection >( *roisWriteHandle, roisWriteHandle->size() - 1, ctx );
107  outputDecision->setObjectLink( TrigCompositeUtils::roiString(), roiEL );
108 
109  ATH_MSG_DEBUG("PRINTING DECISION");
110  ATH_MSG_DEBUG( *outputDecision );
111  }
112  }
113 
114  ATH_MSG_DEBUG("return StatusCode::SUCCESS");
115  return StatusCode::SUCCESS;
116 }
ViewCreatorDVROITool.h
ViewCreatorDVROITool::ViewCreatorDVROITool
ViewCreatorDVROITool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: ViewCreatorDVROITool.cxx:13
PlotCalibFromCool.dv
dv
Definition: PlotCalibFromCool.py:762
TrigCompositeUtils.h
ViewCreatorDVROITool::m_roiEtaWidth
Gaudi::Property< double > m_roiEtaWidth
Definition: ViewCreatorDVROITool.h:48
CxxUtils::wrapToPi
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition: phihelper.h:24
SG::ConstAccessor< float >
ViewHelper.h
ViewCreatorDVROITool::m_roisWriteHandleKey
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
Definition: ViewCreatorDVROITool.h:42
RoiDescriptor::push_back
void push_back(const IRoiDescriptor *roi)
add a RoiDescriptor
Definition: RoiDescriptor.h:157
ViewCreatorDVROITool::m_roiZWidth
Gaudi::Property< double > m_roiZWidth
Definition: ViewCreatorDVROITool.h:55
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ViewCreatorDVROITool::attachROILinks
virtual StatusCode attachROILinks(TrigCompositeUtils::DecisionContainer &decisions, const EventContext &ctx) const override
Tool interface method.
Definition: ViewCreatorDVROITool.cxx:27
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
TrigCompositeUtils::createAndStoreNoAux
SG::WriteHandle< CONT > createAndStoreNoAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Creates and right away records the Container CONT with the key.
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:81
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:886
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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.
SG::WriteHandle< TrigRoiDescriptorCollection >
ViewCreatorDVROITool::initialize
virtual StatusCode initialize() override
Definition: ViewCreatorDVROITool.cxx:20
ViewCreatorDVROITool::m_roiPhiWidth
Gaudi::Property< double > m_roiPhiWidth
Definition: ViewCreatorDVROITool.h:51
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
RoiDescriptor::setComposite
void setComposite(bool b=true)
Definition: RoiDescriptor.h:138
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtilsRoot.cxx:878
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
RoiDescriptor::manageConstituents
bool manageConstituents() const
always manage constituents ???
Definition: RoiDescriptor.h:141
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TrigRoiDescriptorCollection.h
ViewCreatorDVROITool::m_featureLinkName
Gaudi::Property< std::string > m_featureLinkName
Definition: ViewCreatorDVROITool.h:45