Belle II Software prerelease-11-00-00a
HLTPrefilter.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#pragma once
9
10/* HLT headers */
11#include <hlt/softwaretrigger/core/utilities.h>
12#include <hlt/dbobjects/HLTPrefilterParameters.h>
13
14/* basf2 headers */
15#include <svd/dataobjects/SVDShaperDigit.h>
16#include <cdc/dataobjects/CDCHit.h>
17#include <ecl/dataobjects/ECLDigit.h>
18#include <framework/database/DBObjPtr.h>
19#include <framework/datastore/StoreArray.h>
20#include <framework/datastore/StoreObjPtr.h>
21#include <framework/dbobjects/BunchStructure.h>
22#include <framework/dbobjects/HardwareClockSettings.h>
23#include <mdst/dataobjects/EventLevelTriggerTimeInfo.h>
24#include <mdst/dataobjects/TRGSummary.h>
25#include <reconstruction/dbobjects/EventsOfDoomParameters.h>
26
27/* C++ headers */
28#include <cstdint>
29
30namespace Belle2::HLTPrefilter {
31
36 private:
37
40
43
46
49
52
53 public:
54
56 {
57 if (m_TTDInfo.isValid() && m_hltPrefilterParameters.isValid() && m_l1Trigger.isValid()) {
58
59 // Injection Timing mode thresholds
61 const double LERtimeSinceLastInjectionMin = m_hltPrefilterParameters->getLERtimeSinceLastInjectionMin();
63 const double LERtimeSinceLastInjectionMax = m_hltPrefilterParameters->getLERtimeSinceLastInjectionMax();
65 const double HERtimeSinceLastInjectionMin = m_hltPrefilterParameters->getHERtimeSinceLastInjectionMin();
67 const double HERtimeSinceLastInjectionMax = m_hltPrefilterParameters->getHERtimeSinceLastInjectionMax();
69 const double LERtimeInBeamCycleMin = m_hltPrefilterParameters->getLERtimeInBeamCycleMin();
71 const double LERtimeInBeamCycleMax = m_hltPrefilterParameters->getLERtimeInBeamCycleMax();
73 const double HERtimeInBeamCycleMin = m_hltPrefilterParameters->getHERtimeInBeamCycleMin();
75 const double HERtimeInBeamCycleMax = m_hltPrefilterParameters->getHERtimeInBeamCycleMax();
76
78 const double revolutionTime = m_bunchStructure->getRFBucketsPerRevolution() * 1e-3 /
79 m_clockSettings->getAcceleratorRF(); // [microsecond]
81 const double globalClock = m_clockSettings->getGlobalClockFrequency() * 1e3; // [microsecond]
82 // Calculate time since last injection
83 const double timeSinceLastInj = m_TTDInfo->getTimeSinceLastInjection() / globalClock; // [microsecond]
84 // Calculate time in beam cycle
85 const double timeInBeamCycle = timeSinceLastInj - (int)(timeSinceLastInj / revolutionTime) * revolutionTime; // [microsecond]
86
87 // Check if events are in injection strip of LER
88 const bool LER_strip = (LERtimeSinceLastInjectionMin < timeSinceLastInj &&
89 timeSinceLastInj < LERtimeSinceLastInjectionMax &&
90 LERtimeInBeamCycleMin < timeInBeamCycle &&
91 timeInBeamCycle < LERtimeInBeamCycleMax);
92
93 // Check if events are in injection strip of HER
94 const bool HER_strip = (HERtimeSinceLastInjectionMin < timeSinceLastInj &&
95 timeSinceLastInj < HERtimeSinceLastInjectionMax &&
96 HERtimeInBeamCycleMin < timeInBeamCycle &&
97 timeInBeamCycle < HERtimeInBeamCycleMax);
98
99 //find out if we are in the passive veto or in the active veto window
100 bool inActiveInjectionVeto = false; //events accepted in the passive veto window but not in the active
101 try {
102 if (m_l1Trigger->testInput("passive_veto") == 1 && m_l1Trigger->testInput("cdcecl_veto") == 0)
103 inActiveInjectionVeto = true; //events in active veto
104 } catch (const std::exception&) {
105 }
106
107 if (inActiveInjectionVeto && (LER_strip || HER_strip))
108 B2WARNING("Skip event if HLTPrefilter On --> Event tagged by HLTPrefilter as injection background");
109
110 // Tag events from active veto inside injection strip with a prescale
111 return inActiveInjectionVeto && (LER_strip || HER_strip);
112 } else
113 return false;
114 }
115 };
116
121 private:
122
125
128
131
134
135 public:
136
138 {
139 if (m_hltPrefilterParameters.isValid() && m_l1Trigger.isValid()) {
140
141 // CDC-ECL mode thresholds
143 const uint32_t nCDCHitsMax = m_hltPrefilterParameters->getCDCHitsMax();
145 const uint32_t nECLDigitsMax = m_hltPrefilterParameters->getECLDigitsMax();
146
148 const uint32_t nCDCHits = m_cdcHits.isOptional() ? m_cdcHits.getEntries() : 0;
150 const uint32_t nECLDigits = m_eclDigits.isOptional() ? m_eclDigits.getEntries() : 0;
151
152 //find out if we are in the passive veto or in the active veto window
153 bool inActiveInjectionVeto = false; //events accepted in the passive veto window but not in the active
154 try {
155 if (m_l1Trigger->testInput("passive_veto") == 1 && m_l1Trigger->testInput("cdcecl_veto") == 0)
156 inActiveInjectionVeto = true; //events in active veto
157 } catch (const std::exception&) {
158 }
159
160 if (inActiveInjectionVeto && (nCDCHits > nCDCHitsMax && nECLDigits > nECLDigitsMax))
161 B2WARNING("Skip event if HLTPrefilter On --> Event tagged by HLTPrefilter as high CDC-ECL occupancy");
162
163 // Tag events having a large CDC and ECL occupancy with a prescale
164 return inActiveInjectionVeto && (nCDCHits > nCDCHitsMax && nECLDigits > nECLDigitsMax);
165 } else
166 return false;
167 }
168
169 };
170
175 private:
182
183 public:
184
186 {
187 if (m_eventsOfDoomParameters.isValid()) {
188
189 // EventsOfDoomBuster mode thresholds
191 const uint32_t nCDCHitsMax = m_eventsOfDoomParameters->getNCDCHitsMax();
193 const uint32_t nSVDShaperDigitsMax = m_eventsOfDoomParameters->getNSVDShaperDigitsMax();
194
196 const uint32_t nCDCHits = m_cdcHits.isOptional() ? m_cdcHits.getEntries() : 0;
198 const uint32_t nSVDShaperDigits = m_svdShaperDigits.isOptional() ? m_svdShaperDigits.getEntries() : 0;
199
200 const bool doomCDC = nCDCHits > nCDCHitsMax;
201 const bool doomSVD = nSVDShaperDigits > nSVDShaperDigitsMax;
202
203 if (doomCDC) {
204 B2ERROR("Skip event --> Too much occupancy from CDC for reconstruction!" <<
205 LogVar("nCDCHits", nCDCHits) <<
206 LogVar("nCDCHitsMax", nCDCHitsMax));
207 }
208
209 if (doomSVD) {
210 B2ERROR("Skip event --> Too much occupancy from SVD for reconstruction!" <<
211 LogVar("nSVDShaperDigits", nSVDShaperDigits) <<
212 LogVar("nSVDShaperDigitsMax", nSVDShaperDigitsMax));
213 }
214
215 // Tag events having a large SVD or CDC occupancy
216 return (doomCDC || doomSVD);
217 } else
218 return false;
219 }
220
221 };
222
223}
Class for accessing objects in the database.
Definition DBObjPtr.h:21
Helper for CDCECLCut state.
StoreObjPtr< TRGSummary > m_l1Trigger
Store Object with the trigger result.
StoreArray< ECLDigit > m_eclDigits
ECLDigits StoreArray.
DBObjPtr< HLTPrefilterParameters > m_hltPrefilterParameters
HLTprefilterParameters Database OjbPtr.
StoreArray< CDCHit > m_cdcHits
CDChits StoreArray.
Helper for EventsOfDoomBuster state.
DBObjPtr< EventsOfDoomParameters > m_eventsOfDoomParameters
EventsOfDoomParameters Database OjbPtr.
StoreArray< SVDShaperDigit > m_svdShaperDigits
SVDShaperDigits StoreArray.
StoreArray< CDCHit > m_cdcHits
CDCHits StoreArray.
Helper for TimingCut state.
StoreObjPtr< EventLevelTriggerTimeInfo > m_TTDInfo
Store array object for injection time info.
StoreObjPtr< TRGSummary > m_l1Trigger
Store Object with the trigger result.
DBObjPtr< HardwareClockSettings > m_clockSettings
Define object for HardwareClockSettings class.
DBObjPtr< BunchStructure > m_bunchStructure
Define object for BunchStructure class.
DBObjPtr< HLTPrefilterParameters > m_hltPrefilterParameters
HLTprefilterParameters Database OjbPtr.
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
Class to store variables with their name which were sent to the logging service.