Belle II Software development
AsicBackgroundDetector Class Referenceabstract

Marks hits as background based on the result of a filter. More...

#include <AsicBackgroundDetector.h>

Inheritance diagram for AsicBackgroundDetector:
Findlet< CDCWireHit & > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

using IOTypes = std::tuple< AIOTypes... >
 Types that should be served to apply on invocation.
 
using IOVectors = std::tuple< std::vector< AIOTypes >... >
 Vector types that should be served to apply on invocation.
 

Public Member Functions

 AsicBackgroundDetector ()=default
 Default constructor.
 
void initialize () final
 Access database here:
 
void beginRun () final
 Reload channel map if needed.
 
std::string getDescription () final
 Short description of the findlet.
 
virtual void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) final
 Expose the parameters to a module.
 
virtual void apply (std::vector< CDCWireHit > &wireHits) final
 Main algorithm marking hit as background.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
void beginEvent () override
 Receive and dispatch signal for the start of a new event.
 
void endRun () override
 Receive and dispatch signal for the end of the run.
 
void terminate () override
 Receive and dispatch Signal for termination of the event processing.
 

Protected Types

using ToVector = typename ToVectorImpl< T >::Type
 Short hand for ToRangeImpl.
 

Protected Member Functions

void addProcessingSignalListener (ProcessingSignalListener *psl)
 Register a processing signal listener to be notified.
 
int getNProcessingSignalListener ()
 Get the number of currently registered listeners.
 

Private Types

using Super = Findlet< CDCWireHit & >
 Type of the base class.
 

Private Member Functions

void applyAsicFilter (std::vector< CDCWireHit * > &wireHits)
 Algorithm marking hit as background for each CDC ASIC.
 

Private Attributes

std::unique_ptr< DBArray< CDCChannelMap > > m_channelMapFromDB
 Channel map retrieved from DB.
 
std::map< int, std::pair< int, int > > m_map
 map from ewire to board/channel ID
 
size_t m_minimal_hit_number {4}
 min. number of hits in ASIC for background check
 
double m_deviation_from_median {10.}
 distance from median TDC, to be considered as bg.
 
size_t m_nsignal_max {4}
 max. number of signal-like hits in ASIC for background check
 
size_t m_max_asic_error_messages {1}
 max. number of logged error messages for number of hits per ASIC check
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized = false
 Flag to keep track whether initialization happened before.
 
bool m_terminated = false
 Flag to keep track whether termination happened before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

Marks hits as background based on the result of a filter.

Definition at line 26 of file AsicBackgroundDetector.h.

Member Typedef Documentation

◆ IOTypes

using IOTypes = std::tuple<AIOTypes...>
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors

using IOVectors = std::tuple< std::vector<AIOTypes>... >
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ Super

using Super = Findlet<CDCWireHit&>
private

Type of the base class.

Definition at line 29 of file AsicBackgroundDetector.h.

◆ ToVector

using ToVector = typename ToVectorImpl<T>::Type
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

Member Function Documentation

◆ addProcessingSignalListener()

void addProcessingSignalListener ( ProcessingSignalListener psl)
protectedinherited

Register a processing signal listener to be notified.

Definition at line 55 of file CompositeProcessingSignalListener.cc.

56{
58}
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
References to subordinary signal processing listener contained in this findlet.

◆ apply()

void apply ( std::vector< CDCWireHit > &  wireHits)
finalvirtual

Main algorithm marking hit as background.

Definition at line 57 of file AsicBackgroundDetector.cc.

58{
59
60 map< pair<int, int>, vector<CDCWireHit*>> groupedByAsic;
61 for (CDCWireHit& wireHit : wireHits) {
62 auto eWire = wireHit.getWireID().getEWire();
63 B2ASSERT("Channel map NOT found for the channel", m_map.count(eWire) > 0);
64 auto board = m_map[eWire].first;
65 auto channel = m_map[eWire].second;
66 auto asicID = pair<int, int>(board, channel / 8); // ASIC are groups of 8 channels
67 groupedByAsic[asicID].push_back(&wireHit);
68 };
69 for (auto& asicList : groupedByAsic) {
70 applyAsicFilter(asicList.second);
71 };
72
73 return;
74}
std::map< int, std::pair< int, int > > m_map
map from ewire to board/channel ID
void applyAsicFilter(std::vector< CDCWireHit * > &wireHits)
Algorithm marking hit as background for each CDC ASIC.
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55

◆ applyAsicFilter()

void applyAsicFilter ( std::vector< CDCWireHit * > &  wireHits)
private

Algorithm marking hit as background for each CDC ASIC.

Extra information:

This is abnormal situation, detected for few runs, related to CDC unpacker. Hits are to be marked as background.

Definition at line 93 of file AsicBackgroundDetector.cc.

94{
95
96 if (wireHits.size() < m_minimal_hit_number) {
97 return;
98 };
99
100 if (wireHits.size() > 8) {
102 auto eWire = wireHits[0]->getWireID().getEWire();
103 auto board = m_map[eWire].first;
104
106 B2ERROR("Number of hits per asic should not exceed 8, observe too many hits."
107 << LogVar("nHits", wireHits.size())
108 << LogVar("Board ID", board));
110 } else {
111 B2WARNING("Number of hits per asic should not exceed 8, observe too many hits."
112 << LogVar("nHits", wireHits.size())
113 << LogVar("Board ID", board));
114 }
115
117 for (auto& hit : wireHits) {
118 (*hit)->setBackgroundFlag();
119 (*hit)->setTakenFlag();
120 }
121 return;
122 }
123
124 // compute median time:
125 vector<short> times;
126 for (auto& hit : wireHits) {
127 short tdc = hit->getHit()->getTDCCount();
128 times.push_back(tdc);
129 }
130 sort(times.begin(), times.end());
131 int mid = times.size() / 2;
132 double median = times.size() % 2 == 0 ? (times[mid] + times[mid - 1]) / 2 : times[mid];
133
134 size_t nbg = 0;
135 int adcOnMedian = 0;
136 int adcOffMedian = 0;
137 for (auto& hit : wireHits) {
138 int adc = hit->getHit()->getADCCount();
139 if (fabs(hit->getHit()->getTDCCount() - median) < m_deviation_from_median) {
140 nbg++;
141 if (adc > adcOnMedian) adcOnMedian = adc;
142 } else {
143 if (adc > adcOffMedian) adcOffMedian = adc;
144 }
145 }
146
147 if ((nbg < times.size()) // at least 1 hit with different TDC ("signal")
148 && (nbg > 1) // more than one candidate hits
149 && (nbg > times.size() - m_nsignal_max) // a few background hits
150 && (adcOnMedian < adcOffMedian) // triggered by large ADC "signal"
151 ) {
152
153 // mark hits too close to the median time as background:
154 for (auto& hit : wireHits) {
155 if (fabs(hit->getHit()->getTDCCount() - median) < m_deviation_from_median) {
156 (*hit)->setBackgroundFlag();
157 (*hit)->setTakenFlag();
158 }
159 }
160 }
161}
double m_deviation_from_median
distance from median TDC, to be considered as bg.
size_t m_nsignal_max
max. number of signal-like hits in ASIC for background check
size_t m_max_asic_error_messages
max. number of logged error messages for number of hits per ASIC check
size_t m_minimal_hit_number
min. number of hits in ASIC for background check
Class to store variables with their name which were sent to the logging service.

◆ beginEvent()

void beginEvent ( )
overridevirtualinherited

Receive and dispatch signal for the start of a new event.

Reimplemented from ProcessingSignalListener.

Reimplemented in SpacePointTagger< Belle2::CKFToPXDResult, Belle2::PXDCluster >, SpacePointTagger< Belle2::CKFToSVDResult, Belle2::SVDCluster >, BaseEventTimeExtractor< RecoTrack * >, BaseEventTimeExtractor< TrackFindingCDC::CDCWireHit & >, SharingHitsMatcher< Belle2::TrackFindingCDC::CDCTrack, Belle2::TrackFindingCDC::CDCSegment2D >, MCSymmetric< BaseAxialSegmentPairFilter >, MCSymmetric< BaseFacetFilter >, MCSymmetric< BaseFacetRelationFilter >, MCSymmetric< BaseSegmentPairFilter >, MCSymmetric< BaseSegmentPairRelationFilter >, MCSymmetric< BaseSegmentRelationFilter >, MCSymmetric< BaseSegmentTripleFilter >, MCSymmetric< BaseSegmentTripleRelationFilter >, MCSymmetric< BaseTrackRelationFilter >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCFacet >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCWireHit, true >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegment2D >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCTrack >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegmentPair >, StoreVectorSwapper< Belle2::TrackFindingCDC::CDCSegmentTriple >, RecoTrackStorer, ROIFinder, and SVDHoughTracking.

Definition at line 31 of file CompositeProcessingSignalListener.cc.

32{
35 psl->beginEvent();
36 }
37}
Interface for an algorithm part that needs to receive the module processing signals.
virtual void beginEvent()
Receive signal for the start of a new event.

◆ beginRun()

void beginRun ( )
finalvirtual

Reload channel map if needed.

Reimplemented from ProcessingSignalListener.

Definition at line 36 of file AsicBackgroundDetector.cc.

37{
39
40 // Load map from DB:
41 for (const auto& cm : (*m_channelMapFromDB)) {
42 const int isl = cm.getISuperLayer();
43 const int il = cm.getILayer();
44 const int iw = cm.getIWire();
45 const int iBoard = cm.getBoardID();
46 const int iCh = cm.getBoardChannel();
47 const WireID wireId(isl, il, iw);
48 m_map[wireId.getEWire()] = std::pair<int, int>(iBoard, iCh);
49 }
50}
std::unique_ptr< DBArray< CDCChannelMap > > m_channelMapFromDB
Channel map retrieved from DB.
void beginRun() override
Receive and dispatch signal for the beginning of a new run.
Class to identify a wire inside the CDC.
Definition: WireID.h:34

◆ endRun()

void endRun ( )
overridevirtualinherited

Receive and dispatch signal for the end of the run.

Reimplemented from ProcessingSignalListener.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

40{
42 psl->endRun();
43 }
45}
virtual void endRun()
Receive signal for the end of the run.

◆ exposeParameters()

void exposeParameters ( ModuleParamList moduleParamList,
const std::string &  prefix 
)
finalvirtual

Expose the parameters to a module.

Reimplemented from Findlet< CDCWireHit & >.

Definition at line 76 of file AsicBackgroundDetector.cc.

77{
78 Super::exposeParameters(moduleParamList, prefix);
79 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "minimalHitNumberASIC"),
81 "Required number of hits per ASIC for background check",
83 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "deviationFromMedianTDCinASIC"),
85 "Flag hits as cross talk if TDC does not deviate from median more than this value",
87 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "minimalNSignalASIC"),
89 "Flag background hits only when ASIC contains no more than this number of signal hits",
91}
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Forward prefixed parameters of this findlet to the module parameter list.
Definition: Findlet.h:69
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.

◆ getDescription()

std::string getDescription ( )
finalvirtual

Short description of the findlet.

Reimplemented from Findlet< CDCWireHit & >.

Definition at line 52 of file AsicBackgroundDetector.cc.

53{
54 return "Marks hits as background using ASIC-based filter.";
55}

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 60 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
finalvirtual

Access database here:

Reimplemented from ProcessingSignalListener.

Definition at line 23 of file AsicBackgroundDetector.cc.

24{
26 // database:
27 m_channelMapFromDB = std::make_unique<DBArray<CDCChannelMap>> ();
28
29 if ((*m_channelMapFromDB).isValid()) {
30 B2DEBUG(25, "CDC Channel map is valid");
31 } else {
32 B2FATAL("CDC Channel map is not valid");
33 }
34}
void initialize() override
Receive and dispatch signal before the start of the event processing.

◆ terminate()

void terminate ( )
overridevirtualinherited

Receive and dispatch Signal for termination of the event processing.

Reimplemented from ProcessingSignalListener.

Reimplemented in StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::HyperHough >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::QuadraticLegendre >, and StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::Z0TanLambdaLegendre >.

Definition at line 47 of file CompositeProcessingSignalListener.cc.

48{
50 psl->terminate();
51 }
53}
virtual void terminate()
Receive Signal for termination of the event processing.

Member Data Documentation

◆ m_channelMapFromDB

std::unique_ptr<DBArray<CDCChannelMap> > m_channelMapFromDB
private

Channel map retrieved from DB.

Definition at line 57 of file AsicBackgroundDetector.h.

◆ m_deviation_from_median

double m_deviation_from_median {10.}
private

distance from median TDC, to be considered as bg.

Definition at line 66 of file AsicBackgroundDetector.h.

◆ m_initialized

bool m_initialized = false
privateinherited

Flag to keep track whether initialization happened before.

Definition at line 52 of file ProcessingSignalListener.h.

◆ m_initializedAs

std::string m_initializedAs
privateinherited

Name of the type during initialisation.

Definition at line 58 of file ProcessingSignalListener.h.

◆ m_map

std::map<int, std::pair<int, int> > m_map
private

map from ewire to board/channel ID

Definition at line 60 of file AsicBackgroundDetector.h.

◆ m_max_asic_error_messages

size_t m_max_asic_error_messages {1}
private

max. number of logged error messages for number of hits per ASIC check

Definition at line 72 of file AsicBackgroundDetector.h.

◆ m_minimal_hit_number

size_t m_minimal_hit_number {4}
private

min. number of hits in ASIC for background check

Definition at line 63 of file AsicBackgroundDetector.h.

◆ m_nsignal_max

size_t m_nsignal_max {4}
private

max. number of signal-like hits in ASIC for background check

Definition at line 69 of file AsicBackgroundDetector.h.

◆ m_subordinaryProcessingSignalListeners

std::vector<ProcessingSignalListener*> m_subordinaryProcessingSignalListeners
privateinherited

References to subordinary signal processing listener contained in this findlet.

Definition at line 52 of file CompositeProcessingSignalListener.h.

◆ m_terminated

bool m_terminated = false
privateinherited

Flag to keep track whether termination happened before.

Definition at line 55 of file ProcessingSignalListener.h.


The documentation for this class was generated from the following files: