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      *  \author  M.Frank
0031      *  \version 1.0
0032      *  \ingroup DD4HEP_DIGITIZATION
0033      */
0034     class DigiDepositNoiseOnSignal : public DigiDepositsProcessor  {
0035     protected:
0036       /// Property: Mean of the added noise on signal in absolute values 
0037       double m_mean                { 0e0 };
0038       /// Property: Sigma of the noise in absolute values
0039       double m_sigma               { 0e0 };
0040 
0041     public:
0042       /// Create deposit mapping with updates on same cellIDs
0043       template <typename T> void
0044       create_noise(DigiContext& context, T& cont, work_t& /* work */, const predicate_t& predicate)  const  {
0045         auto& random = context.randomGenerator();
0046         std::size_t updated = 0UL;
0047         for( auto& dep : cont )  {
0048           if ( predicate(dep) )  {
0049             int flag = EnergyDeposit::DEPOSIT_NOISE;
0050             double delta_E = random.gaussian(m_mean, m_sigma);
0051             if ( m_monitor ) m_monitor->energy_shift(dep, delta_E);
0052             dep.second.deposit += delta_E;
0053             dep.second.flag |= flag;
0054             ++updated;
0055           }
0056         }
0057         info("%s+++ %-32s Noise on signal: %6ld entries, updated %6ld entries. mask: %04X",
0058              context.event->id(), cont.name.c_str(), cont.size(), updated, cont.key.mask());
0059       }
0060 
0061       /// Standard constructor
0062       DigiDepositNoiseOnSignal(const DigiKernel& krnl, const std::string& nam)
0063         : DigiDepositsProcessor(krnl, nam)
0064       {
0065         declareProperty("mean",  m_mean);
0066         declareProperty("sigma", m_sigma);
0067         DEPOSIT_PROCESSOR_BIND_HANDLERS(DigiDepositNoiseOnSignal::create_noise);
0068       }
0069     };
0070   }    // End namespace digi
0071 }      // End namespace dd4hep
0072 /// Factory instantiation:
0073 #include <DDDigi/DigiFactories.h>
0074 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiDepositNoiseOnSignal)