ATLAS Offline Software
ViewCreatorCentredOnClusterROITool.cxx
Go to the documentation of this file.
1 
2 /*
3 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 */
5 
7 #include "AthViews/ViewHelper.h"
9 
10 using namespace TrigCompositeUtils;
11 
12 ViewCreatorCentredOnClusterROITool::ViewCreatorCentredOnClusterROITool(const std::string& type, const std::string& name, const IInterface* parent)
13  : base_class(type, name, parent)
14  {}
15 
16 
19  return StatusCode::SUCCESS;
20 }
21 
22 
25 
26  for ( Decision* outputDecision : decisions ) {
27  const std::vector<LinkInfo<xAOD::TrigEMClusterContainer>> myClusters = findLinks<xAOD::TrigEMClusterContainer>(outputDecision, m_clusterLinkName, TrigDefs::lastFeatureOfType);
28 
29  if (myClusters.size() == 0) {
30  ATH_MSG_ERROR("Found zero xAOD::TrigEMClusters '" << m_clusterLinkName << "' for Decision object index " << outputDecision->index());
31  return StatusCode::FAILURE;
32  }
33 
34  ATH_MSG_DEBUG("This merged Decision Object has " << myClusters.size() << " TrigEMClusters in its history from a previous Step."
35  << " AllowMultipleClusters=" << (m_allowMultipleClusters ? "TRUE" : "FALSE"));
36 
37  // In NOT m_allowMultipleClusters mode, we centre on the highest et
38  size_t singleClusterIndex = 0;
39  if (!m_allowMultipleClusters && myClusters.size() > 1) {
40  float maxEt = 0;
41  for (const LinkInfo<xAOD::TrigEMClusterContainer>& myCluster : myClusters) {
42  ATH_CHECK(myCluster.isValid());
43  ATH_MSG_VERBOSE("- The TrigEMCluster at index " << myCluster.link.index() << " has Et " << (*myCluster.link)->et() << " MeV.");
44  if ((*myCluster.link)->et() > maxEt) {
45  maxEt = (*myCluster.link)->et();
46  singleClusterIndex = myCluster.link.index();
47  }
48  }
49  ATH_MSG_DEBUG("The TrigEMCluster at index " << singleClusterIndex << " will be used as the centre of the FTF ROI, as this one has the highest ET (" << maxEt << " MeV).");
50  }
51 
52  // In m_allowMultipleClusters mode, they are all collected into a SuperRoI
54  TrigRoiDescriptor* superRoI = new TrigRoiDescriptor();
55  superRoI->setComposite(true);
56  superRoI->manageConstituents(true);
57  roisWriteHandle->push_back(superRoI);
58  }
59 
60  for (const LinkInfo<xAOD::TrigEMClusterContainer>& myCluster : myClusters) {
61  ATH_CHECK(myCluster.isValid());
62  if (!m_allowMultipleClusters && myCluster.link.index() != singleClusterIndex) {
63  continue;
64  }
65 
66  const xAOD::TrigEMCluster* c = *(myCluster.link);
67 
68  const double reta = c->eta();
69  const double retap = reta + m_roiEtaWidth;
70  const double retam = reta - m_roiEtaWidth;
71  const double rphi = c->phi();
72  const double rphip = rphi + m_roiPhiWidth;
73  const double rphim = rphi - m_roiPhiWidth;
74 
75  ATH_MSG_DEBUG( " New ROI for xAOD::TrigEMCluster ET="<< c->et()
76  << " eta="<< c->eta() << " +- " << m_roiEtaWidth
77  << " phi="<< c->phi() << " +- " << m_roiPhiWidth );
78 
79  if ( m_roiZedWidth==0 ) {
80  std::unique_ptr<TrigRoiDescriptor> roi = std::make_unique<TrigRoiDescriptor>(reta, retam, retap, rphi, rphim, rphip);
82  roisWriteHandle->back()->push_back( roi.release() ); // Note: manageConstituents=true, superRoI will handle deletion of roi
83  } else {
84  roisWriteHandle->push_back( roi.release() ); // Note: roi now owned by roisWriteHandle
85  }
86  }
87  else {
90  const double rzed = 0;
91  const double rzedm = rzed - m_roiZedWidth;
92  const double rzedp = rzed + m_roiZedWidth;
93 
94  std::unique_ptr<TrigRoiDescriptor> roi = std::make_unique<TrigRoiDescriptor>(reta, retam, retap, rphi, rphim, rphip, rzed, rzedm, rzedp );
96  roisWriteHandle->back()->push_back( roi.release() ); // Note: manageConstituents=true, superRoI will handle deletion of roi
97  } else {
98  roisWriteHandle->push_back( roi.release() ); // Note: roi now owned by roisWriteHandle
99  }
100  }
101 
102 
103  }
104 
105  // Link this ROI into the navigation. It will be used to spawn the Event View for this Decision Object.
106  const ElementLink<TrigRoiDescriptorCollection> roiEL = ElementLink<TrigRoiDescriptorCollection>(*roisWriteHandle, roisWriteHandle->size() - 1, ctx);
107  outputDecision->setObjectLink(roiString(), roiEL);
108 
109  }
110 
111  return StatusCode::SUCCESS;
112 }
ViewCreatorCentredOnClusterROITool::m_roisWriteHandleKey
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
Definition: ViewCreatorCentredOnClusterROITool.h:40
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ViewHelper.h
ViewCreatorCentredOnClusterROITool.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
RoiDescriptor::push_back
void push_back(const IRoiDescriptor *roi)
add a RoiDescriptor
Definition: RoiDescriptor.h:157
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
ViewCreatorCentredOnClusterROITool::initialize
virtual StatusCode initialize() override
Definition: ViewCreatorCentredOnClusterROITool.cxx:17
ViewCreatorCentredOnClusterROITool::m_clusterLinkName
Gaudi::Property< std::string > m_clusterLinkName
Definition: ViewCreatorCentredOnClusterROITool.h:43
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ViewCreatorCentredOnClusterROITool::ViewCreatorCentredOnClusterROITool
ViewCreatorCentredOnClusterROITool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: ViewCreatorCentredOnClusterROITool.cxx:12
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
ViewCreatorCentredOnClusterROITool::m_roiZedWidth
Gaudi::Property< double > m_roiZedWidth
Definition: ViewCreatorCentredOnClusterROITool.h:55
DataVector::back
const T * back() const
Access the last element in the collection as an rvalue.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:81
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::WriteHandle< TrigRoiDescriptorCollection >
TrigCompositeUtils::LinkInfo
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition: LinkInfo.h:28
ViewCreatorCentredOnClusterROITool::m_roiPhiWidth
Gaudi::Property< double > m_roiPhiWidth
Definition: ViewCreatorCentredOnClusterROITool.h:52
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
RoiDescriptor::setComposite
void setComposite(bool b=true)
Definition: RoiDescriptor.h:138
ViewCreatorCentredOnClusterROITool::m_roiEtaWidth
Gaudi::Property< double > m_roiEtaWidth
Definition: ViewCreatorCentredOnClusterROITool.h:49
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtilsRoot.cxx:878
TrigRoiDescriptor
Athena::TPCnvVers::Current TrigRoiDescriptor
Definition: TrigSteeringEventTPCnv.cxx:68
ViewCreatorCentredOnClusterROITool::attachROILinks
virtual StatusCode attachROILinks(TrigCompositeUtils::DecisionContainer &decisions, const EventContext &ctx) const override
Tool interface method.
Definition: ViewCreatorCentredOnClusterROITool.cxx:23
RoiDescriptor::manageConstituents
bool manageConstituents() const
always manage constituents ???
Definition: RoiDescriptor.h:141
ViewCreatorCentredOnClusterROITool::m_allowMultipleClusters
Gaudi::Property< bool > m_allowMultipleClusters
Definition: ViewCreatorCentredOnClusterROITool.h:46
xAOD::TrigEMCluster_v1
Description of a trigger EM cluster.
Definition: TrigEMCluster_v1.h:28
python.compressB64.c
def c
Definition: compressB64.py:93
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TrigRoiDescriptorCollection.h