ATLAS Offline Software
Loading...
Searching...
No Matches
IRingerProcedure.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef RINGERSELECTORTOOLS_PROCEDURES_IPROCEDURE_H
6#define RINGERSELECTORTOOLS_PROCEDURES_IPROCEDURE_H
7
8// STL includes:
9#include <vector>
10#include <utility>
11
12// Root includes:
13#include <TDirectory.h>
14//#include <TClass.h>
15
16// Local includes:
18#include "RingerSelectorTools/tools/IRedirectMsgStream.h"
19#include <type_traits>
20
21#ifndef INCLUDE_HEADER_ONLY
22#define INCLUDE_HEADER_ONLY
23#endif // INCLUDE_HEADER_ONLY
24#include "RingerSelectorTools/procedures/Types.h"
25#undef INCLUDE_HEADER_ONLY
26
38#define RINGER_PROCEDURE_BASE_METHODS(self) \
39 \
40 public: \
41 \
42 template <typename T = const char*> \
43 static T procType(); \
44 \
45 virtual std::string name() const = 0; \
46 \
47 virtual void print(MSG::Level lvl) const = 0;
48
52#define RINGER_DEFINE_INTERFACE_DEFAULT_METHODS(self) \
53 \
54 template<> \
55 inline \
56 const char* self::procType() \
57 { \
58 return #self; \
59 } \
60 \
61 template<> \
62 inline \
63 Ringer::RingerProcedureType<self>::procEnum_t self::procType() \
64 { \
65 return Ringer::getType< \
66 Ringer::RingerProcedureType<self>::procEnum_t>(#self); \
67 }
68
69#define __RINGER_DEFINE_PROCEDURE_STANDARD_METHODS__(self) \
70 \
71 virtual std::string name() const \
72 override; \
73 template <typename T = const char*> \
74 static T procType(); \
75 \
76
77
80#define RINGER_DEFINE_PROCEDURE(self) \
81 \
82 public: \
83 __RINGER_DEFINE_PROCEDURE_STANDARD_METHODS__(self) \
84 \
85 virtual void print(MSG::Level lvl) const \
86 override;
87
91#define RINGER_DEFINE_NOMEMBER_PROCEDURE(self) \
92 \
93 public: \
94 __RINGER_DEFINE_PROCEDURE_STANDARD_METHODS__(self) \
95 \
96 virtual void print(MSG::Level lvl) const \
97 override \
98 { \
99 if ( !this->isStreamAvailable() ) { \
100 std::cerr << "Cannot print " << this->name() << ", stream unavailable" \
101 << std::endl; \
102 } \
103 if ( this->level() > lvl ) { \
104 return; \
105 } \
106 ATH_MSG_LVL(lvl, "Procedure hasn't any property."); \
107 }
108
109
117#define RINGER_DEFINE_PROCEDURE_DEFAULT_METHODS(self) \
118 \
119 RINGER_DEFINE_INTERFACE_DEFAULT_METHODS(self) \
120 \
121 inline \
122 std::string self::name() const \
123 { \
124 return this->procType<const char*>(); \
125 }
126
127
128
132namespace Ringer {
133
134class DepVarStruct;
135
136// Declare interface base for all Ringer procedure types:
137//
144class IRingerProcedure : virtual public IRedirectMsgStream {
145 public:
149 virtual void write(TDirectory *configDir, const char*idxStr = "")
150 const = 0;
151
153 virtual ~IRingerProcedure(){;}
154
155 protected:
156
158 //ClassDef(IRingerProcedure,0)
159};
160
161// Forward declare base procedure types:
162namespace PreProcessing {
163 class IPreProcessor;
165}
166
167namespace Discrimination {
168 class IDiscriminator;
170 class IThreshold;
171 class IThresholdVarDep;
172}
173
189template<typename procedure_t >
191
192 static_assert( (std::is_base_of<IRingerProcedure,procedure_t>::value),
193 "Requested to check Ringer procedure type from class that is not a IRingerProcedure.");
194
195 // Determine which procedure type it is:
196 static constexpr bool is_pre_processor =
197 std::is_base_of<PreProcessing::IPreProcessor,procedure_t>::value;
198 static constexpr bool is_discriminator =
199 std::is_base_of<Discrimination::IDiscriminator,procedure_t>::value;
200 static constexpr bool is_threshold =
201 std::is_base_of<Discrimination::IThreshold,procedure_t>::value;
202
203 static_assert( ( is_pre_processor || is_discriminator || is_threshold ),
204 "Couldn't find a procedure type.");
205
206 // Determine which enumType it should have been declared
207 typedef typename std::conditional< is_pre_processor,
208 preProcEnum_t, // true, it is_pre_processor
209 typename std::conditional< is_discriminator,
210 discrEnum_t, // true, it is discriminator
211 thresEnum_t >::type >::type procEnum_t;
212
213 // Boolean to determine whether this procedure inherits from VariableDependency
214 static constexpr bool inherits_from_var_dep = std::is_base_of< VariableDependency,
215 procedure_t>::value;
216
217 // Determine which interface this Ringer procedure inherits from
218 typedef typename std::conditional< is_pre_processor,
219 // true, it is_pre_processor
220 typename std::conditional< inherits_from_var_dep,
222 // not pre_processor, check if is_discriminator
223 typename std::conditional< is_discriminator,
224 // true, it is_discriminator
225 typename std::conditional< inherits_from_var_dep,
227 // otherwise it has to be threshold
228 typename std::conditional< inherits_from_var_dep,
230 >::type
232};
233
238template<typename procedure_t >
240
244namespace PreProcessing {
245
249class IPreProcessor : virtual public IRingerProcedure
250{
251
253
254 public:
258 virtual void execute(std::vector<float> &inputSpace) const = 0;
259
261 //ClassDef(IPreProcessor,0)
262};
263
268 public virtual IPreProcessor
269{
270
272
273 public:
274 //IPreProcessorVarDep(){;}
275
276 // This is needed for parsing wrapper
277 static IPreProcessorVarDep* read(TDirectory *){ return nullptr;}
278
280 //ClassDef(IPreProcessorVarDep,0)
281};
282
283} // namespace PreProcessor
284
288namespace Discrimination {
289
293class IDiscriminator : virtual public IRingerProcedure
294{
295
297
298 public:
299 virtual void execute(const std::vector<float> &input,
300 std::vector<float> &output) const = 0;
301
303 //ClassDef(IDiscriminator,0)
304};
305
310 public virtual IDiscriminator
311{
312
314
315 public:
316 //IDiscriminatorVarDep(){;}
317
318 // This prototype is needed for parsing wrapper
319 static IDiscriminatorVarDep* read(TDirectory *){ return nullptr;}
320
322 //ClassDef(IDiscriminatorVarDep,0)
323};
324
328class IThreshold : virtual public IRingerProcedure
329{
330
332
333 public:
337 virtual void execute(const std::vector<float> &input,
338 std::vector<bool> &output, const DepVarStruct &depVar) const = 0;
339
341 //ClassDef(IThreshold,0)
342};
343
348 public virtual IThreshold
349{
350
352
353 public:
354 //IThresholdVarDep(){;}
355
356 // This prototype is needed for parsing wrapper
357 static IThresholdVarDep* read(TDirectory *){ return nullptr;}
358
360 //ClassDef(IThresholdVarDep,0)
361};
362
363} // namespace Discrimination
364
365// Declare procedure type member functions
366namespace PreProcessing {
368RINGER_DEFINE_INTERFACE_DEFAULT_METHODS( IPreProcessorVarDep )
369} // namespace PreProcessing
370namespace Discrimination {
375} // namespace Discrimination
376
377} // namespace Ringer
378
379#endif // RINGERSELECTORTOOLS_PROCEDURES_IPROCEDURE_H
#define RINGER_DEFINE_INTERFACE_DEFAULT_METHODS(self)
Define Ringer interface procedure type methods.
#define RINGER_PROCEDURE_BASE_METHODS(self)
Define ringer interface default methods.
Discriminator interface to be used by Ringer Wrapper.
static IDiscriminatorVarDep * read(TDirectory *)
Discriminator interface to be inherited by discrimination procedures.
virtual void execute(const std::vector< float > &input, std::vector< float > &output) const =0
Threshold interface to be used by Ringer Wrapper.
static IThresholdVarDep * read(TDirectory *)
Threshold interface to be inherited by thresholding procedures.
virtual void execute(const std::vector< float > &input, std::vector< bool > &output, const DepVarStruct &depVar) const =0
Execute threshold for input and retrieve throw output.
The base interface for all Ringer procedures.
virtual ~IRingerProcedure()
Ensures virtual dtor for all inherited classes.
virtual void write(TDirectory *configDir, const char *idxStr="") const =0
Write Ringer procedure to configuration directory.
PreProcessor interface to be used by Ringer Wrapper.
static IPreProcessorVarDep * read(TDirectory *)
PreProcessing interface to be inherited by PreProcessing procedures.
virtual void execute(std::vector< float > &inputSpace) const =0
Check if depVar is within this procedure range.
VariableDependency()=default
Ctor for independent.
Namespace dedicated for Ringer Discrimination utilities.
Namespace dedicated for Ringer pre-processing utilities.
Namespace dedicated for Ringer utilities.
Check Ringer Procedure type.
static constexpr bool is_threshold
static constexpr bool inherits_from_var_dep
static constexpr bool is_pre_processor
std::conditional< is_pre_processor, preProcEnum_t, typenamestd::conditional< is_discriminator, discrEnum_t, thresEnum_t >::type >::type procEnum_t
std::conditional< is_pre_processor, typenamestd::conditional< inherits_from_var_dep, PreProcessing::IPreProcessorVarDep, PreProcessing::IPreProcessor >::type, typenamestd::conditional< is_discriminator, typenamestd::conditional< inherits_from_var_dep, Discrimination::IDiscriminatorVarDep, Discrimination::IDiscriminator >::type, typenamestd::conditional< inherits_from_var_dep, Discrimination::IThresholdVarDep, Discrimination::IThreshold >::type >::type >::type baseInterface_t
static constexpr bool is_discriminator