ATLAS Offline Software
Loading...
Searching...
No Matches
TrigInDetAccelerationSvc Class Reference

Service for creating GPU-accelerated Work items for HLT ID algorithms. More...

#include <TrigInDetAccelerationSvc.h>

Inheritance diagram for TrigInDetAccelerationSvc:
Collaboration diagram for TrigInDetAccelerationSvc:

Classes

struct  PhiEtaHash

Public Member Functions

 TrigInDetAccelerationSvc (const std::string &, ISvcLocator *)
 Constructor.
virtual ~TrigInDetAccelerationSvc () override
virtual StatusCode initialize () override
 Initialize.
virtual StatusCode finalize () override
 Finalize.
virtual void handle (const Incident &) override
 OnBeginRun data gathering and export.
virtual bool isReady () const override
virtual TrigAccel::WorkcreateWork (unsigned int, std::shared_ptr< TrigAccel::OffloadBuffer >) const override
virtual const std::vector< short > & getLayerInformation (int) const override
virtual size_t getMiddleLayersSize () const override

Private Member Functions

bool exportGeometryInformation (const std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > &) const
bool extractGeometryInformation (std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > &)
bool extractITkGeometryInformation (std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > &)
bool exportITkGeometryInformation (const std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > &hashMap) const

Private Attributes

int m_nDCs
std::string m_moduleName
bool m_useITkGeometry
std::vector< int > m_middleSpacePointLayers
void * m_libHandle
TrigAccel::WorkFactorym_pWF
TrigAccel::Modulem_module
ServiceHandle< StoreGateSvcm_detStore
ServiceHandle< StoreGateSvcm_evtStore
bool m_factoryConfigured
std::vector< short > m_layerInfo [3]
std::mutex m_workMutex

Detailed Description

Service for creating GPU-accelerated Work items for HLT ID algorithms.

Definition at line 29 of file TrigInDetAccelerationSvc.h.

Constructor & Destructor Documentation

◆ TrigInDetAccelerationSvc()

TrigInDetAccelerationSvc::TrigInDetAccelerationSvc ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructor.

Definition at line 27 of file TrigInDetAccelerationSvc.cxx.

27 :
28 base_class( name, pSvcLocator ),
29 m_nDCs(12),
30 m_moduleName("libTrigInDetCUDA.so"),
31 m_useITkGeometry(false),
32 m_libHandle(0),
33 m_pWF(0),
34 m_module(0),
35 m_detStore("DetectorStore", name),
36 m_evtStore("StoreGateSvc",name),
37 m_factoryConfigured(false) {
38
39 declareProperty( "NumberOfDCs", m_nDCs = 8 );
40 declareProperty( "ModuleName", m_moduleName = "libTrigInDetCUDA.so");
41 declareProperty( "useITkGeometry", m_useITkGeometry = false);
42 declareProperty( "MiddleSpacePointLayers", m_middleSpacePointLayers = std::vector<int>(), "Global IDs of layers that can contain middle spacepoints of track seeds" );
43}
ServiceHandle< StoreGateSvc > m_evtStore
ServiceHandle< StoreGateSvc > m_detStore
std::vector< int > m_middleSpacePointLayers
TrigAccel::WorkFactory * m_pWF

◆ ~TrigInDetAccelerationSvc()

virtual TrigInDetAccelerationSvc::~TrigInDetAccelerationSvc ( )
inlineoverridevirtual

Definition at line 35 of file TrigInDetAccelerationSvc.h.

35{};

Member Function Documentation

◆ createWork()

TrigAccel::Work * TrigInDetAccelerationSvc::createWork ( unsigned int jobCode,
std::shared_ptr< TrigAccel::OffloadBuffer > pB ) const
overridevirtual

Definition at line 177 of file TrigInDetAccelerationSvc.cxx.

177 {
178
179 if(!m_factoryConfigured) return 0;
180
181 // To remove this, WorkFactory::createWork() should be made const
182 // (and thread-safe).
183 std::scoped_lock lock (m_workMutex);
184 TrigAccel::WorkFactory* wf ATLAS_THREAD_SAFE = m_pWF;
185 return wf->createWork(jobCode, pB);
186
187}
#define ATLAS_THREAD_SAFE

◆ exportGeometryInformation()

bool TrigInDetAccelerationSvc::exportGeometryInformation ( const std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > & hashMap) const
private

Definition at line 403 of file TrigInDetAccelerationSvc.cxx.

403 {
404
405 const InDetDD::SCT_DetectorManager * sct_mgr = nullptr;
406 const InDetDD::PixelDetectorManager * pix_mgr = nullptr;
407
408 if (m_detStore->retrieve(sct_mgr, "SCT").isFailure()) {
409 ATH_MSG_WARNING("failed to get SCT Manager");
410 return false;
411
412 }
413 if (m_detStore->retrieve(pix_mgr,"Pixel").isFailure()) {
414 ATH_MSG_WARNING("failed to get SCT Manager");
415 return false;
416 }
417
418 //export layer structure
419
420 size_t dataTypeSize = sizeof(TrigAccel::DETECTOR_MODEL);
421 const size_t bufferOffset = 256;
422 size_t totalSize = bufferOffset + dataTypeSize;
423
425
426 if(!pBG->fit(totalSize)) pBG->reallocate(totalSize);
427
428 TrigAccel::DETECTOR_MODEL* pArray = reinterpret_cast<TrigAccel::DETECTOR_MODEL*>(pBG->m_buffer + bufferOffset);
429
430 // cppcheck-suppress memsetClassFloat; deliberate
431 memset(pArray,0,dataTypeSize);
432
433 int nLayers = (int)hashMap.size();
434 pArray->m_nLayers = nLayers;
435 pArray->m_nModules=0;
436
437 int layerIdx=0;
438
439 for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::const_iterator it = hashMap.begin();it!=hashMap.end();++it, layerIdx++) {
440 short subdetid = std::get<0>((*it).first);
441 short barrel_ec = std::get<1>((*it).first);
442
443 pArray->m_layers[layerIdx].m_nElements = 0;
444 pArray->m_layers[layerIdx].m_subdet = subdetid;
445 pArray->m_layers[layerIdx].m_type = barrel_ec;
446
447 std::vector<std::vector<PhiEtaHash>::const_iterator> vStops;
448 vStops.push_back((*it).second.begin());
449 std::vector<PhiEtaHash>::const_iterator firstIt = (*it).second.begin();
450 std::vector<PhiEtaHash>::const_iterator nextIt = (*it).second.begin();
451 ++nextIt;
452
453 int nPhiSlices=0;
454
455 for(; nextIt!=(*it).second.end();++nextIt, ++firstIt) {
456 if((*nextIt).m_phiIndex!=(*firstIt).m_phiIndex) {
457 vStops.push_back(nextIt);
458 nPhiSlices++;
459 }
460 }
461
462 nPhiSlices++;
463
464 vStops.push_back((*it).second.end());
465
466 float rc=0.0;
467 float minBound = 100000.0;
468 float maxBound =-100000.0;
469
470 pArray->m_layers[layerIdx].m_nPhiSlices = nPhiSlices;
471
472 //3. iterating over phi sectors
473
474 for(unsigned int iStops = 1; iStops<vStops.size();iStops++) {
475
476 bool first = true;
477
478 for(std::vector<PhiEtaHash>::const_iterator hIt = vStops[iStops-1];hIt!=vStops[iStops];++hIt) {
479
480 pArray->m_hashArray[pArray->m_nModules] = (*hIt).m_hash;
481
482 const InDetDD::SiDetectorElement *p = (subdetid==1) ? pix_mgr->getDetectorElement((*hIt).m_hash) : sct_mgr->getDetectorElement((*hIt).m_hash);
483
484 if(first) {
485 first = false;
486 }
487
488 pArray->m_layers[layerIdx].m_nElements++;
489
490 const Amg::Vector3D& C = p->center();
491 if(barrel_ec == 0) {
492 rc += sqrt(C(0)*C(0)+C(1)*C(1));
493 if(p->zMin() < minBound) minBound = p->zMin();
494 if(p->zMax() > maxBound) maxBound = p->zMax();
495 pArray->m_minRZ[pArray->m_nModules] = p->zMin();
496 pArray->m_maxRZ[pArray->m_nModules] = p->zMax();
497 }
498 else {
499 rc += C(2);
500 if(p->rMin() < minBound) minBound = p->rMin();
501 if(p->rMax() > maxBound) maxBound = p->rMax();
502 pArray->m_minRZ[pArray->m_nModules] = p->rMin();
503 pArray->m_maxRZ[pArray->m_nModules] = p->rMax();
504 }
505
506 pArray->m_nModules++;
507 }
508
509 }
510 pArray->m_layers[layerIdx].m_refCoord = rc/pArray->m_layers[layerIdx].m_nElements;
511 pArray->m_layers[layerIdx].m_minBound = minBound;
512 pArray->m_layers[layerIdx].m_maxBound = maxBound;
513 }
514
515 std::shared_ptr<TrigAccel::OffloadBuffer> pDMBuff = std::make_shared<TrigAccel::OffloadBuffer>(pBG);
516
517 delete pBG;
518
520
522
523 return pW == 0;//request is actioned immediately, no actual WorkItem is created
524
525}
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
static Double_t rc
static unsigned int totalSize(const MultiDimArray< T, N > &ht)
virtual const SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier
virtual const SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements via Identifier
virtual TrigAccel::Work * createWork(unsigned int, std::shared_ptr< TrigAccel::OffloadBuffer >) const override
struct color C
Eigen::Matrix< double, 3, 1 > Vector3D
bool first
Definition DeMoScan.py:534
struct TrigAccel::DataExportBuffer DATA_EXPORT_BUFFER
struct TrigAccel::DetectorModel DETECTOR_MODEL
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]

◆ exportITkGeometryInformation()

bool TrigInDetAccelerationSvc::exportITkGeometryInformation ( const std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > & hashMap) const
private

Definition at line 195 of file TrigInDetAccelerationSvc.cxx.

195 {
196
197 const InDetDD::PixelDetectorManager * pix_mgr = nullptr;
198
199 if (m_detStore->retrieve(pix_mgr,"ITkPixel").isFailure()) {
200 ATH_MSG_WARNING("failed to get ITkPixel Manager");
201 return false;
202 }
203
204 //export layer structure
205
206 size_t dataTypeSize = sizeof(TrigAccel::ITk::DETECTOR_MODEL);
207 const size_t bufferOffset = 256;
208 size_t totalSize = bufferOffset + dataTypeSize;
209
211
212 if(!pBG->fit(totalSize)) pBG->reallocate(totalSize);
213
214 TrigAccel::ITk::DETECTOR_MODEL* pArray = reinterpret_cast<TrigAccel::ITk::DETECTOR_MODEL*>(pBG->m_buffer + bufferOffset);
215
216 // cppcheck-suppress memsetClassFloat; deliberate
217 memset(pArray,0,dataTypeSize);
218
219 int nLayers = (int)hashMap.size();
220 pArray->m_nLayers = nLayers;
221 pArray->m_nModules=0;
222
223 int layerIdx=0;
224 int middleLayerIdx=0;
225
226 for(std::map<std::tuple<short,short, int, int>,std::vector<PhiEtaHash> >::const_iterator it = hashMap.begin();it!=hashMap.end();++it, layerIdx++) {
227
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;
233
234 pArray->m_layers[layerIdx].m_nElements = 0;
235 pArray->m_layers[layerIdx].m_subdet = globalLayerId;
236 pArray->m_layers[layerIdx].m_type = barrel_ec;
237
238 // Fill in a table of layer ids that can contain the middle SPs
239 if (std::find(m_middleSpacePointLayers.begin(), m_middleSpacePointLayers.end(), globalLayerId) != m_middleSpacePointLayers.end()){
240 pArray->m_middleSpacePointLayers[middleLayerIdx] = layerIdx;
241 ++middleLayerIdx;
242 }
243
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();
248 ++nextIt;
249
250 int nPhiSlices=0;
251
252 for(; nextIt!=(*it).second.end();++nextIt, ++firstIt) {
253 if((*nextIt).m_phiIndex!=(*firstIt).m_phiIndex) {
254 vStops.push_back(nextIt);
255 nPhiSlices++;
256 }
257 }
258
259 nPhiSlices++;
260
261 vStops.push_back((*it).second.end());
262
263 float rc=0.0;
264 float minBound = 100000.0;
265 float maxBound =-100000.0;
266
267 pArray->m_layers[layerIdx].m_nPhiSlices = nPhiSlices;
268
269 //3. iterating over phi sectors
270
271 for(unsigned int iStops = 1; iStops<vStops.size();iStops++) {
272 bool first = true;
273
274 for(std::vector<PhiEtaHash>::const_iterator hIt = vStops[iStops-1];hIt!=vStops[iStops];++hIt) {
275
276 pArray->m_hashArray[pArray->m_nModules] = (*hIt).m_hash;
277 const InDetDD::SiDetectorElement *p = pix_mgr->getDetectorElement((*hIt).m_hash);
278
279 if (first) {
280 first = false;
281 }
282
283 pArray->m_layers[layerIdx].m_nElements++;
284
285 const Amg::Vector3D& C = p->center();
286 if (barrel_ec == 0) {
287 rc += sqrt(C(0)*C(0)+C(1)*C(1));
288 if(p->zMin() < minBound) minBound = p->zMin();
289 if(p->zMax() > maxBound) maxBound = p->zMax();
290 pArray->m_minRZ[pArray->m_nModules] = p->zMin();
291 pArray->m_maxRZ[pArray->m_nModules] = p->zMax();
292 } else {
293 rc += C(2);
294 if(p->rMin() < minBound) minBound = p->rMin();
295 if(p->rMax() > maxBound) maxBound = p->rMax();
296 pArray->m_minRZ[pArray->m_nModules] = p->rMin();
297 pArray->m_maxRZ[pArray->m_nModules] = p->rMax();
298 }
299
300 pArray->m_nModules++;
301 }
302
303 }
304 pArray->m_layers[layerIdx].m_refCoord = rc/pArray->m_layers[layerIdx].m_nElements;
305 pArray->m_layers[layerIdx].m_minBound = minBound;
306 pArray->m_layers[layerIdx].m_maxBound = maxBound;
307 }
308
309 std::shared_ptr<TrigAccel::OffloadBuffer> pDMBuff = std::make_shared<TrigAccel::OffloadBuffer>(pBG);
310
311 delete pBG;
312
314
316
317 return pW == 0;//request is actioned immediately, no actual WorkItem is created
318
319}
struct TrigAccel::ITk::DetectorModel DETECTOR_MODEL
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]

◆ extractGeometryInformation()

bool TrigInDetAccelerationSvc::extractGeometryInformation ( std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > & hashMap)
private

Definition at line 528 of file TrigInDetAccelerationSvc.cxx.

528 {
529
530 const PixelID* pixelId = nullptr;
531 const SCT_ID* sctId = nullptr;
532
533 if (m_detStore->retrieve(pixelId, "PixelID").isFailure()) {
534 ATH_MSG_WARNING("Could not get Pixel ID helper");
535 return false;
536 }
537
538 if (m_detStore->retrieve(sctId, "SCT_ID").isFailure()) {
539 ATH_MSG_WARNING("Could not get Pixel ID helper");
540 return false;
541 }
542
543 short subdetid = 1;
544
545 for(int hash = 0; hash<(int)pixelId->wafer_hash_max(); hash++) {
546
547 Identifier offlineId = pixelId->wafer_id(hash);
548
549 if(offlineId==0) continue;
550
551 short barrel_ec = pixelId->barrel_ec(offlineId);
552 if(abs(barrel_ec)>2) continue;//no DBM needed
553 short layer_disk = pixelId->layer_disk(offlineId);
554 short phi_index = pixelId->phi_module(offlineId);
555 short eta_index = pixelId->eta_module(offlineId);
556 auto t = std::make_tuple(subdetid, barrel_ec, layer_disk);
557 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.find(t);
558 if(it==hashMap.end())
559 hashMap.insert(std::pair<std::tuple<short,short,short>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1, PhiEtaHash(phi_index, eta_index, hash) )));
560 else (*it).second.push_back(PhiEtaHash(phi_index, eta_index, hash));
561 }
562 subdetid = 2;
563 for(int hash = 0; hash<(int)sctId->wafer_hash_max(); hash++) {
564
565 Identifier offlineId = sctId->wafer_id(hash);
566
567 if(offlineId==0) continue;
568
569 short barrel_ec = sctId->barrel_ec(offlineId);
570 short layer_disk = sctId->layer_disk(offlineId);
571 short phi_index = sctId->phi_module(offlineId);
572 short eta_index = sctId->eta_module(offlineId);
573
574 auto t = std::make_tuple(subdetid, barrel_ec, layer_disk);
575 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.find(t);
576 if(it==hashMap.end())
577 hashMap.insert(std::pair<std::tuple<short,short,short>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1, PhiEtaHash(phi_index, eta_index, hash))));
578 else (*it).second.push_back(PhiEtaHash(phi_index, eta_index, hash));
579 }
580
581 m_layerInfo[1].resize(pixelId->wafer_hash_max(), -1);
582 m_layerInfo[2].resize(sctId->wafer_hash_max(), -1);
583
584 int layerId=0;
585
586 for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.begin();it!=hashMap.end();++it, layerId++) {
587
588 short subdetId = std::get<0>((*it).first);
589 short barrel_ec = std::get<1>((*it).first);
590
591 m_layerInfo[0].push_back(barrel_ec);
592
593 if(subdetId == 1) {//pixel
594 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
595 m_layerInfo[subdetId][(*hIt).m_hash] = layerId;
596 }
597 }
598 if(subdetId == 2) {//SCT
599 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
600 m_layerInfo[subdetId][(*hIt).m_hash] = layerId;
601 }
602 }
603 }
604
605
606 for(std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> >::iterator it = hashMap.begin();it!=hashMap.end();++it) {
607
608 //sorting along phi first, then along eta
609
610 std::sort((*it).second.begin(), (*it).second.end(), PhiEtaHash::compare());
611
612 }
613 return true;
614}
int layer_disk(const Identifier &id) const
Definition PixelID.h:607
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition PixelID.h:360
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition PixelID.h:600
size_type wafer_hash_max() const
Definition PixelID.cxx:801
int eta_module(const Identifier &id) const
Definition PixelID.h:632
int phi_module(const Identifier &id) const
Definition PixelID.h:625
size_type wafer_hash_max() const
Definition SCT_ID.cxx:621
int layer_disk(const Identifier &id) const
Definition SCT_ID.h:687
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int side) const
For a single side of module.
Definition SCT_ID.h:459
int phi_module(const Identifier &id) const
Definition SCT_ID.h:693
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition SCT_ID.h:681
int eta_module(const Identifier &id) const
Definition SCT_ID.h:699
std::vector< short > m_layerInfo[3]
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ extractITkGeometryInformation()

bool TrigInDetAccelerationSvc::extractITkGeometryInformation ( std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > & hashMap)
private

Definition at line 322 of file TrigInDetAccelerationSvc.cxx.

322 {
323
324 const PixelID* pixelId = nullptr;
325
326 if (m_detStore->retrieve(pixelId, "PixelID").isFailure()) {
327 ATH_MSG_WARNING("Could not get Pixel ID helper");
328 return false;
329 }
330
331 // Read Pixel layer details
332 short subdetid = 1;
333 for(int hash = 0; hash<(int)pixelId->wafer_hash_max(); hash++) {
334
335 Identifier offlineId = pixelId->wafer_id(hash);
336
337 if(offlineId==0) continue;
338
339 short barrel_ec = pixelId->barrel_ec(offlineId);
340 if(abs(barrel_ec)>2) continue;//no DBM needed
341
342 short phi_index = pixelId->phi_module(offlineId);
343 short eta_index = pixelId->eta_module(offlineId);
344 short layer_disk = pixelId->layer_disk(offlineId);
345
346 // Calculate new volume and layer id for ITk
347 int vol_id = -1;
348 if (barrel_ec== 0) vol_id = 8;
349 if (barrel_ec==-2) vol_id = 7;
350 if (barrel_ec== 2) vol_id = 9;
351
352 int new_vol=0, new_lay=0;
353
354 if (vol_id == 7 || vol_id == 9) {
355 new_vol = 10*vol_id + layer_disk;
356 new_lay = eta_index;
357 } else if (vol_id == 8) {
358 new_lay = 0;
359 new_vol = 10*vol_id + layer_disk;
360 }
361
362 auto t = std::make_tuple(barrel_ec==0 ? -100 : barrel_ec, subdetid, new_vol, new_lay);
363 std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >::iterator it = hashMap.find(t);
364 if(it==hashMap.end())
365 hashMap.insert(std::pair<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >(t,std::vector<PhiEtaHash>(1, PhiEtaHash(phi_index, eta_index, hash) )));
366 else (*it).second.push_back(PhiEtaHash(phi_index, eta_index, hash));
367 }
368
369 m_layerInfo[0].clear();
370 m_layerInfo[1].clear();
371
372 m_layerInfo[0].resize(hashMap.size()); // Mapping from layerId to barrel_ec
373 m_layerInfo[1].resize(pixelId->wafer_hash_max(), -1); // Mapping from layerId to the module hash
374
375 // Map layer geometry details to module hash id
376 int layerId=0;
377 for(std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >::iterator it = hashMap.begin();it!=hashMap.end();++it, layerId++) {
378
379 short barrel_ec = std::get<0>((*it).first);
380 short subdetId = std::get<1>((*it).first);
381 if(barrel_ec == -100) barrel_ec = 0;
382
383 m_layerInfo[0][layerId] = barrel_ec;
384
385 if(subdetId == 1) {//pixel
386 for(std::vector<PhiEtaHash>::iterator hIt = (*it).second.begin();hIt != (*it).second.end();++hIt) {
387 m_layerInfo[subdetId][(*hIt).m_hash] = layerId;
388 }
389 }
390 }
391
392 for(std::map<std::tuple<short,short,int,int>,std::vector<PhiEtaHash> >::iterator it = hashMap.begin();it!=hashMap.end();++it) {
393
394 //sorting along phi first, then along eta
395 std::sort((*it).second.begin(), (*it).second.end(), PhiEtaHash::compare());
396
397 }
398
399 return true;
400}

◆ finalize()

StatusCode TrigInDetAccelerationSvc::finalize ( )
overridevirtual

Finalize.

Definition at line 129 of file TrigInDetAccelerationSvc.cxx.

129 {
130
131 delete m_pWF;
132
133 dlclose(m_libHandle);
134
135 return StatusCode::SUCCESS;
136}

◆ getLayerInformation()

const std::vector< short > & TrigInDetAccelerationSvc::getLayerInformation ( int i) const
overridevirtual

Definition at line 190 of file TrigInDetAccelerationSvc.cxx.

190 {
191 if (i<0 || i>2) i = 0;
192 return m_layerInfo[i];
193}

◆ getMiddleLayersSize()

virtual size_t TrigInDetAccelerationSvc::getMiddleLayersSize ( ) const
inlineoverridevirtual

Definition at line 47 of file TrigInDetAccelerationSvc.h.

47{return m_middleSpacePointLayers.size();};

◆ handle()

void TrigInDetAccelerationSvc::handle ( const Incident & )
overridevirtual

OnBeginRun data gathering and export.

Definition at line 143 of file TrigInDetAccelerationSvc.cxx.

143 {
144
145 ATH_MSG_INFO("OnBeginRun ");
146
147 if (m_useITkGeometry) {
148 // barrel ec, subdetector id, itk volume id, itk layer disk id
149 std::map<std::tuple<short,short, int, int>,std::vector<PhiEtaHash> > hashMap;
150 if(!extractITkGeometryInformation(hashMap)) {
151 ATH_MSG_INFO("ITk Geometry extraction failed");
152 return;
153 }
154
155 if(!exportITkGeometryInformation(hashMap)) {
156 ATH_MSG_INFO("ITk Geometry export failed");
157 }
158
159 } else {
160 // subdetector id, barrel ec, layer disk
161 std::map<std::tuple<short,short,short>,std::vector<PhiEtaHash> > hashMap;
162
163 if(!extractGeometryInformation(hashMap)) {
164 ATH_MSG_INFO("Geometry extraction failed");
165 return;
166 }
167
168 if(!exportGeometryInformation(hashMap)) {
169 ATH_MSG_INFO("Geometry export failed");
170 }
171
172 }
173
174 return;
175}
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
bool extractITkGeometryInformation(std::map< std::tuple< short, short, int, int >, std::vector< PhiEtaHash > > &)
bool extractGeometryInformation(std::map< std::tuple< short, short, short >, std::vector< PhiEtaHash > > &)

◆ initialize()

StatusCode TrigInDetAccelerationSvc::initialize ( )
overridevirtual

Initialize.

Definition at line 50 of file TrigInDetAccelerationSvc.cxx.

50 {
51
52 ATH_MSG_INFO("TrigInDetAccelerationSvc: initialize");
53
54 ATH_CHECK (m_evtStore.retrieve() );
55 ATH_CHECK (m_detStore.retrieve() );
56
57 //load the OffloadFactory library
58
59 m_libHandle = dlopen(m_moduleName.c_str(), RTLD_LAZY);
60
61 if(!m_libHandle) {
62 ATH_MSG_INFO("TrigInDetAccelerationSvc: cannot load the factory library, error:"<<dlerror());
63 return StatusCode::SUCCESS;
64 }
65
66 dlerror();
67
68 //declare library interface methods
69 TrigAccel::Module* (*getModule)();
70
71 getModule = (TrigAccel::Module* (*)()) dlsym(m_libHandle, "getModule");
72
74
75 int factory_id_to_load = 0;
76
78 factory_id_to_load = TrigAccel::TrigITkModuleID_CUDA;
79 }else{
80 factory_id_to_load = TrigAccel::TrigInDetModuleID_CUDA;
81 }
82
83 m_pWF = m_module->getFactoryById(factory_id_to_load);
84
85 if(m_pWF == nullptr){
86 ATH_MSG_INFO("OffloadFactory with id "<<std::hex<<factory_id_to_load<<" not available from the module");
87 m_factoryConfigured = false;
88 return StatusCode::SUCCESS;
89 }
90
91 bool cfgResult = m_pWF->configure();
92
93 if(!cfgResult) {
94 ATH_MSG_INFO("OffloadFactory config failed");
95 m_factoryConfigured = false;
96 return StatusCode::SUCCESS;
97 }
98
100
101 for(int i=0;i<3;i++) m_layerInfo[i].clear();
102
103 ATH_MSG_INFO("TrigInDetAccelerationSvc: created OffloadFactory, factory id = "<<std::hex<<m_pWF->getFactoryId()<<std::dec);
104
105 /*
106 * Ask to be informed at the beginning of a new run so that we
107 * can collect geometry, conditions, etc. and copy them to on-GPU data structures
108 * For athenaHLT this should be UpdateAfterFork
109 */
110
111 SmartIF<IIncidentSvc> incsvc{service("IncidentSvc")};
112 const int priority = 100;
113 if( incsvc ) {
114 const bool is_multiprocess = (Gaudi::Concurrency::ConcurrencyFlags::numProcs() > 0);
115 if (is_multiprocess) {
116 incsvc->addListener( this, AthenaInterprocess::UpdateAfterFork::type(), priority);
117 }
118 else {
119 incsvc->addListener( this, "BeginRun", priority);
120 }
121 }
122
123 return StatusCode::SUCCESS;
124}
#define ATH_CHECK
Evaluate an expression and check for errors.
bool getModule(std::istream &s, RegSelModule &m)
static const std::string & type()
Incident type.
Definition Incidents.h:49
constexpr unsigned int TrigITkModuleID_CUDA
constexpr unsigned int TrigInDetModuleID_CUDA

◆ isReady()

virtual bool TrigInDetAccelerationSvc::isReady ( ) const
inlineoverridevirtual

Definition at line 41 of file TrigInDetAccelerationSvc.h.

41 {
43 }

Member Data Documentation

◆ m_detStore

ServiceHandle<StoreGateSvc> TrigInDetAccelerationSvc::m_detStore
private

Definition at line 78 of file TrigInDetAccelerationSvc.h.

◆ m_evtStore

ServiceHandle<StoreGateSvc> TrigInDetAccelerationSvc::m_evtStore
private

Definition at line 79 of file TrigInDetAccelerationSvc.h.

◆ m_factoryConfigured

bool TrigInDetAccelerationSvc::m_factoryConfigured
private

Definition at line 81 of file TrigInDetAccelerationSvc.h.

◆ m_layerInfo

std::vector<short> TrigInDetAccelerationSvc::m_layerInfo[3]
private

Definition at line 91 of file TrigInDetAccelerationSvc.h.

◆ m_libHandle

void* TrigInDetAccelerationSvc::m_libHandle
private

Definition at line 75 of file TrigInDetAccelerationSvc.h.

◆ m_middleSpacePointLayers

std::vector<int> TrigInDetAccelerationSvc::m_middleSpacePointLayers
private

Definition at line 74 of file TrigInDetAccelerationSvc.h.

◆ m_module

TrigAccel::Module* TrigInDetAccelerationSvc::m_module
private

Definition at line 77 of file TrigInDetAccelerationSvc.h.

◆ m_moduleName

std::string TrigInDetAccelerationSvc::m_moduleName
private

Definition at line 72 of file TrigInDetAccelerationSvc.h.

◆ m_nDCs

int TrigInDetAccelerationSvc::m_nDCs
private

Definition at line 71 of file TrigInDetAccelerationSvc.h.

◆ m_pWF

TrigAccel::WorkFactory* TrigInDetAccelerationSvc::m_pWF
private

Definition at line 76 of file TrigInDetAccelerationSvc.h.

◆ m_useITkGeometry

bool TrigInDetAccelerationSvc::m_useITkGeometry
private

Definition at line 73 of file TrigInDetAccelerationSvc.h.

◆ m_workMutex

std::mutex TrigInDetAccelerationSvc::m_workMutex
mutableprivate

Definition at line 93 of file TrigInDetAccelerationSvc.h.


The documentation for this class was generated from the following files: