Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:06

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 <DDDigi/DigiContainerProcessor.h>
0016 
0017 /// Namespace for the AIDA detector description toolkit
0018 namespace dd4hep {
0019 
0020   /// Namespace for the Digitization part of the AIDA detector description toolkit
0021   namespace digi {
0022 
0023     /// Actor to drop energy deposits of a container having deposits with the "KILLED" flag set
0024     /**
0025      *
0026      *  \author  M.Frank
0027      *  \version 1.0
0028      *  \ingroup DD4HEP_DIGITIZATION
0029      */
0030     class DigiDepositDropKilled : public DigiContainerProcessor   {
0031     public:
0032       /// Standard constructor
0033       using DigiContainerProcessor::DigiContainerProcessor;
0034 
0035       /// Main functional callback
0036       virtual void execute(DigiContext& context, work_t& work, const predicate_t&)  const override final  {
0037         std::size_t killed = 0, total = 0, i = 0;
0038         if ( auto* v = work.get_input<DepositVector>() )   {
0039           total = v->size();
0040           for( auto iter = v->begin(); iter != v->end(); ++iter, ++i )   {
0041             if ( v->at(i).flag&EnergyDeposit::KILLED )   {
0042               v->remove(iter);
0043               iter = v->begin() + (--i);
0044             }
0045           }
0046           killed = total - v->size();
0047         }
0048         else if ( auto* m = work.get_input<DepositMapping>() )   {
0049           CellID last_cell = ~0x0ULL;
0050           total = m->size();
0051           for( auto iter = m->begin(); iter != m->end(); ++iter )   {
0052             if ( iter->second.flag&EnergyDeposit::KILLED )   {
0053               m->remove(iter);
0054               iter = (last_cell != ~0x0ULL) ? m->data.find(last_cell) : m->begin();
0055               if ( iter == m->end() ) iter = m->begin();
0056               if ( iter == m->end() ) break;
0057               continue;
0058             }
0059             last_cell = iter->first;
0060           }
0061           killed = total - m->size();
0062         }
0063         else   {
0064           except("Request to handle unknown data type: %s", work.input_type_name().c_str());
0065         }
0066         if ( m_monitor ) m_monitor->count_shift(total, killed);
0067         info("%s+++ Killed %6ld out of %6ld deposit entries from container: %s",context.event->id(), killed, total);
0068       }
0069     };
0070   }    // End namespace digi
0071 }      // End namespace dd4hep
0072 
0073 #include <DDDigi/DigiFactories.h>
0074 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiDepositDropKilled)