Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DeVelo detector element for DDDB #340

Merged
merged 1 commit into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions DDCond/include/DDCond/ConditionsContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
12 changes: 12 additions & 0 deletions DDCore/include/DD4hep/ConditionsData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
12 changes: 11 additions & 1 deletion DDCore/include/DD4hep/IOV.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */
134 changes: 45 additions & 89 deletions DDDB/include/Detector/DeIOV.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
/// Gaudi namespace declaration
namespace gaudi {

// Forward declarations
class DeIOV;

/// Gaudi::detail namespace declaration
namespace detail {

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
/**
Expand All @@ -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

Expand Down
57 changes: 34 additions & 23 deletions DDDB/include/Detector/DeStatic.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#ifndef DETECTOR_DESTATIC_H
#define DETECTOR_DESTATIC_H

/// Framework include files
#include "Detector/DetectorElement.h"

/// gaudi namespace declaration
namespace gaudi {

Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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
Loading