28 memset(mSmallTopologiesLUT, -1, STopoSize *
sizeof(
int));
39 for (
auto& p : dict.mVectorOfIDs) {
40 os <<
"ID: " <<
ID++ <<
" Hash: " << p.mHash <<
" ErrX: " << p.mErrX <<
" ErrZ : " << p.mErrZ <<
" xCOG: " << p.mXCOG <<
" zCOG: " << p.mZCOG <<
" Npixles: " << p.mNpixels <<
" Frequency: " << p.mFrequency <<
" isGroup : " << std::boolalpha << p.mIsGroup <<
'\n'
42 <<
"*********************************************************" <<
'\n'
50 std::ofstream file_output(outputfile, std::ios::out | std::ios::binary);
51 for (
auto& p : mVectorOfIDs) {
52 file_output.write(
reinterpret_cast<char*
>(&p.mHash),
sizeof(
unsigned long));
53 file_output.write(
reinterpret_cast<char*
>(&p.mErrX),
sizeof(float));
54 file_output.write(
reinterpret_cast<char*
>(&p.mErrZ),
sizeof(float));
55 file_output.write(
reinterpret_cast<char*
>(&p.mErr2X),
sizeof(float));
56 file_output.write(
reinterpret_cast<char*
>(&p.mErr2Z),
sizeof(float));
57 file_output.write(
reinterpret_cast<char*
>(&p.mXCOG),
sizeof(float));
58 file_output.write(
reinterpret_cast<char*
>(&p.mZCOG),
sizeof(float));
59 file_output.write(
reinterpret_cast<char*
>(&p.mNpixels),
sizeof(
int));
60 file_output.write(
reinterpret_cast<char*
>(&p.mFrequency),
sizeof(double));
61 file_output.write(
reinterpret_cast<char*
>(&p.mIsGroup),
sizeof(bool));
62 file_output.write(
const_cast<char*
>(
reinterpret_cast<const char*
>(&p.mPattern.getPattern())),
70 LOGP(info,
"Reading TopologyDictionary from File '{}'", fname);
72 std::unique_ptr<TopologyDictionary> d{
loadFrom(fname)};
77 throw std::runtime_error(fmt::format(
"Unrecognized format {}", fname));
86 for (
auto& p : mSmallTopologiesLUT) {
89 std::ifstream in(fname.data(), std::ios::in | std::ios::binary);
93 LOG(error) <<
"The file " << fname <<
" coud not be opened";
94 throw std::runtime_error(
"The file coud not be opened");
96 while (in.read(
reinterpret_cast<char*
>(&gr.
mHash),
sizeof(
unsigned long))) {
97 in.read(
reinterpret_cast<char*
>(&gr.
mErrX),
sizeof(
float));
98 in.read(
reinterpret_cast<char*
>(&gr.
mErrZ),
sizeof(
float));
99 in.read(
reinterpret_cast<char*
>(&gr.
mErr2X),
sizeof(
float));
100 in.read(
reinterpret_cast<char*
>(&gr.
mErr2Z),
sizeof(
float));
101 in.read(
reinterpret_cast<char*
>(&gr.
mXCOG),
sizeof(
float));
102 in.read(
reinterpret_cast<char*
>(&gr.
mZCOG),
sizeof(
float));
103 in.read(
reinterpret_cast<char*
>(&gr.
mNpixels),
sizeof(
int));
104 in.read(
reinterpret_cast<char*
>(&gr.
mFrequency),
sizeof(
double));
105 in.read(
reinterpret_cast<char*
>(&gr.
mIsGroup),
sizeof(
bool));
107 mVectorOfIDs.push_back(gr);
109 mCommonMap.insert(std::make_pair(gr.
mHash, groupID));
114 mGroupMap.insert(std::make_pair((
int)(gr.
mHash >> 32) & 0x00000000ffffffff, groupID));
126 auto* histo =
new TH1F(hname.data(),
";Topology ID;Frequency", dictSize, -0.5, dictSize - 0.5);
127 histo->SetFillColor(kRed);
128 histo->SetFillStyle(3005);
129 histo->SetDrawOption(
"histo");
130 for (
int i = 0;
i < dictSize;
i++) {
149 float xCurved{0.f}, yCurved{0.f};
151 locCl.SetXYZ(xCurved, yCurved, locCl.Z());
159 auto refRow = cl.
getRow();
160 auto refCol = cl.
getCol();
161 float xCOG = 0, zCOG = 0;
164 refRow -= round(xCOG);
165 refCol -= round(zCOG);
173 float xCurved{0.f}, yCurved{0.f};
175 locCl.SetXYZ(xCurved, yCurved, locCl.Z());
182 LOGP(info,
"Loading TopologyDictionary from {} with name {}", fname, objName);
184 TFile fl(fname.c_str(),
"READ");
185 if (fl.IsZombie() || !fl.IsOpen()) {
186 throw std::runtime_error(fmt::format(
"Failed to open {} file", fname));
189 if (dict ==
nullptr) {
190 throw std::runtime_error(fmt::format(
"Failed to load {} from {}", objName, fname));
Definition of the BuildTopologyDictionary class for ITS3.
ClassImp(o2::its3::TopologyDictionary)
Definition of the SegmentationAlpide class.
Definition of the SegmentationSuperAlpide class.
static constexpr float mPitchRow
static constexpr float mPitchCol
math_utils::Point3D< T > getClusterCoordinates(const itsmft::CompClusterExt &cl) const
Returns the local position of a compact cluster.
int getSize() const
Returns the number of elements in the dicionary;.
static TopologyDictionary * loadFrom(const std::string &fileName="", const std::string &objName="ccdb_object")
int readBinaryFile(const std::string &fileName)
Reads the dictionary from a binary file.
bool isGroup(int n) const
Returns true if the element corresponds to a group of rare topologies.
TH1F * getTopologyDistribution(const std::string_view hname="h_topo_dist") const
Fills a hostogram with the distribution of the IDs.
void writeBinaryFile(const std::string &outputFile)
Prints the dictionary in a binary file.
double getFrequency(int n) const
Returns the frequency of the n_th element;.
int readFromFile(const std::string &fileName)
int getColumnSpan() const
Returns the number of columns.
static int getCOG(int rowSpan, int colSpan, const unsigned char patt[MaxPatternBytes], float &xCOG, float &zCOG)
Static: Compute pattern's COG position. Returns the number of fired pixels.
static constexpr int kExtendedPatternBytes
Maximum number of bytes for the cluster puttern + 2 bytes respectively for the number of rows and col...
unsigned char getByte(int n) const
Returns a specific byte of the pattern.
const std::array< unsigned char, kExtendedPatternBytes > & getPattern() const
Returns the pattern.
int getUsedBytes() const
Returns the number of bytes used for the pattern.
UShort_t getSensorID() const
UShort_t getPatternID() const
static void detectorToLocalUnchecked(L row, L col, T &xRow, T &zCol)
static constexpr float PitchCol
static constexpr float PitchRow
GLenum GLuint GLint GLint layer
T getDetID2Layer(T detID)
const std::array< SegmentationSuperAlpide, constants::nLayers > SuperSegmentations
Segmentation array.
Structure containing the most relevant pieces of information of a topology.
float mErrX
Error associated to the hit point in the x direction.
float mErr2X
Squared Error associated to the hit point in the x direction.
float mErrZ
Error associated to the hit point in the z direction.
unsigned long mHash
Hashcode.
float mXCOG
x position of the COG wrt the bottom left corner of the bounding box
int mNpixels
Number of fired pixels.
double mFrequency
Frequency of the topology.
bool mIsGroup
false: common topology; true: group of rare topologies
float mErr2Z
Squared Error associated to the hit point in the z direction.
float mZCOG
z position of the COG wrt the bottom left corner of the bounding box
static bool endsWith(const std::string &s, const std::string &ending)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"