DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
IDDescriptor.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DD4HEP_IDDESCRIPTOR_H
14 #define DD4HEP_IDDESCRIPTOR_H
15 
16 // Framework include files
17 #include <DD4hep/Handle.h>
18 #include <DD4hep/BitFieldCoder.h>
19 
20 // C++ include files
21 #include <string>
22 #include <vector>
23 #include <map>
24 
26 namespace dd4hep {
27 
28  class IDDescriptorObject;
29 
31 
37  class IDDescriptor: public Handle<IDDescriptorObject> {
38  public:
39  typedef BitFieldElement Field;
40  typedef std::vector<std::pair<std::string, const Field*> > FieldMap;
41  typedef std::vector<std::pair<size_t, std::string> > FieldIDs;
42 
43  public:
45  IDDescriptor() = default;
47  template <typename Q> IDDescriptor(const Handle<Q>& e) : Handle<Object>(e) { }
49  IDDescriptor(const std::string& name, const std::string& description);
51  std::string fieldDescription() const;
53  unsigned maxBit() const;
55  const FieldIDs& ids() const;
57  const FieldMap& fields() const;
59  const BitFieldElement* field(const std::string& field_name) const;
61  size_t fieldID(const std::string& field_name) const;
63  const BitFieldElement* field(size_t identifier) const;
64 #ifndef __MAKECINT__
65  static VolumeID encode(const Field* fld, VolumeID value);
68  VolumeID encode(const std::vector<std::pair<std::string, int> >& ids) const;
70  VolumeID encode_reverse(const std::vector<std::pair<std::string, int> >& id_vector) const;
72  VolumeID get_mask(const std::vector<std::pair<std::string, int> >& id_vector) const;
73 #endif
74  void decodeFields(VolumeID vid, std::vector<std::pair<const BitFieldElement*, VolumeID> >& fields) const;
77  std::string str(VolumeID vid) const;
79  std::string str(VolumeID vid, VolumeID mask) const;
81  std::string toString() const;
83  BitFieldCoder* decoder() const;
85  void rebuild(const std::string& description);
86  };
87 } /* End namespace dd4hep */
88 #endif // DD4HEP_IDDESCRIPTOR_H
dd4hep::IDDescriptor::decodeFields
void decodeFields(VolumeID vid, std::vector< std::pair< const BitFieldElement *, VolumeID > > &fields) const
Decode volume IDs and return filled descriptor with all fields.
Definition: IDDescriptor.cpp:164
dd4hep::IDDescriptor::fieldID
size_t fieldID(const std::string &field_name) const
Get the field identifier of one field by name.
Definition: IDDescriptor.cpp:113
dd4hep::IDDescriptorObject
Concrete object implementation of the IDDescriptorObject Handle.
Definition: ObjectsInterna.h:206
dd4hep::DDSegmentation::BitFieldElement
Helper class for BitFieldCoder that corresponds to one field value.
Definition: BitFieldCoder.h:32
dd4hep::IDDescriptor::FieldMap
std::vector< std::pair< std::string, const Field * > > FieldMap
Definition: IDDescriptor.h:40
dd4hep::IDDescriptor::field
const BitFieldElement * field(const std::string &field_name) const
Get the field descriptor of one field by name.
Definition: IDDescriptor.cpp:96
dd4hep::DDSegmentation::BitFieldCoder
Helper class for decoding and encoding a bit field of 64bits for convenient declaration.
Definition: BitFieldCoder.h:114
dd4hep::IDDescriptor::maxBit
unsigned maxBit() const
The total number of encoding bits for this descriptor.
Definition: IDDescriptor.cpp:73
dd4hep::IDDescriptor
Class implementing the ID encoding of the detector response.
Definition: IDDescriptor.h:37
Handle.h
dd4hep::IDDescriptor::Field
BitFieldElement Field
Definition: IDDescriptor.h:39
dd4hep::Handle
Handle: a templated class like a shared pointer, which allows specialized access to tgeometry objects...
Definition: Handle.h:84
dd4hep::Handle< IDDescriptorObject >::name
const char * name() const
Access the object name (or "" if not supported by the object)
dd4hep::IDDescriptor::IDDescriptor
IDDescriptor()=default
Default constructor.
dd4hep::IDDescriptor::encode
static VolumeID encode(const Field *fld, VolumeID value)
Encode partial volume identifiers to a volumeID.
Definition: IDDescriptor.cpp:148
dd4hep::IDDescriptor::FieldIDs
std::vector< std::pair< size_t, std::string > > FieldIDs
Definition: IDDescriptor.h:41
dd4hep::IDDescriptor::str
std::string str(VolumeID vid) const
Decode volume IDs and return string reprensentation for debugging purposes.
Definition: IDDescriptor.cpp:174
dd4hep::IDDescriptor::get_mask
VolumeID get_mask(const std::vector< std::pair< std::string, int > > &id_vector) const
Compute the submask for a given set of volume IDs.
Definition: IDDescriptor.cpp:124
dd4hep::IDDescriptor::fields
const FieldMap & fields() const
Access the fieldmap container.
Definition: IDDescriptor.cpp:87
VolumeID
dd4hep::DDSegmentation::VolumeID VolumeID
Definition: SegmentationDictionary.h:49
dd4hep::IDDescriptor::fieldDescription
std::string fieldDescription() const
The string description of all fields from the BitField.
Definition: IDDescriptor.cpp:67
dd4hep::IDDescriptor::rebuild
void rebuild(const std::string &description)
Re-build object in place.
Definition: IDDescriptor.cpp:51
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::IDDescriptor::decoder
BitFieldCoder * decoder() const
Access the BitFieldCoder object.
Definition: IDDescriptor.cpp:198
dd4hep::IDDescriptor::encode_reverse
VolumeID encode_reverse(const std::vector< std::pair< std::string, int > > &id_vector) const
Encode a set of volume identifiers to a volumeID with the system ID on the top bits.
Definition: IDDescriptor.cpp:158
BitFieldCoder.h
dd4hep::IDDescriptor::toString
std::string toString() const
Access string representation.
Definition: IDDescriptor.cpp:60
dd4hep::IDDescriptor::IDDescriptor
IDDescriptor(const Handle< Q > &e)
Constructor to be used when reading the already parsed object.
Definition: IDDescriptor.h:47
dd4hep::IDDescriptor::ids
const FieldIDs & ids() const
Access the field-id container.
Definition: IDDescriptor.cpp:78