Belle II Software  release-08-01-10
SectorMapBasedSVDPairFilter.cc
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 #include <tracking/ckf/svd/filters/relations/SectorMapBasedSVDPairFilter.h>
9 #include <tracking/trackFindingCDC/filters/base/Filter.icc.h>
10 
11 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
12 
13 #include <tracking/spacePointCreation/SpacePoint.h>
14 #include <framework/core/ModuleParamList.templateDetails.h>
15 #include <tracking/dataobjects/FullSecID.h>
16 
17 namespace Belle2 {
23  {
25 
27  if (not m_vxdtfFilters) {
28  B2FATAL("Requested secMapName '" << m_param_sectorMapName << "' does not exist!");
29  }
30  }
31 
32  void SectorMapBasedSVDPairFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
33  {
34  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "sectorMapName"), m_param_sectorMapName,
35  "Name of the sector map to use.", m_param_sectorMapName);
36  }
37 
38  TrackFindingCDC::Weight SectorMapBasedSVDPairFilter::operator()(const std::pair<const CKFToSVDState*, const CKFToSVDState*>&
39  relation)
40  {
41  const CKFToSVDState* fromState = relation.first;
42  const CKFToSVDState* toState = relation.second;
43 
44  B2ASSERT("From and to state must be set", fromState and toState);
45 
46  const CKFToSVDState::stateCache& outerStateCache = fromState->getStateCache();
47  const CKFToSVDState::stateCache& innerStateCache = toState->getStateCache();
48 
49  B2ASSERT("Both hits must be present!", outerStateCache.isHitState and innerStateCache.isHitState);
50 
51  // TODO maybe it would be better to look for the full IDs first; maybe not
52  B2ASSERT("Outer hit is invalid",
53  m_vxdtfFilters->areCoordinatesValid(outerStateCache.sensorID, outerStateCache.localNormalizedu, outerStateCache.localNormalizedv));
54  B2ASSERT("Inner hit is invalid",
55  m_vxdtfFilters->areCoordinatesValid(innerStateCache.sensorID, innerStateCache.localNormalizedu, innerStateCache.localNormalizedv));
56 
57  FullSecID outerSecID = m_vxdtfFilters->getFullID(outerStateCache.sensorID, outerStateCache.localNormalizedu,
58  outerStateCache.localNormalizedv);
59  FullSecID innerSecID = m_vxdtfFilters->getFullID(innerStateCache.sensorID, innerStateCache.localNormalizedu,
60  innerStateCache.localNormalizedv);
61 
62  const auto* outerStaticSector = m_vxdtfFilters->getStaticSector(outerSecID);
63 
64  const auto* filter = outerStaticSector->getFilter2sp(innerSecID);
65  if (not filter) {
66  return NAN;
67  }
68 
69  const SpacePoint* outerHit = fromState->getHit();
70  const SpacePoint* innerHit = toState->getHit();
71 
72  if (not filter->accept(*outerHit, *innerHit)) {
73  return NAN;
74  }
75 
76  B2INFO(outerSecID.getVxdID() << " -> " << innerSecID.getVxdID());
77  return 1;
78  }
80 }
const Hit * getHit() const
Return the SP this state is related to. May be nullptr.
Definition: CKFState.h:66
Specialized CKF State for extrapolating into the SVD.
Definition: CKFToSVDState.h:27
const struct stateCache & getStateCache() const
Get the cached data of this state.
Definition: CKFToSVDState.h:54
VXDTFFilters< point_t > * getFilters(const std::string &setupName)
Gives access to the sector map and filters of a given setup.
Class to identify a sector inside of the VXD.
Definition: FullSecID.h:33
VxdID getVxdID() const
returns VxdID of sensor.
Definition: FullSecID.h:138
The Module parameter list class.
SectorMapFilter * m_vxdtfFilters
The sector map filter, will be set in begin run.
std::string m_param_sectorMapName
Name of the sector map to use.
FilterContainer & m_filtersContainer
The filter container to use.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
void beginRun() override
Receive and dispatch signal for the beginning of a new run.
FullSecID getFullID(VxdID aSensorID, double normalizedU, double normalizedV) const
returns fullSecID for given sensorID and local coordinates.
Definition: VXDTFFilters.h:259
bool areCoordinatesValid(VxdID aSensorID, double normalizedU, double normalizedV) const
check if using getFullID() would be safe (true if it is safe):
Definition: VXDTFFilters.h:248
const staticSector_t * getStaticSector(const FullSecID secID) const
returns pointer to static sector for given fullSecID.
Definition: VXDTFFilters.h:220
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
void beginRun() final
Initialize the sector map.
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
TrackFindingCDC::Weight operator()(const std::pair< const CKFToSVDState *, const CKFToSVDState * > &relation) override
Give a final weight to the possibilities by asking the filter.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters of the filter.
Abstract base class for different kinds of events.