ATLAS Offline Software
TestRoICreatorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 namespace ActsTrk {
8 
10  const std::string& name,
11  const IInterface* parent)
12  : base_class(type, name, parent)
13 {}
14 
16 {
17  ATH_MSG_DEBUG("Inizializing " << name() << " ..." );
18 
19  // Check consistency
20  // We need at least one entry
21  if (m_eta_center_rois.size() == 0) {
22  ATH_MSG_ERROR("No RoI definition defined, cannot create the test RoI.");
23  return StatusCode::FAILURE;
24  }
25 
26  // eta and phi vectors MUST have the same size. z vectors can have 0 size OR the same size as the eta/phi vectors
27  if (m_eta_center_rois.size() != m_phi_center_rois.size() or
28  m_eta_center_rois.size() != m_half_eta_width_rois.size() or
29  m_eta_center_rois.size() != m_half_phi_width_rois.size()) {
30  ATH_MSG_ERROR("Inconsistent definitions for eta/phi vectors. Check their definitions!");
31  return StatusCode::FAILURE;
32  }
33 
34  // Now check the z vectors
35  if (m_z_center_rois.size() != m_half_z_width_rois.size()) {
36  ATH_MSG_ERROR("Inconsistent definitions for the z vectors. Check their definitions!");
37  return StatusCode::FAILURE;
38  }
39 
40  if (m_z_center_rois.size() != 0 and m_z_center_rois.size() != m_eta_center_rois.size()) {
41  ATH_MSG_ERROR("Z vector is not empty but it is not consistent with the phi/eta counterpart. Check their definitions!");
42  return StatusCode::FAILURE;
43  }
44 
45  return StatusCode::SUCCESS;
46 }
47 
49  TrigRoiDescriptorCollection& collectionRoI) const
50 {
51  bool isComposite = m_eta_center_rois.size() > 1;
52  // Add a composite RoI
53  if (isComposite) {
54  collectionRoI.push_back( new TrigRoiDescriptor() );
55  collectionRoI.back()->setComposite(true);
56  }
57 
58  bool useZconstraint = m_z_center_rois.size() != 0;
59 
60  for (std::size_t i(0); i<m_eta_center_rois.size(); ++i) {
61  double eta = m_eta_center_rois.value().at(i);
62  double phi = m_phi_center_rois.value().at(i);
63  double eta_half_width = m_half_eta_width_rois.value().at(i);
64  double phi_half_width = m_half_phi_width_rois.value().at(i);
65 
66  TrigRoiDescriptor *toAdd = nullptr;
67  if (not useZconstraint) {
68  toAdd = new TrigRoiDescriptor(eta, eta - eta_half_width, eta + eta_half_width,
69  phi, phi - phi_half_width, phi + phi_half_width);
70  } else {
71  double z = m_z_center_rois.value().at(i);
72  double z_half_width = m_half_z_width_rois.value().at(i);
73  toAdd = new TrigRoiDescriptor(eta, eta - eta_half_width, eta + eta_half_width,
74  phi, phi - phi_half_width, phi + phi_half_width,
75  z, z - z_half_width, z + z_half_width);
76  }
77 
78  // if composite roi, add the consituent to it (already in the collection)
79  // if not, the collection is empty and we have to add this one to it
80  if (isComposite) {
81  collectionRoI.back()->push_back( std::move(toAdd) );
82  } else {
83  collectionRoI.push_back( std::move(toAdd) );
84  }
85  }
86 
87  ATH_MSG_DEBUG("RoI collection size: " << collectionRoI.size());
88  ATH_MSG_DEBUG("Created a test RoI");
89  if (collectionRoI.back()->composite()) {
90  ATH_MSG_DEBUG("This is a composite RoI made from " << collectionRoI.back()->size() << " constituents");
91  }
92 
93  return StatusCode::SUCCESS;
94 }
95 
96 }
ActsTrk::TestRoICreatorTool::m_phi_center_rois
Gaudi::Property< std::vector< double > > m_phi_center_rois
Definition: TestRoICreatorTool.h:30
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
RoiDescriptor::composite
virtual bool composite() const override final
SuperRoI compatability methods.
Definition: RoiDescriptor.h:137
RoiDescriptor::size
virtual unsigned size() const override final
number of constituents
Definition: RoiDescriptor.h:145
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
ActsTrk::TestRoICreatorTool::m_z_center_rois
Gaudi::Property< std::vector< double > > m_z_center_rois
Definition: TestRoICreatorTool.h:31
ActsTrk::TestRoICreatorTool::initialize
virtual StatusCode initialize() override
Definition: TestRoICreatorTool.cxx:15
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
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
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
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ActsTrk::TestRoICreatorTool::defineRegionsOfInterest
virtual StatusCode defineRegionsOfInterest(const EventContext &ctx, TrigRoiDescriptorCollection &collectionRoI) const override
Definition: TestRoICreatorTool.cxx:48
ActsTrk::TestRoICreatorTool::TestRoICreatorTool
TestRoICreatorTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TestRoICreatorTool.cxx:9
DataVector::back
const T * back() const
Access the last element in the collection as an rvalue.
DeMoUpdate.toAdd
bool toAdd
Definition: DeMoUpdate.py:1304
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.
ActsTrk::TestRoICreatorTool::m_eta_center_rois
Gaudi::Property< std::vector< double > > m_eta_center_rois
Definition: TestRoICreatorTool.h:29
ActsTrk::TestRoICreatorTool::m_half_eta_width_rois
Gaudi::Property< std::vector< double > > m_half_eta_width_rois
Definition: TestRoICreatorTool.h:33
ActsTrk::TestRoICreatorTool::m_half_phi_width_rois
Gaudi::Property< std::vector< double > > m_half_phi_width_rois
Definition: TestRoICreatorTool.h:34
ActsTrk::TestRoICreatorTool::m_half_z_width_rois
Gaudi::Property< std::vector< double > > m_half_z_width_rois
Definition: TestRoICreatorTool.h:35
TrigRoiDescriptorCollection
Definition: TrigRoiDescriptorCollection.h:21
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
RoiDescriptor::setComposite
void setComposite(bool b=true)
Definition: RoiDescriptor.h:138
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:34
TrigRoiDescriptor
Athena::TPCnvVers::Current TrigRoiDescriptor
Definition: TrigSteeringEventTPCnv.cxx:68
TestRoICreatorTool.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.