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 #include <DD4hep/DD4hepUnits.h>
0017 
0018 /// C/C++ include files
0019 #include <limits>
0020 
0021 /// Namespace for the AIDA detector description toolkit
0022 namespace dd4hep {
0023 
0024   /// Namespace for the Digitization part of the AIDA detector description toolkit
0025   namespace digi {
0026 
0027     /// Actor to smear timing information of energy deposits
0028     /**
0029      *
0030      *
0031      *  \author  M.Frank
0032      *  \version 1.0
0033      *  \ingroup DD4HEP_DIGITIZATION
0034      */
0035     class DigiDepositSmearTime : public DigiDepositsProcessor  {
0036     protected:
0037       using limit_t = std::numeric_limits<double>;
0038       /// Property: Intrinsic energy resolution constant (gaussian ~ std::sqrt(energy))
0039       double m_resolution_time                { 0e0 };
0040       /// Property: Time window within the smeared deposits shall be accepted
0041       std::pair<double, double> m_window_time { limit_t::min(), limit_t::max() };
0042 
0043     public:
0044       /// Create deposit mapping with updates on same cellIDs
0045       template <typename T> void
0046       smear(DigiContext& context, T& cont, work_t& /* work */, const predicate_t& predicate)  const  {
0047         auto& random = context.randomGenerator();
0048         std::size_t killed  = 0UL;
0049         std::size_t updated = 0UL;
0050         for( auto& dep : cont )  {
0051           if ( predicate(dep) )  {
0052             int flag = EnergyDeposit::TIME_SMEARED;
0053             double delta_T = m_resolution_time * random.gaussian();
0054             if ( delta_T < m_window_time.first || delta_T > m_window_time.second )   {
0055               flag |= EnergyDeposit::KILLED;
0056               ++killed;
0057             }
0058             if ( m_monitor ) m_monitor->time_shift(dep, delta_T);
0059             dep.second.time += delta_T;
0060             dep.second.flag |= flag;
0061             ++updated;
0062           }
0063         }
0064         if ( m_monitor ) m_monitor->count_shift(cont.size(), -killed);
0065         info("%s+++ %-32s Smeared time resolution: %6ld entries, updated %6ld killed %6ld entries from mask: %04X",
0066              context.event->id(), cont.name.c_str(), cont.size(), updated, killed, cont.key.mask());
0067       }
0068 
0069       /// Standard constructor
0070       DigiDepositSmearTime(const DigiKernel& krnl, const std::string& nam)
0071         : DigiDepositsProcessor(krnl, nam)
0072       {
0073         declareProperty("resolution_time", m_resolution_time);
0074         declareProperty("window_time",     m_window_time);
0075         DEPOSIT_PROCESSOR_BIND_HANDLERS(DigiDepositSmearTime::smear);
0076       }
0077     };
0078   }    // End namespace digi
0079 }      // End namespace dd4hep
0080 
0081 #include <DDDigi/DigiFactories.h>
0082 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiDepositSmearTime)