19#include "GaudiKernel/ConcurrencyFlags.h"
28 base_class( name, pSvcLocator ),
39 declareProperty(
"NumberOfDCs",
m_nDCs = 8 );
40 declareProperty(
"ModuleName",
m_moduleName =
"libTrigInDetCUDA.so");
42 declareProperty(
"MiddleSpacePointLayers",
m_middleSpacePointLayers = std::vector<int>(),
"Global IDs of layers that can contain middle spacepoints of track seeds" );
62 ATH_MSG_INFO(
"TrigInDetAccelerationSvc: cannot load the factory library, error:"<<dlerror());
63 return StatusCode::SUCCESS;
75 int factory_id_to_load = 0;
86 ATH_MSG_INFO(
"OffloadFactory with id "<<std::hex<<factory_id_to_load<<
" not available from the module");
88 return StatusCode::SUCCESS;
91 bool cfgResult =
m_pWF->configure();
96 return StatusCode::SUCCESS;
103 ATH_MSG_INFO(
"TrigInDetAccelerationSvc: created OffloadFactory, factory id = "<<std::hex<<
m_pWF->getFactoryId()<<std::dec);
111 SmartIF<IIncidentSvc> incsvc{service(
"IncidentSvc")};
112 const int priority = 100;
114 const bool is_multiprocess = (Gaudi::Concurrency::ConcurrencyFlags::numProcs() > 0);
115 if (is_multiprocess) {
119 incsvc->addListener(
this,
"BeginRun", priority);
123 return StatusCode::SUCCESS;
135 return StatusCode::SUCCESS;
149 std::map<std::tuple<short,short, int, int>,std::vector<PhiEtaHash> > hashMap;
161 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> > hashMap;
185 return wf->createWork(jobCode, pB);
191 if (i<0 || i>2) i = 0;
199 if (
m_detStore->retrieve(pix_mgr,
"ITkPixel").isFailure()) {
207 const size_t bufferOffset = 256;
208 size_t totalSize = bufferOffset + dataTypeSize;
217 memset(pArray,0,dataTypeSize);
219 int nLayers = (int)hashMap.size();
224 int middleLayerIdx=0;
226 for(std::map<std::tuple<short,short, int, int>,std::vector<PhiEtaHash> >
::const_iterator it = hashMap.begin();it!=hashMap.end();++it, layerIdx++) {
228 short barrel_ec = std::get<0>((*it).first);
229 int vol_id = std::get<2>((*it).first);
230 int lay_id = std::get<3>((*it).first);
231 if(barrel_ec == -100) barrel_ec = 0;
232 int globalLayerId = vol_id*1000 + lay_id;
244 std::vector<std::vector<PhiEtaHash>::const_iterator> vStops;
245 vStops.push_back((*it).second.begin());
246 std::vector<PhiEtaHash>::const_iterator firstIt = (*it).second.begin();
247 std::vector<PhiEtaHash>::const_iterator nextIt = (*it).second.begin();
252 for(; nextIt!=(*it).second.end();++nextIt, ++firstIt) {
253 if((*nextIt).m_phiIndex!=(*firstIt).m_phiIndex) {
254 vStops.push_back(nextIt);
261 vStops.push_back((*it).second.end());
264 float minBound = 100000.0;
265 float maxBound =-100000.0;
271 for(
unsigned int iStops = 1; iStops<vStops.size();iStops++) {
275 for(std::vector<PhiEtaHash>::const_iterator hIt = vStops[iStops-1];hIt!=vStops[iStops];++hIt, nPhiModules++) {
287 if (barrel_ec == 0) {
288 rc += sqrt(
C(0)*
C(0)+
C(1)*
C(1));
289 if(p->zMin() < minBound) minBound = p->zMin();
290 if(p->zMax() > maxBound) maxBound = p->zMax();
295 if(p->rMin() < minBound) minBound = p->rMin();
296 if(p->rMax() > maxBound) maxBound = p->rMax();
310 std::shared_ptr<TrigAccel::OffloadBuffer> pDMBuff = std::make_shared<TrigAccel::OffloadBuffer>(pBG);
325 const PixelID* pixelId =
nullptr;
327 if (
m_detStore->retrieve(pixelId,
"PixelID").isFailure()) {
338 if(offlineId==0)
continue;
340 short barrel_ec = pixelId->
barrel_ec(offlineId);
341 if(abs(barrel_ec)>2)
continue;
343 short phi_index = pixelId->
phi_module(offlineId);
344 short eta_index = pixelId->
eta_module(offlineId);
345 short layer_disk = pixelId->
layer_disk(offlineId);
349 if (barrel_ec== 0) vol_id = 8;
350 if (barrel_ec==-2) vol_id = 7;
351 if (barrel_ec== 2) vol_id = 9;
353 int new_vol=0, new_lay=0;
355 if (vol_id == 7 || vol_id == 9) {
356 new_vol = 10*vol_id + layer_disk;
358 }
else if (vol_id == 8) {
360 new_vol = 10*vol_id + layer_disk;
363 auto t = std::make_tuple(barrel_ec==0 ? -100 : barrel_ec, subdetid, new_vol, new_lay);
364 std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >
::iterator it = hashMap.find(t);
365 if(it==hashMap.end())
366 hashMap.insert(std::pair<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1,
PhiEtaHash(phi_index, eta_index, hash) )));
367 else (*it).second.push_back(
PhiEtaHash(phi_index, eta_index, hash));
378 for(std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >
::iterator it = hashMap.begin();it!=hashMap.end();++it, layerId++) {
380 short barrel_ec = std::get<0>((*it).first);
381 short subdetId = std::get<1>((*it).first);
382 if(barrel_ec == -100) barrel_ec = 0;
387 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
393 for(std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >
::iterator it = hashMap.begin();it!=hashMap.end();++it) {
409 if (
m_detStore->retrieve(sct_mgr,
"SCT").isFailure()) {
414 if (
m_detStore->retrieve(pix_mgr,
"Pixel").isFailure()) {
422 const size_t bufferOffset = 256;
423 size_t totalSize = bufferOffset + dataTypeSize;
432 memset(pArray,0,dataTypeSize);
434 int nLayers = (int)hashMap.size();
440 for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >
::const_iterator it = hashMap.begin();it!=hashMap.end();++it, layerIdx++) {
441 short subdetid = std::get<0>((*it).first);
442 short barrel_ec = std::get<1>((*it).first);
448 std::vector<std::vector<PhiEtaHash>::const_iterator> vStops;
449 vStops.push_back((*it).second.begin());
450 std::vector<PhiEtaHash>::const_iterator firstIt = (*it).second.begin();
451 std::vector<PhiEtaHash>::const_iterator nextIt = (*it).second.begin();
456 for(; nextIt!=(*it).second.end();++nextIt, ++firstIt) {
457 if((*nextIt).m_phiIndex!=(*firstIt).m_phiIndex) {
458 vStops.push_back(nextIt);
465 vStops.push_back((*it).second.end());
468 float minBound = 100000.0;
469 float maxBound =-100000.0;
475 for(
unsigned int iStops = 1; iStops<vStops.size();iStops++) {
481 for(std::vector<PhiEtaHash>::const_iterator hIt = vStops[iStops-1];hIt!=vStops[iStops];++hIt, nPhiModules++) {
495 rc += sqrt(
C(0)*
C(0)+
C(1)*
C(1));
496 if(p->zMin() < minBound) minBound = p->zMin();
497 if(p->zMax() > maxBound) maxBound = p->zMax();
503 if(p->rMin() < minBound) minBound = p->rMin();
504 if(p->rMax() > maxBound) maxBound = p->rMax();
518 std::shared_ptr<TrigAccel::OffloadBuffer> pDMBuff = std::make_shared<TrigAccel::OffloadBuffer>(pBG);
533 const PixelID* pixelId =
nullptr;
534 const SCT_ID* sctId =
nullptr;
536 if (
m_detStore->retrieve(pixelId,
"PixelID").isFailure()) {
541 if (
m_detStore->retrieve(sctId,
"SCT_ID").isFailure()) {
552 if(offlineId==0)
continue;
554 short barrel_ec = pixelId->
barrel_ec(offlineId);
555 if(abs(barrel_ec)>2)
continue;
556 short layer_disk = pixelId->
layer_disk(offlineId);
557 short phi_index = pixelId->
phi_module(offlineId);
558 short eta_index = pixelId->
eta_module(offlineId);
559 auto t = std::make_tuple(subdetid, barrel_ec, layer_disk);
560 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >
::iterator it = hashMap.find(t);
561 if(it==hashMap.end())
562 hashMap.insert(std::pair<std::tuple<short,short,short>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1,
PhiEtaHash(phi_index, eta_index, hash) )));
563 else (*it).second.push_back(
PhiEtaHash(phi_index, eta_index, hash));
570 if(offlineId==0)
continue;
572 short barrel_ec = sctId->
barrel_ec(offlineId);
573 short layer_disk = sctId->
layer_disk(offlineId);
574 short phi_index = sctId->
phi_module(offlineId);
575 short eta_index = sctId->
eta_module(offlineId);
577 auto t = std::make_tuple(subdetid, barrel_ec, layer_disk);
578 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >
::iterator it = hashMap.find(t);
579 if(it==hashMap.end())
580 hashMap.insert(std::pair<std::tuple<short,short,short>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1,
PhiEtaHash(phi_index, eta_index, hash))));
581 else (*it).second.push_back(
PhiEtaHash(phi_index, eta_index, hash));
589 for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >
::iterator it = hashMap.begin();it!=hashMap.end();++it, layerId++) {
591 short subdetId = std::get<0>((*it).first);
592 short barrel_ec = std::get<1>((*it).first);
597 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
602 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
609 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)
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.
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 > > &)
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]