ATLAS Offline Software
Loading...
Searching...
No Matches
ViewCreatorDVROITool.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
10
12
14 const std::string& name,
15 const IInterface* parent)
16 : base_class(type, name, parent)
17{}
18
19
21 ATH_CHECK( m_roisWriteHandleKey.initialize() );
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Helper class to provide constant type-safe access to aux data.
size_type size() const noexcept
Returns the number of elements in the collection.
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Gaudi::Property< double > m_roiPhiWidth
ViewCreatorDVROITool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< double > m_roiZWidth
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_featureLinkName
virtual StatusCode attachROILinks(TrigCompositeUtils::DecisionContainer &decisions, const EventContext &ctx) const override
Tool interface method.
Gaudi::Property< double > m_roiEtaWidth
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition phihelper.h:24
SG::WriteHandle< CONT > createAndStoreNoAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx)
Creates and right away records the Container CONT with the key.
const std::string & roiString()
const std::string & featureString()
void findLinks(const Decision *start, const std::string &linkName, std::vector< LinkInfo< T > > &links, unsigned int behaviour=TrigDefs::allFeaturesOfType, std::set< const xAOD::TrigComposite * > *fullyExploredFrom=nullptr)
search back the TC links for the object of type T linked to the one of TC (recursively) Populates pro...
static const unsigned int lastFeatureOfType
Run 3 "enum". Only return the final feature along each route through the navigation.
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
Helper for azimuthal angle calculations.