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"
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  const std::vector<LinkInfo<xAOD::IParticleContainer>> myFeature = findLinks<xAOD::IParticleContainer>(outputDecision, m_iParticleLinkName, TrigDefs::lastFeatureOfType);
31 
32  if(myFeature.size()==0){
33  //check if there is a MET feature (since MET isn't an IParticle), add a FS RoI if there is
34  auto metFeature = findLinks<xAOD::TrigMissingETContainer>(outputDecision, m_iParticleLinkName, TrigDefs::lastFeatureOfType);
35  if(metFeature.size()==1){
36  ATH_MSG_DEBUG("Encountered a MET feature in the CentredOnIParticle ROITool. Cannot centre an ROI on this. Attaching a FullScan RoI");
37  roisWriteHandle->push_back( new TrigRoiDescriptor( RoiDescriptor::FULLSCAN ) );
38  const ElementLink<TrigRoiDescriptorCollection> roiEL = ElementLink<TrigRoiDescriptorCollection>(*roisWriteHandle, roisWriteHandle->size() - 1, ctx);
39  outputDecision->setObjectLink(roiString(), roiEL);
40  continue;
41  }
42  else{
43  ATH_MSG_ERROR("Did not find any xAOD::IParticle: '"<< m_iParticleLinkName << "' for Decsion object index "<<outputDecision->index());
44  return StatusCode::FAILURE;
45  }
46  }
47  else if (myFeature.size() != 1) {
48  ATH_MSG_ERROR("Did not find exactly one most-recent xAOD::IParticle '" << m_iParticleLinkName << "' for Decision object index " << outputDecision->index()
49  << ", found " << myFeature.size());
50  return StatusCode::FAILURE;
51  }
52  ATH_CHECK(myFeature.at(0).isValid());
53 
54  const ElementLink<xAOD::IParticleContainer> p4EL = myFeature.at(0).link;
55 
56  const double reta = (*p4EL)->eta();
57  const double retap = reta + m_roiEtaWidth;
58  const double retam = reta - m_roiEtaWidth;
59  const double rphi = (*p4EL)->phi();
60  const double rphip = rphi + m_roiPhiWidth;
61  const double rphim = rphi - m_roiPhiWidth;
62 
63  TrigRoiDescriptor *newROI = nullptr;
64 
65  if ( m_roiZedWidth >= 0 ) {
66 
67  const xAOD::Muon* muon = dynamic_cast< const xAOD::Muon*>(*p4EL); //get muon of this found object
68  double zed0 = 0.0; //initialization
69 
70  bool update_z_width = true;
71 
72  if ( m_useZedPosition ) {
73  if ( muon && muon->primaryTrackParticle() ) {
74  zed0 = muon->primaryTrackParticle()->z0();
75  if ( m_useBeamspot ) zed0 += muon->primaryTrackParticle()->vz();
76  }
77  else update_z_width = false;
78  }
79 
80  if ( update_z_width ) {
81 
82  double zed0p = zed0 + m_roiZedWidth; // in mm
83  double zed0m = zed0 - m_roiZedWidth; // in mm
84 
85  if ( m_roiZedSinThetaFlag ) {
87  double cosheta = std::cosh( (*p4EL)->eta() );
88  zed0p = zed0 + m_roiZedWidth*cosheta; // in mm
89  zed0m = zed0 - m_roiZedWidth*cosheta; // in mm
90  }
91 
92  ATH_MSG_DEBUG( "New ROI for xAOD::Particle ET="<< (*p4EL)->p4().Et()
93  << " eta="<< (*p4EL)->eta() << " +- " << m_roiEtaWidth
94  << " phi="<< (*p4EL)->phi() << " +- " << m_roiPhiWidth
95  << " zed0="<< zed0 << " +- " << m_roiZedWidth );
96 
97  newROI = new TrigRoiDescriptor( reta, retam, retap,
98  rphi, rphim, rphip,
99  zed0, zed0m, zed0p );
100  }
101  else {
102  newROI = new TrigRoiDescriptor( reta, retam, retap,
103  rphi, rphim, rphip);
104  }
105  }
106  else {
107  newROI = new TrigRoiDescriptor( reta, retam, retap,
108  rphi, rphim, rphip);
109  }
110 
111  roisWriteHandle->push_back( newROI );
112 
113  const ElementLink<TrigRoiDescriptorCollection> roiEL = ElementLink<TrigRoiDescriptorCollection>(*roisWriteHandle, roisWriteHandle->size() - 1, ctx);
114 
115  outputDecision->setObjectLink(roiString(), roiEL);
116  }
117 
118  return StatusCode::SUCCESS;
119 }
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
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
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
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
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:52
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
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtilsRoot.cxx:891
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: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