Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /DD4hep/DDDigi/src/DigiSynchronize.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
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     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework include files
0015 #include <DD4hep/InstanceCount.h>
0016 #include <DDDigi/DigiKernel.h>
0017 #include <DDDigi/DigiContext.h>
0018 #include <DDDigi/DigiSynchronize.h>
0019 
0020 // C/C++ include files
0021 #include <stdexcept>
0022 
0023 using namespace dd4hep::digi;
0024 
0025 
0026 template <> void 
0027 DigiParallelWorker<DigiEventAction, DigiSynchronize::work_t, std::size_t, DigiSynchronize&>::execute(void* data) const  {
0028   calldata_t* args = reinterpret_cast<calldata_t*>(data);
0029   action->execute(*args);
0030 }
0031 
0032 /// Standard constructor
0033 DigiSynchronize::DigiSynchronize(const DigiKernel& kernel, const std::string& nam)
0034   : DigiEventAction(kernel, nam)
0035 {
0036   InstanceCount::increment(this);
0037 }
0038 
0039 /// Default destructor
0040 DigiSynchronize::~DigiSynchronize() {
0041   InstanceCount::decrement(this);
0042 }
0043 
0044 /// Pre-track action callback
0045 void DigiSynchronize::execute(DigiContext& context)  const   {
0046   auto start = std::chrono::high_resolution_clock::now();
0047   if ( !m_actors.empty() )   {
0048     m_kernel.submit(context, m_actors.get_group(), m_actors.size(), &context, m_parallel);
0049   }
0050   std::chrono::duration<double> secs = std::chrono::high_resolution_clock::now() - start;
0051   const DigiEvent& ev = *context.event;
0052   debug("%s+++ Event: %8d (DigiSynchronize) Parallel: %-4s  %3ld actions [%8.3g sec]",
0053         ev.id(), ev.eventNumber, yes_no(m_parallel), m_actors.size(),
0054         secs.count());
0055 }
0056 
0057 /// Add an actor responding to all callbacks. Sequence takes ownership.
0058 void DigiSynchronize::adopt(DigiEventAction* action) {
0059   if (action)    {
0060     m_actors.insert(new worker_t(action, m_actors.size(), *this));
0061     return;
0062   }
0063   except("DigiSynchronize","++ Attempt to add invalid actor!");
0064 }