10#include <tracking/trackFindingCDC/rootification/StoreWrappedObjPtr.h>
12#include <tracking/trackFindingCDC/utilities/EvalVariadic.h>
14#include <framework/core/Module.h>
15#include <framework/core/ModuleParamList.h>
26 namespace TrackFindingCDC {
29 template<
class AFindlet>
37 using IOTypes =
typename AFindlet::IOTypes;
40 template<std::
size_t I>
41 using IOType =
typename std::tuple_element<I, IOTypes>::type;
45 using Stripped =
typename std::remove_reference<typename std::remove_const<T>::type>::type;
48 template<std::
size_t I>
52 template <std::
size_t I>
59 template<std::
size_t I>
62 return std::is_const<IOType<I>>::value or std::is_reference<IOType<I>>::value;
66 static const std::size_t
c_nTypes = std::tuple_size<IOTypes>::value;
69 using Indices = std::make_index_sequence<c_nTypes>;
73 explicit FindletModule(
const std::array<std::string, c_nTypes>& storeVectorNames = {})
77 std::string description =
"Findlet: ";
78 if (std::tuple_size<IOTypes>() == 0) {
83 description +=
m_findlet.getDescription();
90 const std::string prefix =
"";
91 m_findlet.exposeParameters(&moduleParamList, prefix);
138 template <
size_t... Is>
141 m_findlet.apply(*(getStoreVector<Is>())...);
145 template <
size_t... Is>
148 evalVariadic((createStoreVector<Is>(), std::ignore)...);
152 template <
size_t... Is>
155 evalVariadic((requireStoreVector<Is>(), std::ignore) ...);
156 evalVariadic((registerStoreVector<Is>(), std::ignore) ...);
164 template <std::
size_t I>
167 if (isInputStoreVector<I>()) {
168 getStoreVector<I>().isRequired();
173 template <std::
size_t I>
176 if (not isInputStoreVector<I>()) {
182 template<std::
size_t I>
185 if (not getStoreVector<I>().isValid()) {
186 getStoreVector<I>().construct();
191 template<std::
size_t I>
199 template<
size_t ... Is>
202 evalVariadic((addStoreVectorParameter<Is>(), std::ignore)...);
206 template<std::
size_t I>
209 std::string name = getStoreVectorParameterName<I>();
210 std::string description = getStoreVectorParameterDescription<I>();
226 template <std::
size_t I>
230 int order = primary ? 1 : 2;
231 bool input = isInputStoreVector<I>();
239 template<std::
size_t I>
243 int order = primary ? 1 : 2;
244 bool input = isInputStoreVector<I>();
260 std::string orderPrefix;
263 }
else if (order == 2) {
264 orderPrefix =
"secondary";
266 B2ERROR(
"More than two inputs of the same type are not supported");
268 std::string inputPrefix = input ?
"input" :
"";
270 if (input or order > 1) {
271 classMnemonic[0] = ::toupper(classMnemonic.at(0));
273 if (input and order > 1) {
274 inputPrefix[0] = ::toupper(inputPrefix.at(0));
277 return orderPrefix + inputPrefix + classMnemonic +
"s";
288 std::string orderPrefix;
291 }
else if (order == 2) {
292 orderPrefix =
"secondary ";
294 B2ERROR(
"More than two inputs of the same type are not supported");
296 std::string inputPrefix = input ?
"input " :
"";
297 return "Name of the " + orderPrefix + inputPrefix + classMnemonic +
" vector.";
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
The Module parameter list class.
void setDescription(const std::string &description)
Sets the description of the module.
const ModuleParamList & getParamList() const
Return module param list.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
@ c_TerminateInAllProcesses
When using parallel processing, call this module's terminate() function in all processes().
virtual void initialize()
Initialize the Module.
virtual void beginRun()
Called when entering a new run.
virtual void endRun()
This method is called if the current run ends.
void setParamList(const ModuleParamList ¶ms)
Replace existing parameter list.
virtual void terminate()
This method is called at the end of the event processing.
Adapter of a findlet to a module that exposes the parameters of the findlet and manages the IO with t...
typename AFindlet::IOTypes IOTypes
Tuple of input / output types of the findlet.
virtual void endRun() override
Signal the end of the run.
virtual void terminate() override
Signal to terminate the event processing.
static constexpr bool isInputStoreVector()
Test if the given io type designates an input store vector.
Stripped< IOType< I > > StrippedIOType
Accessor for the individual input / output types of the findlet stripped from modifiers.
std::array< std::string, c_nTypes > m_param_storeVectorNames
Parameters : Names of the vectors on the DataStore.
FindletModule(const std::array< std::string, c_nTypes > &storeVectorNames={})
Constructor of the module.
std::string getStoreVectorParameterDescription() const
Get parameter description for the StoreVector at index I.
void registerStoreVector()
Register the vector with index I to the DataStore.
StoreVector< I > getStoreVector()
Get the vector with index I from the DataStore.
std::string getStoreVectorParameterDescription(const std::string &classMnemonic, int order, bool input) const
Compose a parameter description for the name of the vector on the DataStore.
typename std::tuple_element< I, IOTypes >::type IOType
Accessor for the individual input / output types of the findlet.
void addStoreVectorParameters(std::index_sequence< Is... >)
Expose parameters to set the names of the vectors on the DataStore.
virtual void event() override
Start processing the current event.
AFindlet m_findlet
Findlet that implements the algorithm to be executed.
static const std::size_t c_nTypes
Number of types served to the findlet.
void createStoreVector()
Create the vector with index I on the DataStore.
virtual void initialize() override
Initialize the Module before event processing.
typename std::remove_reference< typename std::remove_const< T >::type >::type Stripped
Type function to strip constant and reference qualification form a given type.
std::make_index_sequence< c_nTypes > Indices
Helper class to iterate over the individual types served to the findlet.
virtual void beginRun() override
Signal the beginning of a new run.
void requireStoreVector()
Require the vector with index I to be on the DataStore.
std::string getStoreVectorParameterName() const
Get parameter name for the StoreVector at index I.
void applyFindlet(std::index_sequence< Is... >)
Get the vectors from the DataStore and apply the findlet.
std::string getStoreVectorParameterName(std::string classMnemonic, int order, bool input) const
Compose a parameter name for the name of the vector on the DataStore.
void requireOrRegisterStoreVectors(std::index_sequence< Is... >)
Require or register the vectors on the DataStore.
virtual ~FindletModule()=default
Make destructor of interface virtual.
void createStoreVectors(std::index_sequence< Is... >)
Create the vectors on the DataStore.
void addStoreVectorParameter()
Expose parameter to set the names of the vector with index I on the DataStore.
This class is for convenience access and registration of objects, that are stored inside the StoreWra...
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
std::string getClassMnemomicParameterDescription(const RecoTrack *dispatchTag)
Returns a short description for class RecoTrack to be used in descriptions of parameters.
std::string getClassMnemomicParameterName(const RecoTrack *dispatchTag)
Returns a short name for class RecoTrack to be used in names of parameters.
Abstract base class for different kinds of events.
Looks up, at which index the given Type can be found in a tuple.