Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:07

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/DigiSegmentSplitter.h>
0017 #include <DDDigi/DigiContainerProcessor.h>
0018 
0019 /// Namespace for the AIDA detector description toolkit
0020 namespace dd4hep {
0021 
0022   /// Namespace for the Digitization part of the AIDA detector description toolkit
0023   namespace digi {
0024 
0025     /// Helper class to print energy deposits pre-selected by the segment splitter
0026     /** Helper class to print energy deposits pre-selected by the segment splitter
0027      *
0028      *  \author  M.Frank
0029      *  \version 1.0
0030      *  \ingroup DD4HEP_SIMULATION
0031      */
0032     class DigiSegmentDepositPrint : public DigiContainerProcessor   {
0033     public:
0034       /// Standard constructor
0035       DigiSegmentDepositPrint(const DigiKernel& kernel, const std::string& nam)
0036         : DigiContainerProcessor(kernel, nam) {}
0037 
0038       /// Single container printout
0039       template <typename T> void
0040       print(const char* fmt, const T& cont, const predicate_t& predicate)  const   {
0041         for( const auto& dep : cont )   {
0042           if( predicate(dep) )   {
0043             info(fmt, predicate.segmentation->split_id(dep.first), dep.first,
0044                  dep.second.history.hits.size(), 
0045                  dep.second.history.particles.size(),
0046                  dep.second.deposit);
0047           }
0048         }
0049       }
0050 
0051       /// Main functional callback
0052       virtual void execute(DigiContext& context, work_t& work, const predicate_t& predicate)  const override final  {
0053         using ulonglong = unsigned long long;
0054         char format[256];
0055         ::snprintf(format, sizeof(format), 
0056                    "%s[%s] %s-id: %%d [processor:%d] Cell: %%016lX mask: %016llX  "
0057                    "hist:%%4ld hits %%4ld parts. "
0058                    "entries deposit: %%f", 
0059                    context.event->id(),
0060                    predicate.segmentation->idspec.name(), predicate.segmentation->cname(),
0061                    predicate.id, ulonglong(predicate.segmentation->split_mask));
0062         if ( const auto* m = work.get_input<DepositMapping>() )
0063           print(format, *m, predicate);
0064         else if ( const auto* v = work.get_input<DepositVector>() )
0065           print(format, *v, predicate);
0066         else
0067           error("+++ Request to dump an invalid container %s", Key::key_name(work.input.key).c_str());
0068       }
0069     };
0070   }    // End namespace digi
0071 }      // End namespace dd4hep
0072 
0073 ///        Factory definition
0074 #include <DDDigi/DigiFactories.h>
0075 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiSegmentDepositPrint)