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/InstanceCount.h>
0017 #include <DD4hep/DD4hepUnits.h>
0018 
0019 /// C/C++ include files
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 DigiDepositRecalibEnergy : public DigiDepositsProcessor   {
0036     protected:
0037       /// Property: Polynomial parameters to recalibrate the energy
0038       std::vector<double> m_polynomial        {  };
0039       /// Property: Energy base point to compute delta(energy)
0040       double              m_e0                { 0e0 };
0041 
0042     public:
0043       /// Standard constructor
0044       DigiDepositRecalibEnergy(const DigiKernel& krnl, const std::string& nam)
0045         : DigiDepositsProcessor(krnl, nam)
0046       {
0047         declareProperty("e0", m_e0);
0048         declareProperty("parameters" , m_polynomial);
0049         DEPOSIT_PROCESSOR_BIND_HANDLERS(DigiDepositRecalibEnergy::recalibrate_deposit_energy);
0050       }
0051 
0052       /// Create deposit mapping with updates on same cellIDs
0053       template <typename T> void 
0054       recalibrate_deposit_energy(DigiContext& context, T& cont, work_t& /* work */, const predicate_t& predicate)  const  {
0055         std::size_t updated = 0UL;
0056         for( auto& dep : cont )    {
0057           if ( predicate(dep) )   {
0058             double deposit = dep.second.deposit;
0059             double delta_E = deposit - m_e0;
0060             double fac     = 1e0;
0061             for( double param : m_polynomial )   {
0062               deposit += param * fac;
0063               fac     *= delta_E;
0064             }
0065             if ( m_monitor ) m_monitor->energy_shift(dep, delta_E);
0066             dep.second.deposit = deposit;
0067             dep.second.flag |= EnergyDeposit::RECALIBRATED;
0068             ++updated;
0069           }
0070         }
0071         info("%s+++ %-32s Recalibrating: updated %6ld out of %6ld entries from mask: %04X",
0072              context.event->id(), cont.name.c_str(), updated, cont.size(), cont.key.mask());
0073       }
0074     };
0075   }    // End namespace digi
0076 }      // End namespace dd4hep
0077 
0078 #include <DDDigi/DigiFactories.h>
0079 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiDepositRecalibEnergy)