Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-05 08:13:59

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 //====================================================================
0011 //
0012 // Define the ROOT dictionaries for all data classes to be saved 
0013 // which are created by the DDG4 examples.
0014 //
0015 //  Author     : M.Frank
0016 //
0017 //====================================================================
0018 
0019 #if defined(__GNUC__)
0020 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
0021 #pragma GCC diagnostic ignored "-Wdeprecated"
0022 #pragma GCC diagnostic ignored "-Wunused"
0023 #pragma GCC diagnostic ignored "-Woverlength-strings"
0024 
0025 #elif defined(__llvm__) || defined(__APPLE__)
0026 
0027 #pragma clang diagnostic ignored "-Wdefaulted-function-deleted"
0028 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
0029 #pragma clang diagnostic ignored "-Wdeprecated"
0030 #pragma clang diagnostic ignored "-Wunused"
0031 #pragma clang diagnostic ignored "-Woverlength-strings"
0032 #endif
0033 
0034 #include <DDDigi/DigiData.h>
0035 #include <DDDigi/DigiHandle.h>
0036 #include <DDDigi/DigiKernel.h>
0037 #include <DDDigi/DigiContext.h>
0038 #include <DDDigi/DigiAction.h>
0039 #include <DDDigi/DigiEventAction.h>
0040 #include <DDDigi/DigiContainerProcessor.h>
0041 
0042 #include <list>
0043 
0044 struct DDDigiDict  {};
0045 
0046 /// Namespace for the AIDA detector description toolkit
0047 namespace dd4hep {
0048 
0049   int init_grammar_types();
0050   
0051   /// Namespace for the Digitization part of the AIDA detector description toolkit
0052   namespace digi {
0053 
0054     template <typename VAL>
0055     int add_action_property(DigiAction* action, const std::string& name, VAL value);
0056 
0057     struct ActionHandle  {
0058       DigiAction* action;
0059       explicit ActionHandle(DigiAction* a) : action(a)  {
0060         if (action) action->addRef();
0061       }
0062       ActionHandle(const ActionHandle& h) : action(h.action) {
0063         if (action) action->addRef();
0064       }
0065       ~ActionHandle()   {
0066         if (action) action->release();
0067       }
0068       ActionHandle& operator=(const ActionHandle& h) { 
0069         if ( h.action ) h.action->addRef();
0070         if ( action ) action->release();
0071         action = h.action;
0072         return *this;
0073       }
0074       DigiAction* release()  {
0075         DigiAction* tmp = action;
0076         action=0;
0077         return tmp;
0078       }
0079       operator dd4hep::digi::DigiAction* () const         { return action; }
0080       DigiAction* operator->() const                      { return action; }
0081       DigiAction* get() const                             { return action; }
0082       DigiAction* I_am_a_ROOT_interface_handle() const    { return action; }
0083       KernelHandle kernel()  const  {
0084         auto* k = const_cast<DigiKernel*>(action->kernel());
0085         return KernelHandle(k);
0086       }
0087     };
0088 
0089     struct PropertyResult  {
0090     public:
0091       std::string data   {   };
0092       int status         { 0 };
0093       PropertyResult() = default;
0094       PropertyResult(const std::string& d, int s);
0095       PropertyResult(const PropertyResult& c) = default;
0096       ~PropertyResult() = default;
0097     };
0098     
0099     inline PropertyResult::PropertyResult(const std::string& d, int s)
0100       : data(d), status(s)
0101     {
0102     }
0103 
0104     struct DigiActionCreation  {
0105       template <typename H> static H* cst(DigiAction* in)  {
0106         auto* out = dynamic_cast<H*>(in);
0107         if ( out ) return out;
0108         if ( in )
0109           except("DigiAction","Invalid cast of action '%s' [type:%s] to type %s!",
0110                  in->c_name(), typeName(typeid(DigiAction)).c_str(), typeName(typeid(H)).c_str());
0111         except("DigiAction","Invalid cast of NULL [type:%s] to type %s!",
0112                typeName(typeid(DigiAction)).c_str(), typeName(typeid(H)).c_str());
0113         return nullptr;
0114       }
0115 
0116       static KernelHandle createKernel(DigiAction* action)   {
0117         auto* k = const_cast<DigiKernel*>(action->kernel());
0118         return KernelHandle(k);
0119       }
0120 
0121       static ActionHandle createAction(KernelHandle& kernel, const std::string& name_type)   {
0122         DigiHandle<DigiAction> action(*kernel.get(),name_type);
0123         return ActionHandle(action.get());
0124       }
0125       static DigiAction* toAction(DigiKernel* f)    { return f;        }
0126       static DigiAction* toAction(DigiAction* f)    { return f;        }
0127       static DigiAction* toAction(KernelHandle f)   { return f.value;  }
0128       static DigiAction* toAction(ActionHandle f)   { return f.action; }
0129 
0130       static DigiEventAction*        toEventAction(DigiAction* a) { return cst<DigiEventAction>(a); }
0131       static DigiDepositMonitor*     toDepositMonitor(DigiAction* a) { return cst<DigiDepositMonitor>(a); }
0132       static DigiContainerProcessor* toContainerProcessor(DigiAction* a) { return cst<DigiContainerProcessor>(a); }
0133       static DigiContainerSequenceAction* toContainerSequenceAction(DigiAction* a) { return cst<DigiContainerSequenceAction>(a); }
0134 
0135       /// Access DigiAction property
0136       static PropertyResult getProperty(DigiAction* action, const std::string& name)  {
0137         if ( action->hasProperty(name) )  {
0138           return PropertyResult(action->property(name).str(),1);
0139         }
0140         return PropertyResult("",0);
0141       }
0142 
0143       /// Set DigiAction property
0144       static int setProperty(DigiAction* action, const std::string& name, const std::string& value)  {
0145         init_grammar_types();
0146         printout(DEBUG,"setProperty","Setting property: %s.%s = %s", action->name().c_str(), name.c_str(), value.c_str());
0147         if ( action->hasProperty(name) )  {
0148           action->property(name).str(value);
0149           return 1;
0150         }
0151         return 0;
0152       }
0153 
0154 #define MKVAL auto val = value
0155 
0156 #define ADD_PROPERTY(n,X)                                               \
0157       static int add##n       (DigiAction* action, const std::string& name, const X value) \
0158       { return add_action_property(action, name, value); }              \
0159       static int addVector##n (DigiAction* action, const std::string& name, std::vector<X> value) \
0160       { MKVAL; return add_action_property(action, name, val); }         \
0161       static int addList##n   (DigiAction* action, const std::string& name, std::list<X> value) \
0162       { MKVAL; return add_action_property(action, name, val); }         \
0163       static int addSet##n    (DigiAction* action, const std::string& name, std::set<X> value) \
0164       { MKVAL; return add_action_property(action, name, val); }         \
0165       static int addMapped##n (DigiAction* action, const std::string& name, std::map<std::string,X> value) \
0166       { MKVAL; return add_action_property(action, name, val); }
0167       ADD_PROPERTY(Property,int)
0168       ADD_PROPERTY(Property,short)
0169       ADD_PROPERTY(Property,size_t)
0170       ADD_PROPERTY(Property,double)
0171 
0172       ADD_PROPERTY(Property,std::string)
0173 
0174       static int addPositionProperty(DigiAction* action, const std::string& name, const std::string value)     {
0175         Position pos;
0176         Property pr(pos);
0177         pr.str(value);
0178         return add_action_property(action, name, pos);
0179       }
0180     };
0181   }
0182 }
0183 
0184 #include <DDDigi/DigiSynchronize.h>
0185 #include <DDDigi/DigiInputAction.h>
0186 #include <DDDigi/DigiSegmentSplitter.h>
0187 #include <DDDigi/DigiActionSequence.h>
0188 #include <DDDigi/DigiSignalProcessor.h>
0189 #include <DDDigi/DigiDepositMonitor.h>
0190 
0191 // CINT configuration
0192 #if defined(__CINT__) || defined(__MAKECINT__) || defined(__CLING__) || defined(__ROOTCLING__)
0193 
0194 #pragma link off all globals;
0195 #pragma link off all classes;
0196 #pragma link off all functions;
0197 
0198 #pragma link C++ namespace dd4hep;
0199 #pragma link C++ namespace dd4hep::digi;
0200 
0201 ///---- Digi data item wrappers
0202 #pragma link C++ class std::pair<dd4hep::digi::Key::key_type, dd4hep::digi::Particle>+;
0203 #pragma link C++ class std::map<dd4hep::digi::Key::key_type, dd4hep::digi::Particle>+;
0204 #pragma link C++ class std::map<dd4hep::digi::Key::key_type, dd4hep::digi::Particle*>+;
0205 #pragma link C++ class std::vector<std::pair<dd4hep::digi::Key::key_type, dd4hep::digi::Particle> >+;
0206 #pragma link C++ class std::vector<std::pair<dd4hep::digi::Key::key_type, dd4hep::digi::Particle*> >+;
0207 
0208 #pragma link C++ class std::pair<dd4hep::CellID, dd4hep::digi::EnergyDeposit>+;
0209 #pragma link C++ class std::pair<dd4hep::CellID, dd4hep::digi::EnergyDeposit*>+;
0210 #pragma link C++ class std::map<dd4hep::CellID, dd4hep::digi::EnergyDeposit>+;
0211 #pragma link C++ class std::map<dd4hep::CellID, dd4hep::digi::EnergyDeposit*>+;
0212 #pragma link C++ class std::vector<std::pair<dd4hep::CellID, dd4hep::digi::EnergyDeposit> >+;
0213 #pragma link C++ class std::vector<std::pair<dd4hep::CellID, dd4hep::digi::EnergyDeposit*> >+;
0214 
0215 #pragma link C++ class dd4hep::digi::History+;
0216 #pragma link C++ class dd4hep::digi::Particle+;
0217 #pragma link C++ class dd4hep::digi::EnergyDeposit+;
0218 #pragma link C++ class dd4hep::digi::ParticleMapping+;
0219 #pragma link C++ class dd4hep::digi::DepositMapping+;
0220 #pragma link C++ class dd4hep::digi::DepositVector+;
0221 #pragma link C++ class dd4hep::digi::DigiEvent;
0222 
0223 ///---- action dictionaries
0224 #pragma link C++ class dd4hep::digi::KernelHandle;
0225 #pragma link C++ class dd4hep::digi::ActionHandle;
0226 
0227 #pragma link C++ class dd4hep::digi::DigiActionCreation;
0228 #pragma link C++ class dd4hep::digi::DigiContext;
0229 #pragma link C++ class dd4hep::digi::DigiKernel;
0230 #pragma link C++ class dd4hep::digi::DigiAction;
0231 #pragma link C++ class dd4hep::digi::DigiEventAction;
0232 #pragma link C++ class dd4hep::digi::DigiInputAction;
0233 #pragma link C++ class dd4hep::digi::DigiActionSequence;
0234 #pragma link C++ class dd4hep::digi::DigiSynchronize;
0235 #pragma link C++ class dd4hep::digi::DigiSignalProcessor;
0236 
0237 #pragma link C++ class dd4hep::digi::DigiContainerProcessor;
0238 #pragma link C++ class dd4hep::digi::DigiContainerSequence;
0239 #pragma link C++ class dd4hep::digi::DigiContainerSequenceAction;
0240 #pragma link C++ class dd4hep::digi::DigiMultiContainerProcessor;
0241 
0242 #pragma link C++ class dd4hep::digi::DigiSegmentSplitter;
0243 #pragma link C++ class dd4hep::digi::DigiDepositMonitor;
0244 
0245 #endif