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/trackFindingCDC/eventdata/hits/CDCWireHit.h>
10#include <cdc/dataobjects/CDCHit.h>
11
12using namespace Belle2;
13using namespace TrackFindingCDC;
14
15
17 m_CDCWireHitRequirementsFromDB(nullptr), m_DBPtrIsValidForCurrentRun(false)
18{
19}
20
22{
23 m_CDCWireHitRequirementsFromDB = std::make_unique<DBObjPtr<CDCWireHitRequirements> >();
25}
26
28{
30}
31
33{
35 B2ERROR("std::unique_ptr<DBObjPtr<CDCWireHitRequirements> > m_CDCWireHitRequirementsFromDB not properly set.\n"
36 "Cut not applied on CDCWireHit by CutsFromDBWireHitFilter. { findlet: CutsFromDBWireHitFilter }");
38 } else {
39 if (!((*m_CDCWireHitRequirementsFromDB).isValid())) {
40 B2WARNING("DBObjPtr<CDCWireHitRequirements> not valid for current run. { findlet: CutsFromDBWireHitFilter }\n"
41 "Cut not applied on CDCWireHit by CutsFromDBWireHitFilter. { findlet: CutsFromDBWireHitFilter }");
43 } else {
45 }
46 }
47}
48
51template <typename T>
52bool CutsFromDBWireHitFilter::isInRange(const T& value, const std::pair<T, T>& range) const
53{
54 if (range.second == -1) {
55 return (value >= range.first);
56 } else {
57 return (value >= range.first) && (value <= range.second);
58 }
59}
60
63template <typename T>
64bool CutsFromDBWireHitFilter::isLessThanOrEqualTo(const T& value, const T& upper_value) const
65{
66 if (upper_value == -1) {
67 return true;
68 } else {
69 return value <= upper_value;
70 }
71}
72
74{
75 const short ADC = (*wireHit.getHit()).getADCCount();
76 const short TOT = (*wireHit.getHit()).getTOT();
77 const float ADCOverTOT = (TOT != 0) ? static_cast<float>(ADC) / TOT : 0;
78
80 if ((*wireHit.getHit()).getISuperLayer() == 0) {
81 // First super layer (0)
82 // Check if ADC, TOT and ADC/TOT are in the corresponding allowed ranges.
83 if (isInRange<short>(ADC, (*m_CDCWireHitRequirementsFromDB)->getADCRangeFirstSuperLayer()) &&
84 isInRange<short>(TOT, (*m_CDCWireHitRequirementsFromDB)->getTOTRangeFirstSuperLayer()) &&
85 isInRange<float>(ADCOverTOT, (*m_CDCWireHitRequirementsFromDB)->getADCOverTOTRangeFirstSuperLayer()) &&
86 isLessThanOrEqualTo<short>(ADC, (*m_CDCWireHitRequirementsFromDB)->getMaxADCGivenTOTFirstSuperLayer(TOT))) {
87 // Hit accepted
88 return ADC;
89 } else {
90 // Hit rejected
91 return NAN;
92 }
93
94 } else {
95 // Outer super layers (1-8)
96 // Check if ADC, TOT and ADC/TOT are in the corresponding allowed ranges.
97 if (isInRange<short>(ADC, (*m_CDCWireHitRequirementsFromDB)->getADCRangeOuterSuperLayers()) &&
98 isInRange<short>(TOT, (*m_CDCWireHitRequirementsFromDB)->getTOTRangeOuterSuperLayers()) &&
99 isInRange<float>(ADCOverTOT, (*m_CDCWireHitRequirementsFromDB)->getADCOverTOTRangeOuterSuperLayers()) &&
100 isLessThanOrEqualTo<short>(ADC, (*m_CDCWireHitRequirementsFromDB)->getMaxADCGivenTOTOuterSuperLayers(TOT))) {
101 // Hit accepted
102 return ADC;
103 } else {
104 // Hit rejected
105 return NAN;
106 }
107 }
108 }
109 // If the DB pointer is not valid, the hit is accepted (cf. B2WARNING above)
110 return ADC;
111}
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition: CDCWireHit.h:159
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...
Weight operator()(const CDCWireHit &wireHit) final
Basic filter method to override.
void checkIfDBObjPtrIsValid()
Check if m_CDCWireHitRequirementsFromDB is valid and set m_DBPtrIsValidForCurrentRun accordingly.
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.
Abstract base class for different kinds of events.