ATLAS Offline Software
Loading...
Searching...
No Matches
ITkPixelCsvWaferIdAlg.h
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ITKPIXELBYTESTREAMCNV_ITKPIXELCSVWAFERIDALG_H
6#define ITKPIXELBYTESTREAMCNV_ITKPIXELCSVWAFERIDALG_H
7
9#include "GaudiKernel/EventContext.h"
10#include "GaudiKernel/ISvcLocator.h"
11#include "Identifier/Identifier.h"
13
14#include <atomic>
15#include <string>
16#include <vector>
17#include <utility>
18
19class PixelID;
20
22public:
23 struct CsvRow {
24 std::string spChain;
25 std::string md;
26 int fe = -1;
27 };
28
29 ITkPixelCsvWaferIdAlg(const std::string& name, ISvcLocator* pSvcLocator);
30 virtual ~ITkPixelCsvWaferIdAlg() = default;
31
32 virtual StatusCode initialize() override;
33 virtual StatusCode execute(const EventContext& ctx) const override;
34
35 const std::vector<CsvRow>& rows() const { return m_rows; }
36
37 StatusCode loadCsv();
38 std::pair<Identifier,int> waferId(const CsvRow& row) const;
39
40private:
41 static std::string trim(const std::string& input);
42 static std::vector<std::string> splitCsvLine(const std::string& line);
43 static std::vector<std::string> parseSPChain(const std::string& spChain);
44
45 // Helper functions implemented in the .cxx file
46 int barrel_ec(const std::vector<std::string>& spchain) const;
47 int layer_disk(const std::vector<std::string>& spchain) const;
48 int phi_module(const std::vector<std::string>& spchain, const std::string& mod, int fe) const;
49 int eta_module(const std::vector<std::string>& spchain, const std::string& mod, int fe) const;
50 int feID(const std::vector<std::string>& spchain, int fe) const;
51 Gaudi::Property<std::string> m_csvFile{this,
52 "CsvFile",
53 "AT2-IP-ES-0016_v1.41_INCOMPLETE-ModuleA_slim.csv",
54 "CSV file containing SP chain, Module and FE columns"};
55 Gaudi::Property<std::string> m_outputFile{this,
56 "OutputFile",
57 "ITkPixelWaferIds.txt",
58 "Output text file for one 32-bit waferID per line"};
59
60 const PixelID* m_pixIdHelper = nullptr;
61 std::vector<CsvRow> m_rows;
62
63 /*
64 uint32_t htonl(const std::string &x) {
65 unsigned char *s = (unsigned char *)x.c_str();
66 return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
67 };
68 */
69 mutable std::atomic<bool> m_done{false};
70};
71
72#endif // ITKPIXELBYTESTREAMCNV_ITKPIXELCSVWAFERIDALG_H
This is an Identifier helper class for the Pixel subdetector.
An algorithm that can be simultaneously executed in multiple threads.
virtual ~ITkPixelCsvWaferIdAlg()=default
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &ctx) const override
static std::string trim(const std::string &input)
std::atomic< bool > m_done
static std::vector< std::string > splitCsvLine(const std::string &line)
std::vector< CsvRow > m_rows
int phi_module(const std::vector< std::string > &spchain, const std::string &mod, int fe) const
Gaudi::Property< std::string > m_outputFile
static std::vector< std::string > parseSPChain(const std::string &spChain)
int feID(const std::vector< std::string > &spchain, int fe) const
Gaudi::Property< std::string > m_csvFile
int barrel_ec(const std::vector< std::string > &spchain) const
std::pair< Identifier, int > waferId(const CsvRow &row) const
int eta_module(const std::vector< std::string > &spchain, const std::string &mod, int fe) const
ITkPixelCsvWaferIdAlg(const std::string &name, ISvcLocator *pSvcLocator)
int layer_disk(const std::vector< std::string > &spchain) const
const std::vector< CsvRow > & rows() const
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:69