Back to home page

EIC code displayed by LXR

 
 

    


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

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/DigiContext.h>
0016 #include <DDDigi/DigiContainerProcessor.h>
0017 
0018 /// Namespace for the AIDA detector description toolkit
0019 namespace dd4hep {
0020 
0021   /// Namespace for the Digitization part of the AIDA detector description toolkit
0022   namespace digi {
0023 
0024     /// Actor to select energy deposits according to the supplied segmentation
0025     /** Actor to select energy deposits according to the supplied segmentation
0026      *
0027      *  The selected deposits are placed in the output container
0028      *  supplied by the arguments.
0029      *
0030      *  \author  M.Frank
0031      *  \version 1.0
0032      *  \ingroup DD4HEP_DIGITIZATION
0033      */
0034     class DigiSegmentDepositExtractor : public DigiContainerProcessor   {
0035     public:
0036       /// Standard constructor
0037       DigiSegmentDepositExtractor(const DigiKernel& kernel, const std::string& nam)
0038         : DigiContainerProcessor(kernel, nam) {}
0039 
0040       template <typename T> void copy_deposits(const T& cont, work_t& work, const predicate_t& predicate)  const  {
0041     DepositVector deposits(cont.name, work.environ.output.mask, cont.data_type);
0042     for( const auto& dep : cont )   {
0043       if( predicate(dep) )   {
0044         CellID        cell = dep.first;
0045         EnergyDeposit depo = dep.second;
0046         deposits.emplace(cell, std::move(depo));
0047       }
0048     }
0049         work.environ.output.data.put(deposits.key, std::move(deposits));
0050       }
0051       /// Main functional callback
0052       virtual void execute(DigiContext&, work_t& work, const predicate_t& predicate)  const override final  {
0053         if ( const auto* m = work.get_input<DepositMapping>() )
0054           copy_deposits(*m, work, predicate);
0055         else if ( const auto* v = work.get_input<DepositVector>() )
0056           copy_deposits(*v, work, predicate);
0057         else
0058           except("Request to handle unknown data type: %s", work.input_type_name().c_str());
0059       }
0060     };
0061   }    // End namespace digi
0062 }      // End namespace dd4hep
0063 //        Factory definitiony
0064 #include <DDDigi/DigiFactories.h>
0065 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiSegmentDepositExtractor)