Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:14

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/DigiInputAction.h>
0017 
0018 /// C/C++ include files
0019 #include <stdexcept>
0020 #include <unistd.h>
0021 
0022 using namespace dd4hep::digi;
0023 
0024 /// Standard constructor
0025 DigiInputAction::DigiInputAction(const DigiKernel& kernel, const std::string& nam)
0026   : DigiEventAction(kernel, nam)
0027 {
0028   declareProperty("input",            m_input_sources);
0029   declareProperty("segment",          m_input_segment);
0030   declareProperty("mask",             m_input_mask);
0031   declareProperty("rescan",           m_input_rescan);
0032   declareProperty("input_section",    m_input_section);
0033   declareProperty("objects_enabled",  m_objects_enabled);
0034   declareProperty("objects_disabled", m_objects_disabled);
0035   declareProperty("events_per_file",  m_events_per_file);
0036   declareProperty("keep_raw",         m_keep_raw);
0037   InstanceCount::increment(this);
0038 }
0039 
0040 /// Default destructor
0041 DigiInputAction::~DigiInputAction()   {
0042   InstanceCount::decrement(this);
0043 }
0044 
0045 /// Check if the number of events per file is reached
0046 bool DigiInputAction::fileLimitReached(input_source& source)   const    {
0047   if ( m_events_per_file > 0 )    {
0048     if ( source.event_count > m_events_per_file )  {
0049       return true;
0050     }
0051   }
0052   return false;
0053 }
0054 
0055 /// Callback when a new file is opened
0056 void DigiInputAction::onOpenFile(input_source& source)    {
0057   source.event_count = 0;
0058 }
0059 
0060 /// Callback when a new event is processed
0061 void DigiInputAction::onProcessEvent(input_source& source, event_frame& /* frame */)   {
0062   ++source.event_count = 0;
0063 }
0064 
0065 /// Check if a event object should be loaded: Default YES unless inhibited by selection or veto
0066 bool DigiInputAction::object_loading_is_enabled(const std::string& nam)  const   {
0067   /// If there are no required branches, we convert everything
0068   if ( m_objects_enabled.empty() && m_objects_disabled.empty() )    {
0069     return true;
0070   }
0071   /// Check for disabled collections:
0072   for( const auto& bname : m_objects_disabled )    {
0073     if ( bname == nam )
0074       return false;
0075   }
0076   /// No selection to be performed: take them all
0077   if ( m_objects_enabled.empty() )    {
0078     return true;
0079   }
0080   /// .... Otherwise only the entities asked for
0081   for( const auto& bname : m_objects_enabled )    {
0082     if ( bname == nam )   {
0083       return true;
0084     }
0085   }
0086   return false;
0087 }
0088 
0089 /// Pre-track action callback
0090 void DigiInputAction::execute(DigiContext& /* context */)  const   {
0091   info("+++ Virtual method execute() --- Should not be called");
0092   ::sleep(1);
0093 }