 |
ATLAS Offline Software
|
Go to the documentation of this file.
8 #include "AthLinks/ElementLink.h"
33 ATH_MSG_ERROR(
"The EventViewCreatorAlgorithm class cannot be used as the InputMaker for an empty step.");
34 return StatusCode::FAILURE;
44 return StatusCode::SUCCESS;
59 ATH_CHECK( viewsHandle.record( std::make_unique<ViewContainer>() ) );
60 auto viewVector = viewsHandle.ptr();
69 cachedViews = cachedRH.
ptr();
76 std::vector<ElementLink<TrigRoiDescriptorCollection>> RoIsFromDecision;
78 if( outputHandle->
size() == 0) {
79 ATH_MSG_DEBUG(
"Have no decisions in output handle "<< outputHandle.
key() <<
". Handle is valid but container is empty. "
80 <<
"This can happen if a ROI-based HLT chain leg was activated in a chain whose L1 item which does not explicitly require the ROI.");
82 ATH_MSG_DEBUG(
"Have output " << outputHandle.
key() <<
" with " << outputHandle->
size() <<
" elements" );
88 for (
Decision* outputDecision : *outputHandle ) {
91 ATH_MSG_ERROR(
"No '" <<
roiString() <<
"'link was attached by the ROITool. Decision object dump:" << *outputDecision);
92 return StatusCode::FAILURE;
104 const bool useCached =
checkCache(cachedViews, outputDecision, cachedIndex, matchingCache);
107 auto roiIt =
find(RoIsFromDecision.begin(), RoIsFromDecision.end(), roiEL);
117 ATH_MSG_DEBUG(
"Re-using cached existing view from " << cachedViewEL.
dataID() <<
", index:" << cachedViewEL.
index() <<
" on ROI " << **cachedROIEL);
118 outputDecision->setObjectLink(
viewString(), cachedViewEL );
119 outputDecision->setObjectLink(
roiString(), cachedROIEL );
122 }
else if ( roiIt == RoIsFromDecision.end() ) {
125 RoIsFromDecision.push_back(roiEL);
126 ATH_MSG_DEBUG(
"Found RoI:" << **roiEL <<
" FS=" << (*roiEL)->isFullscan() <<
". Making View.");
128 viewVector->push_back( newView );
139 std::vector<LinkInfo<xAOD::MuonContainer>> muonELInfo = findLinks<xAOD::MuonContainer>(outputDecision,
featureString(), TrigDefs::lastFeatureOfType);
146 std::vector<LinkInfo<xAOD::JetContainer>> jetELInfo = findLinks<xAOD::JetContainer>(outputDecision,
featureString(), TrigDefs::lastFeatureOfType);
153 ATH_MSG_DEBUG(
"Made new View, storing view in viewVector " <<
m_viewsKey.key() <<
" index:" << viewVector->size()-1 );
158 const size_t existingIndex =
std::distance(RoIsFromDecision.begin(), roiIt);
159 ATH_MSG_DEBUG(
"Found existing View, stored in view in viewVector " <<
m_viewsKey.key() <<
" index:" << existingIndex );
166 ATH_MSG_DEBUG(
"Launching execution in " << viewVector->size() <<
" unique views" );
173 return StatusCode::SUCCESS;
177 if (ending.size() >
value.size()) {
184 return findLinks<ViewContainer>(outputDecision,
viewString(), TrigDefs::lastFeatureOfType);
195 std::vector<LinkInfo<ViewContainer>> previousStepViews = findLinks<ViewContainer>(outputDecision,
viewString(), TrigDefs::allFeaturesOfType);
197 if (previousStepViews.size()) {
200 const bool previousStepDidNotUsedCachedView =
endsWith(previousView.
dataID(),
"_probe");
201 if (previousStepDidNotUsedCachedView) {
203 ATH_MSG_DEBUG(
"Previous probe step used a probe EventView for this decision object. Do not attempt to use a cached EventView in this step.");
208 bool usedROIMatchingFlag{
false};
211 ATH_MSG_ERROR(
"Called matchInCollection in an EVCA configured with mergeUsingFeature=True, however ROI matching was used instead?! Should not be possible.");
226 std::vector<LinkInfo<ViewContainer>> viewsToLinkVector =
viewsToLink(outputDecision);
228 const SG::View* toLink = *(toLinkLI.link);
230 bool foundIt =
false;
231 for (
const SG::View* prevLinked :
view->getParentLinks()) {
232 if (prevLinked == toLink) {
238 ATH_MSG_DEBUG(
"The cached view from the tag step is not linked to the required views from earlier steps which we need in the probe processing, we cannot re-use it.");
250 for (
const Decision* cachedView : *cachedViews) {
253 return StatusCode::FAILURE;
259 return StatusCode::SUCCESS;
266 return StatusCode::SUCCESS;
270 ATH_MSG_ERROR(
"Called linkViewToParent on a Decision object which already has been given a '"
271 <<
viewString() <<
"' link. Call this fn BEFORE linking the new View.");
272 return StatusCode::FAILURE;
274 std::vector<LinkInfo<ViewContainer>> viewsToLinkVector =
viewsToLink(outputDecision);
275 if (viewsToLinkVector.size() == 0) {
276 ATH_MSG_ERROR(
"Could not find the parent View, but 'RequireParentView' is true.");
277 return StatusCode::FAILURE;
284 ATH_MSG_DEBUG(
"Will link " << viewsToLinkVector.size() <<
" parent view(s)" );
288 ATH_MSG_DEBUG(
"Parent view linked (" << toLinkLI.link.dataID() <<
", index:" << toLinkLI.link.index() <<
")" );
291 return StatusCode::SUCCESS;
296 auto oneRoIColl = std::make_unique< ConstDataVector<TrigRoiDescriptorCollection> >();
298 oneRoIColl->push_back( *roiEL );
304 ATH_CHECK( handle.record( std::move( oneRoIColl ) ) );
305 return StatusCode::SUCCESS;
312 auto oneObjectCollection = std::make_unique< xAOD::MuonContainer >();
313 auto oneObjectAuxCollection = std::make_unique< xAOD::MuonAuxContainer >();
314 oneObjectCollection->setStore( oneObjectAuxCollection.get() );
317 oneObjectCollection->push_back( copiedMuon );
318 *copiedMuon = *theObject;
320 auto muonCandidate = std::make_unique< ConstDataVector< MuonCandidateCollection > >();
323 if(msLink.isValid() && extTrackLink.isValid()) muonCandidate->push_back(
new MuonCombined::MuonCandidate(msLink, (*extTrackLink)->trackLink(), (*extTrackLink)->index()) );
327 ATH_CHECK( handleMuon.record( std::move( oneObjectCollection ), std::move( oneObjectAuxCollection )) );
330 ATH_CHECK( handleCandidate.record( std::move( muonCandidate ) ) );
332 return StatusCode::SUCCESS;
341 auto oneObjectCollection = std::make_unique< xAOD::JetContainer >();
342 auto oneObjectAuxCollection = std::make_unique< xAOD::JetAuxContainer >();
343 oneObjectCollection->setStore( oneObjectAuxCollection.get() );
346 oneObjectCollection->push_back( copiedJet );
347 *copiedJet = *theObject;
350 ATH_CHECK( handle.record( std::move(oneObjectCollection),std::move(oneObjectAuxCollection) ) );
352 return StatusCode::SUCCESS;
SG::WriteHandleKey< ConstDataVector< MuonCandidateCollection > > m_inViewMuonCandidates
const std::string & featureString()
Gaudi::Property< bool > m_requireParentView
Gaudi::Property< std::vector< std::string > > m_viewFallFilter
virtual ~EventViewCreatorAlgorithm()
std::string find(const std::string &s)
return a remapped string
StatusCode linkViewToParent(const TrigCompositeUtils::Decision *outputDecision, SG::View *newView) const
Makes sure the views are linked, if configuration requireParentView is set.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_cachedViewsKey
SmartIF< IScheduler > getScheduler() const
Obtain smart pointer to scheduler in order to schedule newly spawned views.
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)
bool hasObjectLink(const std::string &name, const CLID clid=CLID_NULL) const
Check if a link to an object with a given name and type exists. CLID_NULL to not check type.
auto makeHandle(const SG::View *view, const KEY &key, const EventContext &ctx)
Create a view handle from a handle key.
bool checkCache(const TrigCompositeUtils::DecisionContainer *cachedViews, const TrigCompositeUtils::Decision *outputDecision, size_t &cachedIndex, MatchingCache &matchingCache) const
Allow for the re-use of EventViews run in a previous Step in another EVCA instance configured to spaw...
const std::string & key() const
Return the StoreGate ID for the referenced object.
StatusCode placeMuonInView(const xAOD::Muon *theObject, SG::View *view, const EventContext &context) const
Creates a SG::VIEW_ELEMENTS collection inside a newly created View populated by the MuonCombined::Muo...
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
const std::string & roiString()
SG::WriteHandleKey< xAOD::JetContainer > m_inViewJets
bool endsWith(const std::string &value, const std::string &ending)
bool isValid() const
Test to see if the link can be dereferenced.
const ID_type & dataID() const
Get the key that we reference, as a string.
Gaudi::Property< bool > m_reverseViews
bool equal(double a, double b)
Compare two FP numbers, working around x87 precision issues.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
void linkParent(const IProxyDict *parent)
Link to the previously used views.
ToolHandle< IViewCreatorROITool > m_roiTool
SG::WriteHandleKey< xAOD::MuonContainer > m_inViewMuons
SG::WriteHandleKey< ConstDataVector< TrigRoiDescriptorCollection > > m_inViewRoIs
SG::View * makeView(const std::string &common_name, int const unique_index=-1, bool const allowFallThrough=true)
virtual StatusCode initialize() override
::StatusCode StatusCode
StatusCode definition for legacy code.
virtual StatusCode execute(const EventContext &) const override
StatusCode scheduleViews(ViewContainer *viewVector, std::string const &nodeName, EventContext const &sourceContext, SmartIF< IScheduler > scheduler, bool reverseOrder=false)
Default, invalid implementation of ClassID_traits.
const ElementLink< TrackParticleContainer > & muonSpectrometerTrackParticleLink() const
Returns an ElementLink to the InnerDetector TrackParticle used in identification of this muon.
Gaudi::Property< bool > m_viewFallThrough
std::vector< TrigCompositeUtils::LinkInfo< ViewContainer > > viewsToLink(const TrigCompositeUtils::Decision *outputDecision) const
Obtain view(s) from most recent prior step(s) which are to be wired up.
SG::WriteHandleKey< ViewContainer > m_viewsKey
void setFilter(std::vector< std::string > const &inputFilter)
Set a filtering rule for anything loaded via fall-through.
Gaudi::Property< std::string > m_viewNodeName
EventViewCreatorAlgorithm()
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Class used to describe composite objects in the HLT.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode populateMatchingCacheWithCachedViews(const TrigCompositeUtils::DecisionContainer *cachedViews, MatchingCache &matchingCache) const
We look for matching Decision Objects in a matchingCache.
Gaudi::Property< bool > m_cacheDisabled
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Muon_v1 Muon
Reference the current persistent version:
const std::string & viewString()
def cached(func)
Decorator to cache function return value.
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
const_pointer_type ptr()
Dereference the pointer.
StatusCode placeJetInView(const xAOD::Jet *theObject, SG::View *view, const EventContext &context) const
Creates a SG::VIEW_ELEMENTS collection inside a newly created View populated by the jet used to seed ...
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Gaudi::Property< bool > m_placeMuonInView
index_type index() const
Get the index of the element inside of its container.
const ElementLink< TrackParticleContainer > & extrapolatedMuonSpectrometerTrackParticleLink() const
Returns an ElementLink to the Extrapolated Muon Spectrometer TrackParticle used in identification of ...
Gaudi::Property< bool > m_placeJetInView
const T * at(size_type n) const
Access an element, as an rvalue.
StatusCode placeRoIInView(const ElementLink< TrigRoiDescriptorCollection > &roi, SG::View *view, const EventContext &context) const
Seeds a newly created view with an ROI collection containing the single seeding ROI.
A "view" of the event store (IProxyDict).
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
size_type size() const noexcept
Returns the number of elements in the collection.
Jet_v1 Jet
Definition of the current "jet version".