22#include "GaudiKernel/ServiceHandle.h"
23#include "GaudiKernel/Incident.h"
31#include "CLHEP/Random/RandFlat.h"
38 const std::string& n,
const IInterface* p):
41 declareInterface<TruthClusterizationFactory>(
this);
56 return StatusCode::FAILURE;
64 return StatusCode::SUCCESS;
71 const EventContext& ctx = Gaudi::Hive::currentContext();
74 wrapper->setSeed (this->name(), ctx);
76 CLHEP::HepRandomEngine* engine =
m_rndmEngine->getEngine (ctx);
78 std::vector<double> probabilities(3,0.);
79 const auto &rdos = pCluster.
rdoList();
80 unsigned int nPartContributing = 0;
83 std::set<int> uniqueIDs;
87 for (
auto rdoIter : rdos){
88 auto simDataIter = pixSdoColl->find(rdoIter);
89 if (simDataIter != pixSdoColl->end()){
91 auto simData = (simDataIter->second);
92 for(
const auto& deposit :
simData.getdeposits() ){
94 if (!deposit.first){
ATH_MSG_DEBUG(
"No deposits found");
continue;}
96 if (deposit.first.eventIndex() != 0)
continue;
97 uniqueIDs.insert(deposit.first.id());
104 nPartContributing = uniqueIDs.size();
111 std::set< std::pair<HepMcParticleLink::index_type, int> > uniqueIDs;
115 for (
auto rdoIter : rdos){
116 auto simDataIter = pixSdoColl->find(rdoIter);
117 if (simDataIter != pixSdoColl->end()){
119 auto simData = (simDataIter->second);
120 for(
const auto& deposit :
simData.getdeposits() ){
122 if (!deposit.first){
ATH_MSG_DEBUG(
"No deposits found");
continue;}
124 uniqueIDs.insert(std::make_pair(deposit.first.eventIndex(), deposit.first.id()));
131 nPartContributing = uniqueIDs.size();
134 ATH_MSG_VERBOSE(
"Smearing TruthClusterizationFactory probability output for TIDE studies");
137 if (nPartContributing<=1) {
139 probabilities[0] = 1.0;
142 else if (nPartContributing==2) {
146 else probabilities[0] = 1.0;
149 else if (nPartContributing>2) {
153 else probabilities[0] = 1.0;
156 return probabilities;
162 ATH_MSG_ERROR(
"TruthClusterizationFactory::estimatePositions called for ITk ambiguity setup, should never happen! Digital clustering should be run for positions & errors.");
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define CHECK(...)
Evaluate an expression and check for errors.
This is an Identifier helper class for the Pixel subdetector.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
A wrapper class for event-slot-local random engines.
virtual StatusCode initialize()
Gaudi::Property< bool > m_discardPUHits
Gaudi::Property< float > m_truthClusterSplittingEff
TruthClusterizationFactory(const std::string &name, const std::string &n, const IInterface *p)
Gaudi::Property< std::string > m_rndmEngineName
ATHRNG::RNGWrapper * m_rndmEngine
std::vector< Amg::Vector2D > estimatePositions(const InDet::PixelCluster &) const
std::vector< double > estimateNumberOfParticles(const InDet::PixelCluster &pCluster) const
ServiceHandle< IAthRNGSvc > m_rndmSvc
SG::ReadHandleKey< InDetSimDataCollection > m_simDataCollectionName
IncidentSvc to catch begining of event and end of event.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
Eigen::Matrix< double, 2, 1 > Vector2D