19#include "GaudiKernel/ConcurrencyFlags.h"
28 base_class( name, pSvcLocator ),
40 declareProperty(
"NumberOfDCs",
m_nDCs = 8 );
41 declareProperty(
"ModuleName",
m_moduleName =
"libTrigInDetCUDA.so");
43 declareProperty(
"MiddleSpacePointLayers",
m_middleSpacePointLayers = std::vector<int>(),
"Global IDs of layers that can contain middle spacepoints of track seeds" );
67 SmartIF<IIncidentSvc> incsvc{service(
"IncidentSvc")};
68 const int priority = 100;
70 const bool is_multiprocess = (Gaudi::Concurrency::ConcurrencyFlags::numProcs() > 0);
71 if (is_multiprocess) {
75 incsvc->addListener(
this,
"BeginRun", priority);
79 return StatusCode::SUCCESS;
86 ATH_MSG_INFO(
"TrigInDetAccelerationSvc: no CUDA device available");
87 return StatusCode::FAILURE;
95 ATH_MSG_INFO(
"TrigInDetAccelerationSvc: cannot load the factory library, error:"<<dlerror());
96 return StatusCode::SUCCESS;
108 int factory_id_to_load = 0;
118 if(
m_pWF ==
nullptr){
119 ATH_MSG_INFO(
"OffloadFactory with id "<<std::hex<<factory_id_to_load<<
" not available from the module");
121 return StatusCode::SUCCESS;
126 ATH_MSG_INFO(
"TrigInDetAccelerationSvc: created OffloadFactory, factory id = "<<std::hex<<
m_pWF->getFactoryId()<<std::dec);
127 return StatusCode::SUCCESS;
141 return StatusCode::SUCCESS;
160 std::map<std::tuple<short,short, int, int>,std::vector<PhiEtaHash> > hashMap;
172 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> > hashMap;
196 return wf->createWork(jobCode, pB);
202 if (i<0 || i>2) i = 0;
210 if (
m_detStore->retrieve(pix_mgr,
"ITkPixel").isFailure()) {
218 const size_t bufferOffset = 256;
219 size_t totalSize = bufferOffset + dataTypeSize;
228 memset(pArray,0,dataTypeSize);
230 int nLayers = (int)hashMap.size();
235 int middleLayerIdx=0;
237 for(std::map<std::tuple<short,short, int, int>,std::vector<PhiEtaHash> >
::const_iterator it = hashMap.begin();it!=hashMap.end();++it, layerIdx++) {
239 short barrel_ec = std::get<0>((*it).first);
240 int vol_id = std::get<2>((*it).first);
241 int lay_id = std::get<3>((*it).first);
242 if(barrel_ec == -100) barrel_ec = 0;
243 int globalLayerId = vol_id*1000 + lay_id;
255 std::vector<std::vector<PhiEtaHash>::const_iterator> vStops;
256 vStops.push_back((*it).second.begin());
257 std::vector<PhiEtaHash>::const_iterator firstIt = (*it).second.begin();
258 std::vector<PhiEtaHash>::const_iterator nextIt = (*it).second.begin();
263 for(; nextIt!=(*it).second.end();++nextIt, ++firstIt) {
264 if((*nextIt).m_phiIndex!=(*firstIt).m_phiIndex) {
265 vStops.push_back(nextIt);
272 vStops.push_back((*it).second.end());
275 float minBound = 100000.0;
276 float maxBound =-100000.0;
282 for(
unsigned int iStops = 1; iStops<vStops.size();iStops++) {
285 for(std::vector<PhiEtaHash>::const_iterator hIt = vStops[iStops-1];hIt!=vStops[iStops];++hIt) {
297 if (barrel_ec == 0) {
298 rc += sqrt(
C(0)*
C(0)+
C(1)*
C(1));
299 if(p->zMin() < minBound) minBound = p->zMin();
300 if(p->zMax() > maxBound) maxBound = p->zMax();
305 if(p->rMin() < minBound) minBound = p->rMin();
306 if(p->rMax() > maxBound) maxBound = p->rMax();
320 std::shared_ptr<TrigAccel::OffloadBuffer> pDMBuff = std::make_shared<TrigAccel::OffloadBuffer>(pBG);
335 const PixelID* pixelId =
nullptr;
337 if (
m_detStore->retrieve(pixelId,
"PixelID").isFailure()) {
348 if(offlineId==0)
continue;
350 short barrel_ec = pixelId->
barrel_ec(offlineId);
351 if(abs(barrel_ec)>2)
continue;
353 short phi_index = pixelId->
phi_module(offlineId);
354 short eta_index = pixelId->
eta_module(offlineId);
355 short layer_disk = pixelId->
layer_disk(offlineId);
359 if (barrel_ec== 0) vol_id = 8;
360 if (barrel_ec==-2) vol_id = 7;
361 if (barrel_ec== 2) vol_id = 9;
363 int new_vol=0, new_lay=0;
365 if (vol_id == 7 || vol_id == 9) {
366 new_vol = 10*vol_id + layer_disk;
368 }
else if (vol_id == 8) {
370 new_vol = 10*vol_id + layer_disk;
373 auto t = std::make_tuple(barrel_ec==0 ? -100 : barrel_ec, subdetid, new_vol, new_lay);
374 std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >
::iterator it = hashMap.find(t);
375 if(it==hashMap.end())
376 hashMap.insert(std::pair<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1,
PhiEtaHash(phi_index, eta_index, hash) )));
377 else (*it).second.push_back(
PhiEtaHash(phi_index, eta_index, hash));
388 for(std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >
::iterator it = hashMap.begin();it!=hashMap.end();++it, layerId++) {
390 short barrel_ec = std::get<0>((*it).first);
391 short subdetId = std::get<1>((*it).first);
392 if(barrel_ec == -100) barrel_ec = 0;
397 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
403 for(std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >
::iterator it = hashMap.begin();it!=hashMap.end();++it) {
419 if (
m_detStore->retrieve(sct_mgr,
"SCT").isFailure()) {
424 if (
m_detStore->retrieve(pix_mgr,
"Pixel").isFailure()) {
432 const size_t bufferOffset = 256;
433 size_t totalSize = bufferOffset + dataTypeSize;
442 memset(pArray,0,dataTypeSize);
444 int nLayers = (int)hashMap.size();
450 for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >
::const_iterator it = hashMap.begin();it!=hashMap.end();++it, layerIdx++) {
451 short subdetid = std::get<0>((*it).first);
452 short barrel_ec = std::get<1>((*it).first);
458 std::vector<std::vector<PhiEtaHash>::const_iterator> vStops;
459 vStops.push_back((*it).second.begin());
460 std::vector<PhiEtaHash>::const_iterator firstIt = (*it).second.begin();
461 std::vector<PhiEtaHash>::const_iterator nextIt = (*it).second.begin();
466 for(; nextIt!=(*it).second.end();++nextIt, ++firstIt) {
467 if((*nextIt).m_phiIndex!=(*firstIt).m_phiIndex) {
468 vStops.push_back(nextIt);
475 vStops.push_back((*it).second.end());
478 float minBound = 100000.0;
479 float maxBound =-100000.0;
485 for(
unsigned int iStops = 1; iStops<vStops.size();iStops++) {
489 for(std::vector<PhiEtaHash>::const_iterator hIt = vStops[iStops-1];hIt!=vStops[iStops];++hIt) {
503 rc += sqrt(
C(0)*
C(0)+
C(1)*
C(1));
504 if(p->zMin() < minBound) minBound = p->zMin();
505 if(p->zMax() > maxBound) maxBound = p->zMax();
511 if(p->rMin() < minBound) minBound = p->rMin();
512 if(p->rMax() > maxBound) maxBound = p->rMax();
526 std::shared_ptr<TrigAccel::OffloadBuffer> pDMBuff = std::make_shared<TrigAccel::OffloadBuffer>(pBG);
541 const PixelID* pixelId =
nullptr;
542 const SCT_ID* sctId =
nullptr;
544 if (
m_detStore->retrieve(pixelId,
"PixelID").isFailure()) {
549 if (
m_detStore->retrieve(sctId,
"SCT_ID").isFailure()) {
560 if(offlineId==0)
continue;
562 short barrel_ec = pixelId->
barrel_ec(offlineId);
563 if(abs(barrel_ec)>2)
continue;
564 short layer_disk = pixelId->
layer_disk(offlineId);
565 short phi_index = pixelId->
phi_module(offlineId);
566 short eta_index = pixelId->
eta_module(offlineId);
567 auto t = std::make_tuple(subdetid, barrel_ec, layer_disk);
568 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >
::iterator it = hashMap.find(t);
569 if(it==hashMap.end())
570 hashMap.insert(std::pair<std::tuple<short,short,short>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1,
PhiEtaHash(phi_index, eta_index, hash) )));
571 else (*it).second.push_back(
PhiEtaHash(phi_index, eta_index, hash));
578 if(offlineId==0)
continue;
580 short barrel_ec = sctId->
barrel_ec(offlineId);
581 short layer_disk = sctId->
layer_disk(offlineId);
582 short phi_index = sctId->
phi_module(offlineId);
583 short eta_index = sctId->
eta_module(offlineId);
585 auto t = std::make_tuple(subdetid, barrel_ec, layer_disk);
586 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >
::iterator it = hashMap.find(t);
587 if(it==hashMap.end())
588 hashMap.insert(std::pair<std::tuple<short,short,short>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1,
PhiEtaHash(phi_index, eta_index, hash))));
589 else (*it).second.push_back(
PhiEtaHash(phi_index, eta_index, hash));
597 for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >
::iterator it = hashMap.begin();it!=hashMap.end();++it, layerId++) {
599 short subdetId = std::get<0>((*it).first);
600 short barrel_ec = std::get<1>((*it).first);
605 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
610 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
617 for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >
::iterator it = hashMap.begin();it!=hashMap.end();++it) {
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
static unsigned int totalSize(const MultiDimArray< T, N > &ht)
This is an Identifier helper class for the Pixel subdetector.
bool getModule(std::istream &s, RegSelModule &m)
This is an Identifier helper class for the SCT subdetector.
void clear()
Empty the pool.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
static const std::string & type()
Incident type.
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated pixel ...
virtual const SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier
Dedicated detector manager extending the functionality of the SiDetectorManager with dedicated SCT in...
virtual const SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements via Identifier
Class to hold geometrical description of a silicon detector element.
This is an Identifier helper class for the Pixel subdetector.
int layer_disk(const Identifier &id) const
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0).
size_type wafer_hash_max() const
int eta_module(const Identifier &id) const
int phi_module(const Identifier &id) const
This is an Identifier helper class for the SCT subdetector.
size_type wafer_hash_max() const
int layer_disk(const Identifier &id) const
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
int phi_module(const Identifier &id) const
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0).
int eta_module(const Identifier &id) const
virtual void handle(const Incident &) override
OnBeginRun data gathering and export.
ServiceHandle< StoreGateSvc > m_evtStore
virtual const std::vector< short > & getLayerInformation(int) const override
ServiceHandle< StoreGateSvc > m_detStore
virtual StatusCode initialize() override
Initialize.
bool exportITkGeometryInformation(const std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > &hashMap) const
bool exportGeometryInformation(const std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > &) const
std::vector< short > m_layerInfo[3]
virtual StatusCode finalize() override
Finalize.
virtual TrigAccel::Work * createWork(unsigned int, std::shared_ptr< TrigAccel::OffloadBuffer >) const override
bool extractITkGeometryInformation(std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > &)
TrigInDetAccelerationSvc(const std::string &, ISvcLocator *)
Constructor.
std::vector< int > m_middleSpacePointLayers
TrigAccel::Module * m_module
TrigAccel::WorkFactory * m_pWF
bool extractGeometryInformation(std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > &)
ServiceHandle< AthCUDA::IGPUSystemInfoSvc > m_cudaCheckSvc
StatusCode initializeWorkFactory()
Eigen::Matrix< double, 3, 1 > Vector3D
struct TrigAccel::ITk::DetectorModel DETECTOR_MODEL
struct TrigAccel::DataExportBuffer DATA_EXPORT_BUFFER
constexpr unsigned int TrigITkModuleID_CUDA
constexpr unsigned int TrigInDetModuleID_CUDA
struct TrigAccel::DetectorModel DETECTOR_MODEL
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
void reallocate(size_t s)
SILICON_LAYER m_layers[MAX_SILICON_LAYERS]
float m_minRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
float m_maxRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
int m_hashArray[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
int m_hashArray[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
int m_middleSpacePointLayers[MAX_SILICON_LAYERS]
float m_minRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]
SILICON_LAYER m_layers[MAX_SILICON_LAYERS]
float m_maxRZ[MAX_NUMBER_PIX_MODULES+MAX_NUMBER_SCT_MODULES]