Back to home page

EIC code displayed by LXR

 
 

    


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

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 #ifndef DIGI_DIGIEDM4HEPOUTPUT_H
0014 #define DIGI_DIGIEDM4HEPOUTPUT_H
0015 
0016 // Framework include files
0017 #include <DDDigi/DigiOutputAction.h>
0018 
0019 /// C/C++ include files
0020 #if __has_include("edm4hep/TrackerHitCollection.h")
0021 #include <edm4hep/TrackerHitCollection.h>
0022 namespace edm4hep {
0023   using TrackerHit3DCollection = edm4hep::TrackerHitCollection;
0024 }
0025 #else
0026 #include <edm4hep/TrackerHit3DCollection.h>
0027 #endif
0028 
0029 /// Forward declarations from edm4hep
0030 namespace edm4hep  {
0031   class CalorimeterHitCollection;
0032 }
0033 
0034 /// Namespace for the AIDA detector description toolkit
0035 namespace dd4hep {
0036 
0037   /// Namespace for the Digitization part of the AIDA detector description toolkit
0038   namespace digi {
0039 
0040     /// Event action to support edm4hep output format from DDDigi
0041     /**
0042      *  Supported output containers types are:
0043      *  - edm4hep::MCParticles aka "MCParticles"
0044      *  - edm4hep::CalorimeterHitCollection  aka "CalorimeterHits"
0045      *  - edm4hep::TrackerHit3DCollection aka "TracketHits"
0046      *
0047      *  This entity actually is only the work dispatcher:
0048      *  It opens files and dumps data into
0049      *
0050      *  \author  M.Frank
0051      *  \version 1.0
0052      *  \ingroup DD4HEP_DIGITIZATION
0053      */
0054     class DigiEdm4hepOutput : public  DigiOutputAction  {
0055     public:
0056       class internals_t;
0057     protected:
0058       /// Reference to internals
0059       std::shared_ptr<internals_t> internals;
0060 
0061     protected:
0062       /// Define standard assignments and constructors
0063       DDDIGI_DEFINE_ACTION_CONSTRUCTORS(DigiEdm4hepOutput);
0064       /// Default destructor
0065       virtual ~DigiEdm4hepOutput();
0066 
0067     public:
0068       /// Standard constructor
0069       DigiEdm4hepOutput(const kernel_t& kernel, const std::string& nam);
0070       /// Initialization callback
0071       virtual void initialize();
0072       /// Check for valid output stream
0073       virtual bool have_output()  const  override final;
0074       /// Open new output stream
0075       virtual void open_output() const  override final;
0076       /// Close possible open stream
0077       virtual void close_output()  const  override final;
0078       /// Commit event data to output stream
0079       virtual void commit_output() const  override final;
0080     };
0081 
0082     /// Actor to save individual data containers to edm4hep
0083     /** The processor is the actual unit doing the work.
0084      *
0085      *  This is a typical worker action of the DigiEdm4hepOutput
0086      *
0087      *  \author  M.Frank
0088      *  \version 1.0
0089      *  \ingroup DD4HEP_DIGITIZATION
0090      */
0091     class DigiEdm4hepOutputProcessor : public DigiContainerProcessor   {
0092       friend class DigiEdm4hepOutput;
0093 
0094     protected:
0095       /// Reference to the edm4hep engine
0096       std::shared_ptr<DigiEdm4hepOutput::internals_t> internals;
0097       /// Property: RPhi resolution
0098       float m_pointResoutionRPhi = 0.004;
0099       /// Property: Z resolution
0100       float m_pointResoutionZ = 0.004;
0101       /// Hit type for hit processor
0102       int   m_hit_type = 0;
0103 
0104     public:
0105       /// Standard constructor
0106       DigiEdm4hepOutputProcessor(const DigiKernel& krnl, const std::string& nam);
0107 
0108       /// Standard destructor
0109       virtual ~DigiEdm4hepOutputProcessor() = default;
0110 
0111       /// Convert tracker hits to edm4hep
0112       template <typename T> void
0113       convert_depos(const T& cont, const predicate_t& predicate, edm4hep::TrackerHit3DCollection* collection)  const;
0114 
0115       /// Convert calorimeter hits to edm4hep
0116       template <typename T> void
0117       convert_depos(const T& cont, const predicate_t& predicate, edm4hep::CalorimeterHitCollection* collection)  const;
0118 
0119       /// Dispatcher function to convert any kind of deposits
0120       template <typename T> void
0121       convert_deposits(DigiContext& context, const T& cont, const predicate_t& predicate)  const;
0122 
0123       /// Convert history records to edm4hep
0124       void convert_history(DigiContext& context, const DepositsHistory& cont, work_t& work, const predicate_t& predicate)  const;
0125 
0126       /// Convert particle record to edm4hep
0127       void convert_particles(DigiContext& context, const ParticleMapping& cont)  const;
0128 
0129       /// Main functional callback
0130       virtual void execute(DigiContext& context, work_t& work, const predicate_t& predicate)  const override final;
0131     };
0132   }    // End namespace digi
0133 }      // End namespace dd4hep
0134 #endif // DIGI_DIGIEDM4HEPOUTPUT_H