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 /// C/C++ include files
0018 #include <limits>
0019 
0020 /// Namespace for the AIDA detector description toolkit
0021 namespace dd4hep {
0022 
0023   /// Namespace for the Digitization part of the AIDA detector description toolkit
0024   namespace digi {
0025 
0026     /// Actor to merge energy deposits weighted with their energy deposit
0027     /**
0028      *  The selected deposits are placed in the output container
0029      *  supplied by the arguments. Multiple CellIDs will be merged to one single 
0030      *  deposit, where the merge computes the resulting position and
0031      *  momentum according to the contribution of the hits.
0032      *
0033      *  \author  M.Frank
0034      *  \version 1.0
0035      *  \ingroup DD4HEP_DIGITIZATION
0036      */
0037     class DigiDepositWeightedPosition : public DigiDepositsProcessor   {
0038     protected:
0039       /// Property: Energy cutoff. No hits will be merged with a deposit smaller
0040       double m_cutoff { -std::numeric_limits<double>::epsilon() };
0041 
0042     public:
0043       /// Create deposit mapping with updates on same cellIDs
0044       template <typename T> void
0045       create_deposits(context_t& context, const T& cont, work_t& work, const predicate_t& predicate)  const  {
0046         Key key(cont.name, work.environ.output.mask);
0047         DepositMapping m(cont.name, work.environ.output.mask, cont.data_type );
0048         std::size_t dropped = 0UL, updated = 0UL, added = 0UL;
0049         for( const auto& dep : cont )    {
0050           if ( predicate(dep) )   {
0051             const EnergyDeposit& depo = dep.second;
0052             if ( depo.deposit >= m_cutoff )   {
0053               CellID cell = dep.first;
0054               auto   iter = m.data.find(cell);
0055               if ( iter == m.data.end() )
0056                 m.data.emplace(dep.first, depo), ++added;
0057               else
0058                 iter->second.update_deposit_weighted(depo), ++updated;
0059               continue;
0060             }
0061             ++dropped;
0062           }
0063         }
0064         info("%s+++ %-32s added %6ld updated %6ld dropped %6ld entries (now: %6ld) from mask: %04X to mask: %04X",
0065              context.event->id(), cont.name.c_str(), added, updated, dropped, m.size(), cont.key.mask(), m.key.mask());
0066         work.environ.output.data.put(m.key, std::move(m));
0067       }
0068 
0069       /// Standard constructor
0070       DigiDepositWeightedPosition(const DigiKernel& krnl, const std::string& nam)
0071         : DigiDepositsProcessor(krnl, nam)
0072       {
0073         declareProperty("deposit_cutoff", m_cutoff);
0074         DEPOSIT_PROCESSOR_BIND_HANDLERS(DigiDepositWeightedPosition::create_deposits);
0075       }
0076     };
0077   }    // End namespace digi
0078 }      // End namespace dd4hep
0079 
0080 #include <DDDigi/DigiFactories.h>
0081 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiDepositWeightedPosition)