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