ATLAS Offline Software
ViewCreatorCentredOnIParticleROITool.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 #include "xAODMuon/Muon.h"
10 #include "xAODMuon/MuonContainer.h"
11 
12 using namespace TrigCompositeUtils;
13 
14 ViewCreatorCentredOnIParticleROITool::ViewCreatorCentredOnIParticleROITool(const std::string& type, const std::string& name, const IInterface* parent)
15  : base_class(type, name, parent)
16  {}
17 
18 
21  return StatusCode::SUCCESS;
22 }
23 
24 
27 
28  for ( Decision* outputDecision : decisions ) {
29  const std::vector<LinkInfo<xAOD::IParticleContainer>> myFeature = findLinks<xAOD::IParticleContainer>(outputDecision, m_iParticleLinkName, TrigDefs::lastFeatureOfType);
30 
31  if (myFeature.size() != 1) {
32  ATH_MSG_ERROR("Did not find exactly one most-recent xAOD::IParticle '" << m_iParticleLinkName << "' for Decision object index " << outputDecision->index()
33  << ", found " << myFeature.size());
34  return StatusCode::FAILURE;
35  }
36  ATH_CHECK(myFeature.at(0).isValid());
37 
38  const ElementLink<xAOD::IParticleContainer> p4EL = myFeature.at(0).link;
39 
40  const double reta = (*p4EL)->eta();
41  const double retap = reta + m_roiEtaWidth;
42  const double retam = reta - m_roiEtaWidth;
43  const double rphi = (*p4EL)->phi();
44  const double rphip = rphi + m_roiPhiWidth;
45  const double rphim = rphi - m_roiPhiWidth;
46 
47  TrigRoiDescriptor *newROI = nullptr;
48 
49  if ( m_roiZedWidth >= 0 ) {
50 
51  const xAOD::Muon* muon = dynamic_cast< const xAOD::Muon*>(*p4EL); //get muon of this found object
52  double zed0 = 0.0; //initialization
53 
54  bool update_z_width = true;
55 
56  if ( m_useZedPosition ) {
57  if ( muon && muon->primaryTrackParticle() ) {
58  zed0 = muon->primaryTrackParticle()->z0();
59  if ( m_useBeamspot ) zed0 += muon->primaryTrackParticle()->vz();
60  }
61  else update_z_width = false;
62  }
63 
64  if ( update_z_width ) {
65 
66  double zed0p = zed0 + m_roiZedWidth; // in mm
67  double zed0m = zed0 - m_roiZedWidth; // in mm
68 
69  if ( m_roiZedSinThetaFlag ) {
71  double cosheta = std::cosh( (*p4EL)->eta() );
72  zed0p = zed0 + m_roiZedWidth*cosheta; // in mm
73  zed0m = zed0 - m_roiZedWidth*cosheta; // in mm
74  }
75 
76  ATH_MSG_DEBUG( "New ROI for xAOD::Particle ET="<< (*p4EL)->p4().Et()
77  << " eta="<< (*p4EL)->eta() << " +- " << m_roiEtaWidth
78  << " phi="<< (*p4EL)->phi() << " +- " << m_roiPhiWidth
79  << " zed0="<< zed0 << " +- " << m_roiZedWidth );
80 
81  newROI = new TrigRoiDescriptor( reta, retam, retap,
82  rphi, rphim, rphip,
83  zed0, zed0m, zed0p );
84  }
85  else {
86  newROI = new TrigRoiDescriptor( reta, retam, retap,
87  rphi, rphim, rphip);
88  }
89  }
90  else {
91  newROI = new TrigRoiDescriptor( reta, retam, retap,
92  rphi, rphim, rphip);
93  }
94 
95  roisWriteHandle->push_back( newROI );
96 
97  const ElementLink<TrigRoiDescriptorCollection> roiEL = ElementLink<TrigRoiDescriptorCollection>(*roisWriteHandle, roisWriteHandle->size() - 1, ctx);
98 
99  outputDecision->setObjectLink(roiString(), roiEL);
100  }
101 
102  return StatusCode::SUCCESS;
103 }
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
Muon.h
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
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
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
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:19
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ViewCreatorCentredOnIParticleROITool::ViewCreatorCentredOnIParticleROITool
ViewCreatorCentredOnIParticleROITool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: ViewCreatorCentredOnIParticleROITool.cxx:14
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
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.
MuonContainer.h
SG::WriteHandle< TrigRoiDescriptorCollection >
ViewCreatorCentredOnIParticleROITool::m_roiPhiWidth
Gaudi::Property< double > m_roiPhiWidth
Definition: ViewCreatorCentredOnIParticleROITool.h:47
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtilsRoot.cxx:878
TrigRoiDescriptor
Athena::TPCnvVers::Current TrigRoiDescriptor
Definition: TrigSteeringEventTPCnv.cxx:68
ViewCreatorCentredOnIParticleROITool::attachROILinks
virtual StatusCode attachROILinks(TrigCompositeUtils::DecisionContainer &decisions, const EventContext &ctx) const override
Tool interface method.
Definition: ViewCreatorCentredOnIParticleROITool.cxx:25
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