20 constexpr float PI_F =
static_cast<float>(
M_PI);
25 ISvcLocator* pSvcLocator):
43 return StatusCode::FAILURE;
47 return StatusCode::FAILURE;
50 ATH_MSG_FATAL(
"Number of entries in minPt, phiWidth must match number of entries in OutputROIContainerName.");
51 return StatusCode::FAILURE;
55 for (
unsigned int idx=0; idx<
m_minPtEm.size(); ++idx) {
72 for (
unsigned int output_i=0; output_i<
m_outputIndex.size(); ++output_i) {
82 return StatusCode::SUCCESS;
95 return StatusCode::SUCCESS;
103 return StatusCode::SUCCESS;
114 unsigned int all_clusters{};
115 unsigned int selected_clusters{};
117 std::vector<unsigned int > n_rois;
120 std::vector<uint8_t > max_output;
121 rois.reserve( inputClusterContainer->size());
122 max_output.resize(inputClusterContainer->size());
132 addROI(*cluster, *caloMgr, rois, max_output, n_rois);
143 std::vector< SG::WriteHandle<ROIPhiRZContainer> > output_rois;
146 unsigned int the_size = n_rois[output_rois.size()];
148 ATH_CHECK( output_rois.back().record( std::make_unique<ROIPhiRZContainer>() ) );
149 output_rois.back()->reserve( the_size);
154 std::vector<unsigned int> roi_order;
155 roi_order.reserve( rois.size() );
156 for (
unsigned int idx=0; idx< rois.size(); ++idx) { roi_order.push_back( idx ); }
157 std::sort(roi_order.begin(),roi_order.end(),[&rois](
unsigned int a,
unsigned int b) { return rois[a][0] < rois[b][0]; });
159 for (
unsigned int roi_i : roi_order) {
161 if (output_i>=max_output[roi_i])
break;
162 output_rois[output_i]->push_back( rois[ roi_i ] );
170 for (
unsigned int roi_unordered_i=0; roi_unordered_i < rois.size(); ++roi_unordered_i) {
172 if (output_i>=max_output[roi_unordered_i])
break;
173 if (std::abs(rois[ roi_unordered_i ][0])<PI_F or (rois[ roi_unordered_i ][0] == PI_F)) {
174 output_rois[output_i]->push_back( rois[ roi_unordered_i ] );
182 unsigned int max_size;
185 }
while (rois.size()>max_size && !
m_maxNROIs.compare_exchange_weak(max_size, rois.size()));
189 return StatusCode::SUCCESS;
198 double eta = cluster.
eta();
200 double tantheta = tan(
theta);
201 double phi = cluster.
phi();
207 double r = surfRefPoint.perp();
208 double z = tantheta == 0 ? 0. :
r / tantheta;
216 double z = surfRefPoint.z();
217 double r =
z * tantheta;
228 std::vector<uint_fast8_t> &max_output,
229 std::vector<unsigned int> &n_rois)
const {
231 double energy = cluster.
e();
237 if (acc.isAvailable(cluster)) {
238 emFrac = acc(cluster);
241 ATH_MSG_ERROR(
"EM energy requested, but No EM fraction momement stored");
247 std::unique_ptr<const Trk::Surface> surface(
getCaloSurface(cluster, caloDDMgr) );
255 Amg::Vector3D global_position( surface->localToGlobal( localParams) );
256 double et = energy * std::sin(global_position.theta());
258 unsigned int roi_idx=output_rois.size();
261 unsigned int n_duplicates = output_rois.size()-roi_idx-1;
262 if (n_duplicates>0) {
266 unsigned int output_idx=0;
269 n_rois[output_idx] += n_duplicates+1;
273 if (max_output.size() < output_rois.size()) {
274 max_output.resize (output_rois.size());
276 for (; roi_idx < output_rois.size(); ++roi_idx) {
277 max_output[roi_idx]=output_idx;
282 ATH_MSG_DEBUG(
"Skip selected cluster " << energy <<
" * " << std::sin(global_position.theta()) <<
" = " << energy * std::sin(global_position.theta())<<
" >= " <<
m_sortedMinPtEm[0] );
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
An algorithm that can be simultaneously executed in multiple threads.
This class provides the client interface for accessing the detector description information common to...
static Trk::LocalParameters getClusterLocalParameters(const xAOD::CaloCluster &cluster, const Trk::Surface &surf)
StatusCode execute(const EventContext &ctx) const override
std::atomic_uint m_duplicateROI
std::vector< unsigned int > m_outputSorted
SG::WriteHandleKeyArray< ROIPhiRZContainer > m_outputClusterContainerName
Name of the ROI output collection.
std::vector< unsigned int > m_outputIndex
const Trk::Surface * getCaloSurface(const xAOD::CaloCluster &cluster, const CaloDetDescrManager &caloDDMgr) const
Gaudi::Property< bool > m_EMEnergyOnly
std::atomic_uint m_maxNROIs
Gaudi::Property< std::vector< float > > m_minPtEm
StatusCode initialize() override
StatusCode finalize() override
CaloClusterROIPhiRZContainerMaker(const std::string &name, ISvcLocator *pSvcLocator)
std::atomic_uint m_selectedClusters
ToolHandle< ICaloSurfaceBuilder > m_calosurf
Tool to build calorimeter layer surfaces.
std::atomic_uint m_allClusters
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClusterContainerName
Name of the cluster intput collection.
std::vector< float > m_sortedMinPtEm
Gaudi::Property< std::vector< float > > m_phiWidth
std::vector< unsigned int > m_outputUnsorted
~CaloClusterROIPhiRZContainerMaker()
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Name of the CaloDetDescrManager condition object.
void addROI(const xAOD::CaloCluster &cluster, const CaloDetDescrManager &caloDDMgr, ROIPhiRZContainer &output_rois, std::vector< uint_fast8_t > &max_output, std::vector< unsigned int > &n_rois) const
ToolHandle< IegammaCaloClusterSelector > m_egammaCaloClusterSelector
Tool to filter the calo clusters.
container for phi sorted ROIs defined by phi, r and z.
void addROI(const Amg::Vector3D &global_position, float roi_phi_width)
SG::ConstAccessor< T, ALLOC > ConstAccessor
const_pointer_type cptr()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Abstract Base Class for tracking surfaces.
virtual const Amg::Vector3D & globalReferencePoint() const
Returns a global reference point on the surface, for PlaneSurface, StraightLineSurface,...
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
@ ENG_FRAC_EM
Energy fraction in EM calorimeters.
Eigen::Matrix< double, 3, 1 > Vector3D
std::pair< double, ParamDefs > DefinedParameter
Typedef to of a std::pair<double, ParamDefs> to identify a passed-through double as a specific type o...
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
bool isBarrel(const xAOD::Egamma *eg)
return true if the cluster is in the barrel
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Extra patterns decribing particle interation process.