Belle II Software development
CKFModules.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tracking/trackingUtilities/findlets/base/FindletModule.h>
11#include <tracking/ckf/svd/findlets/CKFToSVDFindlet.h>
12#include <tracking/ckf/pxd/findlets/CKFToPXDFindlet.h>
13#include <tracking/ckf/cdc/findlets/CKFToCDCFindlet.h>
14#include <tracking/ckf/svd/findlets/CKFToSVDSeedFindlet.h>
15#include <tracking/ckf/cdc/findlets/CKFToCDCFromEclFindlet.h>
16
17#include <tracking/dbobjects/SVDToCDCCKFParameters.h>
18
19#include <tracking/trackingUtilities/eventdata/utils/ClassMnemomics.h>
20
21#include <boost/variant/variant.hpp>
22
23
24namespace Belle2 {
34
35 public:
38 {
39 setDescription("Combinatorial Kalman Filter used for extrapolating CDC tracks into "
40 "SVD and create merged tracks.");
41 }
42 };
43
49 class CDCToSVDSeedCKFModule : public TrackingUtilities::FindletModule<CKFToSVDSeedFindlet> {
50
51 public:
54 {
55 setDescription("Combinatorial Kalman Filter used for merging existing CDC tracks and SVD tracks.");
56 }
57 };
58
64 class ToPXDCKFModule : public TrackingUtilities::FindletModule<CKFToPXDFindlet> {
65
66 public:
69 {
70 setDescription("Combinatorial Kalman Filter used for extrapolating SVD/CDC tracks into "
71 "PXD and create merged tracks.");
72 }
73 };
74
80 class ToCDCCKFModule : public TrackingUtilities::FindletModule<CKFToCDCFindlet> {
81
82 public:
84 ToCDCCKFModule() : TrackingUtilities::FindletModule<CKFToCDCFindlet>({"CDCWireHitVector"})
85 {
86 setDescription("Combinatorial Kalman Filter used for extrapolating SVD tracks into "
87 "CDC and create merged tracks.");
88
89 // add warnings for all parameters which will be overridden by the payload in the beginRun() function (here and in the findlet)
90 std::vector<std::string> payloadVarNames = {"maximalDeltaPhi", "firstActiveCDCLayer", "maximalLayerJump", "maximalLayerJumpBackwardSeed", "pathMaximalCandidatesInFlight", "stateMaximalHitCandidates", "stateBasicFilterParameters"};
91
92 for (const auto& varName : payloadVarNames) {
93 auto typeInfo = getParamList().getParameterTypeInfo(varName);
94
95 ModuleParamBase* paramPtr = nullptr;
96 if (typeInfo == "int") {
97 paramPtr = &(getParamList().getParameter<int>(varName));
98 } else if (typeInfo == "double") {
99 paramPtr = &(getParamList().getParameter<double>(varName));
100 } else if (typeInfo == "float") {
101 paramPtr = &(getParamList().getParameter<float>(varName));
102 } else if (typeInfo == "unsigned long int") {
103 paramPtr = &(getParamList().getParameter<unsigned long int>(varName));
104 } else if (typeInfo == "dict(str -> variant(bool, int, float, str, list(str)))") {
105 using variantType = boost::variant<bool, int, double, std::string, std::vector<std::string> >;
106 paramPtr = &(getParamList().getParameter< std::map<std::string, variantType> >(varName));
107 } else {
108 B2FATAL("Type " << typeInfo << " not supported ");
109 }
110 // the pointer should be safe as the getParameter<>() function throws an exception if parameter is not present (not sure if should be caught in constructor)
111 paramPtr->setDescription("[WARNING: may be overridden by payload] " + paramPtr->getDescription());
112
113 }
114
115 }
116
117
118
119 // override module parameter
120 void beginRun() override
121 {
122
124
125 if (!payload.isValid()) {
126 B2FATAL("ToCDCCKFModule: DB payload 'SVDToCDCCKFParameters' not found or not valid for current run.");
127 }
128
129 auto& paramRef = Belle2::Module::getParam<int>("firstActiveCDCLayer");
130 paramRef.setValue(payload->getStateCreatorFirstCDCLayer());
131
132 // need to be set before TrackingUtilities::FindletModule<CKFToCDCFindlet>::beginRun()
133 using variantType = boost::variant<bool, int, double, std::string, std::vector<std::string> >;
134
135 // there are 4 potential filter which can be set to the "rough" filter (or derived filters)
136 std::vector<std::string> filterNames = {
137 "statePreFilter",
138 "stateFinalFilter",
139 "stateExtrapolationFilter",
140 "stateBasicFilter"
141 };
142
143 for (const std::string& filterName : filterNames) {
144 const std::string& filterNameValue = Belle2::Module::getParam<std::string>(filterName).getValue();
145
146 if (filterNameValue.find("rough") != filterNameValue.npos) {
147 std::map<std::string, variantType>& value =
148 Belle2::Module::getParam< std::map<std::string, variantType> >(filterName + "Parameters").getValue();
149 value["maximalArcLengthDistance"] = payload->getMaxArcLengthRoughCDCStateFilter();
150 }
151 }
152
154
155 }
156 };
157
158
159
160
166 class ToCDCFromEclCKFModule : public TrackingUtilities::FindletModule<CKFToCDCFromEclFindlet> {
167
168 public:
170 ToCDCFromEclCKFModule() : TrackingUtilities::FindletModule<CKFToCDCFromEclFindlet>({"CDCWireHitVector"})
171 {
172 setDescription("Combinatorial Kalman Filter used for extrapolating ECL showers into "
173 "CDC and create merged tracks.");
174 }
175 };
176
177}
CDCToSVDSeedCKFModule()
Set description.
Definition CKFModules.h:53
CDCToSVDSpacePointCKFModule()
Set description.
Definition CKFModules.h:37
Main findlet of the ToCDCCKF module.
Main findlet of the ToCDCCKF module.
Class for accessing objects in the database.
Definition DBObjPtr.h:21
std::string getParameterTypeInfo(const std::string &name) const
Returns the type info of a parameter given by its name.
void setDescription(const std::string &description)
Definition Module.cc:214
void beginRun() override
Signal the beginning of a new run.
Definition CKFModules.h:120
ToCDCCKFModule()
Set description.
Definition CKFModules.h:84
ToCDCFromEclCKFModule()
Set description.
Definition CKFModules.h:170
ToPXDCKFModule()
Set description.
Definition CKFModules.h:68
Adapter of a findlet to a module that exposes the parameters of the findlet and manages the IO with t...
FindletModule(const std::array< std::string, c_nTypes > &storeVectorNames={})
virtual void beginRun() override
Signal the beginning of a new run.
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
ModuleParam< T > & getParam(const std::string &name) const
Returns a reference to a parameter.
Definition Module.h:572
Abstract base class for different kinds of events.