 |
Belle II Software
release-05-02-19
|
12 #include <tracking/trackFindingCDC/rootification/StoreWrappedObjPtr.h>
14 #include <tracking/trackFindingCDC/utilities/EvalVariadic.h>
16 #include <framework/core/Module.h>
17 #include <framework/core/ModuleParamList.h>
28 namespace TrackFindingCDC {
31 template<
class AFindlet>
32 class FindletModule :
public Module {
39 using IOTypes =
typename AFindlet::IOTypes;
42 template<std::
size_t I>
43 using IOType =
typename std::tuple_element<I, IOTypes>::type;
47 using Stripped =
typename std::remove_reference<typename std::remove_const<T>::type>::type;
50 template<std::
size_t I>
54 template <std::
size_t I>
61 template<std::
size_t I>
64 return std::is_const<IOType<I>>::value or std::is_reference<IOType<I>>::value;
68 static const std::size_t
c_nTypes = std::tuple_size<IOTypes>::value;
71 using Indices = std::make_index_sequence<c_nTypes>;
75 explicit FindletModule(
const std::array<std::string, c_nTypes>& storeVectorNames = {})
79 std::string description =
"Findlet: ";
80 if (std::tuple_size<IOTypes>() == 0) {
85 description +=
m_findlet.getDescription();
92 const std::string prefix =
"";
93 m_findlet.exposeParameters(&moduleParamList, prefix);
117 virtual void event()
override
140 template <
size_t... Is>
143 m_findlet.apply(*(getStoreVector<Is>())...);
147 template <
size_t... Is>
150 evalVariadic((createStoreVector<Is>(), std::ignore)...);
154 template <
size_t... Is>
157 evalVariadic((requireStoreVector<Is>(), std::ignore) ...);
158 evalVariadic((registerStoreVector<Is>(), std::ignore) ...);
166 template <std::
size_t I>
169 if (isInputStoreVector<I>()) {
170 getStoreVector<I>().isRequired();
175 template <std::
size_t I>
178 if (not isInputStoreVector<I>()) {
184 template<std::
size_t I>
187 if (not getStoreVector<I>().isValid()) {
188 getStoreVector<I>().construct();
193 template<std::
size_t I>
201 template<
size_t ... Is>
204 evalVariadic((addStoreVectorParameter<Is>(), std::ignore)...);
208 template<std::
size_t I>
211 std::string name = getStoreVectorParameterName<I>();
212 std::string description = getStoreVectorParameterDescription<I>();
228 template <std::
size_t I>
231 bool primary = I == GetIndexInTuple<IOType<I>,
IOTypes>::value;
232 int order = primary ? 1 : 2;
233 bool input = isInputStoreVector<I>();
241 template<std::
size_t I>
245 int order = primary ? 1 : 2;
246 bool input = isInputStoreVector<I>();
261 std::string orderPrefix;
264 }
else if (order == 2) {
265 orderPrefix =
"secondary";
267 B2ERROR(
"More than two inputs of the same type are not supported");
269 std::string inputPrefix = input ?
"input" :
"";
271 if (input or order > 1) {
272 classMnenomic[0] = ::toupper(classMnenomic.at(0));
274 if (input and order > 1) {
275 inputPrefix[0] = ::toupper(inputPrefix.at(0));
278 return orderPrefix + inputPrefix + classMnenomic +
"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 + classMnenomic +
" vector.";
void requireOrRegisterStoreVectors(std::index_sequence< Is... >)
Require or register the vectors on the DataStore.
virtual void terminate()
This method is called at the end of the event processing.
void setDescription(const std::string &description)
Sets the description of the module.
void applyFindlet(std::index_sequence< Is... >)
Get the vectors from the DataStore and apply the findlet.
typename std::remove_reference< typename std::remove_const< T >::type >::type Stripped
Type function to strip constant and reference qualification form a given type.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
virtual ~FindletModule()=default
Make destructor of interface virtual.
@ c_TerminateInAllProcesses
When using parallel processing, call this module's terminate() function in all processes().
void createStoreVectors(std::index_sequence< Is... >)
Create the vectors on the DataStore.
virtual void endRun() override
Signal the end of the run.
virtual void initialize() override
Initialize the Module before event processing.
This class is for convenience access and registration of objects, that are stored inside the StoreWra...
void registerStoreVector()
Register the vector with index I to the DataStore.
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
typename AFindlet::IOTypes IOTypes
Tuple of input / output types of the findlet.
std::string getClassMnemomicParameterDescription(const RecoTrack *dispatchTag __attribute__((unused)))
Returns a short description for class RecoTrack to be used in descriptions of parameters.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Module Super
Type of the base class.
std::string getStoreVectorParameterName() const
Get parameter name for the StoreVector at index I.
std::make_index_sequence< c_nTypes > Indices
Helper class to iterate over the individual types served to the findlet.
FindletModule(const std::array< std::string, c_nTypes > &storeVectorNames={})
Constructor of the module.
Abstract base class for different kinds of events.
virtual void endRun()
This method is called if the current run ends.
AFindlet m_findlet
Findlet that implements the algorithm to be executed.
static constexpr bool isInputStoreVector()
Test if the given io type designates an input store vector.
std::string getStoreVectorParameterDescription() const
Get parameter description for the StoreVector at index I.
void addStoreVectorParameters(std::index_sequence< Is... >)
Expose parameters to set the names of the vectors on the DataStore.
static const std::size_t c_nTypes
Number of typpes served to the findlet.
virtual void terminate() override
Signal to terminate the event processing.
void createStoreVector()
Create the vector with index I on the DataStore.
virtual void event() override
Start processing the current event.
StoreVector< I > getStoreVector()
Get the vector with index I from the DataStore.
typename std::tuple_element< I, IOTypes >::type IOType
Accessor for the individual input / output types of the findlet.
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
void requireStoreVector()
Require the vector with index I to be on the DataStore.
virtual void beginRun()
Called when entering a new run.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Looks up, at which index the given Type can be found in a tuple.
const ModuleParamList & getParamList() const
Return module param list.
Stripped< IOType< I > > StrippedIOType
Accessor for the individual input / output types of the findlet stripped from modifiers.
The Module parameter list class.
virtual void initialize()
Initialize the Module.
std::string getClassMnemomicParameterName(const RecoTrack *dispatchTag __attribute__((unused)))
Returns a short name for class RecoTrack to be used in names of parameters.
void addStoreVectorParameter()
Expose parameter to set the names of the vector with index I on the DataStore.
std::array< std::string, c_nTypes > m_param_storeVectorNames
Parameters : Names of the vectors on the DataStore.
virtual void beginRun() override
Signal the beginning of a new run.
void setParamList(const ModuleParamList ¶ms)
Replace existing parameter list.