Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:20:18

0001 //==============================================================================
0002 //  AIDA Detector description implementation for LHCb
0003 //------------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 //  \author   Markus Frank
0011 //  \date     2018-03-08
0012 //  \version  1.0
0013 //
0014 //==============================================================================
0015 
0016 // Framework include files
0017 #include "Detector/DeAlignmentCall.h"
0018 #include "Detector/DetectorElement.h"
0019 #include "DD4hep/DetectorTools.h"
0020 #include "DD4hep/DetectorProcessor.h"
0021 #include "DD4hep/AlignmentsProcessor.h"
0022 #include "DD4hep/AlignmentsCalculator.h"
0023 #include "DDCond/ConditionsPool.h"
0024 #include "DDCond/ConditionsManager.h"
0025 
0026 using namespace dd4hep;
0027 using namespace dd4hep::cond;
0028 using namespace dd4hep::align;
0029 
0030 /// Interface to client Callback in order to update the condition
0031 Condition gaudi::DeAlignmentCall::operator()(const ConditionKey& /* key */,
0032                                              ConditionUpdateContext& ctxt)  {
0033 
0034   namespace tools = dd4hep::detail::tools;
0035   Condition       cond;
0036   UserPool* conditions = dynamic_cast<UserPool*>(&ctxt.resolver->conditionsMap());
0037   if ( conditions )    {
0038     typedef AlignmentsCalculator::OrderedDeltas Deltas;
0039     ConditionsHashMap    slice;
0040     AlignmentsCalculator calc;
0041     const IOV&        iov = conditions->validity();
0042     ConditionsManager mgr = ctxt.resolver->manager();
0043     cond = Condition(gaudi::Keys::alignmentsComputedKeyName,"Calculator");
0044     Deltas& deltas = cond.bind<Deltas>();
0045     //conditions->print("");
0046     // Test. Need to be replaced by a special scanner
0047     DetectorScanner().scan(AlignmentsCalculator::Scanner(ctxt,deltas),top);
0048     AlignmentsCalculator::Result ares = calc.compute(deltas, slice);
0049     ConditionsPool* iov_pool = mgr.registerIOV(*iov.iovType,iov.key());
0050     for(auto i=std::begin(slice.data); i != std::end(slice.data); ++i)   {
0051       Condition c = (*i).second;
0052       mgr.registerUnlocked(*iov_pool,c);
0053       conditions->insert(c);
0054     }
0055     printout(INFO,"Align","Alignments:(C:%ld,M:%ld,*:%ld) IOV:%s",
0056              ares.computed, ares.missing, ares.multiply, ctxt.iov->str().c_str());
0057     return cond;
0058   }
0059   except("DeAlignmentCall","No conditions slice present!");
0060   return cond;
0061 }