Belle II Software  release-08-01-10
AsicBackgroundDetector Class Referenceabstract

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

#include <AsicBackgroundDetector.h>

Inheritance diagram for AsicBackgroundDetector:
Collaboration diagram for AsicBackgroundDetector:

Public Types

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

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. More...
 

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 happend before.
 
bool m_terminated = false
 Flag to keep track whether termination happend 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 Function Documentation

◆ 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 
105  if (m_max_asic_error_messages > 0) {
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
std::map< int, std::pair< int, int > > m_map
map from ewire to board/channel ID
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.

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