Warning, file /DD4hep/DDCore/src/plugins/DetectorChecksum.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef DDCORE_SRC_PLUGINS_DETECTORCHECKSUM_H
0014 #define DDCORE_SRC_PLUGINS_DETECTORCHECKSUM_H
0015
0016
0017 #include <DD4hep/Detector.h>
0018 #include <DD4hep/GeoHandler.h>
0019 #include <DD4hep/DD4hepUnits.h>
0020
0021
0022 #include <sstream>
0023
0024
0025
0026
0027 namespace dd4hep {
0028
0029
0030 namespace detail {
0031
0032
0033
0034
0035
0036
0037
0038 class DetectorChecksum: public GeoHandler {
0039 public:
0040 using hash_t = uint64_t;
0041 struct entry_t {
0042 hash_t hash { 0 };
0043 std::string data { "" };
0044 };
0045 using ElementMap = std::map<Atom, entry_t>;
0046 using MaterialMap = std::map<Material, entry_t>;
0047 using LimitMap = std::map<LimitSet, entry_t>;
0048 using PlacementMap = std::map<PlacedVolume, entry_t>;
0049 using RegionMap = std::map<Region, entry_t>;
0050 using SensDetMap = std::map<SensitiveDetector, entry_t>;
0051 using VolumeMap = std::map<Volume, entry_t>;
0052 using IdSpecMap = std::map<IDDescriptor, entry_t>;
0053 using SegmentationMap = std::map<Segmentation, entry_t>;
0054 using VisMap = std::map<VisAttr, entry_t>;
0055 using AlignmentMap = std::map<Alignment, entry_t>;
0056 using SolidMap = std::map<Solid, entry_t>;
0057 using FieldMap = std::map<OverlayedField, entry_t>;
0058 using TrafoMap = std::map<const TGeoMatrix*, entry_t>;
0059 using MapOfDetElements = std::map<DetElement, entry_t>;
0060
0061
0062
0063
0064
0065
0066
0067 class GeometryInfo: public GeoHandler::GeometryInfo {
0068 public:
0069 ElementMap mapOfElements;
0070 MaterialMap mapOfMaterials;
0071 SolidMap mapOfSolids;
0072 VolumeMap mapOfVolumes;
0073 PlacementMap mapOfPlacements;
0074 RegionMap mapOfRegions;
0075 VisMap mapOfVis;
0076 LimitMap mapOfLimits;
0077 IdSpecMap mapOfIdSpecs;
0078 SegmentationMap mapOfSegmentations;
0079 SensDetMap mapOfSensDets;
0080 TrafoMap mapOfPositions;
0081 TrafoMap mapOfRotations;
0082 FieldMap mapOfFields;
0083 AlignmentMap mapOfAlignments;
0084 MapOfDetElements mapOfDetElements;
0085 entry_t header;
0086
0087 GeometryInfo() = default;
0088 };
0089
0090
0091 Detector& m_detDesc;
0092 GeometryInfo* m_dataPtr;
0093 mutable std::stringstream debug_hash;
0094
0095 std::string m_len_unit_nam = "mm";
0096 std::string m_ang_unit_nam = "deg";
0097 std::string m_ene_unit_nam = "GeV";
0098 std::string m_densunit_nam = "g/cm3";
0099 std::string m_atomunit_nam = "g/mole";
0100 double m_len_unit = dd4hep::mm;
0101 double m_ang_unit = dd4hep::deg;
0102 double m_ene_unit = dd4hep::GeV;
0103 double m_densunit = dd4hep::g/dd4hep::cm3;
0104 double m_atomunit = dd4hep::g/dd4hep::mole;
0105
0106 double m_len__def = dd4hep::mm;
0107 double m_ang__def = dd4hep::deg;
0108 double m_ene__def = dd4hep::GeV;
0109 double m_dens_def = dd4hep::g/dd4hep::cm3;
0110 double m_atom_def = dd4hep::g/dd4hep::mole;
0111
0112 entry_t empty_entry { 0UL, "" };
0113 std::string newline = "";
0114
0115
0116 mutable int precision { 6 };
0117
0118 int hash_meshes { 0 };
0119
0120 int hash_readout { 0 };
0121
0122 int max_level { 1 };
0123
0124 int have_hash_strings { 0 };
0125
0126 int debug { 4 };
0127 int reorder { 1 };
0128 int write_files { 1 };
0129
0130 GeometryInfo& data() const {
0131 return *m_dataPtr;
0132 }
0133 void configure();
0134 void hash_debug(const std::string& prefix, const entry_t& str, int flag=0) const;
0135 entry_t make_entry(std::stringstream& log) const;
0136 std::stringstream logger() const;
0137
0138
0139 DetectorChecksum(Detector& description);
0140
0141
0142 virtual ~DetectorChecksum();
0143
0144 template <typename T> std::string refName(T handle) const;
0145 template <typename T> std::string attr_name(T handle) const;
0146 void collect_det_elements(DetElement top) const;
0147
0148
0149 void analyzeDetector(DetElement top);
0150 typedef std::vector<hash_t> hashes_t;
0151 void checksumPlacement(PlacedVolume pv, hashes_t& hashes, bool recursive) const;
0152 void checksumDetElement(int level, DetElement det, hashes_t& hashes, bool recursive) const;
0153
0154
0155 virtual const entry_t& handleHeader() const;
0156
0157
0158 virtual const entry_t& handleMaterial(Material medium) const;
0159
0160
0161 virtual const entry_t& handleElement(Atom element) const;
0162
0163
0164 virtual const entry_t& handleSolid(Solid solid) const;
0165
0166
0167 virtual const entry_t& handleVolume(Volume volume) const;
0168 virtual void collectVolume(Volume volume) const;
0169
0170
0171 virtual const entry_t& handlePlacement(PlacedVolume node) const;
0172
0173
0174 const entry_t& handleAlignment(Alignment alignment) const;
0175
0176
0177
0178
0179
0180 virtual const entry_t& handleRegion(Region region) const;
0181
0182
0183 virtual const entry_t& handleVis(VisAttr vis) const;
0184
0185
0186 virtual const entry_t& handleIdSpec(IDDescriptor idspec) const;
0187
0188
0189 virtual const entry_t& handleLimitSet(LimitSet limitset) const;
0190
0191 virtual const entry_t& handleDetElement(DetElement det) const;
0192
0193
0194 virtual const entry_t& handleSensitive(SensitiveDetector sens_det) const;
0195
0196
0197 virtual const entry_t& handleSegmentation(Segmentation seg) const;
0198
0199
0200 virtual const entry_t& handlePosition(const TGeoMatrix* trafo) const;
0201
0202
0203 virtual const entry_t& handleRotation(const TGeoMatrix* trafo) const;
0204
0205
0206 virtual const entry_t& handleField(OverlayedField field) const;
0207
0208
0209 const entry_t& handleProperties(Detector::Properties& prp) const;
0210
0211
0212 void dump_elements() const;
0213
0214 void dump_materials() const;
0215
0216 void dump_solids() const;
0217
0218 void dump_volumes() const;
0219
0220 void dump_positions() const;
0221
0222 void dump_rotations() const;
0223
0224 void dump_placements() const;
0225
0226 void dump_detelements() const;
0227
0228 void dump_iddescriptors() const;
0229
0230 void dump_segmentations() const;
0231
0232 void dump_sensitives() const;
0233
0234 };
0235 }
0236 }
0237 #endif