| 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 | #pragma once | ||
| 18 | |||
| 19 | #include "na64sw-config.h" | ||
| 20 | |||
| 21 | #include "na64detID/detectorID.hh" | ||
| 22 | |||
| 23 | #include <string> | ||
| 24 | #include <map> | ||
| 25 | |||
| 26 | namespace na64dp { | ||
| 27 | namespace nameutils { | ||
| 28 | |||
| 29 | class KinFeaturesTable { | ||
| 30 | public: | ||
| 31 | struct Features { | ||
| 32 | /// A name of detector kin | ||
| 33 | const std::string name; | ||
| 34 | std::string description ///< A human-readable decription of detector kin | ||
| 35 | , nameFormat ///< Name template of the detector entities | ||
| 36 | , dddNameFormat ///< Format of DDD detector name | ||
| 37 | , pathFormat ///< Path template for various relevant objects | ||
| 38 | ; | ||
| 39 | /// Constructs new instance with name being set | ||
| 40 | 55 | Features( const std::string & nm ) : name(nm) {} | |
| 41 | }; | ||
| 42 | /// Identifier of detector kin -- must include relevant chip ID | ||
| 43 | typedef std::pair<DetChip_t, DetKin_t> KinID; | ||
| 44 | /// Kin table type | ||
| 45 | typedef std::map<KinID, Features> KinTable; | ||
| 46 | private: | ||
| 47 | KinTable _kinTraits; | ||
| 48 | std::map<std::string, KinID> _kinIDs; | ||
| 49 | public: | ||
| 50 | /// Returns kin ID (chip + kin-in-chip) by its string name. Accepts name | ||
| 51 | /// as it was given to `define_kin()`, raises exception if kin not found. | ||
| 52 | KinID kin_id( const std::string & ) const; | ||
| 53 | /// Returns kin features entry (by ID) as it was provided to `define_kin()` | ||
| 54 | const Features & kin_features( KinID ) const; | ||
| 55 | /// Returns kin features entry (by name) | ||
| 56 | const Features & kin_features( const std::string & ) const; | ||
| 57 | /// Defines new detector chip entry returning new entry for subsequent | ||
| 58 | /// initialization | ||
| 59 | /// \param kinName a string name of detector kin (family), like MM, ECAL | ||
| 60 | /// \param kinID a desired kin ID number | ||
| 61 | /// \param chipID a numeric chip identifier number | ||
| 62 | /// \param nameFormat name pattern | ||
| 63 | /// \param kinDescription a detector kin description (for humans) | ||
| 64 | /// \param histsTPath a common histograms path template | ||
| 65 | /// \return new `Features` instance | ||
| 66 | Features & define_kin( const std::string & kinName | ||
| 67 | , DetKin_t kinID | ||
| 68 | , DetChip_t chipID | ||
| 69 | , const std::string & nameFormat="{kin}{statNum}" | ||
| 70 | , const std::string & kinDescription="" | ||
| 71 | , const std::string & histsTPath="" | ||
| 72 | ); | ||
| 73 | /// Returns true if kin with given name is defined | ||
| 74 | 53 | bool has_kin(const std::string & name) const | |
| 75 |
1/1✓ Branch 1 taken 53 times.
|
53 | { return _kinIDs.end() != _kinIDs.find(name); } |
| 76 | /// Wipes out all chip features | ||
| 77 | void clear(); | ||
| 78 | }; | ||
| 79 | |||
| 80 | } | ||
| 81 | } | ||
| 82 |