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