GCC Code Coverage Report


Directory: ./
File: include/na64detID/cellID.hh
Date: 2025-09-01 06:19:01
Exec Total Coverage
Lines: 3 3 100.0%
Functions: 3 3 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /* This file is a part of NA64SW software.
2 * Copyright (C) 2015-2022 NA64 Collaboration, CERN
3 *
4 * NA64SW is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17 #include "na64sw-config.h"
18 #include "na64detID/detectorID.hh"
19
20 #include <string>
21 #include <map>
22
23 /**\file CellID.hh
24 *
25 * File contains common payload definition for SADC detectors.
26 *
27 * \todo move from ECAL dir
28 * */
29
30 namespace na64dp {
31
32 /// Numeric type keeping encoded cell identifier
33 typedef DetIDPayload_t CellID_t;
34
35 /**\brief Spatial coordinates of detector cell
36 *
37 * Represents shortened identifier for the cell of spatially-segmentated
38 * detectors: x, y, z (whether it is preshower).
39 *
40 * One has to consider difference between "unset" cell identifier and
41 * identifier corresponding to 0x0x0: both will return 0 with `get_x()`,
42 * `get_y()`, `get_z()`, but meaning of this zeroes is different. Consider
43 * additional check with `is_set()` method to catch the difference.
44 */
45 struct CellID {
46 /// Maximum index value
47 constexpr static DetIDPayload_t idxMax = 0x1e;
48
49 /// Public member, keeping the encoded information about x/y/z cell idxs.
50 CellID_t id;
51 /// Constructs "unset" cell ID
52 28958 CellID() : id(0x0) {}
53 /// Copies cell ID. "Unset" identifier will be kept.
54 250 CellID( CellID_t id_ ) : id(id_) {}
55 /// Sets the cell ID
56 CellID( int x, int y, int z );
57 /// Returns X index of cell. For both, unset and x=0 cell the 0 will be returned.
58 unsigned int get_x() const;
59 /// Returns `true` if X index is set.
60 bool is_x_set() const;
61 /// Returns Y index of cell. For both, unset and y=0 cell the 0 will be returned.
62 unsigned int get_y() const;
63 /// Returns `true` if Y index is set.
64 bool is_y_set() const;
65 /// Returns Z index of cell. For both, unset and z=0 cell the 0 will be returned.
66 unsigned int get_z() const;
67 /// Returns `true` if Z index is set.
68 bool is_z_set() const;
69 /// Sets X index of the cell
70 void set_x(unsigned int x);
71 /// Sets Y index of the cell
72 void set_y(unsigned int y);
73 /// Sets Z index of the cell
74 void set_z(unsigned int z);
75 /// Returns true if at least one index was set
76 125 bool is_set() const { return id; }
77
78 /// Appends string values text template rendering context
79 static void append_completion_context( DetID, std::map<std::string, std::string> & );
80 /// Converts from WireID to string
81 static void to_string( DetIDPayload_t, char *, size_t available );
82 /// Converts from string to WireID
83 static DetIDPayload_t from_string( const char * );
84 };
85
86 } // namespace na64dp
87