Belle II Software  release-08-01-10
FiltersContainer.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 
9 #pragma once
10 
11 #include "tracking/trackFindingVXD/environment/VXDTFFilters.h"
12 #include <unordered_map>
13 #include <string>
14 
15 namespace Belle2 {
26  template<class point_t>
28  public:
29 
31  using setupNameToFilters_t = std::unordered_map< std::string, Belle2::VXDTFFilters<point_t>*>;
32 
33  private:
34 
37 
38 
41  FiltersContainer(const FiltersContainer& filtersContainer) = delete;
44 
47  {
48  }
49 
50  public:
51 
54  {
56  static std::unique_ptr<FiltersContainer> instance(new FiltersContainer());
57  return * instance;
58  }
59 
60 
63  {
64  for (auto& filter : m_allSetupsFilters)
65  delete filter.second;
66  }
67 
68 
70  VXDTFFilters<point_t>* getFilters(const std::string& setupName)
71  {
72  auto result = m_allSetupsFilters.find(setupName);
73  if (result == m_allSetupsFilters.end())
74  return nullptr;
75  return result->second;
76  }
77 
78 
81  {
82  return m_allSetupsFilters;
83  }
84 
85 
87  void assignFilters(const std::string& setupName,
88  VXDTFFilters<point_t>* filters)
89  {
90  // case there is already a filter with this name in the container, we delete that filter!
91  if (m_allSetupsFilters.count(setupName)) {
92  B2INFO("FiltersContainer: Replacing existing filter for setup name: " << setupName);
93  if (m_allSetupsFilters[ setupName ] && filters != m_allSetupsFilters[ setupName ]) delete m_allSetupsFilters[ setupName ];
94  }
95  m_allSetupsFilters[ setupName ] = filters;
96  }
97 
98  };
100 }
This class contains everything needed by the VXDTF that is not going to change during a RUN,...
static FiltersContainer & getInstance()
one and only way to access the singleton object
virtual ~FiltersContainer()
Destructor deleting all filters stored.
const setupNameToFilters_t & getAllSetups(void)
returns all the available setups.
FiltersContainer & operator=(const FiltersContainer &)=delete
dont allow copies
FiltersContainer(const FiltersContainer &filtersContainer)=delete
Copies of this class, which is a singleton, are not allowed so the copy constructor method is deleted...
VXDTFFilters< point_t > * getFilters(const std::string &setupName)
Gives access to the sector map and filters of a given setup.
FiltersContainer()
Singleton so use a hidden Constructor.
void assignFilters(const std::string &setupName, VXDTFFilters< point_t > *filters)
assigns filters.
std::unordered_map< std::string, Belle2::VXDTFFilters< point_t > * > setupNameToFilters_t
typedef for better readability. Index is name of the setup.
setupNameToFilters_t m_allSetupsFilters
Container of all the Filters indexed by their setupNames.
Class that contains all the static sectors to which the filters are attached.
Definition: VXDTFFilters.h:63
std::map< ExpRun, std::pair< double, double > > filter(const std::map< ExpRun, std::pair< double, double >> &runs, double cut, std::map< ExpRun, std::pair< double, double >> &runsRemoved)
filter events to remove runs shorter than cut, it stores removed runs in runsRemoved
Definition: Splitter.cc:38
Abstract base class for different kinds of events.