Belle II Software development
FilterMill< PointType > Class Template Reference

Small class which stores the filters/selectionVariables to be used for a secMap and has an interface for applying them. More...

#include <FilterMill.h>

Classes

struct  HitPair
 small struct containing pointers to two hits. More...
 
struct  HitQuadruplet
 small struct containing pointers to four hits. More...
 
struct  HitTriplet
 small struct containing pointers to three hits. More...
 

Public Types

using TwoHitFunction = typename std::function< double(const PointType &, const PointType &)>
 typedef for more readable function-type - to be used for 2-hit-selectionVariables.
 
using ThreeHitFunction = typename std::function< double(const PointType &, const PointType &, const PointType &)>
 typedef for more readable function-type - to be used for 3-hit-selectionVariables.
 
using FourHitFunction = typename std::function< double(const PointType &, const PointType &, const PointType &, const PointType &)>
 typedef for more readable function-type - to be used for 4-hit-selectionVariables.
 

Public Member Functions

 FilterMill ()
 Constructor.
 
void lockMill ()
 to block adding new filters, execute this member.
 
void add2HitFilter (std::pair< const std::string, TwoHitFunction > newFilter)
 add new Filter for 2 Hits .
 
void add3HitFilter (std::pair< std::string, ThreeHitFunction > newFilter)
 add new Filter for 3 Hits .
 
void add4HitFilter (std::pair< std::string, FourHitFunction > newFilter)
 add new Filter for 4 Hits .
 
void grindData2Hit (const HitPair &dataSet, std::vector< std::pair< std::string, double > > &collectedData) const
 on given dataSet, apply all filters stored in the mill and store the results in collectedData.
 
void grindData3Hit (const HitTriplet &dataSet, std::vector< std::pair< std::string, double > > &collectedData) const
 on given dataSet, apply all filters stored in the mill and store the results in collectedData.
 
void grindData4Hit (const HitQuadruplet &dataSet, std::vector< std::pair< std::string, double > > &collectedData) const
 on given dataSet, apply all filters stored in the mill and store the results in collectedData.
 

Protected Member Functions

void checkLocked (const std::string &name) const
 to be executed by functions which shall work with unchangeable set of filters.
 

Protected Attributes

std::vector< std::pair< std::string, TwoHitFunction > > m_2Hitfilters
 Contains all 2-hit-Filters and their names to be applied.
 
std::vector< std::pair< std::string, ThreeHitFunction > > m_3Hitfilters
 Contains all 3-hit-Filters and their names to be applied.
 
std::vector< std::pair< std::string, FourHitFunction > > m_4Hitfilters
 Contains all 4-hit-Filters and their names to be applied.
 
bool m_locked = false
 Simple saveguard for not changin any filters after preparing phase.
 

Detailed Description

template<class PointType>
class Belle2::FilterMill< PointType >

Small class which stores the filters/selectionVariables to be used for a secMap and has an interface for applying them.

Definition at line 25 of file FilterMill.h.

Member Typedef Documentation

◆ FourHitFunction

using FourHitFunction = typename std::function<double(const PointType&, const PointType&, const PointType&, const PointType&)>

typedef for more readable function-type - to be used for 4-hit-selectionVariables.

Definition at line 38 of file FilterMill.h.

◆ ThreeHitFunction

using ThreeHitFunction = typename std::function<double(const PointType&, const PointType&, const PointType&)>

typedef for more readable function-type - to be used for 3-hit-selectionVariables.

Definition at line 34 of file FilterMill.h.

◆ TwoHitFunction

using TwoHitFunction = typename std::function<double(const PointType&, const PointType&)>

typedef for more readable function-type - to be used for 2-hit-selectionVariables.

Definition at line 30 of file FilterMill.h.

Constructor & Destructor Documentation

◆ FilterMill()

FilterMill ( )
inline

Constructor.

Definition at line 94 of file FilterMill.h.

94 :
95 m_locked(false) {}
bool m_locked
Simple saveguard for not changin any filters after preparing phase.
Definition: FilterMill.h:56

Member Function Documentation

◆ add2HitFilter()

void add2HitFilter ( std::pair< const std::string, TwoHitFunction newFilter)
inline

add new Filter for 2 Hits .

Definition at line 103 of file FilterMill.h.

104 {
105 if (m_locked) {
106 B2ERROR("FilterMill-add2HitFilter: someone tried to add filter " << newFilter.first <<
107 " after lockdown! This is unintended behavior - doing nothing instead...");
108 return;
109 }
110 B2DEBUG(20, "FilterMill::add2HitFilter: filter " << newFilter.first << " added");
111 m_2Hitfilters.push_back(std::move(newFilter));
112 }
std::vector< std::pair< std::string, TwoHitFunction > > m_2Hitfilters
Contains all 2-hit-Filters and their names to be applied.
Definition: FilterMill.h:44

◆ add3HitFilter()

void add3HitFilter ( std::pair< std::string, ThreeHitFunction newFilter)
inline

add new Filter for 3 Hits .

Definition at line 116 of file FilterMill.h.

117 {
118 if (m_locked) {
119 B2ERROR("FilterMill-add3HitFilter: someone tried to add filter " << newFilter.first <<
120 " after lockdown! This is unintended behavior - doing nothing instead...");
121 return;
122 }
123 B2DEBUG(20, "FilterMill::add3HitFilter: filter " << newFilter.first << " added");
124 m_3Hitfilters.push_back(std::move(newFilter));
125 }
std::vector< std::pair< std::string, ThreeHitFunction > > m_3Hitfilters
Contains all 3-hit-Filters and their names to be applied.
Definition: FilterMill.h:48

◆ add4HitFilter()

void add4HitFilter ( std::pair< std::string, FourHitFunction newFilter)
inline

add new Filter for 4 Hits .

Definition at line 129 of file FilterMill.h.

130 {
131 if (m_locked) {
132 B2ERROR("FilterMill-add4HitFilter: someone tried to add filter " << newFilter.first <<
133 " after lockdown! This is unintended behavior - doing nothing instead...");
134 return;
135 }
136 B2DEBUG(20, "FilterMill::add4HitFilter: filter " << newFilter.first << " added");
137 m_4Hitfilters.push_back(std::move(newFilter));
138 }
std::vector< std::pair< std::string, FourHitFunction > > m_4Hitfilters
Contains all 4-hit-Filters and their names to be applied.
Definition: FilterMill.h:52

◆ checkLocked()

void checkLocked ( const std::string &  name) const
inlineprotected

to be executed by functions which shall work with unchangeable set of filters.

Definition at line 60 of file FilterMill.h.

61 {
62 if (!m_locked) {
63 B2WARNING("FilterMill-checkLocked: Function " << name <<
64 " was executed although the Mill was not locked yet. This might be unintended...");
65 }
66 }

◆ grindData2Hit()

void grindData2Hit ( const HitPair dataSet,
std::vector< std::pair< std::string, double > > &  collectedData 
) const
inline

on given dataSet, apply all filters stored in the mill and store the results in collectedData.

Definition at line 142 of file FilterMill.h.

144 {
145 checkLocked("grindData2Hit");
146 if (m_2Hitfilters.empty()) { B2DEBUG(20, "there are no 2-hit-filters stored, skipping grinding"); return; }
147
148 std::vector<std::pair<std::string, double>> tempData;
149 try {
150 for (const auto& filterPack : m_2Hitfilters) {
151
152 double result = filterPack.second(
153 *(dataSet.outer),
154 *(dataSet.inner));
155 tempData.push_back({filterPack.first, result});
156 }
157 } catch (...) {
158 std::string filterNames;
159 for (const auto& filterPack : m_2Hitfilters) {
160 filterNames += filterPack.first + " ";
161 }
162 B2WARNING("FilterMill:grindData2Hit: an exception was thrown by one of the Filters/SelectionVariables, that indicates strange input data, no data collected! Filters "
163 << filterNames << " were used and one of them did not work.");
164 return;
165 }
166
167 collectedData.insert(collectedData.end(), tempData.begin(), tempData.end());
168
169 B2DEBUG(20, "FilterMill::grindData2Hit: collectedData has now " << collectedData.size() << " entries");
170 }
void checkLocked(const std::string &name) const
to be executed by functions which shall work with unchangeable set of filters.
Definition: FilterMill.h:60

◆ grindData3Hit()

void grindData3Hit ( const HitTriplet dataSet,
std::vector< std::pair< std::string, double > > &  collectedData 
) const
inline

on given dataSet, apply all filters stored in the mill and store the results in collectedData.

Definition at line 174 of file FilterMill.h.

176 {
177 checkLocked("grindData3Hit");
178 if (m_3Hitfilters.empty()) { B2DEBUG(20, "there are no 3-hit-filters stored, skipping grinding"); return; }
179
180 std::vector<std::pair<std::string, double>> tempData;
181 try {
182 for (const auto& filterPack : m_3Hitfilters) {
183
184 double result = filterPack.second(
185 *(dataSet.outer),
186 *(dataSet.center),
187 *(dataSet.inner));
188 tempData.push_back({filterPack.first, result});
189 }
190 } catch (...) {
191 std::string filterNames;
192 for (const auto& filterPack : m_2Hitfilters) {
193 filterNames += filterPack.first + " ";
194 }
195 B2WARNING("FilterMill:grindData3Hit: an exception was thrown by one of the Filters/SelectionVariables, that indicates strange input data, no data collected! Filters "
196 << filterNames << " were used and one of them did not work.");
197 return;
198 }
199 collectedData.insert(collectedData.end(), tempData.begin(), tempData.end());
200
201 B2DEBUG(20, "FilterMill::grindData3Hit: collectedData has now " << collectedData.size() << " entries");
202 }

◆ grindData4Hit()

void grindData4Hit ( const HitQuadruplet dataSet,
std::vector< std::pair< std::string, double > > &  collectedData 
) const
inline

on given dataSet, apply all filters stored in the mill and store the results in collectedData.

Definition at line 206 of file FilterMill.h.

208 {
209 checkLocked("grindData4Hit");
210 if (m_4Hitfilters.empty()) { B2DEBUG(20, "there are no 4-hit-filters stored, skipping grinding"); return; }
211
212 std::vector<std::pair<std::string, double>> tempData;
213 try {
214 for (const auto& filterPack : m_4Hitfilters) {
215
216 double result = filterPack.second(
217 *(dataSet.outer),
218 *(dataSet.outerCenter),
219 *(dataSet.innerCenter),
220 *(dataSet.inner));
221 tempData.push_back({filterPack.first, result});
222 }
223 } catch (...) {
224 B2WARNING("FilterMill:grindData4Hit: an exception was thrown by one of the Filters/SelectionVariables, that indicates strange input data, no data collected!");
225 return;
226 }
227 collectedData.insert(collectedData.end(), tempData.begin(), tempData.end());
228
229 B2DEBUG(20, "FilterMill::grindData4Hit: collectedData has now " << collectedData.size() << " entries");
230 }

◆ lockMill()

void lockMill ( )
inline

to block adding new filters, execute this member.

Definition at line 99 of file FilterMill.h.

99{ m_locked = true; }

Member Data Documentation

◆ m_2Hitfilters

std::vector<std::pair<std::string, TwoHitFunction> > m_2Hitfilters
protected

Contains all 2-hit-Filters and their names to be applied.

Definition at line 44 of file FilterMill.h.

◆ m_3Hitfilters

std::vector<std::pair<std::string, ThreeHitFunction> > m_3Hitfilters
protected

Contains all 3-hit-Filters and their names to be applied.

Definition at line 48 of file FilterMill.h.

◆ m_4Hitfilters

std::vector<std::pair<std::string, FourHitFunction> > m_4Hitfilters
protected

Contains all 4-hit-Filters and their names to be applied.

Definition at line 52 of file FilterMill.h.

◆ m_locked

bool m_locked = false
protected

Simple saveguard for not changin any filters after preparing phase.

Definition at line 56 of file FilterMill.h.


The documentation for this class was generated from the following file: