Back to home page

EIC code displayed by LXR

 
 

    


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

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 EXAMPLES_CONDITIONS_SRC_CONDITIONANYEXAMPLEOBJECTS_H
0014 #define EXAMPLES_CONDITIONS_SRC_CONDITIONANYEXAMPLEOBJECTS_H
0015 
0016 // Framework include files
0017 #include "ConditionExampleObjects.h"
0018 
0019 /// Namespace for the AIDA detector description toolkit
0020 namespace dd4hep {
0021 
0022   /// Namespace for conditions examples
0023   namespace ConditionExamples {
0024 
0025     /// Specialized conditions update callback 
0026     /**
0027      *  Used by clients to update a condition.
0028      *
0029      *  \author  M.Frank
0030      *  \version 1.0
0031      *  \ingroup DD4HEP_CONDITIONS
0032      */
0033     class ConditionAnyUpdate1 : public ConditionUpdateCall, public OutputLevel  {
0034     public:
0035       /// Initializing constructor
0036       ConditionAnyUpdate1(PrintLevel p) : OutputLevel(p) {    }
0037       /// Default destructor
0038       virtual ~ConditionAnyUpdate1() = default;
0039       /// Interface to client Callback in order to update the condition
0040       virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override  final;
0041       /// Interface to client Callback in order to update the condition
0042       virtual void resolve(Condition condition, ConditionUpdateContext& context) override  final;
0043     };
0044 
0045     /// Specialized conditions update callback 
0046     /**
0047      *  Used by clients to update a condition.
0048      *
0049      *  \author  M.Frank
0050      *  \version 1.0
0051      *  \ingroup DD4HEP_CONDITIONS
0052      */
0053     class ConditionAnyUpdate2 : public ConditionUpdateCall, public OutputLevel  {
0054     public:
0055       /// Initializing constructor
0056       ConditionAnyUpdate2(PrintLevel p) : OutputLevel(p) {    }
0057       /// Default destructor
0058       virtual ~ConditionAnyUpdate2() = default;
0059       /// Interface to client Callback in order to update the condition
0060       virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override   final;
0061       /// Interface to client Callback in order to update the condition
0062       virtual void resolve(Condition condition, ConditionUpdateContext& context) override  final;
0063     };
0064 
0065     /// Specialized conditions update callback 
0066     /**
0067      *  Used by clients to update a condition.
0068      *
0069      *  \author  M.Frank
0070      *  \version 1.0
0071      *  \ingroup DD4HEP_CONDITIONS
0072      */
0073     class ConditionAnyUpdate3 : public ConditionUpdateCall, public OutputLevel  {
0074     public:
0075       /// Initializing constructor
0076       ConditionAnyUpdate3(PrintLevel p) : OutputLevel(p) {    }
0077       /// Default destructor
0078       virtual ~ConditionAnyUpdate3() = default;
0079       /// Interface to client Callback in order to update the condition
0080       virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override  final;
0081       /// Interface to client Callback in order to update the condition
0082       virtual void resolve(Condition condition, ConditionUpdateContext& context) override  final;
0083     };
0084     
0085     /// Specialized conditions update callback 
0086     /**
0087      *  Used by clients to update a condition.
0088      *
0089      *  \author  M.Frank
0090      *  \version 1.0
0091      *  \ingroup DD4HEP_CONDITIONS
0092      */
0093     class ConditionAnyUpdate4 : public ConditionUpdateCall, public OutputLevel  {
0094     public:
0095       /// Initializing constructor
0096       ConditionAnyUpdate4(PrintLevel p) : OutputLevel(p) {    }
0097       /// Default destructor
0098       virtual ~ConditionAnyUpdate4() = default;
0099       /// Interface to client Callback in order to update the condition
0100       virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override  final;
0101     };
0102     
0103     /// This is important, otherwise the register and forward calls won't find them!
0104     /**
0105      *  \author  M.Frank
0106      *  \version 1.02
0107      *  \date    01/04/2016
0108      */
0109     class ConditionsAnyKeys : public OutputLevel {
0110     public:
0111       /// Content object to be filled
0112       ConditionsContent& content;
0113       /// Constructor
0114       ConditionsAnyKeys(ConditionsContent& c, PrintLevel p) : OutputLevel(p), content(c) {}
0115       /// Callback to process a single detector element
0116       virtual int operator()(DetElement de, int level) const final;
0117     };
0118 
0119     /// Example how to populate the detector description with derived conditions
0120     /**
0121      *  This is simply a DetElement crawler...
0122      *
0123      *  \author  M.Frank
0124      *  \version 1.0
0125      *  \date    01/04/2016
0126      */
0127     class ConditionsAnyDependencyCreator : public OutputLevel  {
0128     public:
0129       /// Content object to be filled
0130       ConditionsContent&   content;
0131       /// Three different update call types
0132       std::shared_ptr<ConditionUpdateCall> call1, call2, call3, call4;
0133       /// Flag for special setup for ROOT persistency
0134       bool persist_conditions;
0135       /// Flag to indicate increased complexity
0136       int  extended;
0137     public:
0138       /// Constructor
0139       ConditionsAnyDependencyCreator(ConditionsContent& c, PrintLevel p, bool persist=false, int extended=0);
0140       /// Destructor
0141       virtual ~ConditionsAnyDependencyCreator() = default;
0142       /// Callback to process a single detector element
0143       virtual int operator()(DetElement de, int level) const final;
0144     };
0145 
0146     /// Example how to populate the detector description with conditions constants
0147     /**
0148      *  This is simply a DetElement crawler...
0149      *
0150      *  \author  M.Frank
0151      *  \version 1.0
0152      *  \date    01/04/2016
0153      */
0154     class ConditionsAnyCreator  : public OutputLevel  {
0155     public:
0156       /// Content object for which conditions are supposedly created
0157       ConditionsSlice& slice;
0158       /// Conditions pool the created conditions are inserted to (not equals user pool!)
0159       ConditionsPool&  pool;
0160     public:
0161       /// Constructor
0162       ConditionsAnyCreator(ConditionsSlice& s, ConditionsPool& p, PrintLevel l=DEBUG)
0163         : OutputLevel(l), slice(s), pool(p)  {}
0164       /// Destructor
0165       virtual ~ConditionsAnyCreator() = default;
0166       /// Callback to process a single detector element
0167       virtual int operator()(DetElement de, int level)  const final;
0168       template<typename T>
0169       Condition make_condition(DetElement de,
0170                    const std::string& name,
0171                    const T& val)  const;
0172       template<typename T, typename... Args>
0173       Condition make_condition_args(DetElement de,
0174                     const std::string& name,
0175                     Args... args)  const;
0176     };
0177 
0178     /// Example how to access the conditions constants from a detector element
0179     /**
0180      *  \author  M.Frank
0181      *  \version 1.0
0182      *  \date    01/04/2016
0183      */
0184     class ConditionsAnyDataAccess : public OutputLevel   {
0185     public:
0186       /// Reference to the IOV to be checked
0187       const IOV&     iov;
0188       /// Reference to the conditions map to access conditions
0189       ConditionsMap& map;
0190 
0191     public:
0192       /// Constructor
0193       ConditionsAnyDataAccess(const IOV& i, ConditionsMap& m, PrintLevel l=DEBUG)
0194         : OutputLevel(l), iov(i), map(m) {}
0195       /// Destructor
0196       virtual ~ConditionsAnyDataAccess();
0197       /// Callback to process a single detector element
0198       virtual int operator()(DetElement de, int level)  const;
0199       /// Common call to access selected conditions
0200       virtual int accessConditions(DetElement de,
0201                                    const std::vector<Condition>& conditions)  const;
0202     };
0203   }       /* End namespace condExamples             */
0204 }         /* End namespace dd4hep                         */
0205 #endif // EXAMPLES_CONDITIONS_SRC_CONDITIONEXAMPLEOBJECTS_H