diff --git a/DDCond/include/DDCond/ConditionsContent.h b/DDCond/include/DDCond/ConditionsContent.h index 722ff0727b8565df97a9015b1ddb789cef19ba99..cae73ad69bfa21976af0a3c9e9072777ecd3d7c4 100644 --- a/DDCond/include/DDCond/ConditionsContent.h +++ b/DDCond/include/DDCond/ConditionsContent.h @@ -124,8 +124,6 @@ namespace dd4hep { if ( ret ) dep->addRef(); return ret; } - /// Create load-info object - template <typename T> static LoadInfo<T> loadInfo(const T& t) { return LoadInfo<T>(t); } }; } /* End namespace cond */ } /* End namespace dd4hep */ diff --git a/DDCore/include/DD4hep/ConditionsData.h b/DDCore/include/DD4hep/ConditionsData.h index 127f1ecbb3974dc044d2c9f7240ef277de91c926..9b0f49566413b431b56feef07528ff0837cfd676 100644 --- a/DDCore/include/DD4hep/ConditionsData.h +++ b/DDCore/include/DD4hep/ConditionsData.h @@ -110,6 +110,18 @@ namespace dd4hep { if ( i != std::end(params) ) return (*i).second.get<T>(); throw std::runtime_error("AbstractMap: Failed to access non-existing item:"+item); } + /// Simplify access to mapped item of the parameter list (const access) + template <typename T> const T& get(const std::string& item) const { + Params::const_iterator i=params.find(item); + if ( i != std::end(params) ) return (*i).second.get<T>(); + throw std::runtime_error("AbstractMap: Failed to access non-existing item:"+item); + } + /// Simplify access to mapped item of the parameter list + template <typename T> T& get(const std::string& item) { + Params::iterator i=params.find(item); + if ( i != std::end(params) ) return (*i).second.get<T>(); + throw std::runtime_error("AbstractMap: Failed to access non-existing item:"+item); + } }; } /* End namespace cond */ diff --git a/DDCore/include/DD4hep/IOV.h b/DDCore/include/DD4hep/IOV.h index 8cdf334a2e2e5484fcbf2eea1f8114c393b75fde..e27c6cea476feb53931ef60cf5cc5bba8c2f62cc 100644 --- a/DDCore/include/DD4hep/IOV.h +++ b/DDCore/include/DD4hep/IOV.h @@ -98,6 +98,8 @@ namespace dd4hep { IOV& operator=(const IOV& c) = default; /// Move assignment operator IOV& operator=(IOV&& c) = default; + /// Allow for IOV sorting in maps + bool operator<(const IOV& test) const; /// Move the data content: 'from' will be reset to NULL void move(IOV& from); /// Create string representation of the IOV @@ -166,6 +168,14 @@ namespace dd4hep { static bool partial_match(const IOV& iov, const IOV& test) { return same_type(iov,test) && key_partially_contained(iov.keyData,test.keyData); } }; - + + /// Allow for IOV sorting in maps + inline bool IOV::operator<(const IOV& test) const { + if ( type > test.type ) return false; // Actually this should never happen! + if ( keyData.first > test.keyData.first ) return false; + if ( keyData.second > test.keyData.second ) return false; + return true; + } + } /* End namespace dd4hep */ #endif /* DD4HEP_DDCORE_IOV_H */ diff --git a/DDDB/include/Detector/DeIOV.h b/DDDB/include/Detector/DeIOV.h index 80946aa071a0588e26b4d069a82023d731a0aadc..26afa6d07261aabc5eb60d254536cfc6091e2ec9 100644 --- a/DDDB/include/Detector/DeIOV.h +++ b/DDDB/include/Detector/DeIOV.h @@ -22,9 +22,6 @@ /// Gaudi namespace declaration namespace gaudi { - // Forward declarations - class DeIOV; - /// Gaudi::detail namespace declaration namespace detail { @@ -55,7 +52,8 @@ namespace gaudi { */ class DeIOVObject : public detail::ConditionObject { DE_CONDITIONS_TYPEDEFS; - + typedef DeStatic::Object static_t; + public: /// Helper to initialize the basic information DeIOVObject* fill_info(DetElement de, Catalog* cat); @@ -95,54 +93,47 @@ namespace gaudi { /// We want to cache here the delta matrix TGeoHMatrix deltaMatrix; /// Initialization flags to steer actions - int de_flags = 0; + unsigned short de_flags = 0; + unsigned short de_user = 0; /// Item key - itemkey_type key = 0; - }; - } // End namespace detail - + itemkey_type item_key = 0; - /// Geometry access - /** - * - * \author Markus Frank - * \date 2018-03-08 - * \version 1.0 - */ - class TransformationInfo : public dd4hep::Handle<detail::DeIOVObject> { - DE_CONDITIONS_TYPEDEFS; + public: - public: - /// Standard handle assignments and constructors - DE_CTORS_HANDLE(TransformationInfo,Base); - - /* - /// Initialization from detector element base - template<typename s, typename i> - TransformationInfo(const DetectorElementBase<s,i>& base); - */ - /// Access to the alignmant object to transformideal coordinates - Alignment detectorAlignment() const - { return ptr()->detectorAlignment; } - - /// Access to transformation matrices - const TGeoHMatrix& toLocalMatrix() const - { return ptr()->toLocalMatrix; } - const TGeoHMatrix& toGlobalMatrix() const - { return detectorAlignment().worldTransformation(); } - const TGeoHMatrix& toLocalMatrixNominal() const - { return ptr()->deltaMatrix; } - - /// Local -> Global and Global -> Local transformations - XYZPoint toLocal( const XYZPoint& global ) const - { return XYZPoint(detectorAlignment().worldToLocal(XYZVector(global))); } - XYZPoint toGlobal( const XYZPoint& local ) const - { return XYZPoint(detectorAlignment().localToWorld(XYZVector(local))); } - XYZVector toLocal( const XYZVector& globalDirection ) const - { return detectorAlignment().worldToLocal(globalDirection); } - XYZVector toGlobal( const XYZVector& localDirection ) const - { return detectorAlignment().localToWorld(localDirection); } - }; + /// Compute key value for caching + static itemkey_type key(const std::string& value) + { return dd4hep::ConditionKey::itemCode(value); } + /// Compute key value for caching + static itemkey_type key(const char* value) + { return dd4hep::ConditionKey::itemCode(value); } + + /// Check if the condition identified by 'key' is in the list of conditionrefs. + bool hasCondition(itemkey_type key) const + { return this->condition(key, false).isValid(); } + /// Access condition by hash-key (fast) + Condition condition(itemkey_type key) const; + /// Access condition by hash-key (fast) + Condition condition(itemkey_type key, bool throw_if) const; + + /// Check if the condition called 'name' is in the list of conditionrefs. + bool hasCondition(const std::string& nam) const + { return this->condition(nam, false).isValid(); } + /// Access condition by name (slow) + Condition condition(const std::string& name) const; + /// Access condition by name (slow) + Condition condition(const std::string& name, bool throw_if) const; + + /// Local -> Global and Global -> Local transformations + XYZPoint toLocal( const XYZPoint& global ) const + { return XYZPoint(detectorAlignment.worldToLocal(XYZVector(global))); } + XYZPoint toGlobal( const XYZPoint& local ) const + { return XYZPoint(detectorAlignment.localToWorld(XYZVector(local))); } + XYZVector toLocal( const XYZVector& globalDirection ) const + { return detectorAlignment.worldToLocal(globalDirection); } + XYZVector toGlobal( const XYZVector& localDirection ) const + { return detectorAlignment.localToWorld(localDirection); } + }; + } // End namespace detail /// Geometry access /** @@ -151,52 +142,17 @@ namespace gaudi { * \date 2018-03-08 * \version 1.0 */ - class DeIOV : public TransformationInfo { + class DeIOVElement : public dd4hep::Handle<detail::DeIOVObject> { DE_CONDITIONS_TYPEDEFS; - /// Forward definition of the static type for facades typedef detail::DeStaticObject static_t; - + typedef detail::DeIOVObject iov_t; + public: /// Standard handle assignments and constructors - DE_CTORS_HANDLE(DeIOV,TransformationInfo); - DeIOV(const TransformationInfo& c) : TransformationInfo(c) {} - - /// Printout method to stdout - void print(int indent, int flags) const; + DE_CTORS_HANDLE(DeIOVElement,Base); /// Access to the static data - static_t& staticData() const - { return access()->de_static; } - - /// Compute key value for caching - static itemkey_type key(const std::string& value) - { return dd4hep::ConditionKey::itemCode(value); } - /// Compute key value for caching - static itemkey_type key(const char* value) - { return dd4hep::ConditionKey::itemCode(value); } - - /// Access all conditions which belong to this detector element - const Conditions& conditions() const; - - /// Check if the condition identified by 'key' is in the list of conditionrefs. - bool hasCondition(itemkey_type key) const - { return this->condition(key, false).isValid(); } - /// Access condition by hash-key (fast) - Condition condition(itemkey_type key) const; - /// Access condition by hash-key (fast) - Condition condition(itemkey_type key, bool throw_if) const; - - /// Check if the condition called 'name' is in the list of conditionrefs. - bool hasCondition(const std::string& nam) const - { return this->condition(nam, false).isValid(); } - /// Access condition by name (slow) - Condition condition(const std::string& name) const; - /// Access condition by name (slow) - Condition condition(const std::string& name, bool throw_if) const; - - /// Access the volume alignments - const VolumeAlignments& volumeAlignments() const; - + static_t& staticData() const { return access()->de_static; } }; } // End namespace gaudi diff --git a/DDDB/include/Detector/DeStatic.h b/DDDB/include/Detector/DeStatic.h index 50e3e3fc3926f2eddb114c35e37e142fc73ba6cc..e0389d5518e81cc6f9f1b48514639276334aeedd 100644 --- a/DDDB/include/Detector/DeStatic.h +++ b/DDDB/include/Detector/DeStatic.h @@ -19,6 +19,9 @@ #ifndef DETECTOR_DESTATIC_H #define DETECTOR_DESTATIC_H +/// Framework include files +#include "Detector/DetectorElement.h" + /// gaudi namespace declaration namespace gaudi { @@ -65,13 +68,20 @@ namespace gaudi { /// Fill the child cache. May only be called while the condition is NOT active void fillCache(ConditionsMap& m); + /// Access daughter elements: Static part + DeStaticObject* child(DetElement de) const; + + /** Simplification accessors. Do not check validity here */ + /// Access parameters directory + const ParameterMap::Parameters& params() const; + + /// Access single parameter + const ParameterMap::Parameter& parameter(const std::string& nam, bool throw_if_not_present=true) const; + /// Type dependent accessor to a named parameter template <typename T> T param(const std::string& nam, bool throw_if_not_present=true) const { return parameters.parameter(nam,throw_if_not_present).template get<T>(); } - /// Access daughter elements: Static part - DeStaticObject* child(DetElement de) const; - public: /// Cache of static information of the children. std::map<DetElement,DeStaticObject*> childCache; @@ -84,9 +94,10 @@ namespace gaudi { /// The parameter map of this detector element ParameterMap parameters; /// Detector element Class ID - int classID = 0; + int clsID = 0; /// Initialization flags to steer actions - int de_flags = 0; + unsigned short de_flags = 0; + unsigned short de_user = 0; /// Item key itemkey_type key = 0; @@ -95,33 +106,33 @@ namespace gaudi { }; } // End namespace detail - /// Base class for static DetectorElement data + /// Handle definition to an instance of a handle to static detector element data /** + * This object defines the behaviour of the objects's data. + * We implement here only the behaviour of the object specific + * stuff. The geometry interactions are then combined with this + * implementation and the specialized detector element + * DetectorElementStatic<TYPE> to the real data accessor. + * The DetectorElementStatic<TYPE> by non-virtual inheritance + * automatically exposes the specific stuff here. + * + * See the corresponding typedef below. + * + * Note: in this class the is no big deal of specialization! + * this for the time being is only for illustration about the mechanism. * * \author Markus Frank * \date 2018-03-08 * \version 1.0 */ - class DeStatic : public dd4hep::Handle<detail::DeStaticObject> { + class DeStaticElement : public dd4hep::Handle<detail::DeStaticObject> { DE_CONDITIONS_TYPEDEFS; - + /// This is needed by the DetectorElement<TYPE> to properly forward requests. + typedef detail::DeStaticObject static_t; public: /// Standard handle assignments and constructors - DE_CTORS_HANDLE(DeStatic,Base); - - /// Printout method to stdout - void print(int indent, int flags) const; - - /** Simplification accessors. Do not check validity here */ - /// Access parameters directory - const ParameterMap::Parameters& params() const; - - /// Access single parameter - const ParameterMap::Parameter& parameter(const std::string& nam, bool throw_if_not_present=true) const; - - /// Type dependent accessor to a named parameter - template <typename T> T param(const std::string& nam, bool throw_if_not_present=true) const - { return parameter(nam,throw_if_not_present).template get<T>(); } + DE_CTORS_HANDLE(DeStaticElement,Base); }; + } // End namespace gaudi #endif // DETECTOR_DESTATIC_H diff --git a/DDDB/include/Detector/DeVP.h b/DDDB/include/Detector/DeVP.h index 678763ac81c7cd6fb3e5befaff4e8e92062d87f1..bcc8d2aa82b5319eb848150a502077cd5bc51de0 100644 --- a/DDDB/include/Detector/DeVP.h +++ b/DDDB/include/Detector/DeVP.h @@ -19,6 +19,15 @@ #include "Detector/DeVPSensor.h" #include "Detector/DeVPGeneric.h" +#define DE_VP_TYPEDEFS(TYP) public: \ + DE_CONDITIONS_TYPEDEFS; \ + typedef std::vector<DeVPSensor##TYP> Sensors; \ + typedef std::vector<DeVPGeneric##TYP> Sides; \ + typedef std::vector<DeVPGeneric##TYP> ModuleSupports; \ + typedef std::vector<DeVPGeneric##TYP> Modules; \ + typedef std::vector<DeVPGeneric##TYP> Ladders + + /// Gaudi namespace declaration namespace gaudi { @@ -33,13 +42,10 @@ namespace gaudi { * \version 1.0 */ class DeVPStaticObject : public DeVPGenericStaticObject { - DE_CONDITIONS_TYPEDEFS; - typedef std::vector<DeVPGenericStatic> Sides; - typedef std::vector<DeVPGenericStatic> ModuleSupports; - typedef std::vector<DeVPGenericStatic> Modules; - typedef std::vector<DeVPGenericStatic> Ladders; + DE_VP_TYPEDEFS(Static); public: + enum { classID = 8200 }; Sides sides; ModuleSupports supports; Modules modules; @@ -65,22 +71,22 @@ namespace gaudi { * \date 2018-03-08 * \version 1.0 */ - class DeVPStatic : public dd4hep::Handle<detail::DeVPStaticObject> { - DE_CONDITIONS_TYPEDEFS; + class DeVPStaticElement : public dd4hep::Handle<detail::DeVPStaticObject> { + DE_VP_TYPEDEFS(Static); + typedef Object static_t; public: /// Standard constructors and assignment - DE_CTORS_HANDLE(DeVPStatic,Base); - /// Printout method to stdout - void print(int indent, int flags) const; + DE_CTORS_HANDLE(DeVPStaticElement,Base); /// Return the number of sensors. - unsigned int numberSensors() const - { return ptr()->sensors.size(); } + size_t numberSensors() const { return ptr()->sensors.size(); } /// Return vector of sensors. - const std::vector<DeVPSensorStatic>& sensors() const - { return ptr()->sensors; } + const std::vector<DeVPSensorStatic>& sensors() const { return ptr()->sensors; } }; + /// For the fully enabled object, we have to combine it with the generic stuff + typedef DetectorStaticElement<DeVPStaticElement> DeVPStatic; + /// Gaudi::detail namespace declaration namespace detail { @@ -92,11 +98,8 @@ namespace gaudi { * \version 1.0 */ class DeVPObject : public DeVPGenericObject { - DE_CONDITIONS_TYPEDEFS; - typedef std::vector<DeVPGeneric> Sides; - typedef std::vector<DeVPGeneric> ModuleSupports; - typedef std::vector<DeVPGeneric> Modules; - typedef std::vector<DeVPGeneric> Ladders; + DE_VP_TYPEDEFS(); + typedef DeVPStatic::Object static_t; public: DeVPStatic vp_static; @@ -123,24 +126,24 @@ namespace gaudi { * \date 2018-03-08 * \version 1.0 */ - class DeVP : public dd4hep::Handle<detail::DeVPObject> { - DE_CONDITIONS_TYPEDEFS; - typedef detail::DeVPStaticObject static_t; + class DeVPElement : public dd4hep::Handle<detail::DeVPObject> { + DE_VP_TYPEDEFS(); + typedef Object::static_t static_t; + typedef Object iov_t; public: /// Standard constructors and assignment - DE_CTORS_HANDLE(DeVP,Base); - /// Printout method to stdout - void print(int indent, int flags) const; + DE_CTORS_HANDLE(DeVPElement,Base); /// Access to the static data - static_t& staticData() const - { return access()->vp_static; } + static_t& staticData() const { return access()->vp_static; } /// Return the number of sensors. - unsigned int numberSensors() const - { return ptr()->sensors.size(); } + size_t numberSensors() const { return ptr()->sensors.size(); } /// Return vector of sensors. - const std::vector<DeVPSensor>& sensors() const - { return ptr()->sensors; } + const std::vector<DeVPSensor>& sensors() const { return ptr()->sensors; } }; + + /// For the fully enabled object, we have to combine it with the generic stuff + typedef DetectorElement<DeVPElement> DeVP; + } // End namespace gaudi #endif // DETECTOR_DEVP_H diff --git a/DDDB/include/Detector/DeVPConditionCalls.h b/DDDB/include/Detector/DeVPConditionCalls.h index a712191f9bf457a4b00c21d671aa71c5105590c6..a49d1667d61a62382d9bfe2ec75699d9927cdad6 100644 --- a/DDDB/include/Detector/DeVPConditionCalls.h +++ b/DDDB/include/Detector/DeVPConditionCalls.h @@ -29,7 +29,7 @@ namespace gaudi { * \date 2018-03-08 * \version 1.0 */ - class VeloUpdateContext : public dd4hep::cond::ConditionUpdateUserContext { + class VPUpdateContext : public dd4hep::cond::ConditionUpdateUserContext { public: std::map<dd4hep::Condition::detkey_type,std::pair<dd4hep::DetElement,dd4hep::DDDB::DDDBCatalog*> > detectors; dd4hep::Condition alignments_done; @@ -83,9 +83,9 @@ namespace gaudi { public: DetElement detector; Catalog* catalog = 0; - VeloUpdateContext* context = 0; + VPUpdateContext* context = 0; /// Initializing constructor - DeVPIOVConditionCall(DetElement de, Catalog* cat, VeloUpdateContext* ctx) + DeVPIOVConditionCall(DetElement de, Catalog* cat, VPUpdateContext* ctx) : detector(de), catalog(cat), context(ctx) {} /// Default destructor virtual ~DeVPIOVConditionCall() = default; @@ -105,7 +105,7 @@ namespace gaudi { class DeVPConditionCall : public DeVPIOVConditionCall { public: /// Initializing constructor - DeVPConditionCall(DetElement de, Catalog* cat, VeloUpdateContext* ctx) + DeVPConditionCall(DetElement de, Catalog* cat, VPUpdateContext* ctx) : DeVPIOVConditionCall(de,cat,ctx) {} /// Default destructor virtual ~DeVPConditionCall() = default; diff --git a/DDDB/include/Detector/DeVPGeneric.h b/DDDB/include/Detector/DeVPGeneric.h index b03964c45eaa71faf0d24fcb4086d684c6a72a0f..05b0a6475677e4ccfe194ae26c1a30de81acd241 100644 --- a/DDDB/include/Detector/DeVPGeneric.h +++ b/DDDB/include/Detector/DeVPGeneric.h @@ -35,10 +35,11 @@ namespace gaudi { */ class DeVPGenericStaticObject : public DeStaticObject { DE_CONDITIONS_TYPEDEFS; + /// Unique classID + enum { classID = 2 }; public: typedef std::vector<DeVPSensorStatic> Sensors; - int vp_flags = 0; Sensors sensors; public: @@ -59,22 +60,20 @@ namespace gaudi { * \date 2018-03-08 * \version 1.0 */ - class DeVPGenericStatic : public dd4hep::Handle<detail::DeVPGenericStaticObject> { + class DeVPGenericStaticElement + : public dd4hep::Handle<detail::DeVPGenericStaticObject> + { DE_CONDITIONS_TYPEDEFS; - - enum { MAIN = 1<<0, - SIDE = 1<<1, - SUPPORT = 1<<2, - MODULE = 1<<3, - LADDER = 1<<4, - SENSOR = 1<<5 - }; + typedef Object static_t; + typedef Object::Sensors Sensors; public: /// Standard constructors and assignment - DE_CTORS_HANDLE(DeVPGenericStatic,Base); - /// Printout method to stdout - void print(int indent, int flags) const; + DE_CTORS_HANDLE(DeVPGenericStaticElement,Base); + /// Export access to the sensors from the detector element + Object::Sensors& sensors() const { return access()->sensors; } }; + /// For the fully enabled object, we have to combine it with the generic stuff + typedef DetectorStaticElement<DeVPGenericStaticElement> DeVPGenericStatic; /// Gaudi::detail namespace declaration namespace detail { @@ -91,7 +90,6 @@ namespace gaudi { public: typedef std::vector<DeVPSensor> Sensors; - int vp_flags = 0; Sensors sensors; public: @@ -112,29 +110,24 @@ namespace gaudi { * \date 2018-03-08 * \version 1.0 */ - class DeVPGeneric : public dd4hep::Handle<detail::DeVPGenericObject> { + class DeVPGenericElement : public dd4hep::Handle<detail::DeVPGenericObject> { DE_CONDITIONS_TYPEDEFS; - - /// Forward definition of the static type for facades - typedef detail::DeStaticObject static_t; - - typedef std::vector<DeVPSensor> Sensors; - enum { MAIN = 1<<0, - SIDE = 1<<1, - SUPPORT = 1<<2, - MODULE = 1<<3, - LADDER = 1<<4, - SENSOR = 1<<5 - }; + /// These two are needed by the DetectorElement<TYPE> to properly forward requests. + typedef Object iov_t; + typedef Object::static_t static_t; + typedef Object::Sensors Sensors; public: /// Standard constructors and assignment - DE_CTORS_HANDLE(DeVPGeneric,Base); - /// Printout method to stdout - void print(int indent, int flags) const; + DE_CTORS_HANDLE(DeVPGenericElement,Base); /// Access to the static data static_t& staticData() const { return access()->de_static; } + /// Export access to the sensors from the detector element + Object::Sensors& sensors() const { return access()->sensors; } }; + /// For the fully enabled object, we have to combine it with the generic stuff + typedef DetectorElement<DeVPGenericElement> DeVPGeneric; + } // End namespace gaudi #endif // DETECTOR_DEVPGENERIC_H diff --git a/DDDB/include/Detector/DeVPSensor.h b/DDDB/include/Detector/DeVPSensor.h index 2efa42b19d691d93fe11216cf1a515fa056f297d..f15bcbfcf8fb28c908b5410fd881f5c07fec7ca7 100644 --- a/DDDB/include/Detector/DeVPSensor.h +++ b/DDDB/include/Detector/DeVPSensor.h @@ -40,6 +40,7 @@ namespace gaudi { */ class DeVPSensorStaticObject : public detail::DeStaticObject { public: + enum { classID = 1008205 }; /// Cache of local x-cooordinates std::array<double,VP::NSensorColumns> local_x; /// Cache of x-pitch @@ -68,7 +69,6 @@ namespace gaudi { /// Sensor ans module number unsigned int sensorNumber = 0; unsigned int module = 0; - bool isLeft = false; public: /// Standard constructors and assignment @@ -89,15 +89,20 @@ namespace gaudi { * \date 2018-03-08 * \version 1.0 */ - class DeVPSensorStatic : public dd4hep::Handle<detail::DeVPSensorStaticObject> { + class DeVPSensorStaticElement + : public dd4hep::Handle<detail::DeVPSensorStaticObject> + { DE_CONDITIONS_TYPEDEFS; + /// This is needed by the DetectorElement<TYPE> to properly forward requests. + typedef Object static_t; public: /// Standard constructors and assignment - DE_CTORS_HANDLE(DeVPSensorStatic,Base); - /// Printout method to stdout - void print(int indent, int flags) const; + DE_CTORS_HANDLE(DeVPSensorStaticElement,Base); }; + /// For the full sensor object, we have to combine it with the geometry stuff: + typedef DetectorStaticElement<DeVPSensorStaticElement> DeVPSensorStatic; + /// Gaudi::detail namespace declaration namespace detail { @@ -110,6 +115,7 @@ namespace gaudi { */ class DeVPSensorObject : public DeIOVObject { DE_CONDITIONS_TYPEDEFS; + typedef DeVPSensorStatic::Object static_t; /// The static part of the detector element DeVPSensorStatic sensor_static; @@ -142,9 +148,10 @@ namespace gaudi { * \date 2018-03-08 * \version 1.0 */ - class DeVPSensor : public dd4hep::Handle<detail::DeVPSensorObject> { + class DeVPSensorElement : public dd4hep::Handle<detail::DeVPSensorObject> { DE_CONDITIONS_TYPEDEFS; - typedef detail::DeVPSensorStaticObject static_t; + typedef Object::static_t static_t; + typedef Object iov_t; public: /** Define conditions access keys for optimization */ @@ -152,9 +159,15 @@ namespace gaudi { static const itemkey_type key_noise; static const itemkey_type key_readout; /// Standard constructors and assignment - DE_CTORS_HANDLE(DeVPSensor,Base); - /// Printout method to stdout - void print(int indent, int flags) const; + DE_CTORS_HANDLE(DeVPSensorElement,Base); + /// Access to the static data. Does this need to be optionized??? + static_t& staticData() const { return access()->sensor_static; } + bool isLeft() const { return (ptr()->de_user&VP::LEFT) != 0; } + bool isRight() const { return (ptr()->de_user&VP::LEFT) == 0; } }; + + /// For the full sensor object, we have to combine it with the geometry stuff: + typedef DetectorStaticElement<DeVPSensorElement> DeVPSensor; + } // End namespace gaudi #endif // DETECTOR_DEVPSENSORIOV_H diff --git a/DDDB/include/Detector/DeVelo.h b/DDDB/include/Detector/DeVelo.h new file mode 100644 index 0000000000000000000000000000000000000000..ededfeeb07f13bda14553d7055c6d35b40786b59 --- /dev/null +++ b/DDDB/include/Detector/DeVelo.h @@ -0,0 +1,157 @@ +//============================================================================== +// AIDA Detector description implementation for LHCb +//------------------------------------------------------------------------------ +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// \author Markus Frank +// \date 2018-03-08 +// \version 1.0 +// +//============================================================================== +#ifndef DETECTOR_DEVELO_H +#define DETECTOR_DEVELO_H 1 + +// Framework include files +#include "Detector/DeVeloSensor.h" +#include "Detector/DeVeloGeneric.h" + +#define DE_VELO_TYPEDEFS(TYP) public: \ + DE_CONDITIONS_TYPEDEFS; \ + typedef std::vector<DeVeloGeneric##TYP> Sides; \ + typedef std::vector<DeVeloGeneric##TYP> Modules; \ + typedef std::vector<DeVeloGeneric##TYP> Supports; \ + typedef std::vector<DeVeloSensor##TYP> Sensors; \ + typedef std::map<unsigned int, DeVeloSensor##TYP> SensorByTell1; \ + typedef std::map<unsigned int, unsigned int> Tell1BySensorID + +/// Gaudi namespace declaration +namespace gaudi { + + /// Gaudi::detail namespace declaration + namespace detail { + + /// Velo detector element data + /** + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloStaticObject : public DeStaticObject { + DE_VELO_TYPEDEFS(Static); + + public: + enum { NHalfs = 2 }; + enum { classID = 8100 }; + Sides sides; + Modules modules; + Supports supports; + Sensors zOrdered; + Sensors sensors[3]; + Sensors rSensors[2]; + Sensors phiSensors[2]; + Sensors rphiSensors[2]; + Sensors puSensors[2]; + SensorByTell1 sensorByTell1; + Tell1BySensorID tell1BySensorID; + dd4hep::Position halfBoxOffsets[NHalfs]; + double sensitiveVolumeCut = 0e0; + + public: + /// Standard constructors and assignment + DE_CTORS_DEFAULT(DeVeloStaticObject); + /// Initialization of sub-classes + virtual void initialize() override; + /// Printout method to stdout + virtual void print(int indent, int flags) const override; + }; + } // End namespace detail + + + /// Handle defintiion to an instance of Velo detector element data + /** + * This object defines the behaviour of the objects's data + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloStaticElement : public dd4hep::Handle<detail::DeVeloStaticObject> { + DE_VELO_TYPEDEFS(Static); + typedef Object static_t; + enum { NHalfs = 2 }; + + public: + /// Standard constructors and assignment + DE_CTORS_HANDLE(DeVeloStaticElement,Base); + }; + /// For the fully enabled object, we have to combine it with the generic stuff + typedef DetectorStaticElement<DeVeloStaticElement> DeVeloStatic; + + /// Gaudi::detail namespace declaration + namespace detail { + + /// Velo detector element data + /** + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloObject : public DeIOVObject { + DE_VELO_TYPEDEFS(); + typedef DeVeloStatic::Object static_t; + + public: + DeVeloStatic vp_static; + Sides sides; + Modules modules; + Supports supports; + Sensors zOrdered; + Sensors sensors[3]; + Sensors rSensors[2]; + Sensors phiSensors[2]; + Sensors rphiSensors[2]; + Sensors puSensors[2]; + + public: + /// Standard constructors and assignment + DE_CTORS_DEFAULT(DeVeloObject); + /// Initialization of sub-classes + virtual void initialize() override; + /// Printout method to stdout + void print(int indent, int flags) const override; + }; + } // End namespace detail + + /// Handle defintiion to an instance of Velo detector element data + /** + * This object defines the behaviour of the objects's data + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloElement : public dd4hep::Handle<detail::DeVeloObject> { + DE_VELO_TYPEDEFS(); + typedef Object::static_t static_t; + typedef Object iov_t; + enum { NHalfs = 2 }; + + public: + /// Standard constructors and assignment + DE_CTORS_HANDLE(DeVeloElement,Base); + /// Access to the static data. If this handle is valid, the static handle must be valid too! + static_t& staticData() const { return *(access()->vp_static.ptr()); } + }; + + /// For the fully enabled object, we have to combine it with the generic stuff + typedef DetectorElement<DeVeloElement> DeVelo; + +} // End namespace gaudi +#undef DE_VELO_TYPEDEFS +#endif // DETECTOR_DEVELO_H diff --git a/DDDB/include/Detector/DeVeloConditionCalls.h b/DDDB/include/Detector/DeVeloConditionCalls.h new file mode 100644 index 0000000000000000000000000000000000000000..58c89049b63d42036814ff27587b3c959a4c6e6f --- /dev/null +++ b/DDDB/include/Detector/DeVeloConditionCalls.h @@ -0,0 +1,117 @@ +//============================================================================== +// AIDA Detector description implementation for LHCb +//------------------------------------------------------------------------------ +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// \author Markus Frank +// \date 2018-03-08 +// \version 1.0 +// +//============================================================================== +#ifndef DETECTOR_DEVPCONDITIONCALLS_H +#define DETECTOR_DEVPCONDITIONCALLS_H 1 + +// Framework include files +#include "Detector/DeVelo.h" +#include "DD4hep/ConditionDerived.h" + +/// Gaudi namespace declaration +namespace gaudi { + + /// Context information used when computing the Velo-pixel derived conditions + /** + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class VeloUpdateContext : public dd4hep::cond::ConditionUpdateUserContext { + public: + std::map<dd4hep::Condition::detkey_type,std::pair<dd4hep::DetElement,dd4hep::DDDB::DDDBCatalog*> > detectors; + dd4hep::Condition alignments_done; + }; + + /// Base class to share common type definitions + /** + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeConditionCallDefs { + public: + typedef dd4hep::DetElement DetElement; + typedef dd4hep::Condition Condition; + typedef dd4hep::ConditionKey ConditionKey; + typedef dd4hep::ConditionKey::KeyMaker KeyMaker; + typedef dd4hep::cond::ConditionResolver Resolver; + typedef dd4hep::cond::ConditionUpdateContext Context; + typedef dd4hep::DDDB::DDDBCatalog Catalog; + }; + + /// Condition derivation call to build the static Velo-pixel DetElement condition information + /** + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloStaticConditionCall : public dd4hep::cond::ConditionUpdateCall, public DeConditionCallDefs { + public: + /// Initializing constructor + DeVeloStaticConditionCall() = default; + /// Default destructor + virtual ~DeVeloStaticConditionCall() = default; + /// Interface to client Callback in order to update the condition + virtual Condition operator()(const ConditionKey& key, const Context& context) override final; + /// Interface to client callback for resolving references or to use data from other conditions + virtual void resolve(Condition c, Resolver& resolver) override final; + }; + + /// Condition derivation call to build the dynamic Velo-pixel DetElement condition information + /** + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloIOVConditionCall : public dd4hep::cond::ConditionUpdateCall, public DeConditionCallDefs { + public: + DetElement detector; + Catalog* catalog = 0; + VeloUpdateContext* context = 0; + /// Initializing constructor + DeVeloIOVConditionCall(DetElement de, Catalog* cat, VeloUpdateContext* ctx) + : detector(de), catalog(cat), context(ctx) {} + /// Default destructor + virtual ~DeVeloIOVConditionCall() = default; + /// Interface to client Callback in order to update the condition + virtual Condition operator()(const ConditionKey& key, const Context& context) override final; + /// Interface to client callback for resolving references or to use data from other conditions + virtual void resolve(Condition c, Resolver& resolver) override; + }; + + /// Condition derivation call to build the dynamic Velo-pixel DetElement condition information + /** + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloConditionCall : public DeVeloIOVConditionCall { + public: + /// Initializing constructor + DeVeloConditionCall(DetElement de, Catalog* cat, VeloUpdateContext* ctx) + : DeVeloIOVConditionCall(de,cat,ctx) {} + /// Default destructor + virtual ~DeVeloConditionCall() = default; + /// Interface to client callback for resolving references or to use data from other conditions + virtual void resolve(Condition c, Resolver& resolver) override final; + }; + +} // End namespace gaudi +#endif // DETECTOR_DEVPCONDITIONCALLS_H diff --git a/DDDB/include/Detector/DeVeloGeneric.h b/DDDB/include/Detector/DeVeloGeneric.h new file mode 100644 index 0000000000000000000000000000000000000000..28ed6155829a0f4a8cb224a59875d7607acc0c43 --- /dev/null +++ b/DDDB/include/Detector/DeVeloGeneric.h @@ -0,0 +1,136 @@ +//============================================================================== +// AIDA Detector description implementation for LHCb +//------------------------------------------------------------------------------ +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// \author Markus Frank +// \date 2018-03-08 +// \version 1.0 +// +//============================================================================== +#ifndef DETECTOR_DEVELOGENERIC_H +#define DETECTOR_DEVELOGENERIC_H 1 + +// Framework include files +#include "Detector/DeVeloSensor.h" +#include "Detector/DeStatic.h" +#include "Detector/DeIOV.h" + +/// Gaudi namespace declaration +namespace gaudi { + + /// Gaudi::detail namespace declaration + namespace detail { + + /// VP detector element data + /** + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloGenericStaticObject : public DeStaticObject { + DE_CONDITIONS_TYPEDEFS; + /// Unique classID + enum { classID = 2 }; + + public: + typedef std::vector<DeVeloGenericStaticObject*> Children; + typedef std::vector<DeVeloSensorStatic> Sensors; + Children children; // Note: Sensors are no children. They go extra + Sensors sensors; + + public: + /// Standard constructors and assignment + DE_CTORS_DEFAULT(DeVeloGenericStaticObject); + /// Initialization of sub-classes + virtual void initialize() override; + /// Printout method to stdout + virtual void print(int indent, int flg) const override; + }; + } // End namespace detail + + /// Handle defintiion to an instance of VP detector element data + /** + * This object defines the behaviour of the objects's data + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloGenericStaticElement : public dd4hep::Handle<detail::DeVeloGenericStaticObject> { + DE_CONDITIONS_TYPEDEFS; + typedef Object static_t; + public: + /// Standard constructors and assignment + DE_CTORS_HANDLE(DeVeloGenericStaticElement,Base); + /// Export access to the sensors from the detector element + Object::Sensors& sensors() const { return access()->sensors; } + /// Export access to the children from the detector element + Object::Children& children() const { return access()->children; } + }; + /// For the fully enabled object, we have to combine it with the generic stuff + typedef DetectorStaticElement<DeVeloGenericStaticElement> DeVeloGenericStatic; + + /// Gaudi::detail namespace declaration + namespace detail { + + /// VP detector element data + /** + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloGenericObject : public DeIOVObject { + DE_CONDITIONS_TYPEDEFS; + + public: + typedef std::vector<DeVeloGenericObject*> Children; + typedef std::vector<DeVeloSensor> Sensors; + Children children; // Note: Sensors are no children. They go extra + Sensors sensors; + + public: + /// Standard constructors and assignment + DE_CTORS_DEFAULT(DeVeloGenericObject); + /// Initialization of sub-classes + virtual void initialize() override; + /// Printout method to stdout + virtual void print(int indent, int flg) const override; + }; + } // End namespace detail + + /// Handle defintiion to an instance of VP detector element data + /** + * This object defines the behaviour of the objects's data + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloGenericElement : public dd4hep::Handle<detail::DeVeloGenericObject> { + DE_CONDITIONS_TYPEDEFS; + /// These two are needed by the DetectorElement<TYPE> to properly forward requests. + typedef Object::static_t static_t; + typedef Object iov_t; + public: + /// Standard constructors and assignment + DE_CTORS_HANDLE(DeVeloGenericElement,Base); + /// Access to the static data. Must define here, not in DetectorElement to preserve types. + static_t& staticData() const { return access()->de_static; } + /// Export access to the sensors from the detector element + Object::Sensors& sensors() const { return access()->sensors; } + /// Export access to the children from the detector element + Object::Children& children() const { return access()->children; } + }; + + /// For the fully enabled object, we have to combine it with the generic stuff + typedef DetectorElement<DeVeloGenericElement> DeVeloGeneric; + +} // End namespace gaudi +#endif // DETECTOR_DEVELOGENERIC_H diff --git a/DDDB/include/Detector/DeVeloSensor.h b/DDDB/include/Detector/DeVeloSensor.h new file mode 100644 index 0000000000000000000000000000000000000000..5278ae3a313a7ea7b934163d705e59b960189832 --- /dev/null +++ b/DDDB/include/Detector/DeVeloSensor.h @@ -0,0 +1,489 @@ +//============================================================================== +// AIDA Detector description implementation for LHCb +//------------------------------------------------------------------------------ +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// \author Markus Frank +// \date 2018-03-08 +// \version 1.0 +// +//============================================================================== +#ifndef DETECTOR_DEVELOSENSOR_H +#define DETECTOR_DEVELOSENSOR_H 1 + +// C/C++ include files +#include <array> + +// Framework include files +#include "Detector/DetectorElement.h" +#include "Detector/DeStatic.h" +#include "Detector/DeIOV.h" +#include "DD4hep/DD4hepUnits.h" + +/// Gaudi namespace declaration +namespace gaudi { + + namespace DeVeloConst { + } + namespace DeVeloFlags { + enum { + // DeVelo specific + ALL = 2, + + // de_flags flags(static/dynamic): ALL objects + RIGHT = 0, + LEFT = 1<<0, + MAIN = 1<<2, + SIDE = 1<<3, + SUPPORT = 1<<4, + MODULE = 1<<5, + LADDER = 1<<6, + SENSOR = 1<<7, + + // de_user flags(static): DeVeloSensorStatic specific + TOP = 1<<8, // 4 + DOWNSTREAM = 1<<9, + R_TYPE = 1<<10, + PHI_TYPE = 1<<11, + PU_TYPE = 1<<12, + + // de_user flags(dynamic): DeVeloSensorIOV specific + READOUT = 1<<7, + T1NOSENS = 1<<8 + }; + } + + /// Gaudi::detail namespace declaration + namespace detail { + + /// Generic VP static detector element + /** + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloSensorStaticObject : public detail::DeStaticObject { + public: + /// Unique classID + enum { classID = 1008101 }; + + static const unsigned int minRoutingLine = 1; + static const unsigned int maxRoutingLine = 2048; + static const unsigned int numberOfStrips = 2048; + + std::string moduleName; + std::string typeName; + std::string fullType; + int moduleId;//<Liverpool database module id + unsigned int sensorNumber; + double siliconThickness; + double innerRadius; + double outerRadius; + + /// Un-inited - still + unsigned int numberOfZones; + std::map< unsigned int, unsigned int > mapRoutingLineToStrip; + std::map< unsigned int, unsigned int > mapStripToRoutingLine; + std::vector< std::pair< XYZPoint, XYZPoint > > stripLimits; + + public: + /// Standard constructors and assignment + DE_CTORS_DEFAULT(DeVeloSensorStaticObject); + + /// Initialization of sub-classes + virtual void initialize() override; + /// Printout method to stdout + virtual void print(int indent, int flags) const override; + }; + } // End namespace detail + + /// Handle definition to an instance of VP static detector element data + /** + * This object defines the behaviour of the objects's data. + * We implement here only the behaviour of the object specific + * stuff. The geometry interactions are then combined with this + * implementation and the specialized detector element + * DetectorElementStatic<TYPE> to the real data accessor. + * The DetectorElementStatic<TYPE> by non-virtual inheritance + * automatically exposes the specific stuff here. + * + * See the corresponding typedef below. + * + * Note: in this class the is no big deal of specialization! + * this for the time being is only for illustration about the mechanism. + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloSensorStaticElement : public dd4hep::Handle<detail::DeVeloSensorStaticObject> { + DE_CONDITIONS_TYPEDEFS; + /// This is needed by the DetectorElement<TYPE> to properly forward requests. + typedef Object static_t; + public: + /// Standard constructors and assignment + DE_CTORS_HANDLE(DeVeloSensorStaticElement,Base); + }; + + /// For the full sensor object, we have to combine it with the geometry stuff: + typedef DetectorStaticElement<DeVeloSensorStaticElement> DeVeloSensorStatic; + + + /// Gaudi::detail namespace declaration + namespace detail { + + /// Generic VP iov dependent detector element + /** + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloSensorObject : public DeIOVObject { + DE_CONDITIONS_TYPEDEFS; + typedef DeVeloSensorStatic::Object static_t; + + /// The static part of the detector element. Cached for optimizations to avoid casts + DeVeloSensorStatic sensor_static; + + /** For ref only: values are taken from the RUN-II conditions information */ + /// Reference to time-dependent sensor information + Condition info; + /// Reference to time-dependent noise + Condition noise; + /// Reference to time-dependent readout configuration parameters + Condition readout; + + DeIOV halfBoxGeom; + Condition stripNoiseCondition; + Condition stripInfoCondition; + Condition readoutCondition; + + std::vector< double > stripNoise; + std::vector< int > stripInfos; + + double z = 0.0; + + public: + /// Standard constructors and assignment + DE_CTORS_DEFAULT(DeVeloSensorObject); + + /// Initialization of sub-classes + virtual void initialize() override; + /// Printout method to stdout + virtual void print(int indent, int flags) const override; + }; + } // End namespace detail + + + /// Handle defintiion to an instance of VP IOV dependent data + /** + * This object defines the behaviour of the objects's data. + * We implement here only the behaviour of the object specific + * stuff. The geometry interactions are then combined with this + * implementation and the specialized detector element + * DetectorElement<TYPE> to the real data accessor. + * The DetectorElement<TYPE> by non-virtual inheritance + * automatically exposes the specific stuff here. + * + * See the corresponding typedef below. + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloSensorElement : public dd4hep::Handle<detail::DeVeloSensorObject> { + DE_CONDITIONS_TYPEDEFS; + /// These two are needed by the DetectorElement<TYPE> to properly forward requests. + typedef Object::static_t static_t; + typedef Object iov_t; + + public: + /** Define conditions access keys for optimization */ + static const itemkey_type key_info; + static const itemkey_type key_noise; + static const itemkey_type key_readout; + + /** @class DeVeloSensor::StripInfo DeVeloSensor.h VeloDet/DeVeloSensor.h + * + * Encodes strip information. + * From construction information states are : + * OK, Low gain, Noisy, Dead, Open, Pinhole and Short + * + * @author Kurt Rinnert + * @date 2006-01-18 + */ + class StripInfo + { + public: + StripInfo() : m_info(0) { ; } + StripInfo(int i) : m_info(i) { ; } + + private: + enum { + LOWGAIN= 2, + NOISY= 1, + STRIPOK = 0, + DEAD= -1, + OPEN= -2, + PINHOLE= -3, + SHORT= -4 + }; + + public: + /// No problems with this strip + bool stripIsOK() const { return m_info==STRIPOK; } + /// Lower gain strip + bool stripIsLowGain() const { return m_info==LOWGAIN; } + /// higher noise strip + bool stripIsNoisy() const { return m_info==NOISY; } + /// very low gain strip + bool stripIsDead() const { return m_info==DEAD; } + /// Did not bond strip to beetle + bool stripIsOpen() const { return m_info==OPEN; } + /// pinhole in sensor + bool stripIsPinhole() const { return m_info==PINHOLE; } + /// Strip shorted to another (may not be next neighbour) + bool stripIsShort() const { return m_info==SHORT; } + /// StripInfo as integer + int asInt() const{ return m_info; } + + private: + int m_info; + }; + + /// Standard constructors and assignment + DE_CTORS_HANDLE(DeVeloSensorElement,Base); + /// Access to the static data. Does this need to be optionized??? + static_t& staticData() const + { return access()->sensor_static; } + /// Access the time dependent data block. Used internally - may be specialized for optimization. + const iov_t& iovData() const + { return *access(); } + + /// Return station number, station contains 2 modules (right and left) + unsigned int station () const + { return (staticData().sensorNumber&0x3E) >> 1; } + /// Returns the sensor number. + unsigned int sensorNumber () const + { return staticData().sensorNumber; } + /// Returns the hardware module number. + unsigned int moduleId () const + { return staticData().moduleId; } + /// Return the number of strips. + unsigned int numberOfStrips () const + { return staticData().numberOfStrips; } + /// Access the strip info object + StripInfo stripInfo(size_t which) const + { return iovData().stripInfos[which]; } + /// The number of zones in the detector. + unsigned int numberOfZones () const + { return staticData().numberOfZones; } + /// Return the z position of the sensor in the global frame. + double z () const + { return iovData().z; } + /// The minimum radius for the sensitive area of the sensor. + double innerRadius () const + { return staticData().innerRadius; } + /// The maximum radius for the sensitive area of the sensor. + double outerRadius () const + { return staticData().outerRadius; } + /// The thickness of the sensor in mm. + double siliconThickness () const + { return staticData().siliconThickness; } + /// Return true for X<0 side of the detector (-ve x is Right) + bool isRight () const + { return 0 == (staticData().de_user&DeVeloFlags::LEFT); } + /// Return true for X>0 side of the detector (+ve x is Left) + bool isLeft () const + { return 1 == (staticData().de_user&DeVeloFlags::LEFT); } + /// Returns true if sensor is downstream. + bool isDownstream () const + { return 1 == (staticData().de_user&DeVeloFlags::DOWNSTREAM); } + /// Returns true if pile up Sensor. + bool isPileUp () const + { return 1 == (staticData().de_user&DeVeloFlags::PU_TYPE); } + /// Returns true if R Sensor. + bool isR () const + { return 1 == (staticData().de_user&DeVeloFlags::R_TYPE); } + /// Returns true if Phi Sensor. + bool isPhi () const + { return 1 == (staticData().de_user&DeVeloFlags::PHI_TYPE); } + /// Returns true if sensor is top cabled. + bool isTop () const + { return 1 == (staticData().de_user&DeVeloFlags::TOP); } + /// Returns true if sensor is bottom cabled. + bool isBottom () const + { return 0 == (staticData().de_user&DeVeloFlags::TOP); } + /** Check whether this sensor is read out at all (cached condition). + * This information is based on CondDB, i.e. it can change + * with time. + */ + bool isReadOut() const + { return 1 == (staticData().de_user&DeVeloFlags::READOUT); } + /** Check whether this sensor exists or is TELL1 w/o sensor (cached condition). + * This information is based on CondDB, i.e. it can change + * with time. + */ + bool tell1WithoutSensor() const + { return 1 == (staticData().de_user&DeVeloFlags::T1NOSENS); } + + + unsigned int globalZoneOfStrip(const unsigned int strip) const { + int flg = staticData().de_user; + return (flg&DeVeloFlags::PHI_TYPE) + ? static_cast<unsigned int>(strip>682) + : ((flg&DeVeloFlags::DOWNSTREAM) ? 3-strip/512 : strip/512); + } + /** The Noise of a strip (cached condition). + * This information is based on CondDB, i.e. it can change + * with time. + */ + double stripNoise(unsigned int strip) const { return iovData().stripNoise[strip]; } + + /** Get info for this strip (cached condition). + * This information is based on CondDB, i.e. it can change + * with time. + * @see StripInfo + */ + StripInfo stripInfo(unsigned int strip) const { return iovData().stripInfos[strip]; } + + /// Convert position inside Velo half Box (one per side) into local position + /// Local from is +ve x and Upstream + XYZPoint veloHalfBoxToLocal(const XYZPoint& boxPos) const { + XYZPoint globalPos = iovData().halfBoxGeom.toGlobal(boxPos); + return DeIOV(ptr()).toLocal(globalPos); + } + /// Convert position inside Velo half Box (one per side) to global + XYZPoint veloHalfBoxToGlobal(const XYZPoint& boxPos) const { + return iovData().halfBoxGeom.toGlobal(boxPos); + } + /// Convert global position to inside Velo half Box (one per side) + XYZPoint globalToVeloHalfBox(const XYZPoint& globalPos) const { + return iovData().halfBoxGeom.toLocal(globalPos); + } + + /// Returns a pair of points which define the begin and end points of a strip in the local frame + std::pair<XYZPoint,XYZPoint> localStripLimits(unsigned int strip) const { + return staticData().stripLimits[strip]; + } + + /// Returns a pair of points which define the begin and end points of a strip in the global frame + std::pair<XYZPoint,XYZPoint> globalStripLimits(unsigned int strip) const { + const DeIOV iov(ptr()); + const static_t& s = staticData(); + XYZPoint begin = iov.toGlobal(s.stripLimits[strip].first); + XYZPoint end = iov.toGlobal(s.stripLimits[strip].second); + return std::pair<XYZPoint,XYZPoint>(begin,end); + } + /// Convert local phi to ideal global phi + double localPhiToGlobal(double phiLocal) const { + int flg = staticData().de_user; + if( flg&DeVeloFlags::DOWNSTREAM ) phiLocal = -phiLocal; + if( 0 == (flg&DeVeloFlags::LEFT) ) phiLocal += dd4hep::pi; // if ( isRight() ) .... + return phiLocal; + } + /// Convert routing line to chip channel (1234 -> 0213) + unsigned int RoutingLineToChipChannel(unsigned int routLine) const { + routLine = detail::DeVeloSensorStaticObject::maxRoutingLine-routLine; + if(1 == routLine%4){ + routLine++; + }else if(2 == routLine%4){ + routLine--; + } + return routLine; + } + /// Convert chip channel to routing line (0213 -> 1234) + unsigned int ChipChannelToRoutingLine(unsigned int chipChan) const { + if(1 == chipChan%4){ + chipChan++; + } else if(2 == chipChan%4) { + chipChan--; + } + return (detail::DeVeloSensorStaticObject::numberOfStrips-chipChan); + } + /// Convert chip channel to strip number + unsigned int ChipChannelToStrip(unsigned int chipChan) const { + return RoutingLineToStrip(ChipChannelToRoutingLine(chipChan)); + } + /// Convert strip number to chip channel + unsigned int StripToChipChannel(unsigned int strip) const { + return RoutingLineToChipChannel(StripToRoutingLine(strip)); + } + /// Convert routing line to strip number + unsigned int RoutingLineToStrip(unsigned int routLine) const { + return staticData().mapRoutingLineToStrip.at(routLine); + } + /// Convert strip number to routing line + unsigned int StripToRoutingLine(unsigned int strip) const { + return staticData().mapStripToRoutingLine.at(strip); + } + /// Get the chip number from the routing line + unsigned int ChipFromRoutingLine(unsigned int routLine) const { + return ChipFromChipChannel(RoutingLineToChipChannel(routLine)); + } + /// Get the chip number from the chip channel + unsigned int ChipFromChipChannel(unsigned int chipChan) const { + return static_cast<int>(chipChan/128); + } + /// Get the Chip from the strip + unsigned int ChipFromStrip(unsigned int strip) const { + return ChipFromChipChannel(StripToChipChannel(strip)); + } + /** Return the validity of a strip + * Since this method uses the condition cache, the result + * depends on CondDB. + */ + bool OKStrip(unsigned int strip) const { + return (strip<staticData().numberOfStrips && stripInfo(strip).stripIsOK()); + } + /// Returns the validity of a given channel + bool OKChipChannel(unsigned int chipChan) const { + return (chipChan<staticData().numberOfStrips && OKStrip(ChipChannelToStrip(chipChan))); + } + }; + + /// For the full sensor object, we have to combine it with the geometry stuff: + typedef DetectorElement<DeVeloSensorElement> DeVeloSensor; + + + /// Handle defintiion to an instance of VP IOV dependent data + /** + * This object defines the behaviour of the objects's data + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloRSensor : public DeVeloSensorElement { + enum { classID = 1008101 }; + + public: + /// Standard constructors and assignment + DE_CTORS_HANDLE(DeVeloRSensor,DeVeloSensorElement); + }; + + + /// Handle defintiion to an instance of VP IOV dependent data + /** + * This object defines the behaviour of the objects's data + * + * \author Markus Frank + * \date 2018-03-08 + * \version 1.0 + */ + class DeVeloPhiSensor : public DeVeloSensorElement { + enum { classID = 1008101 }; + + public: + /// Standard constructors and assignment + DE_CTORS_HANDLE(DeVeloPhiSensor,DeVeloSensorElement); + }; + +} // End namespace gaudi +#endif // DETECTOR_DEVELOSENSORIOV_H diff --git a/DDDB/include/Detector/DetectorElement.h b/DDDB/include/Detector/DetectorElement.h index 57df6c0c13e3a0f82ef26f4ca54ccc893f45afeb..85771e482bb199b5b808b42f2f51654faabee6ce 100644 --- a/DDDB/include/Detector/DetectorElement.h +++ b/DDDB/include/Detector/DetectorElement.h @@ -76,18 +76,19 @@ namespace gaudi { std::string indent(int level); } namespace DePrint { - enum PrintFlags { BASICS = 1, - PARAMS = 2, - DETAIL = 4, - SPECIFIC = 5, - STATIC = 6, - ALIGNMENTS = 7, - ALL = BASICS|PARAMS|DETAIL|SPECIFIC|STATIC + enum PrintFlags { BASICS = 1<<1, + PARAMS = 1<<2, + DETAIL = 1<<4, + SPECIFIC = 1<<5, + STATIC = 1<<6, + ALIGNMENTS = 1<<7, + CHILDREN = 1<<8, + ALL = BASICS|PARAMS|DETAIL|SPECIFIC|STATIC|CHILDREN }; } namespace DeInit { enum InitFlags { FILLCACHE = 1, - INITIALIZED = 1<<31 + INITIALIZED = 1<<15 }; } struct DeHelpers { @@ -145,7 +146,92 @@ namespace gaudi { }; } // End namespace gaudi + +/// ------------------- Generic handle layer for STATIC objects ----------------- #include "Detector/DeStatic.h" + +/// Gaudi::detail namespace declaration +namespace gaudi { + + template<typename TYPE> + class DetectorStaticElement : public TYPE { + DE_CONDITIONS_TYPEDEFS; + typedef DetectorStaticElement<TYPE> self_t; + typedef TYPE base_t; + typedef typename TYPE::static_t static_t; + typedef typename DetElement::Children children_t; + protected: + /// Static detelement accessor. Used internally - may be specialized for optimization + const static_t& static_data() const; + /// Access to the base implementation + base_t& base() { return *this; } + + public: + /// Standard constructor + DetectorStaticElement() = default; + /// Copy constructoe + DetectorStaticElement(const DetectorStaticElement&) = default; + /// Copy assignment + DetectorStaticElement& operator=(const DetectorStaticElement&) = default; + /// Constructor from base class pointer + DetectorStaticElement(const typename base_t::Object* p) : base_t(p) {} + /// Constructor from other polymorph pointers + template <typename Q> DetectorStaticElement(Q* p) : base_t(dd4hep::Handle<Q>(p)) {} + + /// Constructor from other polymorph handle + template <typename Q> DetectorStaticElement(const dd4hep::Handle<Q>& p) : base_t() { + base() = p; + if ( p.ptr() && !this->ptr() ) { this->bad_assignment(typeid(p),typeid(self_t)); } + } + + /// Copy assignment from polymorph handle + template <typename Q> DetectorStaticElement& operator=(const dd4hep::Handle<Q>& p) { + base() = p; + if ( p.ptr() && !this->ptr() ) { this->bad_assignment(typeid(p),typeid(self_t)); } + return *this; + } + + /// Access to the classID + static int classID() { return static_t::classID; } + + /// Print the detector element's information to stdout. No-inline, allow specialization + void print(int indent, int flg) const; + + /** Simplification accessors. Do not check validity here */ + /// Access parameters directory + const ParameterMap::Parameters& params() const + { return static_data().params(); } + + /// Access single parameter + const ParameterMap::Parameter& parameter(const std::string& nam, bool throw_if_not_present=true) const + { return static_data().parameter(nam, throw_if_not_present); } + + /// Type dependent accessor to a named parameter + template <typename T> T param(const std::string& nam, bool throw_if_not_present=true) const + { return static_data().template parameter<T>(nam,throw_if_not_present); } + + /// Access daughter elements: Static part + DeStaticElement child(DetElement de) const + { return static_data().child(de); } + }; + + + /// Static detelement accessor. Used internally - may be specialized for optimization + template <typename TYPE> inline + const typename DetectorStaticElement<TYPE>::static_t& + DetectorStaticElement<TYPE>::static_data() const + { return this->TYPE::staticData(); } + + /// Print the detector element's information to stdout. Allow specialization + template <typename TYPE> inline + void DetectorStaticElement<TYPE>::print(int indent, int flg) const + { this->base_t::access()->print(indent, flg); } + + /// For the fully enabled object, we have to combine it with the generic stuff + typedef DetectorStaticElement<DeStaticElement> DeStatic; +} // End namespace gaudi + +/// ------------------- Generic handle layer for IOV objects ------------------- #include "Detector/DeIOV.h" /// Gaudi::detail namespace declaration @@ -161,8 +247,8 @@ namespace gaudi { template<typename TYPE> class DetectorElement : public TYPE { DE_CONDITIONS_TYPEDEFS; - typedef DetectorElement<TYPE> self_t; - typedef TYPE base_t; + typedef DetectorElement<TYPE> self_t; + typedef TYPE base_t; typedef typename TYPE::Object iov_t; typedef typename TYPE::static_t static_t; typedef typename DetElement::Children children_t; @@ -172,8 +258,9 @@ namespace gaudi { const static_t& static_data() const; /// Access the time dependent data block. Used internally - may be specialized for optimization const iov_t& iovData() const; - + /// Access to the base implementation base_t& base() { return *this; } + public: /// Standard constructor DetectorElement() = default; @@ -196,11 +283,22 @@ namespace gaudi { if ( p.ptr() && !this->ptr() ) { this->bad_assignment(typeid(p),typeid(self_t)); } return *this; } - + + /// Access to the classID + static int classID() { return static_t::classID; } + /// Print the detector element's information to stdout + void print(int indent, int flg) const; + /// Compute key value for caching + static itemkey_type key(const std::string& value) + { return dd4hep::ConditionKey::itemCode(value); } + /// Compute key value for caching + static itemkey_type key(const char* value) + { return dd4hep::ConditionKey::itemCode(value); } + /** Access to static detector element data */ - /// Detector element Class ID - int classID() const - { return static_data().classID; } + /// Detector element Class ID (real one from XML, not the enum!) + int clsID() const + { return static_data().clsID; } /// Accessor to detector structure DetElement detector() const { return static_data().detector; } @@ -241,7 +339,7 @@ namespace gaudi { { return iovData().detectorAlignment; } /// Access the volume alignments const VolumeAlignments& volumeAlignments() const - { return iovData().volumeAlignments(); } + { return iovData().volumeAlignments; } /// helper member using IGeometryInfo::isInside bool isInside(const XYZPoint& globalPoint) const @@ -257,11 +355,11 @@ namespace gaudi { /// Access to transformation matrices const TGeoHMatrix& toLocalMatrix() const - { return iovData().toLocalMatrix(); } + { return iovData().toLocalMatrix; } const TGeoHMatrix& toGlobalMatrix() const - { return iovData().toGlobalMatrix(); } + { return iovData().toGlobalMatrix; } const TGeoHMatrix& toLocalMatrixNominal() const - { return iovData().toLocalMatrixNominal(); } + { return iovData().toLocalMatrixNominal; } /// Local -> Global and Global -> Local transformations XYZPoint toLocal( const XYZPoint& global ) const @@ -273,7 +371,7 @@ namespace gaudi { XYZVector toGlobal( const XYZVector& localDirection ) const { return iovData().toGlobal(localDirection); } }; - + /// Static detelement accessor. Used internally - may be specialized for optimization template <typename TYPE> inline const typename DetectorElement<TYPE>::static_t& @@ -285,6 +383,14 @@ namespace gaudi { const typename DetectorElement<TYPE>::iov_t& DetectorElement<TYPE>::iovData() const { return *(this->TYPE::access()); } + + /// Print the detector element's information to stdout. Allow specialization + template <typename TYPE> inline + void DetectorElement<TYPE>::print(int indent, int flg) const + { this->base_t::access()->print(indent, flg); } + /// For the fully enabled object, we have to combine it with the generic stuff + typedef DetectorElement<DeIOVElement> DeIOV; } // End namespace gaudi + #endif diff --git a/DDDB/include/Kernel/VPConstants.h b/DDDB/include/Kernel/VPConstants.h index 45e19202ffa1fbeb5237d41eb2a0d57cfb733eb5..84a15c8a49ea03256cd2c344939209f6101ca9ed 100644 --- a/DDDB/include/Kernel/VPConstants.h +++ b/DDDB/include/Kernel/VPConstants.h @@ -2,17 +2,28 @@ #define KERNEL_VPCONSTANTS_H 1 namespace VP { -static const unsigned int NModules = 52; -static const unsigned int NSensorsPerModule = 4; -static const unsigned int NSensors = NModules * NSensorsPerModule; -static const unsigned int NChipsPerSensor = 3; -static const unsigned int NRows = 256; -static const unsigned int NColumns = 256; -static const unsigned int NSensorColumns = NColumns * NChipsPerSensor; -static const unsigned int NPixelsPerSensor = NSensorColumns * NRows; + static const unsigned int NModules = 52; + static const unsigned int NSensorsPerModule = 4; + static const unsigned int NSensors = NModules * NSensorsPerModule; + static const unsigned int NChipsPerSensor = 3; + static const unsigned int NRows = 256; + static const unsigned int NColumns = 256; + static const unsigned int NSensorColumns = NColumns * NChipsPerSensor; + static const unsigned int NPixelsPerSensor = NSensorColumns * NRows; -static const double Pitch = 0.055; + static const double Pitch = 0.055; + enum UserFlags { + LEFT = 0, + RIGHT = 1<<0, + MAIN = 1<<1, + SIDE = 1<<2, + SUPPORT = 1<<3, + MODULE = 1<<4, + LADDER = 1<<5, + SENSOR = 1<<6 + }; + } #endif diff --git a/DDDB/src/Detector/DeIOV.cpp b/DDDB/src/Detector/DeIOV.cpp index 39236bfbbc8cf9901f88de0b588c004cc92400c3..cb26018de92d388de09ebb5ddaf0b24bb7d3729b 100644 --- a/DDDB/src/Detector/DeIOV.cpp +++ b/DDDB/src/Detector/DeIOV.cpp @@ -35,7 +35,7 @@ using namespace gaudi::detail; /// Helper to initialize the basic information DeIOVObject* DeIOVObject::fill_info(DetElement de, Catalog* /* cat */) { name = Keys::deKeyName; - key = Keys::deKey; + item_key = Keys::deKey; detector = de; return this; } @@ -58,26 +58,26 @@ void DeIOVObject::initialize() { /// Printout method to stdout void DeIOVObject::print(int indent, int flg) const { std::string prefix = DE::indent(indent); - printout(INFO, "DeIOVObject", + if ( flg&DePrint::STATIC) { + de_static.print(indent, flg&~DePrint::CHILDREN); + } + printout(INFO, "DeIOV", "%s+ Name:%s Hash:%016lX Type:%s Flags:%08X IOV:%s", prefix.c_str(), name.c_str(), hash, is_bound() ? data.dataType().c_str() : "<UNBOUND>", flags, iov ? iov->str().c_str() : "--"); - if ( flg&DePrint::STATIC) { - de_static.print(indent, flg); - } if ( flg&DePrint::DETAIL) { - printout(INFO, "DeIOVObject","%s+ >> Conditions:%ld Alignment:%s VolAlign:%ld", + printout(INFO, "DeIOV","%s+ >> Conditions:%ld Alignment:%s VolAlign:%ld", prefix.c_str(), conditions.size(), yes_no(detectorAlignment.isValid()), volumeAlignments.size()); for(const auto& cc : conditions) { Condition c = cc.second; - printout(INFO, "DeIOVObject","%s+ >> Condition [%08X] %s Hash:%016X Flags:%08X Type:%s", + printout(INFO, "DeIOV","%s+ >> Condition [%08X] %s Hash:%016X Flags:%08X Type:%s", prefix.c_str(), cc.first, c.name(), c.key(), c.flags(), c.is_bound() ? c.data().dataType().c_str() : "<UNBOUND>"); if ( c->iov ) { - printout(INFO, "DeIOVObject","%s+ >> + IOV:%s", + printout(INFO, "DeIOV","%s+ >> + IOV:%s", prefix.c_str(), c->iov ? c.iov().str().c_str() : "--"); } } @@ -101,14 +101,14 @@ void DeIOVObject::print(int indent, int flg) const { else ::snprintf(txt3,sizeof(txt3),"Pivot: ------- "); - printout(INFO,"DeIOVObject","%s+ >> Aligment [%p] Typ:%s \tData:(%11s-%8s-%5s)", + printout(INFO,"DeIOV","%s+ >> Aligment [%p] Typ:%s \tData:(%11s-%8s-%5s)", prefix.c_str(), detectorAlignment.ptr(), dd4hep::typeName(typeid(*ptr)).c_str(), D.hasTranslation() ? "Translation" : "", D.hasRotation() ? "Rotation" : "", D.hasPivot() ? "Pivot" : ""); if ( D.hasTranslation() || D.hasRotation() || D.hasPivot() ) { - printout(INFO,"DeIOVObject","%s+ >> Aligment-Delta %s %s %s",prefix.c_str(), txt1,txt2,txt3); + printout(INFO,"DeIOV","%s+ >> Aligment-Delta %s %s %s",prefix.c_str(), txt1,txt2,txt3); } } } @@ -142,48 +142,30 @@ DeIOVObject* DeIOVObject::child(DetElement de) const { return (*i).second; } -/// Printout method to stdout -void DeIOV::print(int indent, int flags) const { - return access()->print(indent, flags); -} - /// Access condition by name -DeIOV::Condition DeIOV::condition(const std::string& nam) const { +DeIOV::Condition DeIOVObject::condition(const std::string& nam) const { return this->condition(dd4hep::ConditionKey::itemCode(nam)); } /// Access condition by name -DeIOV::Condition DeIOV::condition(const std::string& nam, bool throw_if) const { +DeIOV::Condition DeIOVObject::condition(const std::string& nam, bool throw_if) const { return this->condition(dd4hep::ConditionKey::itemCode(nam), throw_if); } /// Access condition by name -DeIOV::Condition DeIOV::condition(itemkey_type key) const { - const auto* o = access(); - auto i = o->conditions.find(key); - return (i == o->conditions.end()) ? (*i).second : Condition(); +DeIOV::Condition DeIOVObject::condition(itemkey_type k) const { + auto i = conditions.find(k); + return (i == conditions.end()) ? (*i).second : Condition(); } /// Access condition by name -DeIOV::Condition DeIOV::condition(itemkey_type key, bool throw_if) const { - const auto* o = access(); - auto i = o->conditions.find(key); - if (i != o->conditions.end()) { +DeIOV::Condition DeIOVObject::condition(itemkey_type k, bool throw_if) const { + auto i = conditions.find(k); + if (i != conditions.end()) { return (*i).second; } if ( throw_if ) { - except("DeIOV","Attempt to access non-existing condition."); + except("DeIOV","Attempt to access non-existing condition with key: %d.",k); } return Condition(); } - -/// Access all conditions which belong to this detector element -const DeIOV::Conditions& DeIOV::conditions() const { - return access()->conditions; -} - -/// Access the volume alignments -const DeIOV::VolumeAlignments& DeIOV::volumeAlignments() const { - return access()->volumeAlignments; -} - diff --git a/DDDB/src/Detector/DeStatic.cpp b/DDDB/src/Detector/DeStatic.cpp index be1d0880183308e114e6b5ce1cb4d4db32a4569a..67b7d46b5b52de61478eff1d773f4342513e5e4f 100644 --- a/DDDB/src/Detector/DeStatic.cpp +++ b/DDDB/src/Detector/DeStatic.cpp @@ -32,7 +32,7 @@ DeStaticObject* DeStaticObject::fill_info(DetElement de, Catalog* cat) { geometry = de.placement(); name = Keys::staticKeyName; key = Keys::staticKey; - classID = cat->classID; + clsID = cat->classID; catalog = cat; for( const auto& p : cat->params ) parameters.set(p.first, p.second.second, p.second.first); @@ -52,18 +52,8 @@ void DeStaticObject::initialize() { /// Printout method to stdout void DeStaticObject::print(int indent, int flg) const { std::string prefix = DE::indent(indent); - printout(INFO, "DeStatic", "%s+ Detector:%s", + printout(INFO, "DeStatic", "%s*========== Detector:%s", prefix.c_str(), detector.path().c_str()); - printout(INFO, "DeStatic", - "%s+ Name:%s Hash:%016lX Type:%s Flags:%08X IOV:%s", - prefix.c_str(), name.c_str(), hash, - is_bound() ? data.dataType().c_str() : "<UNBOUND>", - flags, iov ? iov->str().c_str() : "--"); - if ( flg & DePrint::BASICS ) { - const DetElement::Children& c = detector.children(); - printout(INFO, "DeStatic", "%s+ Detector:%s Class:%d key:%08X #Dau:%d", - prefix.c_str(), detector.name(), classID, key, int(c.size())); - } if ( flg & DePrint::PARAMS ) { for( const auto& p : parameters.params() ) { printout(INFO, "DeStatic", "%s+ Param: %s -> %s [%s]", @@ -71,6 +61,19 @@ void DeStaticObject::print(int indent, int flg) const { p.second.value.c_str(), p.second.type.c_str()); } } + printout(INFO, "DeStatic", + "%s+ Name:%s Hash:%016lX Type:%s Flags:%08X %s%s", + prefix.c_str(), name.c_str(), hash, + is_bound() ? data.dataType().c_str() : "<UNBOUND>", + flags, iov ? "" : "IOV:", iov ? "" : "---"); + if ( iov ) { + printout(INFO, "DeStatic","%s+ IOV: %s", prefix.c_str(), iov->str().c_str()); + } + if ( flg & DePrint::BASICS ) { + const DetElement::Children& c = detector.children(); + printout(INFO, "DeStatic", "%s+ Detector:%s Class:%d key:%08X #Dau:%d", + prefix.c_str(), detector.name(), clsID, key, int(c.size())); + } } /// Access daughter elements: Static part @@ -93,18 +96,13 @@ void DeStaticObject::fillCache(ConditionsMap& m) { Keys::staticKeyName.c_str(), detector.path().c_str()); } -/// Printout method to stdout -void DeStatic::print(int indent, int flags) const { - return access()->print(indent, flags); -} - /// Access parameters directory -const ParameterMap::Parameters& DeStatic::params() const { - return access()->parameters.params(); +const ParameterMap::Parameters& DeStaticObject::params() const { + return this->parameters.params(); } /// Access single parameter const ParameterMap::Parameter& -DeStatic::parameter(const std::string& nam, bool throw_if_not_present) const { - return access()->parameters.parameter(nam, throw_if_not_present); +DeStaticObject::parameter(const std::string& nam, bool throw_if_not_present) const { + return this->parameters.parameter(nam, throw_if_not_present); } diff --git a/DDDB/src/Detector/DeVP.cpp b/DDDB/src/Detector/DeVP.cpp index c9ac3a5beccdd1f17ec543ae711bf24050526591..ecd9d04625d17d4e88f73353e3f0b0f4edae174f 100644 --- a/DDDB/src/Detector/DeVP.cpp +++ b/DDDB/src/Detector/DeVP.cpp @@ -23,12 +23,11 @@ using namespace gaudi::detail; /// Printout method to stdout void DeVPStaticObject::print(int indent, int flg) const { std::string prefix = DE::indent(indent); - printout(INFO, "DeVPStatic", - "%s*+++++ VP detector element for %s Sides:%ld Supports:%ld Modules:%ld Ladders:%ld Sensors:%ld Cut:%g", - prefix.c_str(), detector.path().c_str(), - sides.size(), supports.size(), modules.size(), ladders.size(), sensors.size(), - sensitiveVolumeCut); this->DeVPGenericStaticObject::print(indent,flg); + printout(INFO, "DeVPStatic", + "%s >> Sides:%ld Supports:%ld Modules:%ld Ladders:%ld Sensors:%ld Cut:%g", + prefix.c_str(), sides.size(), supports.size(), modules.size(), + ladders.size(), sensors.size(), sensitiveVolumeCut); std::for_each(sensors.begin(), sensors.end(), [indent,flg](const DeVPSensorStatic& s) { s.print(indent+1,flg); }); } @@ -38,19 +37,14 @@ void DeVPStaticObject::initialize() { sensitiveVolumeCut = param<double>("sensitiveVolumeCut"); } -/// Printout method to stdout -void gaudi::DeVPStatic::print(int indent, int flg) const { - access()->print(indent, flg); -} - /// Printout method to stdout void DeVPObject::print(int indent, int flg) const { std::string prefix = DE::indent(indent); + this->DeVPGenericObject::print(indent,flg); printout(INFO, "DeVP", - "%s*+++++ VP detector element for %s Sides:%ld Supports:%ld Modules:%ld Ladders:%ld Sensors:%ld", + "%s >> Sides:%ld Supports:%ld Modules:%ld Ladders:%ld Sensors:%ld", prefix.c_str(), detector.path().c_str(), sides.size(), supports.size(), modules.size(), ladders.size(), sensors.size()); - this->DeVPGenericObject::print(indent,flg); std::for_each(sensors.begin(), sensors.end(), [indent,flg](const DeVPSensor& s) { if ( s.isValid() ) s.print(indent+1,flg); }); } @@ -60,20 +54,3 @@ void DeVPObject::initialize() { this->DeVPGenericObject::initialize(); vp_static = de_static; } - - -/// Printout method to stdout -void gaudi::DeVP::print(int indent, int flg) const { - access()->print(indent,flg); -} - -#if 0 -static void test() { - using namespace gaudi; - DeVP devp; - DetectorElement<DeVP> detElem(devp); - std::cout << "TEST: Got detector element:" << detElem.detector().path() - << detElem.detectorAlignment().name() - << std::endl; -} -#endif diff --git a/DDDB/src/Detector/DeVPConditionCalls.cpp b/DDDB/src/Detector/DeVPConditionCalls.cpp index b05d112a604a25dd1c988840bb7ac907dfc438a2..76722b6f2a1e626593dd49e16cd36887b167118b 100644 --- a/DDDB/src/Detector/DeVPConditionCalls.cpp +++ b/DDDB/src/Detector/DeVPConditionCalls.cpp @@ -22,15 +22,15 @@ using namespace gaudi; /// Interface to client Callback in order to update the condition dd4hep::Condition DeVPStaticConditionCall::operator()(const ConditionKey& key, const Context& context) { - VeloUpdateContext* ctxt = dynamic_cast<VeloUpdateContext*>(context.parameter); + VPUpdateContext* ctxt = dynamic_cast<VPUpdateContext*>(context.parameter); KeyMaker km(key.hash); auto ide = ctxt->detectors.find(km.values.det_key); auto* cat = (*ide).second.second; DetElement det = (*ide).second.first; DeStatic s; - if ( cat->classID == 1008205 ) // DeVPSensor + if ( cat->classID == DeVPSensor::classID() ) // DeVPSensor s = DeStatic(new detail::DeVPSensorStaticObject()); - else if ( cat->classID == 8200 ) // DeVP Velo main element + else if ( cat->classID == DeVP::classID() ) // DeVP Velo main element s = DeStatic(new detail::DeVPStaticObject()); else // All other in the hierarchy s = DeStatic(new detail::DeVPGenericStaticObject()); @@ -40,14 +40,14 @@ dd4hep::Condition DeVPStaticConditionCall::operator()(const ConditionKey& key, c /// Interface to client callback for resolving references or to use data from other conditions void DeVPStaticConditionCall::resolve(Condition c, Resolver& resolver) { DeStatic s(c); - if ( s->classID == 8200 ) { // Velo main element + if ( s->clsID == DeVP::classID() ) { // Velo main element DeVPStatic vp = s; DeVPSensorStatic sens; DeVPGenericStatic side, support, module, ladder; std::vector<std::pair<DetElement, int> > elts; dd4hep::DetectorScanner(dd4hep::detElementsCollector(elts), s->detector); - vp->vp_flags |= DeVPGenericStatic::MAIN; + vp->de_user |= VP::MAIN; vp->sensors.resize(200); for ( const auto& i : elts ) { DetElement de = i.first; @@ -61,28 +61,28 @@ void DeVPStaticConditionCall::resolve(Condition c, Resolver& resolver) { case 1: side = cond; side->parent = vp.access(); - side->vp_flags |= DeVPGeneric::SIDE; + side->de_user |= VP::SIDE; vp->sides.push_back(side); printout(INFO,"DeVPStatic","Add Side[%03ld]: %s",vp->sides.size()-1,path.c_str()); break; case 2: support = cond; support->parent = side.access(); - support->vp_flags |= DeVPGeneric::SUPPORT; + support->de_user |= VP::SUPPORT; vp->supports.push_back(support); printout(INFO,"DeVPStatic","Add Support[%03ld]: %s",vp->supports.size()-1,path.c_str()); break; case 3: module = cond; module->parent = support.access(); - module->vp_flags |= DeVPGeneric::MODULE; + module->de_user |= VP::MODULE; vp->modules.push_back(module); printout(INFO,"DeVPStatic","Add Module[%03ld]: %s",vp->modules.size()-1,path.c_str()); break; case 4: ladder = cond; ladder->parent = module.access(); - ladder->vp_flags |= DeVPGeneric::LADDER; + ladder->de_user |= VP::LADDER; vp->ladders.push_back(ladder); printout(INFO,"DeVPStatic","Add Ladder[%03ld]: %s",vp->ladders.size()-1,path.c_str()); break; @@ -112,10 +112,10 @@ void DeVPStaticConditionCall::resolve(Condition c, Resolver& resolver) { /// Interface to client Callback in order to update the condition dd4hep::Condition DeVPIOVConditionCall::operator()(const ConditionKey&, const Context&) { - DeIOV iov((catalog->classID == 1008205) ? new detail::DeVPSensorObject() : new detail::DeIOVObject()); - if ( catalog->classID == 1008205 ) // DeVPSensor + DeIOV iov; + if ( catalog->classID == DeVPSensor::classID() ) // DeVPSensor iov = DeIOV(new detail::DeVPSensorObject()); - else if ( catalog->classID == 8200 ) // DeVP Velo main element + else if ( catalog->classID == DeVP::classID() ) // DeVP Velo main element iov = DeIOV(new detail::DeVPObject()); else // All other in the hierarchy iov = DeIOV(new detail::DeVPGenericObject()); diff --git a/DDDB/src/Detector/DeVPGeneric.cpp b/DDDB/src/Detector/DeVPGeneric.cpp index a856f7359af1ff24cb72042697eb2f528f344070..2273167e964133e4d96a7ffa53fdd5fa8cbbfee4 100644 --- a/DDDB/src/Detector/DeVPGeneric.cpp +++ b/DDDB/src/Detector/DeVPGeneric.cpp @@ -26,14 +26,19 @@ void DeVPGenericStaticObject::initialize() { /// Printout method to stdout void DeVPGenericStaticObject::print(int indent, int flg) const { + std::string prefix = DE::indent(indent); + DeStaticObject::print(indent, flg); if ( flg & DePrint::SPECIFIC ) { - printout(INFO,"DeVPGenStatic", "%s*========== %ld Sensors %s", - DE::indent(indent).c_str(), sensors.size(), detector.path().c_str()); + printout(INFO,"DeVPGenStatic", "%s+ >> %ld Sensor(s)", prefix.c_str(), sensors.size()); + } + for(size_t i=0; i<sensors.size(); ++i) { + if ( sensors[i].isValid() ) { + printout(INFO,"DeVeloGenStatic", "%s+ >> [%ld] %s", + prefix.c_str(), i, sensors[i]->detector.path().c_str()); + } } - DeStaticObject::print(indent, flg); } - /// Initialization of sub-classes void DeVPGenericObject::initialize() { this->DeIOVObject::initialize(); @@ -41,9 +46,15 @@ void DeVPGenericObject::initialize() { /// Printout method to stdout void DeVPGenericObject::print(int indent, int flg) const { + std::string prefix = DE::indent(indent); + DeIOVObject::print(indent, flg); if ( flg & DePrint::SPECIFIC ) { - printout(INFO,"DeVPGen", "%s*========== %ld Sensors %s", - DE::indent(indent).c_str(), sensors.size(), detector.path().c_str()); + printout(INFO,"DeVPGen", "%s+ >> %ld Sensor(s)", prefix.c_str(), sensors.size()); + } + for(size_t i=0; i<sensors.size(); ++i) { + if ( sensors[i].isValid() ) { + printout(INFO,"DeVeloGenStatic", "%s+ >> [%ld] %s", + prefix.c_str(), i, sensors[i]->detector.path().c_str()); + } } - DeIOVObject::print(indent, flg); } diff --git a/DDDB/src/Detector/DeVPSensor.cpp b/DDDB/src/Detector/DeVPSensor.cpp index 9c819c02fdc010e3a3dae3b60ce3b223e28a9b81..69f3ab163fd652eebf8666477a2362e0a920dafd 100644 --- a/DDDB/src/Detector/DeVPSensor.cpp +++ b/DDDB/src/Detector/DeVPSensor.cpp @@ -19,32 +19,30 @@ #include "DD4hep/Printout.h" namespace gaudi { - const DeVPSensor::itemkey_type DeVPSensor::key_info = dd4hep::ConditionKey::itemCode("StripInfo"); - const DeVPSensor::itemkey_type DeVPSensor::key_noise = dd4hep::ConditionKey::itemCode("StripNoise"); - const DeVPSensor::itemkey_type DeVPSensor::key_readout = dd4hep::ConditionKey::itemCode("StripReadout"); + const DeVPSensorElement::itemkey_type DeVPSensorElement::key_info = dd4hep::ConditionKey::itemCode("StripInfo"); + const DeVPSensorElement::itemkey_type DeVPSensorElement::key_noise = dd4hep::ConditionKey::itemCode("StripNoise"); + const DeVPSensorElement::itemkey_type DeVPSensorElement::key_readout = dd4hep::ConditionKey::itemCode("StripReadout"); } /// Printout method to stdout void gaudi::detail::DeVPSensorStaticObject::print(int indent, int flg) const { + this->DeStaticObject::print(indent, flg); if ( flg & DePrint::SPECIFIC ) { - printout(INFO,"DeVPSensorStatic", "%s*==========%s", - DE::indent(indent).c_str(), detector.path().c_str()); printout(INFO,"DeVPSensorStatic", - "%s%s >> Module:%d Sensor:%d %s %d Chips Rows:%d Cols:%d", - DE::indent(indent).c_str(),"+ ", - module, sensorNumber, isLeft ? "Left" : "Right", nChips, nCols, nRows); + "%s+ >> Module:%d Sensor:%d %s %d Chips Rows:%d Cols:%d", + DE::indent(indent).c_str(), + module, sensorNumber, (de_user&VP::LEFT) ? "Left" : "Right", nChips, nCols, nRows); } if ( flg & DePrint::DETAIL ) { printout(INFO,"DeVPSensorStatic", - "%s%s >> Thickness:%g ChipSize:%g Dist:%g Pix-Size:%g Dist:%g", - DE::indent(indent).c_str(),"+ ", + "%s+ >> Thickness:%g ChipSize:%g Dist:%g Pix-Size:%g Dist:%g", + DE::indent(indent).c_str(), thickness, chipSize, interChipDist, pixelSize, interChipPixelSize); printout(INFO,"DeVPSensorStatic", - "%s%s >> SizeX: %g SizeY: %g local:%ld pitch:%ld", - DE::indent(indent).c_str(), "+ ", sizeX, sizeY, local_x.size(), x_pitch.size()); + "%s+ >> SizeX: %g SizeY: %g local:%ld pitch:%ld", + DE::indent(indent).c_str(), sizeX, sizeY, local_x.size(), x_pitch.size()); } - this->DeStaticObject::print(indent, flg); } /// Initialization of sub-classes @@ -53,7 +51,7 @@ void gaudi::detail::DeVPSensorStaticObject::initialize() { sensorNumber = param<int>("SensorNumber"); module = param<int>("Module"); - isLeft = side.find("Left") == 0; + side.find("Left") == 0 ? de_user |= VP::LEFT : de_user &= ~VP::LEFT; thickness = param<double>("Thickness"); nChips = param<int>("NChips"); @@ -98,20 +96,14 @@ void gaudi::detail::DeVPSensorStaticObject::initialize() { } } -/// Printout method to stdout -void gaudi::DeVPSensorStatic::print(int indent, int flg) const { - access()->print(indent,flg); -} - - /// Printout method to stdout void gaudi::detail::DeVPSensorObject::print(int indent, int flg) const { - printout(INFO,"DeVPSensor", "%s+ Info: %s Noise:%s Readout:%s", + DeIOVObject::print(indent, flg); + printout(INFO,"DeVPSensor", "%s+ >> Info: %s Noise:%s Readout:%s", DE::indent(indent).c_str(), yes_no(info.isValid()), yes_no(noise.isValid()), yes_no(readout.isValid())); - DeIOVObject::print(indent, flg); } /// Initialization of sub-classes @@ -119,6 +111,7 @@ void gaudi::detail::DeVPSensorObject::initialize() { DeIOVObject::initialize(); sensor_static = de_static; + de_user = de_static->de_user; // We require a valid alignment object for sensors! checkAlignment(); for(const auto& c : conditions) { @@ -137,8 +130,3 @@ void gaudi::detail::DeVPSensorObject::initialize() { // except(DeVPSensor", "Invalid IOV dependent sensor readout!"); } } - -/// Printout method to stdout -void gaudi::DeVPSensor::print(int indent, int flg) const { - access()->print(indent, flg); -} diff --git a/DDDB/src/Detector/DeVelo.cpp b/DDDB/src/Detector/DeVelo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0ae8379dd5150c961996eb78b9f7d7b1571bd65a --- /dev/null +++ b/DDDB/src/Detector/DeVelo.cpp @@ -0,0 +1,92 @@ +//============================================================================== +// AIDA Detector description implementation for LHCb +//------------------------------------------------------------------------------ +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// \author Markus Frank +// \date 2018-03-08 +// \version 1.0 +// +//============================================================================== + +// Framework include files +#include "Detector/DeVelo.h" +#include "DD4hep/Printout.h" + +using namespace gaudi::detail; + +/// Printout method to stdout +void DeVeloStaticObject::print(int indent, int flg) const { + std::string prefix = DE::indent(indent); + this->DeStaticObject::print(indent,flg); + printout(INFO, "DeVeloStatic", + "%s+ Sides: %ld Modules:%ld Supports: %ld Sensors: %ld Cut:%g", + prefix.c_str(), sides.size(), modules.size(), supports.size(), + sensors[DeVeloFlags::ALL].size(), sensitiveVolumeCut); + printout(INFO, "DeVeloStatic", + "%s+ Sensors: R:%ld (L:%ld R:%ld) Phi:%ld (L:%ld R:%ld) rPhi:%ld (L:%ld R:%ld) PU:%ld (L:%ld R:%ld)", + prefix.c_str(), + sensors[DeVeloFlags::ALL].size(), + rSensors[DeVeloFlags::ALL].size(), + rSensors[DeVeloFlags::LEFT].size(), + rSensors[DeVeloFlags::RIGHT].size(), + phiSensors[DeVeloFlags::ALL].size(), + phiSensors[DeVeloFlags::LEFT].size(), + phiSensors[DeVeloFlags::RIGHT].size(), + rphiSensors[DeVeloFlags::ALL].size(), + rphiSensors[DeVeloFlags::LEFT].size(), + rphiSensors[DeVeloFlags::RIGHT].size(), + puSensors[DeVeloFlags::ALL].size(), + puSensors[DeVeloFlags::LEFT].size(), + puSensors[DeVeloFlags::RIGHT].size() + ); + if ( flg&DePrint::CHILDREN ) { + std::for_each(sides.begin(), sides.end(), + [indent,flg](const DeVeloGenericStatic& s) { if (s.isValid()) s.print(indent+1,flg); }); + } +} + +/// Initialization of sub-classes +void DeVeloStaticObject::initialize() { + this->DeStaticObject::initialize(); + sensitiveVolumeCut = param<double>("sensitiveVolumeCut"); +} + +/// Printout method to stdout +void DeVeloObject::print(int indent, int flg) const { + std::string prefix = DE::indent(indent); + this->DeIOVObject::print(indent,flg&~DePrint::CHILDREN); + printout(INFO, "DeVelo", + "%s+ Sides: %ld Modules:%ld Supports: %ld Sensors: %ld", + prefix.c_str(), sides.size(), modules.size(), supports.size(), + sensors[DeVeloFlags::ALL].size()); + printout(INFO, "DeVelo", + "%s+ Sensors: R:%ld (L:%ld R:%ld) Phi:%ld (L:%ld R:%ld) rPhi:%ld (L:%ld R:%ld) PU:%ld (L:%ld R:%ld)", + prefix.c_str(), + sensors[DeVeloFlags::ALL].size(), + rSensors[DeVeloFlags::ALL].size(), + rSensors[DeVeloFlags::LEFT].size(), + rSensors[DeVeloFlags::RIGHT].size(), + phiSensors[DeVeloFlags::ALL].size(), + phiSensors[DeVeloFlags::LEFT].size(), + phiSensors[DeVeloFlags::RIGHT].size(), + rphiSensors[DeVeloFlags::ALL].size(), + rphiSensors[DeVeloFlags::LEFT].size(), + rphiSensors[DeVeloFlags::RIGHT].size(), + puSensors[DeVeloFlags::ALL].size(), + puSensors[DeVeloFlags::LEFT].size(), + puSensors[DeVeloFlags::RIGHT].size() + ); + std::for_each(sides.begin(), sides.end(), + [indent,flg](const DeVeloGeneric& s) { if (s.isValid()) s.print(indent+1,flg); }); +} + +/// Initialization of sub-classes +void DeVeloObject::initialize() { + this->DeIOVObject::initialize(); + vp_static = de_static; +} diff --git a/DDDB/src/Detector/DeVeloConditionCalls.cpp b/DDDB/src/Detector/DeVeloConditionCalls.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8d1f18635e9ccd10394701e2d96f6645193c87a4 --- /dev/null +++ b/DDDB/src/Detector/DeVeloConditionCalls.cpp @@ -0,0 +1,222 @@ +//============================================================================== +// AIDA Detector description implementation for LHCb +//------------------------------------------------------------------------------ +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// \author Markus Frank +// \date 2018-03-08 +// \version 1.0 +// +//============================================================================== + +// Framework include files +#include "Detector/DeVeloConditionCalls.h" +#include "DD4hep/DetectorProcessor.h" +#include "DDDB/DDDBConversion.h" + +using namespace std; +using namespace gaudi; + +/// Interface to client Callback in order to update the condition +dd4hep::Condition DeVeloStaticConditionCall::operator()(const ConditionKey& key, const Context& context) { + VeloUpdateContext* ctxt = dynamic_cast<VeloUpdateContext*>(context.parameter); + KeyMaker km(key.hash); + auto ide = ctxt->detectors.find(km.values.det_key); + auto* cat = (*ide).second.second; + DetElement det = (*ide).second.first; + DeStatic s; + if ( cat->classID == DeVeloSensor::classID() || cat->classID == 1008102 || cat->classID == 1008103 ) // DeVeloSensor + s = DeStatic(new detail::DeVeloSensorStaticObject()); + else if ( cat->classID == DeVelo::classID() ) // DeVelo Velo main element + s = DeStatic(new detail::DeVeloStaticObject()); + else // All other in the hierarchy + s = DeStatic(new detail::DeVeloGenericStaticObject()); + return s->fill_info(det, cat); +} + +/// Interface to client callback for resolving references or to use data from other conditions +void DeVeloStaticConditionCall::resolve(Condition c, Resolver& resolver) { + DeStatic s(c); + if ( s->clsID == DeVelo::classID() ) { // Velo main element + DeVeloStatic vp = s; + DeVeloSensorStatic sens; + DeVeloGenericStatic side, module, support; + vector<pair<DetElement, int> > elts; + dd4hep::DetectorScanner(dd4hep::detElementsCollector(elts), s->detector); + + vp->de_user |= DeVeloFlags::MAIN; + vp->sides.resize(2); + + for ( const auto& i : elts ) { + DetElement de = i.first; + KeyMaker key(de.key(), Keys::staticKey); + DeStatic cond = resolver.get(key.hash); + const string& path = de.path(); + bool left = path.find("/VeloLeft/Module") != string::npos || path.find("/VeloLeft") == path.length()-9; + bool right = path.find("/VeloRight/Module") != string::npos || path.find("/VeloRight") == path.length()-10; + size_t sideNo = left ? DeVeloFlags::LEFT : right ? DeVeloFlags::RIGHT : 99999; + + printout(INFO,"DeVelo"," %03d DetElement: %s",i.second, de.path().c_str()); + if ( left || right ) { + switch( i.second ) { + case 0: // Self! + break; + case 1: + side = cond; + side->parent = vp.access(); + side->de_user |= DeVeloFlags::SIDE; + vp->sides[sideNo] = side; + printout(INFO,"DeVeloStatic","Add Side[%03ld]: %s",vp->sides.size()-1,path.c_str()); + break; + case 2: + module = cond; + module->parent = side.access(); + module->de_user |= DeVeloFlags::MODULE; + side->children.push_back(module.ptr()); + vp->modules.push_back(module); + printout(INFO,"DeVeloStatic","Add Module[%03ld]: %s",vp->modules.size()-1,path.c_str()); + break; + case 3: + support = cond; + support->parent = module.access(); + support->de_user |= DeVeloFlags::SUPPORT; + vp->supports.push_back(support); + module->children.push_back(support.ptr()); + printout(INFO,"DeVeloStatic","Add Support[%03ld]: %s",vp->supports.size()-1,path.c_str()); + break; + case 4: + sens = cond; + if ( !sens.isValid() ) { + except("DeVeloStatic","Problem: Unknown sensor type or invalid object encountered!"); + } + sens->parent = support.access(); + vp->sensors[DeVeloFlags::ALL].push_back(sens); + vp->sensors[sideNo].push_back(sens); + // ---- Contiguous array of sensors + vp->rSensors[sideNo].push_back(sens); + vp->phiSensors[sideNo].push_back(sens); + vp->puSensors[sideNo].push_back(sens); + vp->rphiSensors[sideNo].push_back(sens); + support->sensors.push_back(sens); + module->sensors.push_back(sens); + side->sensors.push_back(sens); + printout(INFO,"DeVeloStatic","Add Sensor[%03ld]: %s",long(sens->sensorNumber),path.c_str()); + break; + default: + break; + } + } + else { + printout(INFO,"DeVeloStatic","Aux.DetElmenet: %s",path.c_str()); + } + } + } + s->initialize(); +} + +/// Interface to client Callback in order to update the condition +dd4hep::Condition DeVeloIOVConditionCall::operator()(const ConditionKey&, const Context&) { + DeIOV iov; + if ( catalog->classID == DeVeloSensor::classID() || catalog->classID == 1008102 || catalog->classID == 1008103 ) // DeVeloSensor + iov = DeIOV(new detail::DeVeloSensorObject()); + else if ( catalog->classID == DeVelo::classID() ) // DeVelo Velo main element + iov = DeIOV(new detail::DeVeloObject()); + else // All other in the hierarchy + iov = DeIOV(new detail::DeVeloGenericObject()); + return iov->fill_info(detector, catalog); +} + +/// Interface to client callback for resolving references or to use data from other conditions +void DeVeloIOVConditionCall::resolve(Condition cond, Resolver& resolver) { + DeIOV iov(cond); + Condition::detkey_type det_key = iov->detector.key(); + KeyMaker kalign(det_key,dd4hep::align::Keys::alignmentKey); + KeyMaker kstatic(det_key,Keys::staticKey); + + /// Check that the alignments are computed. We need them here! + if ( !context->alignments_done.isValid() ) { + context->alignments_done = resolver.get(Keys::alignmentsComputedKey); + } + + vector<Condition> conds = resolver.get(det_key); + iov->de_static = resolver.get(kstatic.hash); + iov->detectorAlignment = resolver.get(kalign.hash); + for ( Condition c : conds ) + iov->conditions.insert(make_pair(c.item_key(),c)); + iov->initialize(); +} + +namespace { + /// Resolve generic parent-sensor dependencies + void add_sensors( vector<DeVeloSensor>& cont, + const vector<DeVeloSensorStatic>& src, + map<DeVeloSensorStatic,DeVeloSensor>& mapping) { + cont.reserve(src.size()); + for (DeVeloSensorStatic i : src) + cont.push_back(mapping[i]); + } + + /// Resolve generic parent-sensor dependencies + void add_sensors( DeVeloGeneric gen, + DeVeloGenericStatic src, + map<DeVeloSensorStatic,DeVeloSensor>& mapping, + dd4hep::cond::ConditionResolver& resolver) + { + gen->sensors.reserve(src->sensors.size()); + for (DeVeloSensorStatic i : src->sensors) { + DeVeloSensor sens = mapping[i]; + if ( !sens.isValid() ) { + cout << "Problem" << endl; + } + gen->sensors.push_back(sens); + } + for (detail::DeVeloGenericStaticObject* i : src->children) { + dd4hep::ConditionKey::KeyMaker key(i->detector.key(), Keys::deKey); + DeVeloGeneric child = resolver.get(key.hash); + gen->children.push_back(child.ptr()); + add_sensors(child, DeVeloGenericStatic(i), mapping, resolver); + } + } +} + +/// Interface to client callback for resolving references or to use data from other conditions +void DeVeloConditionCall::resolve(Condition cond, Resolver& resolver) { + DeIOV iov(cond); + DeVelo vp(cond); + DeVeloIOVConditionCall::resolve(cond, resolver); + DeVeloStatic s = vp.access()->vp_static; + map<DeVeloSensorStatic,DeVeloSensor> sensorMapping; + + sensorMapping[DeVeloSensorStatic()] = DeVeloSensor(); + for ( const auto& i : s->sensors[DeVeloFlags::ALL] ) { + if ( i.isValid() ) { + KeyMaker key(i->detector.key(), Keys::deKey); + DeVeloSensor sens = resolver.get(key.hash); + if ( !sens.isValid() ) { + cout << "Problem Mapping " << (void*)i.ptr() + << " ---> " << (void*)sens.ptr() << " " << i->detector.path() + << endl; + } + sensorMapping[i] = sens; + continue; + } + } + + for(size_t iside = 0; iside<3; ++iside) { + add_sensors(vp->sensors[iside], s->sensors[iside], sensorMapping); + add_sensors(vp->rSensors[iside], s->rSensors[iside], sensorMapping); + add_sensors(vp->phiSensors[iside], s->phiSensors[iside], sensorMapping); + add_sensors(vp->rphiSensors[iside], s->rphiSensors[iside], sensorMapping); + add_sensors(vp->puSensors[iside], s->puSensors[iside], sensorMapping); + } + for ( auto side : s->sides ) { + dd4hep::ConditionKey::KeyMaker key(side->detector.key(), Keys::deKey); + DeVeloGeneric child = resolver.get(key.hash); + vp->sides.push_back(child); + add_sensors(child, side, sensorMapping, resolver); + } +} diff --git a/DDDB/src/Detector/DeVeloGeneric.cpp b/DDDB/src/Detector/DeVeloGeneric.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d668dd1675a307a460a16725294f46c2dd81319f --- /dev/null +++ b/DDDB/src/Detector/DeVeloGeneric.cpp @@ -0,0 +1,66 @@ +//============================================================================== +// AIDA Detector description implementation for LHCb +//------------------------------------------------------------------------------ +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// \author Markus Frank +// \date 2018-03-08 +// \version 1.0 +// +//============================================================================== + +// Framework include files +#include "Detector/DeVelo.h" +#include "DD4hep/Printout.h" + +using namespace gaudi::detail; + +/// Initialization of sub-classes +void DeVeloGenericStaticObject::initialize() { + this->DeStaticObject::initialize(); +} + +/// Printout method to stdout +void DeVeloGenericStaticObject::print(int indent, int flg) const { + std::string prefix = DE::indent(indent); + DeStaticObject::print(indent, flg&~DePrint::CHILDREN); + if ( flg & DePrint::SPECIFIC ) { + printout(INFO,"DeVeloGen", "%s+ >> %ld child(ren) %ld Sensor(s)", + prefix.c_str(), children.size(), sensors.size()); + } + if ( flg&DePrint::CHILDREN ) { + for(size_t i=0, e=children.size(); e==0 && i<sensors.size(); ++i) + sensors[i]->print(indent+1, flg); + for(size_t i=0, e=children.size(); e>0 && i<sensors.size(); ++i) { + printout(INFO,"DeVeloGen", "%s+ >> Sensor[%ld] %s", + prefix.c_str(),i,sensors[i]->detector.path().c_str()); + } + for(auto c : children) c->print(indent+1,flg); + } +} + +/// Initialization of sub-classes +void DeVeloGenericObject::initialize() { + this->DeIOVObject::initialize(); +} + +/// Printout method to stdout +void DeVeloGenericObject::print(int indent, int flg) const { + std::string prefix = DE::indent(indent); + DeIOVObject::print(indent, flg&~DePrint::CHILDREN); + if ( flg & DePrint::SPECIFIC ) { + printout(INFO,"DeIOVVeloGen", "%s+ >> %ld child(ren) %ld Sensor(s)", + prefix.c_str(), children.size(), sensors.size()); + } + for(size_t i=0, e=children.size(); e==0 && i<sensors.size(); ++i) + sensors[i]->print(indent+1, flg); + for(size_t i=0, e=children.size(); e>0 && i<sensors.size(); ++i) { + printout(INFO,"DeIOVVeloGen", "%s+ >> [%ld] %s", + prefix.c_str(), i, sensors[i]->detector.path().c_str()); + } + for(auto c : children) c->print(indent+1,flg); +} diff --git a/DDDB/src/Detector/DeVeloHandles.cpp b/DDDB/src/Detector/DeVeloHandles.cpp new file mode 100644 index 0000000000000000000000000000000000000000..82b2386de3b22e7984d6eb16db69375103c81039 --- /dev/null +++ b/DDDB/src/Detector/DeVeloHandles.cpp @@ -0,0 +1,31 @@ +//============================================================================== +// AIDA Detector description implementation for LHCb +//------------------------------------------------------------------------------ +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// \author Markus Frank +// \date 2018-03-08 +// \version 1.0 +// +//============================================================================== + +// A bit of magic + +// Framework include files +#include "Detector/DeVelo.h" +#include "DD4hep/detail/Handle.inl" + +// This is some magic you do not really want to know about.... +using namespace gaudi::detail; + +DD4HEP_INSTANTIATE_HANDLE_UNNAMED(DeVeloSensorStaticObject,DeStaticObject,ConditionObject); +DD4HEP_INSTANTIATE_HANDLE_UNNAMED(DeVeloGenericStaticObject,DeStaticObject,ConditionObject); +DD4HEP_INSTANTIATE_HANDLE_UNNAMED(DeVeloStaticObject,DeVeloGenericStaticObject,DeStaticObject,ConditionObject); + +DD4HEP_INSTANTIATE_HANDLE_UNNAMED(DeVeloSensorObject,DeIOVObject,ConditionObject); +DD4HEP_INSTANTIATE_HANDLE_UNNAMED(DeVeloGenericObject,DeIOVObject,ConditionObject); +DD4HEP_INSTANTIATE_HANDLE_UNNAMED(DeVeloObject,DeVeloGenericObject,DeIOVObject,ConditionObject); diff --git a/DDDB/src/Detector/DeVeloSensor.cpp b/DDDB/src/Detector/DeVeloSensor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b1b2e373296c06cfe34839829422daa36a411a93 --- /dev/null +++ b/DDDB/src/Detector/DeVeloSensor.cpp @@ -0,0 +1,154 @@ +//============================================================================== +// AIDA Detector description implementation for LHCb +//------------------------------------------------------------------------------ +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// \author Markus Frank +// \date 2018-03-08 +// \version 1.0 +// +//============================================================================== + +// Framework include files +#include "Detector/DeVeloSensor.h" +#include "DD4hep/ConditionsData.h" +#include "DD4hep/Primitives.h" +#include "DD4hep/Printout.h" + +namespace gaudi { + const DeVeloSensorElement::itemkey_type DeVeloSensorElement::key_info = dd4hep::ConditionKey::itemCode("StripInfo"); + const DeVeloSensorElement::itemkey_type DeVeloSensorElement::key_noise = dd4hep::ConditionKey::itemCode("StripNoise"); + const DeVeloSensorElement::itemkey_type DeVeloSensorElement::key_readout = dd4hep::ConditionKey::itemCode("StripReadout"); +} + +/// Printout method to stdout +void gaudi::detail::DeVeloSensorStaticObject::print(int indent, int flg) const { + this->DeStaticObject::print(indent, flg); + if ( flg & DePrint::SPECIFIC ) { + printout(INFO,"DeVeloSensor", "%s+ >> %s:%d [%s] Class:%d Sens:%d Side:%c %s R:%s Phi:%s Veto:%s Thick:%g Rmin:%g Rmax:%g", + DE::indent(indent).c_str(), + moduleName.c_str(), moduleId, fullType.c_str(), clsID, sensorNumber, + (de_user&DeVeloFlags::LEFT) == 0 ? 'R' : 'L', + (de_user&DeVeloFlags::DOWNSTREAM) == 0 ? "UpStrm" : "DnStrm", + yes_no((de_user&DeVeloFlags::R_TYPE) != 0), + yes_no((de_user&DeVeloFlags::PHI_TYPE) != 0), + yes_no((de_user&DeVeloFlags::PU_TYPE) != 0), + siliconThickness, innerRadius, outerRadius); + } +} + +/// Initialization of sub-classes +void gaudi::detail::DeVeloSensorStaticObject::initialize() { + de_user |= DeVeloFlags::READOUT; + moduleName = param<std::string>("Module"); + typeName = param<std::string>("Type"); + sensorNumber = param<int>("SensorNumber"); + siliconThickness = param<double>("SiThick"); + innerRadius = param<double>("InnerRadius"); + outerRadius = param<double>("OuterRadius"); + + if ( typeName.find("R") == 0 ) de_user |= DeVeloFlags::R_TYPE; + if ( typeName.find("Phi") == 0 ) de_user |= DeVeloFlags::PHI_TYPE; + if ( typeName.find("Veto") == 0 ) de_user |= DeVeloFlags::PU_TYPE; + if ( typeName == "R" || typeName == "Phi" || typeName == "Veto" ) { + if ( 0 != param<int>("Left") ) de_user |= DeVeloFlags::LEFT; + if ( 0 != param<int>("Downstream") ) de_user |= DeVeloFlags::DOWNSTREAM; + fullType = typeName + + ( (de_user&DeVeloFlags::DOWNSTREAM) ? "DnStrm" : "UpStrm" ) + + ( (de_user&DeVeloFlags::LEFT) ? "Left" : "Right"); + } else { + if ( (typeName == "PhiDL" || typeName == "PhiUL" || + typeName == "RLeft" || typeName == "VetoL") ) de_user |= DeVeloFlags::LEFT; + if (typeName == "PhiDL" || typeName == "PhiDR") de_user |= DeVeloFlags::DOWNSTREAM; + fullType = typeName; + } + // test new parameters .... + if ( de_user&DeVeloFlags::R_TYPE ) { + (0 != param<int>("DownstreamR")) ? de_user|=DeVeloFlags::DOWNSTREAM : de_user &= ~DeVeloFlags::DOWNSTREAM; + } else if ( de_user&DeVeloFlags::PHI_TYPE ) { + (0 != param<int>("DownstreamPhi")) ? de_user|=DeVeloFlags::DOWNSTREAM : de_user &= ~DeVeloFlags::DOWNSTREAM; + } +} + +/// Printout method to stdout +void gaudi::detail::DeVeloSensorObject::print(int indent, int flg) const { + DeIOVObject::print(indent, flg); + printout(INFO,"DeIOVVeloSensor", "%s+ Z:%g Info(%s): %s [%ld entries] Noise(%s): %s [%ld entries] " + "Readout(%s): %s [READOUT:%s Tell1-no-Sensor:%s]", + DE::indent(indent).c_str(), + z, + + info.isValid() ? info.name() : "--", + yes_no(info.isValid()), + stripInfos.size(), + + noise.isValid() ? noise.name() : "--", + yes_no(noise.isValid()), + stripNoise.size(), + + readout.isValid() ? readout.name() : "--", + yes_no(readout.isValid()), + yes_no((de_user&DeVeloFlags::READOUT)!=0), + yes_no((de_user&DeVeloFlags::T1NOSENS)!=0)); +} + +/// Initialization of sub-classes +void gaudi::detail::DeVeloSensorObject::initialize() { + DeIOVObject::initialize(); + + sensor_static = de_static; + // We require a valid alignment object for sensors! + checkAlignment(); + z = DetectorElement<DeVeloSensor>(this).toGlobal(XYZPoint(0,0,0)).z(); + for(const auto& c : conditions) { + if ( c.first == DeVeloSensor::key_info ) info = c.second; + else if ( c.first == DeVeloSensor::key_noise ) noise = c.second; + else if ( c.first == DeVeloSensor::key_readout ) readout = c.second; + } + + // Check here if values must be valid ? + if ( !info.isValid() ) { + except("DeIOVVeloSensor", "Invalid IOV dependent sensor info!"); + } + else { + const dd4hep::cond::AbstractMap& m = info.get<dd4hep::cond::AbstractMap>(); + stripInfos = m.get<std::vector<int> >("StripInfo"); +#if 0 + if(m_verbose){ + msg() << MSG::VERBOSE << "Sensor " << m_sensorNumber << " has stripInfoConditions "<< endmsg; + for( int row = 0 ; row < 64 ; ++row ){ //table of 64 rows * 32 columns of statuses + msg() << MSG::VERBOSE << format("%4i-%4i",(32*row),(32*row+31)); + for( int col = 0 ; col < 32 ; ++col ){ + msg() << MSG::VERBOSE << format("%2i ",m_stripInfos[32*row+col].asInt()); + } + msg() << MSG::VERBOSE << endmsg; + } + } +#endif + if (stripInfos.size() != DeVeloSensorStaticObject::numberOfStrips) { + except("DeIOVVeloSensor","Strip info condition size does not match number of strips!"); + } + } + if ( !noise.isValid() ) { + except("DeIOVVeloSensor", "Invalid IOV dependent sensor noise!"); + } + else { + const dd4hep::cond::AbstractMap& m = noise.get<dd4hep::cond::AbstractMap>(); + stripNoise = m.get<std::vector<double> >("StripNoise"); + if ( stripNoise.size() != DeVeloSensorStaticObject::numberOfStrips ) { + except("IOVDeVeloSensor","Strip noise condition size does not match number of strips!"); + } + } + if ( !readout.isValid() ) { + // except(DeIOVVeloSensor", "Invalid IOV dependent sensor readout!"); + } + else { + const dd4hep::cond::AbstractMap& m = noise.get<dd4hep::cond::AbstractMap>(); + (0 != m.get<int>("ReadoutFlag")) ? de_user |= DeVeloFlags::READOUT : de_user &= ~DeVeloFlags::READOUT; + (0 != m.get<int>("Tell1WithoutSensor")) ? de_user |= DeVeloFlags::T1NOSENS : de_user &= ~DeVeloFlags::T1NOSENS; + } +} diff --git a/DDDB/src/plugins/DeVeloTest.cpp b/DDDB/src/plugins/DeVeloTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..96e9e54ed2f1d60d7b9ccc095b0a0317a564dfed --- /dev/null +++ b/DDDB/src/plugins/DeVeloTest.cpp @@ -0,0 +1,191 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== +// +// DDDB is a detector description convention developed by the LHCb experiment. +// For further information concerning the DTD, please see: +// http://lhcb-comp.web.cern.ch/lhcb-comp/Frameworks/DetDesc/Documents/lhcbDtd.pdf +// +//========================================================================== + +// Framework includes +#include "DD4hep/Detector.h" +#include "DD4hep/Plugins.h" +#include "DD4hep/Printout.h" +#include "DD4hep/Factories.h" +#include "DD4hep/DetectorTools.h" +#include "DD4hep/ConditionsPrinter.h" +#include "DD4hep/DetectorProcessor.h" + +#include "DDCond/ConditionsManager.h" +#include "DDCond/ConditionsSlice.h" +#include "DDDB/DDDBConversion.h" + +// C/C++ include files +//#include <memory> + +#include "Detector/DeVelo.h" +#include "Detector/DeAlignmentCall.h" +#include "Detector/DeVeloConditionCalls.h" + +using namespace std; +using namespace gaudi; + + +/// Anonymous namespace for plugins +namespace { + dd4hep::PrintLevel s_PrintLevel = INFO; +} + +//========================================================================== +/// Anonymous namespace for plugins +namespace { + + /// Basic entry point to print out the detector element hierarchy + /** + * \author M.Frank + * \version 1.0 + * \date 01/04/2014 + */ + long dump_det(dd4hep::Detector& description, int argc, char** argv) { + + /// Callback object to print selective information + /** + * \author M.Frank + * \version 1.0 + * \date 01/04/2014 + */ + struct DumpActor { + dd4hep::Detector& m_detDesc; + dd4hep::DetElement m_de; + unique_ptr<VeloUpdateContext> m_context; + dd4hep::cond::ConditionsManager m_manager; + shared_ptr<dd4hep::cond::ConditionsContent> m_content; + const dd4hep::IOVType* m_iovtype = 0; + + /// Standard constructor + DumpActor(dd4hep::Detector& l, const string& path) : m_detDesc(l) { + shared_ptr<dd4hep::cond::ConditionsSlice> slice; + shared_ptr<dd4hep::cond::ConditionsContent> cont; + vector<pair<dd4hep::DetElement, int> > elts; + m_manager = dd4hep::cond::ConditionsManager::from(m_detDesc); + m_de = dd4hep::detail::tools::findElement(m_detDesc, path); + m_iovtype = m_manager.iovType("epoch"); + + dd4hep::IOV iov(m_iovtype, 0); + + cont.reset(new dd4hep::cond::ConditionsContent()); + slice.reset(new dd4hep::cond::ConditionsSlice(m_manager,cont)); + dd4hep::cond::fill_content(m_manager, *cont, *m_iovtype); + m_manager.prepare(iov, *slice); + + m_context.reset(new VeloUpdateContext()); + m_content.reset(new dd4hep::cond::ConditionsContent()); + dd4hep::DetectorScanner(dd4hep::detElementsCollector(elts), m_de); + dd4hep::cond::DependencyBuilder align_builder(m_detDesc.world(), + Keys::alignmentsComputedKey, + new DeAlignmentCall(m_de)); + auto* dep = align_builder.release(); + dep->target.hash = Keys::alignmentsComputedKey; + m_content->insertDependency(dep); + + std::unique_ptr<DeVeloStaticConditionCall> static_update(new DeVeloStaticConditionCall()); + for(const auto& e : elts) { + dd4hep::DetElement de = e.first; + dd4hep::DDDB::DDDBCatalog* cat = de.extension<dd4hep::DDDB::DDDBCatalog>(); + dd4hep::Condition::detkey_type det_key = de.key(); + dd4hep::ConditionKey::KeyMaker lower(det_key, 0); + dd4hep::ConditionKey::KeyMaker upper(det_key, ~0x0); + cout << "Processing " << e.second << " class " << cat->classID << " -> " << de.path() << endl; + m_context->detectors.insert(make_pair(det_key,make_pair(de,cat))); + { + auto first = cont->conditions().lower_bound(lower.hash); + for(; first != cont->conditions().end() && (*first).first <= upper.hash; ++first) + m_content->insertKey((*first).first); + } + { + auto first = cont->derived().lower_bound(lower.hash); + for(; first != cont->derived().end() && (*first).first <= upper.hash; ++first) + m_content->insertDependency((*first).second); + } + + dd4hep::cond::DependencyBuilder static_builder(de, Keys::staticKey, static_update->addRef()); + m_content->insertDependency(static_builder.release()); + + dd4hep::cond::ConditionUpdateCall* call = (e.first == m_de) + ? new DeVeloConditionCall(de, cat, m_context.get()) + : new DeVeloIOVConditionCall(de, cat, m_context.get()); + dd4hep::cond::DependencyBuilder iov_builder(de, Keys::deKey, call); + m_content->insertDependency(iov_builder.release()); + } + static_update.release()->release(); + } + + /// Standard destructor + ~DumpActor() { + } + + /// __________________________________________________________________________________ + long dump() { + shared_ptr<dd4hep::cond::ConditionsSlice> slice; + dd4hep::IOV iov(m_iovtype, 0); + + slice.reset(new dd4hep::cond::ConditionsSlice(m_manager, m_content)); + m_manager.prepare(iov, *slice, m_context.get()); + /* + dd4hep::cond::ConditionsPrinter printer(slice.get()); + printer.lineLength = 180; + dd4hep::DetectorScanner(printer, m_de); + */ + DeVelo devp = slice->get(m_de,Keys::deKey); + devp.print(0,DePrint::ALL); + + DetectorElement<DeVelo> detVP = devp; + cout << "TEST: Got detector element:" + << " " << detVP.conditions().size() + << " " << detVP.detector().path() + << " " << detVP.detectorAlignment().name() + << " " << detVP.conditions().size() + << endl; + try { + DeVeloGeneric deGEN = devp; + cout << " " << deGEN.conditions().size() + << " " << deGEN.children().size() + << endl; + } + catch(const exception& e) { + cout << "Exception(This is GOOD!): " << e.what() << endl; + } + return 1; + } + }; + + for(int i=0; i<argc; ++i) { + if ( ::strcmp(argv[i],"-print")==0 ) { + s_PrintLevel = dd4hep::printLevel(argv[++i]); + printout(INFO,"DDDB","Setting print level for %s to %s [%d]",__FILE__,argv[i-1],s_PrintLevel); + } + else if ( ::strcmp(argv[i],"--help")==0 ) { + printout(INFO,"Plugin-Help","Usage: DDDBDetectorDump --opt [--opt] "); + printout(INFO,"Plugin-Help"," -print <value> Printlevel for output "); + printout(INFO,"Plugin-Help"," -help Print this help message "); + return 0; + } + } + DumpActor actor(description, "/world/LHCb/BeforeMagnetRegion/Velo"); + return actor.dump(); + } +} /* End anonymous namespace */ + +using namespace dd4hep; +DECLARE_APPLY(DDDB_DeVeloTest,dump_det) +//========================================================================== diff --git a/DDDB/src/plugins/DetectorElementTest.cpp b/DDDB/src/plugins/DetectorElementTest.cpp deleted file mode 100644 index 8fa06570237171d6d69979900dc2b7462ef5f975..0000000000000000000000000000000000000000 --- a/DDDB/src/plugins/DetectorElementTest.cpp +++ /dev/null @@ -1,136 +0,0 @@ -//========================================================================== -// AIDA Detector description implementation -//-------------------------------------------------------------------------- -// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -// All rights reserved. -// -// For the licensing terms see $DD4hepINSTALL/LICENSE. -// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. -// -// Author : M.Frank -// -//========================================================================== -// -// DDDB is a detector description convention developed by the LHCb experiment. -// For further information concerning the DTD, please see: -// http://lhcb-comp.web.cern.ch/lhcb-comp/Frameworks/DetDesc/Documents/lhcbDtd.pdf -// -//========================================================================== - -// Framework includes -#include "DD4hep/Detector.h" -#include "DD4hep/Plugins.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Factories.h" -#include "DD4hep/ConditionsData.h" -#include "DD4hep/ConditionsPrinter.h" -#include "DD4hep/AlignmentsProcessor.h" -#include "DD4hep/ConditionsProcessor.h" -#include "DD4hep/detail/DetectorInterna.h" - -#include "DDCond/ConditionsOperators.h" -#include "DDCond/ConditionsManager.h" -#include "DDCond/ConditionsSlice.h" - -// C/C++ include files -#include <memory> - -using namespace std; -using namespace dd4hep; - -#include "Kernel/VPConstants.h" -#include "Detector/DeVP.h" - -/// Anonymous namespace for plugins -namespace { - PrintLevel s_PrintLevel = INFO; -} - -//========================================================================== -/// Anonymous namespace for plugins -namespace { - - using namespace dd4hep::cond; - - /// Basic entry point to print out the detector element hierarchy - /** - * \author M.Frank - * \version 1.0 - * \date 01/04/2014 - */ - long dump_det_tree(Detector& description, int argc, char** argv) { - - using DDDB::DDDBCatalog; - - /// Callback object to print selective information - /** - * \author M.Frank - * \version 1.0 - * \date 01/04/2014 - */ - struct DumpActor { - /// Container with all known conditions - vector<pair<int,Condition> > m_allConditions; - shared_ptr<ConditionsSlice> m_slice; - ConditionsManager m_manager; - string m_name; - Detector& m_detDesc; - - /// Standard constructor - DumpActor(Detector& l) - : m_detDesc(l) - { - m_manager = ConditionsManager::from(m_detDesc); - m_slice.reset(new ConditionsSlice(m_manager,shared_ptr<ConditionsContent>(new ConditionsContent()))); - } - - /// Standard destructor - ~DumpActor() { - } - - /// __________________________________________________________________________________ - void printDetElement(int , DetElement ) { - } - long dump(DetElement de, int level) { - char fmt[64], text[512]; - const DetElement::Children& c = de.children(); - ::snprintf(fmt,sizeof(fmt),"%%-%ds-> ",2*level+5); - ::snprintf(text,sizeof(text),fmt,""); - try { - printDetElement(level, de); - } - catch(const exception& e) { - ::sprintf(fmt,"%03d %%-%ds WARNING from: %%s %%-20s %%s",level+1,2*level+3); - printout(INFO, m_name, fmt, "", de.path().c_str(), "[NO CATALOG availible]",e.what()); - } - catch(...) { - ::sprintf(fmt,"%03d %%-%ds WARNING from: %%s %%-20s",level+1,2*level+3); - printout(INFO, m_name, fmt, "", de.path().c_str(), "[NO CATALOG availible]"); - } - for (const auto& i : c) - dump(i.second,level+1); - return 1; - } - }; - for(int i=0; i<argc; ++i) { - if ( ::strcmp(argv[i],"-print")==0 ) { - s_PrintLevel = dd4hep::printLevel(argv[++i]); - printout(INFO,"DDDB","Setting print level for %s to %s [%d]",__FILE__,argv[i-1],s_PrintLevel); - } - else if ( ::strcmp(argv[i],"--help")==0 ) { - printout(INFO,"Plugin-Help","Usage: DDDBDetectorDump --opt [--opt] "); - printout(INFO,"Plugin-Help"," -print <value> Printlevel for output "); - printout(INFO,"Plugin-Help"," -help Print this help message "); - return 0; - } - } - DumpActor actor(description); - return actor.dump(description.world(), 0); - } - - template <int flag> long dump_detelement_tree(Detector& description, int argc, char** argv) - { return dump_det_tree(description,argc,argv); } -} /* End anonymous namespace */ - -DECLARE_APPLY(DDDB_DeVeloTest,dump_detelement_tree<0>) -//==========================================================================