Belle II Software development
CutsFromDBWireHitFilter.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/trackFindingCDC/filters/wireHit/CutsFromDBWireHitFilter.h>
9#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
10#include <cdc/dataobjects/CDCHit.h>
11
12using namespace Belle2;
13using namespace TrackFindingCDC;
14using namespace TrackingUtilities;
15
16
21
23{
24 m_CDCWireHitRequirementsFromDB = std::make_unique<DBObjPtr<CDCWireHitRequirements> >();
26}
27
32
34{
36 B2ERROR("std::unique_ptr<DBObjPtr<CDCWireHitRequirements> > m_CDCWireHitRequirementsFromDB not properly set.\n"
37 "Cut not applied on CDCWireHit by CutsFromDBWireHitFilter. { findlet: CutsFromDBWireHitFilter }");
39 } else {
40 if (!((*m_CDCWireHitRequirementsFromDB).isValid())) {
41 B2WARNING("DBObjPtr<CDCWireHitRequirements> not valid for current run. { findlet: CutsFromDBWireHitFilter }\n"
42 "Cut not applied on CDCWireHit by CutsFromDBWireHitFilter. { findlet: CutsFromDBWireHitFilter }");
44 } else {
46 }
47 }
48}
49
52template <typename T>
53bool CutsFromDBWireHitFilter::isInRange(const T& value, const std::pair<T, T>& range) const
54{
55 if (range.second == -1) {
56 return (value >= range.first);
57 } else {
58 return (value >= range.first) && (value <= range.second);
59 }
60}
61
64template <typename T>
65bool CutsFromDBWireHitFilter::isLessThanOrEqualTo(const T& value, const T& upper_value) const
66{
67 if (upper_value == -1) {
68 return true;
69 } else {
70 return value <= upper_value;
71 }
72}
73
75{
76 const short ADC = (*wireHit.getHit()).getADCCount();
77 const short TOT = (*wireHit.getHit()).getTOT();
78 const float ADCOverTOT = (TOT != 0) ? static_cast<float>(ADC) / TOT : 0;
79
81 if ((*wireHit.getHit()).getISuperLayer() == 0) {
82 // First super layer (0)
83 // Check if ADC, TOT and ADC/TOT are in the corresponding allowed ranges.
84 if (isInRange<short>(ADC, (*m_CDCWireHitRequirementsFromDB)->getADCRangeFirstSuperLayer()) &&
85 isInRange<short>(TOT, (*m_CDCWireHitRequirementsFromDB)->getTOTRangeFirstSuperLayer()) &&
86 isInRange<float>(ADCOverTOT, (*m_CDCWireHitRequirementsFromDB)->getADCOverTOTRangeFirstSuperLayer()) &&
87 isLessThanOrEqualTo<short>(ADC, (*m_CDCWireHitRequirementsFromDB)->getMaxADCGivenTOTFirstSuperLayer(TOT))) {
88 // Hit accepted
89 return ADC;
90 } else {
91 // Hit rejected
92 return NAN;
93 }
94
95 } else {
96 // Outer super layers (1-8)
97 // Check if ADC, TOT and ADC/TOT are in the corresponding allowed ranges.
98 if (isInRange<short>(ADC, (*m_CDCWireHitRequirementsFromDB)->getADCRangeOuterSuperLayers()) &&
99 isInRange<short>(TOT, (*m_CDCWireHitRequirementsFromDB)->getTOTRangeOuterSuperLayers()) &&
100 isInRange<float>(ADCOverTOT, (*m_CDCWireHitRequirementsFromDB)->getADCOverTOTRangeOuterSuperLayers()) &&
101 isLessThanOrEqualTo<short>(ADC, (*m_CDCWireHitRequirementsFromDB)->getMaxADCGivenTOTOuterSuperLayers(TOT))) {
102 // Hit accepted
103 return ADC;
104 } else {
105 // Hit rejected
106 return NAN;
107 }
108 }
109 }
110 // If the DB pointer is not valid, the hit is accepted (cf. B2WARNING above)
111 return ADC;
112}
std::unique_ptr< DBObjPtr< CDCWireHitRequirements > > m_CDCWireHitRequirementsFromDB
Cut values from the Data Base.
void initialize() final
Called at the beginning of the processing.
void beginRun() final
Called when a new run is started.
bool isInRange(const T &value, const std::pair< T, T > &range) const
Check if value >= range.first and value <= range.second If range.second == -1, then check only if val...
void checkIfDBObjPtrIsValid()
Check if m_CDCWireHitRequirementsFromDB is valid and set m_DBPtrIsValidForCurrentRun accordingly.
TrackingUtilities::Weight operator()(const TrackingUtilities::CDCWireHit &wireHit) final
Basic filter method to override.
bool m_DBPtrIsValidForCurrentRun
Boolean asserting if DBObjPtr is valid for the current run.
bool isLessThanOrEqualTo(const T &value, const T &upper_value) const
Check if value <= upper_value If upper_value == -1, then return true.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:58
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition CDCWireHit.h:162
Abstract base class for different kinds of events.