diff --git a/DDAlign/include/DDAlign/AlignmentUpdateCall.h b/DDAlign/include/DDAlign/AlignmentUpdateCall.h new file mode 100644 index 0000000000000000000000000000000000000000..ed55cf3f1d842e919148281dcee575f6a9038329 --- /dev/null +++ b/DDAlign/include/DDAlign/AlignmentUpdateCall.h @@ -0,0 +1,78 @@ +// $Id$ +//========================================================================== +// 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_ALIGMENTS_ALIGNMENTUPDATECALL_H +#define DD4HEP_ALIGMENTS_ALIGNMENTUPDATECALL_H + +// Framework include files +#include "DD4hep/ConditionDerived.h" +#include "DD4hep/AlignmentData.h" +#include "DD4hep/Alignments.h" + +/// Namespace for the AIDA detector description toolkit +namespace DD4hep { + + /// Namespace for the alignment part of the AIDA detector description toolkit + namespace Alignments { + + /// Specialized conditions update callback for alignment condition objects + /** + * Used by clients to update an alignment condition. + * The input data, a condition with an AbstractMap data structure + * containing the alignment delta data. + * + * The condition must be fully computed in two steps: + * - firstly it is created here and the alignment delta copied. + * - secondly, once all updates are processed, the world-transformations + * for the alignment object(s) are computed by the AlignmentManager + * objects. + * The AlignmentManager also keeps track of newly created alignment + * conditions and is informed in the callback. + * + * \author M.Frank + * \version 1.0 + * \ingroup DD4HEP_CONDITIONS + */ + class AlignmentUpdateCall : public Conditions::ConditionUpdateCall { + public: + typedef Conditions::Condition Condition; + typedef Conditions::ConditionKey ConditionKey; + typedef Conditions::ConditionUpdateContext UpdateContext; + typedef Alignments::AlignmentData Data; + typedef Alignments::AlignmentData::Delta Delta; + + public: + /// Default constructor + AlignmentUpdateCall(); + /// Default destructor + virtual ~AlignmentUpdateCall(); + /// Interface to client Callback in order to update the condition. To be overloaded by sub-class + virtual Condition operator()(const ConditionKey& key, const UpdateContext& context) = 0; + /// Callback to build the alignment conditions object and assign the delta + /** Please Note: + * We MUST register the undigested condition to the alignment manager in order to + * later be able to compute the derived transformations. + * The derived transfomrations can only be computed 'later' once ALL delta stubs + * of a given consisten set of alignment transactions are present. The trafo + * computation must take place in a second pass. + * This is necessary, because the parent information may actually be supplied also 'later'. + * + * 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); + }; + + } /* End namespace Aligments */ +} /* End namespace DD4hep */ +#endif /* DD4HEP_ALIGMENTS_ALIGNMENTUPDATECALL_H */ diff --git a/DDAlign/include/DDAlign/AlignmentsManager.h b/DDAlign/include/DDAlign/AlignmentsManager.h index a626bbefc36becdb6f683aee6ee2c6726d0d7980..7402335b803e80430cf99dd06a92dd479243d3f3 100644 --- a/DDAlign/include/DDAlign/AlignmentsManager.h +++ b/DDAlign/include/DDAlign/AlignmentsManager.h @@ -35,8 +35,9 @@ namespace DD4hep { /// Forward declarations class AlignContext; + class AlignmentsManager; class AlignmentsManagerObject; - + /// Alignment manager instance to handle alignment dependencies /** * \author M.Frank diff --git a/DDAlign/src/AlignmentUpdateCall.cpp b/DDAlign/src/AlignmentUpdateCall.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1924ed117a8a1afe8d0b8540ab813a0602e67332 --- /dev/null +++ b/DDAlign/src/AlignmentUpdateCall.cpp @@ -0,0 +1,46 @@ +// $Id$ +//========================================================================== +// 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 include files +#include "DDAlign/AlignmentUpdateCall.h" +#include "DDAlign/AlignmentsManager.h" +#include "DD4hep/InstanceCount.h" + +using namespace DD4hep::Alignments; + +/// Default constructor +AlignmentUpdateCall::AlignmentUpdateCall() : DD4hep::Conditions::ConditionUpdateCall() +{ +} + +/// Default destructor +AlignmentUpdateCall::~AlignmentUpdateCall() { +} + +AlignmentUpdateCall::Condition +AlignmentUpdateCall::handle(const ConditionKey& key, const UpdateContext& ctxt, const Delta& delta) +{ + AlignmentCondition target(key.name); + AlignmentData& data = target.data(); + data.delta = delta; + data.flag = AlignmentData::HAVE_NONE; + data.detector = ctxt.dependency.detector; + // We MUST register the undigested condition to the alignment manager in order to + // later be able to compute the derived transformations. + // The derived transfomrations can only be computed 'later' once all delta stubs + // are present in a second pass. This is necessary, because the parent information + // may actually be supplied also 'later'. + AlignmentsManager::newEntry(ctxt, data.detector, &ctxt.dependency, target); + return target; +} diff --git a/DDAlign/src/AlignmentsManager.cpp b/DDAlign/src/AlignmentsManager.cpp index 6faa5c149ee7f9a17b3c9cef2dbc3df972cb939d..9314678a9f9d310b286219955bca57d57c59eb85 100644 --- a/DDAlign/src/AlignmentsManager.cpp +++ b/DDAlign/src/AlignmentsManager.cpp @@ -16,6 +16,7 @@ #include "DD4hep/LCDD.h" #include "DD4hep/Handle.inl" #include "DD4hep/Printout.h" +#include "DD4hep/InstanceCount.h" #include "DD4hep/MatrixHelpers.h" #include "DDCond/ConditionsPool.h" #include "DDAlign/AlignmentsManager.h" @@ -50,7 +51,12 @@ namespace DD4hep { Keys keys; Entries entries; unsigned long long int magic; - AlignContext() : magic(magic_word()) {} + AlignContext() : magic(magic_word()) { + InstanceCount::increment(this); + } + ~AlignContext() { + InstanceCount::decrement(this); + } void newEntry(DetElement det, const Dependency* dep, AlignmentCondition::Object* con) { if ( det.isValid() ) { Entry entry; @@ -83,6 +89,7 @@ DD4HEP_INSTANTIATE_HANDLE_NAMED(AlignmentsManagerObject); /// Initializing constructor AlignmentsManagerObject::AlignmentsManagerObject() : NamedObject() { + InstanceCount::increment(this); all_alignments = new AlignContext(); dependencies = new Dependencies(); } @@ -92,6 +99,7 @@ AlignmentsManagerObject::~AlignmentsManagerObject() { dependencies->clear(); deletePtr(dependencies); deletePtr(all_alignments); + InstanceCount::decrement(this); } void AlignmentsManagerObject::to_world(AlignContext& new_alignments, UserPool& pool, DetElement det, TGeoHMatrix& mat) const { diff --git a/DDAlign/src/plugins/AlignmentPlugins.cpp b/DDAlign/src/plugins/AlignmentPlugins.cpp index ab2e71950b33a55d3caf2c5eccc1630d95fb7d5f..3fefd1e623762f689b070e6e6a2082e8625a0df1 100644 --- a/DDAlign/src/plugins/AlignmentPlugins.cpp +++ b/DDAlign/src/plugins/AlignmentPlugins.cpp @@ -14,11 +14,11 @@ // Framework includes #include "DD4hep/Printout.h" -#include "DD4hep/DetFactoryHelper.h" #include "DD4hep/DetectorTools.h" +#include "DD4hep/DetFactoryHelper.h" -using namespace std; using namespace DD4hep; +using namespace DD4hep::Alignments; // ====================================================================================== #include "DDAlign/AlignmentsManager.h" @@ -27,8 +27,6 @@ namespace { /// Plugin function: /// Install the alignment manager as an extension to the central LCDD object int ddalign_install_align_mgr (Geometry::LCDD& lcdd, int /* argc */, char** /* argv */) { - using Alignments::AlignmentsManager; - using Alignments::AlignmentsManagerObject; Handle<AlignmentsManagerObject> mgr(lcdd.extension<AlignmentsManagerObject>(false)); if ( !mgr.isValid() ) { AlignmentsManager mgr_handle("LCDD_AlignmentManager"); @@ -39,14 +37,14 @@ namespace { } } /* End anonymous namespace */ DECLARE_APPLY(DD4hep_AlignmentsManagerInstaller,ddalign_install_align_mgr) -// ====================================================================================== +// ====================================================================================== #include "DDAlign/AlignmentWriter.h" namespace { namespace DetectorTools = DD4hep::Geometry::DetectorTools; - long create_alignment_file(Geometry::LCDD& lcdd, int argc, char** argv) { + long create_global_alignment_file(Geometry::LCDD& lcdd, int argc, char** argv) { Geometry::DetElement top; - string output, path = "/world"; + std::string output, path = "/world"; bool enable_transactions = false; for(int i=1; i<argc;++i) { if ( argv[i][0]=='-' || argv[i][0]=='/' ) { @@ -58,7 +56,7 @@ namespace { else if ( strncmp(argv[i]+1,"-transactions",5)==0 ) enable_transactions = true; else - throw runtime_error("AlignmentWriter: Invalid argument:"+string(argv[i])); + throw std::runtime_error("AlignmentWriter: Invalid argument:"+std::string(argv[i])); } } printout(ALWAYS,"AlignmentWriter", @@ -66,11 +64,11 @@ namespace { path.c_str(), output.c_str()); top = DetectorTools::findDaughterElement(lcdd.world(),path); if ( top.isValid() ) { - Alignments::AlignmentWriter wr(lcdd); + AlignmentWriter wr(lcdd); return wr.write(wr.dump(top,enable_transactions), output); } - throw runtime_error("AlignmentWriter: Invalid top level element name:"+path); + throw std::runtime_error("AlignmentWriter: Invalid top level element name:"+path); } } /* End anonymous namespace */ -DECLARE_APPLY(DDAlignmentWriter, create_alignment_file) +DECLARE_APPLY(DD4hep_GlobalAlignmentWriter, create_global_alignment_file) // ====================================================================================== diff --git a/DDDB/include/DDDB/DDDBAlignmentUpdateCall.h b/DDDB/include/DDDB/DDDBAlignmentUpdateCall.h index 2be998090935941dcfdb97ea899d33c9260d2406..25c4c5173ea5eca907fb00f4fb8b72322a2b56f5 100644 --- a/DDDB/include/DDDB/DDDBAlignmentUpdateCall.h +++ b/DDDB/include/DDDB/DDDBAlignmentUpdateCall.h @@ -21,7 +21,7 @@ #define DD4HEP_DDDB_DDDBALIGNMENTUPDATECALL_H // Framework includes -#include "DD4hep/ConditionDerived.h" +#include "DDAlign/AlignmentUpdateCall.h" /// Namespace for the AIDA detector description toolkit namespace DD4hep { @@ -47,14 +47,10 @@ namespace DD4hep { * \version 1.0 * \ingroup DD4HEP_CONDITIONS */ - class DDDBAlignmentUpdateCall : public Conditions::ConditionUpdateCall { - public: - typedef Conditions::Condition Condition; - typedef Conditions::ConditionKey ConditionKey; - typedef Conditions::ConditionUpdateContext UpdateContext; + class DDDBAlignmentUpdateCall : public Alignments::AlignmentUpdateCall { public: /// Default constructor - DDDBAlignmentUpdateCall(); + DDDBAlignmentUpdateCall() : Alignments::AlignmentUpdateCall() {} /// Default destructor virtual ~DDDBAlignmentUpdateCall(); /// Interface to client Callback in order to update the condition diff --git a/DDDB/src/DDDBAlignmentTest.cpp b/DDDB/src/DDDBAlignmentTest.cpp index f45f21e983238a595fcb4749f305cf271c63b20c..36d67337fa7a77880c910f924da5d275c584ce1b 100644 --- a/DDDB/src/DDDBAlignmentTest.cpp +++ b/DDDB/src/DDDBAlignmentTest.cpp @@ -195,10 +195,9 @@ namespace { DD4hep::InstanceCount::dump(); } } - align.destroy(); return ret; } -} /* End anonymous namespace */ +} /* End anonymous namespace */ DECLARE_APPLY(DDDB_DerivedAlignmentsTest,dddb_derived_alignments) //========================================================================== @@ -214,9 +213,8 @@ namespace { if ( ret == 1 ) { ret = selec.access(conds,align,time); } - align.destroy(); return ret; } -} /* End anonymous namespace */ +} /* End anonymous namespace */ DECLARE_APPLY(DDDB_AlignmentsAccessTest,dddb_access_alignments) //========================================================================== diff --git a/DDDB/src/DDDBAlignmentUpdateCall.cpp b/DDDB/src/DDDBAlignmentUpdateCall.cpp index 6cb42f909dce1c07e6c3166fe97dcae873fa01bd..64c033a77c3dcb54ea3f7b65f81a56fe27a644e4 100644 --- a/DDDB/src/DDDBAlignmentUpdateCall.cpp +++ b/DDDB/src/DDDBAlignmentUpdateCall.cpp @@ -21,20 +21,12 @@ // Framework includes #include "DDDB/DDDBAlignmentUpdateCall.h" #include "DDDB/DDDBConditionPrinter.h" -#include "DDAlign/AlignmentsManager.h" #include "DD4hep/ConditionsData.h" -#include "DD4hep/Alignments.h" #include "DD4hep/Printout.h" using namespace DD4hep; using namespace DD4hep::Conditions; -/// Default constructor -DDDB::DDDBAlignmentUpdateCall::DDDBAlignmentUpdateCall() - : Conditions::ConditionUpdateCall() -{ -} - /// Default destructor DDDB::DDDBAlignmentUpdateCall::~DDDBAlignmentUpdateCall() { } @@ -43,31 +35,25 @@ DDDB::DDDBAlignmentUpdateCall::~DDDBAlignmentUpdateCall() { DDDB::DDDBAlignmentUpdateCall::Condition DDDB::DDDBAlignmentUpdateCall::operator()(const ConditionKey& key, const UpdateContext& context) { - typedef OpaqueDataBlock Param; - typedef Alignments::AlignmentData Data; - Alignments::AlignmentCondition target(key.name); - Data& data = target.data(); - Condition cond = context.condition(0); - AbstractMap& src = cond.get<AbstractMap>(); - const Param& par = src.firstParam().second; - DetElement det = context.dependency.detector; + Condition cond = context.condition(0); + AbstractMap& src = cond.get<AbstractMap>(); + OpaqueDataBlock& par = src.firstParam().second; + DetElement det = context.dependency.detector; printout(DEBUG,"AlignmentUpdate","++ Building dependent condition: %s Detector [%d]: %s ", key.name.c_str(), det.level(), det.path().c_str()); if ( par.typeInfo() == typeid(Data::Delta) ) { const Data::Delta& delta = src.first<Data::Delta>(); - data.delta = delta; - data.flag = Data::HAVE_NONE; - } - else { - printout(INFO,"AlignmentUpdate","++ Failed to access alignment-Delta from %s", - cond->value.c_str()); - ConditionPrinter()(cond); + return AlignmentUpdateCall::handle(key, context, delta); } + // Somehow the condition is not of type Data::Delta. This is an ERROR. + // Here only print and return an empty alignment condition. + // Otherwise the return is not accepted! + // TODO: To be decided how to handle this error + Alignments::AlignmentCondition target(key.name); + Data& data = target.data(); data.detector = det; - Alignments::AlignmentsManager::newEntry(context, det, &context.dependency, target); - // A callback returning no condition is illegal! - // Need to crosscheck though if the alignment IOV interval of parents may be - // smaller then the daughter IOV interval. - // I though expect, that this is a purely academic case. + printout(INFO,"AlignmentUpdate","++ Failed to access alignment-Delta from %s", + cond->value.c_str()); + ConditionPrinter()(cond); return target; } diff --git a/doc/git.cmds b/doc/git.cmds index 1a745286c501fb8f16a53033279006e730bde4b4..23abe6f0968d3f3b9360a212a81ab7fdaa9ab769 100644 --- a/doc/git.cmds +++ b/doc/git.cmds @@ -10,13 +10,16 @@ git diff --staged ## Equiv to svn diff (raw stuff) git diff +## svn diff for one git repository +git diff --numstat downstream/master + ## Equiv svn status git status ## Push for running tests git push gitlab - +## Damned password: ## Adding ssh key using web page!