diff --git a/DDAlign/include/DDAlign/AlignmentsCalib.h b/DDAlign/include/DDAlign/AlignmentsCalib.h new file mode 100644 index 0000000000000000000000000000000000000000..9de039399bc4bb6e51ee7fe43ed6b86d5850b9c1 --- /dev/null +++ b/DDAlign/include/DDAlign/AlignmentsCalib.h @@ -0,0 +1,222 @@ +//========================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== +#ifndef DD4HEP_DDALIGN_ALIGNMENTCALIB_H +#define DD4HEP_DDALIGN_ALIGNMENTCALIB_H + +// Framework includes +#include "DD4hep/Detector.h" +#include "DD4hep/Conditions.h" +#include "DD4hep/Alignments.h" +#include "DD4hep/AlignmentData.h" + +#include "DDCond/ConditionsSlice.h" +#include "DDAlign/AlignmentsManager.h" + +// C/C++ include files +#include <set> +#include <map> + +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + + /// Namespace for the geometry part of the AIDA detector description toolkit + namespace Conditions { + // Forward declarations + class ConditionsSlice; + } + + /// Namespace for the geometry part of the AIDA detector description toolkit + namespace Alignments { + + // Forward declarations + class AlignmentsUpdateCall; + + /// Calib alignment dependencies from conditions + /** + * + * \author M.Frank + * \version 1.0 + * \date 31/01/2017 + * \ingroup DD4HEP_DDALIGN + */ + class AlignmentsCalib { + public: + /// Shortcut the ConditionsSlice type + typedef Conditions::Condition Condition; + typedef Conditions::ConditionKey ConditionKey; + typedef Conditions::ConditionsSlice Slice; + typedef Conditions::ConditionDependency Dependency; + typedef Conditions::ConditionsDescriptor Descriptor; + typedef Condition::key_type key_type; + typedef Slice::ConditionsProxy Proxy; + typedef Geometry::DetElement DetElement; + + /** + * \author M.Frank + * \version 1.0 + * \date 31/01/2017 + * \ingroup DD4HEP_DDALIGN + */ + struct Entry { + Delta delta; + Descriptor* source = 0; + Descriptor* target = 0; + int dirty = 0; + Entry() = default; + Entry(const Entry& c) = default; + Entry(Descriptor* s, Descriptor* d) : delta(), source(s), target(d), dirty(0) {} + Entry(Descriptor* s, Descriptor* d, const Delta& del) : delta(del), source(s), target(d), dirty(0) {} + Entry& operator=(const Entry& c) = default; + }; + typedef std::map<key_type,Entry*> UsedConditions; + + public: + LCDD& lcdd; + /// Reference to the alignment manager object + Slice& slice; + UsedConditions used; + AlignmentsUpdateCall* derivationCall = 0; + AlignmentsUpdateCall* propagationCall = 0; + + protected: + /// Propagate all Delta parameters to the source conditions + bool propagateDeltas(); + /// Update Dependencies between the source conditions and the computations + bool updateDependencies(); + /// Compute all dependent conditions from the Delta parameters + AlignmentsManager::Result computeDependencies(); + + /// Implementation: Add a new entry to the transaction list + key_type _insert(const std::pair<Condition::key_type,Entry*>& e); + /// Implementation: Register newly created condition to user-pool, slice and manager + Condition _register(Condition cond) const; + /// Implementation: Add a new raw(delta)-condition to the transaction stack. + Condition _create_source(key_type key, const std::string& nam) const; + /// Implementation: Add a new alignment-condition to the transaction stack. + Condition _create_target(DetElement detector, key_type key, const std::string& nam) const; + + /// Implementation: Add a new entry to the transaction stack. + key_type _use(AlignmentCondition alignment); + + public: + + /// No default constructor + AlignmentsCalib() = delete; + + /// No copy constructor + AlignmentsCalib(const AlignmentsCalib& copy) = delete; + + /// Initializing constructor + AlignmentsCalib(LCDD& lcdd, Slice& slice); + + /// Default destructor + virtual ~AlignmentsCalib(); + + /// No assignment operator + AlignmentsCalib& operator=(const AlignmentsCalib& copy) = delete; + + /// (1) Add a new entry to the transaction stack. + /** + * Note: + * The alignment must be a valid object bound to an alignment condition. + * Otherwise the call shal throw an exception. + * + * Note: + * Such alignments are only present if they are created through the usual + * loading mechanism. + * + * The resulting alignment key is returned to the client. If NULL: Failure + */ + key_type use(Alignment alignment); + + /// (2) Add a new entry to an existing DetElement structure. + /** + * This call does several actions: + * + * A check is performed if the alignment with this identifier + * already exists: if YES, continue with use(Alignment alignment). + * If NO, then: + * 1) a Condition object is added using the given 'name'. + * This condition is added to the ConditionsManager's repository + * and the ConditionsSlice. + * 'name' MUST denote a unique conditions identifier. + * 1.1) A conditions key with the id 'name' is added to the DetElement's + * conditions container. + * + * 2) an AlignmentCondition object is added to the + * ConditionsManager's repository and the used ConditionsSlice. + * Hereby as a name 'align_name' is used. + * If empty, the default results to: align_name = name+"/Transformations". + * + * Then for align_name: + * 2.1) A conditions key with the id 'align_name' is added to the DetElement's + * conditions container. + * 2.2) A conditions key-alias named "Alignment" is added to the + * DetElement's conditions container. + * 2.3) An alignment key with the id 'align_name' is added to the DetElement's + * alignments container. + * 2.4) A alignment key-alias named "Alignment" is added to the + * DetElement's alignments container. + * 2.5) A callback dependency is added to the ConditionsSlice's dependency list. + * The callback dependency uses the call 'callback'. + * If the callback is not registered, an exception is thrown. + * + * The resulting alignment key is returned to the client. If NULL: Failure + */ + key_type use(DetElement detector, const std::string& name, const std::string& align_name=""); + + /// (3) Add a new entry to an existing DetElement structure. + /** + * Shortcut call equivalent to: + * key_type use(detector, detector.path()+"#alignment","") + * + * The alignment key is returned to the client. If NULL: Failure + */ + key_type use(DetElement detector); + + /// (4) Add a new entry to an existing DetElement structure. + /** + * The alignment key is returned to the client. If NULL: Failure + */ + key_type use(const std::string& detector, const std::string& name, const std::string& align_name=""); + + /// (5) Add a new entry to an existing DetElement structure. + /** + * The alignment key is returned to the client. If NULL: Failure + */ + key_type use(const std::string& detector); + + /// Set a new delta value in the transaction stack. + /** Note: has no effect on the real alignment conditions + * as long as the callbacks are not executed, + * which is triggered by the "commit" call. + * The delta is only cached locally. + */ + bool setDelta(Alignment::key_type key_val, const Delta& delta); + + /// Set a new delta value identified by the conditions-key + bool setDelta(const ConditionKey& key, const Delta& delta); + + /// Clear all delta data in the caches transaction stack. + void clearDeltas(); + + /// We clear the entire cached stack of used entries. + void clear(); + + /// Commit all pending transactions. Returns number of altered entries + AlignmentsManager::Result commit(); + }; + + } /* End namespace Alignments */ +} /* End namespace DD4hep */ +#endif /* DD4HEP_DDALIGN_ALIGNMENTCALIB_H */ diff --git a/DDAlign/include/DDAlign/AlignmentsForward.h b/DDAlign/include/DDAlign/AlignmentsForward.h index 26271e9484a70756d257cc42fca944f51d46af2c..1f487962db1b2ccab7719d44a8326c13ec2ee381 100644 --- a/DDAlign/include/DDAlign/AlignmentsForward.h +++ b/DDAlign/include/DDAlign/AlignmentsForward.h @@ -62,8 +62,6 @@ namespace DD4hep { Slice& slice; /// The callback to be registered for the update mechanism AlignmentsUpdateCall* updateCall; - /// Conditions pool used to access the basic conditions object - Conditions::UserPool* user_pool; /// Extension property to construct the name of the alignment condition std::string extension; /// Name of the alignment alias for the detector elements alignment object diff --git a/DDAlign/include/DDAlign/AlignmentsManager.h b/DDAlign/include/DDAlign/AlignmentsManager.h index 185c112bac2a96778210ac82e281f0a5b86ae0d4..2e609a6129e87fc6cd65f1985266afea82592645 100644 --- a/DDAlign/include/DDAlign/AlignmentsManager.h +++ b/DDAlign/include/DDAlign/AlignmentsManager.h @@ -102,14 +102,6 @@ namespace DD4hep { void destroy(); /// Compute all alignment conditions of the internal dependency list Result compute(Slice& slice) const; -#if 0 - /// Compute all alignment conditions of the specified dependency list - Result compute(Slice& slice, const Dependencies& deps) const; - /// Compute all alignment conditions of the internal dependency list - Result compute(Pool& pool) const; - /// Compute all alignment conditions of the specified dependency list - Result compute(Pool& pool, const Dependencies& deps) const; -#endif /// Register new updated derived alignment during the computation step static void newEntry(const Context& parameter, DetElement& det, @@ -131,9 +123,6 @@ namespace DD4hep { typedef AlignmentsManager::Pool Pool; typedef AlignmentsManager::Slice Slice; typedef AlignmentsManager::Result Result; - - /// References to all alignment possibilities known - //AlignContext* all_alignments; protected: /// Compute the transformation from the closest detector element of the alignment to the world system @@ -148,8 +137,6 @@ namespace DD4hep { virtual ~AlignmentsManagerObject(); /// Compute all alignment conditions of the internal dependency list Result compute(Slice& slice) const; - /// Compute all alignment conditions of the specified dependency list - //Result compute(Pool& pool, const Dependencies& deps) const; }; } /* End namespace Geometry */ diff --git a/DDAlign/include/DDAlign/AlignmentsUpdateCall.h b/DDAlign/include/DDAlign/AlignmentsUpdateCall.h index f0bed54e58f8141dddf4bb4907a577848c1cffd7..34b84128f126815fae174093e93b0dba2b18aa57 100644 --- a/DDAlign/include/DDAlign/AlignmentsUpdateCall.h +++ b/DDAlign/include/DDAlign/AlignmentsUpdateCall.h @@ -76,7 +76,10 @@ namespace DD4hep { * We also cannot do this is some 'generic' way, because the delta is provided outside * and may very well depend on the extrnal database technology used to save conditions. */ - virtual Condition handle(const ConditionKey& key, const UpdateContext& context, const Delta& delta); + virtual Condition handle(const ConditionKey& key, + const UpdateContext& context, + Condition::key_type source, + const Delta& delta); /// Handler to be called if the Alignment cannot be created due to a bad underlying data type. virtual Condition invalidDataType(const ConditionKey& key, const UpdateContext& context); diff --git a/DDAlign/include/DDAlign/GlobalAlignmentStack.h b/DDAlign/include/DDAlign/GlobalAlignmentStack.h index b55a7225134356f1f2a53a88efd22ff0e7d4a29d..6f8393e2407e1bc1da06d54027087cf580eb48ab 100644 --- a/DDAlign/include/DDAlign/GlobalAlignmentStack.h +++ b/DDAlign/include/DDAlign/GlobalAlignmentStack.h @@ -33,7 +33,7 @@ namespace DD4hep { */ class GlobalAlignmentStack { public: - enum { + enum Flags { OVERLAP_DEFINED = 1<<20, MATRIX_DEFINED = 1<<21, CHECKOVL_DEFINED = 1<<22, @@ -41,7 +41,7 @@ namespace DD4hep { RESET_VALUE = 1<<24, RESET_CHILDREN = 1<<25, ____LLLAST = 1<<31 - } Flags; + }; /// Stack entry definition /** @@ -57,8 +57,10 @@ namespace DD4hep { /// Path to the misaligned volume std::string path; /// Parameter for overlap checking - double overlap; + double overlap = 0.0; + /// Default constructor + StackEntry() = delete; /// Fully initializing constructor StackEntry(DetElement p, const std::string& placement, const Delta& t, double ov); /// Copy constructor @@ -67,7 +69,7 @@ namespace DD4hep { virtual ~StackEntry(); /// Assignment operator - StackEntry& operator=(const StackEntry& e); + StackEntry& operator=(const StackEntry& e) = default; /// Check if the overlap flag checking is enabled bool overlapDefined() const { return delta.checkFlag(OVERLAP_DEFINED); } diff --git a/DDAlign/src/AlignmentsCalib.cpp b/DDAlign/src/AlignmentsCalib.cpp new file mode 100644 index 0000000000000000000000000000000000000000..07d7dcf74e342431b79e62fa66d0638df572e126 --- /dev/null +++ b/DDAlign/src/AlignmentsCalib.cpp @@ -0,0 +1,327 @@ +//========================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== + +// Framework includes +#include "DDAlign/AlignmentsCalib.h" +#include "DDAlign/AlignmentsUpdateCall.h" + +#include "DD4hep/Printout.h" +#include "DD4hep/DetAlign.h" +#include "DD4hep/Alignments.h" +#include "DD4hep/DetConditions.h" +#include "DD4hep/DetectorTools.h" +#include "DDCond/ConditionsPool.h" +#include "DDCond/ConditionsSlice.h" +#include "DD4hep/objects/AlignmentsInterna.h" + +using namespace std; +using namespace DD4hep; +using namespace DD4hep::Alignments; +using Conditions::Condition; +using Conditions::ConditionKey; +using Conditions::ConditionsPool; +using Conditions::ConditionsSlice; +using Conditions::ConditionsManager; +using Conditions::ConditionDependency; + +// ====================================================================================== + +/// Initializing constructor +AlignmentsCalib::AlignmentsCalib(LCDD& l, Slice& s) : lcdd(l), slice(s), derivationCall(0) +{ +} + +/// Default destructor +AlignmentsCalib::~AlignmentsCalib() { +} + +/// Add a new entry to the transaction list +AlignmentsCalib::key_type AlignmentsCalib::_insert(const pair<Condition::key_type,Entry*>& e) { + auto res = used.insert(e); + if ( res.second ) return (*res.first).first; + return 0; +} + +/// Add a new entry to the transaction stack. +AlignmentsCalib::key_type AlignmentsCalib::_use(AlignmentCondition alignment_condition) { + key_type tar_key = alignment_condition.key(); + UsedConditions::iterator i = used.find(tar_key); + if ( i != used.end() ) { + return (*i).first; + } + + dd4hep_ptr<Entry> entry(new Entry()); + UserPool* pool = slice.pool.get(); + Condition cc(alignment_condition); + printout(INFO,"Ex","Check key: %p %p -> %s",(void*)alignment_condition.key(),(void*)cc.key(), + alignment_condition.name()); + + /// This may be the derived condition: check presence + cc = pool->get(tar_key); + AlignmentCondition align_cond = pool->get(tar_key); + if ( !align_cond.isValid() ) { + except("AlignmentsCalib","++ The DERIVED alignment condition [%p] is invalid.",(void*)tar_key); + } + key_type src_key = align_cond->source_key; + Condition src_cond = pool->get(src_key); + if ( !src_cond.isValid() ) { + except("AlignmentsCalib","++ The SOURCE alignment condition [%p] for %s is invalid.", + (void*)src_key, align_cond.name()); + } + /// Check for the source data entry + Proxy::const_iterator is = slice.conditions().find(src_key); + if ( is == slice.conditions().end() ) { + slice.insert(src_cond); + is = slice.conditions().find(src_key); + } + entry->source = (*is).second; + /// Check for the derived conditions entry + Proxy::const_iterator ip = slice.derived().find(tar_key); + if ( ip == slice.derived().end() ) { + if ( derivationCall ) { + Conditions::DependencyBuilder b(ConditionKey(align_cond.name(),align_cond.key()),derivationCall); + b.add(ConditionKey(src_cond.name(),src_cond.key())); + slice.insert(b.release()); + ip = slice.derived().find(tar_key); + } + else { + except("AlignmentsCalib","++ The dependency rule for [%p] %s cannot be added [no callback].", + (void*)tar_key, align_cond.name()); + } + } + entry->target = (*ip).second; + return _insert(make_pair(tar_key,entry.release())); +} + +/// Registers a new condition to the conditions manager. Throws exception on failure +Condition AlignmentsCalib::_register(Condition cond) const { + if ( cond.isValid() ) { + // Need to add the new condition to the IOV pool + // using the user pool's IOV. + const IOV& iov = slice.pool->validity(); + ConditionsPool* pool = slice.manager.registerIOV(*iov.iovType, iov.keyData); + // We must simultaneously add the newly created condition to + // -- the IOV pool using the conditions manager + slice.manager.registerUnlocked(pool, cond); + // -- the slice and the user pool + ConditionKey key(cond.name(),cond.key()); + slice.insert(key,slice.loadInfo(cond.address())); + slice.insert(cond); + printout(INFO,"Ex","Inserted key: %p -> %s",(void*)key.hash,key.name.c_str()); + return cond; + } + invalidHandleError<Condition>(); + return Condition(); +} + +/// Implementation: Add a new raw(delta)-condition to the transaction stack. +Condition AlignmentsCalib::_create_source(key_type key, + const string& nam) const +{ + Condition cond(nam,"alignment"); + cond.bind<Delta>(); + cond->setFlag(Condition::ALIGNMENT); + cond->validate(); + cond->hash = key; + return _register(cond); +} + +/// Implementation: Add a new alignment-condition to the transaction stack. +Condition AlignmentsCalib::_create_target(DetElement detector, + key_type key, + const string& nam) const +{ + AlignmentCondition cond(nam); + AlignmentData& data = Condition(cond).get<AlignmentData>(); + data.detector = detector; + cond->setFlag(Condition::ALIGNMENT_DERIVED); + cond->invalidate(); + cond->hash = key; + return _register(cond); +} + +/// (1) Add a new entry to the transaction stack. +AlignmentsCalib::key_type AlignmentsCalib::use(Alignment alignment) { + AlignmentCondition cond = alignment.condition(); + cond.access(); // Throw exception if invalid. + return _use(cond); +} + +/// (2) Add a new entry to an existing DetElement structure. +AlignmentsCalib::key_type AlignmentsCalib::use(DetElement detector, + const string& src_nam, + const string& align_nam) +{ + UserPool* pool = slice.pool.get(); + key_type src_key = ConditionKey::hashCode(src_nam); + Condition src_cond = pool->get(src_key); + + if ( !src_cond.isValid() ) { + /// Try to create a new condition and register it to the conditions manager from the delta value. + src_cond = _create_source(src_key, src_nam); + /// Now check again if we succeeded. + if ( !src_cond.isValid() ) { + except("AlignmentsCalib","++ The SOURCE alignment condition [%p]: %s is invalid.", + (void*)src_key, src_nam.c_str()); + } + // Add the conditons keys to the detector element: + Conditions::DetConditions conditions(detector); + Conditions::Container cond_cont = conditions.conditions(); + cond_cont.insertKey(src_nam); + } + + /// This may be the derived condition: check presence + string tar_nam = align_nam.empty() ? src_nam+"/Transformations" : align_nam; + key_type tar_key = ConditionKey::hashCode(tar_nam); + AlignmentCondition align_cond = pool->get(tar_key); + if ( !align_cond.isValid() ) { + /// Try to create a new condition and register it to the conditions manager from the delta value. + align_cond = _create_target(detector, tar_key, tar_nam); + /// Now check again if we succeeded. + if ( !align_cond.isValid() ) { + except("AlignmentsCalib","++ The DERIVED alignment condition [%p]: %s is invalid.", + (void*)tar_key, tar_nam.c_str()); + } + // Add the conditons keys to the detector element: + Conditions::DetConditions conditions(detector); + Conditions::Container cond_cont = conditions.conditions(); + cond_cont.insertKey("Alignment", tar_nam); + cond_cont.insertKey(tar_nam); + + // Add the corresponding alignment keys: + DetAlign da(detector); + Alignments::Container align_cont = da.alignments(); + align_cont.insertKey("Alignment",tar_nam); + align_cont.insertKey(tar_nam); + } + align_cond->source_key = src_key; + + // Now all pre-conditions should be satisfied. + // Add the entry the usual way. This should also check everything again. + return _use(align_cond); +} + +/// (3) Add a new entry to an existing DetElement structure. +AlignmentsCalib::key_type AlignmentsCalib::use(DetElement detector) { + if ( detector.isValid() ) { + string name = detector.path()+"#alignment"; + return use(detector,name); + } + invalidHandleError<DetElement>(); + return 0; +} + +/// (4) Add a new entry to an existing DetElement structure. +AlignmentsCalib::key_type AlignmentsCalib::use(const std::string& detector, + const string& src_nam, + const string& align_nam) { + DetElement det(Geometry::DetectorTools::findElement(lcdd,detector)); + if ( det.isValid() ) { + return use(det, src_nam, align_nam); + } + invalidHandleError<DetElement>(); + return 0; +} + +/// (5) Add a new entry to an existing DetElement structure. +AlignmentsCalib::key_type AlignmentsCalib::use(const std::string& detector) { + DetElement det(Geometry::DetectorTools::findElement(lcdd,detector)); + if ( det.isValid() ) { + return use(det); + } + invalidHandleError<DetElement>(); + return 0; +} + +/// Clear all delta data in the caches transaction stack. +void AlignmentsCalib::clearDeltas() { + if ( !used.empty() ) { + Delta empty; + for ( auto& e : used ) { + e.second->delta = empty; + e.second->dirty = false; + } + } +} + +/// Commit all pending transactions. Returns number of altered entries +void AlignmentsCalib::clear() { + for(auto& e : used) delete e.second; + used.clear(); +} + +/// Set a new delta value in the transaction stack. +bool AlignmentsCalib::setDelta(Condition::key_type key_val, const Delta& delta) { + UsedConditions::iterator i = used.find(key_val); + if ( i != used.end() ) { + (*i).second->delta = delta; + (*i).second->dirty = 1; + return true; + } + except("AlignmentsCalib","++ FAILED setDelta: invalid entry id: %p",(void*)key_val); + return false; +} + +/// Set a new delta value in the transaction stack. +bool AlignmentsCalib::setDelta(const ConditionKey& key, const Delta& delta) { + return setDelta(key.hash, delta); +} + +/// Propagate all Delta parameters to the source conditions +bool AlignmentsCalib::propagateDeltas() { + UserPool* pool = slice.pool.get(); + for ( const auto& entry : used ) { + const Entry* e = entry.second; + + /// Invalidate the target condition to trigger the computation. + Condition tar_cond = pool->get(e->target->key.hash); + if ( !tar_cond.isValid() ) { + except("AlignmentsCalib","++ The DERIVED alignment condition [%p]: %s is invalid.", + (void*)e->target->key.hash, e->target->key.name.c_str()); + } + tar_cond->invalidate(); + + /// Update the source condition with the new delta value + Condition src_cond = pool->get(e->source->key.hash); + if ( !src_cond.isValid() ) { + except("AlignmentsCalib","++ The SOURCE alignment condition [%p]: %s is invalid.", + (void*)e->source->key.hash, e->source->key.name.c_str()); + } + src_cond.get<Delta>() = e->delta; + src_cond->validate(); + } + return true; +} + +/// Update Dependencies between the source conditions and the computations +bool AlignmentsCalib::updateDependencies() { + // As long as we do not add new conditions, the old entries are still valid and present. + return true; +} + +/// Compute all dependent conditions from the Delta parameters +AlignmentsManager::Result AlignmentsCalib::computeDependencies() { + AlignmentsManager mgr; + return mgr.compute(slice); +} + +/// Commit all pending transactions. Returns number of altered entries +AlignmentsManager::Result AlignmentsCalib::commit() { + if ( propagateDeltas() ) { + if ( updateDependencies() ) { + return computeDependencies(); + } + } + return AlignmentsManager::Result(); +} + diff --git a/DDAlign/src/AlignmentsUpdateCall.cpp b/DDAlign/src/AlignmentsUpdateCall.cpp index 5902ee507d6ea6b332021485db692900866635f2..e10fda0d28ea7a485002bb0662dd01c702361f62 100644 --- a/DDAlign/src/AlignmentsUpdateCall.cpp +++ b/DDAlign/src/AlignmentsUpdateCall.cpp @@ -36,11 +36,17 @@ AlignmentsUpdateCall::~AlignmentsUpdateCall() { } AlignmentsUpdateCall::Condition -AlignmentsUpdateCall::handle(const ConditionKey& key, const UpdateContext& ctxt, const Delta& delta) { +AlignmentsUpdateCall::handle(const ConditionKey& key, + const UpdateContext& ctxt, + Condition::key_type source, + const Delta& delta) +{ AlignmentCondition target(key.name); AlignmentData& data = target.data(); - data.delta = delta; - data.detector = ctxt.dependency.detector; + data.delta = delta; + data.flag = AlignmentData::HAVE_NONE; + data.detector = ctxt.dependency.detector; + target->source_key = source; target->setFlag(Condition::ALIGNMENT_DERIVED); // // This here is the main difference compared to other derived conditions: @@ -71,9 +77,10 @@ AlignmentsUpdateCall::invalidDataType(const ConditionKey& key, const UpdateConte Condition cond = context.condition(0); DetElement det = context.dependency.detector; Alignments::AlignmentCondition target(key.name); - Data& data = target.data(); - data.detector = det; - data.flag = AlignmentData::HAVE_NONE; + Data& data = target.data(); + data.detector = det; + data.flag = AlignmentData::HAVE_NONE; + target->source_key = 0; printout(ERROR,"AlignmentUpdate","++ Failed to access alignment-Delta for %s from %s", det.path().c_str(), cond->value.c_str()); printout(ERROR,"AlignmentUpdate","++ The true data type is: %s",typeName(cond.typeInfo()).c_str()); diff --git a/DDAlign/src/DDAlignForwardCall.cpp b/DDAlign/src/DDAlignForwardCall.cpp index f346616d1fd04ca0614e1286802e0b82feb4ef95..cbb5094348461e48707fd9720f0efdce0eb819e8 100644 --- a/DDAlign/src/DDAlignForwardCall.cpp +++ b/DDAlign/src/DDAlignForwardCall.cpp @@ -25,7 +25,7 @@ Alignments::DDAlignForwardCall::operator()(const ConditionKey& key, const Update { Data::Delta delta; DetElement det = context.dependency.detector; - Condition c = AlignmentsUpdateCall::handle(key, context, delta); + Condition c = AlignmentsUpdateCall::handle(key, context, 0, delta); printout(INFO,"DDAlignForward","++ Building child alignment condition: %s Detector [%d]: %s [%p]", key.name.c_str(), det.level(), det.path().c_str(), c.ptr()); return c; diff --git a/DDAlign/src/DDAlignResetCall.cpp b/DDAlign/src/DDAlignResetCall.cpp index 53ee9b09ffc9368395500c7412e473165a0dc60c..5b35c3d424009b8cc46731785c66feb665141330 100644 --- a/DDAlign/src/DDAlignResetCall.cpp +++ b/DDAlign/src/DDAlignResetCall.cpp @@ -29,7 +29,7 @@ Alignments::DDAlignResetCall::operator()(const ConditionKey& key, const UpdateCo Data::Delta empty_delta; Data::Delta& delta = cond.get<Data::Delta>(); delta = empty_delta; - Condition c = AlignmentsUpdateCall::handle(key, context, empty_delta); + Condition c = AlignmentsUpdateCall::handle(key, context, cond.key(), empty_delta); printLevel = INFO; printout(printLevel,"DDAlignReset","++ Building dependent condition: %s Detector [%d]: %s [%p]", key.name.c_str(), det.level(), det.path().c_str(), c.ptr()); diff --git a/DDAlign/src/DDAlignUpdateCall.cpp b/DDAlign/src/DDAlignUpdateCall.cpp index 871d5acdaf4d7e3ddc80361ce607fc8dc5475163..7fddb7703f83732e0f747638000bd04ff8a0298a 100644 --- a/DDAlign/src/DDAlignUpdateCall.cpp +++ b/DDAlign/src/DDAlignUpdateCall.cpp @@ -27,7 +27,7 @@ Alignments::DDAlignUpdateCall::operator()(const ConditionKey& key, const UpdateC DetElement det = context.dependency.detector; if ( cond.typeInfo() == typeid(Data::Delta) ) { const Data::Delta& delta = cond.get<Data::Delta>(); - Condition c = AlignmentsUpdateCall::handle(key, context, delta); + Condition c = AlignmentsUpdateCall::handle(key, context, cond.key(), delta); //printLevel = INFO; printout(printLevel,"DDAlignUpdate","++ Building dependent condition: %s Detector [%d]: %s [%p]", key.name.c_str(), det.level(), det.path().c_str(), c.ptr()); diff --git a/DDAlign/src/GlobalAlignmentStack.cpp b/DDAlign/src/GlobalAlignmentStack.cpp index 146aeef007c2a0aed6da054e0dab7e1ceae6960e..62139da256c51484f3ad74945dd27d161487f24e 100644 --- a/DDAlign/src/GlobalAlignmentStack.cpp +++ b/DDAlign/src/GlobalAlignmentStack.cpp @@ -51,17 +51,6 @@ GlobalAlignmentStack::StackEntry::~StackEntry() { InstanceCount::decrement(this); } -/// Assignment operator -GlobalAlignmentStack::StackEntry& GlobalAlignmentStack::StackEntry::operator=(const StackEntry& e) { - if ( this != &e ) { - detector = e.detector; - delta = e.delta; - overlap = e.overlap; - path = e.path; - } - return *this; -} - /// Set flag to reset the entry to it's ideal geometrical position GlobalAlignmentStack::StackEntry& GlobalAlignmentStack::StackEntry::setReset(bool new_value) { new_value ? (delta.flags |= RESET_VALUE) : (delta.flags &= ~RESET_VALUE); @@ -150,14 +139,13 @@ bool GlobalAlignmentStack::add(dd4hep_ptr<StackEntry>& entry) { if ( entry.get() && !entry->path.empty() ) { Stack::const_iterator i = m_stack.find(entry->path); if ( i == m_stack.end() ) { - + StackEntry* e = entry.get(); // Need to make some checks BEFORE insertion - if ( !entry->detector.isValid() ) { + if ( !e->detector.isValid() ) { throw runtime_error("GlobalAlignmentStack> Invalid alignment entry [No such detector]"); } - printout(INFO,"GlobalAlignmentStack","Add node:%s",entry->path.c_str()); - m_stack.insert(make_pair(entry->path,entry.get())); - entry.release(); + printout(INFO,"GlobalAlignmentStack","Add node:%s",e->path.c_str()); + m_stack.insert(make_pair(e->path,entry.release())); return true; } throw runtime_error("GlobalAlignmentStack> The entry with path "+entry->path+ diff --git a/DDCond/include/DDCond/ConditionsEntry.h b/DDCond/include/DDCond/ConditionsEntry.h index 769881c4e356c27c73ebb316d5b99acade9a47de..753308f34d360a4379722951918cb8e61830ea22 100644 --- a/DDCond/include/DDCond/ConditionsEntry.h +++ b/DDCond/include/DDCond/ConditionsEntry.h @@ -1,4 +1,3 @@ -// $Id$ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -43,9 +42,9 @@ namespace DD4hep { /// The validity string to be interpreted by the updating engine std::string validity; /// Hash value of the name for fast identification - int hash; + int hash = 0; /// Default constructor - Entry() {} + Entry(); /// Initializing constructor Entry(const Geometry::DetElement& det, const std::string& nam, const std::string& typ, const std::string& valid, int hash); /// Copy constructor diff --git a/DDCond/include/DDCond/ConditionsSlice.h b/DDCond/include/DDCond/ConditionsSlice.h index 7a8a256e922e08ed95244d14e2cc8c204c1f8353..0429fe84db03180dedeeb7d41f046f76d1ade55e 100644 --- a/DDCond/include/DDCond/ConditionsSlice.h +++ b/DDCond/include/DDCond/ConditionsSlice.h @@ -164,8 +164,8 @@ namespace DD4hep { virtual const void* data() const { return (T*)this; } }; - typedef Condition::key_type key_type; - typedef ConditionDependency Dependency; + typedef Condition::key_type key_type; + typedef ConditionDependency Dependency; typedef std::map<key_type,Descriptor*> ConditionsProxy; public: @@ -214,7 +214,6 @@ namespace DD4hep { ConditionsProxy& missingConditions() { return m_missingConditions; } /// Access the map of missing computational conditions (only valid after preparation) ConditionsProxy& missingDerivations() { return m_missingDerivations;} - /// Clear the container. Destroys the contained stuff void clear(); /// Clear the conditions access and the user pool. diff --git a/DDCond/include/DDCond/ConditionsTextRepository.h b/DDCond/include/DDCond/ConditionsTextRepository.h index b445fd83aea03eb8193e7dfab938bbbbd4967303..c56bf4860420543f3ec7d81796bf51050cf9a099 100644 --- a/DDCond/include/DDCond/ConditionsTextRepository.h +++ b/DDCond/include/DDCond/ConditionsTextRepository.h @@ -44,17 +44,11 @@ namespace DD4hep { class Entry { public: std::string name, address; - Condition::key_type key; - Entry() {} - Entry(const Entry& e) : name(e.name), address(e.address), key(e.key) {} - Entry& operator=(const Entry& e) { - if ( this != &e ) { - key = e.key; - name = e.name; - address = e.address; - } - return *this; - } + Condition::key_type key = 0; + Entry() = default; + Entry(const Entry& copy) = default; + ~Entry() = default; + Entry& operator=(const Entry& copy) = default; }; typedef std::vector<Entry> Data; diff --git a/DDCond/src/ConditionsDependencyHandler.cpp b/DDCond/src/ConditionsDependencyHandler.cpp index 809aa4c331a2107b22516a5eb19e30f566dba632..4f2c5fa59b6f2a48a43c2738da2386b1cf0f101f 100644 --- a/DDCond/src/ConditionsDependencyHandler.cpp +++ b/DDCond/src/ConditionsDependencyHandler.cpp @@ -76,6 +76,7 @@ ConditionsDependencyHandler::do_callback(const ConditionDependency& dep) const if ( obj ) { if ( !obj->hash ) obj->hash = ConditionKey::hashCode(obj->name); cond->setFlag(Condition::DERIVED); + cond->validate(); cond->iov = m_pool.validityPtr(); // Must IMMEDIATELY insert to handle inter-dependencies. ++num_callback; diff --git a/DDCond/src/ConditionsEntry.cpp b/DDCond/src/ConditionsEntry.cpp index ca90bdc2e27b10ff19481d340aa7fc55d1968b8a..b42b3a80c0b3d8b99ab09d6be65d83923558ae86 100644 --- a/DDCond/src/ConditionsEntry.cpp +++ b/DDCond/src/ConditionsEntry.cpp @@ -1,4 +1,3 @@ -// $Id$ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -19,6 +18,13 @@ using std::string; using namespace DD4hep::Conditions; +/// Default constructor +Entry::Entry() + : NamedObject(), detector(), value(), validity(), hash(0) +{ + InstanceCount::increment(this); +} + /// Initializing constructor Entry::Entry(const DD4hep::Geometry::DetElement& det, const string& nam, const string& typ, const string& valid, int h) : NamedObject(nam,typ), detector(det), value(), validity(valid), hash(h) @@ -28,7 +34,7 @@ Entry::Entry(const DD4hep::Geometry::DetElement& det, const string& nam, const s /// Copy constructor Entry::Entry(const Entry& c) - : NamedObject(c), detector(c.detector), value(c.value), validity(c.validity) + : NamedObject(c), detector(c.detector), value(c.value), validity(c.validity), hash(c.hash) { InstanceCount::increment(this); } @@ -43,8 +49,9 @@ Entry& Entry::operator=(const Entry& c) { if ( this != &c ) { this->NamedObject::operator=(c); detector = c.detector; - value = c.value; + value = c.value; validity = c.validity; + hash = c.hash; } return *this; } diff --git a/DDCond/src/ConditionsTextRepository.cpp b/DDCond/src/ConditionsTextRepository.cpp index 75ece0c8ec8d5eff6dfb49ce9d44314cebe4203e..6ce24540c415db7d7d6621835baf120dfe44c6f7 100644 --- a/DDCond/src/ConditionsTextRepository.cpp +++ b/DDCond/src/ConditionsTextRepository.cpp @@ -141,7 +141,7 @@ namespace { int readText(const string& input, ConditionsTextRepository::Data& data) { size_t idx; ConditionsTextRepository::Entry e; - long siz_nam, siz_add, siz_tot; + size_t siz_nam, siz_add, siz_tot; char sep, c, text[2*PATH_MAX+64]; ifstream in(input); in >> c >> c >> c >> c >> c >> c >> c >> sep diff --git a/DDCond/src/plugins/ConditionsRepositoryParser.cpp b/DDCond/src/plugins/ConditionsRepositoryParser.cpp index 2813051cf995974969c90f581944afdb87841c0a..1b3f7751b9ef0922aba51f3c0c876526b7de3096 100644 --- a/DDCond/src/plugins/ConditionsRepositoryParser.cpp +++ b/DDCond/src/plugins/ConditionsRepositoryParser.cpp @@ -209,8 +209,8 @@ namespace DD4hep { */ template <> void Converter<iov_type>::operator()(xml_h element) const { xml_dim_t e = element; - size_t id = e.id(); string nam = e.nameStr(); + size_t id = size_t(e.id()); ConversionArg* arg = _param<ConversionArg>(); printout(s_parseLevel,"XMLConditions","++ Registering IOV type: [%d]: %s",id,nam.c_str()); const IOVType* iov_type = arg->manager.registerIOVType(id,nam).second; @@ -250,6 +250,10 @@ namespace DD4hep { */ template <> void Converter<manager>::operator()(xml_h element) const { ConversionArg* arg = _param<ConversionArg>(); + if ( element.hasAttr(_U(ref)) ) { + XML::DocumentHolder doc(XML::DocumentHandler().load(element, element.attr_value(_U(ref)))); + (*this)(doc.root()); + } for( xml_coll_t c(element,_UC(property)); c; ++c) { xml_dim_t d = c; string nam = d.nameStr(); @@ -525,6 +529,8 @@ namespace DD4hep { Converter<conditions>(lcdd,param,optional)(e); else if ( tag == "detelement" ) Converter<detelement>(lcdd,param,optional)(e); + else if ( tag == "iov_type" ) + Converter<iov_type>(lcdd,param,optional)(e); else if ( tag == "iov" ) // Processing repository file Converter<iov>(lcdd,param,optional)(e); else diff --git a/DDCore/include/DD4hep/Alignments.h b/DDCore/include/DD4hep/Alignments.h index c86108732ce8bb196eba92646b89527726ccf22f..08d04ba08cff5cb30000e76d9fcee979dbee7b6f 100644 --- a/DDCore/include/DD4hep/Alignments.h +++ b/DDCore/include/DD4hep/Alignments.h @@ -16,6 +16,7 @@ // Framework include files #include "DD4hep/IOV.h" #include "DD4hep/Volumes.h" +#include "DD4hep/Conditions.h" /// Namespace for the AIDA detector description toolkit namespace DD4hep { @@ -25,8 +26,10 @@ namespace DD4hep { /// Namespace for the conditions part of the AIDA detector description toolkit namespace Conditions { - class UserPool; + class Condition; + class ConditionsKey; + /// Conditions internal namespace namespace Interna { class ConditionObject; @@ -55,6 +58,67 @@ namespace DD4hep { class Alignment; class Delta; + /// Main handle class to hold an alignment conditions object + /** + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_GEOMETRY + * \ingroup DD4HEP_ALIGN + */ + class AlignmentCondition : public Handle<Interna::AlignmentConditionObject> { + public: + /// Forward definition of the base data object containing alignment data + typedef Interna::AlignmentConditionObject Object; + /// Forward definition of the base data object containing alignment data + typedef AlignmentData Data; + /// Forward definition of the geometry placement + typedef Geometry::PlacedVolume PlacedVolume; + /// Forward definition of the nodelist leading to the world + typedef std::vector<PlacedVolume> NodeList; + /// Forward definition of the alignment delta data + typedef Alignments::Delta Delta; + /// Forward definition of the key type + typedef unsigned long long int key_type; + /// Forward definition of the iov type + typedef IOV iov_type; + + public: + /// Default constructor + AlignmentCondition() : Handle<Object>() {} + /// Default constructor + AlignmentCondition(Object* p) : Handle<Object>(p) {} + /// Assignment constructor from condition object + AlignmentCondition(Conditions::Interna::ConditionObject* p) : Handle<Object>(p) {} + /// Constructor to be used when reading the already parsed object + template <typename Q> AlignmentCondition(const Handle<Q>& e) : Handle<Object>(e) {} + /// Object constructor for pure alignment objects +#if defined(__APPLE__) || defined(__clang__) + AlignmentCondition(const std::string& name) ; +#else + template <typename Q=Object> AlignmentCondition(const std::string& name); +#endif + /** Interval of validity */ + /// Access the IOV type + const IOVType& iovType() const; + /// Access the IOV block + const iov_type& iov() const; + /// Access the hash identifier + key_type key() const; + + /** Data block (bound type) */ + /// Data accessor for the use of decorators + Data& data(); + /// Data accessor for the use of decorators + const Data& data() const; + /// Create cached matrix to transform to world coordinates + const TGeoHMatrix& worldTransformation() const; + /// Access the alignment/placement matrix with respect to the world + const TGeoHMatrix& detectorTransformation() const; + /// Check if object is already bound.... + bool is_bound() const; + }; + /// Main handle class to hold an alignment object /** * @@ -114,6 +178,10 @@ namespace DD4hep { /// Hash code generation from input string static key_type hashCode(const std::string& value); + /// Access the hash identifier if the alignment is bound to a condition. Otherwise NULL. + key_type key() const; + /// Access the bound condition if the alignment is bound to a condition. Otherwise NULL. + AlignmentCondition condition() const; /// Data accessor for the use of decorators Data& data() { return (*access()); } /// Data accessor for the use of decorators @@ -176,68 +244,6 @@ namespace DD4hep { inline Alignment::key_type Alignment::hashCode(const std::string& value) { return hash64(value); } - /// Main handle class to hold an alignment conditions object - /** - * - * \author M.Frank - * \version 1.0 - * \ingroup DD4HEP_GEOMETRY - * \ingroup DD4HEP_ALIGN - */ - class AlignmentCondition : public Handle<Interna::AlignmentConditionObject> { - public: - /// Forward definition of the base data object containing alignment data - typedef Interna::AlignmentConditionObject Object; - /// Forward definition of the base data object containing alignment data - typedef AlignmentData Data; - /// Forward definition of the geometry placement - typedef Geometry::PlacedVolume PlacedVolume; - /// Forward definition of the nodelist leading to the world - typedef std::vector<PlacedVolume> NodeList; - /// Forward definition of the alignment delta data - typedef Alignments::Delta Delta; - /// Forward definition of the key type - typedef unsigned int key_type; - /// Forward definition of the iov type - typedef IOV iov_type; - - public: - /// Default constructor - AlignmentCondition() : Handle<Object>() {} - /// Default constructor - AlignmentCondition(Object* p) : Handle<Object>(p) {} - /// Assignment constructor from condition object - AlignmentCondition(Conditions::Interna::ConditionObject* p) : Handle<Object>(p) {} - /// Constructor to be used when reading the already parsed object - template <typename Q> AlignmentCondition(const Handle<Q>& e) : Handle<Object>(e) {} - /// Object constructor for pure alignment objects -#if defined(__APPLE__) || defined(__clang__) - AlignmentCondition(const std::string& name) ; -#else - template <typename Q=Object> AlignmentCondition(const std::string& name); -#endif - /** Interval of validity */ - /// Access the IOV type - const IOVType& iovType() const; - /// Access the IOV block - const iov_type& iov() const; - /// Access the hash identifier - key_type key() const; - - /** Data block (bound type) */ - /// Data accessor for the use of decorators - Data& data(); - /// Data accessor for the use of decorators - const Data& data() const; - /// Create cached matrix to transform to world coordinates - const TGeoHMatrix& worldTransformation() const; - /// Access the alignment/placement matrix with respect to the world - const TGeoHMatrix& detectorTransformation() const; - /// Check if object is already bound.... - bool is_bound() const; - }; - - /// Container class for alignment handles aggregated by a detector element /** * Note: The alignments container is owner by the detector element @@ -293,12 +299,28 @@ namespace DD4hep { /// Known keys of conditions in this container const Keys& keys() const; - /// Add a new key to the conditions access map. + /// Insert a new key to the alignments access map. Ignores already existing keys. + /** Caution: This is not thread protected! + * + * @return true if key was inserted. False if already present. + */ + bool insertKey(const std::string& key_val); + + /// Insert a new key to the alignments access map: Allow for alias if key_val != data_val + /** Caution: This is not thread protected! + * + * @return true if key was inserted. False if already present. + */ + bool insertKey(const std::string& key_val, const std::string& data_val); + + /// Add a new key to the alignments access map. If key exists: exception /** Caution: This is not thread protected! */ void addKey(const std::string& key_val); - /// Add a new key to the conditions access map: Allow for alias if key_val != data_val - /** Caution: This is not thread protected! */ + /// Add a new key to the alignments access map: Allow for alias if key_val != data_val + /** If key exists: exception + * Caution: This is not thread protected! + */ void addKey(const std::string& key_val, const std::string& data_val); /// Access to alignment objects by key and IOV. @@ -318,6 +340,6 @@ namespace DD4hep { inline Container::Container() : Handle<Object>() { } - } /* End namespace Aligments */ -} /* End namespace DD4hep */ -#endif /* DD4HEP_ALIGMENTS_ALIGNMENTS_H */ + } /* End namespace Aligments */ +} /* End namespace DD4hep */ +#endif /* DD4HEP_ALIGMENTS_ALIGNMENTS_H */ diff --git a/DDCore/include/DD4hep/Conditions.h b/DDCore/include/DD4hep/Conditions.h index 8b8ad1679462dc95a1d6c27f2472e7d23b8b2bca..9bdad86d0f7088ab609ef8ddd555cd8d6b9e686f 100644 --- a/DDCore/include/DD4hep/Conditions.h +++ b/DDCore/include/DD4hep/Conditions.h @@ -79,28 +79,31 @@ namespace DD4hep { public: enum StringFlags { - WITH_IOV = 1<<0, - WITH_ADDRESS = 1<<1, - WITH_TYPE = 1<<2, - WITH_COMMENT = 1<<4, - WITH_DATATYPE = 1<<5, - WITH_DATA = 1<<6, - NO_NAME = 1<<20, + WITH_IOV = 1<<0, + WITH_ADDRESS = 1<<1, + WITH_TYPE = 1<<2, + WITH_COMMENT = 1<<4, + WITH_DATATYPE = 1<<5, + WITH_DATA = 1<<6, + NO_NAME = 1<<20, NONE }; enum ConditionState { - INACTIVE = 0, - ACTIVE = 1<<0, - CHECKED = 1<<2, - DERIVED = 1<<3, - TEMPERATURE = 1<<4, - PRESSURE = 1<<5, - ALIGNMENT = 1<<6, - ALIGNMENT_DERIVED = 1<<7, + INACTIVE = 0, + ACTIVE = 1<<0, + CHECKED = 1<<2, + DERIVED = 1<<3, + // Flags for specific conditions + TEMPERATURE = 1<<4, + TEMPERATURE_DERIVED = TEMPERATURE|DERIVED, + PRESSURE = 1<<5, + PRESSURE_DERIVED = PRESSURE|DERIVED, + ALIGNMENT = 1<<6, + ALIGNMENT_DERIVED = ALIGNMENT|DERIVED, // Keep bit 8-15 for other generic types // Bit 16-31 is reserved for user classifications - USER_FLAGS_FIRST = 1<<16, - USER_FLAGS_LAST = 1<<31 + USER_FLAGS_FIRST = 1<<16, + USER_FLAGS_LAST = 1<<31 }; /// Abstract base for processing callbacks to conditions objects @@ -252,6 +255,14 @@ namespace DD4hep { /** Caution: This is not thread protected! */ const Keys& keys() const; + /// Insert a new key to the conditions access map. Ignores already existing keys. + /** Caution: This is not thread protected! */ + bool insertKey(const std::string& key_val); + + /// Insert a new key to the conditions access map: Allow for alias if key_val != data_val + /** Caution: This is not thread protected! */ + bool insertKey(const std::string& key_val, const std::string& data_val); + /// Add a new key to the conditions access map. /** Caution: This is not thread protected! */ void addKey(const std::string& key_val); @@ -374,6 +385,17 @@ namespace DD4hep { /// Hashed key representation key_type hash = 0; + /// Compare keys by the hash value + /** + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_CONDITIONS + */ + struct HashCompare { + Condition::key_type key; + HashCompare(Condition::key_type k) : key(k) {} + bool operator==(const ConditionKey& k) const { return key==k.hash; } + }; public: /// Default constructor ConditionKey() = default; diff --git a/DDCore/include/DD4hep/OpaqueData.h b/DDCore/include/DD4hep/OpaqueData.h index 06bb8fd2f4d63ef0dc714fb32c7e1b3bbcf013a3..b2d39ac25461f0dd762680d9e8315bf4a13eed21 100644 --- a/DDCore/include/DD4hep/OpaqueData.h +++ b/DDCore/include/DD4hep/OpaqueData.h @@ -37,21 +37,21 @@ namespace DD4hep { private: protected: /// Standard initializing constructor - OpaqueData(); + OpaqueData() = default; /// Standard Destructor - virtual ~OpaqueData(); + virtual ~OpaqueData() = default; /// Copy constructor - OpaqueData(const OpaqueData& c); + OpaqueData(const OpaqueData& c) = default; /// Assignment operator - OpaqueData& operator=(const OpaqueData& c); + OpaqueData& operator=(const OpaqueData& c) = default; public: /// Data type - const BasicGrammar* grammar; + const BasicGrammar* grammar = 0; protected: /// Pointer to object data - void* pointer; + void* pointer = 0; public: /// Create data block from string representation @@ -62,8 +62,10 @@ namespace DD4hep { const std::type_info& typeInfo() const; /// Access type name of the condition data block const std::string& dataType() const; + /// Access to the data buffer (read only!). Is only valid after call to bind<T>() + const void* ptr() const { return pointer; } /// Check if object is already bound.... - bool is_bound() const { return 0 != pointer; } + bool is_bound() const { return 0 != pointer; } /// Generic getter. Specify the exact type, not a polymorph type template <typename T> T& get(); /// Generic getter (const version). Specify the exact type, not a polymorph type diff --git a/DDCore/include/DD4hep/SurfaceInstaller.h b/DDCore/include/DD4hep/SurfaceInstaller.h index 4cdc1c897fef2ee3dd34c74bde52756c1f040c88..0c14d2fe9c1da3fb53f3df297eb0cc5986054434 100644 --- a/DDCore/include/DD4hep/SurfaceInstaller.h +++ b/DDCore/include/DD4hep/SurfaceInstaller.h @@ -72,10 +72,16 @@ namespace DD4hep { void scan(DetElement de); public: + /// No default constructor + SurfaceInstaller() = delete; + /// No copy constructor + SurfaceInstaller(const SurfaceInstaller& copy) = delete; /// Initializing constructor SurfaceInstaller(LCDD& lcdd, int argc, char** argv); /// Default destructor - virtual ~SurfaceInstaller() {} + virtual ~SurfaceInstaller() = default; + /// No assignment + SurfaceInstaller& operator=(const SurfaceInstaller& copy) = delete; /// Set flag to stop scanning volumes and detector elements void stopScanning() { m_stopScanning = true; } /// Indicate error message and throw exception @@ -148,10 +154,16 @@ namespace { /// Default (empty argument handler void handle_arguments(int argc, char** argv); public: + /// No default constructor + Installer() = delete; + /// No copy constructor + Installer(const Installer& copy) = delete; /// Initializing constructor Installer(LCDD& lcdd, int argc, char** argv); /// Default destructor - virtual ~Installer() {} + virtual ~Installer() = default; + /// No assignment + Installer& operator=(const Installer& copy) = delete; /// Install volume information. Default implementation only prints! virtual void install(DetElement component, PlacedVolume pv); /// Try to handle surface using the surface cache @@ -168,7 +180,7 @@ namespace { /// Initializing constructor template <typename UserData> Installer<UserData>::Installer(LCDD& lcdd, int argc, char** argv) - : DD4hep::SurfaceInstaller(lcdd, argc, argv) + : DD4hep::SurfaceInstaller(lcdd, argc, argv), data() { handle_arguments(argc, argv); } @@ -203,5 +215,4 @@ typedef Installer<SURFACEINSTALLER_DATA> InstallerClass; DECLARE_SURFACE_INSTALLER(DD4HEP_USE_SURFACEINSTALL_HELPER,InstallerClass) #endif /* defined(DD4HEP_USE_SURFACEINSTALL_HELPER) */ - -#endif /* DD4HEP_DDREC_SURFACEINSTALLER_H */ +#endif /* DD4HEP_DDREC_SURFACEINSTALLER_H */ diff --git a/DDCore/include/DD4hep/objects/AlignmentsInterna.h b/DDCore/include/DD4hep/objects/AlignmentsInterna.h index 1220922f183700935f121927460014aef25dbfae..38d7484b1b59d3b6f05409a179cbe21f280317cc 100644 --- a/DDCore/include/DD4hep/objects/AlignmentsInterna.h +++ b/DDCore/include/DD4hep/objects/AlignmentsInterna.h @@ -93,14 +93,24 @@ namespace DD4hep { public: /// Cached pointer to the bound conditions data, since these may be accessed very frequently AlignmentData* alignment_data = 0; - /// Accessor to the alignment data - AlignmentData& values(); + /// Reference to the source conditions object + key_type source_key = 0; + + public: + /// Default constructor + AlignmentConditionObject(); + /// Copy constructor + AlignmentConditionObject(const AlignmentConditionObject& copy) = delete; /// Standard constructor AlignmentConditionObject(const std::string& nam,const std::string& tit=""); /// Standard Destructor virtual ~AlignmentConditionObject(); + /// Assignment operator + AlignmentConditionObject& operator=(const AlignmentConditionObject& copy) = delete; /// Clear data void clear(); + /// Accessor to the alignment data. Cannot be NULL. Initialized in the constructor(s) + AlignmentData& values() { return *alignment_data; } }; /// The data class behind an alignments container handle. @@ -149,9 +159,27 @@ namespace DD4hep { public: /// Known keys of alignments in this container Keys keys; + + /// Insert a new key to the alignments access map. Ignores already existing keys. + /** Caution: This is not thread protected! + * + * @return true if key was inserted. False otherwise. + */ + bool insertKey(const std::string& key_val); + + /// Insert a new key to the alignments access map: Allow for alias if key_val != data_val + /** Caution: This is not thread protected! + * + * @return true if key was inserted. False otherwise. + */ + bool insertKey(const std::string& key_val, const std::string& data_val); + /// Add a new key to the alignments access map + /** Caution: This is not thread protected! */ void addKey(const std::string& key_value); + /// Add a new key to the alignments access map: Allow for alias if key_val != data_val + /** Caution: This is not thread protected! */ void addKey(const std::string& key_value, const std::string& data_value); }; diff --git a/DDCore/include/DD4hep/objects/ConditionsInterna.h b/DDCore/include/DD4hep/objects/ConditionsInterna.h index 82e1ae11dc66294c268e0a0a028bd555be3140be..e30eef9cf539fe72f7d929222a933151007ff63d 100644 --- a/DDCore/include/DD4hep/objects/ConditionsInterna.h +++ b/DDCore/include/DD4hep/objects/ConditionsInterna.h @@ -113,31 +113,40 @@ namespace DD4hep { /// Data block OpaqueDataBlock data; /// Reference to conditions pool - ConditionsPool* pool; + ConditionsPool* pool = 0; /// Interval of validity - const iov_type* iov; + const iov_type* iov = 0; /// Hash value of the name - key_type hash; + key_type hash = 0; /// Flags - mask_type flags; + mask_type flags = 0; /// Reference count - int refCount; + int refCount = 0; + /// Default constructor + ConditionObject(); /// Standard constructor - ConditionObject(const std::string& nam="",const std::string& tit=""); + ConditionObject(const std::string& nam,const std::string& tit=""); /// Standard Destructor virtual ~ConditionObject(); + /// Data offset from the opaque data block pointer to the condition + static size_t offset(); /// Move data content: 'from' will be reset to NULL ConditionObject& move(ConditionObject& from); /// Access safely the IOV const iov_type* iovData() const; /// Access safely the IOV-type const IOVType* iovType() const; + /// Access the bound data payload. Exception id object is unbound + void* payload() const; /// Check if object is already bound.... - bool is_bound() const { return data.is_bound(); } - bool is_traced() const { return true; } - void setFlag(int option) { flags |= option; } - void unFlag(int option) { flags &= ~option; } - bool testFlag(int option) const { return 0 != (flags&option); } + bool is_bound() const { return data.is_bound(); } + bool is_traced() const { return true; } + /// Flag operations + void setFlag(mask_type option) { flags |= option; } + void unFlag(mask_type option) { flags &= ~option; } + bool testFlag(mask_type option) const { return 0 != (flags&option); } + void validate() { setFlag(Condition::ACTIVE); } + void invalidate() { unFlag(Condition::ACTIVE); } }; /// The data class behind a conditions container handle. @@ -187,9 +196,26 @@ namespace DD4hep { /// Known keys of conditions in this container Keys keys; + /// Insert a new key to the conditions access map. Ignores already existing keys. + /** Caution: This is not thread protected! + * + * @return true if key was inserted. False if already present. + */ + bool insertKey(const std::string& key_val); + + /// Insert a new key to the conditions access map: Allow for alias if key_val != data_val + /** Caution: This is not thread protected! + * + * @return true if key was inserted. False if already present. + */ + bool insertKey(const std::string& key_val, const std::string& data_val); + /// Add a new key to the conditions access map + /** Caution: This is not thread protected! */ void addKey(const std::string& key_value); + /// Add a new key to the conditions access map: Allow for alias if key_val != data_val + /** Caution: This is not thread protected! */ void addKey(const std::string& key_value, const std::string& data_value); }; diff --git a/DDCore/src/Alignments.cpp b/DDCore/src/Alignments.cpp index 0aad46671651cba13b31a9120393ef8c9859be20..9c20c73325178936b3ef27e6387928c1ff606ecf 100644 --- a/DDCore/src/Alignments.cpp +++ b/DDCore/src/Alignments.cpp @@ -57,6 +57,19 @@ namespace DD4hep { Alignment::Processor::Processor() { } +/// Access the hash identifier +Alignment::key_type Alignment::key() const { + // If the alignment is bound to a condition, the key is the same as the one of the condition. + // Otherwise the key is invalid and an exception is thrown + Conditions::Condition cond = access()->condition; + return cond.access()->hash; +} + +/// Access the bound condition if the alignment is bound to a condition. Otherwise NULL. +AlignmentCondition Alignment::condition() const { + return AlignmentCondition(data().condition); +} + /// Create cached matrix to transform to world coordinates const TGeoHMatrix& Alignment::worldTransformation() const { return data().worldTransformation(); @@ -182,6 +195,16 @@ const Container::Keys& Container::keys() const { return access()->keys; } +/// Insert a new key to the alignments access map. Ignores already existing keys. +bool Container::insertKey(const std::string& key_val) { + return access()->insertKey(key_val); +} + +/// Insert a new key to the alignments access map: Allow for alias if key_val != data_val +bool Container::insertKey(const std::string& key_val, const std::string& data_val) { + return access()->insertKey(key_val, data_val); +} + /// Add a new key to the alignments access map void Container::addKey(const string& key_val) { access()->addKey(key_val); diff --git a/DDCore/src/AlignmentsInterna.cpp b/DDCore/src/AlignmentsInterna.cpp index b41506c7c91b9c010369c9620174212ab2c3fc47..99f5de27162dd2cbd4f1617bf0d5cec956856c31 100644 --- a/DDCore/src/AlignmentsInterna.cpp +++ b/DDCore/src/AlignmentsInterna.cpp @@ -30,12 +30,26 @@ DD4HEP_INSTANTIATE_HANDLE_NAMED(AlignmentNamedObject); DD4HEP_INSTANTIATE_HANDLE_NAMED(AlignmentContainer); DD4HEP_INSTANTIATE_HANDLE_UNNAMED(AlignmentData); +/// Default constructor +AlignmentConditionObject::AlignmentConditionObject() + : ConditionObject(), alignment_data(0), source_key(0) +{ + InstanceCount::increment(this); + flags = Conditions::Condition::ALIGNMENT; + Alignment::Data& d = Conditions::Condition(this).bind<Alignment::Data>(); + d.condition = this; + alignment_data = &d; +} + /// Standard constructor AlignmentConditionObject::AlignmentConditionObject(const string& nam, const string& tit) - : ConditionObject(nam, tit), alignment_data(0) + : ConditionObject(nam, tit), alignment_data(0), source_key(0) { InstanceCount::increment(this); flags = Conditions::Condition::ALIGNMENT; + Alignment::Data& d = Conditions::Condition(this).bind<Alignment::Data>(); + d.condition = this; + alignment_data = &d; } /// Standard Destructor @@ -43,16 +57,6 @@ AlignmentConditionObject::~AlignmentConditionObject() { InstanceCount::decrement(this); } -/// Accessor to the alignment data -Alignment::Data& AlignmentConditionObject::values() { - if ( alignment_data ) - return *alignment_data; - Conditions::Condition c(this); - alignment_data = c.is_bound() ? &c.get<Alignment::Data>() : &c.bind<Alignment::Data>(); - alignment_data->condition = c; - return *alignment_data; -} - /// Clear data content on demand. void AlignmentConditionObject::clear() { AlignmentCondition a(this); @@ -76,6 +80,19 @@ AlignmentContainer::~AlignmentContainer() { InstanceCount::decrement(this); } +/// Insert a new key to the alignments access map. Ignores already existing keys. +bool AlignmentContainer::insertKey(const std::string& key_val) { + key_type hash = Alignment::hashCode(key_val); + return keys.insert(make_pair(hash,make_pair(hash,key_val))).second; +} + +/// Insert a new key to the alignments access map: Allow for alias if key_val != data_val +bool AlignmentContainer::insertKey(const std::string& key_val, const std::string& data_val) { + key_type key_hash = Alignment::hashCode(key_val); + key_type val_hash = Alignment::hashCode(data_val); + return keys.insert(make_pair(key_hash,make_pair(val_hash,data_val))).second; +} + /// Add a new key to the alignments access map void AlignmentContainer::addKey(const string& key_val) { key_type hash = Alignment::hashCode(key_val); diff --git a/DDCore/src/Conditions.cpp b/DDCore/src/Conditions.cpp index b1ca801745089324a8f408a85f7486e32ce1fc82..06a11a99ade635652143190ee6e5d786de1a3000 100644 --- a/DDCore/src/Conditions.cpp +++ b/DDCore/src/Conditions.cpp @@ -150,6 +150,16 @@ const Container::Keys& Container::keys() const { return access()->keys; } +/// Insert a new key to the conditions access map. Ignores already existing keys. +bool Container::insertKey(const std::string& key_val) { + return access()->insertKey(key_val); +} + +/// Insert a new key to the conditions access map: Allow for alias if key_val != data_val +bool Container::insertKey(const std::string& key_val, const std::string& data_val) { + return access()->insertKey(key_val, data_val); +} + /// Add a new key to the conditions access map void Container::addKey(const string& key_val) { access()->addKey(key_val); diff --git a/DDCore/src/ConditionsInterna.cpp b/DDCore/src/ConditionsInterna.cpp index af348ea48a6c667ebc106e825cd82194bb6b385f..09fb3aba53bdb5b426330e973318fe37d3dbd35f 100644 --- a/DDCore/src/ConditionsInterna.cpp +++ b/DDCore/src/ConditionsInterna.cpp @@ -26,11 +26,18 @@ using namespace DD4hep::Conditions; DD4HEP_INSTANTIATE_HANDLE_NAMED(Interna::ConditionObject); DD4HEP_INSTANTIATE_HANDLE_NAMED(Interna::ConditionContainer); +/// Default constructor +Interna::ConditionObject::ConditionObject() + : NamedObject(), value(), validity(), address(), comment(), + data(), pool(0), iov(0), hash(0), flags(0), refCount(0) +{ + InstanceCount::increment(this); +} + /// Standard constructor Interna::ConditionObject::ConditionObject(const string& nam,const string& tit) : NamedObject(nam, tit), value(), validity(), address(), comment(), - data(), pool(0), iov(0), - hash(0), flags(0), refCount(0) + data(), pool(0), iov(0), hash(0), flags(0), refCount(0) { InstanceCount::increment(this); } @@ -40,6 +47,19 @@ Interna::ConditionObject::~ConditionObject() { InstanceCount::decrement(this); } +/// Data offset from the opaque data block pointer to the condition +size_t Interna::ConditionObject::offset() { + ConditionObject* o = (ConditionObject*)(0x1000); + size_t off = ((char*)&o->data.grammar) - ((char*)o) + sizeof(o->data.grammar); + return off; +} + +/// Access the bound data payload. Exception id object is unbound +void* Interna::ConditionObject::payload() const { + void** p = (void**)(((char*)this)+offset()); + return p ? *p : 0; +} + /// Move data content: 'from' will be reset to NULL Interna::ConditionObject& Interna::ConditionObject::move(ConditionObject& /* from */) { return *this; @@ -71,6 +91,19 @@ Interna::ConditionContainer::~ConditionContainer() { InstanceCount::decrement(this); } +/// Insert a new key to the conditions access map. Ignores already existing keys. +bool Interna::ConditionContainer::insertKey(const std::string& key_val) { + key_type hash = ConditionKey::hashCode(key_val); + return keys.insert(make_pair(hash,make_pair(hash,key_val))).second; +} + +/// Insert a new key to the conditions access map: Allow for alias if key_val != data_val +bool Interna::ConditionContainer::insertKey(const std::string& key_val, const std::string& data_val) { + key_type key_hash = ConditionKey::hashCode(key_val); + key_type val_hash = ConditionKey::hashCode(data_val); + return keys.insert(make_pair(key_hash,make_pair(val_hash,data_val))).second; +} + /// Add a new key to the conditions access map void Interna::ConditionContainer::addKey(const string& key_val) { key_type hash = ConditionKey::hashCode(key_val); diff --git a/DDCore/src/DetConditions.cpp b/DDCore/src/DetConditions.cpp index b5bf8ec6a29dfc23e0854830c7fa880380039b80..40798825f65e081ef14c0dd82edb2d09169d7d9c 100644 --- a/DDCore/src/DetConditions.cpp +++ b/DDCore/src/DetConditions.cpp @@ -1,4 +1,3 @@ -// $Id$ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDCore/src/OpaqueData.cpp b/DDCore/src/OpaqueData.cpp index 32feeda184da1888125fcf81f58ddb9450536ee1..0b36ce059ebd2186b18efacf3ccce7880b81397d 100644 --- a/DDCore/src/OpaqueData.cpp +++ b/DDCore/src/OpaqueData.cpp @@ -1,4 +1,3 @@ -// $Id$ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -25,27 +24,6 @@ using namespace std; using namespace DD4hep; -/// Standard initializing constructor -OpaqueData::OpaqueData() : grammar(0), pointer(0) { -} - -/// Copy constructor -OpaqueData::OpaqueData(const OpaqueData& c) : grammar(c.grammar), pointer(c.pointer) { -} - -/// Standard Destructor -OpaqueData::~OpaqueData() { -} - -/// Assignment operator -OpaqueData& OpaqueData::operator=(const OpaqueData& c) { - if ( &c != this ) { - grammar = c.grammar; - pointer = c.pointer; - } - return *this; -} - /// Create data block from string representation bool OpaqueData::fromString(const string& rep) { if ( pointer && grammar ) { diff --git a/DDCore/src/Plugins.cpp b/DDCore/src/Plugins.cpp index 3bc5de85deb93fbbd5f4f8f3c639300aa8631405..42cfd47db57459fce663f1f803f07990c3e74b56 100644 --- a/DDCore/src/Plugins.cpp +++ b/DDCore/src/Plugins.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -85,8 +84,8 @@ namespace { void* creator_stub, const char* signature, const char* return_type); - PluginInterface(); - static PluginInterface& instance() { + PluginInterface() throw(std::exception); + static PluginInterface& instance() throw(std::exception) { static PluginInterface s_instance; return s_instance; } @@ -111,7 +110,9 @@ namespace { return fp.fptr.fcn; } - PluginInterface::PluginInterface() : getDebug(0), setDebug(0), create(0), add(0) { + PluginInterface::PluginInterface() throw(std::exception) + : getDebug(0), setDebug(0), create(0), add(0) + { void* handle = 0; const char* plugin_name = ::getenv("DD4HEP_PLUGINMGR"); if ( 0 == plugin_name ) { diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index 62e45ba4a4e6224ddaef31744399e2c0725cf49d..7bd98e634b81f32eecac0c9edfd02a3bd014fffe 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -708,9 +708,8 @@ template <int flag> long dump_detelement_tree(LCDD& lcdd, int argc, char** argv) PlacedVolume place = de.placement(); const TGeoNode* node = place.ptr(); char sens = place.volume().isSensitive() ? 'S' : ' '; - int value = flag; char fmt[128]; - switch(value) { + switch(flag) { case 0: if ( de.placement() == de.idealPlacement() ) { ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s NumDau:%%d VolID:%%08X Place:%%p %%c",level+1,2*level+1); diff --git a/DDDB/src/DDDBAlignmentTestEx.cpp b/DDDB/src/DDDBAlignmentTestEx.cpp index 65b398df3d3351126845cc90cb8792814bb2cf4b..86c6473719fde319f240dc32fa7bdffaa7440cb8 100644 --- a/DDDB/src/DDDBAlignmentTestEx.cpp +++ b/DDDB/src/DDDBAlignmentTestEx.cpp @@ -75,7 +75,7 @@ namespace { key.name.c_str(), det.level(), det.path().c_str()); if ( par.typeInfo() == typeid(Data::Delta) ) { const Data::Delta& delta = src.first<Data::Delta>(); - return AlignmentsUpdateCall::handle(key, context, delta); + return AlignmentsUpdateCall::handle(key, context, cond.key(), delta); } // Somehow the condition is not of type Data::Delta. This is an ERROR. // Here only print and return an empty alignment condition. diff --git a/DDDB/src/DDDBAlignmentUpdateCall.cpp b/DDDB/src/DDDBAlignmentUpdateCall.cpp index 2fc87f0c37beb7a1da0ed2f94bea3c9ad7f9fada..94c6aad81c72050b610030044903065630b1dffa 100644 --- a/DDDB/src/DDDBAlignmentUpdateCall.cpp +++ b/DDDB/src/DDDBAlignmentUpdateCall.cpp @@ -38,7 +38,7 @@ DDDB::DDDBAlignmentUpdateCall::operator()(const ConditionKey& key, const UpdateC key.name.c_str(), det.level(), det.path().c_str()); if ( par.typeInfo() == typeid(Data::Delta) ) { const Data::Delta& delta = src.first<Data::Delta>(); - return AlignmentsUpdateCall::handle(key, context, delta); + return AlignmentsUpdateCall::handle(key, context, cond.key(), delta); } // Somehow the condition is not of type Data::Delta. This is an ERROR. // Here only print and return an empty alignment condition. diff --git a/DDEve/CMakeLists.txt b/DDEve/CMakeLists.txt index 36d38843dc674266de5e3a7c1c4bd2e810193c99..de0139faaf23a663cc5eb9db6ec38dd1811a7e18 100644 --- a/DDEve/CMakeLists.txt +++ b/DDEve/CMakeLists.txt @@ -1,4 +1,3 @@ -# $Id: $ #========================================================================== # AIDA Detector description implementation for LCD #-------------------------------------------------------------------------- diff --git a/DDEve/include/DDEve/Annotation.h b/DDEve/include/DDEve/Annotation.h index 7c1d45a7510e15f69505f2fbc658c699a67b1541..a9f8745c0875a7ab9d3eb5aa1b4dc31beb2871cd 100644 --- a/DDEve/include/DDEve/Annotation.h +++ b/DDEve/include/DDEve/Annotation.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -45,7 +44,6 @@ namespace DD4hep { /// Default margin for placement in bottom left corner static float DefaultMargin(); }; - -} /* End namespace DD4hep */ +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_ANNOTATION_H */ diff --git a/DDEve/include/DDEve/Calo2DProjection.h b/DDEve/include/DDEve/Calo2DProjection.h index 86a6aab15a6e1685032cbb7fd0e98ae93d99cfea..4912aad74d6c8a91a26872792abc29954e6aedd2 100644 --- a/DDEve/include/DDEve/Calo2DProjection.h +++ b/DDEve/include/DDEve/Calo2DProjection.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -40,18 +39,17 @@ namespace DD4hep { /// Default destructor virtual ~Calo2DProjection(); /// Build the projection view and map it to the given slot - virtual View& Build(TEveWindow* slot); + virtual View& Build(TEveWindow* slot) override; /// Configure a single geometry view - virtual void ConfigureGeometry(const DisplayConfiguration::ViewConfig& config); + virtual void ConfigureGeometry(const DisplayConfiguration::ViewConfig& config) override; /// Configure a single event scene view - virtual void ConfigureEvent(const DisplayConfiguration::ViewConfig& config); + virtual void ConfigureEvent(const DisplayConfiguration::ViewConfig& config) override; /// Call to import geometry topics - void ImportGeoTopics(const std::string& title); + void ImportGeoTopics(const std::string& title) override; /// Root implementation macro - ClassDef(Calo2DProjection,0); + ClassDefOverride(Calo2DProjection,0); }; -} /* End namespace DD4hep */ - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_CALO2DPROJECTION_H */ diff --git a/DDEve/include/DDEve/Calo3DProjection.h b/DDEve/include/DDEve/Calo3DProjection.h index a4660cbf220f58dfaef9503390411cbb838b9b84..c0afffc7c68207873eb0f1d66c487c3f68626e7f 100644 --- a/DDEve/include/DDEve/Calo3DProjection.h +++ b/DDEve/include/DDEve/Calo3DProjection.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -40,13 +39,12 @@ namespace DD4hep { /// Default destructor virtual ~Calo3DProjection(); /// Build the projection view and map it to the given slot - virtual View& Build(TEveWindow* slot); + virtual View& Build(TEveWindow* slot) override; /// Root implementation macro - ClassDef(Calo3DProjection,0); + ClassDefOverride(Calo3DProjection,0); }; -} /* End namespace DD4hep */ - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_CALO3DPROJECTION_H */ diff --git a/DDEve/include/DDEve/CaloLego.h b/DDEve/include/DDEve/CaloLego.h index c8e706a5ba844f49c130ab36e27a0cc0cfd52320..67ef45bf10ce578184ee06e593626984512ff076 100644 --- a/DDEve/include/DDEve/CaloLego.h +++ b/DDEve/include/DDEve/CaloLego.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -41,18 +40,16 @@ namespace DD4hep { /// Default destructor virtual ~CaloLego(); /// Build the projection view and map it to the given slot - virtual View& Build(TEveWindow* slot); + virtual View& Build(TEveWindow* slot) override; /// Configure a single geometry view - virtual void ConfigureGeometry(const DisplayConfiguration::ViewConfig& config); + virtual void ConfigureGeometry(const DisplayConfiguration::ViewConfig& config) override; /// Configure a single event scene view - virtual void ConfigureEvent(const DisplayConfiguration::ViewConfig& config); + virtual void ConfigureEvent(const DisplayConfiguration::ViewConfig& config) override; /// Call to import geometry topics - void ImportGeoTopics(const std::string& title); + void ImportGeoTopics(const std::string& title) override; /// Root implementation macro - ClassDef(CaloLego,0); + ClassDefOverride(CaloLego,0); }; - -} /* End namespace DD4hep */ - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_CALOLEGO_H */ diff --git a/DDEve/include/DDEve/ContextMenu.h b/DDEve/include/DDEve/ContextMenu.h index 09e9920e3b794c5daa48aeeee3b732cbaa5f3bc7..959285faa515d9801e2d0673cf527d927602e99c 100644 --- a/DDEve/include/DDEve/ContextMenu.h +++ b/DDEve/include/DDEve/ContextMenu.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -49,7 +48,7 @@ namespace DD4hep { /// Callback void Context(TObject* target); /// Root implementation macro - ClassDef(ContextMenuHandler,0); + ClassDefOverride(ContextMenuHandler,0); }; diff --git a/DDEve/include/DDEve/DD4hepMenu.h b/DDEve/include/DDEve/DD4hepMenu.h index 66ee660cbd9e9107b3559d4f480623a9e0a7297a..0f472bacc291783e7386f1c58e8b9c45b62302d5 100644 --- a/DDEve/include/DDEve/DD4hepMenu.h +++ b/DDEve/include/DDEve/DD4hepMenu.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -49,7 +48,7 @@ namespace DD4hep { virtual ~DD4hepMenu(); /// Add the menu to the menu bar - virtual void Build(TGMenuBar* bar, int hints=kLHintsNormal); + virtual void Build(TGMenuBar* bar, int hints=kLHintsNormal) override; /// Callback when loading the configuration void OnLoadXML(TGMenuEntry* entry, void* ptr); /// Callback when loading the configuration @@ -68,11 +67,9 @@ namespace DD4hep { /// Callback when the geometry was loaded void OnGeometryLoaded(); /// ROOT implementation macro - ClassDef(DD4hepMenu,0); + ClassDefOverride(DD4hepMenu,0); }; -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_DD4HEPMENU_H */ diff --git a/DDEve/include/DDEve/DDEveEventData.h b/DDEve/include/DDEve/DDEveEventData.h index 99ed15c5720863c105cf562c099fa02bbac96ab7..aeb5c4b408b2cadf19543ac1666732aba176f775 100644 --- a/DDEve/include/DDEve/DDEveEventData.h +++ b/DDEve/include/DDEve/DDEveEventData.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -72,8 +71,6 @@ namespace DD4hep { DDEveParticle& operator=(const DDEveParticle& c); }; typedef std::vector<DDEveParticle> DDEveParticles; -} /* End namespace DD4hep */ - - -#endif /* DD4HEP_DDEVE_DDEVEHIT_H */ +} /* End namespace DD4hep */ +#endif /* DD4HEP_DDEVE_DDEVEHIT_H */ diff --git a/DDEve/include/DDEve/DDG4EventHandler.h b/DDEve/include/DDEve/DDG4EventHandler.h index 2b46e8f442b7b13d39363704b23ac7a7006a9def..87b54f726567deeba289e8ec4767743dc0684278 100644 --- a/DDEve/include/DDEve/DDG4EventHandler.h +++ b/DDEve/include/DDEve/DDG4EventHandler.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -60,34 +59,31 @@ namespace DD4hep { virtual ~DDG4EventHandler(); /// Access the map of simulation data collections - virtual const TypedEventCollections& data() const { return m_data; } + virtual const TypedEventCollections& data() const override { return m_data; } /// Access the number of events on the current input data source (-1 if no data source connected) - virtual long numEvents() const; + virtual long numEvents() const override; /// Access the data source name - std::string datasourceName() const; + std::string datasourceName() const override; /// Access to the collection type by name - virtual CollectionType collectionType(const std::string& collection) const; + virtual CollectionType collectionType(const std::string& collection) const override; /// Call functor on hit collection - virtual size_t collectionLoop(const std::string& collection, DDEveHitActor& actor); + virtual size_t collectionLoop(const std::string& collection, DDEveHitActor& actor) override; /// Loop over collection and extract particle data - virtual size_t collectionLoop(const std::string& collection, DDEveParticleActor& actor); + virtual size_t collectionLoop(const std::string& collection, DDEveParticleActor& actor) override; /// Open new data file - virtual bool Open(const std::string& type, const std::string& file_name); + virtual bool Open(const std::string& type, const std::string& file_name) override; /// User overloadable function: Load the next event - virtual bool NextEvent(); + virtual bool NextEvent() override; /// User overloadable function: Load the previous event - virtual bool PreviousEvent(); + virtual bool PreviousEvent() override; /// Goto a specified event in the file - virtual bool GotoEvent(long event_number); + virtual bool GotoEvent(long event_number) override; /// Load the specified event Int_t ReadEvent(Long64_t n); - ClassDef(DDG4EventHandler,0); + ClassDefOverride(DDG4EventHandler,0); }; - -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_DDG4EVENTHANDLER_H */ diff --git a/DDEve/include/DDEve/Dictionary.h b/DDEve/include/DDEve/Dictionary.h index df6e75e18d012194a0ff33094fc2c404642f9ade..ffd03d08ed4a47bb350c7cd160f23881c54a61cb 100644 --- a/DDEve/include/DDEve/Dictionary.h +++ b/DDEve/include/DDEve/Dictionary.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDEve/include/DDEve/Display.h b/DDEve/include/DDEve/Display.h index 19d82581ffe7c4d06174abf3383a71f9f8373ffd..e1296400cc12ab248f08c1c079005ba508177acf 100644 --- a/DDEve/include/DDEve/Display.h +++ b/DDEve/include/DDEve/Display.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -190,20 +189,18 @@ namespace DD4hep { /// Call to import event elements by topic void ImportEvent(const std::string& topic, TEveElement* el); + /// Consumer overload: open file + virtual void OnFileOpen(EventHandler& handler) override; /// EventConsumer overload: Consumer event data - virtual void OnNewEvent(EventHandler* handler); + virtual void OnNewEvent(EventHandler& handler) override; /// Build the DDEve specific menues. Default bar is the ROOT browser's bar virtual void BuildMenus(TGMenuBar* bar=0); /// Add new menu to the main menu bar virtual void AddMenu(TGMenuBar* bar, PopupMenu* menu, int hints=kLHintsNormal); - ClassDef(Display,0); + ClassDefOverride(Display,0); }; - - -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_DISPLAY_H */ diff --git a/DDEve/include/DDEve/DisplayConfiguration.h b/DDEve/include/DDEve/DisplayConfiguration.h index 268d6223fb35758e189ed40266052ffbf691378f..311f8cf4793fdc1d7894927d66547839c6170fef 100644 --- a/DDEve/include/DDEve/DisplayConfiguration.h +++ b/DDEve/include/DDEve/DisplayConfiguration.h @@ -124,8 +124,6 @@ namespace DD4hep { /// Root implementation macro ClassDef(DisplayConfiguration,0); }; - -} /* End namespace DD4hep */ - -#endif /* DD4HEP_DDEVE_DISPLAYCONFIGURATION_H */ +} /* End namespace DD4hep */ +#endif /* DD4HEP_DDEVE_DISPLAYCONFIGURATION_H */ diff --git a/DDEve/include/DDEve/ElementList.h b/DDEve/include/DDEve/ElementList.h index cc5357862e6ada9ea7717ad880894f63b5401e66..f5ace2f6cda4e02e687ba479449e48264ac161f7 100644 --- a/DDEve/include/DDEve/ElementList.h +++ b/DDEve/include/DDEve/ElementList.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -44,9 +43,9 @@ namespace DD4hep { /// Default destructor virtual ~ElementList(); /// Clone object: Overload from TEveElementList - virtual TEveElementList* CloneElement() const; + virtual TEveElementList* CloneElement() const override; /// Root implementation macro - ClassDef(ElementList,0); + ClassDefOverride(ElementList,0); }; /// DDEve context menu class @@ -68,7 +67,5 @@ namespace DD4hep { ClassDef(ElementListContextMenu,0); }; -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_ELEMENTLIST_H */ diff --git a/DDEve/include/DDEve/EvePgonSetProjectedContextMenu.h b/DDEve/include/DDEve/EvePgonSetProjectedContextMenu.h index 965afe6209d484e55a45a33f1a7c1a1567023678..5fccae904289668566a7521da4c25c4010f93c18 100644 --- a/DDEve/include/DDEve/EvePgonSetProjectedContextMenu.h +++ b/DDEve/include/DDEve/EvePgonSetProjectedContextMenu.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -36,11 +35,7 @@ namespace DD4hep { /// Instantiator static EvePgonSetProjectedContextMenu& install(Display* m); /// Root implementation macro - ClassDef(EvePgonSetProjectedContextMenu,0); + ClassDefOverride(EvePgonSetProjectedContextMenu,0); }; - - -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_EVEPGONSETPROJECTEDCONTEXTMENU_H */ diff --git a/DDEve/include/DDEve/EveShapeContextMenu.h b/DDEve/include/DDEve/EveShapeContextMenu.h index b31c361ea82285a2672b654fbc8d3c0e00d9d724..4a09c30740a3d77b39d0c9f1b596b3cecf07a2dc 100644 --- a/DDEve/include/DDEve/EveShapeContextMenu.h +++ b/DDEve/include/DDEve/EveShapeContextMenu.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -36,11 +35,7 @@ namespace DD4hep { /// Instantiator static EveShapeContextMenu& install(Display* m); /// Root implementation macro - ClassDef(EveShapeContextMenu,0); + ClassDefOverride(EveShapeContextMenu,0); }; - - -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_EVESHAPECONTEXTMENU_H */ diff --git a/DDEve/include/DDEve/EveUserContextMenu.h b/DDEve/include/DDEve/EveUserContextMenu.h index 1cef1a7a2383f11190b763cb5e575f1704c1a0de..e3e501748b4cc39172a16f6bd3356aede1a0d0be 100644 --- a/DDEve/include/DDEve/EveUserContextMenu.h +++ b/DDEve/include/DDEve/EveUserContextMenu.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -74,6 +73,5 @@ namespace DD4hep { /// Root implementation macro ClassDef(EveUserContextMenu,0); }; -} /* End namespace DD4hep */ - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_EVEUSERCONTEXTMENU_H */ diff --git a/DDEve/include/DDEve/EventControl.h b/DDEve/include/DDEve/EventControl.h index 96bd6dedb745421090c77ea0b96c7a34fcb3210e..8d8ccc80306713892bb6c5382c6872f391a1aa4d 100644 --- a/DDEve/include/DDEve/EventControl.h +++ b/DDEve/include/DDEve/EventControl.h @@ -57,9 +57,9 @@ namespace DD4hep { virtual ~EventControl(); /// User callback to add elements to the control - virtual void OnBuild(); + virtual void OnBuild() override; /// Create the frame for this control structure. Default: create horizontal frame - TGCompositeFrame* CreateFrame(); + TGCompositeFrame* CreateFrame() override; /// Open a new event data file virtual bool Open(); @@ -72,17 +72,13 @@ namespace DD4hep { /// EventConsumer overload: New consumer event data - virtual void OnNewEvent(EventHandler* handler); + virtual void OnNewEvent(EventHandler& handler) override; /// EventConsumer overload: New event data file - virtual void OnFileOpen(EventHandler* handler); + virtual void OnFileOpen(EventHandler& handler) override; - ClassDef(EventControl,0) // Top level window frame + ClassDefOverride(EventControl,0) // Top level window frame }; - - -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_EVENTCONTROL_H */ diff --git a/DDEve/include/DDEve/EventHandler.h b/DDEve/include/DDEve/EventHandler.h index 026172171a718f35f73bf64236b2c51faf3018a4..108be95ef07879b517ddd7d9ffe7bf0bb4d7fd1b 100644 --- a/DDEve/include/DDEve/EventHandler.h +++ b/DDEve/include/DDEve/EventHandler.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -80,12 +79,12 @@ namespace DD4hep { protected: /// Flag to indicate that a file is opened - bool m_hasFile; + bool m_hasFile = false; /// Flag to indicate that an event is loaded - bool m_hasEvent; + bool m_hasEvent = false; public: /// Standard constructor - EventHandler(); + EventHandler() = default; /// Default destructor virtual ~EventHandler(); /// Check if an event is present in memory @@ -124,19 +123,16 @@ namespace DD4hep { class EventConsumer { public: /// Standard constructor - EventConsumer(); + EventConsumer() = default; /// Default destructor virtual ~EventConsumer(); /// Consumer event data callback - virtual void OnNewEvent(EventHandler* /* handler */) {} + virtual void OnNewEvent(EventHandler& /* handler */) = 0; /// Consumer file open callback - virtual void OnFileOpen(EventHandler* /* handler */) {} + virtual void OnFileOpen(EventHandler& /* handler */) = 0; ClassDef(EventConsumer,0); }; - -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_EVENTHANDLER_H */ diff --git a/DDEve/include/DDEve/Factories.h b/DDEve/include/DDEve/Factories.h index 409a7f07a1a0aa81a4b8e493a4dd7fbe3d54e41a..6b4155a6111acd49f08170dff325694c1c8c222f 100644 --- a/DDEve/include/DDEve/Factories.h +++ b/DDEve/include/DDEve/Factories.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDEve/include/DDEve/FrameControl.h b/DDEve/include/DDEve/FrameControl.h index 33a0c778cf3a19a3fc81c58efc2bc5cf3b05915d..a714a9b762df70b047b5172fecb22d66a0c3de79 100644 --- a/DDEve/include/DDEve/FrameControl.h +++ b/DDEve/include/DDEve/FrameControl.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -64,12 +63,8 @@ namespace DD4hep { /// Helper: Load picture using path name virtual const TGPicture* LoadPicture(const std::string& path); - ClassDef(FrameControl,0) // Top level window frame + ClassDefOverride(FrameControl,0) // Top level window frame }; - - -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_FRAMECONTROL_H */ diff --git a/DDEve/include/DDEve/GenericEventHandler.h b/DDEve/include/DDEve/GenericEventHandler.h index c995558b0c378b249d3f0c8e80c8c9d0b5e61937..8a42ca81a2e1e6f4f6b9a40b8226af41cc4c0c27 100644 --- a/DDEve/include/DDEve/GenericEventHandler.h +++ b/DDEve/include/DDEve/GenericEventHandler.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -44,25 +43,25 @@ namespace DD4hep { /// Default destructor virtual ~GenericEventHandler(); /// Access the map of simulation data collections - virtual const TypedEventCollections& data() const { return current()->data(); } + virtual const TypedEventCollections& data() const override { return current()->data(); } /// Access the number of events on the current input data source (-1 if no data source connected) - virtual long numEvents() const; + virtual long numEvents() const override; /// Access the data source name - virtual std::string datasourceName() const; + virtual std::string datasourceName() const override; /// Access to the collection type by name - virtual CollectionType collectionType(const std::string& collection) const; + virtual CollectionType collectionType(const std::string& collection) const override; /// Loop over collection and extract data - virtual size_t collectionLoop(const std::string& collection, DDEveHitActor& actor); + virtual size_t collectionLoop(const std::string& collection, DDEveHitActor& actor) override; /// Loop over collection and extract particle data - virtual size_t collectionLoop(const std::string& collection, DDEveParticleActor& actor); + virtual size_t collectionLoop(const std::string& collection, DDEveParticleActor& actor) override; /// Open a new event data file - virtual bool Open(const std::string& type, const std::string& file_name); + virtual bool Open(const std::string& type, const std::string& file_name) override; /// Load the next event - virtual bool NextEvent(); + virtual bool NextEvent() override; /// User overloadable function: Load the previous event - virtual bool PreviousEvent(); + virtual bool PreviousEvent() override; /// Goto a specified event in the file - virtual bool GotoEvent(long event_number); + virtual bool GotoEvent(long event_number) override; /// Subscribe to notification of new data present virtual void Subscribe(EventConsumer* display); /// Unsubscribe from notification of new data present @@ -70,10 +69,10 @@ namespace DD4hep { #ifndef __CINT__ /// Notfy all subscribers - virtual void NotifySubscribers(void (EventConsumer::*pmf)(EventHandler*)); + virtual void NotifySubscribers(void (EventConsumer::*pmf)(EventHandler&)); #endif - ClassDef(GenericEventHandler,0); + ClassDefOverride(GenericEventHandler,0); }; } /* End namespace DD4hep */ diff --git a/DDEve/include/DDEve/HitActors.h b/DDEve/include/DDEve/HitActors.h index b080caca28ae7c1eee127cd1461afbd044ad99f5..1969e202838ef78c87b9fe104fa43b22c5e660b3 100644 --- a/DDEve/include/DDEve/HitActors.h +++ b/DDEve/include/DDEve/HitActors.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDEve/include/DDEve/MultiView.h b/DDEve/include/DDEve/MultiView.h index ede90e14b6ce6796e5204f0a49235cdb1ed6f271..bd46b21a5b3fb18532626b27d8d8ddfb2e286568 100644 --- a/DDEve/include/DDEve/MultiView.h +++ b/DDEve/include/DDEve/MultiView.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -37,11 +36,9 @@ namespace DD4hep { /// Default destructor virtual ~MultiView(); /// Build the 3d view and map it to the given slot - virtual View& Build(TEveWindow* slot); + virtual View& Build(TEveWindow* slot) override; /// Root implementation macro - ClassDef(MultiView,0); + ClassDefOverride(MultiView,0); }; -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_MULTIVIEW_H */ diff --git a/DDEve/include/DDEve/ParticleActors.h b/DDEve/include/DDEve/ParticleActors.h index 8ee6e9b127366872556306979d831a50bcb6c48e..6bc1d61868c25ce8e63ca54fded954cab85250de 100644 --- a/DDEve/include/DDEve/ParticleActors.h +++ b/DDEve/include/DDEve/ParticleActors.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDEve/include/DDEve/PopupMenu.h b/DDEve/include/DDEve/PopupMenu.h index 975be50823b4add806ce561c6fed496ccf2f9081..2af45832f525d8b178cb3ffc7a760b7341bd8b8f 100644 --- a/DDEve/include/DDEve/PopupMenu.h +++ b/DDEve/include/DDEve/PopupMenu.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -79,14 +78,10 @@ namespace DD4hep { /// Public access to the popup menu using '->' TGPopupMenu* operator->() { return &m_popup; } /// Public access to the popup menu using '->' - operator TGPopupMenu* () { return &m_popup; } + operator TGPopupMenu* () { return &m_popup; } ClassDef(PopupMenu,0); }; - - -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_POPUPMENU_H */ diff --git a/DDEve/include/DDEve/Projection.h b/DDEve/include/DDEve/Projection.h index c2301c6c1feaca9b8738af02c284b74c43f6dfc0..935a9361cf2b166664a2d2fd8784955a7efc80f3 100644 --- a/DDEve/include/DDEve/Projection.h +++ b/DDEve/include/DDEve/Projection.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -40,11 +39,11 @@ namespace DD4hep { /// Call an element to a event element list virtual TEveElement* ImportElement(TEveElement* el, TEveElementList* list); /// Call an element to a geometry element list - virtual TEveElement* ImportGeoElement(TEveElement* element, TEveElementList* list); + virtual TEveElement* ImportGeoElement(TEveElement* element, TEveElementList* list) override; /// Call an element to a geometry element list - virtual TEveElement* ImportGeoTopic(TEveElement* element, TEveElementList* list); + virtual TEveElement* ImportGeoTopic(TEveElement* element, TEveElementList* list) override; /// Call an element to a event element list - virtual TEveElement* ImportEventElement(TEveElement* element, TEveElementList* list); + virtual TEveElement* ImportEventElement(TEveElement* element, TEveElementList* list) override; public: @@ -53,7 +52,7 @@ namespace DD4hep { /// Default destructor virtual ~Projection(); /// Map the projection view to the slot - virtual View& Map(TEveWindow* slot); + virtual View& Map(TEveWindow* slot) override; /// Add projection axis to the view virtual Projection& AddAxis(); /// Create Rho-Phi projection @@ -63,9 +62,7 @@ namespace DD4hep { virtual void SetDepth(Float_t d); - ClassDef(Projection,0); + ClassDefOverride(Projection,0); }; -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_PROJECTION_H */ diff --git a/DDEve/include/DDEve/RhoPhiProjection.h b/DDEve/include/DDEve/RhoPhiProjection.h index d1b611938fb5e963819fcfe362b6750c89f40c66..482ca82ef5e4ecf5cd3c11fea3e12e8c0fff1b15 100644 --- a/DDEve/include/DDEve/RhoPhiProjection.h +++ b/DDEve/include/DDEve/RhoPhiProjection.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -34,12 +33,10 @@ namespace DD4hep { /// Default destructor virtual ~RhoPhiProjection(); /// Build the projection view and map it to the given slot - virtual View& Build(TEveWindow* slot); + virtual View& Build(TEveWindow* slot) override; /// Root implementation macro - ClassDef(RhoPhiProjection,0); + ClassDefOverride(RhoPhiProjection,0); }; - -} /* End namespace DD4hep */ - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_RHOPHIPROJECTION_H */ diff --git a/DDEve/include/DDEve/RhoZProjection.h b/DDEve/include/DDEve/RhoZProjection.h index e217fa6e2056f4d2623289fc937d6bd4b0145f23..44f59fc04d889ab97ef40f27bc83c87f4b441a67 100644 --- a/DDEve/include/DDEve/RhoZProjection.h +++ b/DDEve/include/DDEve/RhoZProjection.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -34,12 +33,10 @@ namespace DD4hep { /// Default destructor virtual ~RhoZProjection(); /// Build the projection view and map it to the given slot - virtual View& Build(TEveWindow* slot); + virtual View& Build(TEveWindow* slot) override; /// Root implementation macro - ClassDef(RhoZProjection,0); + ClassDefOverride(RhoZProjection,0); }; - -} /* End namespace DD4hep */ - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_RHOZPROJECTION_H */ diff --git a/DDEve/include/DDEve/Utilities.h b/DDEve/include/DDEve/Utilities.h index 63492c0558952c15140af9d4fd8f32418df86448..03d1db68bc4ee4ed1a42e2b334d56b064fc61742 100644 --- a/DDEve/include/DDEve/Utilities.h +++ b/DDEve/include/DDEve/Utilities.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -47,12 +46,7 @@ namespace DD4hep { TNamed *n = dynamic_cast<TNamed*>(p); return n ? n->GetName() : "???"; } - } - - -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_UTILITIES_H */ diff --git a/DDEve/include/DDEve/View.h b/DDEve/include/DDEve/View.h index 89a6f0cb94ff6545f4835bc36d2a8a34b6c41760..c30d6c9bb9441b293d426225ff12bb3efe321421 100644 --- a/DDEve/include/DDEve/View.h +++ b/DDEve/include/DDEve/View.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -156,7 +155,5 @@ namespace DD4hep { /// Root implementation macro ClassDef(View,0); }; -} /* End namespace DD4hep */ - - -#endif /* DD4HEP_DDEVE_VIEW_H */ +} /* End namespace DD4hep */ +#endif /* DD4HEP_DDEVE_VIEW_H */ diff --git a/DDEve/include/DDEve/View3D.h b/DDEve/include/DDEve/View3D.h index bf4a466716e9aaf1dc0876d0e4cdc1bb9395d556..26aff0972518de95765e991f0cf60d114cd97b54 100644 --- a/DDEve/include/DDEve/View3D.h +++ b/DDEve/include/DDEve/View3D.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -37,12 +36,10 @@ namespace DD4hep { /// Default destructor virtual ~View3D(); /// Build the 3d view and map it to the given slot - virtual View& Build(TEveWindow* slot); + virtual View& Build(TEveWindow* slot) override; /// Root implementation macro - ClassDef(View3D,0); + ClassDefOverride(View3D,0); }; -} /* End namespace DD4hep */ - - -#endif /* DD4HEP_DDEVE_VIEW3D_H */ +} /* End namespace DD4hep */ +#endif /* DD4HEP_DDEVE_VIEW3D_H */ diff --git a/DDEve/include/DDEve/ViewMenu.h b/DDEve/include/DDEve/ViewMenu.h index 4c7a7181b902b9562efd83201bf563bdb09f68ac..4049cf4c3be6ee32652eabcb6b917e5de0b2a1b5 100644 --- a/DDEve/include/DDEve/ViewMenu.h +++ b/DDEve/include/DDEve/ViewMenu.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -49,7 +48,7 @@ namespace DD4hep { virtual ~ViewMenu(); /// Add the menu to the menu bar - virtual void Build(TGMenuBar* bar, int hints=kLHintsNormal); + virtual void Build(TGMenuBar* bar, int hints=kLHintsNormal) override; /// Import Geometry data and build the view void BuildView(View *view) const; @@ -66,11 +65,8 @@ namespace DD4hep { View* CreateRhoPhiProjection(const std::string& title); /// ROOT implementation macro - ClassDef(ViewMenu,0); + ClassDefOverride(ViewMenu,0); }; - -} /* End namespace DD4hep */ - - +} /* End namespace DD4hep */ #endif /* DD4HEP_DDEVE_VIEWMENU_H */ diff --git a/DDEve/src/Display.cpp b/DDEve/src/Display.cpp index 48fc9550713c9373e83c4b9851f48ae9b830ab79..304b1c56da982a359f8a3507dd71969415a50425 100644 --- a/DDEve/src/Display.cpp +++ b/DDEve/src/Display.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -373,10 +372,15 @@ TFile* Display::Open(const char* name) const { } /// Consumer event data -void Display::OnNewEvent(EventHandler* handler ) { +void Display::OnFileOpen(EventHandler& handler ) { + EventConsumer::OnFileOpen(handler); +} + +/// Consumer event data +void Display::OnNewEvent(EventHandler& handler ) { typedef EventHandler::TypedEventCollections Types; typedef vector<EventHandler::Collection> Collections; - const Types& types = handler->data(); + const Types& types = handler.data(); TEveElement* particles = 0; printout(ERROR,"EventHandler","+++ Display new event....."); @@ -387,7 +391,7 @@ void Display::OnNewEvent(EventHandler* handler ) { size_t len = (*j).second; const char* nam = (*j).first; if ( len > 0 ) { - EventHandler::CollectionType typ = handler->collectionType(nam); + EventHandler::CollectionType typ = handler.collectionType(nam); if ( typ == EventHandler::CALO_HIT_COLLECTION || typ == EventHandler::TRACKER_HIT_COLLECTION ) { const DataConfigurations::const_iterator i=m_collectionsConfigs.find(nam); @@ -395,28 +399,28 @@ void Display::OnNewEvent(EventHandler* handler ) { const DataConfig& cfg = (*i).second; if ( cfg.hits == "PointSet" ) { PointsetCreator cr(nam,len,cfg); - handler->collectionLoop((*j).first, cr); + handler.collectionLoop((*j).first, cr); ImportEvent(cr.element()); } else if ( cfg.hits == "BoxSet" ) { BoxsetCreator cr(nam,len,cfg); - handler->collectionLoop((*j).first, cr); + handler.collectionLoop((*j).first, cr); ImportEvent(cr.element()); } else if ( cfg.hits == "TowerSet" ) { TowersetCreator cr(nam,len,cfg); - handler->collectionLoop((*j).first, cr); + handler.collectionLoop((*j).first, cr); ImportEvent(cr.element()); } else { // Default is point set PointsetCreator cr(nam,len); - handler->collectionLoop((*j).first, cr); + handler.collectionLoop((*j).first, cr); ImportEvent(cr.element()); } } else { PointsetCreator cr(nam,len); - handler->collectionLoop((*j).first, cr); + handler.collectionLoop((*j).first, cr); ImportEvent(cr.element()); } } @@ -430,7 +434,7 @@ void Display::OnNewEvent(EventHandler* handler ) { const DataConfig* cfg = (i==m_collectionsConfigs.end()) ? 0 : &((*i).second); MCParticleCreator cr(new TEveTrackPropagator("","",new TEveMagFieldDuo(350, -3.5, 2.0)), new TEveCompound("MC_Particles","MC_Particles"),cfg); - handler->collectionLoop((*j).first, cr); + handler.collectionLoop((*j).first, cr); cr.close(); particles = cr.particles; } diff --git a/DDEve/src/ElementList.cpp b/DDEve/src/ElementList.cpp index 7fd8220e5377794175b6f0b7c7cde39013f445b9..60bfa8ceb7503e277ffed95dc07dc5f219850d3f 100644 --- a/DDEve/src/ElementList.cpp +++ b/DDEve/src/ElementList.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDEve/src/EventControl.cpp b/DDEve/src/EventControl.cpp index 872aa546ed752829d2430bc19fcd0029f983f649..c74dd7ca29ebdd4a673e1c544b128377750e1d24 100644 --- a/DDEve/src/EventControl.cpp +++ b/DDEve/src/EventControl.cpp @@ -92,13 +92,13 @@ bool EventControl::Open() { } /// EventConsumer overload: New event data file -void EventControl::OnFileOpen(EventHandler* handler) { +void EventControl::OnFileOpen(EventHandler& handler) { char text[1024], fname[1024]; - ::strncpy(fname, handler->datasourceName().c_str(), sizeof(fname)-1); + ::strncpy(fname, handler.datasourceName().c_str(), sizeof(fname)-1); fname[sizeof(fname)-1] = 0; // ----------------------------------------------------------------------------------------- - if ( handler && handler->hasFile() ) { - ::snprintf(text,sizeof(text),"Number of events: %ld",handler->numEvents()); + if ( handler.hasFile() ) { + ::snprintf(text,sizeof(text),"Number of events: %ld",handler.numEvents()); m_input1->SetText(::basename(fname)); m_input2->SetText(text); } @@ -112,17 +112,17 @@ void EventControl::OnFileOpen(EventHandler* handler) { } /// Consumer event data -void EventControl::OnNewEvent(EventHandler* handler) { +void EventControl::OnNewEvent(EventHandler& handler) { typedef EventHandler::TypedEventCollections Types; typedef std::vector<EventHandler::Collection> Collections; - const Types& types = handler->data(); + const Types& types = handler.data(); size_t cnt = 1; m_lines[0].second.first->SetText("Hit collection name"); m_lines[0].second.second->SetText("No.Hits"); - for(Types::const_iterator i=types.begin(); i!=types.end() && cnt+1<m_lines.size(); ++i) { - const Collections& colls = (*i).second; - Line line = m_lines[cnt++]; - string cl = (*i).first; + for(const auto& t : types) { + const Collections& colls = t.second; + Line line = m_lines[cnt++]; + string cl = t.first; size_t idx = cl.rfind("Geant4"); if ( idx != string::npos ) { cl = cl.substr(idx); @@ -137,11 +137,11 @@ void EventControl::OnNewEvent(EventHandler* handler) { line.second.second->SetTextColor(kRed); line.second.first->SetText(("Coll.Type: "+cl).c_str()); line.second.second->SetText(""); - for(Collections::const_iterator j=colls.begin(); j!=colls.end() && cnt+1<m_lines.size(); ++j) { + for(const auto& c : colls) { char text[132]; - ::snprintf(text,sizeof(text),"%ld",long((*j).second)); + ::snprintf(text,sizeof(text),"%ld",long(c.second)); line = m_lines[cnt++]; - line.second.first->SetText((*j).first); + line.second.first->SetText(c.first); line.second.second->SetText(text); line.second.first->SetTextColor(kBlack); line.second.second->SetTextColor(kBlack); @@ -215,7 +215,7 @@ void EventControl::OnBuild() { group = new TGGroupFrame(m_frame,"Event data",200); m_frame->AddFrame(group,new TGLayoutHints(kLHintsLeft|kLHintsExpandX|kLHintsExpandY, 0, 0, 2, 2)); m_dataFrame = new TGVerticalFrame(group); - for(int i=0; i<NUM_DATA_LINES; ++i) { + for( int i=0; i<NUM_DATA_LINES; ++i ) { Line line; TGCompositeFrame* fr = new TGHorizontalFrame(m_dataFrame); fr->AddFrame(line.second.first=new TGLabel(fr,""), new TGLayoutHints(kLHintsNormal, 2, 0, 2, 2)); diff --git a/DDEve/src/EventHandler.cpp b/DDEve/src/EventHandler.cpp index 63c46eddb3b7ecbf5b94372d4e7c8c66e729dc2f..c8facea73447dd7980fe7af736f4df5eb60be3db 100644 --- a/DDEve/src/EventHandler.cpp +++ b/DDEve/src/EventHandler.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -20,18 +19,10 @@ using namespace DD4hep; ClassImp(EventHandler) ClassImp(EventConsumer) -/// Standard constructor -EventHandler::EventHandler() : m_hasFile(false), m_hasEvent(false) { -} - /// Default destructor EventHandler::~EventHandler() { } -/// Standard constructor -EventConsumer::EventConsumer() { -} - /// Default destructor EventConsumer::~EventConsumer() { } diff --git a/DDEve/src/GenericEventHandler.cpp b/DDEve/src/GenericEventHandler.cpp index a5e9e3dcdb5b5702fd1babcc800f4050bb2c1089..d817e43b79e82d48d687d42dfcfacc83b80ad7c7 100644 --- a/DDEve/src/GenericEventHandler.cpp +++ b/DDEve/src/GenericEventHandler.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -47,9 +46,9 @@ EventHandler* GenericEventHandler::current() const { } /// Notfy all subscribers -void GenericEventHandler::NotifySubscribers(void (EventConsumer::*pmf)(EventHandler*)) { +void GenericEventHandler::NotifySubscribers(void (EventConsumer::*pmf)(EventHandler&)) { for(Subscriptions::iterator i=m_subscriptions.begin(); i!=m_subscriptions.end();++i) - ((*i)->*pmf)(this); + ((*i)->*pmf)(*this); } /// Subscribe to notification of new data present diff --git a/DDG4/ddsim.cpp b/DDG4/ddsim.cpp index 3658dea8ab89067bab89b733453fe3b4d598148d..facfb8ee757697a63e73f5d078aecae04fef34aa 100644 --- a/DDG4/ddsim.cpp +++ b/DDG4/ddsim.cpp @@ -2,7 +2,6 @@ // DDSim - LC simulation based on DD4hep //-------------------------------------------------------------------- // F.Gaede, DESY -// $Id:$ //==================================================================== #include "DDG4/Geant4Config.h" @@ -17,9 +16,7 @@ using namespace DD4hep::Simulation::Setup; * - subsequent files configure the application */ -int main(int argc, char** argv) { - - +int main_wrapper(int argc, char** argv) { if( argc < 2 ){ std::cout << " --- Usage example: \n " << " dd_sim ../ILD/compact/ILD_o1_v05.xml [sensitive_detectors.xml] sequences.xml physics.xml " @@ -27,9 +24,7 @@ int main(int argc, char** argv) { exit( 0 ) ; } - DD4hep::Geometry::LCDD& lcdd = DD4hep::Geometry::LCDD::getInstance(); - Kernel& kernel = Kernel::instance(lcdd); // first argument: geometry file @@ -38,21 +33,29 @@ int main(int argc, char** argv) { geoFile += argv[1] ; kernel.loadGeometry( geoFile ) ; - for( int i=2 ; i < argc ; ++i ) { - std::cout << " will open xml file " << argv[i] << " and load to kernel ..." << std::endl ; - kernel.loadXML( argv[i] ) ; } kernel.configure(); kernel.initialize(); - kernel.run(); - std::cout << "Successfully executed application .... " << std::endl; - kernel.terminate(); } + +//______________________________________________________________________________ +int main(int argc, char** argv) { + try { + return main_wrapper(argc,argv); + } + catch(const exception& e) { + cout << "Got uncaught exception: " << e.what() << endl; + } + catch (...) { + cout << "Got UNKNOWN uncaught exception." << endl; + } + return EINVAL; +} diff --git a/DDG4/g4gdmlDisplay.cpp b/DDG4/g4gdmlDisplay.cpp index bfe48f24c41eeaa520fd579e34af971c8902dfd5..d6f501c1e10e6c622de375cd5f64a02a5abf9875 100644 --- a/DDG4/g4gdmlDisplay.cpp +++ b/DDG4/g4gdmlDisplay.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -59,7 +58,7 @@ static const char* get_arg(int argc, char** argv,int which) { throw runtime_error("Invalid argument sequence"); } -int main(int argc, char** argv) { +int main_wrapper(int argc, char** argv) { string gdml = argv[1]; string setup = argv[2]; const char* args[] = {"cmd"}; @@ -99,3 +98,17 @@ int main(int argc, char** argv) { delete run; return 0; } + +//______________________________________________________________________________ +int main(int argc, char** argv) { + try { + return main_wrapper(argc,argv); + } + catch(const exception& e) { + cout << "Got uncaught exception: " << e.what() << endl; + } + catch (...) { + cout << "Got UNKNOWN uncaught exception." << endl; + } + return EINVAL; +} diff --git a/DDG4/include/DDG4/Geant4Kernel.h b/DDG4/include/DDG4/Geant4Kernel.h index 1c5ecce55d85fdbb470ebdf768b4006d36649dd1..9c6746af73f772d3ccaa4f29c7ac444ea012d04e 100644 --- a/DDG4/include/DDG4/Geant4Kernel.h +++ b/DDG4/include/DDG4/Geant4Kernel.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/include/DDG4/IoStreams.h b/DDG4/include/DDG4/IoStreams.h index 1c779ca5b28c79eec20267a42fc1aee48f84c523..67fc4800bc0e98d8509ef38a29082bfec54e05e4 100644 --- a/DDG4/include/DDG4/IoStreams.h +++ b/DDG4/include/DDG4/IoStreams.h @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -81,27 +80,35 @@ namespace DD4hep { typedef boost::iostreams::detail::path detail_path; struct category : boost::iostreams::seekable_device_tag, boost::iostreams::closable_tag { }; - // Default constructor + /// Default constructor dd4hep_file() : m_handle(0) { } - // Constructors taking file desciptors + /// Constructors taking file desciptors dd4hep_file(handle_type fd, dd4hep_file_flags); - // Constructors taking file desciptors + /// Constructors taking file desciptors dd4hep_file(const char* fname, BOOST_IOS::openmode mode); - - // open overloads taking file descriptors + /// Default destructor + ~dd4hep_file(); + /// open overloads taking file descriptors void open(handle_type fd, dd4hep_file_flags flags); - - // open overload taking C-style string + /// open overload taking C-style string void open(const char* path, BOOST_IOS::openmode mode = BOOST_IOS::in | BOOST_IOS::out ); - - bool is_open() const { return m_handle != 0; } + /// Close the file stream void close(); + /// Read from input stream std::streamsize read(char_type* s, std::streamsize n); + /// Write to output stream std::streamsize write(const char_type* s, std::streamsize n); + /// Direct access: set file pointer of the stream std::streampos seek(stream_offset off, BOOST_IOS::seekdir way); + /// Check if the file stream is opened + bool is_open() const { return m_handle != 0; } + /// Access to native stream handle handle_type handle() const { return m_handle; } + private: + /// Native stream handle handle_type m_handle; + /// Stream flag(s) dd4hep_file_flags m_flag; }; diff --git a/DDG4/include/DDG4/Python/DDPython.h b/DDG4/include/DDG4/Python/DDPython.h index d3aa8449f018c2f8cc4cede33f17160a3dd36e1c..d78500bf0a8043bf0831eb531c289aaf8173a7df 100644 --- a/DDG4/include/DDG4/Python/DDPython.h +++ b/DDG4/include/DDG4/Python/DDPython.h @@ -1,3 +1,4 @@ +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -10,7 +11,6 @@ // \date 2015-11-07 // //========================================================================== -// $Id$ #ifndef DD4HEP_DDG4_DDPYTHON_H #define DD4HEP_DDG4_DDPYTHON_H 1 diff --git a/DDG4/include/DDG4/Python/Geant4PythonAction.h b/DDG4/include/DDG4/Python/Geant4PythonAction.h index 8e6e3658e112bf62b7c8b95236f6fd5c3c094a9f..0a7db9c907816efaa3be750346c098e84c51f77e 100644 --- a/DDG4/include/DDG4/Python/Geant4PythonAction.h +++ b/DDG4/include/DDG4/Python/Geant4PythonAction.h @@ -1,3 +1,4 @@ +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -10,7 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ #ifndef DD4HEP_DDG4_GEANT4PYTHONACTION_H #define DD4HEP_DDG4_GEANT4PYTHONACTION_H diff --git a/DDG4/include/DDG4/Python/Geant4PythonCall.h b/DDG4/include/DDG4/Python/Geant4PythonCall.h index 7fce64f2be2199c8f720f4da162bdcca86afff48..22b08c8c43bcce2df4ca86bdd40dce44c798823b 100644 --- a/DDG4/include/DDG4/Python/Geant4PythonCall.h +++ b/DDG4/include/DDG4/Python/Geant4PythonCall.h @@ -1,3 +1,4 @@ +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -10,7 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ #ifndef DD4HEP_DDG4_GEANT4PYTHONCALL_H #define DD4HEP_DDG4_GEANT4PYTHONCALL_H diff --git a/DDG4/include/DDG4/Python/Geant4PythonDetectorConstruction.h b/DDG4/include/DDG4/Python/Geant4PythonDetectorConstruction.h index 6aa015f2113904ab64bcd72ab3f43a626462b79e..b0c01dc3d8e40358451f809575976858c2d4d71f 100644 --- a/DDG4/include/DDG4/Python/Geant4PythonDetectorConstruction.h +++ b/DDG4/include/DDG4/Python/Geant4PythonDetectorConstruction.h @@ -1,3 +1,4 @@ +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -10,7 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ #ifndef DD4HEP_DDG4_GEANT4PYTHONDETECTORCONSTRUCTION_H #define DD4HEP_DDG4_GEANT4PYTHONDETECTORCONSTRUCTION_H diff --git a/DDG4/include/DDG4/Python/Geant4PythonInitialization.h b/DDG4/include/DDG4/Python/Geant4PythonInitialization.h index 653d7203b2e5b65967401d6077315b1dd825b82f..001521ca00b31fb178c448caaf7f0fae17ffe507 100644 --- a/DDG4/include/DDG4/Python/Geant4PythonInitialization.h +++ b/DDG4/include/DDG4/Python/Geant4PythonInitialization.h @@ -1,3 +1,4 @@ +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -10,7 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ #ifndef DD4HEP_DDG4_GEANT4PYTHONINITIALIZATION_H #define DD4HEP_DDG4_GEANT4PYTHONINITIALIZATION_H diff --git a/DDG4/include/DDG4/Python/PyDDG4.h b/DDG4/include/DDG4/Python/PyDDG4.h index c24f8d88a7fde7be6ae6a417df65da8cfd7d6fe4..c0f89a55c9acceb7c2870a572dd21b526560e7ee 100644 --- a/DDG4/include/DDG4/Python/PyDDG4.h +++ b/DDG4/include/DDG4/Python/PyDDG4.h @@ -1,4 +1,4 @@ -// Framework include files +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -11,8 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ - #ifndef DD4HEP_DDG4_PYDDG4_H #define DD4HEP_DDG4_PYDDG4_H diff --git a/DDG4/plugins/Geant4TrackerWeightedSD.cpp b/DDG4/plugins/Geant4TrackerWeightedSD.cpp index 80ff2d75a824802704e78d1f787717c74c079e46..22676ab1b547906dcd5ad30acc2e15bc731fcc15 100644 --- a/DDG4/plugins/Geant4TrackerWeightedSD.cpp +++ b/DDG4/plugins/Geant4TrackerWeightedSD.cpp @@ -1,4 +1,3 @@ -// $Id$ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -80,28 +79,23 @@ namespace DD4hep { Geant4Tracker::Hit pre, post; Position mean_pos; - Geant4Sensitive* sensitive; - G4VSensitiveDetector* thisSD; - double distance_to_inside; - double distance_to_outside; - double mean_time; - double step_length; - double e_cut; - int current, parent; - int combined; - int hit_position_type; - int hit_flag; - int g4ID; - EInside last_inside; - long long int cell; - bool single_deposit_mode; - TrackerWeighted() : pre(), post(), sensitive(0), thisSD(0), - distance_to_inside(0.0), distance_to_outside(0.0), mean_time(0.0), - step_length(0.0), e_cut(0.0), current(-1), parent(0), combined(0), - hit_position_type(POSITION_MIDDLE), hit_flag(0), g4ID(0), cell(0), - single_deposit_mode(false) - { - } + Geant4Sensitive* sensitive = 0; + G4VSensitiveDetector* thisSD = 0; + double distance_to_inside = 0.0; + double distance_to_outside = 0.0; + double mean_time = 0.0; + double step_length = 0.0; + double e_cut = 0.0; + int current = 0; + int parent = 0; + int combined = 0; + int hit_position_type = POSITION_MIDDLE; + int hit_flag = 0; + int g4ID = 0; + EInside last_inside = kOutside; + long long int cell = 0; + bool single_deposit_mode = false; + TrackerWeighted() = default; /// Clear collected information and restart for new hit TrackerWeighted& clear() { diff --git a/DDG4/pyddg4.cpp b/DDG4/pyddg4.cpp index d4390b239da0cfe6885fccbe1bfb675563470d15..3618f5cdc79980e18d9fa374b89873f01493dc20 100644 --- a/DDG4/pyddg4.cpp +++ b/DDG4/pyddg4.cpp @@ -1,4 +1,3 @@ -// $Id$ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/python/DDG4Dict.C b/DDG4/python/DDG4Dict.C index 200b4acd821ee41ed92f2e0f1499de7b74818073..ebc076d3b22546075a4b562761e714db430b2614 100644 --- a/DDG4/python/DDG4Dict.C +++ b/DDG4/python/DDG4Dict.C @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/python/checkGeometry.py b/DDG4/python/checkGeometry.py index 26ec76d5ddae08f9d529154f15e8e1810728cacf..a4e1c0a5700fd30e0bed7da3a3e536d99b6bb5d8 100755 --- a/DDG4/python/checkGeometry.py +++ b/DDG4/python/checkGeometry.py @@ -1,5 +1,4 @@ #!/bin/python -# $Id: $ #========================================================================== # AIDA Detector description implementation for LCD #-------------------------------------------------------------------------- diff --git a/DDG4/python/checkOverlaps.py b/DDG4/python/checkOverlaps.py index 641ae538918dcc5f9939fc8e16195727dc1d368b..4120fe841bd4f232ac76e6471ea7dd503a30f3fb 100755 --- a/DDG4/python/checkOverlaps.py +++ b/DDG4/python/checkOverlaps.py @@ -1,5 +1,4 @@ #!/bin/python -# $Id: $ #========================================================================== # AIDA Detector description implementation for LCD #-------------------------------------------------------------------------- diff --git a/DDG4/python/g4MaterialScan.py b/DDG4/python/g4MaterialScan.py index 2e4850b673c620cd7ec86b5261048f0c4b84ddf4..a25c50a2c4b50c8732755b8cb6393ee49ea07f0e 100644 --- a/DDG4/python/g4MaterialScan.py +++ b/DDG4/python/g4MaterialScan.py @@ -1,5 +1,4 @@ #!/bin/python -# $Id: $ #========================================================================== # AIDA Detector description implementation for LCD #-------------------------------------------------------------------------- diff --git a/DDG4/reco/Geant4SurfaceTest.cpp b/DDG4/reco/Geant4SurfaceTest.cpp index eab2b3b1f1adc3251511b56bd61cbf5c0124d7c1..aad44659d551a2774d7b685f2549852a0cb4336e 100644 --- a/DDG4/reco/Geant4SurfaceTest.cpp +++ b/DDG4/reco/Geant4SurfaceTest.cpp @@ -10,7 +10,6 @@ // \date 2015-10-14 // //========================================================================== -// $Id$ #ifndef DD4HEP_DDG4_GEANT4SURFACETEST_H #define DD4HEP_DDG4_GEANT4SURFACETEST_H diff --git a/DDG4/scripts/dumpDDG4.C b/DDG4/scripts/dumpDDG4.C index f681542a6f7eee17f22a12778fa9e21b04daaf48..b0a07fcbeb3c41295174d1cc1af4ca55aea34bd8 100644 --- a/DDG4/scripts/dumpDDG4.C +++ b/DDG4/scripts/dumpDDG4.C @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp index 541723504d89192e4763707782481f9f8da4c516..11ba1e0bb5123ae5e185016595ea496c15af0700 100644 --- a/DDG4/src/Geant4Converter.cpp +++ b/DDG4/src/Geant4Converter.cpp @@ -677,8 +677,10 @@ void* Geant4Converter::handleAssembly(const std::string& name, const TGeoNode* n else { Geant4GeometryMaps::VolumeMap::iterator volIt = info.g4Volumes.find(dau_vol); if ( volIt == info.g4Volumes.end() ) { - printout(FATAL, "Geant4Converter", "+++ Invalid child volume at %s : %d parent: %s child:%s", + printout(FATAL,"Geant4Converter", "+++ Invalid child volume at %s : %d parent: %s child:%s", __FILE__, __LINE__, name.c_str(), d->GetName()); + except("Geant4Converter", "+++ Invalid child volume at %s : %d parent: %s child:%s", + __FILE__, __LINE__, name.c_str(), d->GetName()); } g4->placeVolume(d,(*volIt).second, transform); printout(m_outputLevel, "Geant4Converter", "+++ Assembly: AddPlacedVolume : dau:%s " @@ -736,7 +738,7 @@ void* Geant4Converter::handlePlacement(const string& name, const TGeoNode* node) // printout(m_outputLevel, "Geant4Converter", "+++ Assembly: makeImprint: dau:%s in mother %s " "Tr:x=%8.3f y=%8.3f z=%8.3f", - node->GetName(), mot_vol->GetName(), + node->GetName(), mot_vol ? mot_vol->GetName() : "<unknown>", transform.dx(), transform.dy(), transform.dz()); Geant4AssemblyVolume* ass = (Geant4AssemblyVolume*)info.g4AssemblyVolumes[node]; Geant4AssemblyVolume::Chain chain; diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp index 5e5b6fe29d74ad75ed8e9bfabbbf56eb517067d6..0e0e0934c1231d129e0b34b1ea108166fd3798d4 100644 --- a/DDG4/src/Geant4Kernel.cpp +++ b/DDG4/src/Geant4Kernel.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -77,7 +76,8 @@ Geant4ActionPhase& Geant4Kernel::PhaseSelector::operator[](const std::string& na /// Standard constructor Geant4Kernel::Geant4Kernel(LCDD& lcdd_ref) : Geant4ActionContainer(), m_runManager(0), m_control(0), m_trackMgr(0), m_lcdd(&lcdd_ref), - m_numThreads(0), m_id(Geant4Kernel::thread_self()), m_master(this), m_shared(0), phase(this) + m_numThreads(0), m_id(Geant4Kernel::thread_self()), m_master(this), m_shared(0), + m_threadContext(0), phase(this) { m_lcdd->addExtension < Geant4Kernel > (this); m_ident = -1; @@ -97,11 +97,13 @@ Geant4Kernel::Geant4Kernel(LCDD& lcdd_ref) /// Standard constructor Geant4Kernel::Geant4Kernel(Geant4Kernel* m, unsigned long ident) : Geant4ActionContainer(), m_runManager(0), m_control(0), m_trackMgr(0), m_lcdd(0), - m_numThreads(1), m_id(ident), m_master(m), m_shared(0), phase(this) + m_numThreads(1), m_id(ident), m_master(m), m_shared(0), + m_threadContext(0), phase(this) { char text[64]; m_lcdd = m_master->m_lcdd; m_ident = m_master->m_workers.size(); + m_numEvent = m_master->m_numEvent; declareProperty("UI",m_uiName = m_master->m_uiName); declareProperty("OutputLevel", m_outputLevel = m_master->m_outputLevel); declareProperty("OutputLevels",m_clientLevels = m_master->m_clientLevels); diff --git a/DDG4/src/Geant4ParticlePrint.cpp b/DDG4/src/Geant4ParticlePrint.cpp index 04e7d71161af431d100db9eca3bd331898b8d6ac..66c031e54749a2a1802559593724eff4a2c6d0a7 100644 --- a/DDG4/src/Geant4ParticlePrint.cpp +++ b/DDG4/src/Geant4ParticlePrint.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -196,7 +195,7 @@ void Geant4ParticlePrint::printParticleTree(const G4Event* e, char txt[64]; size_t len = sizeof(txt)-33; // Careful about overruns... // Ensure we do not overwrite the array - if ( level>int(len)-3 ) level=len-3; + if ( level>int(len)-3 ) level = len-3; ::snprintf(txt,sizeof(txt),"%5d ",level); ::memset(txt+6,' ',len-6); diff --git a/DDG4/src/Geant4PhysicsConstructor.cpp b/DDG4/src/Geant4PhysicsConstructor.cpp index 36d3fd5c1a4a52f8a94949176d310c87d72ece82..3ed066e85309ddcb3e5d1b89161b3174f15242a9 100644 --- a/DDG4/src/Geant4PhysicsConstructor.cpp +++ b/DDG4/src/Geant4PhysicsConstructor.cpp @@ -1,4 +1,3 @@ -// $Id$ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/src/Geant4PhysicsList.cpp b/DDG4/src/Geant4PhysicsList.cpp index 5092fd18f9206f2643b8bfcc71383a9f99ec03ea..a1208b6abf7798891a83a2661ea74ccad0806083 100644 --- a/DDG4/src/Geant4PhysicsList.cpp +++ b/DDG4/src/Geant4PhysicsList.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/src/Geant4Plugins.cpp b/DDG4/src/Geant4Plugins.cpp index 9fb288a7bbaec5c0966c241fbc1934dd1cbfc353..26828acbebae11e0dea5df7cc88abb34415b6b80 100644 --- a/DDG4/src/Geant4Plugins.cpp +++ b/DDG4/src/Geant4Plugins.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/src/Geant4Primary.cpp b/DDG4/src/Geant4Primary.cpp index 64743bbbace1de2d91fbcdcbbb42f7ad93006cc9..45f307dd1168654e518d324d06a7fc69060aaba1 100644 --- a/DDG4/src/Geant4Primary.cpp +++ b/DDG4/src/Geant4Primary.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/src/Geant4PrimaryHandler.cpp b/DDG4/src/Geant4PrimaryHandler.cpp index ba65062bea191fca49c8cf579a2afe3f76f27f01..836e4701c29d4facb92a2dc6563e923c29365b81 100644 --- a/DDG4/src/Geant4PrimaryHandler.cpp +++ b/DDG4/src/Geant4PrimaryHandler.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/src/IoStreams.cpp b/DDG4/src/IoStreams.cpp index 861fe9c5608d1897d27136178a33296a3c1a0c2d..940a388f91ba90fd48ee826af6eeb3afeeed0b56 100644 --- a/DDG4/src/IoStreams.cpp +++ b/DDG4/src/IoStreams.cpp @@ -1,4 +1,3 @@ -// $Id: $ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- @@ -62,6 +61,10 @@ namespace DD4hep { template<> std::streamsize dd4hep_file<int>::read(char_type* s, std::streamsize n) { return ::read(m_handle,s,n); } + /// Specialization for standard file descriptor files according to the posix standard: Default destructor + template<> dd4hep_file<int>::~dd4hep_file() + { if (m_handle) ::close(m_handle); m_handle = 0;} + /// Specialization for standard file descriptor files according to the posix standard template<> std::streamsize dd4hep_file<int>::write(const char_type* s, std::streamsize n) { return ::write(m_handle,s,n); } @@ -98,11 +101,15 @@ namespace DD4hep { /// Specialization for the usage of TFile structures template<> dd4hep_file<TFile*>::dd4hep_file(handle_type fd, dd4hep_file_flags flags) - : m_handle(fd), m_flag(flags) { } + : m_handle(fd), m_flag(flags) { } /// Specialization for the usage of TFile structures template<> dd4hep_file<TFile*>::dd4hep_file(const char* fname, BOOST_IOS::openmode mode) - : m_handle(0), m_flag(close_handle) { open(fname,mode); } + : m_handle(0), m_flag(close_handle) { open(fname,mode); } + + /// Specialization for the usage of TFile structures: Default destructor + template<> dd4hep_file<TFile*>::~dd4hep_file() + { if ( m_handle ) m_handle->Close(); m_handle = 0; } /// Specialization for the usage of TFile structures template<> std::streamsize dd4hep_file<TFile*>::read(char_type* s, std::streamsize n) { diff --git a/DDG4/src/python/DDG4Python.C b/DDG4/src/python/DDG4Python.C index bb1975d6a064a95e12ac8dbecdb911fb23eed562..ad1d0be3c99d5a620b32e0d6c68e5117c2812e0d 100644 --- a/DDG4/src/python/DDG4Python.C +++ b/DDG4/src/python/DDG4Python.C @@ -1,4 +1,3 @@ -// $Id$ //========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- diff --git a/DDG4/src/python/Geant4PythonAction.cpp b/DDG4/src/python/Geant4PythonAction.cpp index ca04698b3b4d46d65a758a6576edfa7b70b3d3ef..1fe10b54950aa1b7518204c5dc5f86aca527eda5 100644 --- a/DDG4/src/python/Geant4PythonAction.cpp +++ b/DDG4/src/python/Geant4PythonAction.cpp @@ -1,4 +1,4 @@ -// Framework include files +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -11,7 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ // Framework include files #include "DDG4/Factories.h" diff --git a/DDG4/src/python/Geant4PythonCall.cpp b/DDG4/src/python/Geant4PythonCall.cpp index 38227326fc4a89dbb54f6f72b21448540beaeeda..30cdb676a8dd5c4b8ea15bf38f9ac47330e5d97b 100644 --- a/DDG4/src/python/Geant4PythonCall.cpp +++ b/DDG4/src/python/Geant4PythonCall.cpp @@ -1,4 +1,4 @@ -// Framework include files +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -11,7 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ // Framework include files #include "DDG4/Python/Geant4PythonCall.h" diff --git a/DDG4/src/python/Geant4PythonDetectorConstruction.cpp b/DDG4/src/python/Geant4PythonDetectorConstruction.cpp index c0aa95157876fce9bac132a6423200a4b61f6d43..a6151dce3306d8e0c029e8fba38217d072b77a29 100644 --- a/DDG4/src/python/Geant4PythonDetectorConstruction.cpp +++ b/DDG4/src/python/Geant4PythonDetectorConstruction.cpp @@ -1,3 +1,4 @@ +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -10,8 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ - // Framework include files #include "DDG4/Geant4Context.h" #include "DDG4/Geant4Kernel.h" diff --git a/DDG4/src/python/Geant4PythonDetectorConstructionLast.cpp b/DDG4/src/python/Geant4PythonDetectorConstructionLast.cpp index 1c3664aa08f9bb0e257a8511ff2541a8e1a071f8..1c53b7ea1e5e5a067f2e27b2c4a3bb82abd45744 100644 --- a/DDG4/src/python/Geant4PythonDetectorConstructionLast.cpp +++ b/DDG4/src/python/Geant4PythonDetectorConstructionLast.cpp @@ -1,3 +1,4 @@ +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -10,7 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ #ifndef DD4HEP_DDG4_GEANT4PYTHONDETECTORCONSTRUCTIONLAST_H #define DD4HEP_DDG4_GEANT4PYTHONDETECTORCONSTRUCTIONLAST_H diff --git a/DDG4/src/python/Geant4PythonInitialization.cpp b/DDG4/src/python/Geant4PythonInitialization.cpp index dd3ef82c6dbd06645eea174955f0e2e6204c7b9a..bf805f5a9d1ab0503d47484d8ce6b46b1faf793b 100644 --- a/DDG4/src/python/Geant4PythonInitialization.cpp +++ b/DDG4/src/python/Geant4PythonInitialization.cpp @@ -1,3 +1,4 @@ +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -10,7 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ // Framework include files #include "DDG4/Factories.h" diff --git a/DDG4/src/python/PyDDG4.cpp b/DDG4/src/python/PyDDG4.cpp index d8aa86d6a71e52623e56d5014e50353719b64cb2..f12d17390af468d616f0f9c311ebae1e44de666d 100644 --- a/DDG4/src/python/PyDDG4.cpp +++ b/DDG4/src/python/PyDDG4.cpp @@ -1,4 +1,4 @@ -// Framework include files +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -11,7 +11,6 @@ // \date 2015-11-03 // //========================================================================== -// $Id$ // Framework include files #include "DD4hep/LCDD.h" diff --git a/DDG4/tpython/DDPython.cpp b/DDG4/tpython/DDPython.cpp index 60c1cc4a9a45cf4ff2358854f004d24682150ff5..980e06371727c9fe66ad49b2147a5fd14041b786 100644 --- a/DDG4/tpython/DDPython.cpp +++ b/DDG4/tpython/DDPython.cpp @@ -1,3 +1,4 @@ +//========================================================================== // AIDA Detector description implementation for LCD //-------------------------------------------------------------------------- // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) @@ -10,7 +11,6 @@ // \date 2015-11-07 // //========================================================================== -// $Id$ // C/C++ include files #include <fstream> @@ -137,7 +137,7 @@ DDPython::AllowThreads::~AllowThreads() { } /// Standard constructor, initializes variables -DDPython::DDPython() { +DDPython::DDPython() : context(0) { ++_refCount; bool inited = ::Py_IsInitialized(); if ( !inited ) { diff --git a/UtilityApps/src/run_plugin.h b/UtilityApps/src/run_plugin.h index 245707614679480aacff27cdd256e9cbdddd030f..805d75a290f8162d2d3c9c0565c42b39509a1a66 100644 --- a/UtilityApps/src/run_plugin.h +++ b/UtilityApps/src/run_plugin.h @@ -23,6 +23,7 @@ #include <string> using namespace std; +using namespace DD4hep; using namespace DD4hep::Geometry; //________________________________________________________________________________ @@ -40,16 +41,15 @@ namespace { if ( v.p ) { return *v.l; } - throw runtime_error("Failed to locate plugin to create LCDD instance"); + except("RunPlugin","++ Failed to locate plugin to create LCDD instance"); } catch(const exception& e) { - cout << "Exception:" << e.what() << endl; - throw runtime_error("Exception:\""+string(e.what())); + except("RunPlugin","++ Exception: %s", e.what()); } catch(...) { - cout << "UNKNOWN Exception while creating LCDD instance." << endl; + except("RunPlugin","++ UNKNOWN Exception while creating LCDD instance."); } - throw runtime_error("UNKNOWN Exception while creating LCDD instance."); + except("RunPlugin","++ UNKNOWN Exception while creating LCDD instance."); #endif return LCDD::getInstance(); } @@ -61,19 +61,18 @@ namespace { return 0; } catch(const exception& e) { - cout << e.what() << endl; - return EINVAL; + except("RunPlugin","++ Exception while executing plugin %s: %s", + name ? name : "<unknown>", e.what()); } catch(...) { - cout << "UNKNOWN Exception" << endl; - return EINVAL; + except("RunPlugin","++ UNKNOWN Exception while executing plugin %s.",name ? name : "<unknown>"); } ::exit(EINVAL); return EINVAL; } //______________________________________________________________________________ - std::ostream& print_default_args() { + ostream& print_default_args() { cout << " -build_type <number/string> Specify the build type \n" " [OPTIONAL] MUST come immediately after the -compact input.\n" @@ -115,8 +114,8 @@ namespace { struct Args { bool volmgr, dry_run, destroy, interpreter, ui; int print; - std::vector<const char*> geo_files, build_types; - std::vector<std::vector<const char*> > plugins; + vector<const char*> geo_files, build_types; + vector<vector<const char*> > plugins; //____________________________________________________________________________ Args() { @@ -162,7 +161,7 @@ namespace { ui = true; else if ( strncmp(argv[i],"-plugin",5)==0 ) { // Need to interprete plugin args here locally..... - plugins.push_back(std::vector<const char*>()); + plugins.push_back(vector<const char*>()); plugins.back().push_back(argv[++i]); for( ++i; i < argc; ++i ) { if ( strncmp(argv[i],"-plugin",5)==0 ) { --i; break; } @@ -181,7 +180,7 @@ namespace { pair<int, char**> a(0,0); long result; for(size_t i=0; i<plugins.size(); ++i) { - std::vector<const char*>& plug=plugins[i]; + vector<const char*>& plug=plugins[i]; // Remove plugin name and trailing 0x0 from args. size_t num_args = plug.size()>2 ? plug.size()-2 : 0; @@ -207,7 +206,7 @@ namespace { } //____________________________________________________________________________ - int decodePrintLevel(const std::string& val) { + int decodePrintLevel(const string& val) { switch(::toupper(val[0])) { case '1': case 'V': @@ -232,7 +231,7 @@ namespace { return DD4hep::FATAL; default: cout << "Unknown print level supplied:'" << val << "'. Argument ignored." << endl; - throw std::runtime_error("Invalid printLevel:"+val); + throw runtime_error("Invalid printLevel:"+val); } } }; @@ -296,11 +295,11 @@ namespace { try { return main_wrapper(name,argc,argv); } - catch(const std::exception& e) { - std::cout << "Got uncaught exception: " << e.what() << std::endl; + catch(const exception& e) { + cout << "Got uncaught exception: " << e.what() << endl; } catch (...) { - std::cout << "Got UNKNOWN uncaught exception." << std::endl; + cout << "Got UNKNOWN uncaught exception." << endl; } return EINVAL; } diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index 84ba23626044baaef356cc1cce8f1b3bd6b4410d..d88a8e895aa4735a661891da4a47a620b3aa314b 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -37,7 +37,7 @@ find_package(Threads REQUIRED) macro(dd4hep_set_compiler_flags) include(CheckCXXCompilerFlag) - SET(COMPILER_FLAGS -Wall -Wextra -pedantic -Wshadow -Wformat-security -Wno-long-long -Wdeprecated -fdiagnostics-color=auto ) + SET(COMPILER_FLAGS -Wall -Wextra -pedantic -Wshadow -Wformat-security -Wno-long-long -Wdeprecated -fdiagnostics-color=auto -Winconsistent-missing-override) FOREACH( FLAG ${COMPILER_FLAGS} ) CHECK_CXX_COMPILER_FLAG( "${FLAG}" CXX_FLAG_WORKS_${FLAG} ) diff --git a/examples/AlignDet/src/Alignment_to_Condition.cpp b/examples/AlignDet/src/Alignment_to_Condition.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5a327fd5001b038aae652777ff33ddf79c1f8b39 --- /dev/null +++ b/examples/AlignDet/src/Alignment_to_Condition.cpp @@ -0,0 +1,87 @@ +//========================================================================== +// AIDA Detector description implementation for LCD +//-------------------------------------------------------------------------- +// 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 +// +//========================================================================== +/* + Plugin invocation: + ================== + This plugin behaves like a main program. + Invoke the plugin with something like this: + + geoPluginRun -volmgr -destroy -plugin DD4hep_Alignment2Condition + +*/ +// Framework include files +#include "DD4hep/Printout.h" +#include "DD4hep/Conditions.h" +#include "DD4hep/Alignments.h" +#include "DD4hep/AlignmentData.h" +#include "DD4hep/objects/ConditionsInterna.h" +#include "DD4hep/objects/AlignmentsInterna.h" + +#include "DD4hep/Factories.h" + +#include <cerrno> + +using namespace std; +using namespace DD4hep; +using Alignments::Alignment; +using Alignments::AlignmentData; +using Alignments::AlignmentCondition; +using Conditions::Condition; +using Conditions::ConditionKey; + +/// Plugin function: Alignment program example +/** + * Factory: DD4hep_Alignment2Condition + * + * \author M.Frank + * \version 1.0 + * \date 01/12/2016 + */ +static int Alignment_to_Condition (Geometry::LCDD& , int argc, char** argv) { + for(int i=0; i<argc && argv[i]; ++i) { + if ( 0 == ::strncmp("-help",argv[i],2) || 0 == ::strncmp("-?",argv[i],2) ) { + /// Help printout describing the basic command line interface + cout << + "Usage: -plugin <name> \n" + " name: factory name DD4hep_AlignmentExample_read_xml \n" + "\tArguments given: " << arguments(argc,argv) << endl << flush; + ::exit(EINVAL); + } + } + + AlignmentCondition ac("alignment"); + ac->hash = ConditionKey::hashCode(ac.name()); + + printout(INFO,"Example","Alignment condition: \"%s\" Key:%p",ac.name(),(void*)ac->hash); + printout(INFO,"Example","Alignment condition ptr: %p",(void*)ac.ptr()); + + Condition con(ac); + AlignmentData& data = ac.data(); + printout(INFO,"Example","Alignment condition data: %p",(void*)&data); + printout(INFO,"Example","Condition opaque pointer: %p",(void*)con.data().ptr()); + printout(INFO,"Example","Offset to opaque pointer: %uld",con->offset()); + printout(INFO,"Example","Computed Pointer: %p",((char*)con.ptr()+con->offset())); + printout(INFO,"Example","Computed payload pointer: %p",con->payload()); + + Alignment align(&data); + printout(INFO,"Example","Alignment object pointer: %p",align.ptr()); + printout(INFO,"Example","Alignment key: %p",(void*)align.key()); + printout(INFO,"Example","Condition key: %p",(void*)con.key()); + + Condition c(data.condition); + printout(INFO,"Example","Condition ptr from alignment: %p",(void*)c.ptr()); + + return 1; +} + +DECLARE_APPLY(DD4hep_Alignment2Condition,Alignment_to_Condition) diff --git a/examples/Conditions/data/manager.xml b/examples/Conditions/data/manager.xml new file mode 100644 index 0000000000000000000000000000000000000000..d0ec45f60b08eb8c2e2810d08f326f761d3291a4 --- /dev/null +++ b/examples/Conditions/data/manager.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!--- Author : Markus Frank --> +<!--- Created : 2016-11-07 --> + +<conditions> + <manager> + <property name="PoolType" value="DD4hep_ConditionsLinearPool"/> + <property name="LoaderType" value="xml"/> + <property name="UserPoolType" value="DD4hep_ConditionsMapUserPool"/> + <property name="UpdatePoolType" value="DD4hep_ConditionsLinearUpdatePool"/> + </manager> + <iov_type name="epoch" id="0"/> + <iov_type name="run" id="1"/> + <iov_type name="fill" id="2"/> +</conditions> diff --git a/examples/Conditions/data/repository.xml b/examples/Conditions/data/repository.xml index e476e80c0f067a1a216309b8988c6f362fe88ac3..bc8179dac07aea89f0cfef55bd96c4d57a6c455e 100644 --- a/examples/Conditions/data/repository.xml +++ b/examples/Conditions/data/repository.xml @@ -3,19 +3,7 @@ <!--- Created : 2016-11-07 --> <conditions> - - <repository> - <manager> - <property name="PoolType" value="DD4hep_ConditionsLinearPool"/> - <property name="LoaderType" value="xml"/> - <property name="UserPoolType" value="DD4hep_ConditionsMapUserPool"/> - <property name="UpdatePoolType" value="DD4hep_ConditionsLinearUpdatePool"/> - </manager> - <iov_type name="epoch" id="0"/> - <iov_type name="run" id="1"/> - <iov_type name="fill" id="2"/> - </repository> - + <manager ref="manager.xml"/> <repository> <iov validity="1000,2000#run" ref="Modules_run-1000...2000.xml"/> </repository>