Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:12

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/DigiData.h>
0016 #include <DDDigi/DigiContainerProcessor.h>
0017 
0018 /// C/C++ include files
0019 #include <iostream>
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 move the IP of one single container
0028     /**
0029      *  Note: in place movement. Not thread safe for the containers!
0030      *
0031      *  \author  M.Frank
0032      *  \version 1.0
0033      *  \ingroup DD4HEP_DIGITIZATION
0034      */
0035     class DigiIPMover : public DigiContainerProcessor  {
0036     public:
0037 
0038       /// Standard constructor
0039       DigiIPMover(const DigiKernel& krnl, const std::string& nam)
0040     : DigiContainerProcessor(krnl, nam)
0041       {
0042       }
0043 
0044       /// Move IP location of deposits
0045       template <typename DEPOSITS> std::size_t
0046       move_deposits(const char* tag, DEPOSITS& cont, const Position& delta, const predicate_t& predicate)  const  {
0047     info("%s+++ %-32s [%6ld] IP: x:%7.3f y:%7.3f z:%7.3f", 
0048          tag, cont.name.c_str(), cont.size(), delta.X(), delta.Y(), delta.Z());
0049     for( auto& dep : cont )   {
0050       if( predicate(dep) )   {
0051         dep.second.position += delta;
0052       }
0053     }
0054     return cont.size();
0055       }
0056 
0057       /// Move IP location of MC particles
0058       template <typename PARTICLES> std::size_t
0059       move_particles(const char* tag, PARTICLES& cont, const Position& delta)  const  {
0060     info("%s+++ %-32s [%6ld] IP: x:%7.3f y:%7.3f z:%7.3f", 
0061          tag, cont.name.c_str(), cont.size(), delta.X(), delta.Y(), delta.Z());
0062     /// Move particle
0063     for( auto& p : cont )
0064       p.second.move_position(delta);
0065     return cont.size();
0066       }
0067 
0068       /// Main functional callback
0069       virtual void execute(DigiContext& context, work_t& work, const predicate_t& predicate)  const  override  {
0070     const char* tag = context.event->id();
0071     Position  delta = property("interaction_point").value<Position>();
0072     if ( auto* m = work.get_input<DepositMapping>() )
0073       move_deposits(tag, *m, delta, predicate);
0074     else if ( auto* v = work.get_input<DepositVector>() )
0075       move_deposits(tag, *v, delta, predicate);
0076     else if ( auto* p = work.get_input<ParticleMapping>() )
0077       move_particles(tag, *p, delta);
0078     else
0079       except("%s+++ Request to handle unknown data type: %s", tag, work.input_type_name().c_str());
0080     return;
0081       }
0082     };
0083   }    // End namespace digi
0084 }      // End namespace dd4hep
0085 /// Factory instantiation:
0086 #include <DDDigi/DigiFactories.h>
0087 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiIPMover)