ATLAS Offline Software
ViewCreatorCentredOnIParticleROITool.cxx
Go to the documentation of this file.
1 
2 /*
3 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 */
5 
7 #include "AthViews/ViewHelper.h"
9 #include "xAODMuon/Muon.h"
10 #include "xAODMuon/MuonContainer.h"
12 
13 using namespace TrigCompositeUtils;
14 
15 ViewCreatorCentredOnIParticleROITool::ViewCreatorCentredOnIParticleROITool(const std::string& type, const std::string& name, const IInterface* parent)
16  : base_class(type, name, parent)
17  {}
18 
19 
22  return StatusCode::SUCCESS;
23 }
24 
25 
28 
29  for ( Decision* outputDecision : decisions ) {
30 
31  std::set<const Decision*> cache;
32  std::vector<SG::sgkey_t> keys;
33  std::vector<uint32_t> clids;
34  std::vector<Decision::index_type> indices;
35  std::vector<const Decision*> sources;
36  typelessFindLinks(outputDecision, m_iParticleLinkName, keys, clids, indices, sources, TrigDefs::lastFeatureOfType, &cache);
37 
38  //expect only one link per decision
39  if(keys.size()!=1){
40  ATH_MSG_ERROR("Did not find exactly one object having searched for a link named '"<<m_iParticleLinkName<<"'. Found "<<keys.size()<<" instead");
41  return StatusCode::FAILURE;
42  }
43 
44  //first check if we've found a MET feature, and attach a FS RoI if so
46  ATH_MSG_DEBUG("Encountered a MET feature in the CentredOnIParticle ROITool. Cannot centre an ROI on this. Attaching a FullScan RoI");
47  roisWriteHandle->push_back( new TrigRoiDescriptor( RoiDescriptor::FULLSCAN ) );
48  const ElementLink<TrigRoiDescriptorCollection> roiEL = ElementLink<TrigRoiDescriptorCollection>(*roisWriteHandle, roisWriteHandle->size() - 1, ctx);
49  outputDecision->setObjectLink(roiString(), roiEL);
50  continue;
51  }
52 
53  //If not MET, we should have an IParticle
54  const ElementLink<xAOD::IParticleContainer> p4EL(keys.at(0), indices.at(0), ctx);
55  ATH_CHECK(p4EL.isValid());
56 
57  const double reta = (*p4EL)->eta();
58  const double retap = reta + m_roiEtaWidth;
59  const double retam = reta - m_roiEtaWidth;
60  const double rphi = (*p4EL)->phi();
61  const double rphip = rphi + m_roiPhiWidth;
62  const double rphim = rphi - m_roiPhiWidth;
63 
64  TrigRoiDescriptor *newROI = nullptr;
65 
66  if ( m_roiZedWidth >= 0 ) {
67 
68  const xAOD::Muon* muon = dynamic_cast< const xAOD::Muon*>(*p4EL); //get muon of this found object
69  double zed0 = 0.0; //initialization
70 
71  bool update_z_width = true;
72 
73  if ( m_useZedPosition ) {
74  if ( muon && muon->primaryTrackParticle() ) {
75  zed0 = muon->primaryTrackParticle()->z0();
76  if ( m_useBeamspot ) zed0 += muon->primaryTrackParticle()->vz();
77  }
78  else update_z_width = false;
79  }
80 
81  if ( update_z_width ) {
82 
83  double zed0p = zed0 + m_roiZedWidth; // in mm
84  double zed0m = zed0 - m_roiZedWidth; // in mm
85 
86  if ( m_roiZedSinThetaFlag ) {
88  double cosheta = std::cosh( (*p4EL)->eta() );
89  zed0p = zed0 + m_roiZedWidth*cosheta; // in mm
90  zed0m = zed0 - m_roiZedWidth*cosheta; // in mm
91  }
92 
93  ATH_MSG_DEBUG( "New ROI for xAOD::Particle ET="<< (*p4EL)->p4().Et()
94  << " eta="<< (*p4EL)->eta() << " +- " << m_roiEtaWidth
95  << " phi="<< (*p4EL)->phi() << " +- " << m_roiPhiWidth
96  << " zed0="<< zed0 << " +- " << m_roiZedWidth );
97 
98  newROI = new TrigRoiDescriptor( reta, retam, retap,
99  rphi, rphim, rphip,
100  zed0, zed0m, zed0p );
101  }
102  else {
103  newROI = new TrigRoiDescriptor( reta, retam, retap,
104  rphi, rphim, rphip);
105  }
106  }
107  else {
108  newROI = new TrigRoiDescriptor( reta, retam, retap,
109  rphi, rphim, rphip);
110  }
111 
112  roisWriteHandle->push_back( newROI );
113 
114  const ElementLink<TrigRoiDescriptorCollection> roiEL = ElementLink<TrigRoiDescriptorCollection>(*roisWriteHandle, roisWriteHandle->size() - 1, ctx);
115 
116  outputDecision->setObjectLink(roiString(), roiEL);
117  }
118 
119  return StatusCode::SUCCESS;
120 }
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
Muon.h
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
ViewCreatorCentredOnIParticleROITool.h
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
ViewHelper.h
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtils.h:418
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
ViewCreatorCentredOnIParticleROITool::m_iParticleLinkName
Gaudi::Property< std::string > m_iParticleLinkName
Definition: ViewCreatorCentredOnIParticleROITool.h:41
ViewCreatorCentredOnIParticleROITool::m_roiZedWidth
Gaudi::Property< double > m_roiZedWidth
Definition: ViewCreatorCentredOnIParticleROITool.h:50
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ViewCreatorCentredOnIParticleROITool::m_useZedPosition
Gaudi::Property< bool > m_useZedPosition
Definition: ViewCreatorCentredOnIParticleROITool.h:56
TrigCompositeUtils::typelessFindLinks
bool typelessFindLinks(const Decision *start, const std::string &linkName, std::vector< sgkey_t > &keyVec, std::vector< uint32_t > &clidVec, std::vector< Decision::index_type > &indexVec, std::vector< const Decision * > &sourceVec, const unsigned int behaviour, std::set< const Decision * > *fullyExploredFrom)
search back the TC links for the object of type T linked to the one of TC (recursively) Returns the l...
Definition: TrigCompositeUtilsRoot.cxx:603
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
ViewCreatorCentredOnIParticleROITool::m_useBeamspot
Gaudi::Property< bool > m_useBeamspot
Definition: ViewCreatorCentredOnIParticleROITool.h:59
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:37
TrigCompositeUtils::createAndStoreNoAux
SG::WriteHandle< CONT > createAndStoreNoAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx)
Creates and right away records the Container CONT with the key.
ViewCreatorCentredOnIParticleROITool::m_roiEtaWidth
Gaudi::Property< double > m_roiEtaWidth
Definition: ViewCreatorCentredOnIParticleROITool.h:44
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ViewCreatorCentredOnIParticleROITool::initialize
virtual StatusCode initialize() override
Definition: ViewCreatorCentredOnIParticleROITool.cxx:20
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigMissingETContainer.h
ViewCreatorCentredOnIParticleROITool::ViewCreatorCentredOnIParticleROITool
ViewCreatorCentredOnIParticleROITool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: ViewCreatorCentredOnIParticleROITool.cxx:15
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
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:49
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:101
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
MuonContainer.h
SG::WriteHandle< TrigRoiDescriptorCollection >
ViewCreatorCentredOnIParticleROITool::m_roiPhiWidth
Gaudi::Property< double > m_roiPhiWidth
Definition: ViewCreatorCentredOnIParticleROITool.h:47
RoiDescriptor::FULLSCAN
static constexpr bool FULLSCAN
convenient
Definition: RoiDescriptor.h:45
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigRoiDescriptor
Athena::TPCnvVers::Current TrigRoiDescriptor
Definition: TrigSteeringEventTPCnv.cxx:68
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
ViewCreatorCentredOnIParticleROITool::attachROILinks
virtual StatusCode attachROILinks(TrigCompositeUtils::DecisionContainer &decisions, const EventContext &ctx) const override
Tool interface method.
Definition: ViewCreatorCentredOnIParticleROITool.cxx:26
ViewCreatorCentredOnIParticleROITool::m_roiZedSinThetaFlag
Gaudi::Property< double > m_roiZedSinThetaFlag
Definition: ViewCreatorCentredOnIParticleROITool.h:53
ViewCreatorCentredOnIParticleROITool::m_roisWriteHandleKey
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
Definition: ViewCreatorCentredOnIParticleROITool.h:38
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
TrigRoiDescriptorCollection.h