File indexing completed on 2025-01-30 09:17:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef EXAMPLES_CONDITIONS_SRC_CONDITIONEXAMPLEOBJECTS_H
0014 #define EXAMPLES_CONDITIONS_SRC_CONDITIONEXAMPLEOBJECTS_H
0015
0016
0017 #include "DD4hep/Detector.h"
0018 #include "DD4hep/Printout.h"
0019 #include "DD4hep/Conditions.h"
0020 #include "DD4hep/ConditionsMap.h"
0021 #include "DD4hep/ConditionDerived.h"
0022 #include "DD4hep/ConditionsPrinter.h"
0023 #include "DD4hep/ConditionsProcessor.h"
0024 #include "DD4hep/DetectorProcessor.h"
0025
0026 #include "DDCond/ConditionsSlice.h"
0027 #include "DDCond/ConditionsManager.h"
0028
0029
0030 namespace dd4hep {
0031
0032
0033 namespace ConditionExamples {
0034
0035 using cond::UserPool;
0036 using cond::ConditionsPool;
0037 using cond::ConditionsSlice;
0038 using cond::ConditionsContent;
0039 using cond::ConditionsPrinter;
0040 using cond::ConditionsManager;
0041 using cond::ConditionUpdateCall;
0042 using cond::ConditionUpdateContext;
0043 using cond::conditionsCollector;
0044
0045
0046
0047
0048
0049
0050
0051 class OutputLevel {
0052 public:
0053
0054 PrintLevel printLevel = DEBUG;
0055
0056 OutputLevel() = default;
0057
0058 OutputLevel(PrintLevel p) : printLevel(p) {}
0059
0060 virtual ~OutputLevel() = default;
0061 };
0062
0063
0064
0065
0066
0067
0068
0069 class NonDefaultCtorCond {
0070 private:
0071
0072 NonDefaultCtorCond() = delete;
0073
0074 NonDefaultCtorCond(NonDefaultCtorCond&& copy) = delete;
0075
0076 NonDefaultCtorCond(const NonDefaultCtorCond& copy) = delete;
0077
0078 NonDefaultCtorCond& operator=(NonDefaultCtorCond&& copy) = delete;
0079
0080 NonDefaultCtorCond& operator=(const NonDefaultCtorCond& copy) = delete;
0081 public:
0082 int a, b, c, d;
0083
0084 NonDefaultCtorCond(int aa, int bb, int cc);
0085
0086 virtual ~NonDefaultCtorCond();
0087
0088 void set(int val);
0089 };
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 class ConditionNonDefaultCtorUpdate1 : public ConditionUpdateCall, public OutputLevel {
0100 public:
0101
0102 ConditionNonDefaultCtorUpdate1(PrintLevel p) : OutputLevel(p) { }
0103
0104 virtual ~ConditionNonDefaultCtorUpdate1() = default;
0105
0106 virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override final;
0107
0108 virtual void resolve(Condition condition, ConditionUpdateContext& context) override final;
0109 };
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 class ConditionUpdateUnresolved : public ConditionUpdateCall, public OutputLevel {
0120 public:
0121
0122 ConditionUpdateUnresolved(PrintLevel p) : OutputLevel(p) { }
0123
0124 virtual ~ConditionUpdateUnresolved() = default;
0125
0126 virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override final;
0127
0128 virtual void resolve(Condition condition, ConditionUpdateContext& context) override final;
0129 };
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139 class ConditionUpdate1 : public ConditionUpdateCall, public OutputLevel {
0140 public:
0141
0142 ConditionUpdate1(PrintLevel p) : OutputLevel(p) { }
0143
0144 virtual ~ConditionUpdate1() = default;
0145
0146 virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override final;
0147
0148 virtual void resolve(Condition condition, ConditionUpdateContext& context) override final;
0149 };
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159 class ConditionUpdate2 : public ConditionUpdateCall, public OutputLevel {
0160 public:
0161
0162 ConditionUpdate2(PrintLevel p) : OutputLevel(p) { }
0163
0164 virtual ~ConditionUpdate2() = default;
0165
0166 virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override final;
0167
0168 virtual void resolve(Condition condition, ConditionUpdateContext& context) override final;
0169 };
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179 class ConditionUpdate3 : public ConditionUpdateCall, public OutputLevel {
0180 public:
0181
0182 ConditionUpdate3(PrintLevel p) : OutputLevel(p) { }
0183
0184 virtual ~ConditionUpdate3() = default;
0185
0186 virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override final;
0187
0188 virtual void resolve(Condition condition, ConditionUpdateContext& context) override final;
0189 };
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199 class ConditionUpdate4 : public ConditionUpdateCall, public OutputLevel {
0200 public:
0201
0202 ConditionUpdate4(PrintLevel p) : OutputLevel(p) { }
0203
0204 virtual ~ConditionUpdate4() = default;
0205
0206 virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override final;
0207 };
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217 class ConditionUpdate5 : public ConditionUpdateCall, public OutputLevel {
0218 public:
0219
0220 ConditionUpdate5(PrintLevel p) : OutputLevel(p) { }
0221
0222 virtual ~ConditionUpdate5() = default;
0223
0224 virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override final;
0225 };
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235 class ConditionUpdate6 : public ConditionUpdateCall, public OutputLevel {
0236 public:
0237 size_t max_deps = 0;
0238 size_t min_deps = 999999999999UL;
0239 size_t num_deps = 0;
0240 size_t call_count = 0;
0241
0242 ConditionUpdate6(PrintLevel p) : OutputLevel(p) { }
0243
0244 virtual ~ConditionUpdate6();
0245
0246 virtual Condition operator()(const ConditionKey& key, ConditionUpdateContext& context) override final;
0247 };
0248
0249
0250
0251
0252
0253
0254
0255 class ConditionsKeys : public OutputLevel {
0256 public:
0257
0258 ConditionsContent& content;
0259
0260 ConditionsKeys(ConditionsContent& c, PrintLevel p) : OutputLevel(p), content(c) {}
0261
0262 virtual int operator()(DetElement de, int level) const final;
0263 };
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273 struct ConditionsDependencyCreator : public OutputLevel {
0274
0275 ConditionsContent& content;
0276
0277 std::shared_ptr<ConditionUpdateCall> scall1, call1, call2, call3, call4, call5, call6, callUnresolved;
0278
0279 bool persist_conditions;
0280
0281 int extended;
0282
0283 ConditionsDependencyCreator(ConditionsContent& c, PrintLevel p, bool persist=false, int extended=0);
0284
0285 virtual ~ConditionsDependencyCreator() = default;
0286
0287 virtual int operator()(DetElement de, int level) const final;
0288 };
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298 struct ConditionsCreator : public OutputLevel {
0299
0300 ConditionsSlice& slice;
0301
0302 ConditionsPool& pool;
0303
0304 ConditionsCreator(ConditionsSlice& s, ConditionsPool& p, PrintLevel l=DEBUG)
0305 : OutputLevel(l), slice(s), pool(p) {}
0306
0307 virtual ~ConditionsCreator() = default;
0308
0309 virtual int operator()(DetElement de, int level) const final;
0310 template<typename T>
0311 Condition make_condition(DetElement de,
0312 const std::string& name,
0313 const T& val) const;
0314 template<typename T, typename... Args>
0315 Condition make_condition_args(DetElement de,
0316 const std::string& name,
0317 Args... args) const;
0318 };
0319
0320
0321
0322
0323
0324
0325
0326 struct ConditionsDataAccess : public OutputLevel {
0327
0328 const IOV& iov;
0329
0330 ConditionsMap& map;
0331
0332
0333 ConditionsDataAccess(const IOV& i, ConditionsMap& m, PrintLevel l=DEBUG)
0334 : OutputLevel(l), iov(i), map(m) {}
0335
0336 virtual ~ConditionsDataAccess() = default;
0337
0338 virtual int operator()(DetElement de, int level) const;
0339
0340 virtual int accessConditions(DetElement de,
0341 const std::vector<Condition>& conditions) const;
0342 };
0343
0344
0345 typedef DetectorScanner Scanner;
0346
0347
0348 ConditionsManager installManager(Detector& description);
0349 }
0350 }
0351 #endif