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

#include <ITkPixelCsvWaferIdAlg.h>

Inheritance diagram for ITkPixelCsvWaferIdAlg:
Collaboration diagram for ITkPixelCsvWaferIdAlg:

Classes

struct  CsvRow

Public Member Functions

 ITkPixelCsvWaferIdAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~ITkPixelCsvWaferIdAlg ()=default
virtual StatusCode initialize () override
virtual StatusCode execute (const EventContext &ctx) const override
const std::vector< CsvRow > & rows () const
StatusCode loadCsv ()
std::tuple< Identifier, int, std::bitset< 32 > > waferId (const CsvRow &row) const
std::bitset< 32 > onlineId (const std::vector< std::string > &spchain, const std::string &mod, int fe) const
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
 Get filter decision:
virtual void setFilterPassed (bool state, const EventContext &ctx) const
 Set filter decision:
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

std::vector< int > DmaBuffer () const
std::bitset< 32 > sourceID (const std::vector< std::string > &spchain, const std::string &flx, const unsigned int dma) const
std::vector< std::string > splitFLX_card_device (const std::string &s) const
std::bitset< 32 > subDetID (int barrel_endcap, int layer_disk) const
int barrel_ec (const std::vector< std::string > &spchain) const
int layer_disk (const std::vector< std::string > &spchain) const
int phi_module (const std::vector< std::string > &spchain, const std::string &mod, int fe) const
int eta_module (const std::vector< std::string > &spchain, const std::string &mod, int fe) const
int feID (const std::vector< std::string > &spchain, int fe) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Static Private Member Functions

static std::string trim (const std::string &input)
static std::vector< std::string > splitCsvLine (const std::string &line)
static std::vector< std::string > parseSPChain (const std::string &spChain)

Private Attributes

Gaudi::Property< std::string > m_csvFile
Gaudi::Property< std::string > m_outputFile
const PixelIDm_pixIdHelper = nullptr
std::vector< CsvRowm_rows
std::atomic< bool > m_done {false}
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 24 of file ITkPixelCsvWaferIdAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ITkPixelCsvWaferIdAlg()

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

Definition at line 18 of file ITkPixelCsvWaferIdAlg.cxx.

20 : AthReentrantAlgorithm(name, pSvcLocator)
21{
22}

◆ ~ITkPixelCsvWaferIdAlg()

virtual ITkPixelCsvWaferIdAlg::~ITkPixelCsvWaferIdAlg ( )
virtualdefault

Member Function Documentation

◆ barrel_ec()

int ITkPixelCsvWaferIdAlg::barrel_ec ( const std::vector< std::string > & spchain) const
private

Definition at line 210 of file ITkPixelCsvWaferIdAlg.cxx.

210 {
211
212 if (spchain[1] == "IS" &&
213 (spchain[2] == "L0" || spchain[2] == "L1") &&
214 spchain.at(3)[0] != 'R') { // inner flat barrel
215 return 0;
216 }
217 else if (spchain[1] == "OB" &&
218 (spchain[2] == "L2" || spchain[2] == "L3" ||
219 spchain[2] == "L4") &&
220 (spchain.at(3)[0] == 'B')) { // Outer flat barrel has 3 layers
221 return 0;
222 }
223 else{
224 //Need to calculat the side sign because eta is always positive.
225 std::string sideAC = spchain[4];
226 if(sideAC != "A" && sideAC != "C"){
227 sideAC = spchain[5];
228 }
229 int side = (sideAC == "A")? 1 : -1; // A for side pos, C for side neg
230 return side*2; // endcap is +2 or -2 - this includes barrel rings, in offline they are treated as endcap
231 }
232}
BySideTypeMod sideAC(0)

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ DmaBuffer()

std::vector< int > ITkPixelCsvWaferIdAlg::DmaBuffer ( ) const
private

Definition at line 478 of file ITkPixelCsvWaferIdAlg.cxx.

478 {
479 std::vector<int> dmaNumbers;
480 dmaNumbers.reserve(m_rows.size());
481
482 size_t i = 0;
483 while (i < m_rows.size()) {
484 // find contiguous block for the same felix card device
485 const std::string& card = m_rows[i].flx_card_device;
486 size_t j = i;
487 unsigned int minFiber = std::numeric_limits<unsigned int>::max();
488 for (; j < m_rows.size() && m_rows[j].flx_card_device == card; ++j) {
489 if (m_rows[j].fiber > 0 && m_rows[j].fiber < minFiber){
490 minFiber = m_rows[j].fiber;
491 }
492 }
493 if (minFiber == std::numeric_limits<unsigned int>::max()) {
494 // no valid fiber found in this block, assign 9
495 for (size_t k = i; k < j; ++k){
496 dmaNumbers.push_back(9);
497 }
498 i = j;
499 continue;
500 }
501
502 // assign DMA groups based on minFiber, groups of 3 fibers -> DMA 0..3
503 for (size_t k = i; k < j; ++k) {
504 int dma = 0;
505 if (m_rows[k].fiber >= minFiber) {
506 const int offset = static_cast<int>(m_rows[k].fiber) - static_cast<int>(minFiber);
507 // 3 fibers per DMA buffer except for L0 flat barrel (4 lanes FE --> 2 fibers)
508 int b_ec = barrel_ec(parseSPChain(m_rows[k].spChain));
509 int ld = layer_disk(parseSPChain(m_rows[k].spChain));
510 if(b_ec == 0 && ld ==0){
511 dma = offset / 2;
512 }
513 else{
514 dma = offset / 3;
515 }
516 }
517 if (dma < 0){
518 ATH_MSG_WARNING("Assigned DMA buffer goes negative: " << dma);
519 }
520 if (dma > 3){
521 ATH_MSG_WARNING("Assigned DMA buffer goes higher than 3: " << dma);
522 }
523 dmaNumbers.push_back(std::move(dma));
524 }
525
526 i = j;
527 }
528 return dmaNumbers;
529}
#define ATH_MSG_WARNING(x)
std::vector< CsvRow > m_rows
static std::vector< std::string > parseSPChain(const std::string &spChain)
int barrel_ec(const std::vector< std::string > &spchain) const
int layer_disk(const std::vector< std::string > &spchain) const
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ eta_module()

int ITkPixelCsvWaferIdAlg::eta_module ( const std::vector< std::string > & spchain,
const std::string & mod,
int fe ) const
private

Definition at line 348 of file ITkPixelCsvWaferIdAlg.cxx.

348 {
349 int b_ec = barrel_ec(spchain);
350 int ld = layer_disk(spchain);
351 int side = (spchain[4] == "A") ? 1 : -1; // A for side pos, C for side neg
352
353 if( b_ec == 0 ){ // flat barrel
354 if(ld ==0){ //triplets, one front-end is considered as one module
355 return side * (3 * (std::stoi(mod) -1) + fe );
356 }
357 else if(ld == 1){
358 return side * std::stoi(mod);
359 }
360 else if(ld < 5){
361 std::string eta_str(1, mod[4]);
362 int eta = std::stoi(eta_str);
363 return side * eta;
364 }
365 else{
366 ATH_MSG_WARNING("Bad layer for flat barrel: " << ld);
367 return -9999;
368 }
369 }
370 //barrel rings and end caps - all considered as disks
371 else{
372 if(spchain[2] == "L01"){ // barrel vertical small and large combined rings, disk 0
373 std::string eta_str = (spchain.at(3)).substr(1,2);
374 return std::stoi(eta_str);
375 }
376 else if(ld == 3 || ld == 5 || ld ==7){ //OB inclined rings, disks 3, 5, 7
377 std::string eta_str = (spchain.at(3)).substr(1,2);
378 return std::stoi(eta_str) - 1 ;
379 }
380 else if(ld == 1){ //end-cap rings, inner system, disk 1 (L05) - triplets: one module per FE
381 std::string eta_str = (spchain.at(3)).substr(1,2);
382 return std::stoi(eta_str) - 1;
383 }
384 else if(ld == 2){ // end-cap rings, inner system, disk 2 - eta from 15 to 22
385 std::string eta_str = (spchain.at(3)).substr(1,2);
386 return std::stoi(eta_str) + 14 ;
387 }
388 else if(ld == 4 || ld == 6 || ld ==8){ //Outer EC disks 4, 6, 8
389 std::string eta_str = (spchain.at(3)).substr(1,2);
390 return std::stoi(eta_str) - 1 ;
391 }
392 else{
393 ATH_MSG_WARNING("Bad input for eta_module,return -9999 ");
394 return -9999;
395 }
396 }
397 return -9999;
398}
Scalar eta() const
pseudorapidity method

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode ITkPixelCsvWaferIdAlg::execute ( const EventContext & ctx) const
overridevirtual

Definition at line 33 of file ITkPixelCsvWaferIdAlg.cxx.

33 {
34
35 ATH_CHECK ( ctx.valid() );
36
37 if (m_done.load(std::memory_order_acquire)) {
38 return StatusCode::SUCCESS;
39 }
40
41 bool expected = false;
42 if (!m_done.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
43 return StatusCode::SUCCESS;
44 }
45
46 ATH_MSG_INFO("Executing CsvWaferId algorithm");
47
48 std::ofstream output(m_outputFile.value());
49 if (!output.good()) {
50 ATH_MSG_FATAL("Could not open wafer ID output file: " << m_outputFile.value());
51 return StatusCode::FAILURE;
52 }
53 output << "DetectorResourceID,True DetectorResourceID,FELIX Card Name,Uplink Pin,DMA buffer,SourceID\n";
54
55 std::vector<int> dma_buffer_vec = DmaBuffer();
56
57 for (size_t i = 0; i < m_rows.size(); ++i) {
58 const CsvRow& row = m_rows[i];
59 const auto w_and_fe_id = waferId(row);
60 const Identifier& id = std::get<0>(w_and_fe_id);
61 const int fe = std::get<1>(w_and_fe_id);
62 std::bitset<32> onlineId = std::get<2>(w_and_fe_id);
63 const std::string waferId_str = id.get_identifier32().getString();
64 const auto bec = m_pixIdHelper->barrel_ec(id);
65 const auto ld = m_pixIdHelper->layer_disk(id);
66 const auto phi = m_pixIdHelper->phi_module(id);
67 const auto eta = m_pixIdHelper->eta_module(id);
68
69 std::bitset<32> sID = sourceID( parseSPChain(row.spChain), row.flx_card_device, dma_buffer_vec[i]);
70
71 std::string x = waferId_str.substr(0, waferId_str.length() - 2 );
72 std::stringstream ss;
73 ss << std::hex << x;
74 unsigned n;
75 ss >> n;
76 std::bitset<32> b(n);
77 b <<= 2; //shift left by two bits, to add FE bits
78 std::bitset<32> febits = std::bitset<32>(fe);
79 b |= febits;
80
81 if (msgLvl(MSG::DEBUG)) {
82 output << waferId_str << "\t"
83 << x << "\t"
84 << b.to_string() << "\t"
85 << febits.to_string() << "\t"
86 << bec << "\t"
87 << ld << "\t"
88 << phi << "\t"
89 << eta << "\t"
90 << std::hex<< onlineId.to_ulong() << "\t";
91 }
92 //convert back to hex
93 std::stringstream res;
94 res << std::hex << std::uppercase << b.to_ulong();
95 // keep this, might be useful later
96 //output << res.str() << "\n";
97 output << std::hex << (b| onlineId).to_ulong() << ","
98 << (b| onlineId).to_ulong() << ","
99 << row.flx_card_device << ","
100 << row.fiber << ","
101 << dma_buffer_vec[i] << ","
102 << sID.to_ulong() << "\n";
103
104 }
105
106 ATH_MSG_INFO("Wrote " << m_rows.size() << " wafer IDs to " << m_outputFile.value());
107 return StatusCode::SUCCESS;
108}
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
std::pair< std::vector< unsigned int >, bool > res
static Double_t ss
#define x
bool msgLvl(const MSG::Level lvl) const
std::bitset< 32 > onlineId(const std::vector< std::string > &spchain, const std::string &mod, int fe) const
std::atomic< bool > m_done
std::vector< int > DmaBuffer() const
std::bitset< 32 > sourceID(const std::vector< std::string > &spchain, const std::string &flx, const unsigned int dma) const
Gaudi::Property< std::string > m_outputFile
std::tuple< Identifier, int, std::bitset< 32 > > waferId(const CsvRow &row) const
Number expected
Definition Arrayrep.cxx:222
row
Appending html table to final .html summary file.
output
Definition merge.py:16

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthCommonAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 89 of file AthCommonAlgorithm.cxx.

54{
55 // If we didn't find any symlinks to add, just return the collection
56 // from the base class. Otherwise, return the extended collection.
57 if (!m_extendedExtraObjects.empty()) {
59 }
61}
Common base class for algorithms.

◆ feID()

int ITkPixelCsvWaferIdAlg::feID ( const std::vector< std::string > & spchain,
int fe ) const
private

Definition at line 401 of file ITkPixelCsvWaferIdAlg.cxx.

401 {
402 int ld = layer_disk(spchain);
403 if(ld < 2){ //triplets
404 return 0;
405 }
406 else{ // quads
407 return fe-1;
408 }
409
410}

◆ filterPassed()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Get filter decision:

Definition at line 93 of file AthCommonAlgorithm.h.

93 {
94 return execState( ctx ).filterPassed();
95 }
virtual bool filterPassed(const EventContext &ctx) const
Get filter decision:

◆ initialize()

StatusCode ITkPixelCsvWaferIdAlg::initialize ( )
overridevirtual

Definition at line 24 of file ITkPixelCsvWaferIdAlg.cxx.

24 {
25 ATH_MSG_INFO("Initializing CsvWaferId algorithm");
26 ATH_CHECK(detStore()->retrieve(m_pixIdHelper, "PixelID"));
27 ATH_MSG_INFO("Retrieved PixelID helper");
29 ATH_MSG_INFO("Loaded CSV file");
30 return StatusCode::SUCCESS;
31}
const ServiceHandle< StoreGateSvc > & detStore() const

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::isClonable ( ) const
inlineoverridevirtualinherited

Specify if the algorithm is clonable.

Only relevant for non-reentrant algorithms. Actual number of clones needs to be set via the "Cardinality" property.

Reimplemented in AFP_DigiTop, AlgB, AlgT, BCM_Digitization, CscDigitBuilder, CscDigitToCscRDO, G4AtlasAlg, G4RunAlg, HGTD_Digitization, HiveAlgBase, InDet::GNNSeedingTrackMaker, InDet::SCT_Clusterization, InDet::SiSPGNNTrackMaker, InDet::SiSPSeededTrackFinder, InDet::SiTrackerSpacePointFinder, ISF::SimKernelMT, ITk::StripDigitization, ITkPixelCablingAlg, ITkStripCablingAlg, LArHitEMapMaker, LArTTL1Maker, LUCID_DigiTop, LVL1::L1TopoSimulation, MergeCalibHits, MergeGenericMuonSimHitColl, MergeHijingPars, MergeMcEventCollection, MergeTrackRecordCollection, MergeTruthJets, MergeTruthParticles, MuonDigitizer, PileUpMTAlg, PixelDigitization, RoIBResultToxAOD, SCT_ByteStreamErrorsTestAlg, SCT_CablingCondAlgFromCoraCool, SCT_CablingCondAlgFromText, SCT_ConditionsParameterTestAlg, SCT_ConditionsSummaryTestAlg, SCT_ConfigurationConditionsTestAlg, SCT_Digitization, SCT_FlaggedConditionTestAlg, SCT_LinkMaskingTestAlg, SCT_MajorityConditionsTestAlg, SCT_ModuleVetoTestAlg, SCT_MonitorConditionsTestAlg, SCT_PrepDataToxAOD, SCT_RawDataToxAOD, SCT_ReadCalibChipDataTestAlg, SCT_ReadCalibDataTestAlg, SCT_RODVetoTestAlg, SCT_SensorsTestAlg, SCT_SiliconConditionsTestAlg, SCT_StripVetoTestAlg, SCT_TdaqEnabledTestAlg, SCT_TestCablingAlg, SCTEventFlagWriter, SCTRawDataProvider, SCTSiLorentzAngleTestAlg, SCTSiPropertiesTestAlg, SGInputLoader, Simulation::BeamEffectsAlg, TileHitVecToCnt, TileMuonFitter, TilePulseForTileMuonReceiver, TileRawChannelMaker, TRTDigitization, and ZDC_DigiTop.

Definition at line 68 of file AthCommonAlgorithm.h.

68 {
69 return true;
70 }

◆ layer_disk()

int ITkPixelCsvWaferIdAlg::layer_disk ( const std::vector< std::string > & spchain) const
private

Definition at line 234 of file ITkPixelCsvWaferIdAlg.cxx.

234 {
235 int b_ec = barrel_ec(spchain);
236 if( b_ec == 0 ){ // flat barrel
237 return spchain.at(2)[1] - '0';
238 }
239 else{ // endcap and barrel rings - all considered as 'endcap' disks
240 if (spchain[2] == "L01" &&
241 (spchain.at(5) == "SP1" || spchain.at(5) == "SP3")) { // barrel vertical small combined rings, disk 0
242 return 0;
243 }
244 else if (spchain[2] == "L01" &&
245 (spchain.at(5) == "SP2" || spchain.at(5) == "SP4")) { // barrel vertical large combined rings, disk 2
246 return 2;
247 }
248 else if(spchain[1] == "OB" && (spchain[2] == "L2" || //OB inclined rings, disks 3, 5, 7
249 spchain[2] == "L3" ||
250 spchain[2] == "L4") ){
251 return (2* ((spchain.at(2))[1] -'0') - 1);
252 }
253 else if(spchain[1] == "IS" && spchain[2] == "L05"){
254 return 1; // end-cap rings, inner system, disk 1
255 }
256 else if(spchain[1] == "IS" && spchain[2] == "L1"){
257 return 2; // end-cap rings, inner system, layer 2
258 }
259 else if(spchain[1] == "EC"){ //outer end-cap
260 return 2* (spchain.at(2)[1]-'0'); // disks 4, 6, 8
261 }
262 else{
263 ATH_MSG_WARNING("Bad values in layer_disk function, return -9999");
264 return -9999;
265 }
266 }
267}

◆ loadCsv()

StatusCode ITkPixelCsvWaferIdAlg::loadCsv ( )

Definition at line 110 of file ITkPixelCsvWaferIdAlg.cxx.

110 {
111 const std::string resolvedCsv = PathResolver::find_file(m_csvFile.value(), "DATAPATH");
112 if (resolvedCsv.empty()) {
113 ATH_MSG_FATAL("Could not resolve CSV file: " << m_csvFile.value());
114 return StatusCode::FAILURE;
115 }
116
117
118 std::ifstream input(resolvedCsv);
119 if (!input.good()) {
120 ATH_MSG_FATAL("Could not open CSV file: " << resolvedCsv);
121 return StatusCode::FAILURE;
122 }
123
124 m_rows.clear();
125
126 ATH_MSG_INFO("Loading CSV");
127 std::string line;
128 bool firstLine = true;
129 while (std::getline(input, line)) {
130 if (line.empty()) {
131 continue;
132 }
133
134 if (firstLine) {
135 firstLine = false;
136 continue;
137 }
138 const std::vector<std::string> fields = splitCsvLine(line);
139 if (fields.size() < 5) {
140 ATH_MSG_WARNING("Skipping malformed CSV line: " << line);
141 continue;
142 }
143
144 CsvRow row;
145 row.spChain = trim(fields[0]);
146 row.md = trim(fields[1]);
147 row.fe = std::stoi(trim(fields[2]));
148 row.flx_card_device = trim(fields[3]);
149 row.fiber = static_cast<unsigned int>(std::stoul(trim(fields[4])));
150
151 m_rows.push_back(std::move(row));
152 }
153
154 ATH_MSG_INFO("Loaded " << m_rows.size() << " CSV rows from " << resolvedCsv);
155 return StatusCode::SUCCESS;
156}
static std::string trim(const std::string &input)
static std::vector< std::string > splitCsvLine(const std::string &line)
Gaudi::Property< std::string > m_csvFile
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ onlineId()

std::bitset< 32 > ITkPixelCsvWaferIdAlg::onlineId ( const std::vector< std::string > & spchain,
const std::string & mod,
int fe ) const

Definition at line 412 of file ITkPixelCsvWaferIdAlg.cxx.

412 {
413 // onlineID = chipID (4b) chipID ON/OFF (1b) RD53C (1b)
414 std::bitset<32> febits(0);
415 int ld = layer_disk(spchain);
416 int fe_id = feID(spchain, fe);
417 int b_ec = barrel_ec(spchain);
418 int etamod = eta_module(spchain, mod, fe);
419
420 if( b_ec == 0 ){ // barrel
421 if(ld == 1 || ld ==2 ){ //L1, L2 flat, 4 to 2 merging
422 if(fe_id < 2){
423 febits = std::bitset<32>(0x30000000);
424 }
425 else{
426 febits = std::bitset<32>(0xC0000000);
427 }
428 }
429 if(ld == 3 || ld == 4 ){ //L3, L4 flat, 4 to 1 merging
430 febits = std::bitset<32>(0xF0000000);
431 }
432 }
433 else{
434 if(ld == 3){ // Barrel ring L2
435 if(fe_id < 2){
436 febits = std::bitset<32>(0x30000000);
437 }
438 else{
439 febits = std::bitset<32>(0xC0000000);
440 }
441 }
442 if(ld == 5 || ld ==7){ // Barrel rings L3, L4
443 febits = std::bitset<32>(0xF0000000);
444 }
445 if(ld == 4 && etamod < 5){ // first half of EC L2
446 if(fe_id < 2){
447 febits = std::bitset<32>(0x30000000);
448 }
449 else{
450 febits = std::bitset<32>(0xC0000000);
451 }
452 }
453 if(ld == 6){ // EC L3
454 if(fe_id < 2){
455 febits = std::bitset<32>(0x30000000);
456 }
457 else{
458 febits = std::bitset<32>(0xC0000000);
459 }
460 }
461 if(ld == 8 && etamod < 7){ // EC L4, 1-7
462 febits = std::bitset<32>(0xF0000000);
463 }
464 if(ld == 8 && etamod >= 7){ // EC L4, 8-9
465 if(fe_id < 2){
466 febits = std::bitset<32>(0x30000000);
467 }
468 else{
469 febits = std::bitset<32>(0xC0000000);
470 }
471 }
472 }
473 febits |= std::bitset<32>("00001100000000000000000000000000");
474 return febits;
475}
int feID(const std::vector< std::string > &spchain, int fe) const
int eta_module(const std::vector< std::string > &spchain, const std::string &mod, int fe) const
etamod(flags, cells_name, *args, **kw)

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ parseSPChain()

std::vector< std::string > ITkPixelCsvWaferIdAlg::parseSPChain ( const std::string & spChain)
staticprivate

Definition at line 197 of file ITkPixelCsvWaferIdAlg.cxx.

197 {
198 std::vector<std::string> elements;
199 std::stringstream ss(spChain);
200 std::string element;
201
202 while (std::getline(ss, element, '-')) {
203 elements.push_back(element);
204 }
205
206 return elements;
207}

◆ phi_module()

int ITkPixelCsvWaferIdAlg::phi_module ( const std::vector< std::string > & spchain,
const std::string & mod,
int fe ) const
private

Definition at line 269 of file ITkPixelCsvWaferIdAlg.cxx.

269 {
270
271 int b_ec = barrel_ec(spchain);
272 int ld = layer_disk(spchain);
273
274 if( b_ec == 0 ){ // flat barrel
275 std::string phi_str = (spchain.at(3)).substr(1,2);
276 if(ld == 0 || ld ==1 ){ //inner system flat barrel
277 return std::stoi(phi_str) - 1;
278 }
279 else{ //outer flat barrel
280 int phi = std::stoi(phi_str) - 1 ;
281 phi = (mod[2] == 'T') ? 2*phi + 1 : 2*phi; //(TOCHECK)
282 return phi;
283 }
284 }
285 else{ // endcap and barrel rings - all considered as disks
286 if (spchain[2] == "L01" &&
287 (spchain.at(5) == "SP1" || spchain.at(5) == "SP3")) { // barrel vertical small combined rings, disk 0
288 std::string sp_str(1, (spchain.at(5)[2])); // SP=1 and SP=3 alternate in phi
289 if(sp_str == "1"){
290 return 6 * (stoi(mod) - 1 ) + 2 * (fe - 1); // probably wrong offset, TOCHECK
291 }
292 else if(sp_str == "3"){
293 return 6 * (stoi(mod) - 1 ) + 2 * (fe - 1) + 1; // probably wrong offset, TOCHECK
294 }
295 else{
296 ATH_MSG_WARNING("Bad input for phi_module,return -9999 ");
297 return -9999;
298 }
299 }
300 else if (spchain[2] == "L01" &&
301 (spchain.at(5) == "SP2" || spchain.at(5) == "SP4")) {
302 // barrel vertical large combined rings (quad modules), disk 2
303 std::string sp_str(1, spchain.at(5)[2]); // SP=2 and SP=4 alternate in phi
304 if(sp_str == "2"){
305 return 2 * (stoi(mod) - 1 ) ; // probably wrong offset, TODO need to revisit
306 }
307 else if(sp_str == "4"){
308 return 2 * (stoi(mod) - 1 ) + 1; // probably wrong offset, TODO need to revisit
309 }
310 else{
311 ATH_MSG_WARNING("Bad input for phi_module,return -9999 ");
312 return -9999;
313 }
314 }
315 //barrel inclined rings
316 else if(ld == 3 || ld == 5 || ld ==7){ //OB inclined rings, disks 3, 5, 7
317 std::string phi_str = mod.substr(3,2);
318 int phi = std::stoi(phi_str);
319 return phi;
320 }
321 else if(ld == 1){ //end-cap intermediate rings, inner system, disk 1 - triplets: one module per FE /!\ 0-17
322 return 6 * (stoi(mod) - 1 ) + 2 * (fe - 1); // probably wrong offset, TODO need to revisit
323 }
324 else if(ld == 2){ // end-cap rings, inner system, layer 2 // 0-19
325 std::string sp_str(1, spchain.at(5)[2]); // SP=1 and SP=2 alternate in phi
326 if(sp_str == "1"){
327 return 2 * (stoi(mod) - 1 ) ; // probably wrong offset, TODO need to revisit
328 }
329 else if(sp_str == "2"){
330 return 2 * (stoi(mod) - 1 ) + 1; // probably wrong offset, TODO need to revisit
331 }
332 //return stoi(mod) * fe;
333 }
334 else if(ld == 4 || ld == 6 || ld ==8){ //Outer EC disks 4, 6, 8
335 std::string phi_str = mod.substr(2,2);
336 int phi = std::stoi(phi_str);
337 return phi;
338 }
339 else{
340 ATH_MSG_WARNING("Bad input for phi_module,return -9999 ");
341 return -9999;
342 }
343 }
344 return -9999;
345}

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ rows()

const std::vector< CsvRow > & ITkPixelCsvWaferIdAlg::rows ( ) const
inline

Definition at line 40 of file ITkPixelCsvWaferIdAlg.h.

40{ return m_rows; }

◆ setFilterPassed()

virtual void AthCommonAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Set filter decision:

Reimplemented in AthFilterAlgorithm.

Definition at line 99 of file AthCommonAlgorithm.h.

99 {
101 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Set filter decision:

◆ sourceID()

std::bitset< 32 > ITkPixelCsvWaferIdAlg::sourceID ( const std::vector< std::string > & spchain,
const std::string & flx,
const unsigned int dma ) const
private

Definition at line 532 of file ITkPixelCsvWaferIdAlg.cxx.

532 {
533 // ((subdetector ID) << 16) |((FELIX card ID) << 8) | ((FELIX device ID) << 7) | ((DMA buffer number) << 5)
534
535 int b_ec = barrel_ec(spchain);
536 int ld = layer_disk(spchain);
537
538 std::bitset<32> b(0);
539 std::bitset<32> subdet = subDetID(b_ec, ld);
540 subdet <<= 16 ; //shift left by 16 bits
541
542 std::vector<std::string> flx_card_device = splitFLX_card_device(flx);
543
544 std::bitset<32> flxCard = std::bitset<32>(std::stoi(flx_card_device[0]));
545 flxCard <<= 8; //shift left by 8 bits
546 std::bitset<32> flxDev = std::bitset<32>(std::stoi(flx_card_device[1]) - 1 );
547 flxDev <<= 7; //shift left by 7 bits
548 std::bitset<32> dma_b = std::bitset<32>(dma);
549 dma_b <<= 5; //shift left by 5 bits
550 b = subdet | flxCard | flxDev | dma_b;
551 return b;
552}
std::bitset< 32 > subDetID(int barrel_endcap, int layer_disk) const
std::vector< std::string > splitFLX_card_device(const std::string &s) const

◆ splitCsvLine()

std::vector< std::string > ITkPixelCsvWaferIdAlg::splitCsvLine ( const std::string & line)
staticprivate

Definition at line 185 of file ITkPixelCsvWaferIdAlg.cxx.

185 {
186 std::vector<std::string> fields;
187 std::stringstream ss(line);
188 std::string field;
189
190 while (std::getline(ss, field, ',')) {
191 fields.push_back(field);
192 }
193
194 return fields;
195}

◆ splitFLX_card_device()

std::vector< std::string > ITkPixelCsvWaferIdAlg::splitFLX_card_device ( const std::string & s) const
private

Definition at line 556 of file ITkPixelCsvWaferIdAlg.cxx.

556 {
557 std::vector<std::string> fields;
558 std::stringstream ss(s);
559 std::string field;
560
561 while (std::getline(ss, field, '.')) {
562 fields.push_back(field);
563 }
564 if (fields.size() !=2){
565 ATH_MSG_ERROR("Wrong FLX_card_device input: " << s);
566 }
567 if (fields[1] !="1" && fields[1] !="2" ){
568 ATH_MSG_ERROR("Wrong FLX device input: " << fields[1]);
569 }
570 return fields;
571}
#define ATH_MSG_ERROR(x)

◆ subDetID()

std::bitset< 32 > ITkPixelCsvWaferIdAlg::subDetID ( int barrel_endcap,
int layer_disk ) const
private

Definition at line 574 of file ITkPixelCsvWaferIdAlg.cxx.

574 {
575 if(barrel_endcap == 0){
576 if(layer_disk < 2){
577 return std::bitset<32>(0x16);
578 }
579 else{
580 return std::bitset<32>(0x17);
581 }
582 }
583 else if(barrel_endcap == 2){
584 return std::bitset<32>(0x18);
585 }
586 else if(barrel_endcap == -2){
587 return std::bitset<32>(0x19);
588 }
589 else{
590 ATH_MSG_ERROR("Wrong barrel_endcap value: " << barrel_endcap);
591 ATH_MSG_ERROR("return subDetectorID =0 " );
592 return std::bitset<32>(0);
593 }
594
595}

◆ sysExecute()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Reimplemented in AthAnalysisAlgorithm.

Definition at line 80 of file AthCommonAlgorithm.cxx.

41{
42 return BaseAlg::sysExecute (ctx);
43}

◆ sysInitialize()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, HypoBase, InputMakerBase, and PyAthena::Alg.

Definition at line 60 of file AthCommonAlgorithm.cxx.

71 {
73
74 if (sc.isFailure()) {
75 return sc;
76 }
77
78 ServiceHandle<ICondSvc> cs("CondSvc",name());
79 for (auto h : outputHandles()) {
80 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
81 // do this inside the loop so we don't create the CondSvc until needed
82 if ( cs.retrieve().isFailure() ) {
83 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
85 }
86 if (cs->regHandle(this,*h).isFailure()) {
88 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
89 << " with CondSvc");
90 }
91 }
92 }
93 return sc;
94}
virtual StatusCode sysInitialize() override
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ trim()

std::string ITkPixelCsvWaferIdAlg::trim ( const std::string & input)
staticprivate

Definition at line 175 of file ITkPixelCsvWaferIdAlg.cxx.

175 {
176 const auto begin = input.find_first_not_of(" \t\r\n");
177 if (begin == std::string::npos) {
178 return "";
179 }
180
181 const auto end = input.find_last_not_of(" \t\r\n");
182 return input.substr(begin, end - begin + 1);
183}

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

◆ waferId()

std::tuple< Identifier, int, std::bitset< 32 > > ITkPixelCsvWaferIdAlg::waferId ( const CsvRow & row) const

Definition at line 158 of file ITkPixelCsvWaferIdAlg.cxx.

158 {
159 //ATH_MSG_DEBUG("waferId lookup for SP chain " << row.spChain
160 // << ", module " << row.md << ", FE " << row.fe);
161
162 //SP chain is like G-IS-L05-R05-A-SP2
163 std::vector<std::string> spChain_cur = parseSPChain(row.spChain);
164
165 int bec = barrel_ec(spChain_cur);
166 int ld = layer_disk(spChain_cur);
167 int phi = phi_module(spChain_cur, row.md, row.fe );
168 int eta = eta_module(spChain_cur, row.md, row.fe );
169 int fe_n = feID(spChain_cur, row.fe );
170 std::bitset<32> online_id = onlineId(spChain_cur, row.md, row.fe);
171
172 return std::make_tuple(m_pixIdHelper->wafer_id(bec, ld, phi, eta), fe_n, online_id);
173}
int phi_module(const std::vector< std::string > &spchain, const std::string &mod, int fe) const

Member Data Documentation

◆ m_csvFile

Gaudi::Property<std::string> ITkPixelCsvWaferIdAlg::m_csvFile
private
Initial value:
{this,
"CsvFile",
"AT2-IP-ES-0016_v1.41_INCOMPLETE-ModuleA_slim.csv",
"CSV file containing SP chain, Module and FE columns"}

Definition at line 63 of file ITkPixelCsvWaferIdAlg.h.

63 {this,
64 "CsvFile",
65 "AT2-IP-ES-0016_v1.41_INCOMPLETE-ModuleA_slim.csv",
66 "CSV file containing SP chain, Module and FE columns"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_done

std::atomic<bool> ITkPixelCsvWaferIdAlg::m_done {false}
mutableprivate

Definition at line 75 of file ITkPixelCsvWaferIdAlg.h.

75{false};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 108 of file AthCommonAlgorithm.h.

◆ m_outputFile

Gaudi::Property<std::string> ITkPixelCsvWaferIdAlg::m_outputFile
private
Initial value:
{this,
"OutputFile",
"ITkPixelWaferIds.txt",
"Output text file for one 32-bit waferID per line"}

Definition at line 67 of file ITkPixelCsvWaferIdAlg.h.

67 {this,
68 "OutputFile",
69 "ITkPixelWaferIds.txt",
70 "Output text file for one 32-bit waferID per line"};

◆ m_pixIdHelper

const PixelID* ITkPixelCsvWaferIdAlg::m_pixIdHelper = nullptr
private

Definition at line 72 of file ITkPixelCsvWaferIdAlg.h.

◆ m_rows

std::vector<CsvRow> ITkPixelCsvWaferIdAlg::m_rows
private

Definition at line 73 of file ITkPixelCsvWaferIdAlg.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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